project-librarian 0.4.0 → 0.4.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.
@@ -43,27 +43,13 @@ exports.smallRepoCodeIndexGate = smallRepoCodeIndexGate;
43
43
  const childProcess = __importStar(require("node:child_process"));
44
44
  const fs = __importStar(require("node:fs"));
45
45
  const path = __importStar(require("node:path"));
46
+ const path_ignore_policy_1 = require("./path-ignore-policy");
46
47
  const workspace_1 = require("./workspace");
47
48
  // Single source of truth for the disposable code-evidence directory name. Both
48
49
  // the heavy code-index module and the light bootstrap path (hooks.ts) key off
49
50
  // this; keeping it here avoids loading typescript/node:sqlite during bootstrap.
50
51
  exports.codeEvidenceDirectory = ".project-wiki";
51
- exports.ignoredDirectories = new Set([
52
- ".git",
53
- ".codex",
54
- ".claude",
55
- ".cursor",
56
- ".gemini",
57
- exports.codeEvidenceDirectory,
58
- "node_modules",
59
- ".next",
60
- "dist",
61
- "build",
62
- "coverage",
63
- "vendor",
64
- "tmp",
65
- "temp",
66
- ]);
52
+ exports.ignoredDirectories = (0, path_ignore_policy_1.ignoredDirectorySet)([exports.codeEvidenceDirectory]);
67
53
  const languageByExtension = {
68
54
  ".c": "c",
69
55
  ".cc": "cpp",
@@ -123,10 +109,7 @@ function shouldIndexFile(relativePath) {
123
109
  return ["Dockerfile", "Makefile", "package.json", "tsconfig.json"].includes(base);
124
110
  }
125
111
  function isIgnoredCodePath(relativePath) {
126
- return (0, workspace_1.normalizePath)(relativePath)
127
- .split("/")
128
- .filter(Boolean)
129
- .some((part) => exports.ignoredDirectories.has(part));
112
+ return (0, path_ignore_policy_1.pathContainsIgnoredDirectory)(relativePath, exports.ignoredDirectories);
130
113
  }
131
114
  // Mirrors normalizeProjectRelative in code-index.ts for git ls-files output, but
132
115
  // throws instead of exiting so the light bootstrap path can use discovery too.
@@ -180,16 +163,27 @@ function gitTrackedAndUnignoredFiles(scopes) {
180
163
  return null;
181
164
  }
182
165
  }
166
+ function indexableFileStat(file) {
167
+ try {
168
+ const stat = fs.statSync((0, workspace_1.abs)(file));
169
+ return stat.isFile() ? stat : null;
170
+ }
171
+ catch {
172
+ return null;
173
+ }
174
+ }
183
175
  function discoverCodeFiles(scopes) {
184
176
  const gitFiles = gitTrackedAndUnignoredFiles(scopes);
185
177
  const candidates = gitFiles ?? scopes.flatMap((scope) => walkCodeFiles(scope));
186
- return Array.from(new Set(candidates))
187
- .filter((file) => !isIgnoredCodePath(file))
188
- .filter((file) => fs.existsSync((0, workspace_1.abs)(file)))
189
- .filter((file) => fs.statSync((0, workspace_1.abs)(file)).isFile())
190
- .filter((file) => shouldIndexFile(file))
191
- .filter((file) => fs.statSync((0, workspace_1.abs)(file)).size <= exports.maxIndexedBytes)
192
- .sort();
178
+ const files = [];
179
+ for (const file of Array.from(new Set(candidates))) {
180
+ if (isIgnoredCodePath(file) || !shouldIndexFile(file))
181
+ continue;
182
+ const stat = indexableFileStat(file);
183
+ if (stat && stat.size <= exports.maxIndexedBytes)
184
+ files.push(file);
185
+ }
186
+ return files.sort();
193
187
  }
194
188
  // --- Scale-aware code-evidence gate ------------------------------------------
195
189
  //