@aikdna/kdna-cli 0.26.0 → 0.26.1
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 +13 -3
- package/package.json +1 -1
- package/skills/kdna-loader/SKILL.md +97 -100
- package/templates/standard-domain/USAGE.md +2 -1
package/README.md
CHANGED
|
@@ -30,7 +30,8 @@ kdna inspect ./minimal
|
|
|
30
30
|
kdna validate ./minimal
|
|
31
31
|
kdna plan-load ./minimal --json
|
|
32
32
|
kdna pack ./minimal ./minimal.kdna
|
|
33
|
-
kdna validate ./minimal.kdna
|
|
33
|
+
kdna validate ./minimal.kdna --runtime
|
|
34
|
+
kdna plan-load ./minimal.kdna --json
|
|
34
35
|
kdna load ./minimal.kdna --profile=compact --as=prompt
|
|
35
36
|
```
|
|
36
37
|
|
|
@@ -71,8 +72,17 @@ Use Studio CLI to create formal v1 `.kdna` assets:
|
|
|
71
72
|
```bash
|
|
72
73
|
npm install -g @aikdna/kdna-studio-cli
|
|
73
74
|
kdna-studio create my_domain --name @yourscope/my_domain
|
|
74
|
-
kdna-studio
|
|
75
|
-
|
|
75
|
+
kdna-studio card add my_domain axiom \
|
|
76
|
+
--field one_sentence="Prefer specific evidence over broad claims" \
|
|
77
|
+
--field full_statement="When reviewing content, prefer specific evidence over broad claims because unsupported generalizations make the judgment impossible to verify or improve." \
|
|
78
|
+
--field why="Broad claims hide the actual reason for a judgment, so reviewers cannot tell whether the conclusion is evidence based, reusable, or merely plausible sounding." \
|
|
79
|
+
--field applies_when='["reviewing content"]' \
|
|
80
|
+
--field does_not_apply_when='["pure formatting"]' \
|
|
81
|
+
--field failure_risk="generic advice"
|
|
82
|
+
kdna-studio card approve my_domain --all --by expert --statement "I confirm this judgment."
|
|
83
|
+
kdna-studio export my_domain --format v1 --out ./my_domain.kdna
|
|
84
|
+
kdna validate ./my_domain.kdna --runtime
|
|
85
|
+
kdna plan-load ./my_domain.kdna --json
|
|
76
86
|
kdna load ./my_domain.kdna --profile=compact --as=prompt
|
|
77
87
|
```
|
|
78
88
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kdna-loader
|
|
3
|
-
description: Discover and load KDNA
|
|
3
|
+
description: Discover and load installed KDNA `.kdna` assets through the kdna CLI when the task requires domain-specific judgment (review, diagnosis, critique, classification, strategy) where the same input could legitimately be interpreted multiple ways. Skip for pure formatting, factual lookup, code execution, or mechanical transformations. This skill is the entire interface to KDNA — domains themselves are not separate skills.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# KDNA Loader
|
|
7
7
|
|
|
8
8
|
KDNA (Knowledge DNA) is a portable format for encoding domain judgment.
|
|
9
|
-
Each KDNA domain is a
|
|
9
|
+
Each KDNA domain is a `.kdna` cognitive asset that describes how
|
|
10
10
|
an expert thinks inside one domain: the principles they reason from,
|
|
11
11
|
the misunderstandings they avoid, the questions they ask themselves
|
|
12
12
|
before deciding.
|
|
@@ -17,10 +17,28 @@ this skill provides the **routing and protocol**, KDNA provides the
|
|
|
17
17
|
**judgment material**.
|
|
18
18
|
|
|
19
19
|
This skill is the **only** KDNA-related skill. Domains themselves are
|
|
20
|
-
not registered as skills — they
|
|
21
|
-
are discovered on demand. Whether the user has 1 domain installed or
|
|
20
|
+
not registered as skills — they are installed as `.kdna` assets and
|
|
21
|
+
are discovered through the CLI on demand. Whether the user has 1 domain installed or
|
|
22
22
|
100, this skill is the single entry point.
|
|
23
23
|
|
|
24
|
+
## Core Principle: No KDNA is better than wrong KDNA
|
|
25
|
+
|
|
26
|
+
Loading a mismatched domain is not just "unhelpful" — it is harmful.
|
|
27
|
+
It produces **Judgment Contamination**: the agent classifies problems
|
|
28
|
+
incorrectly, assigns wrong priorities, applies wrong risk models, and
|
|
29
|
+
offers wrong recommendations — all with the false confidence of having
|
|
30
|
+
"loaded expert judgment."
|
|
31
|
+
|
|
32
|
+
*No KDNA*: the agent uses model capability, tools, MCP, project files,
|
|
33
|
+
and normal prompts. It may lack domain-specific judgment, but it is
|
|
34
|
+
not polluted by incorrect judgment.
|
|
35
|
+
|
|
36
|
+
*Wrong KDNA*: the agent applies a mismatched framework — e.g., diagnosing
|
|
37
|
+
a website design task through a team management lens, or treating a
|
|
38
|
+
price question as an editing issue. The output is worse than baseline.
|
|
39
|
+
|
|
40
|
+
**When in doubt, skip.** This is the first law of KDNA routing.
|
|
41
|
+
|
|
24
42
|
---
|
|
25
43
|
|
|
26
44
|
## Part 1 — Decide whether KDNA applies at all
|
|
@@ -59,19 +77,23 @@ The user should never see "I considered loading KDNA but didn't."
|
|
|
59
77
|
Do **not** assume any specific domains exist. Ask the CLI every time.
|
|
60
78
|
|
|
61
79
|
```bash
|
|
62
|
-
kdna
|
|
80
|
+
kdna load <file.kdna> --profile=index --as=json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
When an MCP runtime is available, use:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
kdna.available-local
|
|
63
87
|
```
|
|
64
88
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
domains are excluded automatically.
|
|
89
|
+
The current v1 path discovers local `.kdna` files or v1 source
|
|
90
|
+
directories, then inspects their index profile. Legacy installations may
|
|
91
|
+
also expose `kdna available --json`; treat that as a compatibility path,
|
|
92
|
+
not the v1 source of truth.
|
|
70
93
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
change; `kdna available` will not.
|
|
94
|
+
The supported contract is the CLI/MCP loader, not hand-reading internal
|
|
95
|
+
JSON files. Do not inspect `~/.kdna/packages/` or `cat` payload files
|
|
96
|
+
directly unless the user explicitly asks for debugging.
|
|
75
97
|
|
|
76
98
|
If the command returns `[]` or fails (CLI not installed) → no KDNA
|
|
77
99
|
available → answer normally, mention installation only if the user is
|
|
@@ -81,12 +103,13 @@ asking about KDNA itself.
|
|
|
81
103
|
|
|
82
104
|
## Part 3 — Evaluate fit (per candidate domain)
|
|
83
105
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
**reading the language**, not by token matching.
|
|
106
|
+
The index profile or MCP local inventory gives you each domain's title,
|
|
107
|
+
summary, keywords, and profile availability. For each candidate, load
|
|
108
|
+
the compact profile only after the task plausibly fits. Decide whether
|
|
109
|
+
it fits by **reading the language**, not by token matching.
|
|
88
110
|
|
|
89
|
-
For a hint signal (optional, low-
|
|
111
|
+
For a hint signal (optional, low-confidence), legacy installations may
|
|
112
|
+
also support:
|
|
90
113
|
|
|
91
114
|
```bash
|
|
92
115
|
kdna match "<task in user's own words>" --json
|
|
@@ -124,18 +147,27 @@ what you'd produce if you loaded the domain? If yes, skip it.
|
|
|
124
147
|
|
|
125
148
|
---
|
|
126
149
|
|
|
127
|
-
## Part 4 — Selection
|
|
150
|
+
## Part 4 — Selection (7-State Router)
|
|
128
151
|
|
|
129
|
-
After evaluating
|
|
152
|
+
After evaluating against `applies_when`, `does_not_apply_when`, and
|
|
153
|
+
`failure_risks`, classify into one of 7 states:
|
|
130
154
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
155
|
+
| State | Condition | Action |
|
|
156
|
+
|-------|-----------|--------|
|
|
157
|
+
| **SKIP_NO_JUDGMENT_NEEDED** | Task is mechanical: format, translate, lookup, execute | Answer normally. Do not mention KDNA. |
|
|
158
|
+
| **SKIP_NO_LOCAL_DOMAIN** | Task may need judgment, but no installed domain covers it | Answer normally. Only mention KDNA if user explicitly asks. |
|
|
159
|
+
| **SKIP_WEAK_FIT** | A domain is weakly related but insufficiently matches | Answer normally. Trace notes "weak match, skipped." |
|
|
160
|
+
| **REJECT_NEGATIVE_MATCH** | A domain's `does_not_apply_when` explicitly excludes this task | Block loading. Respect the author's boundary. |
|
|
161
|
+
| **ASK_AMBIGUOUS_DOMAIN** | 2+ domains could apply but with different judgment frameworks | Ask user to choose. Do **not** silently blend. |
|
|
162
|
+
| **LOAD_STRONG_FIT** | One local domain strongly matches and validates | Load it. |
|
|
163
|
+
| **BLOCK_INTEGRITY_FAILED** | Domain matches but validation, checksum, parsing, or runtime loading fails | Block loading. Notify if appropriate. |
|
|
164
|
+
|
|
165
|
+
**Rule: Negative Match First.** Check `does_not_apply_when` before
|
|
166
|
+
checking `applies_when`. A domain that says "not for visual design"
|
|
167
|
+
must be excluded before evaluating whether it matches "design task."
|
|
168
|
+
|
|
169
|
+
**Rule: When in doubt, skip.** Weak fit → skip. Ambiguous without
|
|
170
|
+
clear user preference → ask, don't guess. Integrity failure → block.
|
|
139
171
|
|
|
140
172
|
Never load more than one domain as primary. A secondary domain can
|
|
141
173
|
constrain (e.g. `@aikdna/agent_safety` always advises on irreversible
|
|
@@ -143,12 +175,27 @@ actions), but the primary judgment frame is always one.
|
|
|
143
175
|
|
|
144
176
|
---
|
|
145
177
|
|
|
146
|
-
## Part 5 — Load
|
|
178
|
+
## Part 5 — Plan, then Load (v1 & legacy)
|
|
179
|
+
|
|
180
|
+
Once selected, ask the runtime for a LoadPlan before loading:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
kdna plan-load <file.kdna> --json
|
|
184
|
+
```
|
|
147
185
|
|
|
148
|
-
|
|
186
|
+
If the LoadPlan does not return `can_load_now=true`, do not load the asset.
|
|
187
|
+
Follow `required_action` and `issues[].code` instead. Remote assets are
|
|
188
|
+
recognized but unsupported until the runtime provides a remote projection
|
|
189
|
+
implementation.
|
|
190
|
+
|
|
191
|
+
Only after `can_load_now=true`, load the domain via the official KDNA CLI.
|
|
192
|
+
Two paths are supported:
|
|
149
193
|
|
|
150
194
|
```bash
|
|
151
|
-
kdna load
|
|
195
|
+
kdna load <file.kdna> --profile=compact --as=prompt
|
|
196
|
+
kdna load <source-dir> --profile=compact --as=prompt
|
|
197
|
+
|
|
198
|
+
Legacy installed domains may still support: kdna load @scope/name
|
|
152
199
|
```
|
|
153
200
|
|
|
154
201
|
The default output (`--as=prompt`) is a compact text rendering
|
|
@@ -157,17 +204,12 @@ optimized for system-prompt injection: axioms with their
|
|
|
157
204
|
banned terms, misunderstandings, and self-checks. Typically
|
|
158
205
|
~30–50% smaller than the raw JSON.
|
|
159
206
|
|
|
160
|
-
|
|
207
|
+
Use `--as=prompt` for normal loading. For raw inspection (debugging only):
|
|
161
208
|
|
|
162
209
|
```bash
|
|
163
|
-
kdna
|
|
164
|
-
kdna load @scope/name --as=raw # concatenated raw file contents
|
|
210
|
+
kdna dev decode domain.kdna --reveal
|
|
165
211
|
```
|
|
166
212
|
|
|
167
|
-
Use `--as=prompt` for normal loading. Use `--as=json` only when you
|
|
168
|
-
genuinely need to inspect the structure (e.g. user is debugging the
|
|
169
|
-
domain itself).
|
|
170
|
-
|
|
171
213
|
**Token discipline**: the prompt output already includes everything
|
|
172
214
|
the agent needs to apply judgment. Do not also `cat` the optional
|
|
173
215
|
files (`KDNA_Scenarios.json`, `KDNA_Cases.json`, etc.) unless the
|
|
@@ -181,8 +223,8 @@ stages.
|
|
|
181
223
|
You have now internalized the domain's judgment surface. From this
|
|
182
224
|
point on:
|
|
183
225
|
|
|
184
|
-
1. **Adopt the axioms as your reasoning frame** — reason
|
|
185
|
-
them, not
|
|
226
|
+
1. **Adopt the axioms as your reasoning frame** — reason *from*
|
|
227
|
+
them, not *around* them.
|
|
186
228
|
2. **Honour the boundaries** — for each axiom you'd apply, confirm
|
|
187
229
|
the task is in `applies_when` AND not in `does_not_apply_when`.
|
|
188
230
|
3. **Pre-check failure_risk** — before producing output, ask:
|
|
@@ -215,62 +257,16 @@ KDNA does not override:
|
|
|
215
257
|
|
|
216
258
|
---
|
|
217
259
|
|
|
218
|
-
## Safety & Governance
|
|
219
|
-
|
|
220
|
-
KDNA domains influence agent judgment. The loader MUST apply safety rules before loading any domain.
|
|
221
|
-
|
|
222
|
-
### Loading Priority
|
|
223
|
-
|
|
224
|
-
When KDNA is loaded, the agent MUST respect this priority order:
|
|
225
|
-
|
|
226
|
-
1. System safety policy (highest — cannot be overridden)
|
|
227
|
-
2. Legal and compliance requirements
|
|
228
|
-
3. User's explicit intent
|
|
229
|
-
4. KDNA domain judgment
|
|
230
|
-
5. Tool/skill instructions (lowest)
|
|
231
|
-
|
|
232
|
-
KDNA MUST NOT override system safety policies, legal requirements, or the user's explicit refusal to apply domain judgment.
|
|
233
|
-
|
|
234
|
-
### Risk-Level Checks
|
|
235
|
-
|
|
236
|
-
Before loading a KDNA domain, check its risk level in `kdna.json` or `KDNA_CARD.json`:
|
|
237
|
-
|
|
238
|
-
| Risk Level | Loading Behavior |
|
|
239
|
-
| ------------------- | ---------------------------------------------- |
|
|
240
|
-
| **R0** (Low) | Load silently |
|
|
241
|
-
| **R1** (Medium) | Load silently; log |
|
|
242
|
-
| **R2** (High) | Warn user before loading; require confirmation |
|
|
243
|
-
| **R3** (Restricted) | Reject loading unless explicitly authorized |
|
|
244
|
-
|
|
245
|
-
### Signature & Trust Checks
|
|
246
|
-
|
|
247
|
-
- Yanked domains: **REJECT** loading (domain has been withdrawn for safety)
|
|
248
|
-
- Deprecated domains: warn; suggest replacement if `replaced_by` is set
|
|
249
|
-
- Unsigned domains: warn; load only if user confirms
|
|
250
|
-
- Unknown scope domains: warn; load only if user confirms
|
|
251
|
-
|
|
252
|
-
### Runtime Logging
|
|
253
|
-
|
|
254
|
-
Every KDNA load MUST be logged with:
|
|
255
|
-
|
|
256
|
-
- Domain name and version
|
|
257
|
-
- Risk level
|
|
258
|
-
- Signature status
|
|
259
|
-
- Which axioms were triggered
|
|
260
|
-
- Which misunderstandings were avoided
|
|
261
|
-
- Self-check pass rate
|
|
262
|
-
|
|
263
|
-
This enables audit and accountability.
|
|
264
|
-
|
|
265
260
|
## Failure handling
|
|
266
261
|
|
|
267
|
-
| Situation
|
|
268
|
-
|
|
269
|
-
| `kdna` CLI not installed
|
|
270
|
-
|
|
|
271
|
-
| `kdna load <
|
|
272
|
-
|
|
|
273
|
-
|
|
|
262
|
+
| Situation | What to do |
|
|
263
|
+
|---|---|
|
|
264
|
+
| `kdna` CLI not installed | Skip KDNA. Answer normally. Mention installation only if user asks about KDNA itself. |
|
|
265
|
+
| No local v1 assets are found | No domains installed. Skip KDNA. |
|
|
266
|
+
| `kdna plan-load <asset>` returns `can_load_now=false` | Do not load. Follow `required_action` and `issues[].code`. |
|
|
267
|
+
| `kdna load <name>` exits non-zero | That domain is broken (validation, authorization, parse, or runtime loading failure). Try next candidate or skip KDNA. The error message tells you why. |
|
|
268
|
+
| User explicitly asks for a domain that isn't installed | Tell them, suggest `kdna install <name>`. Do not fabricate the domain. |
|
|
269
|
+
| Two domains' stances directly conflict on the task | Surface to user. Do not blend. |
|
|
274
270
|
|
|
275
271
|
---
|
|
276
272
|
|
|
@@ -293,11 +289,12 @@ Otherwise, stay silent about the loading mechanics.
|
|
|
293
289
|
|
|
294
290
|
## What this skill is NOT
|
|
295
291
|
|
|
296
|
-
- Not a list of available KDNA domains (those are installed `.kdna` assets,
|
|
297
|
-
|
|
298
|
-
- Not a
|
|
299
|
-
|
|
300
|
-
Studio
|
|
292
|
+
- Not a list of available KDNA domains (those are installed `.kdna` assets,
|
|
293
|
+
discovered on demand through the CLI)
|
|
294
|
+
- Not a registry browser. Legacy registry commands are compatibility-only.
|
|
295
|
+
- Not a domain creator. Agents may draft judgment proposals or candidate cards,
|
|
296
|
+
but formal `.kdna` assets are created through the official KDNA Studio toolchain.
|
|
297
|
+
compile/export.
|
|
301
298
|
- Not an auto-loader that runs on every request — you decide per
|
|
302
299
|
request whether the task needs KDNA at all
|
|
303
300
|
|
|
@@ -45,8 +45,9 @@ kdna verify ./.
|
|
|
45
45
|
|
|
46
46
|
# 7. Export and verify the local v1 asset
|
|
47
47
|
KDNA_IDENTITY_DIR=~/.kdna/identity-official \
|
|
48
|
-
kdna validate ./dist/your-domain.kdna
|
|
48
|
+
kdna validate ./dist/your-domain.kdna --runtime
|
|
49
49
|
|
|
50
|
+
kdna plan-load ./dist/your-domain.kdna --json
|
|
50
51
|
kdna load ./dist/your-domain.kdna --profile=compact --as=prompt
|
|
51
52
|
```
|
|
52
53
|
|