kodingo-cli 1.0.3 → 1.0.5

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
- const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
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 client = new sdk_1.default({ apiKey });
15
- const prompt = [
16
- "You are a senior software engineer reviewing a code change.",
17
- "Your job is to interpret what this change represents as a decision or evolution in the codebase.",
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
- const textBlock = response.content.find((b) => b.type === "text");
39
- if (textBlock && textBlock.type === "text") {
40
- return textBlock.text.trim();
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/cli.js CHANGED
@@ -14,10 +14,18 @@ const deny_1 = require("./commands/deny");
14
14
  const scan_git_1 = require("./commands/scan-git");
15
15
  const init_1 = require("./commands/init");
16
16
  const install_hook_1 = require("./commands/install-hook");
17
+ const update_1 = require("./commands/update");
17
18
  const program = new commander_1.Command();
18
- program.name("kodingo").description("Kodingo CLI").version("1.0.1");
19
+ program.name("kodingo").description("Kodingo CLI").version("1.0.4");
19
20
  // ── init ──────────────────────────────────────────────────────────────────────
20
21
  (0, init_1.registerInitCommand)(program);
22
+ // ── update ────────────────────────────────────────────────────────────────────
23
+ program
24
+ .command("update")
25
+ .description("Update kodingo-cli to the latest version")
26
+ .action(async () => {
27
+ await (0, update_1.updateCommand)();
28
+ });
21
29
  // ── capture ───────────────────────────────────────────────────────────────────
22
30
  program
23
31
  .command("capture")
@@ -65,3 +65,5 @@ async function readStdin() {
65
65
  process.stdin.on("error", reject);
66
66
  });
67
67
  }
68
+ // review test
69
+ // review test
@@ -82,3 +82,14 @@ function findRepoRoot(startPath) {
82
82
  current = parent;
83
83
  }
84
84
  }
85
+ function testKodingoSaveWatcher() {
86
+ return false;
87
+ }
88
+ async function validateTokenExpiry(token, maxAgeMs) {
89
+ const parts = token.split('.');
90
+ if (parts.length !== 3)
91
+ return false;
92
+ const payload = JSON.parse(Buffer.from(parts[1], 'base64').toString());
93
+ const issuedAt = payload.iat * 1000;
94
+ return Date.now() - issuedAt < maxAgeMs;
95
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateCommand = updateCommand;
4
+ const child_process_1 = require("child_process");
5
+ async function updateCommand() {
6
+ console.log("Checking for updates...");
7
+ let currentVersion;
8
+ let latestVersion;
9
+ try {
10
+ currentVersion = (0, child_process_1.execSync)("kodingo --version", { encoding: "utf-8" }).trim();
11
+ }
12
+ catch {
13
+ currentVersion = "unknown";
14
+ }
15
+ try {
16
+ latestVersion = (0, child_process_1.execSync)("npm view kodingo-cli version", { encoding: "utf-8" }).trim();
17
+ }
18
+ catch {
19
+ console.error("Could not fetch latest version. Check your internet connection.");
20
+ process.exit(1);
21
+ }
22
+ if (currentVersion === latestVersion) {
23
+ console.log(`Already on the latest version (${currentVersion}).`);
24
+ return;
25
+ }
26
+ console.log(`Updating from ${currentVersion} to ${latestVersion}...`);
27
+ try {
28
+ (0, child_process_1.execSync)("npm install -g kodingo-cli@latest", { stdio: "inherit" });
29
+ console.log(`Updated to ${latestVersion} successfully.`);
30
+ }
31
+ catch {
32
+ console.error("Update failed. Try running: npm install -g kodingo-cli@latest");
33
+ process.exit(1);
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodingo-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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",
@@ -34,4 +33,4 @@
34
33
  "@types/uuid": "^10.0.0",
35
34
  "typescript": "^5.6.0"
36
35
  }
37
- }
36
+ }