@try-works/dsh-recursive-mode 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 (88) hide show
  1. package/cordis.patch.yml +12 -0
  2. package/lib/bootstrap.d.ts +35 -0
  3. package/lib/client/board.d.ts +10 -0
  4. package/lib/client/contract.d.ts +51 -0
  5. package/lib/client/derive.d.ts +92 -0
  6. package/lib/client/index.d.ts +21 -0
  7. package/lib/client/inspector.d.ts +10 -0
  8. package/lib/client/node.d.ts +71 -0
  9. package/lib/client/settings.d.ts +6 -0
  10. package/lib/client/slots.d.ts +7 -0
  11. package/lib/client/strip.d.ts +7 -0
  12. package/lib/client.d.ts +10 -0
  13. package/lib/client.js +490 -0
  14. package/lib/closeout.d.ts +23 -0
  15. package/lib/commands.d.ts +51 -0
  16. package/lib/delegation.d.ts +92 -0
  17. package/lib/enforcement.d.ts +53 -0
  18. package/lib/events.d.ts +173 -0
  19. package/lib/handoff.d.ts +51 -0
  20. package/lib/index.d.ts +40 -0
  21. package/lib/lifecycle.d.ts +107 -0
  22. package/lib/lock.d.ts +92 -0
  23. package/lib/policy.d.ts +12 -0
  24. package/lib/projection.d.ts +29 -0
  25. package/lib/recursive_closeout.tool.d.ts +8 -0
  26. package/lib/recursive_init.tool.d.ts +2 -0
  27. package/lib/recursive_lint.tool.d.ts +2 -0
  28. package/lib/recursive_lock.tool.d.ts +2 -0
  29. package/lib/recursive_scratch.tool.d.ts +7 -0
  30. package/lib/recursive_status.tool.d.ts +2 -0
  31. package/lib/review.d.ts +39 -0
  32. package/lib/router.d.ts +77 -0
  33. package/lib/run.d.ts +29 -0
  34. package/lib/runtime.d.ts +241 -0
  35. package/lib/scratch.d.ts +18 -0
  36. package/lib/status.d.ts +19 -0
  37. package/lib/types.d.ts +104 -0
  38. package/lib/workspace.d.ts +50 -0
  39. package/package.json +119 -0
  40. package/preset/recursive/agent.cordis.yml +282 -0
  41. package/preset/recursive/preset.yml +3 -0
  42. package/scripts/install-recursive-mode.ps1 +956 -0
  43. package/scripts/install-recursive-mode.py +750 -0
  44. package/scripts/lint-recursive-run.py +2868 -0
  45. package/scripts/recursive-closeout.py +541 -0
  46. package/scripts/recursive-init.py +356 -0
  47. package/scripts/recursive-lock.py +302 -0
  48. package/scripts/recursive-status.py +2124 -0
  49. package/scripts/recursive_phase_rules.py +367 -0
  50. package/scripts/recursive_router_lib.py +2282 -0
  51. package/scripts/test-recursive-mode-smoke.ts +204 -0
  52. package/scripts/verify-locks.py +353 -0
  53. package/src/bootstrap.ts +118 -0
  54. package/src/client/board.tsx +61 -0
  55. package/src/client/contract.ts +58 -0
  56. package/src/client/derive.ts +241 -0
  57. package/src/client/index.ts +28 -0
  58. package/src/client/inspector.tsx +49 -0
  59. package/src/client/node.ts +156 -0
  60. package/src/client/settings.tsx +18 -0
  61. package/src/client/slots.ts +67 -0
  62. package/src/client/strip.tsx +28 -0
  63. package/src/client.ts +11 -0
  64. package/src/closeout.ts +183 -0
  65. package/src/commands.ts +142 -0
  66. package/src/delegation.ts +306 -0
  67. package/src/enforcement.ts +180 -0
  68. package/src/events.ts +173 -0
  69. package/src/handoff.ts +165 -0
  70. package/src/index.ts +283 -0
  71. package/src/lifecycle.ts +235 -0
  72. package/src/lock.ts +369 -0
  73. package/src/policy.ts +56 -0
  74. package/src/projection.ts +237 -0
  75. package/src/recursive_closeout.tool.ts +35 -0
  76. package/src/recursive_init.tool.ts +28 -0
  77. package/src/recursive_lint.tool.ts +29 -0
  78. package/src/recursive_lock.tool.ts +33 -0
  79. package/src/recursive_scratch.tool.ts +42 -0
  80. package/src/recursive_status.tool.ts +24 -0
  81. package/src/review.ts +178 -0
  82. package/src/router.ts +197 -0
  83. package/src/run.ts +85 -0
  84. package/src/runtime.ts +564 -0
  85. package/src/scratch.ts +85 -0
  86. package/src/status.ts +194 -0
  87. package/src/types.ts +112 -0
  88. package/src/workspace.ts +67 -0
@@ -0,0 +1,282 @@
1
+ # The `recursive` agent preset: the full coding agent (standard surface), presented
2
+ # with BOTH tool modes (`mode: both`), plus the recursive-mode workflow surface.
3
+ # Everything in `standard` is here unchanged; see the recursive-mode surface rows
4
+ # added before the identity section (tool-presentation both, the isolated
5
+ # recursive-realm, and the recursive:policy prompt section).
6
+ #
7
+ # This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
8
+ # standing scope; every session naming it joins by scope parentage, so the
9
+ # tools and prompt sections registered here cover each joined agent while a
10
+ # session's own state stays keyed per Session/Agent inside the plugins. The
11
+ # host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
12
+ # preset must not own: the registries themselves, the sandbox and approval
13
+ # stack, persistence, and the model route.
14
+ #
15
+ # A service row here MUST sit inside a group carrying an `isolate` realm.
16
+ # Without one it publishes into the root realm, where it is process-global —
17
+ # another preset publishing the same name collides, and a host reader would
18
+ # resolve one preset's instance for every session; `dsh-agent-presets` rejects
19
+ # that at mount. `true` means an entry-local realm: this standing mount's own
20
+ # private instance, apart from every other preset's. (A shared label does NOT
21
+ # pool instances — `provide()` throws on the second registration under the
22
+ # same realm symbol; labels join REALMS, and are not what this file needs.)
23
+
24
+ # ── recursive-mode surface ─────────────────────────────────────────────────
25
+
26
+ # tool-presentation mode both (decision #12, PROPOSAL §7.4): the model sees
27
+ # native tools AND the run_code SDK.
28
+ - id: tool-presentation
29
+ name: '@deepseek-ai/dsh-agent-tool-presentation'
30
+ config:
31
+ mode: both
32
+
33
+ # The recursive workflow realm: per-session isolated RecursiveRuntime service +
34
+ # the recursive_* tools + the /recursive command + the policy prompt section.
35
+ # isolate.recursive keeps `provide('recursive')` from colliding across sessions.
36
+ - id: recursive-realm
37
+ name: cordis:group
38
+ group: true
39
+ isolate:
40
+ recursive: true
41
+ config:
42
+ - id: recursive
43
+ name: @try-works/dsh-recursive-mode/src/index.ts
44
+
45
+ - id: recursive-command
46
+ name: @try-works/dsh-recursive-mode/src/commands.ts
47
+
48
+ # The recursive:policy prompt section is registered in code (Stage A,
49
+ # src/index.ts via ctx.systemPrompt.section) — see plan-mode's pattern.
50
+
51
+ # ── identity ────────────────────────────────────────────────────────────────
52
+
53
+ # The preset's own persona, shadowing the deployment default for this agent.
54
+ # `{{model}}` and `{{cwd}}` resolve from the agent's own route and workspace.
55
+ - id: persona
56
+ name: '@deepseek-ai/dsh-persona'
57
+ config:
58
+ text: >-
59
+ You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}.
60
+
61
+ - id: agent-instructions
62
+ name: '@deepseek-ai/dsh-agent-instructions'
63
+ config:
64
+ maxBytes: 65536
65
+
66
+ # ── shell ───────────────────────────────────────────────────────────────────
67
+
68
+ # `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
69
+ # publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
70
+ # the criterion for host-plane ownership — injection resolves before any session
71
+ # exists, so there is no agent to key by. Behind a preset realm those variables
72
+ # never reached the model's shell at all. Both shell tools consume the host
73
+ # registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
74
+ # host-plane too.
75
+ - id: tool-bash
76
+ name: '@deepseek-ai/dsh-tool-bash'
77
+ disabled: !!js process.platform === 'win32'
78
+
79
+ - id: tool-pwsh
80
+ name: '@deepseek-ai/dsh-tool-pwsh'
81
+ disabled: !!js process.platform !== 'win32'
82
+
83
+ # ── filesystem ──────────────────────────────────────────────────────────────
84
+
85
+ # Both register into the host `tools` registry and provide nothing, so
86
+ # they need no realm. The `fs` service and its policy stay in the host.
87
+ - id: tool-fs
88
+ name: '@deepseek-ai/dsh-tool-fs'
89
+
90
+ - id: tool-fs-search
91
+ name: '@deepseek-ai/dsh-tool-fs-search'
92
+ config:
93
+ sampleOverCapGlobResults: false
94
+
95
+ # ── background jobs ────────────────────────────────────────────────────────
96
+
97
+ # Only the model-facing controls. The task REGISTRY stays on the host plane:
98
+ # its producers sit outside any realm this file could put it in — `tool-bash`
99
+ # above resolves it with `ctx.get`, and an entry-local realm here is invisible
100
+ # to every sibling row, so `run_in_background` would answer "background jobs
101
+ # unavailable" while these controls sat in the catalog. The registry is keyed by
102
+ # owning agent anyway, so one host instance serves every session. What a preset
103
+ # chooses is whether its agent can collect and stop background work at all.
104
+ - id: tool-jobs
105
+ name: '@deepseek-ai/dsh-tool-jobs'
106
+
107
+ # ── skills ──────────────────────────────────────────────────────────────────
108
+
109
+ # The skill REGISTRY lives in the host composition and is layered per scope:
110
+ # these rows register into THIS preset's layer of it, so they need no realm.
111
+ # `skill-filesystem` contributes local-root discovery for agents on this preset, and
112
+ # `tool-skill` gives them the catalog and loader; the merged catalog also
113
+ # carries whatever the deployment registered globally (repository plugins).
114
+ - id: skill-filesystem
115
+ name: '@deepseek-ai/dsh-skill-filesystem'
116
+
117
+ - id: tool-skill
118
+ name: '@deepseek-ai/dsh-tool-skill'
119
+
120
+ # ── goals ───────────────────────────────────────────────────────────────────
121
+
122
+ # Only the model-facing tool. The goal SERVICE, its session driver, and the
123
+ # `/goal` command stay on the host plane: the Gateway serves the goal domain as
124
+ # Remote endpoints whose receiver comes from a generated descriptor, so it
125
+ # resolves `goals` on the host and an entry-local realm here would hide it. The
126
+ # registry is keyed by session anyway, so one host instance serves every
127
+ # session. What a preset chooses is whether its agent can call the goal tool.
128
+ - id: tool-goal
129
+ name: '@deepseek-ai/dsh-tool-goal'
130
+
131
+ # ── plan mode ───────────────────────────────────────────────────────────────
132
+
133
+ # Plan state is per-agent by nature, so an entry-local realm is not a
134
+ # workaround here — it is the correct lifetime.
135
+ - id: planning
136
+ name: cordis:group
137
+ group: true
138
+ isolate:
139
+ planMode: true
140
+ config:
141
+ - id: plan-mode
142
+ name: '@deepseek-ai/dsh-plan-mode'
143
+ config:
144
+ section: |
145
+ 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.
146
+
147
+ 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.
148
+
149
+ 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.
150
+
151
+ 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.
152
+
153
+ 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.
154
+
155
+ 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.
156
+
157
+ # ── compaction ──────────────────────────────────────────────────────────────
158
+
159
+ # `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
160
+ # share this realm rather than sit outside it.
161
+ #
162
+ # `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
163
+ # plane, and the rows here resolve that one instance. It takes no configuration,
164
+ # keys every fold by Session, and owns the context-meter projection units the
165
+ # browser reads for every session — behind a realm those units would come and go
166
+ # with whichever presets happen to be mounted. What a preset chooses is whether
167
+ # its agent compacts at all, which is `compaction-basic` below.
168
+ - id: compaction
169
+ name: cordis:group
170
+ group: true
171
+ isolate:
172
+ compaction: true
173
+ toolResultPruner: true
174
+ config:
175
+ - id: compaction-basic
176
+ name: '@deepseek-ai/dsh-compaction-basic'
177
+
178
+ - id: command-compact
179
+ name: '@deepseek-ai/dsh-command-compact'
180
+
181
+ - id: tool-result-pruner
182
+ name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
183
+ config:
184
+ thresholdChars: 8192
185
+ headChars: 4096
186
+ tailChars: 1024
187
+
188
+ # ── delegation and workflows ────────────────────────────────────────────────
189
+
190
+ # The `subagents` registry and its spawn/fork backends live in the HOST
191
+ # composition: the registry is a process singleton whose cross-session queries
192
+ # the api-proxy serves to the browser, and a provider name may only be
193
+ # registered once. This preset contributes the delegation TOOLS, which resolve
194
+ # that host registry.
195
+ #
196
+ # `workflows` is different — nothing outside an agent reads it — so every row
197
+ # that reaches it shares one entry-local realm here, and a consumer left
198
+ # outside would resolve a host registry this preset does not populate.
199
+ #
200
+ # `tool-subagent-report` is host-plane for the same reason as the registry,
201
+ # not because a preset may not want it: it registers a CONTINUABLE SETUP on
202
+ # that singleton rather than a tool this agent calls, and the setup list is
203
+ # not scope-aware — one copy per mounted preset means every child gets
204
+ # `report` registered once per live session, which throws on the second.
205
+ - id: delegation
206
+ name: cordis:group
207
+ group: true
208
+ isolate:
209
+ workflowEngine: true
210
+ config:
211
+ - id: tool-subagent-control
212
+ name: '@deepseek-ai/dsh-tool-subagent-control'
213
+
214
+ - id: tool-subagent-list-agents
215
+ name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
216
+
217
+ - id: tool-subagent
218
+ name: '@deepseek-ai/dsh-tool-subagent'
219
+ config:
220
+ provider: spawn
221
+ toolName: subagent
222
+ backgroundMode: continuable
223
+
224
+ - id: tool-subagent-fork
225
+ name: '@deepseek-ai/dsh-tool-subagent'
226
+ config:
227
+ provider: fork
228
+ toolName: subagent_fork
229
+ backgroundMode: continuable
230
+
231
+ # Product providers are host-plane singletons. Copy this preset, then
232
+ # remove `disabled` from either ordinary tool row to expose that product
233
+ # only to agents composed from the copy.
234
+ - id: tool-subagent-codex
235
+ name: '@deepseek-ai/dsh-tool-subagent'
236
+ disabled: true
237
+ config:
238
+ provider: codex
239
+ toolName: subagent_codex
240
+ enableRunInBackground: false
241
+ maxDepth: provider-managed
242
+
243
+ - id: tool-subagent-claude-code
244
+ name: '@deepseek-ai/dsh-tool-subagent'
245
+ disabled: true
246
+ config:
247
+ provider: claude-code
248
+ toolName: subagent_claude_code
249
+ enableRunInBackground: false
250
+ maxDepth: provider-managed
251
+
252
+ - id: workflow-worker-thread
253
+ name: '@deepseek-ai/dsh-workflow-worker-thread'
254
+ config:
255
+ provider: spawn
256
+
257
+ - id: tool-workflow
258
+ name: '@deepseek-ai/dsh-tool-workflow'
259
+
260
+ - id: tool-ralph
261
+ name: '@deepseek-ai/dsh-tool-ralph'
262
+ config:
263
+ subagentProvider: spawn
264
+ maxRounds: 64
265
+
266
+ # ── remaining model-facing rows ─────────────────────────────────────────────
267
+
268
+ - id: tool-ask-user
269
+ name: '@deepseek-ai/dsh-tool-ask-user'
270
+
271
+ - id: tool-todo
272
+ name: '@deepseek-ai/dsh-tool-todo'
273
+ config:
274
+ allowParallelInProgress: true
275
+
276
+ # The `web` service and its search provider stay in the host composition; only
277
+ # the model-facing tool is per-session.
278
+ - id: tool-web
279
+ name: '@deepseek-ai/dsh-tool-web'
280
+ config:
281
+ fetch: false
282
+ searchTimeoutMs: 60000
@@ -0,0 +1,3 @@
1
+ name: Recursive 模式
2
+ description: recursive-mode 工作流代理:在会话的当前工作区内运行递归工作流(Phase A: status/spec/worktree/init/lock/qa/closeout/addendum/review/scratch + 全局 bootstrap/list/help)。
3
+ order: 5