MCPcopy
hub / github.com/codeaashu/claude-code / logMemoryDirCounts

Function logMemoryDirCounts

src/memdir/memdir.ts:153–185  ·  view source on GitHub ↗

* Log memory directory file/subdir counts asynchronously. * Fire-and-forget — doesn't block prompt building.

(
  memoryDir: string,
  baseMetadata: Record<
    string,
    | number
    | boolean
    | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
  >,
)

Source from the content-addressed store, hash-verified

151 * Fire-and-forget — doesn't block prompt building.
152 */
153function logMemoryDirCounts(
154 memoryDir: string,
155 baseMetadata: Record<
156 string,
157 | number
158 | boolean
159 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
160 >,
161): void {
162 const fs = getFsImplementation()
163 void fs.readdir(memoryDir).then(
164 dirents => {
165 let fileCount = 0
166 let subdirCount = 0
167 for (const d of dirents) {
168 if (d.isFile()) {
169 fileCount++
170 } else if (d.isDirectory()) {
171 subdirCount++
172 }
173 }
174 logEvent('tengu_memdir_loaded', {
175 ...baseMetadata,
176 total_file_count: fileCount,
177 total_subdir_count: subdirCount,
178 })
179 },
180 () => {
181 // Directory unreadable — log without counts
182 logEvent('tengu_memdir_loaded', baseMetadata)
183 },
184 )
185}
186
187/**
188 * Build the typed-memory behavioral instructions (without MEMORY.md content).

Callers 2

buildMemoryPromptFunction · 0.85
loadMemoryPromptFunction · 0.85

Calls 2

getFsImplementationFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected