@aikdna/kdna-cli 0.16.10 → 0.18.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.
@@ -0,0 +1,122 @@
1
+ const { error, EXIT } = require('./_common');
2
+ const { parseName } = require('../registry');
3
+ const { getInstalled, readContainer } = require('../package-store');
4
+
5
+ function cmdExplain(args) {
6
+ const target = args.filter((a) => !a.startsWith('--'))[1];
7
+ if (!target) {
8
+ error(
9
+ 'Usage: kdna explain <domain> [--locale zh-CN]\n\n' +
10
+ ' Produces a natural language explanation of what a domain covers,\n' +
11
+ ' its key axioms, applicable scenarios, and intended model types.',
12
+ EXIT.INPUT_ERROR,
13
+ );
14
+ }
15
+
16
+ const parsed = parseName(target);
17
+ if (!parsed) {
18
+ error(`Invalid domain name: ${target}`, EXIT.INPUT_ERROR);
19
+ }
20
+
21
+ const installed = getInstalled(parsed.full);
22
+ if (!installed) {
23
+ error(
24
+ `${parsed.full} is not installed.\nRun: kdna install ${target}`,
25
+ EXIT.INPUT_ERROR,
26
+ );
27
+ }
28
+
29
+ const { core, patterns, scenarios } = readContainer(installed.asset_path);
30
+
31
+ if (!core) {
32
+ error(`Failed to load KDNA_Core.json from ${installed.asset_path}`, EXIT.VALIDATION_FAILED);
33
+ }
34
+
35
+ const m = core.meta || {};
36
+ const purpose = m.purpose || '(not specified)';
37
+ const domain = m.domain || parsed.ident;
38
+ const version = m.version || 'unknown';
39
+ const axioms = core.axioms || [];
40
+ const bannedTerms = patterns?.terminology?.banned_terms || [];
41
+ const selfChecks = patterns?.self_checks || patterns?.self_check || [];
42
+ const standardTerms = patterns?.terminology?.standard_terms || [];
43
+ const misunderstandings = patterns?.misunderstandings || [];
44
+
45
+ console.log('');
46
+ console.log(`╔══════════════════════════════════════════════════════════════╗`);
47
+ console.log(`║ KDNA Domain: ${domain.padEnd(46)}║`);
48
+ console.log(`║ Package: ${parsed.full.padEnd(46)}║`);
49
+ console.log(`║ Version: ${version.padEnd(46)}║`);
50
+ console.log(`╚══════════════════════════════════════════════════════════════╝`);
51
+ console.log('');
52
+
53
+ console.log('── Purpose ──');
54
+ console.log(` ${purpose}`);
55
+ console.log('');
56
+
57
+ console.log(`── Axioms (${axioms.length} core principles) ──`);
58
+ for (const ax of axioms) {
59
+ console.log(` • ${ax.one_sentence || ax.id}`);
60
+ const applies = (ax.applies_when || []).join('; ');
61
+ if (applies) console.log(` Applies when: ${applies.slice(0, 120)}`);
62
+ const notApply = (ax.does_not_apply_when || []).join('; ');
63
+ if (notApply) console.log(` NOT when: ${notApply.slice(0, 120)}`);
64
+ console.log('');
65
+ }
66
+
67
+ if (standardTerms.length) {
68
+ console.log(`── Standard Terms (${standardTerms.length}) ──`);
69
+ for (const t of standardTerms.slice(0, 8)) {
70
+ const def = t.definition ? `: ${t.definition.slice(0, 80)}` : '';
71
+ console.log(` • ${t.term}${def}`);
72
+ }
73
+ console.log('');
74
+ }
75
+
76
+ if (misunderstandings.length) {
77
+ console.log(`── Common Misunderstandings (${misunderstandings.length}) ──`);
78
+ for (const mm of misunderstandings.slice(0, 5)) {
79
+ console.log(` ✗ "${mm.mistake || mm.id}"`);
80
+ }
81
+ console.log('');
82
+ }
83
+
84
+ if (bannedTerms.length) {
85
+ console.log(`── Banned Terms (${bannedTerms.length} — do not use) ──`);
86
+ for (const b of bannedTerms.slice(0, 6)) {
87
+ const why = b.why ? ` → ${b.why.slice(0, 60)}` : '';
88
+ console.log(` ✗ "${b.term}"${why}`);
89
+ }
90
+ console.log('');
91
+ }
92
+
93
+ if (selfChecks.length) {
94
+ console.log(`── Self-Checks (${selfChecks.length} — verify before responding) ──`);
95
+ for (const sc of selfChecks.slice(0, 8)) {
96
+ console.log(` ✓ ${sc.question || sc.id || sc}`);
97
+ }
98
+ console.log('');
99
+ }
100
+
101
+ if (scenarios && scenarios.scenarios && scenarios.scenarios.length) {
102
+ console.log(`── Scenarios (${scenarios.scenarios.length} — strategy shifts) ──`);
103
+ for (const s of scenarios.scenarios.slice(0, 6)) {
104
+ const desc = s.description ? s.description.slice(0, 80) : '';
105
+ console.log(` ▶ ${s.signal || s.id}: ${desc}`);
106
+ }
107
+ console.log('');
108
+ }
109
+
110
+ console.log('── Model Compatibility ──');
111
+ console.log(' Works with any LLM/agent that loads context before reasoning.');
112
+ console.log(' Tested: Claude, GPT, Gemini, Qwen, MiniMax');
113
+ console.log('');
114
+
115
+ console.log('── Quick Start ──');
116
+ console.log(` kdna verify ${target} --judgment`);
117
+ console.log(` kdna compare ${target} --input "<your task>"`);
118
+ console.log(` kdna trace --domain ${target.slice(0, 40)}`);
119
+ console.log('');
120
+ }
121
+
122
+ module.exports = { cmdExplain };
@@ -2,10 +2,10 @@ const { error } = require('./_common');
2
2
 
3
3
  function cmdPreview() {
4
4
  // Removed in v0.9 — no real user scenario for browser preview.
5
- // To inspect a .kdna file, use: kdna inspect <path>
5
+ // To inspect a .kdna file, use: kdna inspect <file.kdna>
6
6
  error(
7
7
  'kdna preview was removed in v0.9.\n' +
8
- 'Use: kdna inspect <path> to view a .kdna file or domain directory.',
8
+ 'Use: kdna inspect <file.kdna> to view a .kdna asset.',
9
9
  );
10
10
  }
11
11
 
@@ -18,8 +18,8 @@ function cmdProject() {
18
18
  'kdna project was removed in v0.9. The .kdna/config.json file is no\n' +
19
19
  'longer read by the kdna-loader skill — it would have forced KDNA\n' +
20
20
  'loading on tasks where the user did not ask for it.\n\n' +
21
- 'The agent now discovers KDNA on demand by reading ~/.kdna/domains/\n' +
22
- 'and matching the task against v2.1 applies_when fields.\n\n' +
21
+ 'The agent now discovers KDNA on demand through kdna available/load,\n' +
22
+ 'which read installed .kdna assets from the package index.\n\n' +
23
23
  'If you have stale .kdna/config.json files in your projects, you\n' +
24
24
  'can delete them — nothing reads them anymore.',
25
25
  );
@@ -32,7 +32,7 @@ function cmdEval() {
32
32
  error(
33
33
  'kdna eval was removed in v0.9.\n' +
34
34
  'To compare with/without KDNA reasoning, use:\n' +
35
- ' kdna compare <name> --input "<task>"\n' +
35
+ ' kdna compare <name|file.kdna> --input "<task>"\n' +
36
36
  'To inspect a domain, use:\n' +
37
37
  ' kdna info <name>',
38
38
  );
@@ -53,17 +53,17 @@ function cmdSelect() {
53
53
  }
54
54
 
55
55
  function cmdExport() {
56
- // Removed in v0.9 — was an alias for `kdna pack`.
56
+ // Removed in v0.9 — was an alias for the old top-level pack command.
57
57
  error(
58
58
  'kdna export was removed in v0.9 (it was an alias for pack).\n' +
59
- 'Use: kdna pack <path> [--output <dir>]',
59
+ 'Use: kdna dev pack <source-dir> [--output <dir>]',
60
60
  );
61
61
  }
62
62
 
63
63
  function cmdDemo() {
64
64
  // Removed in v0.9 — internal demo, not a user feature. To see
65
65
  // before/after on a real input, use:
66
- // kdna compare <name> --input "<task>" (requires LLM API key)
66
+ // kdna compare <name|file.kdna> --input "<task>" (requires LLM API key)
67
67
  error(
68
68
  'kdna demo was removed in v0.9.\n' +
69
69
  'To see KDNA before/after on a real input, use:\n' +