kodingo-cli 1.0.36 → 1.0.38
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/commands/init.js
CHANGED
|
@@ -273,6 +273,20 @@ function registerInitCommand(program) {
|
|
|
273
273
|
(0, persistence_config_1.writeConfig)({ ...existingConfig, mode: "cloud", apiUrl, machineId });
|
|
274
274
|
(0, persistence_config_1.writeWorkspaceConfig)(repoRoot, { mode: "cloud", apiUrl, token: selectedProject.token });
|
|
275
275
|
ensureGitignoreEntry(repoRoot, ".kortex/");
|
|
276
|
+
// Register this repo with the project on the API
|
|
277
|
+
// This is the authoritative binding that prevents cross-project contamination
|
|
278
|
+
try {
|
|
279
|
+
const repoName = path.basename(repoRoot);
|
|
280
|
+
await fetch(`${apiUrl}/org/projects/${selectedProject.id}/repos`, {
|
|
281
|
+
method: "POST",
|
|
282
|
+
headers: {
|
|
283
|
+
"Content-Type": "application/json",
|
|
284
|
+
"Authorization": `Bearer ${authToken}`,
|
|
285
|
+
},
|
|
286
|
+
body: JSON.stringify({ repoName }),
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
catch { }
|
|
276
290
|
console.log(`✔ Connected. Token saved to ${persistence_config_1.CONFIG_PATH}`);
|
|
277
291
|
console.log("\nKortex is now watching this repo.");
|
|
278
292
|
console.log("Run `kodingo install-hook` to capture memories on every commit.\n");
|
|
@@ -25,7 +25,7 @@ function getCredentials(repoRoot) {
|
|
|
25
25
|
current = path_1.default.dirname(current);
|
|
26
26
|
wsEntry = config.workspaces?.[current] ?? config.workspaces?.[current + "/"];
|
|
27
27
|
}
|
|
28
|
-
const token = wsEntry?.token ??
|
|
28
|
+
const token = wsEntry?.token ?? "";
|
|
29
29
|
const apiUrl = wsEntry?.apiUrl ?? config.apiUrl ?? API_BASE_DEFAULT;
|
|
30
30
|
return { token, apiUrl };
|
|
31
31
|
}
|
|
@@ -186,11 +186,11 @@ async function scanRepoCommand(options = {}) {
|
|
|
186
186
|
const config = (0, persistence_config_1.readConfig)();
|
|
187
187
|
const repoRoot2 = options.repo ? path_1.default.resolve(options.repo) : findRepoRoot(process.cwd());
|
|
188
188
|
const wsConfig = (0, persistence_config_1.readWorkspaceConfig)(repoRoot2);
|
|
189
|
-
const token = wsConfig?.token ??
|
|
189
|
+
const token = wsConfig?.token ?? "";
|
|
190
190
|
const apiUrl = wsConfig?.apiUrl ?? config.apiUrl ?? "https://kodingo-api.onrender.com";
|
|
191
191
|
if (!token) {
|
|
192
192
|
if (!options.silent)
|
|
193
|
-
console.error("✖
|
|
193
|
+
console.error("✖ This repo is not connected to Kodingo. Run `kodingo init` in this directory first.");
|
|
194
194
|
return 0;
|
|
195
195
|
}
|
|
196
196
|
const repoRoot = options.repo
|
|
@@ -20,24 +20,24 @@ class CloudEventPort {
|
|
|
20
20
|
}
|
|
21
21
|
async pushDecision(decision, _context) {
|
|
22
22
|
await this.persistence.initDb();
|
|
23
|
-
// Build real priorMemory from
|
|
23
|
+
// Build real priorMemory from affirmed memories in this project
|
|
24
24
|
let context = _context;
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
.
|
|
34
|
-
.
|
|
26
|
+
const repoPath = this.repoPath;
|
|
27
|
+
const records = await this.persistence.queryMemory("", 100, this.repoPath, { includeNonCanonical: false }).catch(() => []);
|
|
28
|
+
const decisions = records
|
|
29
|
+
.filter((r) => r.externalId?.startsWith("git:") || r.id)
|
|
30
|
+
.map((r) => r.externalId ?? r.id)
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
const mostRecent = records
|
|
33
|
+
.map((r) => new Date(r.updatedAt ?? r.updated_at ?? 0))
|
|
34
|
+
.sort((a, b) => b.getTime() - a.getTime())[0];
|
|
35
35
|
context = {
|
|
36
36
|
..._context,
|
|
37
37
|
priorMemory: {
|
|
38
38
|
projectId: decision.projectId,
|
|
39
39
|
decisions,
|
|
40
|
-
updatedAt:
|
|
40
|
+
updatedAt: mostRecent ?? new Date(0),
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
}
|