knodin 0.7.4 → 0.7.6

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 (104) hide show
  1. package/README.md +4 -1
  2. package/dist/bin/cli.js +108 -1859
  3. package/dist/bin/launcher.js +3 -10
  4. package/dist/chunks/chunk-DMQAGX77.js +654 -0
  5. package/dist/chunks/chunk-F4Z3Z766.js +4 -0
  6. package/dist/chunks/chunk-SIJAQVSX.js +3 -0
  7. package/dist/chunks/chunk-X6M4HUUE.js +2 -0
  8. package/dist/chunks/chunk-YPRMY2LP.js +8 -0
  9. package/dist/chunks/pure-compression-cli-4TA2TQD5.js +5 -0
  10. package/dist/chunks/server-7EDF4CBY.js +14 -0
  11. package/dist/chunks/structural-fast-path-KD5KQSPX.js +4 -0
  12. package/dist/src/init-progress-worker.js +2 -106
  13. package/dist/src/repair-progress-worker.js +2 -120
  14. package/docs/INSTALLATION.md +17 -1
  15. package/docs/releases/0.7.6.md +25 -0
  16. package/package.json +1 -110
  17. package/dist/src/agent-integration.js +0 -238
  18. package/dist/src/artifact-refresh.js +0 -81
  19. package/dist/src/cli-args.js +0 -274
  20. package/dist/src/cli-model.js +0 -358
  21. package/dist/src/codeflow-replay.js +0 -80
  22. package/dist/src/compact-structural.js +0 -96
  23. package/dist/src/competitive-cold-mcp.js +0 -40
  24. package/dist/src/competitive-constraints.js +0 -20
  25. package/dist/src/competitive-manifest.js +0 -411
  26. package/dist/src/competitive-measurement.js +0 -183
  27. package/dist/src/competitive-runner.js +0 -487
  28. package/dist/src/competitive-sandbox.js +0 -108
  29. package/dist/src/context-export.js +0 -422
  30. package/dist/src/context.js +0 -102
  31. package/dist/src/diagnostics.js +0 -449
  32. package/dist/src/docs-sections.js +0 -141
  33. package/dist/src/doctor.js +0 -380
  34. package/dist/src/engine/ann-hnsw.js +0 -271
  35. package/dist/src/engine/embeddings.js +0 -193
  36. package/dist/src/engine/file-walker.js +0 -43
  37. package/dist/src/engine/git-history.js +0 -289
  38. package/dist/src/engine/index.js +0 -13377
  39. package/dist/src/engine/perf.js +0 -115
  40. package/dist/src/engine/prune.js +0 -112
  41. package/dist/src/engine/scip-import.js +0 -408
  42. package/dist/src/engine/source-policy.js +0 -69
  43. package/dist/src/engine/sqlite.js +0 -71
  44. package/dist/src/engine/symbol-delete.js +0 -58
  45. package/dist/src/execution-profile.js +0 -203
  46. package/dist/src/failure-diagnosis.js +0 -649
  47. package/dist/src/fleet.js +0 -7
  48. package/dist/src/git-executable.js +0 -31
  49. package/dist/src/graph-query-health.js +0 -115
  50. package/dist/src/hook-manager-integration.js +0 -156
  51. package/dist/src/index-activity.js +0 -125
  52. package/dist/src/init-progress.js +0 -155
  53. package/dist/src/init.js +0 -1254
  54. package/dist/src/lifecycle-health.js +0 -250
  55. package/dist/src/lsp-readonly.js +0 -217
  56. package/dist/src/output-compression.js +0 -629
  57. package/dist/src/output-telemetry.js +0 -363
  58. package/dist/src/pr-triage.js +0 -638
  59. package/dist/src/progressive-evidence.js +0 -473
  60. package/dist/src/pure-compression-cli.js +0 -101
  61. package/dist/src/relationship-adapters.js +0 -370
  62. package/dist/src/release-attestation.js +0 -533
  63. package/dist/src/release-preflight.js +0 -510
  64. package/dist/src/repair-progress.js +0 -262
  65. package/dist/src/repository-init-process.js +0 -173
  66. package/dist/src/repository-management.js +0 -1231
  67. package/dist/src/response-budget.js +0 -194
  68. package/dist/src/server.js +0 -73
  69. package/dist/src/structural-fast-path.js +0 -338
  70. package/dist/src/structural-snapshot.js +0 -33
  71. package/dist/src/system-config.js +0 -615
  72. package/dist/src/terminal-help.js +0 -83
  73. package/dist/src/tools/knodin-tools.js +0 -1529
  74. package/dist/src/update-ceremony.js +0 -158
  75. package/dist/src/update-policy.js +0 -944
  76. package/dist/src/update-trust.js +0 -503
  77. package/dist/src/version.js +0 -13
  78. package/dist/src/visualization.js +0 -162
  79. package/dist/src/wait-for-fresh.js +0 -98
  80. package/dist/src/worktree-lifecycle.js +0 -231
  81. package/docs/CONTAINED-EXECUTION.md +0 -77
  82. package/docs/DIAGNOSTICS.md +0 -45
  83. package/docs/GIT-HISTORY-REVIEW.md +0 -39
  84. package/docs/PROGRESSIVE-EVIDENCE.md +0 -37
  85. package/docs/PT-ACCESS-RECOMMENDATION.md +0 -91
  86. package/docs/RELEASE-0.3-EVIDENCE.md +0 -73
  87. package/docs/SCIP-IMPORT.md +0 -57
  88. package/docs/SIGNED-UPDATES.md +0 -151
  89. package/docs/TELEMETRY.md +0 -46
  90. package/docs/assets/knodin-favicon.svg +0 -4
  91. package/docs/releases/0.3.0.md +0 -46
  92. package/docs/releases/0.4.0.md +0 -68
  93. package/docs/releases/0.4.1.md +0 -28
  94. package/docs/releases/0.4.2.md +0 -27
  95. package/docs/releases/0.4.3.md +0 -23
  96. package/docs/releases/0.5.0.md +0 -29
  97. package/docs/releases/0.5.1.md +0 -17
  98. package/docs/releases/0.6.0.md +0 -18
  99. package/docs/releases/0.7.0.md +0 -24
  100. package/docs/releases/0.7.1.md +0 -21
  101. package/docs/releases/0.7.2.md +0 -21
  102. package/docs/releases/0.7.3.md +0 -23
  103. package/docs/releases/0.7.4.md +0 -17
  104. package/schemas/release-attestation-v1.schema.json +0 -210
@@ -1,370 +0,0 @@
1
- import childProcess from "node:child_process";
2
- import crypto from "node:crypto";
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import { gitExecutable } from "./git-executable.js";
6
- const MAX_FILES = 5_000;
7
- const MAX_CONTRACT_BYTES = 2 * 1024 * 1024;
8
- export function trackedRepositoryFiles(repository) {
9
- try {
10
- return childProcess
11
- .execFileSync(gitExecutable(), ["ls-files", "-z"], {
12
- cwd: repository,
13
- encoding: "utf-8",
14
- stdio: ["ignore", "pipe", "ignore"],
15
- })
16
- .split("\0")
17
- .filter(Boolean)
18
- .sort((left, right) => left.localeCompare(right))
19
- .slice(0, MAX_FILES);
20
- }
21
- catch {
22
- return [];
23
- }
24
- }
25
- function lineNumber(content, offset) {
26
- return content.slice(0, offset).split("\n").length;
27
- }
28
- function matchAll(content, pattern, build) {
29
- const findings = [];
30
- for (const match of content.matchAll(pattern)) {
31
- findings.push({ ...build(match), line: lineNumber(content, match.index ?? 0) });
32
- }
33
- return findings;
34
- }
35
- function packageFindings(file, content) {
36
- if (file === "package.json") {
37
- try {
38
- const manifest = JSON.parse(content);
39
- const findings = [];
40
- for (const section of ["dependencies", "devDependencies", "peerDependencies"]) {
41
- const dependencies = manifest[section];
42
- if (typeof dependencies !== "object" || dependencies === null)
43
- continue;
44
- for (const name of Object.keys(dependencies).sort((left, right) => left.localeCompare(right))) {
45
- findings.push({
46
- type: "depends_on",
47
- target: `pkg:npm/${encodeURIComponent(name)}`,
48
- line: lineNumber(content, Math.max(content.indexOf(`"${name}"`), 0)),
49
- adapter: "package-manifest",
50
- confidence: 1,
51
- });
52
- }
53
- }
54
- return findings;
55
- }
56
- catch {
57
- return [];
58
- }
59
- }
60
- if (file === "go.mod") {
61
- return content.split(/\r?\n/).flatMap((line, index) => {
62
- const [moduleName, version] = line.trim().split(/\s+/, 2);
63
- if (!moduleName?.includes(".") || !version?.startsWith("v"))
64
- return [];
65
- return [
66
- {
67
- type: "depends_on",
68
- target: `pkg:golang/${moduleName}`,
69
- line: index + 1,
70
- adapter: "package-manifest",
71
- confidence: 1,
72
- },
73
- ];
74
- });
75
- }
76
- if (file === "Cargo.toml" || file === "pyproject.toml") {
77
- return matchAll(content, /^([A-Za-z0-9_.-]+)[ \t]*=[ \t]*(?:["'{])/gm, (match) => ({
78
- type: "depends_on",
79
- target: `pkg:${file === "Cargo.toml" ? "cargo" : "pypi"}/${match[1]}`,
80
- adapter: "package-manifest",
81
- confidence: 0.9,
82
- }));
83
- }
84
- return [];
85
- }
86
- function contractFindings(file, content) {
87
- const lower = file.toLowerCase();
88
- if (/openapi|swagger/.test(lower) && /\.(json|ya?ml)$/.test(lower)) {
89
- return matchAll(content, /^[ \t]{0,8}(\/[^:\s]+)[ \t]*:/gm, (match) => ({
90
- type: "provides_api",
91
- target: `openapi:${match[1]}`,
92
- adapter: "openapi",
93
- confidence: 1,
94
- }));
95
- }
96
- if (/asyncapi/.test(lower)) {
97
- return matchAll(content, /^[ \t]{2,8}([^:\s]+)[ \t]*:/gm, (match) => ({
98
- type: "publishes_event",
99
- target: `asyncapi:${match[1]}`,
100
- adapter: "asyncapi",
101
- confidence: 0.9,
102
- }));
103
- }
104
- if (lower.endsWith(".graphql") || lower.endsWith(".gql")) {
105
- return matchAll(content, /^[ \t]*(?:type|interface|input)[ \t]+([A-Za-z_]\w*)/gm, (match) => ({
106
- type: "provides_api",
107
- target: `graphql:${match[1]}`,
108
- adapter: "graphql",
109
- confidence: 1,
110
- }));
111
- }
112
- if (lower.endsWith(".proto")) {
113
- return matchAll(content, /^[ \t]*service[ \t]+([A-Za-z_]\w*)/gm, (match) => ({
114
- type: "provides_api",
115
- target: `protobuf:${match[1]}`,
116
- adapter: "protobuf",
117
- confidence: 1,
118
- }));
119
- }
120
- return [];
121
- }
122
- function infrastructureFindings(file, content) {
123
- const lower = file.toLowerCase();
124
- const findings = [];
125
- if (lower.endsWith(".tf")) {
126
- findings.push(...matchAll(content, /^[ \t]*source[ \t]*=[ \t]*"([^"\r\n]+)"/gm, (match) => ({
127
- type: "depends_on",
128
- target: `terraform:${match[1]}`,
129
- adapter: "terraform",
130
- confidence: 1,
131
- })), ...matchAll(content, /^[ \t]*backend[ \t]+"([^"\r\n]+)"/gm, (match) => ({
132
- type: "reads_output",
133
- target: `terraform-state:${match[1]}`,
134
- adapter: "terraform",
135
- confidence: 0.9,
136
- })), ...matchAll(content, /^[ \t]*output[ \t]+"([^"\r\n]+)"/gm, (match) => ({
137
- type: "provisions",
138
- target: `terraform-output:${match[1]}`,
139
- adapter: "terraform",
140
- confidence: 1,
141
- })));
142
- }
143
- if (/\.(ya?ml|tpl)$/.test(lower)) {
144
- findings.push(...matchAll(content, /^[ \t]*image:[ \t]*["']?([^"'\s]+)["']?/gm, (match) => ({
145
- type: "uses_image",
146
- target: `oci:${match[1]}`,
147
- adapter: lower.includes("helm") || lower.includes("chart") ? "helm" : "kubernetes",
148
- confidence: 1,
149
- })));
150
- }
151
- return findings;
152
- }
153
- function provenanceFindings(file, content) {
154
- const lower = file.toLowerCase();
155
- if (lower.endsWith(".map")) {
156
- try {
157
- const sourceMap = JSON.parse(content);
158
- if (!Array.isArray(sourceMap.sources))
159
- return [];
160
- return sourceMap.sources.flatMap((source) => typeof source === "string"
161
- ? [
162
- {
163
- type: "generated_from",
164
- target: `file:${source}`,
165
- line: 1,
166
- adapter: "source-map",
167
- confidence: 1,
168
- },
169
- ]
170
- : []);
171
- }
172
- catch {
173
- return [];
174
- }
175
- }
176
- if (/(?:^|\/)(?:bom|sbom)(?:\.[^/]*)?\.json$/.test(lower)) {
177
- try {
178
- const sbom = JSON.parse(content);
179
- if (!Array.isArray(sbom.components))
180
- return [];
181
- return sbom.components.flatMap((component) => {
182
- if (!component || typeof component !== "object")
183
- return [];
184
- const purl = component.purl;
185
- return typeof purl === "string"
186
- ? [
187
- {
188
- type: "depends_on",
189
- target: purl,
190
- line: lineNumber(content, Math.max(content.indexOf(purl), 0)),
191
- adapter: "cyclonedx-sbom",
192
- confidence: 1,
193
- },
194
- ]
195
- : [];
196
- });
197
- }
198
- catch {
199
- return [];
200
- }
201
- }
202
- if (lower.endsWith(".intoto.jsonl") || lower.includes("provenance")) {
203
- return matchAll(content, /"uri"[ \t]*:[ \t]*"([^"\r\n]+)"/g, (match) => ({
204
- type: "generated_from",
205
- target: match[1] ?? "unknown",
206
- adapter: "slsa-provenance",
207
- confidence: 1,
208
- }));
209
- }
210
- return [];
211
- }
212
- function sourceFindings(content, repository, knownPaths) {
213
- const findings = [];
214
- for (const [knownPath, identity] of knownPaths) {
215
- for (const match of content.matchAll(/(["'`])([^"'`\n]+)\1/g)) {
216
- const literal = match[2];
217
- if (!literal || path.resolve(repository, literal) !== path.resolve(knownPath))
218
- continue;
219
- findings.push({
220
- type: "references_path",
221
- target: identity,
222
- line: lineNumber(content, match.index ?? 0),
223
- adapter: "exact-path-literal",
224
- confidence: 1,
225
- });
226
- }
227
- }
228
- findings.push(...matchAll(content, /\b(?:process\.env\.|os\.environ\[["'])([A-Z][A-Z0-9_]{2,})/g, (match) => ({
229
- type: "reads_config",
230
- target: `config:${match[1]}`,
231
- adapter: "configuration-key",
232
- confidence: 0.85,
233
- })));
234
- return findings;
235
- }
236
- /** Extract bounded, source-evidenced non-symbol relationships from one checkout. */
237
- export function extractRepositoryRelationships(repositoryId, repository, knownPaths = new Map()) {
238
- const relationships = [];
239
- for (const file of trackedRepositoryFiles(repository)) {
240
- const absolute = path.join(repository, file);
241
- let stat;
242
- try {
243
- stat = fs.statSync(absolute);
244
- }
245
- catch {
246
- continue;
247
- }
248
- if (!stat.isFile() || stat.size > MAX_CONTRACT_BYTES)
249
- continue;
250
- let content;
251
- try {
252
- content = fs.readFileSync(absolute, "utf-8");
253
- }
254
- catch {
255
- continue;
256
- }
257
- const findings = [
258
- ...packageFindings(file, content),
259
- ...contractFindings(file, content),
260
- ...infrastructureFindings(file, content),
261
- ...provenanceFindings(file, content),
262
- ...sourceFindings(content, repository, knownPaths),
263
- ];
264
- for (const finding of findings) {
265
- relationships.push({
266
- type: finding.type,
267
- from: repositoryId,
268
- to: finding.target,
269
- targetIdentity: finding.target,
270
- evidence: {
271
- location: `${file}:${finding.line}`,
272
- line: finding.line,
273
- adapter: finding.adapter,
274
- kind: "extracted",
275
- confidence: finding.confidence,
276
- freshness: "current",
277
- indexGeneration: null,
278
- },
279
- });
280
- }
281
- }
282
- return relationships.sort((left, right) => `${left.from}\0${left.type}\0${left.to}\0${left.evidence.location}`.localeCompare(`${right.from}\0${right.type}\0${right.to}\0${right.evidence.location}`));
283
- }
284
- /** Stream a file hash so duplicate detection never buffers an entire artifact. */
285
- export async function hashFileStream(file) {
286
- const digest = crypto.createHash("sha256");
287
- await new Promise((resolve, reject) => {
288
- const stream = fs.createReadStream(file);
289
- stream.on("data", (chunk) => digest.update(chunk));
290
- stream.on("error", reject);
291
- stream.on("end", resolve);
292
- });
293
- return digest.digest("hex");
294
- }
295
- function filesGroupedBySize(repositories) {
296
- const bySize = new Map();
297
- const orderedRepositories = [...repositories].sort((left, right) => left.id.localeCompare(right.id));
298
- for (const repository of orderedRepositories) {
299
- for (const file of trackedRepositoryFiles(repository.path)) {
300
- const absolute = path.join(repository.path, file);
301
- try {
302
- const stat = fs.statSync(absolute);
303
- if (!stat.isFile())
304
- continue;
305
- const candidates = bySize.get(stat.size) ?? [];
306
- candidates.push({ repositoryId: repository.id, file, absolute });
307
- bySize.set(stat.size, candidates);
308
- }
309
- catch {
310
- // A concurrently removed file is absent from this evidence snapshot.
311
- }
312
- }
313
- }
314
- return bySize;
315
- }
316
- async function filesGroupedByHash(candidates) {
317
- const byHash = new Map();
318
- for (const candidate of candidates) {
319
- const hash = await hashFileStream(candidate.absolute);
320
- const matches = byHash.get(hash) ?? [];
321
- matches.push(candidate);
322
- byHash.set(hash, matches);
323
- }
324
- return byHash;
325
- }
326
- function duplicateRelationships(matches) {
327
- const repositoryIds = new Set(matches.map(({ repositoryId }) => repositoryId));
328
- if (repositoryIds.size < 2)
329
- return [];
330
- const ordered = [...matches].sort((left, right) => `${left.repositoryId}\0${left.file}`.localeCompare(`${right.repositoryId}\0${right.file}`));
331
- const canonical = ordered[0];
332
- if (!canonical)
333
- return [];
334
- return ordered.slice(1).flatMap((duplicate) => {
335
- if (duplicate.repositoryId === canonical.repositoryId)
336
- return [];
337
- return [
338
- {
339
- type: "duplicate_candidate",
340
- from: duplicate.repositoryId,
341
- to: canonical.repositoryId,
342
- targetIdentity: canonical.repositoryId,
343
- evidence: {
344
- location: duplicate.file,
345
- adapter: "streaming-sha256",
346
- kind: "inferred",
347
- confidence: 1,
348
- freshness: "current",
349
- indexGeneration: null,
350
- },
351
- },
352
- ];
353
- });
354
- }
355
- /**
356
- * Detect exact tracked-file matches across repositories. Equality is reported
357
- * only as a duplicate candidate; it never asserts generated/vendor lineage.
358
- */
359
- export async function detectDuplicateCandidates(repositories) {
360
- const relationships = [];
361
- for (const candidates of filesGroupedBySize(repositories).values()) {
362
- if (candidates.length < 2)
363
- continue;
364
- const byHash = await filesGroupedByHash(candidates);
365
- for (const matches of byHash.values()) {
366
- relationships.push(...duplicateRelationships(matches));
367
- }
368
- }
369
- return relationships.sort((left, right) => `${left.from}\0${left.to}\0${left.evidence.location}`.localeCompare(`${right.from}\0${right.to}\0${right.evidence.location}`));
370
- }