better-dsh 0.2.3-e → 0.2.3-g

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 (270) hide show
  1. package/docs/50_test-reports/2026-09-13-preact-ui-shell/345/256/236/346/265/213/346/212/245/345/221/212.md +1 -1
  2. package/docs/50_test-reports/2026-09-14-4999-skill/346/270/205/345/215/225/344/270/216lsp-gate/345/256/236/346/265/213/346/212/245/345/221/212.md +54 -0
  3. package/docs/specs/agent/spec.md +54 -0
  4. package/docs/specs/ast/spec.md +34 -0
  5. package/docs/specs/compaction-recall/spec.md +46 -0
  6. package/docs/specs/ctx/spec.md +107 -0
  7. package/docs/specs/dsh/spec.md +47 -0
  8. package/docs/specs/dvc/spec.md +87 -0
  9. package/docs/specs/escalation-guidance/spec.md +44 -0
  10. package/docs/specs/fs-scheme-resolution/spec.md +37 -0
  11. package/docs/specs/hash-edit/spec.md +41 -0
  12. package/docs/specs/http-read/spec.md +73 -0
  13. package/docs/specs/kernel-provisioning/spec.md +53 -0
  14. package/docs/specs/lsp/spec.md +121 -0
  15. package/docs/specs/mobile-layout/spec.md +108 -0
  16. package/docs/specs/model-failover/spec.md +20 -0
  17. package/docs/specs/preact-ui-shell/spec.md +22 -0
  18. package/docs/specs/repl-dispatch-resilience/spec.md +21 -0
  19. package/docs/specs/skill/spec.md +58 -0
  20. package/docs/specs/tool-surface/spec.md +222 -0
  21. package/docs/specs/url-schema/spec.md +148 -0
  22. package/docs/specs/web-trust-fence/spec.md +43 -0
  23. package/dsh-docs/AGENTS.md +75 -0
  24. package/dsh-docs/agent-lifecycle.md +84 -0
  25. package/dsh-docs/agent-lifecycle.zh.md +86 -0
  26. package/dsh-docs/api-gateway.md +164 -0
  27. package/dsh-docs/api-gateway.zh.md +164 -0
  28. package/dsh-docs/architecture.md +150 -0
  29. package/dsh-docs/architecture.zh.md +154 -0
  30. package/dsh-docs/capability-seams.md +543 -0
  31. package/dsh-docs/capability-seams.zh.md +545 -0
  32. package/dsh-docs/config-catalog.md +3473 -0
  33. package/dsh-docs/config-catalog.zh.md +3474 -0
  34. package/dsh-docs/cookbook/adding-a-package.md +117 -0
  35. package/dsh-docs/cookbook/adding-a-package.zh.md +119 -0
  36. package/dsh-docs/cookbook/adding-a-remote-api.md +197 -0
  37. package/dsh-docs/cookbook/adding-a-remote-api.zh.md +197 -0
  38. package/dsh-docs/cookbook/adding-a-settings-card.md +102 -0
  39. package/dsh-docs/cookbook/adding-a-settings-card.zh.md +102 -0
  40. package/dsh-docs/cookbook/adding-a-tool.md +101 -0
  41. package/dsh-docs/cookbook/adding-a-tool.zh.md +103 -0
  42. package/dsh-docs/cookbook/adding-a-vendored-package.md +59 -0
  43. package/dsh-docs/cookbook/adding-a-vendored-package.zh.md +59 -0
  44. package/dsh-docs/cookbook/adding-an-llm-adapter.md +43 -0
  45. package/dsh-docs/cookbook/adding-an-llm-adapter.zh.md +43 -0
  46. package/dsh-docs/cookbook/extension-cookbook.md +132 -0
  47. package/dsh-docs/cookbook/extension-cookbook.zh.md +136 -0
  48. package/dsh-docs/cookbook/maintaining-dsh-code-review.md +64 -0
  49. package/dsh-docs/cookbook/maintaining-dsh-code-review.zh.md +64 -0
  50. package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.md +32 -0
  51. package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.zh.md +32 -0
  52. package/dsh-docs/cordis-api/context.md +364 -0
  53. package/dsh-docs/cordis-api/context.zh.md +366 -0
  54. package/dsh-docs/cordis-api/events.md +207 -0
  55. package/dsh-docs/cordis-api/events.zh.md +209 -0
  56. package/dsh-docs/cordis-api/fiber.md +375 -0
  57. package/dsh-docs/cordis-api/fiber.zh.md +377 -0
  58. package/dsh-docs/cordis-api/inherited.md +39 -0
  59. package/dsh-docs/cordis-api/registry.md +152 -0
  60. package/dsh-docs/cordis-api/registry.zh.md +154 -0
  61. package/dsh-docs/cordis-api/service.md +102 -0
  62. package/dsh-docs/cordis-api/service.zh.md +104 -0
  63. package/dsh-docs/cordis-primer.md +45 -0
  64. package/dsh-docs/cordis-primer.zh.md +51 -0
  65. package/dsh-docs/cordis-tutorial/01-first-plugin.md +95 -0
  66. package/dsh-docs/cordis-tutorial/01-first-plugin.zh.md +95 -0
  67. package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
  68. package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.zh.md +98 -0
  69. package/dsh-docs/cordis-tutorial/03-services.md +98 -0
  70. package/dsh-docs/cordis-tutorial/03-services.zh.md +98 -0
  71. package/dsh-docs/cordis-tutorial/04-events.md +144 -0
  72. package/dsh-docs/cordis-tutorial/04-events.zh.md +144 -0
  73. package/dsh-docs/cordis-tutorial/05-config.md +84 -0
  74. package/dsh-docs/cordis-tutorial/05-config.zh.md +84 -0
  75. package/dsh-docs/cordis-tutorial/06-composition-and-hmr.md +113 -0
  76. package/dsh-docs/cordis-tutorial/06-composition-and-hmr.zh.md +113 -0
  77. package/dsh-docs/cordis-tutorial/07-into-the-harness.md +108 -0
  78. package/dsh-docs/cordis-tutorial/07-into-the-harness.zh.md +108 -0
  79. package/dsh-docs/cordis-tutorial/index.md +60 -0
  80. package/dsh-docs/cordis-tutorial/index.zh.md +62 -0
  81. package/dsh-docs/deepseek-llm-api-wire-extensions.md +163 -0
  82. package/dsh-docs/deepseek-llm-api-wire-extensions.zh.md +163 -0
  83. package/dsh-docs/defensive-patterns.md +33 -0
  84. package/dsh-docs/defensive-patterns.zh.md +35 -0
  85. package/dsh-docs/development.md +167 -0
  86. package/dsh-docs/development.zh.md +173 -0
  87. package/dsh-docs/event-producer-consumer.md +86 -0
  88. package/dsh-docs/event-producer-consumer.zh.md +88 -0
  89. package/dsh-docs/glossary.md +45 -0
  90. package/dsh-docs/glossary.zh.md +45 -0
  91. package/dsh-docs/graph-atlas.md +22 -0
  92. package/dsh-docs/graph-atlas.zh.md +24 -0
  93. package/dsh-docs/i18n/README.md +60 -0
  94. package/dsh-docs/i18n/README.zh.md +62 -0
  95. package/dsh-docs/i18n/style-samples.md +87 -0
  96. package/dsh-docs/i18n/terminology.md +214 -0
  97. package/dsh-docs/i18n/translation-prompt.md +263 -0
  98. package/dsh-docs/i18n/translation-rules.md +69 -0
  99. package/dsh-docs/i18n/translation-rules.zh.md +69 -0
  100. package/dsh-docs/module-graph.md +1411 -0
  101. package/dsh-docs/module-graph.zh.md +1413 -0
  102. package/dsh-docs/persistence-catalog.md +1075 -0
  103. package/dsh-docs/persistence-catalog.zh.md +1077 -0
  104. package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.md +113 -0
  105. package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.zh.md +113 -0
  106. package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.md +47 -0
  107. package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +47 -0
  108. package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.md +53 -0
  109. package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.zh.md +53 -0
  110. package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +55 -0
  111. package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +55 -0
  112. package/dsh-docs/postmortem/README.md +18 -0
  113. package/dsh-docs/postmortem/README.zh.md +18 -0
  114. package/dsh-docs/rescope.md +53 -0
  115. package/dsh-docs/rescope.zh.md +53 -0
  116. package/dsh-docs/subsystems/README.md +61 -0
  117. package/dsh-docs/subsystems/README.zh.md +61 -0
  118. package/dsh-docs/subsystems/agent-team.md +207 -0
  119. package/dsh-docs/subsystems/agent-team.zh.md +207 -0
  120. package/dsh-docs/subsystems/approval.md +170 -0
  121. package/dsh-docs/subsystems/approval.zh.md +170 -0
  122. package/dsh-docs/subsystems/attachment.md +351 -0
  123. package/dsh-docs/subsystems/attachment.zh.md +351 -0
  124. package/dsh-docs/subsystems/client-modules.md +168 -0
  125. package/dsh-docs/subsystems/client-modules.zh.md +168 -0
  126. package/dsh-docs/subsystems/code-runtime.md +195 -0
  127. package/dsh-docs/subsystems/code-runtime.zh.md +195 -0
  128. package/dsh-docs/subsystems/commands.md +219 -0
  129. package/dsh-docs/subsystems/commands.zh.md +219 -0
  130. package/dsh-docs/subsystems/compaction.md +238 -0
  131. package/dsh-docs/subsystems/compaction.zh.md +238 -0
  132. package/dsh-docs/subsystems/conversation.md +258 -0
  133. package/dsh-docs/subsystems/conversation.zh.md +258 -0
  134. package/dsh-docs/subsystems/core.md +1209 -0
  135. package/dsh-docs/subsystems/core.zh.md +1219 -0
  136. package/dsh-docs/subsystems/credentials.md +329 -0
  137. package/dsh-docs/subsystems/credentials.zh.md +329 -0
  138. package/dsh-docs/subsystems/extensions.md +382 -0
  139. package/dsh-docs/subsystems/extensions.zh.md +382 -0
  140. package/dsh-docs/subsystems/feedback.md +266 -0
  141. package/dsh-docs/subsystems/feedback.zh.md +266 -0
  142. package/dsh-docs/subsystems/filesystem.md +505 -0
  143. package/dsh-docs/subsystems/filesystem.zh.md +505 -0
  144. package/dsh-docs/subsystems/goal.md +277 -0
  145. package/dsh-docs/subsystems/goal.zh.md +277 -0
  146. package/dsh-docs/subsystems/invariants.md +88 -0
  147. package/dsh-docs/subsystems/invariants.zh.md +88 -0
  148. package/dsh-docs/subsystems/jobs.md +290 -0
  149. package/dsh-docs/subsystems/jobs.zh.md +290 -0
  150. package/dsh-docs/subsystems/llm-streaming.md +1080 -0
  151. package/dsh-docs/subsystems/llm-streaming.zh.md +1086 -0
  152. package/dsh-docs/subsystems/lsp.md +202 -0
  153. package/dsh-docs/subsystems/lsp.zh.md +202 -0
  154. package/dsh-docs/subsystems/permission-presets.md +131 -0
  155. package/dsh-docs/subsystems/permission-presets.zh.md +131 -0
  156. package/dsh-docs/subsystems/persistence.md +395 -0
  157. package/dsh-docs/subsystems/persistence.zh.md +395 -0
  158. package/dsh-docs/subsystems/plan.md +87 -0
  159. package/dsh-docs/subsystems/plan.zh.md +87 -0
  160. package/dsh-docs/subsystems/sandbox.md +220 -0
  161. package/dsh-docs/subsystems/sandbox.zh.md +220 -0
  162. package/dsh-docs/subsystems/schedule.md +192 -0
  163. package/dsh-docs/subsystems/schedule.zh.md +192 -0
  164. package/dsh-docs/subsystems/scope.md +59 -0
  165. package/dsh-docs/subsystems/scope.zh.md +59 -0
  166. package/dsh-docs/subsystems/session-projection.md +354 -0
  167. package/dsh-docs/subsystems/session-projection.zh.md +354 -0
  168. package/dsh-docs/subsystems/session-query.md +509 -0
  169. package/dsh-docs/subsystems/session-query.zh.md +509 -0
  170. package/dsh-docs/subsystems/session-reference.md +219 -0
  171. package/dsh-docs/subsystems/session-reference.zh.md +219 -0
  172. package/dsh-docs/subsystems/session-telemetry.md +194 -0
  173. package/dsh-docs/subsystems/session-telemetry.zh.md +194 -0
  174. package/dsh-docs/subsystems/session-title.md +204 -0
  175. package/dsh-docs/subsystems/session-title.zh.md +204 -0
  176. package/dsh-docs/subsystems/session.md +1155 -0
  177. package/dsh-docs/subsystems/session.zh.md +1159 -0
  178. package/dsh-docs/subsystems/settings.md +405 -0
  179. package/dsh-docs/subsystems/settings.zh.md +405 -0
  180. package/dsh-docs/subsystems/shell.md +303 -0
  181. package/dsh-docs/subsystems/shell.zh.md +303 -0
  182. package/dsh-docs/subsystems/skills.md +354 -0
  183. package/dsh-docs/subsystems/skills.zh.md +354 -0
  184. package/dsh-docs/subsystems/slots.md +175 -0
  185. package/dsh-docs/subsystems/slots.zh.md +175 -0
  186. package/dsh-docs/subsystems/spill.md +117 -0
  187. package/dsh-docs/subsystems/spill.zh.md +117 -0
  188. package/dsh-docs/subsystems/storage.md +260 -0
  189. package/dsh-docs/subsystems/storage.zh.md +260 -0
  190. package/dsh-docs/subsystems/subagent.md +766 -0
  191. package/dsh-docs/subsystems/subagent.zh.md +770 -0
  192. package/dsh-docs/subsystems/subprocess.md +324 -0
  193. package/dsh-docs/subsystems/subprocess.zh.md +324 -0
  194. package/dsh-docs/subsystems/system-prompt.md +220 -0
  195. package/dsh-docs/subsystems/system-prompt.zh.md +220 -0
  196. package/dsh-docs/subsystems/terminal.md +184 -0
  197. package/dsh-docs/subsystems/terminal.zh.md +184 -0
  198. package/dsh-docs/subsystems/todo.md +32 -0
  199. package/dsh-docs/subsystems/todo.zh.md +32 -0
  200. package/dsh-docs/subsystems/token-meter.md +105 -0
  201. package/dsh-docs/subsystems/token-meter.zh.md +105 -0
  202. package/dsh-docs/subsystems/tools.md +720 -0
  203. package/dsh-docs/subsystems/tools.zh.md +720 -0
  204. package/dsh-docs/subsystems/typert.md +343 -0
  205. package/dsh-docs/subsystems/typert.zh.md +343 -0
  206. package/dsh-docs/subsystems/user-questions.md +178 -0
  207. package/dsh-docs/subsystems/user-questions.zh.md +178 -0
  208. package/dsh-docs/subsystems/web-client.md +95 -0
  209. package/dsh-docs/subsystems/web-client.zh.md +95 -0
  210. package/dsh-docs/subsystems/web-server.md +154 -0
  211. package/dsh-docs/subsystems/web-server.zh.md +154 -0
  212. package/dsh-docs/subsystems/web.md +206 -0
  213. package/dsh-docs/subsystems/web.zh.md +206 -0
  214. package/dsh-docs/subsystems/webhook.md +70 -0
  215. package/dsh-docs/subsystems/webhook.zh.md +70 -0
  216. package/dsh-docs/subsystems/workflow.md +278 -0
  217. package/dsh-docs/subsystems/workflow.zh.md +278 -0
  218. package/dsh-docs/subsystems/workspace.md +321 -0
  219. package/dsh-docs/subsystems/workspace.zh.md +321 -0
  220. package/dsh-docs/testing.md +54 -0
  221. package/dsh-docs/testing.zh.md +54 -0
  222. package/dsh-docs/tool-catalog.md +2225 -0
  223. package/dsh-docs/tool-catalog.zh.md +2233 -0
  224. package/dsh-docs/tool-execution-pipeline.md +62 -0
  225. package/dsh-docs/tool-execution-pipeline.zh.md +64 -0
  226. package/dsh-docs/user/develop/basic/config.md +106 -0
  227. package/dsh-docs/user/develop/basic/config.zh.md +106 -0
  228. package/dsh-docs/user/develop/basic/index.md +144 -0
  229. package/dsh-docs/user/develop/basic/index.zh.md +144 -0
  230. package/dsh-docs/user/develop/basic/publish.md +183 -0
  231. package/dsh-docs/user/develop/basic/publish.zh.md +183 -0
  232. package/dsh-docs/user/develop/basic/tool.md +52 -0
  233. package/dsh-docs/user/develop/basic/tool.zh.md +52 -0
  234. package/dsh-docs/user/develop/framework/events.md +143 -0
  235. package/dsh-docs/user/develop/framework/events.zh.md +143 -0
  236. package/dsh-docs/user/develop/framework/index.md +137 -0
  237. package/dsh-docs/user/develop/framework/index.zh.md +137 -0
  238. package/dsh-docs/user/develop/framework/service.md +148 -0
  239. package/dsh-docs/user/develop/framework/service.zh.md +150 -0
  240. package/dsh-docs/user/develop/practice/dynamic-cordis.md +15 -0
  241. package/dsh-docs/user/develop/practice/dynamic-cordis.zh.md +15 -0
  242. package/dsh-docs/user/develop/practice/index.md +155 -0
  243. package/dsh-docs/user/develop/practice/index.zh.md +155 -0
  244. package/dsh-docs/user/develop/practice/llm-adapter.md +189 -0
  245. package/dsh-docs/user/develop/practice/llm-adapter.zh.md +189 -0
  246. package/dsh-docs/user/guide/github-review.md +102 -0
  247. package/dsh-docs/user/guide/github-review.zh.md +102 -0
  248. package/dsh-docs/user/guide/index.md +30 -0
  249. package/dsh-docs/user/guide/index.zh.md +30 -0
  250. package/dsh-docs/user/guide/mcp-memory.md +101 -0
  251. package/dsh-docs/user/guide/mcp-memory.zh.md +101 -0
  252. package/dsh-docs/user/guide/network-proxy.md +85 -0
  253. package/dsh-docs/user/guide/network-proxy.zh.md +85 -0
  254. package/dsh-docs/user/guide/providers.md +190 -0
  255. package/dsh-docs/user/guide/providers.zh.md +190 -0
  256. package/dsh-docs/user/guide/python-sdk.md +150 -0
  257. package/dsh-docs/user/guide/python-sdk.zh.md +150 -0
  258. package/dsh-docs/user/guide/schedule.md +21 -0
  259. package/dsh-docs/user/guide/schedule.zh.md +21 -0
  260. package/dsh-docs/user/index.md +11 -0
  261. package/dsh-docs/user/index.zh.md +11 -0
  262. package/dsh-docs/web-styling.md +29 -0
  263. package/dsh-docs/web-styling.zh.md +29 -0
  264. package/lib/client/index.js +268 -38
  265. package/lib/fs-aware/sandbox-plugin.js +1 -1
  266. package/lib/index.js +1112 -1261
  267. package/lib/lsp-server-registry-B8DNonhS.js +3 -0
  268. package/lib/lsp-server-registry-BexQagaK.js +943 -0
  269. package/lib/{wrap-DC8O3SYz.js → wrap-JFjcWwZf.js} +42 -16
  270. package/package.json +2 -1
@@ -0,0 +1,222 @@
1
+ # tool-surface Specification
2
+
3
+ ## Purpose
4
+ DASHR 的模型表面(model surface)契约:哪些工具出现在 registry 投影(LLM-client 协议 tools 数组、REPL 绑定)里。核心原则——掩码作用于 tool registry(被替代了呈现面的原生工具全部 visible=false);REPL 绑定对 registry 可见集做机械/透明的自动桥接(零名单维护);被掩工具的能力保留靠三桥 service 层直调(`agent` spawn/fork、`agent_message` 消息+中断、`agent_workflow` 编排),不靠 registry 豁免。全部 REPL 指引(cell 语义、调用形、非 flat 名例外、`subagent` 别名注记)只经由 `eval` 工具的 wire description 承载——system prompt 中不存在任何 DASHR 渲染的工具目录或 control-prompt section。
5
+
6
+ ## Requirements
7
+
8
+ ### Requirement: Registry masking of replaced-presentation native tools
9
+
10
+ The system SHALL remove the native tools whose presentation surface DASHR replaces(`skill`、上游 `send_message`、`report`、`list_agents`、delegation 家族 `subagent_fork`/`interrupt_agent`/`workflow`/`ralph`)from the agent's tool registry projection via an agent-scope registry restriction —— wire tools array 与 REPL bindings 同源于该 projection,移除因此均匀生效。`subagent` is deliberately NOT masked:它在每个表面保持可见,且 **`eval` 工具的 description** 注记它是 `agent` delegation tool(统一 agent-spawn 入口)的别名。The restriction MUST NOT touch the registered tool definitions themselves;DASHR preserves each masked tool's native capability at the tool-bridge level(not by registry exemption):`agent` spawns/forks subagents、`agent_message` 经 host-plane service 层传递 child-downlink/parent-uplink/interrupt、`agent_workflow` 把 script/rfc 透传给 CAPTURED native workflow/ralph definitions(workflowEngine service 是 preset delegation realm 的 entry-local 服务,任何外部 ctx 不可见——native execute closures 从内部解析);`agent://` 取代 `list_agents`、`read skill://` 取代 `skill`。
11
+
12
+ #### Scenario: Masked tool absent from every model-facing surface
13
+
14
+ - **WHEN** an agent session starts under DASHR
15
+ - **THEN** the wire tools array 与 the REPL bindings 均不含 masked 名,对 masked 名的调用返回 `UNKNOWN_TOOL`
16
+
17
+ #### Scenario: subagent stays visible as an annotated alias
18
+
19
+ - **WHEN** an agent session starts under DASHR
20
+ - **THEN** `subagent` remains present on the wire tools array 与 the REPL bindings,且 `eval` 工具 description 注明它是 `agent` delegation tool 的别名
21
+
22
+ #### Scenario: Masked capability preserved through the bridge
23
+
24
+ - **WHEN** the model sends a child-downlink, parent-uplink, or interrupt through the `agent_message` bridge
25
+ - **THEN** the service layer executes it with native delivery semantics (user-role next-turn delivery, `messageId` confirmation) and native authorization (direct-child-only lineage, ancestor authority for interrupt)
26
+
27
+ #### Scenario: DASHR's own wrappers unaffected
28
+
29
+ - **WHEN** the agent-scope restriction denies a native name that a DASHR wrapper shadows on the agent's own layer
30
+ - **THEN** the wrapper (`read`/`write`/`grep`/`glob`, `agent`/`agent_message`/`agent_workflow`) remains visible and callable on every surface
31
+
32
+ ### Requirement: Delegation bridges are registry tools
33
+
34
+ The system SHALL register the delegation bridges(`agent`、`agent_message`、`agent_workflow`)as real tools in the tool registry(与 `eval` transport 同一 host registration 层),runtime argument validation inside their execute、structured `{ error }` return values(bad input 不抛异常)。Registry projection 是**两个**模型表面的 single source:wire tools array 与 REPL `tool.*` bindings(经 mechanical auto-bridge)。两个表面 SHALL 每个 session name-by-name 相等(以 mechanical binding rule 的 flat-name 限定为界);唯一允许的例外是 `eval` 本身排除在 binding set 之外(self-call prevention)。
35
+
36
+ #### Scenario: Bridge callable directly on the wire
37
+
38
+ - **WHEN** the model sends a direct tool call `agent` with `{ description, prompt }` (no cell)
39
+ - **THEN** the call dispatches through the normal kernel pipeline and returns the same result shape the REPL binding returns, with the same audit events as any registry tool
40
+
41
+ #### Scenario: Three-surface name equality
42
+
43
+ - **WHEN** a DASHR session starts
44
+ - **THEN** 目录表面已随「Catalog section presents REPL bridge instructions」的 REMOVED 撤销,原三表面等式收敛为两表面:the wire tools array 与 the REPL binding names 在 flat-name 规则内 equal as sets,excepting only `eval`
45
+
46
+ #### Scenario: No dual-source drift
47
+
48
+ - **WHEN** a bridge's parameter surface changes
49
+ - **THEN** the wire schema 与 REPL binding 一起变化,因为两者都派生自同一注册 schema
50
+
51
+ ### Requirement: eval transport description matches runtime semantics
52
+
53
+ The system SHALL state the eval transport's top-level semantics truthfully in **the `eval` tool's model-facing description(唯一的 REPL 指引载体)**:top-level `await` works —— kernel 以 `PyCF_ALLOW_TOP_LEVEL_AWAIT` 编译 cell 并运行 module coroutine;top-level `return` is a SyntaxError(cell 运行于 module scope,globals = locals)。The description SHALL NOT claim top-level `return` is accepted.
54
+
55
+ #### Scenario: Description promises only what the kernel does
56
+
57
+ - **WHEN** the model reads the `eval` tool description
58
+ - **THEN** the text states that top-level `await` works,states that top-level `return` is a SyntaxError(module-scope cell),and contains no claim that top-level `return` is accepted
59
+
60
+ #### Scenario: Top-level return stays rejected
61
+
62
+ - **WHEN** a cell contains a top-level `return`
63
+ - **THEN** the kernel rejects it with a SyntaxError, matching the description
64
+
65
+ ### Requirement: eval description is the single REPL guidance source
66
+
67
+ The system SHALL carry ALL REPL guidance in the `eval` tool's wire description —— cell 语义、直调 vs 进 cell 的判据、非 flat 名例外、`subagent` 别名注记、**置于 description 末尾**的 mechanical bridge 调用形 —— 内容从**插件源码中的 Markdown 文件**加载、注册工具时作为 `description` 生效;system prompt 中 SHALL NOT 存在任何 DASHR 渲染的工具目录或 control-prompt section。桥接指引 SHALL 只陈述**一个**统一调用形、一句话说清:`await tool.<name>(argsObject)`,argsObject = 该工具 wire JSON-Schema 参数对象写成的 Python dict 字面量(同字段名、单个位置参数、不用 kwargs),唯一系统性语法差异为 `true`/`false`/`null` → `True`/`False`/`None`;SHALL NOT 渲染 per-tool 签名表,且 SHALL NOT 对桥接调用的返回值形态作任何陈述(不写"不保证形状/需试错"类措辞)。描述中的桥接示例 SHALL 使用与被引工具 wire schema 一致的参数名。
68
+
69
+ #### Scenario: System prompt carries no DASHR catalog or control section
70
+
71
+ - **WHEN** an agent session renders its system prompt
72
+ - **THEN** 没有 DASHR 来源的 section 枚举 per-tool 签名,也没有独立的 control-prompt section 教 cell 范式;全部 REPL 指引只经由 `eval` description 到达模型
73
+
74
+ #### Scenario: Description loads from the source Markdown
75
+
76
+ - **WHEN** the plugin registers the `eval` tool
77
+ - **THEN** 其 wire description 等于包内 Markdown 指引文件的内容——编辑该文件即改变模型可见的 description
78
+
79
+ #### Scenario: One bridge call form, one syntax delta
80
+
81
+ - **WHEN** the model reads the bridge instructions in the `eval` description
82
+ - **THEN** it sees the single positional-args-object call form 与 `True`/`False`/`None` 大小写映射,and no per-tool signature table or output-shape caveat(无任何"不保证形态/试错"措辞)
83
+
84
+ #### Scenario: Examples match wire parameter names
85
+
86
+ - **WHEN** the description shows a bridge example for `read`
87
+ - **THEN** 参数键与 `read` 的 wire schema 一致(如 `path`),而非其它工具的键名
88
+
89
+ #### Scenario: Guidance lives and dies with the tool
90
+
91
+ - **WHEN** a session's scope excludes the `eval` tool
92
+ - **THEN** 任何地方都不渲染 REPL 指引(指引即工具自身的 description);`eval` 在场时指引必然在场
93
+
94
+ #### Scenario: Alias annotation present
95
+
96
+ - **WHEN** the model reads the `eval` description
97
+ - **THEN** it states that `subagent` is an alias of the `agent` delegation tool,两者经同一 runtime delegate
98
+
99
+ #### Scenario: Non-flat exception present
100
+
101
+ - **WHEN** the model reads the `eval` description
102
+ - **THEN** it states that 含非标识符字符(如连字符)的工具名没有 `tool.<name>` member,必须以 direct tool call 调用
103
+
104
+ ### Requirement: Masking failures surface loudly
105
+
106
+ The system SHALL surface a structured error, not a silent skip, when restricting any masked tool name fails at session start;application 完成后 mask SHALL verify 每个 masked 名在 **the wire tools array 与 the REPL bindings** 中均不存在。
107
+
108
+ #### Scenario: A masked name's restriction errors and the session reports it
109
+
110
+ - **WHEN** applying the mask, a single masked name's registry restriction throws
111
+ - **THEN** the session surfaces the failure as a structured error naming the masked tool, and the name does not silently remain on any model-facing surface
112
+
113
+ #### Scenario: Masked names absent after successful application
114
+
115
+ - **WHEN** an agent session starts under DASHR with a healthy registry
116
+ - **THEN** the wire tools array 与 the REPL bindings contain none of the masked names(`skill`、`send_message`、`report`、`list_agents`、`subagent_fork`、`interrupt_agent`、`workflow`、`ralph`),and a call naming a masked tool returns `UNKNOWN_TOOL`
117
+
118
+ ### Requirement: REPL bindings bridge the visible registry mechanically
119
+ The system SHALL install REPL bindings by automatic, transparent conversion of every flat-bindable name in the registry's visible set at session start — no manual allowlist or denylist; masked names are naturally absent because the binding source and the masking act on the same projection. Non-flat names SHALL be skipped — a name is non-flat when it contains characters outside `[A-Za-z0-9_]` (e.g. hyphens); a `__` infix alone is a legal identifier and does not by itself make a name non-flat — and the bridge instructions SHALL state the name-shape limitation without enumerating affected tools.
120
+
121
+ #### Scenario: A newly registered host tool appears in the REPL without list edits
122
+ - **WHEN** the host registers a new flat-named tool after a DASHR upgrade
123
+ - **THEN** the next agent session exposes it as `tool.<name>` with no DASHR source change
124
+
125
+ #### Scenario: Non-flat MCP names documented, not listed
126
+ - **WHEN** an MCP tool named `mcp__server__tool-name` is registered
127
+ - **THEN** no binding is created for it, and the bridge instructions explain the name-shape limitation
128
+
129
+ #### Scenario: Double-underscore infix alone stays bindable
130
+ - **WHEN** a tool named `mcp__server__tool` (identifier characters only, no hyphen) is registered
131
+ - **THEN** the name is flat-bindable (`'mcp__server__tool'.isidentifier()` is true) and appears as `tool.<name>` unless separately masked
132
+
133
+ ### Requirement: llm_completion tool
134
+ The system SHALL provide an `llm_completion` tool: a one-shot, stateless LLM call — no tools, no conversation history, no agent creation. Inputs: `{ prompt, system?, maxTokens? }`; output: the model's text. The call SHALL be attributed to the calling agent's session through the normal tool-call audit (the host's auxiliary-purpose enum is closed and carries no completion class), SHALL honor the caller's abort signal, and SHALL resolve its model route from the calling agent's current model selection, and SHALL answer a structured error value — never a silent fallback route — when no selection is available. A finish other than a clean stop, or any tool-call block in the output, SHALL produce a structured error value, not a thrown exception.
135
+
136
+ #### Scenario: Zero-spawn judge step inside a cell
137
+ - **WHEN** a cell calls `await tool.llm_completion({ prompt: "<judge prompt>", system: "<rubric>" })`
138
+ - **THEN** the value returned is the model's text; no subagent is spawned, no session besides the caller's is created, and the call is auditable under its own purpose
139
+
140
+ #### Scenario: Model route follows the caller
141
+ - **WHEN** the calling agent's selected model differs from the host default
142
+ - **THEN** the completion runs on the caller's selection
143
+
144
+ #### Scenario: Degraded finish is a structured error
145
+ - **WHEN** the completion hits maxTokens or aborts
146
+ - **THEN** the tool returns `{ error: <description> }` rather than throwing
147
+
148
+ ### Requirement: REPL tool namespace introspection
149
+ The system SHALL make the REPL `tool` namespace introspectable: `dir(tool)` returns the sorted list of bound tool names — exactly the names callable as `tool.<name>(argsObject)`. The underlying injected mapping (e.g. `__dashr_injected__`) remains unchanged for compatibility; `dir()` is the documented introspection surface.
150
+
151
+ #### Scenario: dir(tool) lists the binding set
152
+ - **WHEN** a cell runs `dir(tool)`
153
+ - **THEN** the returned list equals the sorted set of names bound in the `tool` namespace for that run (dunder members aside), including the delegation bridges and `llm_completion`
154
+
155
+ ### Requirement: Hashline edit family registered on the agent's own layer
156
+
157
+ The system SHALL register the vendored hashline edit family on each agent's own scope layer at session start — `edit` (hash-anchored ordered edit tuples, shadowing the preset's built-in edit by nearest-layer resolution, no mask entry needed) and `undo_last_edit` (revert of the most recent hashline edit) — alongside the URL-aware read/write/grep/glob wrappers, unwinding with the agent. The write tool SHALL remain the upstream full-file write with its native confirmation envelope: no hook SHALL append a hashline preview to write results, and the hashline guidance SHALL NOT promise post-write anchors (the model MAY edit directly using anchors derived from the content it just wrote, or read first). The hashline guidance sections SHALL shadow the preset's built-in tool guidance on the same layer (compiled defaults when no agentPresets service or a failing override — never a failed install).
158
+
159
+ #### Scenario: A hash-anchored edit lands and is reversible
160
+
161
+ - **WHEN** the model calls `edit` with anchored edit tuples on a file whose current content matches the anchors
162
+ - **THEN** the edit applies atomically (drift-checked against current content), and a subsequent `undo_last_edit` reverts it
163
+
164
+ #### Scenario: A write result stays upstream-native
165
+
166
+ - **WHEN** the model calls `write` and it succeeds
167
+ - **THEN** the result content is the upstream confirmation envelope with no auto-read/anchor section appended, and no read is required before the next anchored `edit` on that file
168
+
169
+ #### Scenario: The shadow replaces the built-in edit without masking
170
+
171
+ - **WHEN** an agent session starts under DASHR
172
+ - **THEN** the `edit` the model sees is the hashline tool (own-layer shadow), the preset's built-in edit is unreachable for that agent, and no deny-list entry names `edit`
173
+
174
+ ### Requirement: Lsp feedback rides edit results
175
+ The system SHALL attach the same write-feedback diagnostics contract to successful edits: after a landed `edit` with an explicit path, the result content carries the diagnostics summary computed from the exact landed content (didSave freshness, timeout degradation, span guard — the `dvc` write-feedback requirement's terms apply verbatim). Anchor-only edits (path inferred from anchors) and non-edit tools pass through untouched; the write tool's feedback stays with its wrapper (no double pull).
176
+
177
+ #### Scenario: An edit that introduces a type error reports it
178
+ - **WHEN** an edit lands content introducing a type error in a file with a language server and its check completes within the budget
179
+ - **THEN** the edit result text carries the diagnostics summary for the exact landed content
180
+
181
+ ### Requirement: Hashline edit verification is content-anchored
182
+
183
+ The system SHALL verify each edit tuple's anchors against the CURRENT file content before consulting any ledger: an anchor SHALL be accepted when its hash locates a unique, consistently pairable position in the current canonical line hashes; the served ledger SHALL be advisory (echo/undo attribution) and keyed by canonical absolute path with no session identity, so anchors survive session-tree forks and continuation without a re-read. Genuine drift SHALL still fail closed with nothing written, batch atomicity SHALL be unchanged, and a multi-tuple batch failure SHALL instruct reading the file once and resubmitting the whole batch.
184
+
185
+ #### Scenario: An edit across a forked session lands without a re-read
186
+
187
+ - **WHEN** a file is written or read in one session node, the conversation continues in a forked node (new session identity), and the model submits anchored edit tuples derived from that earlier content
188
+ - **THEN** the edit applies without any intervening `read`, because verification matched current content
189
+
190
+ #### Scenario: A drifted line still fails closed
191
+
192
+ - **WHEN** an anchor's hash no longer exists in the current file (content changed or line removed externally)
193
+ - **THEN** the tuple is rejected with a drift error stating the content changed and a read is needed, and nothing is written
194
+
195
+ #### Scenario: An ambiguous anchor falls back before failing
196
+
197
+ - **WHEN** an anchor's hash occurs at multiple current positions and the served ledger cannot disambiguate the span
198
+ - **THEN** the tuple is rejected with nothing written, and the error names the ambiguity
199
+
200
+ #### Scenario: Multi-tuple failure copy is actionable
201
+
202
+ - **WHEN** any tuple in a multi-tuple batch fails verification
203
+ - **THEN** the batch aborts with zero writes and the error instructs reading the file once, then resubmitting the whole batch
204
+
205
+ ### Requirement: Hashline store centralized under DSH_HOME
206
+
207
+ The hashline store SHALL live at a single location — `$DSH_HOME/storages/dsh-better-edit/hash-store.sqlite` — for tool calls, previews, and tests alike, resolved through the harness home resolver so `DSH_HOME` isolates deployments; no per-workspace dot-directory SHALL be created. The served table SHALL be keyed by canonical absolute path (no session column), the 7-day TTL prune SHALL be retained, and the store schema version SHALL bump with a rebuild-on-mismatch gate that drops and recreates legacy session-keyed served tables.
208
+
209
+ #### Scenario: No dot-directory is created
210
+
211
+ - **WHEN** hashline tools run inside any workspace
212
+ - **THEN** state lands in the centralized store and no `<workspace>/.dsh_better_edit/` directory is created
213
+
214
+ #### Scenario: DSH_HOME isolates deployments
215
+
216
+ - **WHEN** the harness runs with a test `DSH_HOME` (e.g. the 4999 line)
217
+ - **THEN** its hashline store is a separate file under that home and never touches the production store
218
+
219
+ #### Scenario: Legacy session-keyed served tables rebuild
220
+
221
+ - **WHEN** the store opens with a schema version below the current one, or a served table still carrying a `session_id` column
222
+ - **THEN** the served table is dropped and recreated with the path-keyed schema, and the version marker is updated
@@ -0,0 +1,148 @@
1
+ # url-schema Specification
2
+
3
+ ## Purpose
4
+
5
+ Give DASHR one uniform URL resource-addressing layer: read/write/grep/glob accept `scheme://` URLs, route by scheme to a handler, apply one selector syntax uniformly, and keep non-URL behavior byte-identical to the native tools via delegation.
6
+
7
+ ## Requirements
8
+
9
+ ### Requirement: FS-shaped tools accept and route scheme URLs
10
+ The scheme registry SHALL be owned by the `dsh-url-schemes` cordis service (renamed from `dsh-url-schema`), which SHALL contain the `UrlResolver` and scheme handlers only (no tool registrations inside the service). The URL-aware read/write/grep/glob tools SHALL be tool-layer consumers. read SHALL accept `scheme://` URLs and resolve them end-to-end through the scheme registry; grep/glob SHALL translate or materialize the resource for the native search; write SHALL dispatch to a structured per-scheme write channel (all rejected this wave).
11
+
12
+ #### Scenario: Reading a registered scheme
13
+ - **WHEN** the model calls read with a registered scheme URL (e.g. `skill://foo`)
14
+ - **THEN** the system returns the handler-resolved content with the selector applied, not a filesystem read
15
+
16
+ #### Scenario: Reading an unregistered scheme
17
+ - **WHEN** the model calls read with a URL whose scheme has no registered handler (including `history://` — no special case exists)
18
+ - **THEN** the system returns the structured `URL_UNREGISTERED_SCHEME` error listing the registered schemes
19
+
20
+ #### Scenario: URL without a scheme prefix
21
+ - **WHEN** a resolver-layer caller passes a string without `scheme://`
22
+ - **THEN** the system returns the structured `URL_NO_SCHEME` error
23
+
24
+ ### Requirement: `dsh://docs` serves the vendored upstream official docs
25
+ `dsh://docs` SHALL serve the shipped upstream official harness documentation corpus (`dsh-docs/`, vendored from the `deepseek-ai/deepseek-harness` repo `docs/`), not the DASHR repository's working notes. Resolution order: explicit `docsDir` → packaged `dsh-docs/` → packaged `docs/` → repo-root `docs/` (walk-up probes `dsh-docs` before `docs` at every level).
26
+
27
+ #### Scenario: Docs index lists the official corpus
28
+ - **WHEN** the model reads `dsh://docs`
29
+ - **THEN** the index enumerates the upstream official docs tree (`agent-lifecycle.md`, `api-gateway.md`, `architecture.md`, …)
30
+
31
+ ### Requirement: Bare `skill://` lists the available skills
32
+ A bare `skill://` URL (no skill name) SHALL render the cwd-scoped skill catalog from the registry's `list` face — one line per winning summary (`skill://<name> — <description>`, plus `(use when: …)` when `whenToUse` is present) — using the same discovery rule as a name lookup. An empty catalog SHALL answer explicitly, never with an error.
33
+
34
+ #### Scenario: Bare skill list
35
+ - **WHEN** the model reads `skill://` with no skill name
36
+ - **THEN** the tool result contains the count header and per-skill lines, cwd-scoped exactly like `skill://<name>` resolution
37
+
38
+ #### Scenario: Empty catalog
39
+ - **WHEN** no skill is available in the workspace scope
40
+ - **THEN** the result reads "No skills available in this workspace scope." — not a `URL_SKILL_NOT_FOUND` error
41
+
42
+ ### Requirement: Delegation shells preserve native non-URL behavior
43
+ The system SHALL implement read/write/grep/glob as delegation shells over the definition registered under the same semantic name at capture time, captured once per agent via `ctx.tools.get(name, agent)` strictly before the wrappers register on the agent's own scope layer (`read` included — its captured delegate MAY be another feature's wrapper). Non-URL inputs SHALL be forwarded verbatim to `captured.execute(args, exec)`, preserving the native write-intent policy gate, sandbox resolution, ripgrep search semantics, and any outer-layer behavior already present. The shells SHALL honor per-feature config gates `Config = { urlSchemes?: boolean = true, hashline?: boolean = true }` from the patch-line `config:` block: with `urlSchemes: false`, scheme paths SHALL fall through to the captured definition (native failure semantics are honest); with `hashline: false`, file reads SHALL delegate without hashline anchoring.
44
+
45
+ #### Scenario: Ordinary write keeps the policy gate
46
+ - **WHEN** the model writes to an ordinary file path
47
+ - **THEN** the call runs through the captured native write definition — the write-intent policy gate, sandbox resolution, and observation events behave exactly as before the URL schema existed
48
+
49
+ #### Scenario: Ordinary grep/glob keep ripgrep semantics
50
+ - **WHEN** the model greps or globs over ordinary paths
51
+ - **THEN** the call delegates to the captured native definition with args untouched, returning native-shaped results
52
+
53
+ #### Scenario: Missing native delegate fails loudly
54
+ - **WHEN** a host did not deploy the native write/grep/glob and the corresponding wrapper is invoked on a non-URL input
55
+ - **THEN** the system returns the structured `NATIVE_WRITE_UNAVAILABLE` / `NATIVE_GREP_UNAVAILABLE` / `NATIVE_GLOB_UNAVAILABLE` error instead of reimplementing the tool
56
+
57
+ #### Scenario: Capture happens before registration
58
+ - **WHEN** an agent session starts and the URL-aware tools are installed
59
+ - **THEN** the definitions under `read`/`write`/`grep`/`glob` are captured strictly before any wrapper registers on that agent's scope layer, so the captured reference is the pre-existing tool rather than the wrapper (no self-recursion)
60
+
61
+ #### Scenario: URL capability disabled by gate
62
+ - **WHEN** the patch line sets `urlSchemes: false` and the model reads `ctx://session`
63
+ - **THEN** the wrapper delegates to the captured read definition and the native failure surfaces
64
+
65
+ ### Requirement: URL search reuses the native engine
66
+ The system SHALL run grep/glob over URL-addressed resources through the native search engine: path-backed schemes (a handler-implemented `resolvePath` mapping the URL to a real disk location — `skill://` today) have the URL translated to the disk path before delegating; content-backed schemes (agent, ctx, `dsh://config`, http, …) have the resolved text materialized into a fresh RAM-backed tempfs directory (`/dev/shm` when available and writable; falling back to the OS temp dir when unavailable or when a single materialization exceeds 8 MiB) which is removed afterwards whatever the outcome.
67
+
68
+ #### Scenario: Searching a path-backed resource
69
+ - **WHEN** the model greps a `skill://name` URL
70
+ - **THEN** the URL is translated to the skill's real disk path and only the search root is rewritten before the native grep runs
71
+
72
+ #### Scenario: Searching a content-backed resource
73
+ - **WHEN** the model greps a content-backed URL (e.g. `ctx://model`)
74
+ - **THEN** the resolved text is written into a fresh temp dir under `/dev/shm` (or the OS temp dir on fallback) as `content.txt`, the native grep searches it, and the temp dir is removed whether the search succeeds or fails
75
+
76
+ #### Scenario: Listing a URL resource
77
+ - **WHEN** the model calls glob with a URL in `pattern`
78
+ - **THEN** a path-backed scheme globs the resource's real disk directory natively, and a content-backed scheme returns the resolved text's non-empty lines as the listing without a native call
79
+
80
+ #### Scenario: Glob metacharacters in a URL pattern
81
+ - **WHEN** the glob pattern is a URL carrying glob metacharacters (e.g. `skill://grp/*`, `skill://grp/**/*.md`)
82
+ - **THEN** the pattern splits at the first metacharacter (`*?[`): the URL part resolves via `resolvePath` and the tail is the rooted glob pattern applied WITHIN the resource's real disk directory — the raw metachar-containing string is never handed to the native engine as a literal path
83
+
84
+ #### Scenario: Grep match paths report URL addressing
85
+ - **WHEN** a grep over a path-backed URL returns matches
86
+ - **THEN** match paths are rewritten back to the URL form (`skill://grp/SKILL.md`), both for absolute paths under the disk root and for native-relative paths — the model never sees internal disk locations
87
+
88
+ #### Scenario: Fallback to the OS temp dir
89
+ - **WHEN** `/dev/shm` is unavailable or the content exceeds 8 MiB
90
+ - **THEN** materialization falls back to the OS temp dir and the search still completes
91
+
92
+ ### Requirement: URL writes are rejected per scheme
93
+ The system SHALL reject every `scheme://` write with a scheme-specific structured error: `dvc://` → `DVC_NO_DEVICE` (no device mounted), `ctx://` → `URL_READ_ONLY` (curated read-only snapshot), any other registered scheme → `URL_WRITE_UNSUPPORTED`, unregistered scheme → `URL_UNREGISTERED_SCHEME`.
94
+
95
+ #### Scenario: Writing to a read-only scheme
96
+ - **WHEN** the model writes to `ctx://model`
97
+ - **THEN** the system returns the structured `URL_READ_ONLY` error explaining the scheme is a read-only snapshot
98
+
99
+ #### Scenario: Writing to the device placeholder
100
+ - **WHEN** the model writes to `dvc://<device>`
101
+ - **THEN** the system returns the structured `DVC_NO_DEVICE` error (no devices mounted to route the write to)
102
+
103
+ ### Requirement: Unified selector syntax
104
+ The system SHALL parse selectors once (`:N-M` comma-lists, `:raw`, `:path/…`, `?q=`) and apply them uniformly to every handler's full text after resolution. Handlers return full text with no default line truncation; only explicit selectors page. Malformed selectors return the structured `URL_BAD_SELECTOR` error.
105
+
106
+ #### Scenario: Scheme URL with a line range
107
+ - **WHEN** the model reads `skill://foo:50-100`
108
+ - **THEN** the system resolves the full skill body and returns lines 50–100, exactly as it would slice a plain file
109
+
110
+ #### Scenario: JSON path and query selectors
111
+ - **WHEN** the resolved text is JSON and the URL carries `:path/a.b` or `?q=a.b`
112
+ - **THEN** the system navigates the JSON by dot-path; for non-JSON text `?q=` keeps the lines containing the query string
113
+
114
+ ### Requirement: Read delegation shapes args to the delegate and coerces output
115
+ The URL-aware read wrapper SHALL accept both `path` and `file_path` (aliased); when delegating a non-scheme path it SHALL shape args to the delegate's DECLARED parameters (`file_path` for the host-native read, `path` for hashline; opaque schemas forwarded verbatim — no keys added an unknown validator might reject) and SHALL coerce a non-string delegate result to the wrapper's string output (JSON serialization), since the wrapper declares the string face for every branch.
116
+
117
+ #### Scenario: Host-native delegate receives file_path
118
+ - **WHEN** a file path is delegated to a delegate whose schema declares `file_path`
119
+ - **THEN** the delegate receives `file_path` (the `path` key removed) and its structured result is serialized into the wrapper's string output
120
+
121
+ #### Scenario: Hashline delegate receives path
122
+ - **WHEN** a file path is delegated to the hashline read (schema declares `path`)
123
+ - **THEN** the delegate receives `path` only and the anchored text returns verbatim
124
+
125
+ ### Requirement: read's file branch stays vendored hashline
126
+ The system SHALL keep the ordinary-file branch of read on the vendored hashline pipeline (HASH│content anchors plus the snapshot store the vendored edit tools depend on), reading through the sandboxed filesystem and the fs observation policy gate — read delegates to no native definition.
127
+
128
+ #### Scenario: Plain file read returns hashline anchors
129
+ - **WHEN** the model reads an ordinary file path
130
+ - **THEN** the system returns hashline-anchored lines via the vendored pipeline and records the observation with the fs policy gate, so follow-up edit calls see the version just read
131
+
132
+ ### Requirement: Read chassis with ordered transforms
133
+ The `read` tool registration SHALL be owned by a single chassis inside `dsh-url-schemes`: an ordered transform chain (URL transform, hashline anchor transform, …) with a terminal delegate to the captured read definition. Additional read-side features SHALL register transforms into the chassis rather than registering competing `read` definitions (same-layer same-name registration is a registry error); a read-interested feature SHALL fall back to its own minimal wrapper only when the chassis is absent.
134
+
135
+ #### Scenario: Transforms compose deterministically
136
+ - **WHEN** both the URL transform and the hashline anchor transform are registered and the model reads a filesystem path
137
+ - **THEN** the path flows URL transform (no match) → anchor transform (anchors applied) → captured native read
138
+
139
+ ### Requirement: General syntax guidance section
140
+ The service SHALL render a gated `url-schema:general` system-prompt section whose text is loaded once at module load from the package-root `url-schemes-instruction.md` (the owner-maintained instruction file; shipped via the package.json `files` array — an unlisted file is omitted from the published package and the module-load `readFileSync` fails plugin boot, the 0.2.3-d ENOENT lesson) (shipped via the package.json `files` array — an unlisted file is omitted from the published package and the module-load `readFileSync` fails plugin boot, the 0.2.3-d ENOENT lesson). The section is the SINGLE surfacing point of the URL scheme set to the model: the read/grep/glob/write tool descriptions SHALL carry NO `scheme://` mentions, so the model cannot believe only some tools accept URLs. The section text is the OWNER-MAINTAINED file rendered verbatim (2026-09-12 ruling: the file is hand-edited, not generated) and SHALL cover at minimum: the general URL grammar (`scheme://<path>[:selector]`); all six schemes (`skill://`, `agent://`, `dsh://`, `ctx://`, `dvc://`, `http(s)://`) with first-level resource coverage per scheme; the selector set including the composite `:raw:N-M` clause; and bulk-read guidance. The section renders only while the URL capability is enabled.
141
+
142
+ #### Scenario: Gated disclosure
143
+ - **WHEN** the URL capability is enabled and an agent session starts
144
+ - **THEN** the system prompt contains the section text loaded from `url-schemes-instruction.md` with the grammar, selector, and scheme coverage
145
+
146
+ #### Scenario: Tool descriptions stay scheme-silent
147
+ - **WHEN** the model inspects any read/grep/glob/write tool description on the wire
148
+ - **THEN** no description carries a `scheme://` mention — the `url-schema:general` section is the only place the scheme set is surfaced
@@ -0,0 +1,43 @@
1
+ # web-trust-fence Specification
2
+
3
+ ## Purpose
4
+ better-dsh 的 /api 信任栅栏随发契约(替代 prod 手改 patch):bundle patch 整行重述 `connection` 行,`trustedHosts` = `DSH_TRUSTED_HOSTS` env 条目 + 上游 webRuntime 权威拼接(env 缺省时行为与原装行等价、零侵入);host 半 boot script 的 isLoopback 腿——页面 origin 命中 `trustedPageAuthorities` 时置 `window.__DSH_TRANSPORT__ = { ownsHost: true }`(空列表不注入)。
5
+
6
+ ## Requirements
7
+
8
+ ### Requirement: Plugin-shipped fence authorities
9
+
10
+ The plugin's bundle patch layer SHALL override the `connection` loader row by id, restating the row's full shape, with `config.trustedHosts` computed as the concatenation of `DSH_TRUSTED_HOSTS` environment entries (whitespace-separated) and the upstream `webRuntime`-derived authorities; with the environment variable unset or empty the resulting composition SHALL be byte-equivalent in behavior to the unpatched upstream row (inert by default).
11
+
12
+ #### Scenario: Env-derived authority passes the fence
13
+
14
+ - **WHEN** the daemon runs with `DSH_TRUSTED_HOSTS=host.example` and a browser reaches `/api` with `Host: host.example` and same-origin markers
15
+ - **THEN** the request passes the Host/Origin trust fence (no 403 from the fence) and the Settings > Models provider directory loads from that authority
16
+
17
+ #### Scenario: Inert without the environment variable
18
+
19
+ - **WHEN** the daemon runs without `DSH_TRUSTED_HOSTS`
20
+ - **THEN** the fence accepts exactly the authorities the unpatched upstream composition would (loopback, LAN literals on all-interface binds, `--trusted-host` extras)
21
+
22
+ #### Scenario: Malformed entry fails loud at load
23
+
24
+ - **WHEN** `DSH_TRUSTED_HOSTS` contains an entry that is not a bare canonical `host[:port]` authority
25
+ - **THEN** plugin load fails loudly via the upstream `assertTrustedAuthority` validation instead of silently widening or narrowing the fence
26
+
27
+ ### Requirement: Upgrade-safe replacement of the hand patch
28
+
29
+ The plugin SHALL NOT require source-level edits to vendored `@deepseek-ai/*` files for fence behavior; the alpha.3 hand patch (`isLoopbackHostname` widening in `dsh-client-connection` index.js and client bundle) SHALL be retirable on alpha.5+ by this capability alone, and the row-override shape SHALL be tracked as an upstream-alignment checklist item (diff `packages/bundle/web-app/cordis.patch.yml`'s `connection` row each alignment round).
30
+
31
+ #### Scenario: Upstream row drift is detected at alignment time
32
+
33
+ - **WHEN** an upstream release changes the `connection` row's keys (name, inject, or config shape)
34
+ - **THEN** the alignment-round checklist surfaces the drift before the stale restated row ships
35
+
36
+ ### Requirement: User layer keeps precedence
37
+
38
+ A user's own profile or home `cordis.patch.yml` override of the `connection` row SHALL take precedence over the plugin's bundle layer, preserving the upstream layering contract.
39
+
40
+ #### Scenario: User override wins
41
+
42
+ - **WHEN** the user's profile patch restates the `connection` row
43
+ - **THEN** the user's row applies, not the plugin's
@@ -0,0 +1,75 @@
1
+ # AGENTS.md — The documentation standard
2
+
3
+ This file defines document structure, Markdown tiers, writing rules, and `verify-doc-budgets` ceilings. Use [dsh-doc](../.agents/skills/dsh-doc/SKILL.md) for placement and validation, and [dsh-prose-standard](../.agents/skills/dsh-prose-standard/SKILL.md) for required coverage and editorial judgment; the [doc-tiers Agent Note](../.agents/notes/implemented/process/2026-07-04-doc-tiers-and-budgets.md) owns rationale.
4
+
5
+ ## Document structure
6
+
7
+ These rules apply to human-facing documentation; [Agent Notes](../.agents/notes/README.md) remain outside their scope. A [postmortem](postmortem/README.md) is an incident-scoped reference; chronology records evidence, not a teaching sequence. A document's subject and tree position fix its scope: describe its own subject at appropriate detail and direct children only by purpose, responsibility, and high-level behavior; link to the owning descendant for lower-level detail. Document type does not widen that scope. A reference may be exhaustive only about its own subject. Testing mechanisms, fixtures, and harnesses belong at the lowest owning level; higher documents link there.
8
+
9
+ Classify every in-scope document as a tutorial or reference. Tutorials follow an ordered path to an outcome and introduce only what each step needs. References define a lookup scope and current behavior without a teaching sequence. Separate substantial tutorial and reference content; label a section when either part is small.
10
+
11
+ Before writing a tutorial, privately classify the reader's starting knowledge and each concept as beginner, intermediate, or advanced. Establish prerequisites before dependent concepts, increase difficulty gradually, and move unnecessary advanced material to a later tutorial or reference.
12
+
13
+ Author in this order: locate the document in the tree; set its permitted detail; choose tutorial or reference; for a tutorial, order concepts by prerequisite and difficulty; relocate descendant-owned detail; replace lower-level explanations with links to their owners.
14
+
15
+ ## The tier taxonomy: one home per fact
16
+
17
+ Each fact has one home: the tier whose job it is; elsewhere, link there.
18
+
19
+ | Tier | Job | Does NOT belong there |
20
+ |---|---|---|
21
+ | Root `AGENTS.md` | Standing orders: rules an agent needs in context in every session, one to three lines each, linking its home | Stories, worked examples, situational procedures, anything restated from a linked home |
22
+ | Subtree `AGENTS.md` (`packages/`, `docs/`, `.agents/notes/`) | Orders specific to that subtree | Repo-wide rules the root file already carries |
23
+ | [architecture.md](architecture.md) | Ordered map: composition, core packages, loop, seams, extension points; read before changing `packages/` | Type definitions (→ subsystems), per-package detail (→ package READMEs), decision rationale (→ Agent Notes), implementation-status annotations |
24
+ | [subsystems/](subsystems/README.md) | One reference page per subsystem: type definitions, semantics, and the generated Cordis API | Behavior narration (→ architecture.md) |
25
+ | [Agent Notes](../.agents/notes/README.md) | Active decision records: the why, what-was-given-up, and required verification; `implemented/` notes describe shipped reality in present tense | Migration plans, acceptance-task checklists, fixture walkthroughs, and spec-speak ("should…") once the decision has shipped; archived notes are frozen history, never current authority |
26
+ | [postmortem/](postmortem/README.md) | Incident stories — the only tier where war-story narrative belongs | — |
27
+ | [cookbook/](cookbook/adding-a-package.md) | Step-by-step how-tos with numbered verify steps | Design rationale (→ the Agent Note each guide links) |
28
+ | [user/](user/index.md) | Product-facing guides published by the documentation website | Generated reference tables, contributor procedures, decision history |
29
+ | Package README | The per-package contract: config, semantics, limitations, extension points, and [Model Experience](cookbook/adding-a-package.md#4-write-the-package-readme) | JSDoc restatement, generated-catalog restatement (event/tool tables), other packages' concerns |
30
+ | [development.md](development.md) | Contributor setup, daily workflow, and a summary of CI; a bilingual pair under the [i18n contract](i18n/README.md) | Runtime/version rationale (→ Agent Notes), check-by-check lists that drift from `package.json` scripts |
31
+ | Generated reference: the per-page `cordis-surface` regions in [subsystems/](subsystems/README.md), the [Cordis core API + inherited tier](cordis-api/context.md), [tool-catalog](tool-catalog.md), [config-catalog](config-catalog.md), [persistence-catalog](persistence-catalog.md), [module-graph.md](module-graph.md) | Exhaustive English sources regenerated from source and freshness-gated; reviewed Chinese counterparts follow the [pairing workflow](i18n/README.md#scope-and-exclusions) | Hand edits to generated English sources or regions; Chinese counterparts update through pairing only |
32
+ | Skills (`.agents/skills/`) | Reusable workflows and specialized decision standards | Product and runtime contracts (→ docs or source) |
33
+
34
+ Placement: bugs → postmortems; rationale → Agent Notes; procedures → cookbooks; type definitions → subsystems; package contracts → READMEs; standing orders → root `AGENTS.md` with a rationale link.
35
+
36
+ ## Writing rules
37
+
38
+ - **Document current state, not change history.** Avoid "previously/now/no longer", PRs, commits, and stack positions in durable prose; name the live mechanism. Put change stories in commits, PRs, Agent Notes, or postmortems; the latter two may cite merged PRs and issues as evidence.
39
+ - **Every non-trivial change includes at least one Agent Note in the same PR.** Update the owning note or add one; only mechanical/local edits are exempt ([scope](../.agents/notes/README.md#when-to-write-one)).
40
+ - **One physical line per paragraph** (`verify-md-wrap`): use editor soft-wrap. Code blocks, tables, and list structure keep their formatting; code comments stay under the linter's column limit.
41
+ - **Fenced `ts` blocks must compile** (`doc-typecheck`); a pasted type declaration and its original JSDoc use ` ```ts type-equiv `, while a body-stripped public class declaration uses ` ```ts public-api `; register either in the manifest so neither can drift ([mechanics](development.md#documenting-types-verbatim-ts-type-equiv)).
42
+ - **The owning [subsystems page](subsystems/README.md) updates in the same change** that reshapes a documented type. `verify-type-equiv` catches drifted pastes, not never-documented new types; a type is documented on its declaring package group's page ([page scoping](../.agents/notes/implemented/process/2026-08-03-package-anchored-subsystem-pages.md)).
43
+ - **Pairs update together**: [Terminology-guided](i18n/terminology.md), single-pass active-agent work repositions first-use annotations, preserves untouched prose, and re-records; `dsh-translate-docs` remains user-invoked ([contract](i18n/README.md)).
44
+ - **Comments and JSDoc state complete contracts, not reasoning transcripts.** Preserve behavior, failure, timing, ownership, modality, exceptions, consequences, and non-obvious orientation; delete narration, test walkthroughs, review analysis, and code restatement. Keep the local contract and link its rationale. Use [dsh-prose-standard](../.agents/skills/dsh-prose-standard/SKILL.md) for details.
45
+ - Write directly: name actors and facts ([decision](../.agents/notes/implemented/process/2026-08-09-concrete-prose-names-actors-and-recorded-facts.md)). Reserve `seam` for the defined capability. Name the exact check, type, API, operation, or behavior instead of metaphorical "gate", "vocabulary", or "surface".
46
+
47
+ ## Wordcount Budgets
48
+
49
+ [scripts/doc-budgets.manifest.json](../scripts/doc-budgets.manifest.json) sets standing-doc ceilings; `pnpm run verify-doc-budgets` rejects excess or missing files.
50
+
51
+ When the gate goes red:
52
+
53
+ 1. **Relocate** content that belongs in another tier; leave a one-line link if needed.
54
+ 2. **Condense** content that belongs here but can be shorter.
55
+ 3. **Raise** the ceiling only when the words need the space; justify the manifest diff in the PR. A too-low ceiling is a budget bug.
56
+
57
+ Ceilings are guardrails, not reduction targets. At or below target, retain at least 5% headroom; above target, freeze the ceiling until relocation or condensation brings the document under target. Lower a ceiling only when the document still has room. Targets: root `AGENTS.md` ≤ 1,950; `architecture.md` ≤ 2,400; subtree `AGENTS.md` ≤ 600, except `packages/AGENTS.md` ≤ 750 and this file ≤ 1,320; `packages/README.md` ≤ 994; plus `cordis-primer.md` 600, `defensive-patterns.md` 550, `testing.md` 1,300, `examples/AGENTS.md` 310. Review governs unbudgeted tiers.
58
+
59
+ ## The slop checklist
60
+
61
+ Hunt these in any doc; [dsh-doc](../.agents/skills/dsh-doc/SKILL.md) runs this list as an audit:
62
+
63
+ - The same rule stated in more than one home. Grep a distinctive phrase; keep one home and link the rest.
64
+ - Narrated history or war stories: "previously", "now", "no longer", "used to", "renamed", "was moved", PRs, or commits. State the current fact; link an Agent Note or postmortem when needed.
65
+ - Implementation-status annotations in prose or diagrams ("implemented!", "future: …"). Status rots; the repo layout and package manifests carry it.
66
+ - Hand-restated catalogs, JSDoc, or inventories of tests, packages, and status when source or a generator is authoritative.
67
+ - Reasoning transcripts: step-by-step implementation narration, proof of obvious branches, test walkthroughs, or rejected local alternatives. Keep the resulting contract or durable rationale; delete the path used to derive it.
68
+ - Rationale repeated beside sibling methods instead of once at the owning capability or helper.
69
+ - Paragraph walls: one paragraph carrying several rules and parenthetical asides. Split it or demote the detail to its home.
70
+ - Emphasis inflation: bold, CAPS, or "critically" everywhere means nothing stands out. Reserve emphasis for the clause that changes behavior.
71
+ - Spec-speak in `implemented/` Agent Notes: "should", migration plans, acceptance checklists. An implemented Agent Note describes what is, per the [implemented-note instructions](../.agents/notes/implemented/AGENTS.md).
72
+
73
+ ## Cross-reference with machine-checkable links, never free prose
74
+
75
+ Link repository references with relative Markdown paths, never bare filenames or Agent Note numbers. `verify-md-links` rejects missing targets and dead `#fragment` anchors ([rationale](../.agents/notes/implemented/process/2026-06-18-markdown-cross-link-lint.md)).
@@ -0,0 +1,84 @@
1
+ <!-- Generated by scripts/gen-doc-graphs.ts - do not edit by hand.
2
+ Run `pnpm run gen-doc-graphs` to regenerate. -->
3
+
4
+ # Agent Turn And Step Lifecycle
5
+
6
+ This sequence is the visual companion to [architecture.md](architecture.md#turn-flow). It keeps durable replay facts on `session/event` and live control/status on `agent/*`.
7
+
8
+ ```mermaid
9
+ sequenceDiagram
10
+ participant User
11
+ participant Agent
12
+ participant Driver
13
+ participant Hooks as hook listeners
14
+ participant Prompt as ctx.systemPrompt
15
+ participant LLM as ctx.llm
16
+ participant Tools as ctx.tools
17
+ participant Session
18
+ participant SDK as UI or SDK listener
19
+ User->>Agent: followup(content)
20
+ Agent-->>SDK: <code>agent/inbox/spliced</code>
21
+ Agent-->>SDK: <code>agent/inbox/inserted</code> { message }
22
+ Agent->>Driver: queued work wakes driver
23
+ Driver-->>SDK: <code>agent/status</code> running
24
+ Driver->>Session: <code>turn/start</code>
25
+ Note over Agent,Driver: claim pending next-step input plus one queued prompt
26
+ Driver-->>SDK: <code>agent/inbox/spliced</code> pure deletion
27
+ Driver-->>SDK: <code>agent/inbox/claimed</code> { message, turn } per message
28
+ Driver->>Hooks: <code>agent/pre-step</code> waterfall
29
+ Hooks-->>Driver: authoritative reject or enter(messages)
30
+ alt proposed step rejected or pre-step failed
31
+ Driver-->>Driver: claimed batch stays removed, the open turn spends no step
32
+ else enter proposed step
33
+ Driver->>Session: <code>step/start</code>
34
+ Driver->>Session: <code>user/message</code> per entered message
35
+ Driver->>Prompt: <code>system-prompt/assemble</code> waterfall
36
+ Driver->>LLM: <code>agent/request</code> waterfall, then <code>llm/stream</code> waterfall
37
+ LLM-->>Driver: StreamChunk*
38
+ Driver-->>SDK: <code>agent/assistant-stream</code> chunk*
39
+ alt final adapter or terminal in-band request failure
40
+ Driver->>Session: <code>assistant/attempt</code>
41
+ Driver-->>SDK: <code>agent/assistant-stream</code> committed end
42
+ Driver->>Session: <code>step/end</code>
43
+ Driver->>Hooks: <code>agent/request-error</code> waterfall
44
+ Hooks-->>Driver: return retry action or preserve the original error
45
+ else model request succeeded
46
+ Driver->>Session: <code>assistant/message</code>
47
+ Driver-->>SDK: <code>agent/assistant-stream</code> committed end
48
+ Driver->>Tools: classify pending call by executionMode
49
+ loop barriers and bounded rolling pool, reclassify before start
50
+ opt call starts
51
+ Driver->>Session: <code>tool/call</code>
52
+ Driver->>Tools: ordered pre, concurrent execute
53
+ Tools-->>Session: tool-owned events when applicable
54
+ end
55
+ opt next model-order result ready
56
+ Driver->>Tools: ordered post
57
+ Driver->>Session: <code>tool/result</code>
58
+ end
59
+ end
60
+ Driver->>Session: <code>step/end</code>
61
+ opt natural stop and next-step inbox empty
62
+ Driver->>Hooks: <code>agent/turn-stopping</code> serial terminal checkpoint
63
+ end
64
+ opt next-step input is pending
65
+ Driver-->>Driver: claim pending next-step input
66
+ Driver-->>SDK: <code>agent/inbox/claimed</code> { message, turn } per message
67
+ Driver->>Hooks: <code>agent/pre-step</code> waterfall
68
+ Hooks-->>Driver: authoritative reject or enter(messages)
69
+ end
70
+ end
71
+ end
72
+ Driver->>Session: <code>turn/end</code>
73
+ Driver-->>SDK: <code>agent/status</code> idle
74
+ ```
75
+
76
+ The `assistant/message` event records every successful provider call, including content-less and `max-tokens` finishes, and embeds the exact compact timed stream. Empty content stays out of derived history. A failed, retried, cancelled, or stream-error attempt that reaches settlement without a surface message records its stream as `assistant/attempt`. Live `agent/assistant-stream` chunk frames are transient; replay reads either durable settlement, and a hard process loss before settlement leaves no durable attempt stream.
77
+
78
+ `dsh-compaction-basic` uses `agent/pre-step` for pressure before request derivation and `agent/request-error` only for canonical context overflow. Once either trigger qualifies, optional tool-result pruning runs before summary selection. Recovery works between the closed failed step and failed turn close, and opens a fresh retry turn only when pruning or summarization advances the surface replacement generation; otherwise the original request error remains authoritative.
79
+
80
+ The returned `agent/pre-step` decision is authoritative; listeners wrapping `next()` preserve downstream messages and `startsRequestSeries` unless replacement is intentional. Steering and injected context pass through the same waterfall after a later claim operation takes their next-step batch.
81
+
82
+ SDK users that need replayable transcript data should consume `session/event`; `agent/*` is the live coordination API for queue/status, prompt interception, request construction, steering, continuation, and errors.
83
+
84
+ Maintenance mode: curated Mermaid sequence; exact event signatures live in the generated Cordis catalog.