kodingo-cli 1.3.4 → 1.4.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.
- package/dist/__tests__/deepScanLocal.test.js +82 -0
- package/dist/__tests__/inference.test.js +78 -0
- package/dist/__tests__/versionPolicy.test.js +13 -0
- package/dist/adapters/ai/inference.js +5 -2
- package/dist/bootstrap.js +74 -0
- package/dist/cli.js +20 -6
- package/dist/commands/deep-scan-process.js +22 -0
- package/dist/commands/deep-scan-worker.js +19 -0
- package/dist/commands/deep-scan.js +344 -0
- package/dist/commands/init.js +51 -23
- package/dist/commands/install-hook.js +2 -0
- package/dist/commands/scan-git.js +2 -17
- package/dist/commands/update.js +18 -6
- package/dist/ports/cloud-event-port.js +4 -0
- package/dist/ports/db-event-port.js +4 -0
- package/dist/utils/local-deep-scan-extractor.js +21 -0
- package/dist/utils/persistence-config.js +27 -0
- package/dist/utils/vendoredCodeDetector.js +16 -143
- package/dist/utils/version-policy.js +44 -0
- package/package.json +3 -3
- package/dist/test-buildgraph-debug.js +0 -10
- package/dist/test-calls-debug.js +0 -16
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const node_test_1 = require("node:test");
|
|
12
|
+
const local_deep_scan_extractor_1 = require("../utils/local-deep-scan-extractor");
|
|
13
|
+
const deep_scan_1 = require("../commands/deep-scan");
|
|
14
|
+
(0, node_test_1.describe)("local deep scan privacy", () => {
|
|
15
|
+
(0, node_test_1.it)("never reads env paths and redacts secrets from excerpts", () => {
|
|
16
|
+
strict_1.default.equal((0, local_deep_scan_extractor_1.isNeverReadPath)("apps/web/.env.production"), true);
|
|
17
|
+
strict_1.default.equal((0, local_deep_scan_extractor_1.privacySafeExcerpt)('const token = "ghp_abcdefghijklmnopqrstuvwxyz012345";'), "const [REDACTED]");
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)("caps evidence to one short statement", () => {
|
|
20
|
+
strict_1.default.equal((0, local_deep_scan_extractor_1.privacySafeExcerpt)(` first();\nsecond();`).trim(), "first()");
|
|
21
|
+
strict_1.default.ok((0, local_deep_scan_extractor_1.privacySafeExcerpt)("x".repeat(500)).length <= 200);
|
|
22
|
+
});
|
|
23
|
+
(0, node_test_1.it)("honors git tracking, .kodingoignore, and env exclusion", () => {
|
|
24
|
+
const root = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), "kodingo-deep-scan-"));
|
|
25
|
+
(0, node_child_process_1.execFileSync)("git", ["init", "-q", root]);
|
|
26
|
+
node_fs_1.default.mkdirSync(node_path_1.default.join(root, "src"));
|
|
27
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(root, "src", "keep.ts"), "export function keep() { return 1; }");
|
|
28
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(root, "src", "skip.ts"), "export function skip() { return 1; }");
|
|
29
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(root, ".env"), "SECRET=value");
|
|
30
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(root, ".kodingoignore"), "src/skip.ts\n");
|
|
31
|
+
(0, node_child_process_1.execFileSync)("git", ["-C", root, "add", "."]);
|
|
32
|
+
const files = (0, deep_scan_1.listTrackedFiles)(root);
|
|
33
|
+
strict_1.default.deepEqual(files.map((file) => file.path), ["src/keep.ts"]);
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)("extracts structure without uploading a function body", async () => {
|
|
36
|
+
const source = Buffer.from("export function hello() {\n return <main>Hello</main>;\n}\n");
|
|
37
|
+
const result = await (0, local_deep_scan_extractor_1.extractLocalFile)("src/hello.tsx", "a".repeat(40), source);
|
|
38
|
+
strict_1.default.equal(result?.observations[0].name, "hello");
|
|
39
|
+
strict_1.default.ok((result?.observations[0].excerpt.length ?? 0) <= 200);
|
|
40
|
+
strict_1.default.equal(JSON.stringify(result).includes(source.toString("utf8")), false);
|
|
41
|
+
});
|
|
42
|
+
(0, node_test_1.it)("records real UTF-8 byte spans rather than excerpt-relative placeholders", async () => {
|
|
43
|
+
const source = Buffer.from("// café 🚀\nexport function hello() {\n return <main>Hello</main>;\n}\n");
|
|
44
|
+
const result = await (0, local_deep_scan_extractor_1.extractLocalFile)("src/hello.tsx", "a".repeat(40), source);
|
|
45
|
+
const observation = result?.observations.find((item) => item.name === "hello");
|
|
46
|
+
strict_1.default.equal(observation?.startByte, Buffer.byteLength("// café 🚀\n"));
|
|
47
|
+
strict_1.default.ok((observation?.endByte ?? 0) > (observation?.startByte ?? 0));
|
|
48
|
+
strict_1.default.equal(source.subarray(observation?.startByte, observation?.endByte).toString("utf8").startsWith("export function hello"), true);
|
|
49
|
+
});
|
|
50
|
+
(0, node_test_1.it)("normalizes SSH and HTTPS remotes", () => {
|
|
51
|
+
strict_1.default.equal((0, deep_scan_1.normalizeRemote)("git@github.com:owner/repo.git"), "owner/repo");
|
|
52
|
+
strict_1.default.equal((0, deep_scan_1.normalizeRemote)("https://github.com/owner/repo.git"), "owner/repo");
|
|
53
|
+
});
|
|
54
|
+
(0, node_test_1.it)("writes an inspectable dry-run payload without contacting the server", async () => {
|
|
55
|
+
const root = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), "kodingo-dry-run-"));
|
|
56
|
+
(0, node_child_process_1.execFileSync)("git", ["init", "-q", root]);
|
|
57
|
+
(0, node_child_process_1.execFileSync)("git", ["-C", root, "config", "user.email", "test@example.invalid"]);
|
|
58
|
+
(0, node_child_process_1.execFileSync)("git", ["-C", root, "config", "user.name", "Validation Test"]);
|
|
59
|
+
(0, node_child_process_1.execFileSync)("git", ["-C", root, "remote", "add", "origin", "git@github.com:validation/repository.git"]);
|
|
60
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(root, "page.ts"), "export function Page() { return 1; }");
|
|
61
|
+
(0, node_child_process_1.execFileSync)("git", ["-C", root, "add", "."]);
|
|
62
|
+
(0, node_child_process_1.execFileSync)("git", ["-C", root, "commit", "-qm", "fixture"]);
|
|
63
|
+
const output = node_path_1.default.join(root, "payload.json");
|
|
64
|
+
const oldToken = process.env.KODINGO_TOKEN;
|
|
65
|
+
process.env.KODINGO_TOKEN = "validation-token";
|
|
66
|
+
try {
|
|
67
|
+
await (0, deep_scan_1.deepScanCommand)({ repo: root, dryRun: output });
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
if (oldToken === undefined)
|
|
71
|
+
delete process.env.KODINGO_TOKEN;
|
|
72
|
+
else
|
|
73
|
+
process.env.KODINGO_TOKEN = oldToken;
|
|
74
|
+
}
|
|
75
|
+
const payload = JSON.parse(node_fs_1.default.readFileSync(output, "utf8"));
|
|
76
|
+
strict_1.default.equal(payload.manifest.repository, "validation/repository");
|
|
77
|
+
strict_1.default.equal(payload.files[0].path, "page.ts");
|
|
78
|
+
strict_1.default.ok(Array.isArray(payload.files[0].linkPlan.attributeUpdates));
|
|
79
|
+
strict_1.default.ok(Array.isArray(payload.files[0].linkPlan.derivedEntities));
|
|
80
|
+
strict_1.default.equal(JSON.stringify(payload).includes("return 1"), false);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Real tests for adapters/ai/inference.ts's auth fix — build brief "Item 8
|
|
4
|
+
* — the temporal lobe", 2026-10-01.
|
|
5
|
+
*
|
|
6
|
+
* FINDING this closes: inferDecisionSummary (the git-commit-triggered
|
|
7
|
+
* capture surface, via cloud-event-port.ts/db-event-port.ts) was calling
|
|
8
|
+
* POST /infer with no auth header at all — every real call would 401 and
|
|
9
|
+
* silently fall back to the non-LLM template text, meaning this surface
|
|
10
|
+
* never actually reached the shared, semantically-reasoning-enriched
|
|
11
|
+
* prompt built into routes/infer.ts (kodingo-api). These tests prove the
|
|
12
|
+
* real fix: a real token now reaches the request as X-Kodingo-Token, and
|
|
13
|
+
* the existing, honest fallback behavior is completely unchanged when no
|
|
14
|
+
* token is available.
|
|
15
|
+
*/
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const node_test_1 = require("node:test");
|
|
21
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
22
|
+
const inference_1 = require("../adapters/ai/inference");
|
|
23
|
+
(0, node_test_1.describe)("inferDecisionSummary — real auth fix", () => {
|
|
24
|
+
const originalFetch = globalThis.fetch;
|
|
25
|
+
(0, node_test_1.afterEach)(() => {
|
|
26
|
+
globalThis.fetch = originalFetch;
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)("sends the real X-Kodingo-Token header when a real token is available", async () => {
|
|
29
|
+
let capturedHeaders;
|
|
30
|
+
let capturedUrl;
|
|
31
|
+
globalThis.fetch = (async (url, init) => {
|
|
32
|
+
capturedUrl = String(url);
|
|
33
|
+
capturedHeaders = init.headers;
|
|
34
|
+
return new Response(JSON.stringify({ title: "t", content: "A real, LLM-authored decision summary.", type: "decision", tags: [] }), { status: 200 });
|
|
35
|
+
});
|
|
36
|
+
const result = await (0, inference_1.inferDecisionSummary)({
|
|
37
|
+
diff: "commit abc1234\n+ real change",
|
|
38
|
+
changedFiles: ["src/real.ts"],
|
|
39
|
+
symbol: "realFunction",
|
|
40
|
+
commitMessage: "real commit",
|
|
41
|
+
repoName: "real-repo",
|
|
42
|
+
token: "real-project-token",
|
|
43
|
+
apiUrl: "https://example.invalid",
|
|
44
|
+
});
|
|
45
|
+
strict_1.default.equal(result, "A real, LLM-authored decision summary.");
|
|
46
|
+
strict_1.default.equal(capturedUrl, "https://example.invalid/infer");
|
|
47
|
+
strict_1.default.equal(capturedHeaders?.["X-Kodingo-Token"], "real-project-token");
|
|
48
|
+
});
|
|
49
|
+
(0, node_test_1.it)("falls back to the honest template — never calls the network at all — when no real token is available (the pre-existing, unchanged behavior)", async () => {
|
|
50
|
+
let fetchCalled = false;
|
|
51
|
+
globalThis.fetch = (async () => {
|
|
52
|
+
fetchCalled = true;
|
|
53
|
+
throw new Error("should never be called without a real token");
|
|
54
|
+
});
|
|
55
|
+
const result = await (0, inference_1.inferDecisionSummary)({
|
|
56
|
+
diff: "commit abc1234ff\n+ real change",
|
|
57
|
+
changedFiles: ["src/a.ts", "src/b.ts"],
|
|
58
|
+
symbol: "realFunction",
|
|
59
|
+
commitMessage: "a real commit message",
|
|
60
|
+
repoName: "real-repo",
|
|
61
|
+
});
|
|
62
|
+
strict_1.default.equal(fetchCalled, false);
|
|
63
|
+
strict_1.default.match(result, /Changes to realFunction across 2 file\(s\) in commit abc1234f/);
|
|
64
|
+
strict_1.default.match(result, /a real commit message/);
|
|
65
|
+
});
|
|
66
|
+
(0, node_test_1.it)("falls back honestly when the real request itself fails (e.g. a genuine 401)", async () => {
|
|
67
|
+
globalThis.fetch = (async () => new Response("", { status: 401 }));
|
|
68
|
+
const result = await (0, inference_1.inferDecisionSummary)({
|
|
69
|
+
diff: "commit def5678\n+ change",
|
|
70
|
+
changedFiles: ["src/x.ts"],
|
|
71
|
+
symbol: "x",
|
|
72
|
+
commitMessage: "msg",
|
|
73
|
+
repoName: "real-repo",
|
|
74
|
+
token: "a-token-the-server-happens-to-reject",
|
|
75
|
+
});
|
|
76
|
+
strict_1.default.match(result, /Changes to x across 1 file\(s\)/);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const version_policy_1 = require("../utils/version-policy");
|
|
9
|
+
(0, node_test_1.it)("compares CLI policy versions numerically", () => {
|
|
10
|
+
strict_1.default.equal((0, version_policy_1.compareVersions)("1.10.0", "1.9.9"), 1);
|
|
11
|
+
strict_1.default.equal((0, version_policy_1.compareVersions)("1.3.5", "1.3.5"), 0);
|
|
12
|
+
strict_1.default.equal((0, version_policy_1.compareVersions)("1.3.4", "1.3.5"), -1);
|
|
13
|
+
});
|
|
@@ -6,9 +6,12 @@ const KODINGO_API_URL = process.env.KODINGO_API_URL ?? "https://kodingo-api.onre
|
|
|
6
6
|
async function inferDecisionSummary(input) {
|
|
7
7
|
try {
|
|
8
8
|
const code = input.diff.slice(0, 2000);
|
|
9
|
-
|
|
9
|
+
if (!input.token)
|
|
10
|
+
return buildFallback(input);
|
|
11
|
+
const apiUrl = input.apiUrl ?? KODINGO_API_URL;
|
|
12
|
+
const res = await fetch(`${apiUrl}/infer`, {
|
|
10
13
|
method: "POST",
|
|
11
|
-
headers: { "Content-Type": "application/json" },
|
|
14
|
+
headers: { "Content-Type": "application/json", "X-Kodingo-Token": input.token },
|
|
12
15
|
body: JSON.stringify({ symbol: input.symbol, code }),
|
|
13
16
|
});
|
|
14
17
|
if (!res.ok) {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
async function runLocalScanCommand(commandName) {
|
|
39
|
+
if (!["init", "deep-scan", "deep-scan-status"].includes(commandName))
|
|
40
|
+
return false;
|
|
41
|
+
const program = new commander_1.Command();
|
|
42
|
+
const { version } = require("../package.json");
|
|
43
|
+
program.name("kodingo").description("Kodingo CLI").version(version);
|
|
44
|
+
const { enforceVersionPolicy } = await Promise.resolve().then(() => __importStar(require("./utils/version-policy")));
|
|
45
|
+
program.hook("preAction", async () => enforceVersionPolicy());
|
|
46
|
+
if (commandName === "init") {
|
|
47
|
+
const { registerInitCommand } = await Promise.resolve().then(() => __importStar(require("./commands/init")));
|
|
48
|
+
registerInitCommand(program);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const { deepScanCommand, deepScanStatusCommand } = await Promise.resolve().then(() => __importStar(require("./commands/deep-scan")));
|
|
52
|
+
program.command("deep-scan")
|
|
53
|
+
.description("Read this tracked checkout locally and upload a privacy-safe structural summary")
|
|
54
|
+
.option("--repo <path>", "repo path (defaults to the current repo)")
|
|
55
|
+
.option("--yes", "non-interactive consent (token may come from KODINGO_TOKEN)")
|
|
56
|
+
.option("--dry-run <file>", "write the exact payload for review without uploading file summaries")
|
|
57
|
+
.option("--changed", "scan files changed by the current commit only")
|
|
58
|
+
.option("--no-update", "do not auto-update (used by hooks and CI)")
|
|
59
|
+
.action(async (options) => deepScanCommand(options));
|
|
60
|
+
program.command("deep-scan-status")
|
|
61
|
+
.description("Show local deep-scan coverage for this project")
|
|
62
|
+
.option("--repo <path>", "repo path (defaults to the current repo)")
|
|
63
|
+
.action(async (options) => deepScanStatusCommand(options));
|
|
64
|
+
}
|
|
65
|
+
await program.parseAsync(process.argv);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
void runLocalScanCommand(process.argv[2] ?? "").then(async (handled) => {
|
|
69
|
+
if (!handled)
|
|
70
|
+
await Promise.resolve().then(() => __importStar(require("./cli")));
|
|
71
|
+
}).catch((error) => {
|
|
72
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
});
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,6 @@ const ignore_1 = require("./commands/ignore");
|
|
|
13
13
|
const deny_1 = require("./commands/deny");
|
|
14
14
|
const scan_git_1 = require("./commands/scan-git");
|
|
15
15
|
const scan_claude_1 = require("./commands/scan-claude");
|
|
16
|
-
const scan_repo_1 = require("./commands/scan-repo");
|
|
17
16
|
const sync_graph_1 = require("./commands/sync-graph");
|
|
18
17
|
const sync_dependencies_1 = require("./commands/sync-dependencies");
|
|
19
18
|
const security_scan_1 = require("./commands/security-scan");
|
|
@@ -28,11 +27,28 @@ const guardrails_1 = require("./commands/guardrails");
|
|
|
28
27
|
const session_brief_1 = require("./commands/session-brief");
|
|
29
28
|
const check_rules_1 = require("./commands/check-rules");
|
|
30
29
|
const aging_1 = require("./commands/aging");
|
|
30
|
+
const deep_scan_1 = require("./commands/deep-scan");
|
|
31
|
+
const version_policy_1 = require("./utils/version-policy");
|
|
31
32
|
const program = new commander_1.Command();
|
|
33
|
+
program.hook("preAction", async () => (0, version_policy_1.enforceVersionPolicy)());
|
|
32
34
|
const { version } = require("../package.json");
|
|
33
35
|
program.name("kodingo").description("Kodingo CLI").version(version);
|
|
34
36
|
// ── init ──────────────────────────────────────────────────────────────────────
|
|
35
37
|
(0, init_1.registerInitCommand)(program);
|
|
38
|
+
program
|
|
39
|
+
.command("deep-scan")
|
|
40
|
+
.description("Read this tracked checkout locally and upload a privacy-safe structural summary")
|
|
41
|
+
.option("--repo <path>", "repo path (defaults to the current repo)")
|
|
42
|
+
.option("--yes", "non-interactive consent (token may come from KODINGO_TOKEN)")
|
|
43
|
+
.option("--dry-run <file>", "write the exact payload for review without uploading file summaries")
|
|
44
|
+
.option("--changed", "scan files changed by the current commit only")
|
|
45
|
+
.option("--no-update", "do not auto-update (used by hooks and CI)")
|
|
46
|
+
.action(async (options) => (0, deep_scan_1.deepScanCommand)(options));
|
|
47
|
+
program
|
|
48
|
+
.command("deep-scan-status")
|
|
49
|
+
.description("Show local deep-scan coverage for this project")
|
|
50
|
+
.option("--repo <path>", "repo path (defaults to the current repo)")
|
|
51
|
+
.action(async (options) => (0, deep_scan_1.deepScanStatusCommand)(options));
|
|
36
52
|
// ── build ─────────────────────────────────────────────────────────────────────
|
|
37
53
|
program
|
|
38
54
|
.command("build")
|
|
@@ -261,13 +277,11 @@ program
|
|
|
261
277
|
// ── scan-repo ─────────────────────────────────────────────────────────────────
|
|
262
278
|
program
|
|
263
279
|
.command("scan-repo")
|
|
264
|
-
.description("
|
|
280
|
+
.description("Deprecated alias for the local deep scan")
|
|
265
281
|
.option("--repo <path>", "repo path to scan")
|
|
266
282
|
.action(async (options) => {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
payload.repo = String(options.repo);
|
|
270
|
-
await (0, scan_repo_1.scanRepoCommand)(payload);
|
|
283
|
+
console.warn("`kodingo scan-repo` is deprecated; use `npx kodingo-cli init` for first setup or `kodingo deep-scan` for a later rescan.");
|
|
284
|
+
await (0, deep_scan_1.deepScanCommand)(options.repo ? { repo: String(options.repo) } : {});
|
|
271
285
|
});
|
|
272
286
|
program
|
|
273
287
|
.command("sync-graph")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
9
|
+
const worker = new node_worker_threads_1.Worker(node_path_1.default.join(__dirname, "deep-scan-worker.js"));
|
|
10
|
+
process.on("message", (message) => {
|
|
11
|
+
try {
|
|
12
|
+
const bytes = node_fs_1.default.readFileSync(message.absolutePath);
|
|
13
|
+
const transferable = bytes.buffer instanceof ArrayBuffer && bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength ? new Uint8Array(bytes.buffer) : Uint8Array.from(bytes);
|
|
14
|
+
worker.postMessage({ id: message.id, filePath: message.filePath, blobSha: message.blobSha, bytes: transferable, includeExcerpts: message.includeExcerpts }, [transferable.buffer]);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
process.send?.({ id: message.id, error: error instanceof Error ? error.message : String(error) });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
worker.on("message", (message) => process.send?.({ ...message, processRss: process.memoryUsage().rss }));
|
|
21
|
+
worker.on("error", (error) => process.send?.({ id: -1, error: error.message }));
|
|
22
|
+
process.on("disconnect", async () => { await worker.terminate(); process.exit(0); });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const local_deep_scan_extractor_1 = require("../utils/local-deep-scan-extractor");
|
|
9
|
+
node_worker_threads_1.parentPort?.on("message", async (message) => {
|
|
10
|
+
try {
|
|
11
|
+
const bytes = node_fs_1.default.readFileSync(message.absolutePath);
|
|
12
|
+
const extracted = await (0, local_deep_scan_extractor_1.extractLocalFile)(message.filePath, message.blobSha, bytes);
|
|
13
|
+
const result = extracted ? (0, local_deep_scan_extractor_1.sanitizeLocalExtraction)(extracted, message.includeExcerpts) : null;
|
|
14
|
+
node_worker_threads_1.parentPort?.postMessage({ id: message.id, result, processRss: process.memoryUsage().rss });
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
node_worker_threads_1.parentPort?.postMessage({ id: message.id, error: error instanceof Error ? error.message : String(error) });
|
|
18
|
+
}
|
|
19
|
+
});
|