@treeseed/dsh-chapters 0.1.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.
Files changed (119) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +644 -0
  3. package/cordis.patch.yml +88 -0
  4. package/docs/architecture.md +460 -0
  5. package/docs/contract.md +375 -0
  6. package/docs/development.md +437 -0
  7. package/docs/host-compaction-seam.md +117 -0
  8. package/docs/knowledge-repo.md +730 -0
  9. package/docs/provider.md +98 -0
  10. package/docs/verify.md +200 -0
  11. package/lib/archive.d.ts +88 -0
  12. package/lib/archive.js +114 -0
  13. package/lib/archive.js.map +1 -0
  14. package/lib/arrival.d.ts +23 -0
  15. package/lib/arrival.js +86 -0
  16. package/lib/arrival.js.map +1 -0
  17. package/lib/artifact-query.d.ts +53 -0
  18. package/lib/artifact-query.js +130 -0
  19. package/lib/artifact-query.js.map +1 -0
  20. package/lib/client.js +234 -0
  21. package/lib/client.js.map +1 -0
  22. package/lib/commands.d.ts +28 -0
  23. package/lib/commands.js +305 -0
  24. package/lib/commands.js.map +1 -0
  25. package/lib/compose.d.ts +30 -0
  26. package/lib/compose.js +131 -0
  27. package/lib/compose.js.map +1 -0
  28. package/lib/continue-core.d.ts +153 -0
  29. package/lib/continue-core.js +252 -0
  30. package/lib/continue-core.js.map +1 -0
  31. package/lib/engine-core.d.ts +219 -0
  32. package/lib/engine-core.js +405 -0
  33. package/lib/engine-core.js.map +1 -0
  34. package/lib/engine.d.ts +211 -0
  35. package/lib/engine.js +571 -0
  36. package/lib/engine.js.map +1 -0
  37. package/lib/enrich-queue.d.ts +66 -0
  38. package/lib/enrich-queue.js +100 -0
  39. package/lib/enrich-queue.js.map +1 -0
  40. package/lib/enrich-store.d.ts +31 -0
  41. package/lib/enrich-store.js +103 -0
  42. package/lib/enrich-store.js.map +1 -0
  43. package/lib/enrich-wire.d.ts +73 -0
  44. package/lib/enrich-wire.js +209 -0
  45. package/lib/enrich-wire.js.map +1 -0
  46. package/lib/enrich.d.ts +73 -0
  47. package/lib/enrich.js +150 -0
  48. package/lib/enrich.js.map +1 -0
  49. package/lib/gitops.d.ts +107 -0
  50. package/lib/gitops.js +539 -0
  51. package/lib/gitops.js.map +1 -0
  52. package/lib/index.d.ts +81 -0
  53. package/lib/index.js +305 -0
  54. package/lib/index.js.map +1 -0
  55. package/lib/indexing.d.ts +85 -0
  56. package/lib/indexing.js +212 -0
  57. package/lib/indexing.js.map +1 -0
  58. package/lib/injections.d.ts +66 -0
  59. package/lib/injections.js +83 -0
  60. package/lib/injections.js.map +1 -0
  61. package/lib/notice.d.ts +60 -0
  62. package/lib/notice.js +84 -0
  63. package/lib/notice.js.map +1 -0
  64. package/lib/provider.d.ts +44 -0
  65. package/lib/provider.js +66 -0
  66. package/lib/provider.js.map +1 -0
  67. package/lib/redact.d.ts +24 -0
  68. package/lib/redact.js +85 -0
  69. package/lib/redact.js.map +1 -0
  70. package/lib/registry.d.ts +120 -0
  71. package/lib/registry.js +130 -0
  72. package/lib/registry.js.map +1 -0
  73. package/lib/render.d.ts +40 -0
  74. package/lib/render.js +280 -0
  75. package/lib/render.js.map +1 -0
  76. package/lib/repo.d.ts +78 -0
  77. package/lib/repo.js +184 -0
  78. package/lib/repo.js.map +1 -0
  79. package/lib/rules-commands.d.ts +24 -0
  80. package/lib/rules-commands.js +138 -0
  81. package/lib/rules-commands.js.map +1 -0
  82. package/lib/rules.d.ts +90 -0
  83. package/lib/rules.js +185 -0
  84. package/lib/rules.js.map +1 -0
  85. package/lib/search.d.ts +48 -0
  86. package/lib/search.js +152 -0
  87. package/lib/search.js.map +1 -0
  88. package/lib/signature.d.ts +28 -0
  89. package/lib/signature.js +149 -0
  90. package/lib/signature.js.map +1 -0
  91. package/lib/store.d.ts +130 -0
  92. package/lib/store.js +235 -0
  93. package/lib/store.js.map +1 -0
  94. package/lib/sync.d.ts +183 -0
  95. package/lib/sync.js +719 -0
  96. package/lib/sync.js.map +1 -0
  97. package/lib/tools.d.ts +84 -0
  98. package/lib/tools.js +581 -0
  99. package/lib/tools.js.map +1 -0
  100. package/lib/treedx/client.d.ts +57 -0
  101. package/lib/treedx/client.js +82 -0
  102. package/lib/treedx/client.js.map +1 -0
  103. package/lib/treedx/provider.d.ts +39 -0
  104. package/lib/treedx/provider.js +479 -0
  105. package/lib/treedx/provider.js.map +1 -0
  106. package/lib/treedx/state.d.ts +27 -0
  107. package/lib/treedx/state.js +65 -0
  108. package/lib/treedx/state.js.map +1 -0
  109. package/lib/types.d.ts +100 -0
  110. package/lib/types.js +19 -0
  111. package/lib/types.js.map +1 -0
  112. package/lib/vocabulary.d.ts +41 -0
  113. package/lib/vocabulary.js +118 -0
  114. package/lib/vocabulary.js.map +1 -0
  115. package/package.json +132 -0
  116. package/presets/chapters/agent.cordis.yml +272 -0
  117. package/presets/chapters/preset.yml +3 -0
  118. package/presets/probe-roots/agent.cordis.yml +11 -0
  119. package/presets/probe-roots/preset.yml +3 -0
@@ -0,0 +1,272 @@
1
+ # dsh-chapters preset: the standard coding agent with chapter-form compaction.
2
+ # Copied from @deepseek-ai/dsh-agent-presets/presets/standard/agent.cordis.yml
3
+ # (host 0.1.5-rc.1 / rc.2 sub-packages) and modified in exactly one place:
4
+ # the compaction group's engine row. Re-anchor this copy after any DSH upgrade:
5
+ # diff <(sed -n '/^# /!p' <installed>/standard/agent.cordis.yml) presets/chapters/agent.cordis.yml
6
+ # The command-compact row is the host's; its curated error text degrades to a
7
+ # generic failure when our engine's ManualCompactionError (plugin module copy)
8
+ # fails its instanceof check (measured r12) — our own command lands with Stage 4.
9
+ # The `standard` agent preset: the full coding agent, mounted once per process.
10
+ #
11
+ # This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
12
+ # standing scope; every session naming it joins by scope parentage, so the
13
+ # tools and prompt sections registered here cover each joined agent while a
14
+ # session's own state stays keyed per Session/Agent inside the plugins. The
15
+ # host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
16
+ # preset must not own: the registries themselves, the sandbox and approval
17
+ # stack, persistence, and the model route.
18
+ #
19
+ # A service row here MUST sit inside a group carrying an `isolate` realm.
20
+ # Without one it publishes into the root realm, where it is process-global —
21
+ # another preset publishing the same name collides, and a host reader would
22
+ # resolve one preset's instance for every session; `dsh-agent-presets` rejects
23
+ # that at mount. `true` means an entry-local realm: this standing mount's own
24
+ # private instance, apart from every other preset's. (A shared label does NOT
25
+ # pool instances — `provide()` throws on the second registration under the
26
+ # same realm symbol; labels join REALMS, and are not what this file needs.)
27
+
28
+ # ── identity ────────────────────────────────────────────────────────────────
29
+
30
+ # The preset's own persona, shadowing the deployment default for this agent.
31
+ # `{{model}}` and `{{cwd}}` resolve from the agent's own route and workspace.
32
+ - id: persona
33
+ name: '@deepseek-ai/dsh-persona'
34
+ config:
35
+ suffix: "Your working directory is {{cwd}}. When a task spans multiple turns, end each reply with one line beginning 'PLOT:' (max 60 words — objective, current hypothesis, immediate next step). A checkpoint carries this plot forward; if it looks stale, revise it on your next plot line."
36
+ prefix: >-
37
+ You are a coding agent powered by the {{model}} model.
38
+
39
+ - id: agent-instructions
40
+ name: '@deepseek-ai/dsh-agent-instructions'
41
+ config:
42
+ maxBytes: 65536
43
+
44
+ # ── shell ───────────────────────────────────────────────────────────────────
45
+
46
+ # `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
47
+ # publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
48
+ # the criterion for host-plane ownership — injection resolves before any session
49
+ # exists, so there is no agent to key by. Behind a preset realm those variables
50
+ # never reached the model's shell at all. Both shell tools consume the host
51
+ # registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
52
+ # host-plane too.
53
+ - id: tool-bash
54
+ name: '@deepseek-ai/dsh-tool-bash'
55
+ disabled: !!js process.platform === 'win32'
56
+
57
+ - id: tool-pwsh
58
+ name: '@deepseek-ai/dsh-tool-pwsh'
59
+ disabled: !!js process.platform !== 'win32'
60
+
61
+ # ── filesystem ──────────────────────────────────────────────────────────────
62
+
63
+ # Both register into the host `tools` registry and provide nothing, so
64
+ # they need no realm. The `fs` service and its policy stay in the host.
65
+ - id: tool-fs
66
+ name: '@deepseek-ai/dsh-tool-fs'
67
+
68
+ - id: tool-fs-search
69
+ name: '@deepseek-ai/dsh-tool-fs-search'
70
+ config:
71
+ sampleOverCapGlobResults: false
72
+
73
+ # ── background jobs ────────────────────────────────────────────────────────
74
+
75
+ # Only the model-facing controls. The task REGISTRY stays on the host plane:
76
+ # its producers sit outside any realm this file could put it in — `tool-bash`
77
+ # above resolves it with `ctx.get`, and an entry-local realm here is invisible
78
+ # to every sibling row, so `run_in_background` would answer "background jobs
79
+ # unavailable" while these controls sat in the catalog. The registry is keyed by
80
+ # owning agent anyway, so one host instance serves every session. What a preset
81
+ # chooses is whether its agent can collect and stop background work at all.
82
+ - id: tool-jobs
83
+ name: '@deepseek-ai/dsh-tool-jobs'
84
+
85
+ # ── skills ──────────────────────────────────────────────────────────────────
86
+
87
+ # The skill REGISTRY lives in the host composition and is layered per scope:
88
+ # these rows register into THIS preset's layer of it, so they need no realm.
89
+ # `skill-filesystem` contributes local-root discovery for agents on this preset, and
90
+ # `tool-skill` gives them the catalog and loader; the merged catalog also
91
+ # carries whatever the deployment registered globally (repository plugins).
92
+ - id: skill-filesystem
93
+ name: '@deepseek-ai/dsh-skill-filesystem'
94
+
95
+ - id: tool-skill
96
+ name: '@deepseek-ai/dsh-tool-skill'
97
+
98
+ # ── goals ───────────────────────────────────────────────────────────────────
99
+
100
+ # The goal service and session driver stay on the host plane, where the Gateway
101
+ # can resolve them. The human command and model-facing tool register into this
102
+ # preset's scoped layers.
103
+ - id: command-goal
104
+ name: '@deepseek-ai/dsh-command-goal'
105
+
106
+ - id: tool-goal
107
+ name: '@deepseek-ai/dsh-tool-goal'
108
+
109
+ # ── plan mode ───────────────────────────────────────────────────────────────
110
+
111
+ # Plan state is per-agent by nature, so an entry-local realm is not a
112
+ # workaround here — it is the correct lifetime.
113
+ - id: planning
114
+ name: cordis:group
115
+ group: true
116
+ isolate:
117
+ planMode: true
118
+ config:
119
+ - id: plan-mode
120
+ name: '@deepseek-ai/dsh-plan-mode'
121
+ config:
122
+ section: |
123
+ You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
124
+
125
+ Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
126
+
127
+ The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
128
+
129
+ Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
130
+
131
+ Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
132
+
133
+ When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
134
+
135
+ # ── compaction ──────────────────────────────────────────────────────────────
136
+
137
+ # `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
138
+ # share this realm rather than sit outside it.
139
+ #
140
+ # `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
141
+ # plane, and the rows here resolve that one instance. It takes no configuration,
142
+ # keys every fold by Session, and owns the context-meter projection units the
143
+ # browser reads for every session — behind a realm those units would come and go
144
+ # with whichever presets happen to be mounted. What a preset chooses is whether
145
+ # its agent compacts at all, which is `compaction-basic` below.
146
+ - id: compaction
147
+ name: cordis:group
148
+ group: true
149
+ isolate:
150
+ compaction: true
151
+ toolResultPruner: true
152
+ config:
153
+ - id: chapters-engine
154
+ name: '@treeseed/dsh-chapters/engine'
155
+ config:
156
+ thresholdRatio: 0.9
157
+
158
+ - id: command-compact
159
+ name: '@deepseek-ai/dsh-command-compact'
160
+
161
+ - id: tool-result-pruner
162
+ name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
163
+ config:
164
+ thresholdChars: 1000000 # ~1MB results: effectively never; see rationale below
165
+ # DELIBERATELY DORMANT for the Chapters preset (forensics 2026-09-17): the default
166
+ # 8,192-char threshold pruned the user's own Chapters sessions 11x (~35K chars), and on
167
+ # a llama.cpp slot every prune is a prefix cliff -- one silent full re-prefill of the
168
+ # tail at local pp speed -- plus the model then chases the stubs with ranged re-reads
169
+ # (19/29 of that session's reads). Chapters defers oversized results at ARCHIVE time
170
+ # instead (verbatim chapter bodies + artifact references), which costs the surface
171
+ # nothing between compactions. The row stays mounted, threshold pushed to ~1M chars,
172
+ # as last-resort overflow insurance and to keep pruneSession's citation behavior
173
+ # uniform across presets; re-enable deliberately for token-rich cloud presets.
174
+
175
+ # ── delegation and workflows ────────────────────────────────────────────────
176
+
177
+ # The `subagents` registry and its spawn/fork backends live in the HOST
178
+ # composition: the registry is a process singleton whose cross-session queries
179
+ # the api-proxy serves to the browser, and a provider name may only be
180
+ # registered once. This preset contributes the delegation TOOLS, which resolve
181
+ # that host registry.
182
+ #
183
+ # `workflows` is different — nothing outside an agent reads it — so every row
184
+ # that reaches it shares one entry-local realm here, and a consumer left
185
+ # outside would resolve a host registry this preset does not populate.
186
+ - id: delegation
187
+ name: cordis:group
188
+ group: true
189
+ isolate:
190
+ workflowEngine: true
191
+ config:
192
+ - id: tool-subagent-control
193
+ name: '@deepseek-ai/dsh-tool-subagent-control'
194
+
195
+ - id: tool-subagent-list-agents
196
+ name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
197
+
198
+ - id: tool-subagent
199
+ name: '@deepseek-ai/dsh-tool-subagent'
200
+ config:
201
+ provider: spawn
202
+ toolName: subagent
203
+ modelSelectionSettings: true
204
+ backgroundMode: continuable
205
+
206
+ # Fork omits model selection so provider/model stay equal to the parent and
207
+ # the inherited history remains eligible for KV Cache reuse. This preset
208
+ # keeps fork continuable; parent and child inherit the same messaging tool,
209
+ # while the parent id and return guidance follow the inherited history.
210
+ - id: tool-subagent-fork
211
+ name: '@deepseek-ai/dsh-tool-subagent'
212
+ config:
213
+ provider: fork
214
+ toolName: subagent_fork
215
+ backgroundMode: continuable
216
+
217
+ # Production dsh does not install these optional providers. Install the
218
+ # matching Bundle in this Profile and restart the Host, then copy this
219
+ # preset and remove `disabled` from the matching tool row. Host availability
220
+ # alone grants no tool.
221
+ - id: tool-subagent-codex
222
+ name: '@deepseek-ai/dsh-tool-subagent'
223
+ disabled: true
224
+ config:
225
+ provider: codex
226
+ toolName: subagent_codex
227
+ backgroundMode: one-shot
228
+ maxDepth: provider-managed
229
+
230
+ - id: tool-subagent-claude-code
231
+ name: '@deepseek-ai/dsh-tool-subagent'
232
+ disabled: true
233
+ config:
234
+ provider: claude-code
235
+ toolName: subagent_claude_code
236
+ backgroundMode: one-shot
237
+ maxDepth: provider-managed
238
+
239
+ - id: workflow-worker-thread
240
+ name: '@deepseek-ai/dsh-workflow-worker-thread'
241
+ config:
242
+ provider: spawn
243
+
244
+ - id: tool-workflow
245
+ name: '@deepseek-ai/dsh-tool-workflow'
246
+
247
+ - id: tool-ralph
248
+ name: '@deepseek-ai/dsh-tool-ralph'
249
+ config:
250
+ subagentProvider: spawn
251
+ maxRounds: 64
252
+
253
+ # ── remaining model-facing rows ─────────────────────────────────────────────
254
+
255
+ - id: tool-ask-user
256
+ name: '@deepseek-ai/dsh-tool-ask-user'
257
+
258
+ - id: tool-todo
259
+ name: '@deepseek-ai/dsh-tool-todo'
260
+ config:
261
+ allowParallelInProgress: true
262
+
263
+ # The `web` service and its search provider stay in the host composition; only
264
+ # the model-facing tool is per-session.
265
+ - id: tool-web
266
+ name: '@deepseek-ai/dsh-tool-web'
267
+ config:
268
+ fetch: true
269
+ searchTimeoutMs: 60000
270
+
271
+ - id: present
272
+ name: '@deepseek-ai/dsh-tool-present'
@@ -0,0 +1,3 @@
1
+ name: Chapters
2
+ description: Full coding agent; context relief via zero-inference chapter compaction.
3
+ order: 0
@@ -0,0 +1,11 @@
1
+ - id: compaction
2
+ name: cordis:group
3
+ group: true
4
+ isolate:
5
+ compaction: true
6
+ toolResultPruner: true
7
+ config:
8
+ - id: chapters-engine
9
+ name: dsh-chapters/engine
10
+ config:
11
+ auto: false
@@ -0,0 +1,3 @@
1
+ name: Probe Roots
2
+ description: Package-shipped preset resolving via agentPresets config.roots.
3
+ order: 96