claude-brain 0.25.1 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.25.1
1
+ 0.25.2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-brain",
3
- "version": "0.25.1",
3
+ "version": "0.25.2",
4
4
  "description": "Local development assistant bridging Obsidian vaults with Claude Code via MCP",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -83,6 +83,7 @@ export async function runReindex() {
83
83
 
84
84
  const parser = new CodeParser()
85
85
  await parser.initialize()
86
+ console.log(dimText(' Parser initialized'))
86
87
 
87
88
  const indexer = new CodeIndexer(codeDb, parser, logger)
88
89
  await indexer.initialize()
@@ -94,7 +95,19 @@ export async function runReindex() {
94
95
  }
95
96
 
96
97
  const result = await indexer.indexProject(projectPath, projectName)
97
- console.log(successText(` Reindex complete: ${result.filesIndexed ?? 0} files, ${result.symbolsFound ?? 0} symbols`))
98
+ const files = result.filesIndexed ?? 0
99
+ const symbols = result.symbolsFound ?? 0
100
+ const skipped = result.filesSkipped ?? 0
101
+
102
+ if (files === 0 && skipped === 0) {
103
+ console.log(warningText(` No supported files found in project.`))
104
+ console.log(dimText(` Supported: .ts .tsx .js .jsx .mjs .cjs .py .go .rs .vue .html .css .json .yaml .yml`))
105
+ if (result.errors && result.errors.length > 0) {
106
+ console.log(warningText(` Errors: ${result.errors.slice(0, 3).join('; ')}`))
107
+ }
108
+ } else {
109
+ console.log(successText(` Reindex complete: ${files} files, ${symbols} symbols` + (skipped > 0 ? ` (${skipped} unchanged)` : '')))
110
+ }
98
111
  codeDb.close()
99
112
  } catch (error) {
100
113
  console.log(box(
@@ -190,6 +190,10 @@ export class CodeIndexer {
190
190
  private async collectFiles(dirPath: string): Promise<string[]> {
191
191
  const files: string[] = []
192
192
  await this.walkDirectory(dirPath, files)
193
+ if (files.length === 0) {
194
+ this.logger.warn({ dirPath }, 'collectFiles returned 0 files — trying fallback without withFileTypes')
195
+ await this.walkDirectoryFallback(dirPath, files)
196
+ }
193
197
  return files
194
198
  }
195
199
 
@@ -197,8 +201,9 @@ export class CodeIndexer {
197
201
  let entries
198
202
  try {
199
203
  entries = await readdir(dirPath, { withFileTypes: true })
200
- } catch {
201
- return // Skip unreadable directories
204
+ } catch (error) {
205
+ this.logger.debug({ dirPath, error: error instanceof Error ? error.message : String(error) }, 'Cannot read directory')
206
+ return
202
207
  }
203
208
 
204
209
  for (const entry of entries) {
@@ -215,6 +220,38 @@ export class CodeIndexer {
215
220
  }
216
221
  }
217
222
 
223
+ /** Fallback walker that uses readdir (names only) + stat — works on all platforms */
224
+ private async walkDirectoryFallback(dirPath: string, files: string[]): Promise<void> {
225
+ let names: string[]
226
+ try {
227
+ names = await readdir(dirPath)
228
+ } catch (error) {
229
+ this.logger.debug({ dirPath, error: error instanceof Error ? error.message : String(error) }, 'Fallback: cannot read directory')
230
+ return
231
+ }
232
+
233
+ for (const name of names) {
234
+ const fullPath = join(dirPath, name)
235
+ let fileStat
236
+ try {
237
+ fileStat = await stat(fullPath)
238
+ } catch {
239
+ continue
240
+ }
241
+
242
+ if (fileStat.isDirectory()) {
243
+ if (!SKIP_DIRS.has(name)) {
244
+ await this.walkDirectoryFallback(fullPath, files)
245
+ }
246
+ } else if (fileStat.isFile()) {
247
+ if (SKIP_FILES.has(name)) continue
248
+ const ext = extname(name).toLowerCase()
249
+ if (!SUPPORTED_EXTENSIONS.has(ext)) continue
250
+ files.push(fullPath)
251
+ }
252
+ }
253
+ }
254
+
218
255
  private async indexSingleFile(
219
256
  filePath: string,
220
257
  projectPath: string,