kodingo-cli 1.0.2 → 1.0.4
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.
|
@@ -1,43 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.inferDecisionSummary = inferDecisionSummary;
|
|
7
|
-
|
|
4
|
+
exports.inferMemoryFromCode = inferMemoryFromCode;
|
|
5
|
+
const KODINGO_API_URL = process.env.KODINGO_API_URL ?? "https://kodingo-api.onrender.com";
|
|
8
6
|
async function inferDecisionSummary(input) {
|
|
9
|
-
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
10
|
-
if (!apiKey) {
|
|
11
|
-
return buildFallback(input);
|
|
12
|
-
}
|
|
13
7
|
try {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"Write 2 to 4 sentences of plain prose. No markdown, no bullet points, no headers.",
|
|
20
|
-
"Focus on intent and reasoning, not on describing the diff mechanically.",
|
|
21
|
-
"Treat the commit message as a low-trust hint only, not as truth.",
|
|
22
|
-
"Use the symbol and file paths to understand what part of the system changed.",
|
|
23
|
-
"If intent cannot be confidently inferred, say so honestly in plain English.",
|
|
24
|
-
"",
|
|
25
|
-
`Repository: ${input.repoName}`,
|
|
26
|
-
`Symbol: ${input.symbol}`,
|
|
27
|
-
`Changed files: ${input.changedFiles.join(", ")}`,
|
|
28
|
-
`Commit message (low-trust hint): ${input.commitMessage}`,
|
|
29
|
-
"",
|
|
30
|
-
"Diff:",
|
|
31
|
-
input.diff.slice(0, 8000),
|
|
32
|
-
].join("\n");
|
|
33
|
-
const response = await client.messages.create({
|
|
34
|
-
model: "claude-opus-4-5",
|
|
35
|
-
max_tokens: 300,
|
|
36
|
-
messages: [{ role: "user", content: prompt }],
|
|
8
|
+
const code = input.diff.slice(0, 2000);
|
|
9
|
+
const res = await fetch(`${KODINGO_API_URL}/infer`, {
|
|
10
|
+
method: "POST",
|
|
11
|
+
headers: { "Content-Type": "application/json" },
|
|
12
|
+
body: JSON.stringify({ symbol: input.symbol, code }),
|
|
37
13
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
14
|
+
if (!res.ok) {
|
|
15
|
+
return buildFallback(input);
|
|
16
|
+
}
|
|
17
|
+
const data = await res.json();
|
|
18
|
+
if (data.content) {
|
|
19
|
+
return data.content.trim();
|
|
41
20
|
}
|
|
42
21
|
return buildFallback(input);
|
|
43
22
|
}
|
|
@@ -45,6 +24,22 @@ async function inferDecisionSummary(input) {
|
|
|
45
24
|
return buildFallback(input);
|
|
46
25
|
}
|
|
47
26
|
}
|
|
27
|
+
async function inferMemoryFromCode(input) {
|
|
28
|
+
try {
|
|
29
|
+
const res = await fetch(`${KODINGO_API_URL}/infer`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: { "Content-Type": "application/json" },
|
|
32
|
+
body: JSON.stringify({ symbol: input.symbol, code: input.code }),
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok)
|
|
35
|
+
return null;
|
|
36
|
+
const data = await res.json();
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
48
43
|
function buildFallback(input) {
|
|
49
44
|
const shortHash = extractShortHash(input.diff);
|
|
50
45
|
return `Changes to ${input.symbol} across ${input.changedFiles.length} file(s)${shortHash ? ` in commit ${shortHash}` : ""}. Commit message: ${input.commitMessage}.`;
|
package/dist/commands/capture.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.scanGitCommand = scanGitCommand;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
9
10
|
const simple_git_1 = __importDefault(require("simple-git"));
|
|
10
11
|
const git_listener_1 = require("../adapters/git-adapter/git-listener");
|
|
11
12
|
const db_event_port_1 = require("../ports/db-event-port");
|
|
@@ -24,19 +25,33 @@ async function scanGitCommand(options) {
|
|
|
24
25
|
}
|
|
25
26
|
const commitHash = String(latestCommit.hash);
|
|
26
27
|
const externalId = `git:${commitHash}`;
|
|
27
|
-
// Idempotency check via the active persistence adapter (local or cloud)
|
|
28
28
|
const existing = await getMemoryByExternalId(externalId, repoRoot);
|
|
29
29
|
if (existing) {
|
|
30
30
|
console.log(`Git scan skipped (already stored) for repo: ${repoRoot} commit: ${commitHash.slice(0, 8)}`);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
// Use the appropriate event port based on configured persistence mode
|
|
34
33
|
const eventPort = (0, persistence_config_1.isCloudMode)()
|
|
35
34
|
? new cloud_event_port_1.CloudEventPort(repoRoot)
|
|
36
35
|
: new db_event_port_1.DbEventPort(repoRoot);
|
|
37
36
|
const adapter = new git_listener_1.GitListenerAdapter(repoRoot, eventPort, 5000);
|
|
38
37
|
await adapter.runOnceLatest();
|
|
39
38
|
console.log(`Git scan complete (latest commit) for repo: ${repoRoot} commit: ${commitHash.slice(0, 8)}`);
|
|
39
|
+
// Write flag file so VS Code extension knows to surface proposed memories
|
|
40
|
+
writePendingReviewFlag(repoRoot, commitHash);
|
|
41
|
+
}
|
|
42
|
+
function writePendingReviewFlag(repoRoot, commitHash) {
|
|
43
|
+
try {
|
|
44
|
+
const flagPath = path_1.default.join(os_1.default.homedir(), ".kodingo", "pending-review.json");
|
|
45
|
+
const payload = {
|
|
46
|
+
repo: repoRoot,
|
|
47
|
+
commit: commitHash.slice(0, 8),
|
|
48
|
+
timestamp: new Date().toISOString(),
|
|
49
|
+
};
|
|
50
|
+
fs_1.default.writeFileSync(flagPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// silently ignore — flag file is best-effort, never block the commit
|
|
54
|
+
}
|
|
40
55
|
}
|
|
41
56
|
function resolveRepoRoot(options) {
|
|
42
57
|
if (options.repo && options.repo.trim()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kodingo-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Kodingo CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"prepare": "npm run build"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@anthropic-ai/sdk": "^0.78.0",
|
|
24
23
|
"@babel/parser": "^7.29.0",
|
|
25
24
|
"@babel/traverse": "^7.29.0",
|
|
26
25
|
"commander": "^12.1.0",
|