@zenera/cli 1.1.24 → 1.1.25

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.
Files changed (167) hide show
  1. package/README.md +53 -0
  2. package/dist/ask.js +28 -5
  3. package/dist/banner.js +2 -2
  4. package/dist/batch.d.ts +6 -0
  5. package/dist/batch.js +76 -1
  6. package/dist/catalog.d.ts +11 -1
  7. package/dist/catalog.js +80 -7
  8. package/dist/commands/inspect.d.ts +47 -1
  9. package/dist/commands/inspect.js +167 -18
  10. package/dist/commands/memory.js +128 -29
  11. package/dist/commands/meta.js +311 -21
  12. package/dist/commands/models.js +96 -12
  13. package/dist/commands/open.js +4 -4
  14. package/dist/commands/run.js +38 -4
  15. package/dist/commands/sandbox.js +76 -14
  16. package/dist/engine.d.ts +5 -0
  17. package/dist/engine.js +1 -0
  18. package/dist/eventlog.d.ts +59 -0
  19. package/dist/eventlog.js +146 -0
  20. package/dist/liveness.d.ts +7 -0
  21. package/dist/liveness.js +15 -1
  22. package/dist/meta/editor.d.ts +9 -0
  23. package/dist/meta/editor.js +60 -0
  24. package/dist/meta/finetune/children.d.ts +8 -0
  25. package/dist/meta/finetune/children.js +76 -0
  26. package/dist/meta/finetune/command.d.ts +30 -0
  27. package/dist/meta/finetune/command.js +338 -0
  28. package/dist/meta/finetune/dataset/anchors.d.ts +41 -0
  29. package/dist/meta/finetune/dataset/anchors.js +239 -0
  30. package/dist/meta/finetune/dataset/changes.d.ts +36 -0
  31. package/dist/meta/finetune/dataset/changes.js +319 -0
  32. package/dist/meta/finetune/dataset/command.d.ts +17 -0
  33. package/dist/meta/finetune/dataset/command.js +1011 -0
  34. package/dist/meta/finetune/dataset/drift.d.ts +33 -0
  35. package/dist/meta/finetune/dataset/drift.js +71 -0
  36. package/dist/meta/finetune/dataset/export.d.ts +26 -0
  37. package/dist/meta/finetune/dataset/export.js +51 -0
  38. package/dist/meta/finetune/dataset/index.d.ts +2 -0
  39. package/dist/meta/finetune/dataset/index.js +2 -0
  40. package/dist/meta/finetune/dataset/sample.d.ts +50 -0
  41. package/dist/meta/finetune/dataset/sample.js +197 -0
  42. package/dist/meta/finetune/dataset/schema.d.ts +33 -0
  43. package/dist/meta/finetune/dataset/schema.js +216 -0
  44. package/dist/meta/finetune/dataset/store.d.ts +35 -0
  45. package/dist/meta/finetune/dataset/store.js +177 -0
  46. package/dist/meta/finetune/dataset/types.d.ts +125 -0
  47. package/dist/meta/finetune/dataset/types.js +39 -0
  48. package/dist/meta/finetune/failure.d.ts +15 -0
  49. package/dist/meta/finetune/failure.js +26 -0
  50. package/dist/meta/finetune/feedback.d.ts +45 -0
  51. package/dist/meta/finetune/feedback.js +85 -0
  52. package/dist/meta/finetune/improvements.d.ts +51 -0
  53. package/dist/meta/finetune/improvements.js +244 -0
  54. package/dist/meta/finetune/index.d.ts +2 -0
  55. package/dist/meta/finetune/index.js +2 -0
  56. package/dist/meta/finetune/journal.d.ts +35 -0
  57. package/dist/meta/finetune/journal.js +135 -0
  58. package/dist/meta/finetune/live.d.ts +74 -0
  59. package/dist/meta/finetune/live.js +226 -0
  60. package/dist/meta/finetune/loop.d.ts +3 -0
  61. package/dist/meta/finetune/loop.js +114 -0
  62. package/dist/meta/finetune/memories.d.ts +47 -0
  63. package/dist/meta/finetune/memories.js +154 -0
  64. package/dist/meta/finetune/report.d.ts +33 -0
  65. package/dist/meta/finetune/report.js +1284 -0
  66. package/dist/meta/finetune/retry.d.ts +24 -0
  67. package/dist/meta/finetune/retry.js +96 -0
  68. package/dist/meta/finetune/sampler.d.ts +18 -0
  69. package/dist/meta/finetune/sampler.js +41 -0
  70. package/dist/meta/finetune/system.d.ts +27 -0
  71. package/dist/meta/finetune/system.js +132 -0
  72. package/dist/meta/finetune/train.d.ts +39 -0
  73. package/dist/meta/finetune/train.js +391 -0
  74. package/dist/meta/finetune/tui.d.ts +16 -0
  75. package/dist/meta/finetune/tui.js +291 -0
  76. package/dist/meta/finetune/tuning.d.ts +167 -0
  77. package/dist/meta/finetune/tuning.js +289 -0
  78. package/dist/meta/finetune/usage.d.ts +62 -0
  79. package/dist/meta/finetune/usage.js +225 -0
  80. package/dist/meta/host.d.ts +14 -0
  81. package/dist/meta/host.js +20 -0
  82. package/dist/meta/index.d.ts +11 -0
  83. package/dist/meta/index.js +11 -0
  84. package/dist/meta/launch.d.ts +81 -0
  85. package/dist/meta/launch.js +286 -0
  86. package/dist/meta/model.d.ts +44 -0
  87. package/dist/meta/model.js +119 -0
  88. package/dist/meta/prompts.d.ts +18 -0
  89. package/dist/meta/prompts.js +61 -0
  90. package/dist/meta/relay.d.ts +20 -0
  91. package/dist/meta/relay.js +123 -0
  92. package/dist/meta/tokens.d.ts +52 -0
  93. package/dist/meta/tokens.js +226 -0
  94. package/dist/meta/window.d.ts +61 -0
  95. package/dist/meta/window.js +198 -0
  96. package/dist/meta/wire.d.ts +42 -0
  97. package/dist/meta/wire.js +129 -0
  98. package/dist/modelref.d.ts +16 -0
  99. package/dist/modelref.js +41 -0
  100. package/dist/narrate.js +5 -2
  101. package/dist/podman.d.ts +26 -0
  102. package/dist/podman.js +83 -3
  103. package/dist/projects.d.ts +0 -5
  104. package/dist/projects.js +2 -15
  105. package/dist/sandbox.d.ts +2 -0
  106. package/dist/sandbox.js +10 -3
  107. package/dist/scaffold.d.ts +15 -6
  108. package/dist/scaffold.js +5 -60
  109. package/dist/session.js +4 -29
  110. package/dist/term.d.ts +2 -0
  111. package/dist/term.js +11 -2
  112. package/dist/trace.js +53 -2
  113. package/dist/tui/models.d.ts +33 -0
  114. package/dist/tui/models.js +389 -0
  115. package/dist/tui/wrap.d.ts +5 -0
  116. package/dist/tui/wrap.js +12 -0
  117. package/dist/usage.d.ts +78 -0
  118. package/dist/usage.js +51 -0
  119. package/package.json +3 -2
  120. package/templates/editor/.github/copilot-instructions.md +31 -102
  121. package/templates/editor/.github/prompts/analyze.prompt.md +31 -0
  122. package/templates/editor/.github/prompts/dataset.prompt.md +108 -0
  123. package/templates/editor/.github/prompts/finetune-apply.prompt.md +91 -0
  124. package/templates/editor/.github/prompts/finetune.prompt.md +691 -198
  125. package/templates/editor/.github/prompts/new-agent.prompt.md +3 -1
  126. package/templates/editor/.github/prompts/new-skill.prompt.md +2 -0
  127. package/templates/editor/.github/prompts/project-review.prompt.md +4 -3
  128. package/templates/editor/.github/skills/zen-analyze-run/SKILL.md +483 -0
  129. package/templates/editor/.github/skills/zen-cli/SKILL.md +9 -1
  130. package/templates/editor/.github/skills/zen-cli/references/dataset.md +34 -0
  131. package/templates/editor/.github/skills/zen-cli/references/finetune.md +77 -0
  132. package/templates/editor/.github/skills/zen-cli/references/inspect.md +47 -9
  133. package/templates/editor/.github/skills/zen-cli/references/memory.md +33 -10
  134. package/templates/editor/.github/skills/zen-cli/references/meta.md +61 -0
  135. package/templates/editor/.github/skills/zen-cli/references/models.md +5 -1
  136. package/templates/editor/.github/skills/zen-cli/references/rag.md +24 -6
  137. package/templates/editor/.github/skills/zen-cli/references/sandbox.md +10 -1
  138. package/templates/editor/.github/skills/zen-code-python/SKILL.md +123 -0
  139. package/templates/editor/.github/skills/zen-code-python/references/code_python.md +48 -0
  140. package/templates/editor/.github/skills/zen-dataset/SKILL.md +253 -0
  141. package/templates/editor/.github/skills/zen-finetune/SKILL.md +1449 -658
  142. package/templates/editor/.github/skills/zen-finetune/references/readme-template.md +268 -0
  143. package/templates/editor/.github/skills/zen-finetune/scripts/batch.mjs +390 -0
  144. package/templates/editor/.github/skills/zen-finetune/scripts/difficult.mjs +243 -0
  145. package/templates/editor/.github/skills/zen-finetune/scripts/memory.mjs +280 -0
  146. package/templates/editor/.github/skills/zen-finetune/scripts/next.mjs +398 -0
  147. package/templates/editor/.github/skills/zen-finetune/scripts/report.mjs +797 -0
  148. package/templates/editor/.github/skills/zen-finetune/scripts/select.mjs +354 -0
  149. package/templates/editor/.github/skills/zen-finetune/scripts/usage.mjs +722 -0
  150. package/templates/editor/.github/skills/zen-inspect/SKILL.md +60 -25
  151. package/templates/editor/.github/skills/zen-inspect-ask/SKILL.md +270 -0
  152. package/templates/editor/.github/skills/zen-memory/SKILL.md +18 -14
  153. package/templates/editor/.github/skills/zen-rag-docs/SKILL.md +20 -8
  154. package/templates/editor/.github/skills/zen-review/SKILL.md +5 -3
  155. package/templates/editor/.github/skills/zen-review/scripts/check-paths.sh +5 -4
  156. package/templates/editor/.github/skills/zen-sandbox/SKILL.md +7 -3
  157. package/templates/editor/.github/skills/zen-sandbox-capacity/SKILL.md +2 -2
  158. package/templates/editor/.github/skills/zen-topology/SKILL.md +283 -0
  159. package/templates/editor/.vscode/settings.json +1 -0
  160. package/templates/project/agents/files-instructions.md +29 -20
  161. package/templates/project/agents/memory-instructions.md +31 -32
  162. package/templates/project/agents/tools-instructions.md +7 -4
  163. package/templates/project/gitignore +2 -0
  164. package/dist/meta.d.ts +0 -221
  165. package/dist/meta.js +0 -684
  166. package/templates/editor/.github/skills/zen-finetune/scripts/collect.sh +0 -432
  167. package/templates/editor/.github/skills/zen-finetune/scripts/sample.sh +0 -199
@@ -47,7 +47,10 @@ visible in `agents.yaml` and that `zen check` does not report.** Before
47
47
  reviewing or changing a project, list the capabilities it has turned on and load
48
48
  the editor skill for each one - `zen-memory` for a `memory:` block,
49
49
  `zen-sandbox` for sandbox configuration or shell tools, `zen-rag-schema` or
50
- `zen-rag-docs` for an index, `zen-sandbox-capacity` before any `zen run batch`,
50
+ `zen-rag-docs` for an index, `zen-code-python` for an agent that writes or runs
51
+ code, `zen-topology` for `handoffs:` or `fork:` on any agent,
52
+ `zen-sandbox-capacity` before any `zen run batch`
53
+ (except under `zen-finetune`, which sets its own concurrency),
51
54
  `zen-cli` always. A capability that is already
52
55
  configured and already passing `zen check` is exactly the case that looks
53
56
  finished and is not: the obligation lives in the skill, so a review that never
@@ -63,6 +66,14 @@ three those are, where a project's own rules on the same subjects go instead,
63
66
  how `requires:` conditions a document, and what filename order decides. None of
64
67
  that is visible in the file being edited.
65
68
 
69
+ **Load `zen-code-python` before writing, editing or reviewing any prompt, skill
70
+ or house rule for an agent that writes or runs code** - any agent holding
71
+ `sandbox:*` or `run_command` - and before shipping a script inside a skill.
72
+ Code an agent writes must be a reusable tool, so that memory can keep it and the
73
+ next similar question runs it instead of writing it again. The skill holds the
74
+ coding rules and decides where they go: a section of a dedicated code agent's
75
+ system prompt, or a coding skill for generic agents that sometimes run code.
76
+
66
77
  First determine whether the target project uses RAG: a `zen rag` command in an
67
78
  agent prompt or skill, RAG tools supplied by its host, or a documentation or
68
79
  schema index it is expected to consult all count. When it does, also load the
@@ -1430,108 +1441,23 @@ multi-agent instinct suggests.
1430
1441
 
1431
1442
  ### 6.3 Handoffs
1432
1443
 
1433
- - `description:` on the target agent is what the model reads when deciding.
1434
- Write it as a routing condition: _"Applies the written peril policies to a
1435
- claim and explains the outcome."_ - not _"The adjuster agent."_
1436
- - Handoffs are bare name strings; there is no per-edge configuration.
1437
- - Self-handoff is a load error.
1438
- - **Every handoff must be returnable.** For every `A → B` there must be a path
1439
- from `B` back to `A`. Indirect counts - `B → C → A` is a way home - so the
1440
- rule is that every handoff edge lies on a cycle. `zen check` warns
1441
- (`handoff.one-way`) on any edge that does not.
1442
- - Handoff collapses history by policy: the receiving agent sees a selection, not
1443
- the full transcript. Do not assume it saw a detail three turns back; if it
1444
- matters, put it in the handoff.
1445
-
1446
- **Why the return edge is not optional.** A handoff is a one-way door: control
1447
- moves and stays moved. Nothing hands it back, so an agent reached by a dead-end
1448
- edge owns the conversation for the rest of the session - the next question,
1449
- whatever it is about, is answered by the specialist the router sent the user to.
1450
- The drawn architecture holds for one turn and then quietly stops being the
1451
- architecture.
1452
-
1453
- **Forks are the exception, and the alternative.** A branch runs, answers, and
1454
- control returns to the agent that forked it; the return is the mechanism, not an
1455
- edge anyone has to declare. So there are two shapes and they are not
1456
- interchangeable:
1457
-
1458
- - The other agent should **own the conversation from here** → `handoffs:`, and
1459
- something on the far side has to lead back.
1460
- - This agent needs **an answer and then carries on** → `fork:`. Never a handoff:
1461
- a handoff spends the conversation to get the answer. One branch is enough -
1462
- a fork of one is exactly "ask the specialist and continue".
1463
-
1464
- But the return is **condensed**: `A → fork → B` rejoins as one tool result
1465
- holding B's answer, so A never sees the steps B took - no tool calls, no files
1466
- read, no intermediate reasoning. That is what makes fanning out cheap, and it is
1467
- what to design around: whatever A will need must be _in_ the answer, so say so in
1468
- B's prompt. Work whose value is the trace rather than the conclusion does not
1469
- survive a fork.
1444
+ `handoffs: [name, ...]` on an agent gives it one `transfer_to_<name>` tool per
1445
+ entry, described by the target's `description:`. Control moves to the target
1446
+ and **stays moved** - the target sees the whole transcript and answers every
1447
+ later turn until it hands off itself - so every edge needs a path back, and
1448
+ `zen check` warns `handoff.one-way` on one that has none.
1470
1449
 
1471
1450
  ### 6.4 Forking (fan-out / join)
1472
1451
 
1473
- Forking is **opt-in per agent**. Without the key the agent is never offered the
1474
- `fork` tool and cannot split, however obviously parallel the work looks:
1475
-
1476
- ```yaml
1477
- agents:
1478
- - name: trunk
1479
- fork: true # unrestricted: any agent, any number of branches
1480
-
1481
- - name: sweep
1482
- fork:
1483
- agents: [prober] # every branch runs the specialist
1484
- maxBranches: 6
1485
- ```
1452
+ `fork:` on an agent - `true`, or `{ agents, maxBranches }` - gives it the `fork`
1453
+ tool: N branches, run at once, rejoin as one tool result holding each branch's
1454
+ answer. One branch is delegation; several are a fan-out. Without the key the
1455
+ agent cannot split, however obviously parallel the work looks.
1486
1456
 
1487
- | Field | Default | Meaning |
1488
- | ------------- | -------------------- | ------------------------------------- |
1489
- | `agents` | every declared agent | Which agents a branch may run |
1490
- | `maxBranches` | unlimited | Cap on branches per call; minimum `1` |
1491
-
1492
- The **model** decides the split: it names N branches, each with self-contained
1493
- instructions. They run truly concurrently and rejoin as **one tool call and one
1494
- tool result** in the parent's history - so N branches cost the parent
1495
- O(N × summary), not O(N × full history).
1496
-
1497
- Rules worth knowing before you write the key:
1498
-
1499
- - `agents:` **may include the forking agent itself** - unlike `handoffs:`, that
1500
- is not an error, and one role fanned out over ten items is the common shape.
1501
- The list reaches the model as an `enum`, so a name outside it cannot even be
1502
- decoded.
1503
- - A fork of **one** branch is delegation, and it is valid: one assignment run
1504
- elsewhere, its conclusion returned, its transcript left out of this
1505
- conversation. Use it when another agent suits the job better, or when the job
1506
- would fill the caller's context with material it has no use for afterwards.
1507
- - **Branches cannot talk to each other.** If branch B needs branch A's answer,
1508
- it is a sequence, not a fork - keep it in one conversation.
1509
- - Nesting is capped by the run's `maxForkDepth` (2 by default), so a branch may
1510
- fork again but not without bound.
1511
- - Fork vs handoff: a handoff is _one_ conversation changing owner; a fork is the
1512
- _same_ question asked N times at once and merged. **A fork returns; a handoff
1513
- does not** - which is why a handoff needs a return path (§6.3) and a fork
1514
- needs nothing.
1515
-
1516
- Choose `context:` deliberately - the model sets it per call, so say in the
1517
- agent's prompt which one this work wants:
1518
-
1519
- - `inherit` - branch gets the full prefix. For work that depends on the case.
1520
- - `compact` - prefix minus tool calls, tool results and recalls: _what was
1521
- decided_, not the raw noise. **The default for wide fan-outs.**
1522
- - `none` - system prompt plus instructions only. Cheapest; for independent
1523
- lookups.
1524
-
1525
- Declaring `fork:` only makes the tool available. What a fork costs and what
1526
- survives the join is in `agents/fork-instructions.md`, which carries
1527
- `requires: [fork]` and so reaches exactly the agents holding the key. That file
1528
- is `zen`'s, not yours - `zen check --fix` replaces it, editing it or carrying an
1529
- older copy is reported as `rules.stale`, and deleting it leaves your forking
1530
- agents with the tool schema alone (`fork.uninstructed`). What is
1531
- left to you is _when_, in the terms of this domain - _"When the request covers
1532
- more than one region, fork one branch per region and merge their findings"_ - or
1533
- a weaker model will work through the list serially and never call it. Project
1534
- policy on forking goes in a topic file of your own beside it.
1457
+ **Load `zen-topology` before adding or changing either key, and before writing
1458
+ a prompt line that says when to delegate.** It holds the key reference, hand-off
1459
+ versus fork, which `context` a branch should start from, what each choice costs
1460
+ in tokens, prompt cache and time, and how a recorded run shows each mistake.
1535
1461
 
1536
1462
  ### 6.5 Termination
1537
1463
 
@@ -1969,7 +1895,7 @@ Before finishing any change here:
1969
1895
  - [ ] Each `agents/<topic>-instructions.md` is about one capability, and is true
1970
1896
  of every agent it reaches - `requires:` if it is about one of them
1971
1897
  - [ ] If any agent has file tools, `agents/files-instructions.md` is present - §3.6
1972
- - [ ] If any agent has `fork:`, `agents/fork-instructions.md` is present - §6.4
1898
+ - [ ] If any agent has `fork:`, `agents/fork-instructions.md` is present - zen-topology §8
1973
1899
  - [ ] No `rules.stale`: the four files that are `zen`'s rather than yours say
1974
1900
  what this version of the runtime does, and `zen check --fix` replaces them
1975
1901
  - [ ] Any change to an `agents/*instructions.md` was made with the
@@ -2004,6 +1930,9 @@ candidates; these are the judgements to make about each one)**
2004
1930
  - [ ] Catalog >~30 entries → `discovery: search`
2005
1931
  - [ ] A skill that ships a script writes its `/skills/<name>/...` path, the agent
2006
1932
  holds `sandbox:*`, and the sandbox image already has the interpreter
1933
+ - [ ] Every agent that writes or runs code has the `zen-code-python` rules -
1934
+ in its prompt if it is the dedicated code agent, as a skill otherwise -
1935
+ and nothing else restates or softens them - §0.1
2007
1936
  - [ ] A skill whose procedure needs particular tools, an index or a mounted file
2008
1937
  opens by naming them and says what to do without them - rather than naming
2009
1938
  the agents allowed to load it, which `agents.yaml` already decides - §0.1
@@ -2085,10 +2014,10 @@ candidates; these are the judgements to make about each one)**
2085
2014
  | Answers instead of routing | Router prompt prohibition; check `handoffs:` |
2086
2015
  | Routes to the wrong specialist | The target agents' `description:` fields |
2087
2016
  | Gets stuck in the agent it routed to | The target needs a handoff back - §6.3 |
2088
- | Loses a detail after a handoff | Say it in the handoff; check the collapse policy |
2017
+ | Loses a detail after a handoff | The target sees the whole transcript; its prompt must say to use it |
2089
2018
  | Works through N independent items serially | `fork:` on that agent, and a prompt line - §6.4 |
2090
2019
  | Forks when the steps actually depend | Prompt line: branches cannot see each other |
2091
- | Forks a sequence, or loses a branch's working | `agents/fork-instructions.md` is missing or empty - §6.4 |
2020
+ | Forks a sequence, or loses a branch's working | `agents/fork-instructions.md` is missing or empty - zen-topology §8 |
2092
2021
  | Edits files blindly or breaks patches | `agents/files-instructions.md` is missing or empty - §3.6 |
2093
2022
  | Slow and expensive on trivial cases | Demote that agent's model tier / reasoning effort |
2094
2023
  | Fails only on genuinely hard cases | Promote that agent's tier, or split the hard path out |
@@ -0,0 +1,31 @@
1
+ ---
2
+ description: Analyze one recorded run of this project - its health, what it wasted, and what to change in the instructions. Name the run (directory or id) after the command, or get the most recent one.
3
+ ---
4
+
5
+ Load the **zen-analyze-run** skill and follow it to analyze one run of this
6
+ project. Everything about how to analyze it is in the skill. If `agents.yaml`
7
+ has a `memory:` key anywhere (`grep -n 'memory:' agents.yaml`), load the
8
+ **zen-memory** skill with it, before you read the run: the memory areas of the
9
+ audit cannot be graded without it.
10
+
11
+ ## Which run
12
+
13
+ The last line of this prompt may name the run - a run directory or a run id.
14
+ If it does, use it. Words after it like `case=<id> ... feedback=<file>` mean
15
+ the tuning loop sent you: follow section 7 of the skill and write that file.
16
+
17
+ If it does not, list this project's most recent runs, newest first:
18
+
19
+ ```sh
20
+ zen list --runs --json --limit 500 \
21
+ | jq -r --arg p "$PWD/" '[.[] | select(.dir | startswith($p))][:5][]
22
+ | "\(.id) \(.agent // "-") \(.error // .stopReason // "-") \(.dir)"'
23
+ ```
24
+
25
+ - If there are none, stop and say this project has no runs yet.
26
+ - If you can ask the user a question, show that list and ask which run to
27
+ analyze, with the newest as the default.
28
+ - If you cannot ask, take the newest. Say which run you picked, and that it was
29
+ picked as the most recent, at the top of the report.
30
+
31
+ Then give the run to the skill.
@@ -0,0 +1,108 @@
1
+ ---
2
+ description: Build or refresh this project's dataset - every case read from its sources with a class, complexity, tags, a verbatim rubric and an anchor - re-reading only the sections that changed since the last revision. Name a source after the command to add it, `rebuild` to read everything again, or a case and what to fix.
3
+ ---
4
+
5
+ Keep `dataset/` in step with its sources. **Load the `zen-dataset` skill before
6
+ anything else**, and `zen-cli` for the command reference. The skill holds the
7
+ extraction rules and every verb; this prompt is the order of the work. If
8
+ loading a skill fails, read `.github/skills/<name>/SKILL.md` with your file tool
9
+ before going on.
10
+
11
+ You never run cases, never edit `agents/`, and never edit a source. Only
12
+ `zen meta dataset` writes `dataset/` - never a file tool, never a script.
13
+
14
+ This prompt is **reentrant**: the state on disk says what to do, so running it
15
+ twice in a row does nothing the second time.
16
+
17
+ ## 1. Where things stand
18
+
19
+ ```sh
20
+ zen meta dataset status
21
+ zen meta dataset drift
22
+ zen meta dataset ls --note rubric-suspect
23
+ ```
24
+
25
+ Say in three lines: the revision and case count, the sources, and how many
26
+ sections are `changed`, `gone` or `uncovered`.
27
+
28
+ ## 2. What to do
29
+
30
+ The last line of this prompt may hold words. Then read the table top down and
31
+ take the first row that fits:
32
+
33
+ | State | Do |
34
+ | ---------------------------------------- | --------------------------------------------------------------------- |
35
+ | the words name a case and a fix | that fix only, with `update`, `retire` or `reanchor` - then section 6 |
36
+ | the words say `rebuild` | read every source in full, as a whole proposal - section 3 |
37
+ | the words name a source file | read that file in full, add it as a `--partial` proposal - section 3 |
38
+ | no dataset, and no source named anywhere | **stop**: say which training set to name. The only stop |
39
+ | no dataset | read every source `SPECIFICATION.md` points at - section 3 |
40
+ | drift reports anything | read only the drifted sections - section 3 |
41
+ | drift is clean | nothing to do: report the status and stop |
42
+
43
+ Never ask a question mid-run - nobody is there to answer it. What you could not
44
+ decide goes into the report and onto the case as a note.
45
+
46
+ ## 3. Read the sections
47
+
48
+ Read each section yourself and write the cases out by the skill's rules: the
49
+ rubric **verbatim**, class from the source's own distinctions, complexity from
50
+ the trajectory the query demands, an anchor on every case, and **the id a case
51
+ already has** when you re-read its section. Write them to
52
+ `.tmp/dataset/proposal.json`.
53
+
54
+ On a refresh, the proposal holds only the cases of the drifted sections, and is
55
+ applied `--partial`. A case whose section changed but which still asks, expects
56
+ and is judged the same goes in unchanged - that is how its drift is settled.
57
+
58
+ ## 4. Settle what is gone and what is new
59
+
60
+ Every `gone` and `uncovered` line from step 1 gets an answer, or the next drift
61
+ check reports it again:
62
+
63
+ - **gone** - the section was deleted: `retire <id> --why "…"`. It was renamed
64
+ or moved: `reanchor <id> --heading "…" --why "…"`.
65
+ - **uncovered** - it holds queries: they are new cases in the proposal. It does
66
+ not (an introduction, a glossary): `ignore <file> --heading "…" --why "…"`.
67
+
68
+ ## 5. Apply
69
+
70
+ ```sh
71
+ zen meta dataset apply .tmp/dataset/proposal.json [--partial] --dry-run
72
+ ```
73
+
74
+ Check the dry run against what you meant before writing anything:
75
+
76
+ - nothing `retired` you did not intend - a whole proposal retires every case it
77
+ leaves out
78
+ - no id changed for a case you only re-read
79
+ - every `restarted` case is one whose input, rubric or expected answer really
80
+ changed in the source
81
+
82
+ Then the same command without `--dry-run`, with `--why` naming what changed in
83
+ the source.
84
+
85
+ ## 6. Check
86
+
87
+ ```sh
88
+ zen meta dataset drift
89
+ zen meta dataset status
90
+ ```
91
+
92
+ Drift must be clean. The count per class must match a count you take from the
93
+ source by hand. Every media path must exist - apply refuses one that does not,
94
+ so a refusal here is a path to fix, not a step to skip.
95
+
96
+ ## 7. Report
97
+
98
+ - the revision, and what changed: added, updated, retired, restored and
99
+ **restarted** cases, by id
100
+ - cases per class and per complexity, and how many have a rubric
101
+ - what restarted means for whoever runs the cases next: their earlier results
102
+ are about a different question - `zen meta dataset sample --restarted` lists
103
+ them
104
+ - every case with an open `rubric-suspect` note, and what the source would
105
+ need to say
106
+ - what you could not decide, each with the case or section it is about; leave
107
+ each one on its case as well:
108
+ `zen meta dataset note <id> --kind observation -m "…"`
@@ -0,0 +1,91 @@
1
+ ---
2
+ description: Apply a batch of improvement requests from the tuning loop to the project's prose - merge them into patterns, edit prompts, skills and policy files, and record what was done with each. Run by `zen meta finetune`; the last line names the apply directory.
3
+ ---
4
+
5
+ The tuning loop has collected improvement requests from several cases and
6
+ wants them applied **together**. The last line of this prompt names the apply
7
+ directory. Load the `zen-instructions` skill before you edit anything under
8
+ `agents/`, `zen-memory` when any request is from a run with memory, and
9
+ `zen-code-python` when any request touches an agent that writes or runs code.
10
+
11
+ ## What you are given
12
+
13
+ - `<apply dir>/inputs.json` - the requests: each has `id` (`<case>@<phase>-<attempt>`),
14
+ `case`, `phase` (`nomem` or `mem`), `summary`, `improvements` (each with `id`,
15
+ `kind`, `file`, `change`, `why`, `expect`) and `file`, the feedback it came from.
16
+ The analysis behind each is `analysis.md` beside that file - read it when an
17
+ improvement is unclear.
18
+ - Every earlier `finetune/applies/*/decisions.json` and `changes.md` - what
19
+ was already tried. Do not re-apply a rule an earlier apply added and a later
20
+ run showed did not work; change it instead.
21
+ - `<apply dir>/check.log`, if it exists: your previous attempt left the project
22
+ failing `zen check`, and the edit was undone. Read it first.
23
+
24
+ ## What to do
25
+
26
+ 1. **Merge before editing.** Group the improvements by the behaviour they fix.
27
+ Several cases asking for the same thing in different words is one rule.
28
+ Two that contradict each other: decide, and say why.
29
+ 2. **Generalise.** Every rule must hold for queries no case asked. Never write
30
+ a case's answer, its ids or its data into the prose - if a request only
31
+ makes sense for its one case, reject it.
32
+ 3. **Edit** prompts under `agents/prompts/`, skills under `agents/skills/`,
33
+ `agents/instructions.md` and `agents/<topic>-policy-instructions.md`
34
+ (create the policy file when the rule belongs to one capability). Requests
35
+ from runs **with memory** change only the memory policy -
36
+ `agents/memory-policy-instructions.md` - or the memory paragraph a request
37
+ names.
38
+ 4. **Never edit** `agents.yaml`, `agents/memory-instructions.md`,
39
+ `agents/tools-instructions.md`, `agents/fork-instructions.md` or
40
+ `agents/files-instructions.md`, nor anything outside `agents/`. A request
41
+ that needs one of those is **structural**: record it, do not apply it.
42
+ 5. **Check**: `zen check --no-models --no-sandbox` must pass when you finish.
43
+
44
+ ## What to write
45
+
46
+ - `<apply dir>/changes.md` - read by a person deciding whether to trust this
47
+ apply, so leave nothing out. One section per file you touched:
48
+
49
+ ```markdown
50
+ ## agents/prompts/default.md
51
+
52
+ **Answers:** plan-day@nomem-1 i1, long-list-3@nomem-1 i1 (merged)
53
+
54
+ **The pattern:** what the cases did wrong, in one paragraph, with the node
55
+ ids from their analyses - not a case's answer.
56
+
57
+ **Before:** the sentence or section as it was, quoted (or "new section").
58
+
59
+ **After:** the text as it is now, quoted.
60
+
61
+ **Why it generalises:** which queries beyond these cases it changes, and
62
+ which it must not.
63
+
64
+ **Expect:** what the next run's graph should show if it worked.
65
+ ```
66
+
67
+ Then a section **Not applied**: every rejected or structural improvement, with
68
+ why.
69
+
70
+ - `<apply dir>/decisions.json` - a decision for **every** improvement of every
71
+ request, nothing skipped:
72
+
73
+ ```json
74
+ {
75
+ "plan-day@nomem-1": {
76
+ "i1": { "decision": "applied", "note": "agents/prompts/default.md - planning section" },
77
+ "i2": { "decision": "merged", "note": "same rule as long-list-3@nomem-1 i1" }
78
+ },
79
+ "long-list-3@nomem-1": {
80
+ "i1": { "decision": "applied", "note": "agents/pagination-policy-instructions.md" },
81
+ "i2": { "decision": "structural", "note": "needs a tool in agents.yaml" },
82
+ "i3": { "decision": "rejected", "note": "only true for this case's data" }
83
+ }
84
+ }
85
+ ```
86
+
87
+ `decision` is one of `applied`, `merged`, `rejected`, `structural`. The note is
88
+ one line a person reads in the case's FEEDBACK.md.
89
+
90
+ Your answer is a short summary: how many rules, which files, and anything
91
+ structural the user must decide.