pi-doc-injector 0.5.2 → 0.5.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/registry.ts +28 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-doc-injector",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Auto-inject relevant project documentation into Pi's LLM context based on keyword matching",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/registry.ts CHANGED
@@ -232,6 +232,12 @@ export class DocRegistry {
232
232
  private cache: KeywordCache | null = null;
233
233
  private dirtyCache: KeywordCache = { version: 1, files: {} };
234
234
  private notifier: Notifier;
235
+ // Per-registry flag: warn about a missing docs folder at most once.
236
+ // rebuild() is called twice at startup (once from session_start, once
237
+ // from resources_discover); without this flag the user sees the
238
+ // same warning twice. Not reset across rebuilds — a missing folder
239
+ // is a persistent condition, not a transient one.
240
+ private warnedMissingDocs = false;
235
241
 
236
242
  private constructor(
237
243
  docsPath: string,
@@ -268,6 +274,21 @@ export class DocRegistry {
268
274
  // Start with a fresh dirty cache — only files that changed get added
269
275
  this.dirtyCache = { version: 1, files: {} };
270
276
 
277
+ // Pre-check folder existence. The previous catch-all "Docs folder not
278
+ // found" warning was misleading (it also fired for scan errors) and was
279
+ // emitted twice at startup (once from session_start, once from
280
+ // resources_discover). The warnedMissingDocs flag deduplicates across
281
+ // rebuilds for the lifetime of this registry.
282
+ const folderStat = await stat(resolved).catch(() => null);
283
+ if (!folderStat || !folderStat.isDirectory()) {
284
+ if (!this.warnedMissingDocs) {
285
+ this.notifier.warn(`[doc-injector] Docs folder not found: ${resolved}`);
286
+ this.warnedMissingDocs = true;
287
+ }
288
+ this.entries = [];
289
+ return;
290
+ }
291
+
271
292
  try {
272
293
  const scanResults = this.config.recursive
273
294
  ? await this.scanRecursive(resolved)
@@ -282,8 +303,13 @@ export class DocRegistry {
282
303
 
283
304
  const results = await pool.all(tasks);
284
305
  this.entries = results.filter((e): e is DocEntry => e !== null);
285
- } catch {
286
- this.notifier.warn(`[doc-injector] Docs folder not found: ${resolved}`);
306
+ } catch (err) {
307
+ // This catch now only fires for actual scan errors (not folder-missing).
308
+ this.notifier.warn(
309
+ `[doc-injector] Error scanning docs folder ${resolved}: ${
310
+ err instanceof Error ? err.message : String(err)
311
+ }`,
312
+ );
287
313
  this.entries = [];
288
314
  }
289
315
  }