kodingo-cli 1.0.22 → 1.0.24

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.
@@ -56,6 +56,20 @@ const API_BASE = "https://kodingo-api.onrender.com";
56
56
  const APP_URL = "https://kodingo.xyz";
57
57
  const CONFIG_DIR = path.join(os.homedir(), ".kodingo");
58
58
  const AUTH_TOKEN_PATH = path.join(CONFIG_DIR, "auth.json");
59
+ // ── Machine ID ────────────────────────────────────────────────────────────────
60
+ function generateMachineId() {
61
+ const raw = `${os.hostname()}::${os.userInfo().username}::${process.platform}`;
62
+ return require("crypto").createHash("sha256").update(raw).digest("hex").slice(0, 32);
63
+ }
64
+ function getMachineId() {
65
+ const config = (0, persistence_config_1.readConfig)();
66
+ if (config.machineId)
67
+ return config.machineId;
68
+ const machineId = generateMachineId();
69
+ const existing = (0, persistence_config_1.readConfig)();
70
+ (0, persistence_config_1.writeConfig)({ ...existing, machineId });
71
+ return machineId;
72
+ }
59
73
  // ── Auth token storage ────────────────────────────────────────────────────────
60
74
  function readAuthToken() {
61
75
  try {
@@ -255,7 +269,8 @@ function registerInitCommand(program) {
255
269
  const apiUrl = API_BASE;
256
270
  // preserve existing workspaces, never overwrite global token
257
271
  const existingConfig = (0, persistence_config_1.readConfig)();
258
- (0, persistence_config_1.writeConfig)({ ...existingConfig, mode: "cloud", apiUrl });
272
+ const machineId = getMachineId();
273
+ (0, persistence_config_1.writeConfig)({ ...existingConfig, mode: "cloud", apiUrl, machineId });
259
274
  (0, persistence_config_1.writeWorkspaceConfig)(repoRoot, { mode: "cloud", apiUrl, token: selectedProject.token });
260
275
  ensureGitignoreEntry(repoRoot, ".kortex/");
261
276
  console.log(`✔ Connected. Token saved to ${persistence_config_1.CONFIG_PATH}`);
@@ -38,7 +38,7 @@ const IGNORED_DIRS = [
38
38
  "node_modules", ".git", ".kortex", "dist", "build",
39
39
  "out", ".next", "coverage", "__pycache__", "vendor",
40
40
  ];
41
- const MAX_SYMBOLS = 50;
41
+ const MAX_SYMBOLS = 200;
42
42
  const BATCH_SIZE = 5;
43
43
  const BATCH_DELAY_MS = 1200;
44
44
  function findRepoRoot(startPath) {
@@ -107,8 +107,12 @@ async function fetchExistingSymbols(token, repo) {
107
107
  break;
108
108
  const data = await res.json();
109
109
  for (const m of data.memories ?? []) {
110
- if (m.symbol)
110
+ if (m.symbol) {
111
+ // Store both symbol-only and symbol::repo keys for accurate matching
111
112
  known.add(m.symbol);
113
+ if (m.repo)
114
+ known.add(`${m.symbol}::${m.repo}`);
115
+ }
112
116
  }
113
117
  offset += limit;
114
118
  if (offset >= (data.total ?? 0))
@@ -150,9 +154,13 @@ async function inferAndCapture(token, symbol, repo) {
150
154
  }
151
155
  async function scanRepoCommand(options = {}) {
152
156
  const config = (0, persistence_config_1.readConfig)();
153
- if (config.mode !== "cloud" || !config.token) {
157
+ const repoRoot2 = options.repo ? path_1.default.resolve(options.repo) : findRepoRoot(process.cwd());
158
+ const wsConfig = (0, persistence_config_1.readWorkspaceConfig)(repoRoot2);
159
+ const token = wsConfig?.token ?? config.token ?? "";
160
+ const apiUrl = wsConfig?.apiUrl ?? config.apiUrl ?? "https://kodingo-api.onrender.com";
161
+ if (!token) {
154
162
  if (!options.silent)
155
- console.error("✖ scan-repo requires cloud mode. Run `kodingo init` first.");
163
+ console.error("✖ No project token found. Run `kodingo init` first.");
156
164
  return 0;
157
165
  }
158
166
  const repoRoot = options.repo
@@ -178,7 +186,7 @@ async function scanRepoCommand(options = {}) {
178
186
  console.log(` Checking which ones need memory...\n`);
179
187
  }
180
188
  // Fetch all existing memory symbols in one bulk call
181
- const existingSymbols = await fetchExistingSymbols(config.token, repoName);
189
+ const existingSymbols = await fetchExistingSymbols(token, repoName);
182
190
  // Shuffle so repeated runs cover different parts of the codebase
183
191
  const shuffled = [...allSymbols].sort(() => Math.random() - 0.5);
184
192
  // Filter locally — no per-symbol API calls needed
@@ -191,7 +199,9 @@ async function scanRepoCommand(options = {}) {
191
199
  if (seen.has(key))
192
200
  continue;
193
201
  seen.add(key);
194
- if (!existingSymbols.has(sym.name))
202
+ const symRepoKey = `${sym.name}::${path_1.default.basename(sym.file)}`;
203
+ const hasMemory = existingSymbols.has(symRepoKey) || existingSymbols.has(sym.name);
204
+ if (!hasMemory)
195
205
  toCapture.push(sym);
196
206
  }
197
207
  if (toCapture.length === 0) {
@@ -206,7 +216,7 @@ async function scanRepoCommand(options = {}) {
206
216
  let captured = 0;
207
217
  for (let i = 0; i < toCapture.length; i += BATCH_SIZE) {
208
218
  const batch = toCapture.slice(i, i + BATCH_SIZE);
209
- const results = await Promise.all(batch.map(sym => inferAndCapture(config.token, sym, repoName)));
219
+ const results = await Promise.all(batch.map(sym => inferAndCapture(token, sym, repoName)));
210
220
  const batchCaptured = results.filter(Boolean).length;
211
221
  captured += batchCaptured;
212
222
  if (!options.silent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodingo-cli",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Kodingo CLI",
5
5
  "license": "MIT",
6
6
  "private": false,