@aikdna/kdna-cli 0.17.0 → 0.19.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/README.md +120 -101
- package/SECURITY.md +1 -1
- package/package.json +6 -4
- package/skills/kdna-loader/SKILL.md +23 -22
- package/src/agent.js +290 -159
- package/src/cli.js +117 -67
- package/src/cmds/_common.js +40 -18
- package/src/cmds/badge.js +14 -9
- package/src/cmds/changelog.js +32 -12
- package/src/cmds/cluster.js +80 -85
- package/src/cmds/doctor.js +10 -27
- package/src/cmds/domain.js +114 -427
- package/src/cmds/explain.js +119 -0
- package/src/cmds/governance.js +111 -42
- package/src/cmds/legacy.js +8 -9
- package/src/cmds/license.js +491 -26
- package/src/cmds/quality.js +10 -3
- package/src/cmds/registry.js +15 -67
- package/src/cmds/studio.js +99 -47
- package/src/cmds/test.js +9 -6
- package/src/cmds/trace.js +11 -7
- package/src/compare.js +41 -22
- package/src/diff.js +38 -24
- package/src/identity.js +9 -7
- package/src/init.js +2 -2
- package/src/install.js +147 -459
- package/src/loader.js +10 -10
- package/src/package-store.js +232 -0
- package/src/paths.js +44 -0
- package/src/publish.js +150 -51
- package/src/registry.js +81 -9
- package/src/setup.js +19 -20
- package/src/verify.js +293 -140
- package/src/version.js +15 -7
- package/templates/minimal-domain/kdna.json +7 -7
- package/templates/standard-domain/README.md +10 -10
- package/templates/standard-domain/kdna.json +7 -3
- package/validators/kdna-lint.js +45 -11
- package/src/cmds/encrypt.js +0 -199
package/src/diff.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* kdna diff <name>@<ver1> <name>@<ver2> — Judgment-level diff between versions.
|
|
3
3
|
*
|
|
4
|
-
* Downloads two .kdna packages from the registry, extracts to temp dirs,
|
|
4
|
+
* Downloads two .kdna dev packages from the registry, extracts to temp dirs,
|
|
5
5
|
* compares axioms / misunderstandings / banned_terms / stances / boundary,
|
|
6
6
|
* and surfaces what would change for an agent loading the new version.
|
|
7
7
|
*
|
|
@@ -19,11 +19,10 @@
|
|
|
19
19
|
const fs = require('fs');
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const { execSync, execFileSync } = require('child_process');
|
|
22
|
-
const { RegistryResolver
|
|
22
|
+
const { RegistryResolver } = require('./registry');
|
|
23
23
|
const { EXIT } = require('./cmds/_common');
|
|
24
|
+
const { getInstalled, readContainer } = require('./package-store');
|
|
24
25
|
|
|
25
|
-
const USER_KDNA_DIR = path.join(process.env.HOME || process.env.USERPROFILE || '.', '.kdna');
|
|
26
|
-
const INSTALL_DIR = path.join(USER_KDNA_DIR, 'domains');
|
|
27
26
|
const TMP_DIR = '/tmp';
|
|
28
27
|
|
|
29
28
|
function error(msg, code = EXIT.VALIDATION_FAILED) {
|
|
@@ -58,14 +57,15 @@ function parseNameVersion(input) {
|
|
|
58
57
|
// ─── Download specific version ────────────────────────────────────────
|
|
59
58
|
|
|
60
59
|
function downloadVersion(entry, version, destDir) {
|
|
61
|
-
|
|
60
|
+
const assetUrl = entry.asset_url;
|
|
61
|
+
// assetUrl is for the registry-current version. For older versions
|
|
62
62
|
// we infer the URL pattern from the registry-current URL.
|
|
63
63
|
if (entry.version === version) {
|
|
64
|
-
return downloadAndExtract(
|
|
64
|
+
return downloadAndExtract(assetUrl, destDir);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// Infer pattern: replace v<current> in the URL with v<requested>
|
|
68
|
-
const inferredUrl =
|
|
68
|
+
const inferredUrl = assetUrl
|
|
69
69
|
.replace(`/v${entry.version}/`, `/v${version}/`)
|
|
70
70
|
.replace(`-${entry.version}.kdna`, `-${version}.kdna`);
|
|
71
71
|
|
|
@@ -80,7 +80,10 @@ function downloadAndExtract(url, destDir) {
|
|
|
80
80
|
stdio: 'pipe',
|
|
81
81
|
});
|
|
82
82
|
} catch (e) {
|
|
83
|
-
error(
|
|
83
|
+
error(
|
|
84
|
+
`Failed to download ${url}: ${e.stderr?.toString().trim() || e.message}`,
|
|
85
|
+
EXIT.PROVIDER_ERROR,
|
|
86
|
+
);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
fs.mkdirSync(destDir, { recursive: true });
|
|
@@ -232,19 +235,20 @@ async function cmdDiff(a, b, args = []) {
|
|
|
232
235
|
newEntry = entryB;
|
|
233
236
|
} else {
|
|
234
237
|
// single-arg form: installed vs registry-current
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
if (!fs.existsSync(localDir)) {
|
|
238
|
+
const installed = getInstalled(aParsed.full);
|
|
239
|
+
if (!installed) {
|
|
238
240
|
error(`${aParsed.full} not installed. Run: kdna install ${aParsed.full}`, EXIT.INPUT_ERROR);
|
|
239
241
|
}
|
|
240
|
-
const localManifest =
|
|
242
|
+
const localManifest = readContainer(installed.asset_path).manifest || {};
|
|
241
243
|
oldVersion = localManifest?.version || '?';
|
|
242
244
|
newVersion = entryA.version;
|
|
243
245
|
oldEntry = entryA;
|
|
244
246
|
newEntry = entryA;
|
|
245
247
|
if (oldVersion === newVersion) {
|
|
246
248
|
if (jsonMode) {
|
|
247
|
-
console.log(
|
|
249
|
+
console.log(
|
|
250
|
+
JSON.stringify({ error: `${aParsed.full}@${oldVersion}: only one version found.` }),
|
|
251
|
+
);
|
|
248
252
|
process.exit(EXIT.OK);
|
|
249
253
|
}
|
|
250
254
|
console.log(
|
|
@@ -284,8 +288,14 @@ async function cmdDiff(a, b, args = []) {
|
|
|
284
288
|
);
|
|
285
289
|
}
|
|
286
290
|
|
|
287
|
-
const axiomsDiff = diffMaps(
|
|
288
|
-
|
|
291
|
+
const axiomsDiff = diffMaps(
|
|
292
|
+
'axioms',
|
|
293
|
+
oldJ.axioms,
|
|
294
|
+
newJ.axioms,
|
|
295
|
+
(a) => a.one_sentence || a.id,
|
|
296
|
+
jsonMode,
|
|
297
|
+
);
|
|
298
|
+
diffMaps('ontology', oldJ.ontology, newJ.ontology, (o) => o.one_sentence || o.id, jsonMode);
|
|
289
299
|
const misunderstandingsDiff = diffMaps(
|
|
290
300
|
'misunderstandings',
|
|
291
301
|
oldJ.misunderstandings,
|
|
@@ -293,7 +303,13 @@ async function cmdDiff(a, b, args = []) {
|
|
|
293
303
|
(m) => m.wrong || m.id,
|
|
294
304
|
jsonMode,
|
|
295
305
|
);
|
|
296
|
-
const bannedDiff = diffMaps(
|
|
306
|
+
const bannedDiff = diffMaps(
|
|
307
|
+
'banned_terms',
|
|
308
|
+
oldJ.banned_terms,
|
|
309
|
+
newJ.banned_terms,
|
|
310
|
+
(t) => t.term || '',
|
|
311
|
+
jsonMode,
|
|
312
|
+
);
|
|
297
313
|
const stancesDiff = diffStanceList(oldJ.stances, newJ.stances, jsonMode);
|
|
298
314
|
|
|
299
315
|
// Cleanup
|
|
@@ -333,11 +349,7 @@ async function cmdDiff(a, b, args = []) {
|
|
|
333
349
|
}));
|
|
334
350
|
|
|
335
351
|
const affectedScenarios = axiomsDiff.changedDetails
|
|
336
|
-
.filter(
|
|
337
|
-
(d) =>
|
|
338
|
-
d.boundary_changes.applies_when ||
|
|
339
|
-
d.boundary_changes.does_not_apply_when,
|
|
340
|
-
)
|
|
352
|
+
.filter((d) => d.boundary_changes.applies_when || d.boundary_changes.does_not_apply_when)
|
|
341
353
|
.map((d) => ({
|
|
342
354
|
axiom_id: d.id,
|
|
343
355
|
applies_when: d.boundary_changes.applies_when || null,
|
|
@@ -345,14 +357,14 @@ async function cmdDiff(a, b, args = []) {
|
|
|
345
357
|
}));
|
|
346
358
|
|
|
347
359
|
// Determine recommended version bump
|
|
348
|
-
const axiomDrift = Object.keys(newJ.axioms).length - Object.keys(oldJ.axioms).length;
|
|
349
360
|
const hasRemoved = axiomsDiff.removed.length > 0 || misunderstandingsDiff.removed.length > 0;
|
|
350
361
|
const hasAdded = axiomsDiff.added.length > 0 || misunderstandingsDiff.added.length > 0;
|
|
351
362
|
const hasChanged = axiomsDiff.changed.length > 0 || bannedDiff.changed.length > 0;
|
|
352
363
|
let recommendedVersionBump = 'none';
|
|
353
364
|
if (hasRemoved) recommendedVersionBump = 'major';
|
|
354
365
|
else if (hasAdded || hasChanged) recommendedVersionBump = 'minor';
|
|
355
|
-
else if (stancesDiff.added.length > 0 || stancesDiff.removed.length > 0)
|
|
366
|
+
else if (stancesDiff.added.length > 0 || stancesDiff.removed.length > 0)
|
|
367
|
+
recommendedVersionBump = 'patch';
|
|
356
368
|
|
|
357
369
|
if (jsonMode) {
|
|
358
370
|
const result = {
|
|
@@ -378,7 +390,9 @@ async function cmdDiff(a, b, args = []) {
|
|
|
378
390
|
const drift = Object.keys(newJ.axioms).length - Object.keys(oldJ.axioms).length;
|
|
379
391
|
const note = drift !== 0 ? ` (axiom count drift: ${drift > 0 ? '+' : ''}${drift})` : '';
|
|
380
392
|
console.log(` Judgment surface change: ${oldVersion} → ${newVersion}${note}`);
|
|
381
|
-
console.log(
|
|
393
|
+
console.log(
|
|
394
|
+
` Agent loading the new version may classify, diagnose, or recommend differently.`,
|
|
395
|
+
);
|
|
382
396
|
console.log('═'.repeat(64));
|
|
383
397
|
}
|
|
384
398
|
}
|
package/src/identity.js
CHANGED
|
@@ -90,13 +90,15 @@ function cmdIdentityShow(jsonMode = false) {
|
|
|
90
90
|
const fp = fingerprint(pub);
|
|
91
91
|
|
|
92
92
|
if (jsonMode) {
|
|
93
|
-
console.log(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
console.log(
|
|
94
|
+
JSON.stringify({
|
|
95
|
+
pubkey: pub.trim(),
|
|
96
|
+
buyer_id: id,
|
|
97
|
+
fingerprint: fp,
|
|
98
|
+
public_key_path: PUBLIC_KEY_PATH,
|
|
99
|
+
private_key_exists: fs.existsSync(PRIVATE_KEY_PATH),
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
100
102
|
process.exit(EXIT.OK);
|
|
101
103
|
}
|
|
102
104
|
|
package/src/init.js
CHANGED
|
@@ -91,7 +91,7 @@ function cmdInit(name) {
|
|
|
91
91
|
` 2. Edit ${targetDir}/KDNA_Patterns.json — replace terminology and misunderstandings`,
|
|
92
92
|
);
|
|
93
93
|
console.log(` 3. Edit ${targetDir}/kdna.json — set author, description, repo`);
|
|
94
|
-
console.log(` 4. Run: kdna validate ${name}
|
|
94
|
+
console.log(` 4. Run: kdna dev validate ${name} (structural check)`);
|
|
95
95
|
console.log(` 5. Run: kdna publish --check ${name} (content quality gate)`);
|
|
96
96
|
console.log(` 6. Run: kdna verify ${name} (full judgment scoring)`);
|
|
97
97
|
}
|
|
@@ -162,7 +162,7 @@ function cmdClusterInit(name) {
|
|
|
162
162
|
console.log(
|
|
163
163
|
` 3. Add more sub-domains: cp -r ${targetDir}/domain_one ${targetDir}/your_new_domain`,
|
|
164
164
|
);
|
|
165
|
-
console.log(` 4. Run: kdna validate ${name}
|
|
165
|
+
console.log(` 4. Run: kdna dev validate ${name} (check all sub-domains)`);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
module.exports = { cmdInit, cmdClusterInit };
|