@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/cli.js
CHANGED
|
@@ -7,15 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const { error, EXIT, setQuiet, setExitCodeOnly } = require('./cmds/_common');
|
|
10
|
-
const {
|
|
11
|
-
cmdValidate,
|
|
12
|
-
cmdPack,
|
|
13
|
-
cmdPackEncrypt,
|
|
14
|
-
cmdUnpack,
|
|
15
|
-
cmdUnpackEncrypt,
|
|
16
|
-
cmdInspect,
|
|
17
|
-
cmdCard,
|
|
18
|
-
} = require('./cmds/domain');
|
|
10
|
+
const { cmdValidate, cmdPack, cmdUnpack, cmdInspect, cmdCard } = require('./cmds/domain');
|
|
19
11
|
const { cmdList, cmdRegistry } = require('./cmds/registry');
|
|
20
12
|
const {
|
|
21
13
|
cmdCompare,
|
|
@@ -39,6 +31,9 @@ const {
|
|
|
39
31
|
cmdLicenseBind,
|
|
40
32
|
cmdLicenseShow,
|
|
41
33
|
cmdLicenseInstall,
|
|
34
|
+
cmdLicenseStatus,
|
|
35
|
+
cmdLicenseActivate,
|
|
36
|
+
cmdLicenseSync,
|
|
42
37
|
} = require('./cmds/license');
|
|
43
38
|
const { cmdPreview, cmdProject, cmdEval, cmdExport, cmdDemo } = require('./cmds/legacy');
|
|
44
39
|
const {
|
|
@@ -58,7 +53,8 @@ const {
|
|
|
58
53
|
cmdEvolution,
|
|
59
54
|
cmdRegression,
|
|
60
55
|
} = require('./cmds/governance');
|
|
61
|
-
const { cmdBadgeCompute, cmdRegistryAudit
|
|
56
|
+
const { cmdBadgeCompute, cmdRegistryAudit } = require('./cmds/badge');
|
|
57
|
+
const { cmdExplain } = require('./cmds/explain');
|
|
62
58
|
|
|
63
59
|
// ─── Main ─────────────────────────────────────────────────────────────
|
|
64
60
|
|
|
@@ -80,15 +76,14 @@ Usage: kdna <command> [options]
|
|
|
80
76
|
|
|
81
77
|
Domain Authoring:
|
|
82
78
|
init <name> Scaffold a new domain from template
|
|
83
|
-
validate <path>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
card <path> [--locale zh-CN] Display KDNA Card (governance metadata)
|
|
79
|
+
dev validate <path> Validate a dev source directory
|
|
80
|
+
dev pack <path> Build a dev source directory into .kdna
|
|
81
|
+
dev unpack <file> Unpack .kdna into a dev source directory
|
|
82
|
+
dev inspect <path> Inspect a dev source directory
|
|
83
|
+
dev card <path> Display KDNA Card from a dev source directory
|
|
84
|
+
inspect <file.kdna> Inspect a .kdna asset
|
|
85
|
+
card <file.kdna> [--locale zh-CN] Display KDNA Card from a .kdna asset
|
|
86
|
+
explain <name> Natural language summary: axioms, terms, scenarios
|
|
92
87
|
publish <path> Pack + sign + publish
|
|
93
88
|
publish --check <path> Quality gate check only
|
|
94
89
|
version bump <level> [path] Bump domain version
|
|
@@ -106,18 +101,18 @@ Agent Runtime:
|
|
|
106
101
|
available [--json] List installed domains with v2.1 fields
|
|
107
102
|
match "<task>" [--json] Signal matching — find relevant domains
|
|
108
103
|
select --input "..." [--json] Selection policy — decide which domains to load
|
|
109
|
-
load <name> [--as=prompt|json|raw] Emit
|
|
110
|
-
load <name> --profile=index|compact|scenario|full Load profiles (Phase 2)
|
|
104
|
+
load <name|file.kdna> [--as=prompt|json|raw] Emit asset in agent-ready format
|
|
105
|
+
load <name|file.kdna> --profile=index|compact|scenario|full Load profiles (Phase 2)
|
|
111
106
|
postvalidate <name> --output <file> Post-generation judgment check
|
|
112
107
|
|
|
113
108
|
Testing & Verification:
|
|
114
|
-
verify <name>
|
|
115
|
-
verify <name> --i18n
|
|
116
|
-
verify <name> --governance
|
|
117
|
-
verify <name> --judgment --run-tests Judgment validation with eval cases
|
|
118
|
-
compare <name> --input "..." With/without KDNA reasoning diff
|
|
119
|
-
compare <name> --input "..." --report-md Markdown report format
|
|
120
|
-
compare <name> --input "..." --report-json JSON report with scoring
|
|
109
|
+
verify <name|file.kdna> 3-layer: structure + trust + judgment
|
|
110
|
+
verify <name|file.kdna> --i18n I18N verification: locales, overlays, card completeness
|
|
111
|
+
verify <name|file.kdna> --governance Governance verification: risk_level, KDNA_CARD, provenance
|
|
112
|
+
verify <name|file.kdna> --judgment --run-tests Judgment validation with eval cases
|
|
113
|
+
compare <name|file.kdna> --input "..." With/without KDNA reasoning diff
|
|
114
|
+
compare <name|file.kdna> --input "..." --report-md Markdown report format
|
|
115
|
+
compare <name|file.kdna> --input "..." --report-json JSON report with scoring
|
|
121
116
|
diff <name>@<v1> <name>@<v2> Judgment-level diff between versions
|
|
122
117
|
test run <name> --input <file> Record test result against domain
|
|
123
118
|
test import <run> --as-eval Convert test result to eval card
|
|
@@ -148,6 +143,7 @@ Quality & Distribution (Phase 7):
|
|
|
148
143
|
|
|
149
144
|
Registry & Distribution:
|
|
150
145
|
install <name> Install domain from registry
|
|
146
|
+
install <file.kdna> Install a local .kdna asset
|
|
151
147
|
remove <name> Uninstall a domain
|
|
152
148
|
update <name> Update installed domain
|
|
153
149
|
info <name> Show domain metadata and trust status
|
|
@@ -172,9 +168,12 @@ Trace & Diagnostics:
|
|
|
172
168
|
License & Authorization:
|
|
173
169
|
license generate <domain> --to <email> Generate signed license
|
|
174
170
|
license install <license.json> Register license for auto-decrypt
|
|
171
|
+
license activate <domain> --key --server Activate license from entitlement source
|
|
172
|
+
license sync [domain] [--server] Refresh entitlement / revocation status
|
|
175
173
|
license verify <license.json> Verify license signature
|
|
176
174
|
license bind <license.json> Bind license to this machine
|
|
177
175
|
license show <license.json> Display license details
|
|
176
|
+
license status [domain] [--json] Show installed license activation status
|
|
178
177
|
|
|
179
178
|
Flags:
|
|
180
179
|
--json Structured JSON output (machine-readable)
|
|
@@ -190,41 +189,78 @@ Exit Codes:
|
|
|
190
189
|
const cmd = args[0];
|
|
191
190
|
|
|
192
191
|
switch (cmd) {
|
|
192
|
+
case 'dev': {
|
|
193
|
+
const sub = args[1];
|
|
194
|
+
if (sub === 'validate') {
|
|
195
|
+
const schemaFlag = args.includes('--schema');
|
|
196
|
+
const jsonFlag = args.includes('--json');
|
|
197
|
+
const target = args.filter((a, i) => i > 1 && a !== '--schema' && a !== '--json')[0];
|
|
198
|
+
if (!target) error('Usage: kdna dev validate <source-dir>');
|
|
199
|
+
cmdValidate(target, schemaFlag, jsonFlag);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
if (sub === 'pack') {
|
|
203
|
+
let output = null;
|
|
204
|
+
let target = null;
|
|
205
|
+
for (let i = 2; i < args.length; i++) {
|
|
206
|
+
if (args[i] === '--output' || args[i] === '-o') {
|
|
207
|
+
output = args[i + 1];
|
|
208
|
+
i++;
|
|
209
|
+
} else if (args[i].startsWith('-')) {
|
|
210
|
+
error(`Unknown option for kdna dev pack: ${args[i]}`, EXIT.INPUT_ERROR);
|
|
211
|
+
} else if (!target) {
|
|
212
|
+
target = args[i];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (!target) error('Usage: kdna dev pack <source-dir>');
|
|
216
|
+
cmdPack(target, output);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
if (sub === 'unpack') {
|
|
220
|
+
const target = args[2];
|
|
221
|
+
if (!target) error('Usage: kdna dev unpack <file.kdna>');
|
|
222
|
+
if (!target.endsWith('.kdna')) error('Not a .kdna asset.', EXIT.INPUT_ERROR);
|
|
223
|
+
cmdUnpack(target, args.includes('--force'));
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
if (sub === 'inspect') {
|
|
227
|
+
const target = args.filter((a, i) => i > 1 && !a.startsWith('--'))[0];
|
|
228
|
+
if (!target) error('Usage: kdna dev inspect <source-dir> [--json] [--locale zh-CN]');
|
|
229
|
+
const localeIdx = args.indexOf('--locale');
|
|
230
|
+
const locale = localeIdx >= 0 ? args[localeIdx + 1] : null;
|
|
231
|
+
cmdInspect(target, args.includes('--json'), locale, { allowDirectory: true });
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
if (sub === 'card') {
|
|
235
|
+
const target = args.filter((a, i) => i > 1 && !a.startsWith('--'))[0];
|
|
236
|
+
if (!target) error('Usage: kdna dev card <source-dir> [--json] [--locale zh-CN]');
|
|
237
|
+
const localeIdx = args.indexOf('--locale');
|
|
238
|
+
const locale = localeIdx >= 0 ? args[localeIdx + 1] : null;
|
|
239
|
+
cmdCard(target, args.includes('--json'), locale, { allowDirectory: true });
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
error('Usage: kdna dev <validate|pack|unpack|inspect|card> ...', EXIT.INPUT_ERROR);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
193
245
|
case 'validate': {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
cmdValidate(target, schemaFlag, jsonFlag);
|
|
246
|
+
error(
|
|
247
|
+
'Directory validation is a dev-only operation. Use: kdna dev validate <source-dir>',
|
|
248
|
+
EXIT.INPUT_ERROR,
|
|
249
|
+
);
|
|
199
250
|
break;
|
|
200
251
|
}
|
|
201
252
|
case 'pack': {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
output = args[i + 1];
|
|
207
|
-
i++;
|
|
208
|
-
} else if (!target) {
|
|
209
|
-
target = args[i];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (!target) error('Usage: kdna pack <path>');
|
|
213
|
-
if (args.includes('--encrypt')) {
|
|
214
|
-
cmdPackEncrypt(target, args);
|
|
215
|
-
} else {
|
|
216
|
-
cmdPack(target, output);
|
|
217
|
-
}
|
|
253
|
+
error(
|
|
254
|
+
'Directory packaging is a dev-only operation. Use: kdna dev pack <source-dir>',
|
|
255
|
+
EXIT.INPUT_ERROR,
|
|
256
|
+
);
|
|
218
257
|
break;
|
|
219
258
|
}
|
|
220
259
|
case 'unpack': {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
} else {
|
|
226
|
-
cmdUnpack(target, args.includes('--force'));
|
|
227
|
-
}
|
|
260
|
+
error(
|
|
261
|
+
'Unpacking exposes internal files and is dev-only. Use: kdna dev unpack <file.kdna>',
|
|
262
|
+
EXIT.INPUT_ERROR,
|
|
263
|
+
);
|
|
228
264
|
break;
|
|
229
265
|
}
|
|
230
266
|
case 'preview': {
|
|
@@ -242,7 +278,7 @@ switch (cmd) {
|
|
|
242
278
|
domainId = args[i];
|
|
243
279
|
}
|
|
244
280
|
}
|
|
245
|
-
if (!domainId) error('Usage: kdna install <domain-id|
|
|
281
|
+
if (!domainId) error('Usage: kdna install <domain-id|file.kdna>');
|
|
246
282
|
|
|
247
283
|
const { cmdInstallExtended } = require('./install');
|
|
248
284
|
if (fromGit) {
|
|
@@ -285,7 +321,7 @@ switch (cmd) {
|
|
|
285
321
|
}
|
|
286
322
|
case 'inspect': {
|
|
287
323
|
const target = args.filter((a) => !a.startsWith('--'))[1];
|
|
288
|
-
if (!target) error('Usage: kdna inspect <
|
|
324
|
+
if (!target) error('Usage: kdna inspect <file.kdna> [--json] [--locale zh-CN]');
|
|
289
325
|
const localeIdx = args.indexOf('--locale');
|
|
290
326
|
const locale = localeIdx >= 0 ? args[localeIdx + 1] : null;
|
|
291
327
|
cmdInspect(target, args.includes('--json'), locale);
|
|
@@ -293,7 +329,7 @@ switch (cmd) {
|
|
|
293
329
|
}
|
|
294
330
|
case 'card': {
|
|
295
331
|
const target = args.filter((a) => !a.startsWith('--'))[1];
|
|
296
|
-
if (!target) error('Usage: kdna card <
|
|
332
|
+
if (!target) error('Usage: kdna card <file.kdna> [--json] [--locale zh-CN]');
|
|
297
333
|
const localeIdx = args.indexOf('--locale');
|
|
298
334
|
const locale = localeIdx >= 0 ? args[localeIdx + 1] : null;
|
|
299
335
|
cmdCard(target, args.includes('--json'), locale);
|
|
@@ -305,10 +341,10 @@ switch (cmd) {
|
|
|
305
341
|
if (!target) {
|
|
306
342
|
error(
|
|
307
343
|
'Usage:\n' +
|
|
308
|
-
' kdna verify <name> Run all three layers (structure / trust / judgment)\n' +
|
|
309
|
-
' kdna verify <name> --structure Files + schema only\n' +
|
|
310
|
-
' kdna verify <name> --trust Signature + scope + Ed25519 only\n' +
|
|
311
|
-
' kdna verify <name> --judgment v2.1 governance fields + eval cases only',
|
|
344
|
+
' kdna verify <name|file.kdna> Run all three layers (structure / trust / judgment)\n' +
|
|
345
|
+
' kdna verify <name|file.kdna> --structure Files + schema only\n' +
|
|
346
|
+
' kdna verify <name|file.kdna> --trust Signature + scope + Ed25519 only\n' +
|
|
347
|
+
' kdna verify <name|file.kdna> --judgment v2.1 governance fields + eval cases only',
|
|
312
348
|
);
|
|
313
349
|
}
|
|
314
350
|
cmdVerify(target, args);
|
|
@@ -430,9 +466,10 @@ switch (cmd) {
|
|
|
430
466
|
break;
|
|
431
467
|
}
|
|
432
468
|
case 'package': {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
469
|
+
error(
|
|
470
|
+
'Directory packaging is a dev-only operation. Use: kdna dev pack <source-dir>',
|
|
471
|
+
EXIT.INPUT_ERROR,
|
|
472
|
+
);
|
|
436
473
|
break;
|
|
437
474
|
}
|
|
438
475
|
// Legacy (removed) commands
|
|
@@ -452,6 +489,10 @@ switch (cmd) {
|
|
|
452
489
|
cmdDemo();
|
|
453
490
|
break;
|
|
454
491
|
}
|
|
492
|
+
case 'explain': {
|
|
493
|
+
cmdExplain(args);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
455
496
|
case 'list': {
|
|
456
497
|
const localeIdx = args.indexOf('--locale');
|
|
457
498
|
const locale = localeIdx >= 0 ? args[localeIdx + 1] : null;
|
|
@@ -491,14 +532,23 @@ switch (cmd) {
|
|
|
491
532
|
cmdLicenseShow(rest);
|
|
492
533
|
} else if (sub === 'install') {
|
|
493
534
|
cmdLicenseInstall(rest);
|
|
535
|
+
} else if (sub === 'status') {
|
|
536
|
+
cmdLicenseStatus(rest);
|
|
537
|
+
} else if (sub === 'activate') {
|
|
538
|
+
cmdLicenseActivate(rest).catch((e) => error(e.message, EXIT.TRUST_FAILED));
|
|
539
|
+
} else if (sub === 'sync') {
|
|
540
|
+
cmdLicenseSync(rest).catch((e) => error(e.message, EXIT.TRUST_FAILED));
|
|
494
541
|
} else {
|
|
495
542
|
error(
|
|
496
543
|
'Usage:\n' +
|
|
497
544
|
' kdna license generate <domain> --to <email> [--expires <date>]\n' +
|
|
498
545
|
' kdna license install <license.json>\n' +
|
|
546
|
+
' kdna license activate <domain> --key <license-key> --server <url>\n' +
|
|
547
|
+
' kdna license sync [domain] [--server <url>]\n' +
|
|
499
548
|
' kdna license verify <license.json>\n' +
|
|
500
549
|
' kdna license bind <license.json>\n' +
|
|
501
|
-
' kdna license show <license.json
|
|
550
|
+
' kdna license show <license.json>\n' +
|
|
551
|
+
' kdna license status [domain] [--json]',
|
|
502
552
|
EXIT.INPUT_ERROR,
|
|
503
553
|
);
|
|
504
554
|
}
|
package/src/cmds/_common.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
2
|
const { loadRegistry: loadCanonicalRegistry } = require('../registry');
|
|
4
|
-
|
|
5
|
-
const USER_KDNA_DIR = path.join(process.env.HOME || process.env.USERPROFILE || '.', '.kdna');
|
|
6
|
-
const INSTALL_DIR = path.join(USER_KDNA_DIR, 'domains');
|
|
3
|
+
const { USER_KDNA_DIR, INSTALL_DIR } = require('../paths');
|
|
7
4
|
|
|
8
5
|
// ─── Global flags ──────────────────────────────────────────────────────
|
|
9
6
|
|
|
@@ -22,7 +19,9 @@ function setQuiet(val) {
|
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
function isQuiet() {
|
|
22
|
+
function isQuiet() {
|
|
23
|
+
return _quiet;
|
|
24
|
+
}
|
|
26
25
|
|
|
27
26
|
function setExitCodeOnly(val) {
|
|
28
27
|
_exitCodeOnly = val;
|
|
@@ -37,7 +36,9 @@ function setExitCodeOnly(val) {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
function isExitCodeOnly() {
|
|
39
|
+
function isExitCodeOnly() {
|
|
40
|
+
return _exitCodeOnly;
|
|
41
|
+
}
|
|
41
42
|
|
|
42
43
|
function log(...args) {
|
|
43
44
|
if (!_quiet && !_exitCodeOnly) _originalLog(...args);
|
|
@@ -54,14 +55,13 @@ Usage:
|
|
|
54
55
|
|
|
55
56
|
--- Domain authors ---
|
|
56
57
|
kdna init <name> Scaffold a new KDNA domain from template
|
|
57
|
-
kdna validate <path>
|
|
58
|
-
kdna
|
|
59
|
-
kdna
|
|
60
|
-
kdna
|
|
61
|
-
kdna
|
|
62
|
-
kdna
|
|
63
|
-
kdna
|
|
64
|
-
kdna publish <path> Pack + sign + output registry patch
|
|
58
|
+
kdna dev validate <path> Validate a dev source directory
|
|
59
|
+
kdna dev pack <path> Build a dev source directory into .kdna
|
|
60
|
+
kdna dev unpack <path> Unpack .kdna into a dev source directory
|
|
61
|
+
kdna dev inspect <path> Inspect a dev source directory
|
|
62
|
+
kdna dev card <path> Display KDNA Card from a dev source directory
|
|
63
|
+
kdna inspect <file.kdna> Inspect a .kdna asset
|
|
64
|
+
kdna publish <path> Pack + sign a dev source directory
|
|
65
65
|
kdna publish <path> --release-tag <tag> --repo <o/r> ...also upload to GitHub
|
|
66
66
|
kdna publish --check <path> Run quality gate only (no pack/upload)
|
|
67
67
|
kdna version bump <patch|minor|major> [path] Bump domain version
|
|
@@ -72,7 +72,6 @@ Usage:
|
|
|
72
72
|
kdna install @scope/name Install any scoped domain
|
|
73
73
|
kdna install @aikdna/animation Install a cluster (installs all sub-domains)
|
|
74
74
|
kdna install ./file.kdna Install from a local .kdna file
|
|
75
|
-
kdna install ./folder Install from a local directory (dev)
|
|
76
75
|
kdna remove <name> Uninstall a domain
|
|
77
76
|
kdna update <name> Update an installed domain
|
|
78
77
|
kdna update --all Update all installed domains
|
|
@@ -83,14 +82,14 @@ Usage:
|
|
|
83
82
|
kdna registry refresh Refresh the canonical registry cache
|
|
84
83
|
|
|
85
84
|
--- Quality + judgment ---
|
|
86
|
-
kdna verify <name>
|
|
87
|
-
kdna compare <name> --input "<text>" With/without KDNA reasoning diff
|
|
85
|
+
kdna verify <name|file.kdna> Quality check: structure + trust + judgment
|
|
86
|
+
kdna compare <name|file.kdna> --input "<text>" With/without KDNA reasoning diff
|
|
88
87
|
kdna diff <name>@<v1> <name>@<v2> Judgment-level diff between versions
|
|
89
88
|
|
|
90
89
|
--- Agent-facing (called by the kdna-loader skill) ---
|
|
91
90
|
kdna available [--json] List installed domains + v2.1 fields
|
|
92
91
|
kdna match "<task>" [--json] Hint signals (dropped + weak overlap)
|
|
93
|
-
kdna load <name> [--as=prompt|json|raw] Emit
|
|
92
|
+
kdna load <name|file.kdna> [--as=prompt|json|raw] Emit asset in agent-ready format
|
|
94
93
|
|
|
95
94
|
--- Identity ---
|
|
96
95
|
kdna identity init Generate Ed25519 identity key pair
|
|
@@ -144,6 +143,27 @@ function writeJson(file, data) {
|
|
|
144
143
|
fs.writeFileSync(file, JSON.stringify(data, null, 2) + '\n');
|
|
145
144
|
}
|
|
146
145
|
|
|
146
|
+
function selfCheckText(item) {
|
|
147
|
+
if (typeof item === 'string') return item;
|
|
148
|
+
if (item && typeof item === 'object' && typeof item.question === 'string') return item.question;
|
|
149
|
+
return '';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function isYesNoSelfCheck(item) {
|
|
153
|
+
const raw = selfCheckText(item).trim();
|
|
154
|
+
if (!raw) return false;
|
|
155
|
+
const lower = raw.toLowerCase();
|
|
156
|
+
return (
|
|
157
|
+
lower.endsWith('?') ||
|
|
158
|
+
raw.endsWith('?') ||
|
|
159
|
+
raw.endsWith('吗') ||
|
|
160
|
+
raw.includes('是否') ||
|
|
161
|
+
/^(have|has|can|does|do|is|are|did|was|were|should|will|would|could|might|can not|cannot|能不能|会不会|有没有|要不要|是不是)/.test(
|
|
162
|
+
lower,
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
147
167
|
function loadRegistry() {
|
|
148
168
|
return loadCanonicalRegistry({ allowNetwork: true });
|
|
149
169
|
}
|
|
@@ -162,5 +182,7 @@ module.exports = {
|
|
|
162
182
|
isExitCodeOnly,
|
|
163
183
|
readJson,
|
|
164
184
|
writeJson,
|
|
185
|
+
selfCheckText,
|
|
186
|
+
isYesNoSelfCheck,
|
|
165
187
|
loadRegistry,
|
|
166
188
|
};
|
package/src/cmds/badge.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* kdna badge compute <domain> [--json]
|
|
5
5
|
* kdna registry audit --scope <scope> [--json]
|
|
6
|
-
* kdna
|
|
6
|
+
* kdna dev pack <domain>
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const fs = require('fs');
|
|
@@ -142,9 +142,9 @@ function cmdRegistryAudit(args = []) {
|
|
|
142
142
|
status: d.status || 'experimental',
|
|
143
143
|
yanked: d.yanked || false,
|
|
144
144
|
deprecated: d.deprecated || false,
|
|
145
|
-
|
|
145
|
+
has_asset_url: !!d.asset_url,
|
|
146
146
|
has_signature: !!d.signature,
|
|
147
|
-
|
|
147
|
+
has_asset_digest: !!d.asset_digest,
|
|
148
148
|
})),
|
|
149
149
|
issues: [],
|
|
150
150
|
};
|
|
@@ -152,12 +152,13 @@ function cmdRegistryAudit(args = []) {
|
|
|
152
152
|
// Detect issues
|
|
153
153
|
const yanked = scopeDomains.filter((d) => d.yanked);
|
|
154
154
|
const deprecated = scopeDomains.filter((d) => d.deprecated);
|
|
155
|
-
const noPackage = scopeDomains.filter((d) => !d.
|
|
155
|
+
const noPackage = scopeDomains.filter((d) => !d.asset_url);
|
|
156
156
|
const noSignature = scopeDomains.filter((d) => !d.signature);
|
|
157
157
|
|
|
158
158
|
if (yanked.length) audit.issues.push(`${yanked.length} yanked domain(s)`);
|
|
159
159
|
if (deprecated.length) audit.issues.push(`${deprecated.length} deprecated domain(s)`);
|
|
160
|
-
if (noPackage.length)
|
|
160
|
+
if (noPackage.length)
|
|
161
|
+
audit.issues.push(`${noPackage.length} domain(s) without .kdna dev package`);
|
|
161
162
|
if (noSignature.length) audit.issues.push(`${noSignature.length} domain(s) without signature`);
|
|
162
163
|
|
|
163
164
|
audit.healthy = audit.issues.length === 0;
|
|
@@ -183,8 +184,10 @@ function cmdRegistryAudit(args = []) {
|
|
|
183
184
|
const flags = [];
|
|
184
185
|
if (d.yanked) flags.push('yanked');
|
|
185
186
|
if (d.deprecated) flags.push('deprecated');
|
|
186
|
-
if (!d.
|
|
187
|
-
console.log(
|
|
187
|
+
if (!d.has_asset_url) flags.push('no-package');
|
|
188
|
+
console.log(
|
|
189
|
+
` ${d.name.padEnd(36)} v${d.version || '?'} ${flags.length ? `[${flags.join(', ')}]` : '✓'}`,
|
|
190
|
+
);
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
|
|
@@ -205,7 +208,7 @@ function cmdPackage(domainPath, args = []) {
|
|
|
205
208
|
}
|
|
206
209
|
|
|
207
210
|
const manifest = readJson(path.join(abs, 'kdna.json'));
|
|
208
|
-
if (!manifest) error(`No kdna.json found in ${abs}. Run: kdna pack`, EXIT.INPUT_ERROR);
|
|
211
|
+
if (!manifest) error(`No kdna.json found in ${abs}. Run: kdna dev pack`, EXIT.INPUT_ERROR);
|
|
209
212
|
|
|
210
213
|
const domainName = manifest.name?.split('/')?.[1] || path.basename(abs);
|
|
211
214
|
const outFile = path.join(abs, 'dist', `${domainName}-${manifest.version || '0.1.0'}.kdna`);
|
|
@@ -230,7 +233,9 @@ function cmdPackage(domainPath, args = []) {
|
|
|
230
233
|
scenarios: readJson(path.join(abs, 'KDNA_Scenarios.json'))?.scenes?.length || 0,
|
|
231
234
|
cases: readJson(path.join(abs, 'KDNA_Cases.json'))?.cases?.length || 0,
|
|
232
235
|
},
|
|
233
|
-
files: fs
|
|
236
|
+
files: fs
|
|
237
|
+
.readdirSync(abs)
|
|
238
|
+
.filter((f) => f.endsWith('.json') || f === 'README.md' || f === 'LICENSE'),
|
|
234
239
|
};
|
|
235
240
|
|
|
236
241
|
// Actually pack
|
package/src/cmds/changelog.js
CHANGED
|
@@ -18,7 +18,7 @@ function downloadVersion(entry, version, destDir) {
|
|
|
18
18
|
const { execSync, execFileSync } = require('child_process');
|
|
19
19
|
const tmpFile = `${destDir}.kdna.tmp`;
|
|
20
20
|
try {
|
|
21
|
-
execFileSync('curl', ['-fsSL', '--retry', '2', '-o', tmpFile, entry.
|
|
21
|
+
execFileSync('curl', ['-fsSL', '--retry', '2', '-o', tmpFile, entry.asset_url], {
|
|
22
22
|
timeout: 60000,
|
|
23
23
|
stdio: 'pipe',
|
|
24
24
|
});
|
|
@@ -90,25 +90,43 @@ function cmdChangelog(args = []) {
|
|
|
90
90
|
// Diff maps
|
|
91
91
|
const axioms = diffSummary(oldJ.axioms || {}, newJ.axioms || {}, 'one_sentence');
|
|
92
92
|
const ontology = diffSummary(oldJ.ontology || {}, newJ.ontology || {}, 'concept');
|
|
93
|
-
const misunderstandings = diffSummary(
|
|
94
|
-
|
|
93
|
+
const misunderstandings = diffSummary(
|
|
94
|
+
oldJ.misunderstandings || {},
|
|
95
|
+
newJ.misunderstandings || {},
|
|
96
|
+
'wrong',
|
|
97
|
+
);
|
|
98
|
+
const bannedTerms = diffList(
|
|
99
|
+
Object.keys(oldJ.banned_terms || {}),
|
|
100
|
+
Object.keys(newJ.banned_terms || {}),
|
|
101
|
+
);
|
|
95
102
|
const stances = diffList(oldJ.stances || [], newJ.stances || []);
|
|
96
103
|
|
|
97
104
|
// Version bump suggestion
|
|
98
|
-
const hasRemoved =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
const hasRemoved =
|
|
106
|
+
Object.values(axioms).some((a) => a.status === 'removed') ||
|
|
107
|
+
Object.values(misunderstandings).some((m) => m.status === 'removed');
|
|
108
|
+
const hasAdded =
|
|
109
|
+
Object.values(axioms).some((a) => a.status === 'added') ||
|
|
110
|
+
Object.values(misunderstandings).some((m) => m.status === 'added');
|
|
111
|
+
const hasChanged =
|
|
112
|
+
Object.values(axioms).some((a) => a.status === 'changed') ||
|
|
113
|
+
Object.values(misunderstandings).some((m) => m.status === 'changed');
|
|
104
114
|
let recommendedBump = 'none';
|
|
105
115
|
if (hasRemoved) recommendedBump = 'major';
|
|
106
116
|
else if (hasAdded || hasChanged) recommendedBump = 'minor';
|
|
107
117
|
else if (stances.added.length || stances.removed.length) recommendedBump = 'patch';
|
|
108
118
|
|
|
109
119
|
// Cleanup
|
|
110
|
-
try {
|
|
111
|
-
|
|
120
|
+
try {
|
|
121
|
+
fs.rmSync(tmpOld, { recursive: true, force: true });
|
|
122
|
+
} catch {
|
|
123
|
+
/* cleanup */
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
fs.rmSync(tmpNew, { recursive: true, force: true });
|
|
127
|
+
} catch {
|
|
128
|
+
/* cleanup */
|
|
129
|
+
}
|
|
112
130
|
|
|
113
131
|
// Output
|
|
114
132
|
const changelog = {
|
|
@@ -139,7 +157,9 @@ function cmdChangelog(args = []) {
|
|
|
139
157
|
console.log(`## ${fromVersion} → ${toVersion}`);
|
|
140
158
|
console.log('');
|
|
141
159
|
if (oldJ.judgment_version || newJ.judgment_version) {
|
|
142
|
-
console.log(
|
|
160
|
+
console.log(
|
|
161
|
+
`Judgment version: ${oldJ.judgment_version || '(none)'} → ${newJ.judgment_version || '(none)'}`,
|
|
162
|
+
);
|
|
143
163
|
console.log('');
|
|
144
164
|
}
|
|
145
165
|
|