@krisada-m/ksd-intelligence 0.0.0-stage → 1.1.0

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 (119) hide show
  1. package/.antigravity-plugin/plugin.json +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +195 -2
  4. package/agy-skills/erosiano-review/SKILL.md +17 -0
  5. package/dist/adapters/agy/skills.js +252 -0
  6. package/dist/adapters/cli/check-changed.js +3 -0
  7. package/dist/adapters/cli/main.js +1013 -0
  8. package/dist/adapters/cli/policy-bin.js +10 -0
  9. package/dist/adapters/cli/review-verdict.js +3 -0
  10. package/dist/adapters/omp/extension.js +884 -0
  11. package/dist/adapters/omp/skills.js +130 -0
  12. package/dist/adapters/ui/hud.js +389 -0
  13. package/dist/adapters/ui/tree.js +471 -0
  14. package/dist/core/audit/index.js +2 -0
  15. package/dist/core/audit/log.js +505 -0
  16. package/dist/core/audit/summary.js +188 -0
  17. package/dist/core/changes/changes.js +591 -0
  18. package/dist/core/changes/git.js +266 -0
  19. package/dist/core/changes/plan.js +109 -0
  20. package/dist/core/changes/render.js +356 -0
  21. package/dist/core/engine/build.js +178 -0
  22. package/dist/core/engine/child.js +389 -0
  23. package/dist/core/engine/host.js +206 -0
  24. package/dist/core/engine/lock.js +133 -0
  25. package/dist/core/engine/protocol.js +43 -0
  26. package/dist/core/engine/runtime.js +44 -0
  27. package/dist/core/engine/status.js +452 -0
  28. package/dist/core/engine/typescript.js +194 -0
  29. package/dist/core/engine/workspace.js +72 -0
  30. package/dist/core/graph/graph.js +127 -0
  31. package/dist/core/graph/limits.js +16 -0
  32. package/dist/core/impact/query.js +1292 -0
  33. package/dist/core/impact/render.js +590 -0
  34. package/dist/core/impact/session.js +694 -0
  35. package/dist/core/indexing/declarations.js +455 -0
  36. package/dist/core/indexing/differential.js +345 -0
  37. package/dist/core/indexing/doctor.js +120 -0
  38. package/dist/core/indexing/indexer.js +811 -0
  39. package/dist/core/indexing/keys.js +451 -0
  40. package/dist/core/indexing/lexical.js +212 -0
  41. package/dist/core/indexing/packages.js +57 -0
  42. package/dist/core/indexing/program.js +171 -0
  43. package/dist/core/indexing/resolve.js +1004 -0
  44. package/dist/core/indexing/stamp.js +52 -0
  45. package/dist/core/indexing/surface.js +335 -0
  46. package/dist/core/indexing/ui-progress.js +37 -0
  47. package/dist/core/indexing/verify.js +76 -0
  48. package/dist/core/kernel/config.js +383 -0
  49. package/dist/core/kernel/glob.js +105 -0
  50. package/dist/core/kernel/guards.js +4 -0
  51. package/dist/core/kernel/types.js +3 -0
  52. package/dist/core/kernel/verdict.js +142 -0
  53. package/dist/core/knowledge/anchors.js +139 -0
  54. package/dist/core/knowledge/knowledge.js +95 -0
  55. package/dist/core/knowledge/learning.js +102 -0
  56. package/dist/core/knowledge/render.js +76 -0
  57. package/dist/core/knowledge/store.js +109 -0
  58. package/dist/core/knowledge/yaml.js +87 -0
  59. package/dist/core/search/lexical.js +382 -0
  60. package/dist/core/search/render.js +98 -0
  61. package/dist/core/search/segments.js +118 -0
  62. package/dist/core/verify/parse.js +127 -0
  63. package/dist/core/verify/render.js +67 -0
  64. package/dist/core/verify/report.js +40 -0
  65. package/dist/core/verify/revision.js +79 -0
  66. package/dist/core/verify/run.js +117 -0
  67. package/dist/core/verify/store.js +66 -0
  68. package/dist/core/verify/verify.js +173 -0
  69. package/dist/core/workspace/init.js +267 -0
  70. package/dist/core/workspace/probe.js +56 -0
  71. package/dist/core/workspace/scan.js +420 -0
  72. package/dist/engineering/baseline.js +337 -0
  73. package/dist/engineering/change-scope.js +500 -0
  74. package/dist/engineering/check-changed.js +40 -0
  75. package/dist/engineering/config.js +129 -0
  76. package/dist/engineering/dist/policy.d.ts +17 -0
  77. package/dist/engineering/dist/policy.js +150 -0
  78. package/dist/engineering/dist/runtime.d.ts +40 -0
  79. package/dist/engineering/dist/runtime.js +77 -0
  80. package/dist/engineering/dist/sdlc.d.ts +7 -0
  81. package/dist/engineering/dist/sdlc.js +27 -0
  82. package/dist/engineering/eslint-rules/index.js +107 -0
  83. package/dist/engineering/index.d.ts +7 -0
  84. package/dist/engineering/index.js +319 -0
  85. package/dist/engineering/intelligence.js +44 -0
  86. package/dist/engineering/package.json +36 -0
  87. package/dist/engineering/policy.js +2 -0
  88. package/dist/engineering/practice-tool.js +72 -0
  89. package/dist/engineering/practices.js +283 -0
  90. package/dist/engineering/practices.json +2453 -0
  91. package/dist/engineering/review-verdict.js +262 -0
  92. package/dist/engineering/sdlc.js +2 -0
  93. package/dist/index.js +20 -0
  94. package/dist/storage/records.js +245 -0
  95. package/dist/storage/sqlite.js +314 -0
  96. package/dist/workflow/catalog.js +69 -0
  97. package/dist/workflow/classify.js +55 -0
  98. package/dist/workflow/loader.js +140 -0
  99. package/dist/workflow/packs.js +469 -0
  100. package/dist/workflow/registry.js +359 -0
  101. package/dist/workflow/render.js +61 -0
  102. package/dist/workflow/router.js +141 -0
  103. package/dist/workflow/sources.js +229 -0
  104. package/dist/workflow/types.js +44 -0
  105. package/dist/workflow/updates.js +532 -0
  106. package/engineering.lock.json +94 -0
  107. package/package.json +81 -4
  108. package/rules/engineering.md +20 -0
  109. package/scripts/agy-mcp.mjs +27 -0
  110. package/scripts/mcp/engineering.mjs +91 -0
  111. package/scripts/mcp/stdio.mjs +304 -0
  112. package/scripts/mcp/tools.mjs +491 -0
  113. package/skills/ksd-intelligence/SKILL.md +54 -0
  114. package/skills/matt-sdlc/SKILL.md +42 -0
  115. package/skills/osmani-quality/SKILL.md +38 -0
  116. package/skills/poteto-mode/SKILL.md +40 -0
  117. package/skills/pstack-analysis/SKILL.md +36 -0
  118. package/skills.lock.json +71 -0
  119. package/skills.registry.json +181 -0
@@ -0,0 +1,337 @@
1
+ #!/usr/bin/env node
2
+ import { closeSync, constants, fstatSync, lstatSync, openSync, opendirSync, readSync, realpathSync } from "node:fs";
3
+ import { createHash } from "node:crypto";
4
+ import { spawnSync } from "node:child_process";
5
+ import { devNull } from "node:os";
6
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const MAX_FILES = 64;
10
+ const MAX_ADDITIONAL_PATHS = 24;
11
+ const MAX_FILE_BYTES = 128 * 1024;
12
+ const MAX_DIRECTORY_ENTRIES = 256;
13
+ const KNOWN_FILES = [
14
+ "AGENTS.md", "README.md", "CONTRIBUTING.md", "package.json", "tsconfig.json", "jsconfig.json",
15
+ "eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", ".eslintrc.json", "biome.json", "biome.jsonc",
16
+ ".prettierrc", ".prettierrc.json", "vitest.config.ts", "vitest.config.js", "jest.config.js", "jest.config.ts",
17
+ ".erosiano-dev.json", ".engineering-proxy.json", ".editorconfig", "turbo.json", "nx.json", "tsconfig.base.json",
18
+ "Makefile", "Dockerfile", "compose.yml", "compose.yaml", "docker-compose.yml", "docker-compose.yaml",
19
+ "pnpm-workspace.yaml", "package-lock.json", "pnpm-lock.yaml", "yarn.lock", "bun.lock",
20
+ "pyproject.toml", "requirements.txt", "go.mod", "Cargo.toml", "Gemfile", "composer.json", "pom.xml",
21
+ ];
22
+ const SKIP_DIRECTORIES = new Set([".git", "node_modules", ".venv", "vendor", "dist", "build", ".cache", ".omp", ".next"]);
23
+ const SOURCE_FILE = /\.(?:[cm]?[jt]sx?|py|go|rs|java|kt|cs|rb|php|sql|css|html|vue|svelte)$/i;
24
+ const SECRET_NAME = /(?:^\.env(?:\.|$)|(?:credential|secret|password|token|private.?key)|\.(?:pem|key|p12|pfx)$)/i;
25
+ const CONTROL = /[\u0000-\u001f\u007f]/;
26
+ const EXPLICIT_EVIDENCE = /\.(?:md|jsonc?|ya?ml|toml|ini|xml|sh)$/i;
27
+
28
+ function supportedEvidence(path) {
29
+ const name = basename(path);
30
+
31
+ return SOURCE_FILE.test(name) || KNOWN_FILES.includes(name) || EXPLICIT_EVIDENCE.test(name);
32
+ }
33
+
34
+ const sha256 = data => createHash("sha256").update(data).digest("hex");
35
+
36
+ function within(root, path) {
37
+ const rel = relative(root, path);
38
+
39
+ return rel === "" || (!isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." + sep));
40
+ }
41
+
42
+ function info(path) {
43
+ try {
44
+ return lstatSync(path);
45
+ } catch (error) {
46
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return null;
47
+ throw error;
48
+ }
49
+ }
50
+
51
+ function safePath(root, requested) {
52
+ if (typeof requested !== "string" || !requested || CONTROL.test(requested)) throw new Error("Invalid scope path");
53
+ const path = resolve(root, requested);
54
+ if (!within(root, path)) throw new Error("Scope is outside the project root");
55
+ const rel = relative(root, path);
56
+ let current = root;
57
+ for (const part of rel.split(sep).filter(Boolean)) {
58
+ if (SECRET_NAME.test(part) || SKIP_DIRECTORIES.has(part)) throw new Error("Excluded scope path");
59
+ current = join(current, part);
60
+ const metadata = info(current);
61
+ if (!metadata || metadata.isSymbolicLink()) throw new Error("Missing or symlinked scope path");
62
+ }
63
+
64
+ return path;
65
+ }
66
+
67
+ /** Read only bounded regular files at their canonical in-root paths. Never emit file contents. */
68
+ function boundedRead(root, path) {
69
+ const metadata = info(path);
70
+ if (!metadata) return { status: "absent" };
71
+ if (!metadata.isFile() || metadata.isSymbolicLink() || !within(root, path) || realpathSync(path) !== path) return { status: "excluded" };
72
+ if (metadata.size > MAX_FILE_BYTES) return { status: "oversize" };
73
+
74
+ const fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
75
+ try {
76
+ const before = fstatSync(fd);
77
+ if (!before.isFile() || before.size > MAX_FILE_BYTES || before.ino !== metadata.ino || before.dev !== metadata.dev) return { status: "changed" };
78
+ const buffer = Buffer.alloc(MAX_FILE_BYTES + 1);
79
+ let length = 0;
80
+ while (length < buffer.length) {
81
+ const read = readSync(fd, buffer, length, buffer.length - length, null);
82
+ if (!read) break;
83
+ length += read;
84
+ }
85
+ const after = fstatSync(fd);
86
+ if (length > MAX_FILE_BYTES || before.size !== length || before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs) return { status: "changed" };
87
+
88
+ return { status: "read", bytes: buffer.subarray(0, length) };
89
+ } finally {
90
+ closeSync(fd);
91
+ }
92
+ }
93
+
94
+ function revision(root) {
95
+ try {
96
+ const gitDir = info(join(root, ".git"));
97
+ if (!gitDir?.isDirectory() || gitDir.isSymbolicLink()) return { status: "unknown", reason: "No local Git metadata directory (linked worktrees require agent evidence)" };
98
+ const head = boundedRead(root, join(root, ".git", "HEAD"));
99
+ if (head.status !== "read") return { status: "unknown", reason: "HEAD unavailable" };
100
+ const value = head.bytes.toString("utf8").trim();
101
+ if (/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(value)) return { status: "observed", head: value, branch: null };
102
+ const match = /^ref: (refs\/heads\/[A-Za-z0-9._/-]+)$/.exec(value);
103
+ if (!match || match[1].split("/").some(part => part === "." || part === ".." || part === "")) return { status: "unknown", reason: "Unsupported HEAD reference" };
104
+ const ref = boundedRead(root, join(root, ".git", match[1]));
105
+ let commit = ref.status === "read" ? ref.bytes.toString("utf8").trim() : undefined;
106
+ if (ref.status === "absent") {
107
+ const packed = boundedRead(root, join(root, ".git", "packed-refs"));
108
+ const line = packed.status === "read" ? packed.bytes.toString("utf8").split("\n").find(entry => entry.endsWith(" " + match[1])) : undefined;
109
+ commit = line?.split(" ")[0];
110
+ }
111
+ if (!commit || !/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(commit)) return { status: "unknown", reason: "Branch reference unavailable" };
112
+
113
+ return { status: "observed", head: commit, branch: match[1] };
114
+ } catch {
115
+ return { status: "unknown", reason: "Git metadata unreadable" };
116
+ }
117
+ }
118
+
119
+ // Opt-in only for the operator-invoked CLI. Never invoked during an ordinary agent turn.
120
+ // Git handles its own linked-worktree metadata. No shell, no repository hooks or inherited GIT_* overrides.
121
+ function nativeRevision(root) {
122
+ const env = {
123
+ PATH: process.env.PATH ?? "/usr/bin:/bin",
124
+ GIT_CONFIG_NOSYSTEM: "1",
125
+ GIT_CONFIG_GLOBAL: devNull,
126
+ GIT_OPTIONAL_LOCKS: "0",
127
+ GIT_TERMINAL_PROMPT: "0",
128
+ };
129
+ const run = args => spawnSync("git", ["-C", root, ...args], { env, encoding: "utf8", timeout: 2000, maxBuffer: 16384, shell: false });
130
+ try {
131
+ const result = run(["rev-parse", "--show-toplevel", "HEAD"]);
132
+ if (result.error || result.status !== 0) return { status: "unknown", reason: "Native Git revision unavailable" };
133
+ const [top, head, ...rest] = result.stdout.trimEnd().split("\n");
134
+ if (rest.length || !top || CONTROL.test(top) || realpathSync(top) !== root || !/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(head ?? "")) {
135
+ return { status: "unknown", reason: "Native Git root or revision did not match" };
136
+ }
137
+ const symbolic = run(["symbolic-ref", "--quiet", "HEAD"]);
138
+ if (symbolic.error) return { status: "unknown", reason: "Native Git branch unavailable" };
139
+ const branch = symbolic.status === 0 ? symbolic.stdout.trim() : null;
140
+ if (symbolic.status !== 0 && symbolic.status !== 1) return { status: "unknown", reason: "Native Git branch unavailable" };
141
+ if (branch !== null && !/^refs\/heads\/[A-Za-z0-9._/-]+$/.test(branch)) return { status: "unknown", reason: "Unsupported native Git reference" };
142
+
143
+ return { status: "observed", head, branch };
144
+ } catch {
145
+ return { status: "unknown", reason: "Native Git metadata unreadable" };
146
+ }
147
+ }
148
+
149
+ function directorySample(path) {
150
+ const dir = opendirSync(path);
151
+ const entries = [];
152
+ let scanned = 0;
153
+ let truncated = false;
154
+ try {
155
+ while (true) {
156
+ const entry = dir.readSync();
157
+ if (!entry) break;
158
+ scanned++;
159
+ if (scanned > MAX_DIRECTORY_ENTRIES) {
160
+ truncated = true;
161
+ break;
162
+ }
163
+ if (CONTROL.test(entry.name) || SECRET_NAME.test(entry.name) || SKIP_DIRECTORIES.has(entry.name)) continue;
164
+ const kind = entry.isFile() ? "file" : entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : "other";
165
+ entries.push({ name: entry.name, kind });
166
+ }
167
+ } finally {
168
+ dir.closeSync();
169
+ }
170
+ entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
171
+
172
+ return { entries, truncated };
173
+ }
174
+
175
+ function role(path) {
176
+ const name = basename(path);
177
+ if (["AGENTS.md", "README.md", "CONTRIBUTING.md"].includes(name)) return "instruction";
178
+ if (KNOWN_FILES.includes(name) || path.split(sep).includes("workflows")) return "tooling";
179
+ if (/(?:^|[.])(?:test|spec)\.[^.]+$/.test(name)) return "test";
180
+
181
+ return "source";
182
+ }
183
+
184
+ /** A bounded snapshot of sampled evidence, not an inferred or complete project convention baseline. */
185
+ export function collectBaselineEvidence({ root, scope = ".", additionalPaths = [], useGit = false }) {
186
+ if (typeof root !== "string" || !root || typeof scope !== "string" || !scope) throw new Error("Expected project root and scope");
187
+ if (!Array.isArray(additionalPaths) || additionalPaths.length > MAX_ADDITIONAL_PATHS) throw new Error("Too many explicit evidence paths");
188
+ if (typeof useGit !== "boolean") throw new Error("Invalid native Git option");
189
+
190
+ const requestedRoot = resolve(root);
191
+ const canonicalRoot = realpathSync(requestedRoot);
192
+ if (!info(canonicalRoot)?.isDirectory()) throw new Error("Project root must be a directory");
193
+ // Absolute cwd values can use a symlink alias of the operator-selected root (not a scope symlink).
194
+ const scoped = isAbsolute(scope) && within(requestedRoot, resolve(scope)) ? relative(requestedRoot, resolve(scope)) || "." : scope;
195
+ const target = safePath(canonicalRoot, scoped);
196
+ const targetInfo = info(target);
197
+ if (!targetInfo?.isFile() && !targetInfo?.isDirectory()) throw new Error("Scope must be a file or directory");
198
+ if (targetInfo.isFile() && !supportedEvidence(target)) throw new Error("Unsupported evidence file type");
199
+
200
+ const targetDirectory = targetInfo.isDirectory() ? target : dirname(target);
201
+ const evidence = [];
202
+ const unknowns = [];
203
+ const candidates = new Set();
204
+ const readRevision = useGit ? nativeRevision : revision;
205
+ const revisionBefore = readRevision(canonicalRoot);
206
+ if (targetInfo.isFile()) candidates.add(target);
207
+ // Callers, test files and CI/tooling beyond the direct sample must be explicit and bounded.
208
+ const explicit = new Set();
209
+ for (const requested of additionalPaths) {
210
+ if (typeof requested !== "string" || isAbsolute(requested)) throw new Error("Additional evidence paths must be relative to the project root");
211
+ const path = safePath(canonicalRoot, requested);
212
+ if (!info(path)?.isFile() || !supportedEvidence(path)) throw new Error("Unsupported additional evidence file");
213
+ explicit.add(relative(canonicalRoot, path));
214
+ candidates.add(path);
215
+ }
216
+ let current = targetDirectory;
217
+ while (true) {
218
+ for (const name of KNOWN_FILES) {
219
+ if (candidates.size >= MAX_FILES) {
220
+ unknowns.push("Evidence file cap reached");
221
+ break;
222
+ }
223
+ const path = join(current, name);
224
+ try {
225
+ if (info(path)) candidates.add(path);
226
+ } catch {
227
+ unknowns.push("Tooling evidence inaccessible");
228
+ }
229
+ }
230
+ if (current === canonicalRoot || candidates.size >= MAX_FILES) break;
231
+ current = dirname(current);
232
+ }
233
+ let directory;
234
+ try {
235
+ const sample = directorySample(targetDirectory);
236
+ directory = { path: relative(canonicalRoot, targetDirectory) || ".", fingerprint: sha256(JSON.stringify(sample.entries)), count: sample.entries.length, truncated: sample.truncated };
237
+ if (sample.truncated) unknowns.push("Directory inventory truncated");
238
+ for (const entry of sample.entries) {
239
+ if (!SOURCE_FILE.test(entry.name)) continue;
240
+ if (entry.kind !== "file") {
241
+ unknowns.push("Nonregular source evidence excluded");
242
+ continue;
243
+ }
244
+ if (candidates.size >= MAX_FILES) {
245
+ unknowns.push("Source sample cap reached");
246
+ break;
247
+ }
248
+ candidates.add(join(targetDirectory, entry.name));
249
+ }
250
+ } catch {
251
+ unknowns.push("Directory inventory unavailable");
252
+ }
253
+ for (const path of [...candidates].sort()) {
254
+ const rel = relative(canonicalRoot, path);
255
+ try {
256
+ const result = boundedRead(canonicalRoot, path);
257
+ if (result.status !== "read") {
258
+ unknowns.push("Evidence " + result.status + ": " + rel);
259
+ continue;
260
+ }
261
+ evidence.push({ path: rel, role: role(path), sha256: sha256(result.bytes), bytes: result.bytes.length });
262
+ } catch {
263
+ unknowns.push("Evidence unreadable: " + rel);
264
+ }
265
+ }
266
+ const revisionAfter = readRevision(canonicalRoot);
267
+ if (revisionBefore.status !== "observed" || revisionAfter.status !== "observed" || JSON.stringify(revisionBefore) !== JSON.stringify(revisionAfter)) unknowns.push("Git revision unavailable or changed during discovery");
268
+ const record = { schemaVersion: 1, root: canonicalRoot, scope: relative(canonicalRoot, target) || ".", revision: revisionAfter,
269
+ additionalPaths: [...explicit].sort(), revisionSource: useGit ? "native-git" : "local-metadata",
270
+ evidence, directory, unknowns: [...new Set(unknowns)], confidence: "LOW", coverage: "SAMPLED_EVIDENCE_ONLY" };
271
+ const fingerprint = sha256(JSON.stringify(record));
272
+
273
+ return { ...record, fingerprint, cacheable: record.unknowns.length === 0 };
274
+ }
275
+
276
+ export class ScopedBaselineCache {
277
+ #entries = new Map();
278
+
279
+ capture(input) {
280
+ const snapshot = collectBaselineEvidence(input);
281
+ const key = JSON.stringify([snapshot.root, snapshot.scope, snapshot.additionalPaths, snapshot.revisionSource]);
282
+ const previous = this.#entries.get(key);
283
+ const matched = snapshot.cacheable && previous?.cacheable && previous.fingerprint === snapshot.fingerprint;
284
+ this.#entries.delete(key);
285
+ if (snapshot.cacheable) this.#entries.set(key, snapshot);
286
+ if (this.#entries.size > 16) this.#entries.delete(this.#entries.keys().next().value);
287
+
288
+ return { ...snapshot, freshness: matched ? "MATCHED_SCOPED_EVIDENCE" : "NEW_OR_INCOMPLETE_EVIDENCE" };
289
+ }
290
+
291
+ clear() {
292
+ this.#entries.clear();
293
+ }
294
+ }
295
+
296
+ export function summarizeBaselineEvidence(record) {
297
+ const paths = record.evidence.slice(0, 12).map(item => item.path);
298
+
299
+ return JSON.stringify({ scope: record.scope, revision: record.revision, sampled: record.evidence.length, examplePaths: paths,
300
+ fingerprint: record.fingerprint, freshness: record.freshness, confidence: record.confidence, unknowns: record.unknowns.slice(0, 8),
301
+ limitation: "Only sampled bytes and direct directory inventory matched, not all dirty/untracked files, callers, or conventions. Discover remaining evidence through approved tools." });
302
+ }
303
+
304
+ function main(args) {
305
+ const usage = "Usage: erosiano-baseline --root project --scope relative-path [--include relative-file]... [--git]";
306
+ if (args.length < 4 || args[0] !== "--root" || args[2] !== "--scope") throw new Error(usage);
307
+ const additionalPaths = [];
308
+ let useGit = false;
309
+ for (let i = 4; i < args.length; i++) {
310
+ if (args[i] === "--git" && !useGit) {
311
+ useGit = true;
312
+ continue;
313
+ }
314
+ if (args[i] !== "--include" || i + 1 >= args.length || args[i + 1].startsWith("--")) throw new Error(usage);
315
+ additionalPaths.push(args[++i]);
316
+ }
317
+ console.log(JSON.stringify(collectBaselineEvidence({ root: args[1], scope: args[3], additionalPaths, useGit }), null, 2));
318
+ }
319
+
320
+ function isMainModule() {
321
+ try {
322
+ if (!process.argv[1]) return false;
323
+
324
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
325
+ } catch {
326
+ return false;
327
+ }
328
+ }
329
+
330
+ if (isMainModule()) {
331
+ try {
332
+ main(process.argv.slice(2));
333
+ } catch (error) {
334
+ console.error("Baseline evidence NOT_ASSESSED: " + error.message);
335
+ process.exitCode = 2;
336
+ }
337
+ }