@thincoder/core 0.11.2 → 0.11.3

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 (198) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/advisor/compaction.mjs +7 -5
  3. package/advisor/history.mjs +24 -11
  4. package/advisor/loop.mjs +13 -8
  5. package/advisor/messages.mjs +72 -8
  6. package/advisor/run.mjs +24 -13
  7. package/advisor.mjs +7 -3
  8. package/agent/chat-call.mjs +14 -9
  9. package/agent/completion.mjs +28 -40
  10. package/agent/continue-decision.mjs +14 -8
  11. package/agent/digest-account.mjs +133 -59
  12. package/agent/dispatch-run.mjs +1 -1
  13. package/agent/dispatch.mjs +2 -1
  14. package/agent/family-tools.mjs +12 -13
  15. package/agent/helpers.mjs +17 -72
  16. package/agent/image-heal.mjs +18 -4
  17. package/agent/post-turn.mjs +13 -26
  18. package/agent/record-results.mjs +21 -6
  19. package/agent/run-stages.mjs +72 -37
  20. package/agent/run-start.mjs +148 -113
  21. package/agent/setup-reminders.mjs +187 -91
  22. package/agent/setup.mjs +204 -138
  23. package/agent/spawn-child.mjs +2 -2
  24. package/agent/suspension.mjs +43 -15
  25. package/agent/timers.mjs +4 -1
  26. package/agent/turn-domain-text.mjs +105 -0
  27. package/agent/turn-loop.mjs +54 -22
  28. package/agent/turn-projection.mjs +127 -227
  29. package/agent/turn-tool-process.mjs +32 -37
  30. package/agent-tools/advisor-async.mjs +6 -3
  31. package/agent-tools/advisor-launch.mjs +5 -5
  32. package/agent-tools/advisor.mjs +1 -1
  33. package/agent-tools/async-discard.mjs +7 -2
  34. package/agent-tools/async-settle.mjs +18 -12
  35. package/agent-tools/bash-async.mjs +5 -2
  36. package/agent-tools/batch-closeout.mjs +12 -62
  37. package/agent-tools/batch-ledger-bind.mjs +19 -8
  38. package/agent-tools/batch-lifecycle.mjs +37 -11
  39. package/agent-tools/batch-read.mjs +151 -4
  40. package/agent-tools/batch-record-write.mjs +5 -5
  41. package/agent-tools/batch-segment-vocab.mjs +84 -4
  42. package/agent-tools/batch-skeleton.mjs +18 -14
  43. package/agent-tools/batch-supersede.mjs +1 -1
  44. package/agent-tools/batch-tier-gate.mjs +36 -119
  45. package/agent-tools/batch.mjs +30 -20
  46. package/agent-tools/browser-async.mjs +5 -2
  47. package/agent-tools/consult.mjs +10 -7
  48. package/agent-tools/context.mjs +47 -31
  49. package/agent-tools/digest-budget.mjs +10 -9
  50. package/agent-tools/eng.mjs +3 -4
  51. package/agent-tools/escalate-async.mjs +3 -3
  52. package/agent-tools/goal.mjs +5 -2
  53. package/agent-tools/judge-domain.mjs +347 -0
  54. package/agent-tools/manifest.mjs +2 -2
  55. package/agent-tools/parent-channel.mjs +6 -3
  56. package/agent-tools/plan.mjs +11 -10
  57. package/agent-tools/review-facts.mjs +9 -3
  58. package/agent-tools/skill.mjs +7 -8
  59. package/agent-tools/spawn-gates.mjs +5 -16
  60. package/agent-tools/ssh-session.mjs +6 -3
  61. package/agent-tools/ssh-transfer.mjs +1 -1
  62. package/agent-tools/subagent-actions.mjs +2 -2
  63. package/agent-tools/subagent-async.mjs +11 -8
  64. package/agent-tools/subagent-scheduler.mjs +9 -9
  65. package/agent-tools/subagent-spawn.mjs +2 -2
  66. package/agent-tools/subagent.mjs +5 -18
  67. package/agent-tools/task.mjs +0 -8
  68. package/agent.mjs +15 -15
  69. package/auto-think.mjs +5 -2
  70. package/compaction-work-state.mjs +230 -0
  71. package/compress-form.mjs +41 -6
  72. package/config-defaults.mjs +5 -2
  73. package/config.mjs +53 -17
  74. package/context-degrade.mjs +79 -48
  75. package/context-echo.mjs +6 -26
  76. package/context-push.mjs +328 -31
  77. package/context.mjs +203 -141
  78. package/conventions.mjs +1 -1
  79. package/declaration.mjs +95 -17
  80. package/escape.mjs +6 -5
  81. package/explore-distill.mjs +35 -8
  82. package/generate-title.mjs +10 -1
  83. package/knowledge/prompt-resources.md +5 -1
  84. package/ledger-tools.mjs +50 -50
  85. package/ledger-write-ops.mjs +43 -16
  86. package/memory/docs.mjs +51 -15
  87. package/memory/file-list.mjs +6 -0
  88. package/model-specs.mjs +87 -21
  89. package/origin-guard.mjs +190 -0
  90. package/package.json +1 -1
  91. package/prompt-files.mjs +33 -11
  92. package/prompt-overlays.mjs +12 -5
  93. package/prompts/advisor-design.md +55 -36
  94. package/prompts/advisor-round1.md +18 -7
  95. package/prompts/advisor-round2.md +18 -7
  96. package/prompts/advisor-round3.md +18 -7
  97. package/prompts/common.md +89 -51
  98. package/prompts/consult-base.md +2 -3
  99. package/prompts/discipline-engineering.md +474 -440
  100. package/prompts/discipline-normal.md +107 -31
  101. package/prompts/knowledge/business-gates.md +23 -15
  102. package/prompts/knowledge/decision-quality.md +16 -18
  103. package/prompts/knowledge/doc-lookup.md +22 -27
  104. package/prompts/knowledge/document-writing.md +31 -49
  105. package/prompts/knowledge/documentation-evaluation.md +37 -45
  106. package/prompts/knowledge/evidence-discipline.md +36 -55
  107. package/prompts/knowledge/normal-coding-workflow.md +27 -21
  108. package/prompts/knowledge/normal-delivery-collaboration.md +33 -17
  109. package/prompts/knowledge/normal-work-management.md +10 -7
  110. package/prompts/knowledge/product-security.md +22 -17
  111. package/prompts/knowledge/project-records.md +63 -52
  112. package/prompts/knowledge/tool-apply-patch.md +12 -13
  113. package/prompts/knowledge/tool-bash.md +13 -4
  114. package/prompts/knowledge/tool-batch-eng-coder.md +13 -6
  115. package/prompts/knowledge/tool-batch-eng-designer.md +14 -6
  116. package/prompts/knowledge/tool-batch-review.md +12 -6
  117. package/prompts/knowledge/tool-batch.md +76 -62
  118. package/prompts/knowledge/tool-browser.md +45 -34
  119. package/prompts/knowledge/tool-context.md +2 -2
  120. package/prompts/knowledge/tool-delete.md +5 -1
  121. package/prompts/knowledge/tool-doc-check.md +25 -24
  122. package/prompts/knowledge/tool-doc-graph-read.md +3 -3
  123. package/prompts/knowledge/tool-doc-graph.md +15 -15
  124. package/prompts/knowledge/tool-edit.md +26 -23
  125. package/prompts/knowledge/tool-execute.md +9 -4
  126. package/prompts/knowledge/tool-fetch.md +7 -1
  127. package/prompts/knowledge/tool-file-ops.md +6 -1
  128. package/prompts/knowledge/tool-git-read.md +3 -1
  129. package/prompts/knowledge/tool-git.md +1 -1
  130. package/prompts/knowledge/tool-glob.md +3 -1
  131. package/prompts/knowledge/tool-grep.md +5 -2
  132. package/prompts/knowledge/tool-hashline-edit.md +4 -2
  133. package/prompts/knowledge/tool-insert-after.md +3 -1
  134. package/prompts/knowledge/tool-ledger-read.md +6 -13
  135. package/prompts/knowledge/tool-ledger.md +14 -10
  136. package/prompts/knowledge/tool-ls.md +2 -0
  137. package/prompts/knowledge/tool-manifest.md +10 -7
  138. package/prompts/knowledge/tool-memory.md +15 -11
  139. package/prompts/knowledge/tool-operations.md +59 -71
  140. package/prompts/knowledge/tool-plan.md +1 -2
  141. package/prompts/knowledge/tool-process.md +1 -1
  142. package/prompts/knowledge/tool-read-history.md +6 -7
  143. package/prompts/knowledge/tool-read.md +1 -0
  144. package/prompts/knowledge/tool-settings.md +6 -7
  145. package/prompts/knowledge/tool-ssh.md +37 -15
  146. package/prompts/knowledge/tool-subagent.md +37 -39
  147. package/prompts/knowledge/tool-task.md +3 -1
  148. package/prompts/knowledge/tool-team-ledger.md +5 -1
  149. package/prompts/knowledge/tool-tree.md +2 -0
  150. package/prompts/knowledge/tool-wait-for.md +16 -16
  151. package/prompts/knowledge/tool-write.md +4 -1
  152. package/prompts/knowledge/upstream-protocol.md +39 -37
  153. package/prompts/persona-coder.md +1 -3
  154. package/prompts/persona-eng-coder.md +5 -5
  155. package/prompts/persona-eng-designer.md +34 -17
  156. package/prompts/persona-engineering.md +532 -501
  157. package/prompts/persona-explore.md +0 -2
  158. package/prompts/persona-normal.md +17 -9
  159. package/prompts/persona-plan.md +0 -2
  160. package/prompts/persona-tester.md +0 -2
  161. package/prompts/subagent-base.md +0 -2
  162. package/provider/anthropic.mjs +4 -2
  163. package/provider/core.mjs +5 -3
  164. package/provider/errors.mjs +41 -7
  165. package/provider/google.mjs +5 -3
  166. package/provider/reasoning-echo.mjs +16 -0
  167. package/provider/responses.mjs +4 -2
  168. package/provider/sse.mjs +11 -6
  169. package/rules.mjs +11 -10
  170. package/session-lifecycle.mjs +115 -81
  171. package/session-slot-write.mjs +1 -1
  172. package/session.mjs +23 -20
  173. package/shell-identity.mjs +129 -22
  174. package/skip-dirs.mjs +24 -0
  175. package/team-ledger.mjs +22 -22
  176. package/text-budget.mjs +1 -1
  177. package/think-off.mjs +27 -0
  178. package/token-ttl.mjs +1 -1
  179. package/token-window.mjs +278 -88
  180. package/tool-docs/bash.md +0 -2
  181. package/tool-docs/consult_start.md +2 -2
  182. package/tool-docs/consult_stop.md +2 -2
  183. package/tools/browser.mjs +8 -8
  184. package/tools/execute.mjs +2 -2
  185. package/tools/file.mjs +17 -11
  186. package/tools/git.mjs +12 -12
  187. package/tools/ops.mjs +2 -2
  188. package/tools/patch.mjs +1 -1
  189. package/tools/process-doc-mark.mjs +33 -4
  190. package/tools/repomap.mjs +25 -3
  191. package/tools/search.mjs +74 -26
  192. package/tools/shared.mjs +4 -3
  193. package/tools/ssh.mjs +5 -5
  194. package/tools/tree.mjs +32 -10
  195. package/tools/web-deepseek.mjs +1 -1
  196. package/tools/web.mjs +2 -2
  197. package/tools/write-gate-params.mjs +3 -3
  198. package/window-policy.mjs +118 -78
@@ -1,71 +1,62 @@
1
1
  aliases: 工具纪律, 工具选择, 检索优先级
2
2
  ## Tool discipline
3
3
  ### Search tool priority
4
- **Check the tool table before any search**: MCP search tools (`*_web_search*` / `*_search_prime` etc.) are PRIMARY for technical verification and general search
5
- — `websearch` (Bing) is ONLY the fallback (unavailable: not configured, or its call failed).
6
- **`websearch` returns junk/unrelated results twice in a row → switch immediately** to an MCP search tool — the same engine answers the same query with the same junk, so switching tools is the only move that brings new information.
7
- **Blocked/unreachable site (docs.claude.com / ai.google.dev etc.) → take a mirror path** (e.g. gh-proxy.com to fetch GitHub SDK source / type definitions) — a guessed official-doc URL resolves to a 404 or to an outdated copy, and the page you actually fetched is the one to cite.
8
- **Before fetching a page by hand, scan the tool table** ("do I already have a tool for this?") — `fetch` / MCP search before `curl`-style scraping.
4
+ Check the tool table before searching: MCP search tools (`*_web_search*`, `*_search_prime`) are primary for technical verification and general search.
5
+ Use `websearch` only when MCP search is not configured or its call failed.
6
+ It is not Bing-only: a configured DeepSeek provider answers first, then Tavily when `websearch.apiKey` is set and returned results, then Bing.
7
+ `websearch.backend: "local"` skips the DeepSeek leg, as does a query over 128 characters; an empty or failed DeepSeek answer falls through and adds one note beside the results a fallback leg carried.
8
+ Switch to an MCP search tool immediately after two consecutive junk or unrelated `websearch` results.
9
+ Use a mirror path for a blocked or unreachable site, such as gh-proxy.com for GitHub SDK source or type definitions.
10
+ Cite the page actually fetched, not a guessed official-doc URL.
11
+ Check for an existing fetch or search tool before scraping a page by hand: `fetch` or MCP search before `curl`-style scraping.
12
+ Pick search and fetch tools by the stated priority and network reachability, not by a hard-coded name.
13
+ Translate Chinese into English first when needed for search.
9
14
 
10
- ### When online verification is required
11
- **Answering version / API / protocol behavior from training memory = guessing** — memory has a cut-off and misremembers; verify before drawing such conclusions.
12
- **Cases that require a check**: ① **Currency** — version numbers / release status / the "latest · current" behavior of a library · tool · service / quotas · limits;
13
- ② **Precision** — the signature · parameters · defaults · error codes · endpoints of a public API · SDK · protocol, config key names and value ranges;
14
- ③ **Negative assertions** — "feature X does not exist" / "behavior Y is not like that" — negations in memory are the least reliable;
15
- ④ **Conflict with evidence** — when memory contradicts the code in front of you / a measured reading, take the measurement as authoritative and get third-party corroboration online.
16
- **What counts as enough**: a verbatim sentence or code fragment from a **first-hand source** (official docs / official repo / specification) that you can point to a specific page / file.
17
- Second-hand accounts (blogs / Q&A / aggregators) are leads only — only tracing back to a first-hand source or confirming by measurement counts as found.
18
- **No first-hand source ⇒ say so and mark `unverified`** — certainty in tone hides the uncertainty, and downstream cannot tell it from a checked fact.
19
- **What if you can't find it**: **no usable search tool in the environment** (not configured ∥ no online entry in the tool table) ⇒ say "no search tool in the environment" and mark `unverified`;
20
- **searchable but no first-hand source** ⇒ switch sources and try once or twice more, still none ⇒ state "checked, no first-hand source" in the conclusion and mark `unverified` — a fabricated source is worse than none, because downstream cannot tell it from a real one.
21
- **Boundary**: verification = **taking facts**, not **copying an industry checklist** — the criterion is evidence, not "I searched, so I checked". **Common sense needs no check** (language grammar / general algorithms / common knowledge — checking = wasted turns).
22
- **The online prerequisite** = the environment has a usable search tool (the tool table lists an online entry).
23
- **A hard-coded tool name points at the wrong place once the tool is renamed or replaced** — which search / fetch tool to use, **take it per the existing priority** (this spot only judges "should this be checked"),
24
- constrained by network reachability (overseas sites may be unreachable; if needed, translate the Chinese into English first, then search) — getting the facts is what counts; the path follows the environment.
15
+ ### What counts as a source
16
+ Use a verbatim sentence or code fragment from official docs, an official repo or a specification, with its specific page or file.
17
+ Treat blogs, Q&A and aggregators as leads; trace them to a first-hand source or confirm by measurement.
18
+ Say when no first-hand source is available and mark the assertion `unverified`.
19
+ If no usable search tool exists, say "no search tool in the environment" and mark the assertion `unverified`.
20
+ If searches find no first-hand source, keep switching sources until that is established, then state "checked, no first-hand source" and mark `unverified`.
21
+ Never fabricate a source.
22
+ Verify facts rather than copying an industry checklist.
23
+ Online verification requires a usable online entry in the tool table.
25
24
 
26
25
  ### Codebase exploration order
27
26
  repo_outline → doc_search → code_search. Structure → intent → details.
28
27
 
29
28
  ### Document search — finding a document vs locating a line
29
+ Use `doc_search` for discovery: which document states a rule, whether a standard exists, where a decision was made, which repository holds it.
30
+ Use `grep` to locate exact wording once repository, directory and file are known, then read the matching text.
31
+ The doc-lookup rules decide when to look; these decide which tool to use.
30
32
 
31
- Two questions look alike and take different tools.
32
- **Discovery** — which document said this, is there an existing standard, where was that decision made, and which repository holds it — starts with `doc_search`.
33
- **Locating** — the repository, the directory and the file are already known, and what you need is the exact wording — goes to `grep` straight away: a literal scan of a known file, read back with the matching text.
34
- `Check the docs before you ask or answer` decides when to look; this subsection decides which tool looks.
33
+ `doc_search` covers this project's documents and repositories declared under `index.publicRepos` in one query.
34
+ `grep` searches only the supplied `path`, defaulting to `.` in the session's working directory; no repository boundary applies — `path: "../<repo>"` and an absolute path are searched like any other directory.
35
+ Treat a `grep` empty result as limited to its actual reach, not proof of cross-repository absence.
36
+ Report when a search finds nothing.
37
+ After an empty `doc_search`, `grep` is appropriate for alternate spelling or a phrase in a known file; report `doc_search: none found` beside that `grep` result.
35
38
 
36
- The difference is the search surface, not the syntax.
37
- `doc_search` searches a declared domain — this project's documents plus the repositories listed under `index.publicRepos` in the project manifest — queried in one call.
38
- `grep` searches exactly one path: the one you hand it, the current repository by default.
39
- Other repos on this machine are invisible to it unless your command already carries their absolute paths, and an agent holding no list of the machine's repos has no such paths to carry.
40
- That is a structural limit across repositories, not a search done carelessly: `grep` answers "nothing here" with only the reach it was given, and that empty answer arrives in the same shape as a checked absence.
39
+ A hit in a process document is neither a criterion nor a lead: it grounds no finding and never stands in for the requirement or design document's own words.
40
+ Batch records and project-declared archived pages are outside the declared index domain.
41
+ Open the requirement or design state document identified by such a hit before relying on it.
42
+ Do not turn a past batch draft into the current standard.
41
43
 
42
- **A search that found nothing** says so. With `doc_search` empty, `grep` is the legitimate next step — a term spelled differently, a phrase only one known file uses.
43
- The answer then carries `doc_search: none found` beside the `grep` result.
44
- An unstated fallback reads to the next person as "the index holds nothing on this", which claims more than "this query missed": the first closes the topic, the second leaves it open.
45
-
46
- **A hit in a process document** is a lead, not a finding. The declared domain leaves process documents out — batch records always stay out of the index, archived pages wherever the project declares them excluded.
47
- So a hit in an excluded document tells you the search ran outside the domain: a secondary cost next to the blind spot a `grep`-only search has across repositories.
48
- It records where something was discussed once, while the state lives in the requirement and design documents, and a batch record can be dropped whole.
49
- Before an answer rests on such a hit, open the state document it points at: the batch record names the change, the state document carries the rule as it stands.
50
- Answering from the batch line turns a past round's draft into this round's standard.
51
-
52
- **Documents in other repositories** count once declared. A repository outside `index.publicRepos` adds nothing to the searchable domain, and a `grep` result from the current repo says nothing about it either way.
53
- **One key, two consequences**: the same declaration that lets a repo be searched is what lets it be cited — a reference into an undeclared repo is not merely un-indexed, it is refused (reported as a missing document, and a delivery gate fails).
54
- So when a topic may live in a sibling repository and the answer found nothing, the answer carries `cross-repo: not indexed` beside it.
55
- That records which surface was searched, and keeps an unsearched repository from reading as a settled absence.
44
+ A repository outside `index.publicRepos` is neither searchable through `doc_search` nor citable.
45
+ A reference into an undeclared repository is reported as missing and fails the delivery gate.
46
+ When a sibling-repository topic is possible but the answer is empty, report `cross-repo: not indexed`.
56
47
 
57
48
  ### Parallel call principles
58
- Batch independent read-only tool calls into a single reply (they run concurrently) — calling them one by one wastes turns.
59
- **This engine is fully asynchronous and highly concurrent**: a top-level spawn returns immediately, and its report arrives on its own when the session is idle; file conflicts and `dependsOn` dependencies are queued and ordered automatically by the scheduler.
60
- So after dispatching a subagent there are only two moves: if you need its report for the next step ⇒ end the turn and let it arrive; if not ⇒ go on with other work at once.
61
- Holding several spawns in hand and waiting for one to finish before dispatching the next only ends up slower than the order the scheduler has already laid out.
62
- The same goes for repeatedly checking progress midway: the report arrives on its own.
49
+ Batch independent read-only calls into one reply so they run concurrently.
50
+ A top-level spawn returns immediately and its report arrives when the session is idle.
51
+ The scheduler queues file conflicts and `dependsOn` dependencies automatically.
52
+ After dispatching a subagent, end the turn if its report is needed next; otherwise continue other work immediately.
53
+ Do not hold later spawns until earlier ones finish, and do not poll progress.
63
54
 
64
- ### Steering your own context
65
- **Your context** is yours to steer. ① To see the usage and composition, and how far you are from the compaction line, check any time (`context`);
66
- ② when you feel the context needs tidying (the direction changed / too noisy), **start the compaction yourself** and say what the **upcoming work needs** (focus) —
67
- what gets compacted is **retrievable** (the receipt carries the anchor).
68
- ③ At the compaction line, compaction happens automatically — that is **only a fallback**, not a signal to wrap up: once tidied, keep working until the task is actually done.
55
+ ### Steering your own context (a session whose tool table carries `context`)
56
+ Use `context` to inspect usage, composition and distance from the compaction line.
57
+ Start compaction yourself when direction changes or context becomes noisy, and state the focus needed for upcoming work.
58
+ Compacted material remains retrievable through the receipt's anchor.
59
+ Automatic compaction at the line is a fallback, not a signal to stop; continue after compaction until the task is done.
69
60
 
70
61
  ## Tool routing — write-type scenarios route per the table, not bash
71
62
  | Tool | Use it for | Not (use the dedicated tool instead) |
@@ -76,7 +67,7 @@ The same goes for repeatedly checking progress midway: the report arrives on its
76
67
  | `hashline_edit` | content-hash-addressed edit (position-independent) | `sed` by line number |
77
68
  | `insert_after` | insert a block after a known line / regex anchor | `sed` insertion, line-number surgery |
78
69
  | `apply_patch` | multi-file unified diff (all-or-nothing) | `git apply` by hand |
79
- | `delete` | delete a single file (tracked files need force) | `del`, `rm` |
70
+ | `delete` | delete one file, or an empty directory (tracked files need force) | `del`, `rm` |
80
71
  | `file_ops` | move / copy / rename files or dirs | `mv`, `cp`, `ren` |
81
72
  | `ls` / `glob` / `grep` / `tree` | list dirs / find files by pattern / regex search / directory tree | bash `dir`/`find`/`findstr`/`grep -rn` |
82
73
  | `repo_outline` / `code_search` / `doc_search` | module dependency graph / code search / doc search | ad-hoc scripts, grep gymnastics |
@@ -88,27 +79,24 @@ The same goes for repeatedly checking progress midway: the report arrives on its
88
79
  | `timer` | set a thinking-budget reminder — non-blocking; a system reminder lands at the deadline | `sleep` hacks / pushing work to later turns |
89
80
  | `verify` | pre-completion gate (you declare verification.status; it gates mechanically — it does not run checks) | expecting it to run your tests |
90
81
  | `memory` | long-term memory (search/put/list/delete/clear/maintain) | session notes |
91
- | `fetch` / `websearch` / MCP search | fetch a URL (explicit proxy) / Bing fallback / technical lookups primary | `curl` scraping |
82
+ | `fetch` / `websearch` / MCP search | fetch a URL (explicit proxy) / search with a provider chain (DeepSeek → Tavily → Bing) / technical lookups primary | `curl` scraping |
92
83
  | `checkpoint` | git snapshots / rewind safety | manual branches |
93
84
  | `subagent` / `advisor` / `consult_*` | delegation / independent review / consultation | inlining exploration, self-review only, single-model guessing |
94
85
  | `question` | ask the user (ambiguity, design decisions) | guessing; routine confirm-gates (those go in your plain reply text) |
95
86
 
96
- **Why the `git` tool, not `git` in bash (learn the why, not just the rule)** — the rule is not a style preference; bypassing it has cost uncommitted work **permanently**.
97
- The git tool **auto-snapshots before every destructive action** (`checkout -- <path>` · `restore` · `reset --hard` · `stash pop` · `clean -f` · branch/tag delete) — so a mistaken rollback is recoverable via `checkpoint` (`list` → `rewind`).
98
- The bash tool has a matching guard, but it **silently fails in exactly the configuration you are most likely to be in**.
99
- It checks `isGitRepo(cwd)` where `cwd` is the *process* working directory — a session anchored at a non-repo workspace root (with the repo in a subdirectory) resolves that to a non-repo ⇒ **no snapshot is taken, and nothing tells you**.
100
- Changing directory *inside* the command (a shell `cd` / `Set-Location`, or any prefix of that kind) does not change the `cwd` the guard sees.
101
- The same holds for the git tool: it demands an explicit `workdir` when the anchor is ambiguous — **pass it; that friction is the guard working, not an obstacle**.
87
+ Use the `git` tool for every git operation: it snapshots before `checkout -- <path>`, `restore`, `reset --hard`, `stash pop`, `clean -f` and branch/tag deletion.
88
+ Recover a mistaken rollback with `checkpoint` `list` → `rewind`.
89
+ Do not rely on the bash guard: it checks the process `cwd`, which may be a non-repo workspace root even when the repo is in a child directory, and a shell `cd` or `Set-Location` does not change the `cwd` that guard uses.
90
+ Pass an explicit `workdir` to the git tool when the anchor is ambiguous.
102
91
 
103
- **`wait_for` is for states that will not announce themselves**: a port opening, a file appearing — such things have no delivery channel into your session; without a query you would not know, so a blocking wait on them pays off.
104
- An async subagent's report is the opposite: it arrives on its own when the session is idle; what `wait_for` gets is only the "it has settled" signal — the report's content still waits for delivery.
105
- And `wait_for` is a **blocking** call — using it to wait for a report leaves the whole session parked in place, with nothing you can do during that time.
92
+ Use `wait_for` only for states without their own delivery channel, such as a port opening or a file appearing.
93
+ Do not use it for an async subagent report, which arrives when the session is idle.
94
+ A blocking `wait_for` parks the whole session.
106
95
 
107
96
  **Destructive commands — the tool layer catches none of this**:
108
- - **Deletions go through the tool face**: `rm` / `rmdir` / `del` / `rd` / `Remove-Item` and the like run outside the face that gates deletion and keeps it revertable — `delete` / `git rm`, or a very narrow allowlist, is where deletions belong.
109
- - **Diagnostics are read-only**: existence / state checks use read-only commands only (`dir` / `ls` / `where` / `type`).
110
- A smuggled write or delete verb turns a diagnostic into a change nobody expected, and a "no-op / read-only" tag covers the change it labels.
111
- When a dedicated tool exists for the job, the tool-routing table still wins — this bullet covers the bare-command case only.
112
- - **Silent masking hides the failure**: no `2>nul` / `2>/dev/null` error-swallowing on destructive / write commands, no `&` / `;` (as opposed to `&&`) chaining — a failure must be visible.
113
- - **Confirm before irreversible actions**: stop before an irreversible action — the main session asks the user; a subagent raises an upstream `ask` (`notify_parent`).
114
- - **Boundary**: nothing at the tool layer catches this for you (no mechanical gate, no tool-semantics change) — you write the command, so you are the first line of defense.
97
+ - **Deletions go through the tool face**: use `delete`, `git rm` or a very narrow allowlist instead of `rm`, `rmdir`, `del`, `rd`, `Remove-Item` and similar commands.
98
+ - **Diagnostics are read-only**: only read-only existence and state commands such as `dir`, `ls`, `where` and `type`; never smuggle in a write or delete verb.
99
+ Follow the routing table when a dedicated tool exists; this bullet covers bare commands.
100
+ - **Keep failures visible**: no `2>nul` or `2>/dev/null` on destructive or write commands, and no chaining with `&` or `;` instead of `&&`.
101
+ - **Confirm before irreversible actions**: the main session asks the user; a subagent raises `notify_parent` `ask`.
102
+ - **Take responsibility for the command**: no tool-layer gate replaces your own check.
@@ -2,5 +2,4 @@ aliases: 计划模式, 只读计划
2
2
  In plan mode you are restricted to READ-ONLY tools: read files, search code, run read-only shell commands.
3
3
  Use plan mode before complex multi-step tasks — explore the codebase, design the architecture, present a plan to the user.
4
4
 
5
- Exit plan mode to present the plan for the user's approval; implement only after they approve.
6
- For simple single-file edits, skip plan mode and just make the change.
5
+ Exit plan mode to present the plan for the user's approval; implement only after they approve.
@@ -8,7 +8,7 @@ Parameters:
8
8
  - action (optional, default 'list'): list — show running processes; kill — terminate a process tree (target: pid) or a background task (target: id)
9
9
  - name: (list) substring filter (case-insensitive), e.g. "node", "python"
10
10
  - pid: (kill) process id — the whole tree is terminated (taskkill /T /F on win32; POSIX group kill)
11
- - id: (kill) background task id — a `bash#N` (bash async ack) or `browser#N` (browser async ack): bash ⇒ its process tree is terminated; browser ⇒ a queued task is dropped, a running one is aborted (the browser itself is not killed); either way the entry leaves the pool and no digest will arrive (a bash task's log so far stays readable).
11
+ - id: (kill) background task id — the N from a `bash#N` or `browser#N` ack, as a number. bash ⇒ its process tree is terminated; browser ⇒ a queued task is dropped, a running one is aborted (the browser itself is not killed); either way the entry leaves the pool and no digest will arrive (a bash task's log so far stays readable).
12
12
 
13
13
  Notes:
14
14
  - kill is destructive: pass exactly one target (pid or id — never both), and it goes through the same approval gate as other destructive actions — confirm before killing.
@@ -1,13 +1,13 @@
1
1
  aliases: 历史, 会话历史, 回看
2
2
  Recall what was said or done earlier: design decisions, tool-call timing, past rulings.
3
3
 
4
- Default (no `path`): this session's full record - never compacted, audit-complete.
4
+ Default (no `path`): this session's full record — never compacted, audit-complete.
5
5
 
6
- Sub-agent face: eng-coder / eng-designer children get a bounded form of this tool instead — the parent session only, limited to this batch's window (its creation, or where its first spawn bound it, up to the next batch's start), `limit` required and capped at 50, and no `path`.
6
+ Sub-agent face: eng-coder / eng-designer children get a bounded form instead — the parent session only, limited to this batch's window (its creation, or where its first spawn bound it, up to the next batch's start), `limit` required and capped at 50, and no `path`.
7
7
 
8
8
  Everything else (explore / plan / coder / tester / consult) carries no history tool: the facts it needs ride the task book's `knownFacts`.
9
9
 
10
- Filters combine with AND (`role` / `keyword` / `tool` / `since`-`until` / `limit` / `direction` - semantics per parameter; `keyword` with `path="all"` matches words and phrases, not only an exact substring).
10
+ Filters combine with AND (`role` / `keyword` / `tool` / `since`-`until` / `limit` / `direction` — semantics per parameter; `keyword` with `path="all"` matches words and phrases, not only an exact substring).
11
11
 
12
12
  Returns a JSON array in chronological order:
13
13
 
@@ -15,14 +15,13 @@ Returns a JSON array in chronological order:
15
15
  [{ts, role, name?, tool_call_id?, content (≈500 chars, truncated marker), tool_calls ([{name, arguments}] - arguments capped at 300 chars)}]
16
16
  ```
17
17
 
18
- Messages without `ts` return `ts: null`. `content` is truncated to ≈500 chars, and the marker states what is actually retrievable -
19
- `user` / `assistant` bodies: the full text is in the session file; `tool` results: the session file keeps only those first 500 chars, so re-run the tool if you need more.
18
+ Messages without `ts` return `ts: null`. `content` is truncated to ≈500 chars, and the marker states what is actually retrievable — `user` / `assistant` bodies: the full text is in the session file; `tool` results: the session file keeps only those first 500 chars, so re-run the tool for more.
20
19
 
21
20
  Cross-session (`path`, optional): a session file path deep-queries THAT session with the same filters (a relative path resolves against the project cwd). A session too large to deep-query is refused as `session too large`.
22
21
 
23
22
  `cwd:<dir>` lists that directory's session slots (slot + file path + title + count + updatedAt; copy one into `path` to deep-query it).
24
23
 
25
- `all` searches every INDEXED session (cross-project; the rows carry `session.file`). A session never indexed yet is invisible - query it with `path=<file>`, or index first with the CLI `thincoder session index --rebuild`.
24
+ `all` searches every INDEXED session (cross-project; rows carry `session.file`). A session never indexed yet is invisible — query it with `path=<file>`, or index first with `thincoder session index --rebuild`.
26
25
 
27
26
  Which tool for which question:
28
27
  - what was said or ruled in THIS session → `read_history` (default).
@@ -33,4 +32,4 @@ Which tool for which question:
33
32
  - the code as implemented → `code_search`.
34
33
  - a git snapshot → `checkpoint cat` / `versions`.
35
34
 
36
- `read_history` only reads session messages; file-level changes belong to `recent_changes`, knowledge and conventions to `memory` - none substitutes for another.
35
+ `read_history` reads session messages only; file-level changes belong to `recent_changes`, knowledge and conventions to `memory` — none substitutes for another.
@@ -18,4 +18,5 @@ Parameters:
18
18
  Notes:
19
19
  - Always prefer this over `cat` or shell-based reading - it caps output and avoids large dumps.
20
20
  - Use `offset` for pagination when the file is large.
21
+ - The first output line is the document's layer label, e.g. `[design]`: it names the doc layer this file belongs to under the project's doc-root declaration, and reads `[unlayered]` when the file sits under none of the declared roots. Read it as "which kind of document this is", never as file content.
21
22
  - When you plan to edit the file, take `hashes: true` in the same read: hash-based editing is immune to whitespace and encoding mismatches.
@@ -1,18 +1,17 @@
1
1
  aliases: 配置, 设置, 改配置
2
- Actions: `list` (all keys and values, flattened) | `get <key>` | `set <key> <value>` - dot paths into config.json, at any nesting.
2
+ Actions: `list` (all keys and values, flattened) | `get <key>` | `set <key> <value>` — dot paths into config.json, at any nesting.
3
3
 
4
- `set` persists to disk (only the key you set is written, defaults are never baked in) and takes effect in the running session immediately - keys that apply at a turn boundary apply from the next turn - and the value survives restarts.
4
+ `set` persists to disk (only the key you set is written; defaults are never baked in), takes effect in the running session at once — keys that apply at a turn boundary apply from the next turn — and the value survives restarts.
5
5
 
6
- `list` / `get` are read-only (fine in planMode, no approval); `set` is a side effect and goes through the approval gate. The `/config` TUI command is the human equivalent.
6
+ `list` / `get` are read-only (fine in planMode, no approval); `set` is a side effect behind the approval gate. The `/config` TUI command is the human equivalent.
7
7
 
8
8
  Known keys are type-checked, so a value the app would silently drop is refused:
9
-
10
9
  - scalar keys against their built-in default (`agent.maxTurns` a number, `traces.enabled` a boolean);
11
- - `agent.mode` accepts exactly `tiny`, `normal` or `engineering` and sets the new-session default without changing the current session; `agent.engineering` is a derived read-only view and cannot be set directly or through an agent object;
10
+ - `agent.mode` accepts exactly `tiny`, `normal` or `engineering`, sets the new-session default and leaves the current session alone; `agent.engineering` is a derived read-only view, not settable directly or through an agent object;
12
11
  - keys whose default is null against their real consumption shape (`defaultModel` in `"provider:model"` form, `agent.subagentModel` / `shell` a non-empty string, `memory.team` an object carrying a repo).
13
12
 
14
- `null` clears a key: the entry is removed from config.json and the built-in default applies. String-typed keys refuse `null` - there is no "unset" state to fall back to. Unknown keys under a known section are stored as given.
13
+ `null` clears a key: the entry leaves config.json and the built-in default applies. String-typed keys refuse `null` — there is no "unset" state to fall back to. Unknown keys under a known section are stored as given.
15
14
 
16
- SENSITIVE keys are NEVER echoed in plaintext: list / get / set replies show `••••(masked)`. Setting a sensitive key is allowed and stored, but it is never echoed back.
15
+ SENSITIVE keys are NEVER echoed in plaintext: list / get / set replies show `••••(masked)`; setting one is allowed and stored.
17
16
 
18
17
  A key counts as sensitive when a path segment looks like a credential (`apiKey`, `token`, `secret`, `password`, `authorization`, `cookie`, `credential` …), or when it sits under a `headers` / `env` segment.
@@ -1,52 +1,74 @@
1
1
  aliases: 远程, 网络设备, 登录
2
- A session survives across tool calls. Password hosts get a credential window — the value never appears in tool args or results.
2
+ A session survives across tool calls. Password hosts get a credential window, or reuse a saved credential silently — the value never appears in tool args or results.
3
3
 
4
4
  **Route to ssh instead of bash:**
5
- - a one-shot non-interactive command over ssh → `bash` with `ssh host <command>` (cheaper, no session)
5
+ - a one-shot non-interactive command over ssh on a key / ssh-agent host → `bash` with `ssh host <command>` (cheaper, no session); a password host takes the session's long wait instead
6
6
  - an interactive shell that must survive several calls (network device CLI, interactive prompts) → ssh
7
7
  - one file to or from a host you already have a session on → `put` / `get` (they reuse the session's host and credential chain, which `bash scp` cannot reach)
8
8
  - a whole directory tree, a resumable transfer or a progress bar → not this tool (single file only)
9
9
  - port forwarding (`ssh -L` / `-R`) → `bash`
10
10
 
11
+ **Long waits:**
12
+ - Two triggers: the wait is expected to run past 30 seconds, or two consecutive reads of the same observation show no change.
13
+ Either one means change shape — never send the next identical read of that observation.
14
+ - Key or ssh-agent host (a connect that showed no credential window and reused no saved credential): run the wait as a `bash` background task (`async`).
15
+ It returns an ack at once and opens a round with the result when the process exits.
16
+ - Password host (a connect that showed the credential window, or one that reused a saved credential): keep the session and wait once — `send` with a large enough `timeoutMs`.
17
+ `timeoutMs` bounds that wait, so give the remote command a hard bound of its own that makes it return.
18
+ - Never run `bash ssh` against a password host: that shell has no terminal, the password prompt has nowhere to answer, and the process hangs.
19
+ - The auth face is known only after the first connect: reach an untouched host with the session `connect`, then split by auth face from its next wait on.
20
+
21
+ **Session reuse:**
22
+ - `list` before `connect`: reuse the live session for that host through its `ssh#N`, and `connect` only when `list` shows no session for the host.
23
+ - Never keep a second session on a host that already has one.
24
+ - `close` when the task ends; do not leave it to the idle sweep.
25
+ - When the session id is lost, take it back from `list` instead of reconnecting.
26
+ - A `connect` refused because the pool is full names every live session: `close` one of those and continue.
27
+ A retry meets the same refusal and frees nothing.
28
+ - When a long wait outlives the round, end the round with user-facing text that says what you are waiting for and what wakes you.
29
+ A long wait is no exception to that close.
30
+ - A subagent has neither this tool nor the background channel: hand the long wait up to the parent instead of polling in its own layer.
31
+
11
32
  Parameters:
12
33
  - action (required): connect | send | read | secret_input | close | list | credentials | forget | put | get
13
34
  - host: connect / forget — target host (IP or name)
14
35
  - user: connect — login user (optional: your local ssh config decides, else the user recorded for this host locally)
15
36
  - port: connect / forget — TCP port (optional, default 22)
16
37
  - label: connect — short human label for this session (optional); secret_input — label for the value being sent
17
- - promptPattern: connect — regex that marks the shell prompt as ready (optional). Give it when the device's prompt does not look like a shell prompt — otherwise each command waits out the full timeout. Left out, a line ending in `#` `>` `$` `%` counts as the prompt.
38
+ - promptPattern: connect — regex marking the shell prompt as ready (optional). Give it when the device's prompt does not look like a shell prompt, or every command waits out the full timeout. Left out, a line ending in `#` `>` `$` `%` counts as the prompt.
18
39
  - identityFile: connect — private-key path to offer as `-i` (`~` expands); remembered for this host and reused when omitted (optional)
19
40
  - id: send / read / secret_input / close / put / get — session id from connect (`ssh#N`)
20
41
  - data: send — text to type into the session (a trailing newline is passed as-is; otherwise Enter is sent as `\r`)
21
42
  - settle: send — wait for the ready verdict before returning (default true); false returns right after the bytes are written
22
- - timeoutMs: send / read — wait budget override (default 60000; the wait ends as soon as the device is waiting for input — a prompt, `--More--`, a y/n or password prompt); put / get — transfer budget override (default 600000; on expiry the process tree is killed)
43
+ - timeoutMs: send / read — wait budget override (default 60000; the wait ends as soon as the device waits for input — a prompt, `--More--`, a y/n or password prompt); put / get — transfer budget override (default 600000; on expiry the process tree is killed)
23
44
  - maxChars: read — return-window override (default 8000): head 60% + a note + tail 40%, and the omitted middle stays in the session for the next read
24
45
  - localPath: put / get — local file path (`~` expands; a file, never a directory)
25
46
  - remotePath: put / get — path of that file on the session host (e.g. `/flash/img.bin`)
26
47
  - overwrite: get — replace an existing local file (default false: an existing target is refused, never overwritten silently). put follows scp's own semantics: a same-named remote file is replaced
27
- - protocol: put / get — `scp` (classic SCP protocol, the default, what network devices speak) | `sftp` (for hosts that only offer that). There is no automatic fallback between them
48
+ - protocol: put / get — `scp` (classic SCP protocol, the default, what network devices speak) | `sftp` (for hosts that only offer that). No automatic fallback between them
49
+ - ledger: the in-flight ledger row this call serves — `"#N"` or `"N"`. `ledger` is needed on `get` only — `get` writes into the project, `put` writes the remote host.
28
50
 
29
51
  Output:
30
- - connect / send / read / secret_input / close / list / put / get results start with the session status line: `[ssh (ssh#3) 10.0.0.5 — ready · idle 3s]`
52
+ - connect / send / read / secret_input / close / list / put / get start with the session status line: `[ssh (ssh#3) 10.0.0.5 — ready · idle 3s]`
31
53
  - connect returns the first screen; send returns the round's output plus the ready verdict (answer prompt such as `--More--` | prompt matched | timeout); read returns what arrived since the last read
32
- - put / get return the status line, then exactly one more line — `put <localPath> → <remotePath> · N bytes · exit 0` (and the mirrored form for get). The file's content never enters the context: the bytes travel over the disk only, never through a result, a log or a message. On failure you get an `Error:` line plus the tail of scp's stderr (≤ 600 characters), with the exit code named
54
+ - put / get return the status line, then exactly one more line — `put <localPath> → <remotePath> · N bytes · exit 0` (mirrored for get). The file's content never enters context: the bytes travel over the disk only, never through a result, a log or a message. On failure you get an `Error:` line plus the tail of scp's stderr — its last 600 characters, absent when stderr is empty, and escaped for markup after the cut, so the tail you read can run past 600 characters. The exit code is named only when the failure matches no known class — an auth failure or another recognised class reports that class's message instead.
33
55
 
34
56
  Notes:
35
- - Key-first: keys, your ssh config and ssh-agent are always tried before any saved credential — a connect succeeds without a window when a key works. To make a password host prompt-free, install a key once: `ssh-keygen -t ed25519` (if you have none), then `ssh-copy-id user@host`, then reconnect.
36
- - Credential discipline: the password is asked for in a window and reaches ssh only through its child-process environment — it is never echoed in a result and never stored in plaintext. Any captured output containing that value (or a value given to secret_input) is scrubbed from the returned text and from the session log.
37
- - Saving a credential is opt-in and belongs to `connect`: the window carries a `save` checkbox (off by default). When checked and authentication succeeds, the password is stored encrypted under your OS user account in a per-user file outside the repository, and reused silently — the next connect skips the window, and only after key authentication fails. Another process running as the same logged-in user could decrypt it. Saving is Windows-only for now; elsewhere the checkbox does not appear.
57
+ - Key-first: keys, your ssh config and ssh-agent are always tried before any saved credential, so a connect succeeds without a window when a key works. To make a password host prompt-free, install a key once: `ssh-keygen -t ed25519` (if you have none), then `ssh-copy-id user@host`, then reconnect.
58
+ - Credential discipline: the password is asked for in a window and reaches ssh only through its child-process environment — never echoed in a result, never stored in plaintext. Any captured output containing that value (or a value given to secret_input) is scrubbed from the returned text and the session log.
59
+ - Saving a credential is opt-in and belongs to `connect`: the window carries a `save` checkbox (off by default). When checked and authentication succeeds, the password is stored encrypted under your OS user account in a per-user file outside the repository and reused silently — the next connect skips the window, and only after key authentication fails. Another process running as the same logged-in user could decrypt it. Saving is Windows-only for now; elsewhere the checkbox does not appear.
38
60
  - Fail-soft: an unreadable or undecryptable entry, a damaged store or a missing backend falls back to the credential window (the connection is not broken, and undecryptable entries are kept). If the server rejects a saved credential it is deleted and the window is shown. A failed save never affects the connection.
39
61
  - secret_input is for device prompts (enable password, sudo, key passphrases): it opens the same kind of window, writes the value plus Enter, and returns only the output — the value is never shown.
40
- - Sessions: at most 4 live at once (a connect beyond the cap is refused — close one first). A session idle for 600s with no send/read is closed automatically. `close` ends it. Ctrl+I (interrupt) does not kill sessions; a user Stop does.
62
+ - Sessions: at most 4 live at once (a connect beyond the cap is refused — close one first). A session idle for 600s with no send/read closes automatically. `close` ends it. Ctrl+I (interrupt) does not kill sessions; a user Stop does.
41
63
  - Output is a cleaned text stream: terminal escape sequences and CRLF noise are stripped. Each return is a window (8000 chars: head + a note + tail); the omitted middle stays in the session, so another read collects it and a large configuration comes back in full.
42
64
  - Not for full-screen terminal UIs (vim/top/screen): output is read as a text stream — paged output such as `--More--` is shown as-is, not driven for you.
43
65
  - Transfers are binary safe and single-file: no recursive directory sync, no resume, no progress bar, and the parameters take files only (a directory is not a valid `localPath` / `remotePath`).
44
66
  - `get` never overwrites silently and never creates directories: an existing local file is refused unless you pass `overwrite:true`, and the local parent directory must already exist.
45
- - `put` on a password host runs the same credential decision as connect: keys first, then the saved credential (no window), then the credential window. That transfer window asks for user / password only and carries no save checkbox; a session built by typing a password without saving it has no password kept, so the next transfer asks again.
46
- - If a transfer is killed at `timeoutMs`, a `get` removes the partial local file only when that transfer wrote it (an existing file scp never touched is kept, and the receipt says so); after a `put` the remote host may keep a partial file — resend the whole file with `overwrite:true`, or delete it on the host.
47
- - Ready means the device is waiting for you, not that output stopped: a prompt or an answer prompt (`--More--`, y/n, password) ends the wait, and a slow operation that goes quiet keeps waiting instead of returning half of its output.
67
+ - `put` on a password host runs the same credential decision as connect: keys first, then the saved credential (no window), then the credential window. That window asks for user / password only and carries no save checkbox; a session built by typing a password without saving keeps no password, so the next transfer asks again.
68
+ - A transfer killed at `timeoutMs`: a `get` removes the partial local file only when that transfer wrote it (an existing file scp never touched is kept, and the receipt says so); after a `put` the remote host may keep a partial file — resend the whole file with `overwrite:true`, or delete it on the host.
69
+ - Ready means the device waits for you, not that output stopped: a prompt or an answer prompt (`--More--`, y/n, password) ends the wait, and a slow operation that goes quiet keeps waiting instead of returning half its output.
48
70
  - Host keys follow your local ssh config — the tool never rewrites known_hosts. A changed or untrusted key stops the connect with a readable error before any credential is asked for.
49
- - read / list / credentials are read-only (no approval prompt); connect / send / secret_input / close / forget / put / get pass the approval gate like any side-effecting tool, and secret_input shows a masked placeholder — the value itself is never in the approval text. A transfer's approval text names both ends (`localPath` → `remotePath`) and never the file's content.
71
+ - read / list / credentials are read-only (no approval prompt); connect / send / secret_input / close / forget / put / get pass the approval gate like any side-effecting tool, and secret_input shows a masked placeholder — the value itself is never in the approval text. A transfer's approval text names both ends (`localPath` → `remotePath`), never the file's content.
50
72
  - credentials lists saved entries (host / user / saved / last used — never a value); forget deletes the entry for a host (and optional port) and is idempotent — the next connect asks in the window again.
51
73
 
52
74
  Availability: where the end has no UI to collect a credential (headless / ACP), connecting to a password host fails with a readable error — use keys or an ssh-agent there.
@@ -1,59 +1,57 @@
1
1
  aliases: 子代理, 派单, 派活
2
2
  ONE tool, NINE actions — pick by what you need:
3
3
 
4
- - action:'spawn' (DEFAULT): run a sub-agent in its own isolated context — its reads, searches and tool calls never reach your history; only the final report comes back. Spawn MULTIPLE subagents in the SAME response for parallel work — they run concurrently.
5
- - action:'status': NON-BLOCKING progress query — returns immediately, consumes nothing, never fetches. Pass the spawn id for one child (role, state: running|queued|done, model, elapsed, turn, position, plus a touched-files summary — first 5 plus a count) or omit it for a pool overview — see what a running child has changed BEFORE cancelling it. Background advisor reviews share this surface (pass the review id).
6
- - action:'observe': SEE what a running async subagent is DOING right now (progress vs stuck) — pass the id; returns state, turn, the tool(s) executing right now, and the last N one-line turn summaries, newest first (`recent`, required, 1..20). Readonly; running/queued/done all answer — queued returns a placeholder, done gives the activity summary only, NOT the report.
7
- - action:'send': STEER a running async subagent mid-flight — id + message. The child consumes it at its next turn boundary as an ORDINARY user instruction (non-interrupting; guidance, not a deviation waiver); returns {id, status:'delivered', queued}. Only RUNNING async children are targetable — sync/queued/settled/unknown error clearly; if the child settles first, its report carries an 'undelivered' note.
8
- - action:'escalate': hand an implementation task to a STRONGER model from your consult models; it gets WRITE access and does the work itself, then returns a post-op report (what changed, why, verification). Not available in engineering mode (implementation goes through eng-coder). Async at depth 0: pass `async: true` — ack {id, role:'escalate', status:'running'} returns immediately; the report arrives automatically.
9
- - action:'cancel': STOP ONE background subagent — the id from the spawn return is REQUIRED (a blanket cancel is unsupported; Ctrl+C stops everything). Running aborts immediately ({id, status:'cancelled'}); queued is removed ({id, status:'cancelled', was:'queued'}) and later positions shift. Other children and the session keep running. Cancel is a last resort: a running child's in-flight work dies with it, and partial changes stay unmerged and unaudited. Background advisor reviews cancel the same way (pass the review id).
10
- - action:'consume-design' (engineering mode, parent side): chain-terminal token consumption — after the delivery is verified and the chain closes out, consume this design's token slot. Selectors — pass exactly ONE: designId (a single slot; optional for a single-design session), designIds (an explicit non-empty list), expired:true (every expired slot), or olderThanDays:N (every slot older than N days). A consumed slot rejects further spawns for the same designId — new work, deviation fixes included, needs a fresh design review and token. Idempotent (unknown/already-consumed = a no-op notice); batch calls report per-slot lines plus a `consumed N` count line. Do NOT call while the chain is still open — fix rounds reuse the same slot.
11
- - action:'design-slots' (engineering mode, parent side): READ-ONLY inventory of this session's approved design token slots — one line per slot (designId, live|expired, ageDays, expiresAt, batch, designToken), oldest first, ending with a total/live/expired count line. Nothing is written. Every row carries its designToken value, expired ones included (a malformed record shows designToken=—). Pass designId to filter to a single slot (trimmed exact match; unknown = refused with the held id list; empty string = no filter). Take designId + designToken verbatim onto the eng-coder spawn — the gate checks exact equality.
12
- - action:'panel': DIAGNOSE and fix the subagent panel (the collapsible blocks the user sees; headless / VS Code degrade to a 'no panel' pool view). view (default): the live blocks (key, role, status: running|done|awaitingDigest) exactly as the user sees them. freeze: pass a digested-stuck block key (e.g. 'eng-coder#9') to reclaim it into the conversation — passes ONLY for awaitingDigest blocks with no live pool entry and no pending report (refused otherwise).
13
-
14
- Available roles (exposed per mode; the role is REQUIRED for action:'spawn' — a missing or misspelled role is refused):
15
- - explore — read-only search & analysis; its git access is read-only (log / show / diff / status / blame …) and no git working-tree context is injected — evidence comes from reads and the task book; its report must list what it searched and what it did NOT find. Say quick / medium / thorough (default medium).
16
- - plan — read-only planning; NEVER edits; returns a step-by-step plan.
17
- - coder — full implementation; the parent's read/write/execute toolset minus the interactive main-session tools (`question` · `ssh` — a child has no user to ask and no credential window / session to hand back), plus verify and advisor self-review. Its report carries a delivery table, one row per requirement (Done / Simplified / Not done — no deferred column). Normal mode: may optionally carry `batchDoc`, which binds this spawn's §5 record-write channel (unbound ⇒ the main agent records §5 on its behalf); when provided the path must resolve to a readable file.
18
- - eng-coder — engineering mode only (replaces coder): the same toolset plus the design-driven methodology overlay; its delivery protocol (implementation → audit → self-fix → advisor re-review → converged delivery) runs fully inside the child. REQUIRES a valid designToken from a passed advisor(type='design') review — pass the exact value from that review, or copy it verbatim from the action:'design-slots' row (the text after designToken=): missing or mismatched = the spawn is refused, and an expired token is refused with expired named. Its reply also echoes a designId — pass it (required to pick between concurrent designs, optional for one) and echo it back in the delivery report. REQUIRES a batchDoc — the batch record path, the task book this spawn implements (refused when absent, when it does not resolve to a readable file, or when that record already has an in-flight spawn).
19
- - eng-designer — engineering mode only: the SOLE author of the design documents and of the batch record's design section (requirement docs stay with the main agent). Writes no implementation code, does not edit prompts, does not fire reviews, needs NO designToken. Surveys on its own; may only spawn read-only explore children (sync, ≤6 per batch). REQUIRES a batchDoc (same gate as eng-coder).
20
- - tester — BOTH modes: the readings seat. It runs the verification commands the task book puts in `goal` and hands the readings back as they stand — no verdict, no fix, no document of any kind. Its tool face is the read-only tools plus `execute` / `bash` (dependency installs, compiles and fixtures included), minus `verify`. Run only, never change is a role contract, not a sandbox — `bash` can write, so a tester that edits anything is a defect.
21
-
22
- Task book (non-engineering roles: explore / plan / coder / tester): four core structured parameters plus `scope`.
23
- - goal — the goal & why.
4
+ - `spawn` (default): run a sub-agent in its own isolated context — only the final report reaches your history. Spawn several in the SAME response; they run concurrently.
5
+ - `status`: non-blocking progress query; returns immediately and consumes nothing. With a spawn id: role, state (running | queued | done), model, elapsed, turn, position, touched files (first 5 plus a count). Without: the pool overview. Background advisor reviews share this surface — pass the review id; an id that belongs to no live spawn, review or settled row is refused with it named.
6
+ - `observe`: what a running async child is doing now — state, turn, the tools executing, and the last `recent` (required, 1..20) one-line summaries, newest first. Read-only; queued returns a placeholder, done gives the activity summary, not the report.
7
+ - `send`: steer a running async child — id + message, consumed at its next turn boundary as an ordinary user instruction (non-interrupting guidance, not a deviation waiver). Returns {id, status:'delivered', queued}. Sync / queued / settled / unknown error clearly; a child that settles first carries an 'undelivered' note.
8
+ - `escalate`: hand an implementation task to a STRONGER model from your consult models; it gets write access, does the work, then returns a post-op report (what changed, why, verification). Not available in engineering mode. Omission still means the async flight and `false` asks for the blocking one; at depth 0 pass `async: true` — ack `{id, role:'escalate', status:'running'}` returns immediately and the report arrives automatically.
9
+ - `cancel`: stop ONE background child — the spawn id is required. Running aborts (`{id, status:'cancelled'}`); queued is removed (`{id, status:'cancelled', was:'queued'}`) and later positions shift. Last resort: in-flight work dies and partial changes stay unmerged and unaudited. Advisor reviews cancel the same way.
10
+ - `consume-design` (engineering mode, parent side): chain-terminal token consumption. Pass exactly ONE selector — designId / designIds / expired:true / olderThanDays:N. A consumed slot rejects further spawns for that designId, deviation fixes included: new work needs a fresh review and token. Idempotent (unknown or already consumed = a no-op notice); batch calls report per-slot lines plus a `consumed N` count line. Do not call while the chain is open — fix rounds reuse the same slot.
11
+ - `design-slots` (engineering mode, parent side): read-only inventory of this session's approved design tokens, oldest first — designId, live|expired, ageDays, expiresAt, batch, designToken — ending with a total/live/expired line. Malformed records show designToken=—. Copy designId + designToken verbatim onto the eng-coder spawn; the gate checks exact equality.
12
+ - `panel`: diagnose and fix the subagent panel (headless / VS Code degrade to a 'no panel' pool view). `view`: the live blocks (`running` | `queued` | `done` | `awaitingDigest`). `freeze`: pass a digested-stuck block key — passes only for awaitingDigest blocks with no live pool entry and no pending report.
13
+
14
+ Available roles (exposed per mode; `spawn` requires one — missing or misspelled is refused):
15
+ - explore — read-only search and analysis; git access read-only; no working-tree context injected, so evidence comes from reads and the task book. Its report must list what it searched and what it did NOT find. Say quick / medium / thorough (default medium).
16
+ - plan — read-only planning; never edits; returns a step-by-step plan.
17
+ - coder — full implementation: the parent's toolset minus the interactive main-session tools (`question` · `ssh`), plus verify and advisor self-review. Its report carries the requirement-point table, one row per requirement (Done / Simplified / Not done — no deferred column). Normal mode: an optional `batchDoc` binds this spawn's §5 write channel.
18
+ - eng-coder — engineering mode only (replaces coder): the same toolset plus the design-driven overlay, and the delivery protocol runs fully inside the child. REQUIRES a valid designToken from a passed `advisor(type='design')` review. Missing or mismatched is refused; expired is refused with expired named. Echo the designId in the delivery report. REQUIRES a batchDoc that resolves to a readable record with no spawn in flight.
19
+ - eng-designer — engineering mode only: the SOLE author of design documents and of the batch record's design section (requirement docs stay with the main agent). Writes no code, edits no prompts, fires no reviews, needs NO designToken. Surveys on its own; may only spawn read-only explore children (sync, ≤6 per batch). REQUIRES a batchDoc.
20
+ - tester — both modes: the readings seat. Runs the verification commands the task book puts in `goal` and hands the readings back as they stand — no verdict, no fix, no document. Tool face: read-only tools plus `execute` / `bash` (dependency installs, compiles and fixtures included), minus `verify`. Run only, never change is a role contract, not a sandbox — `bash` can write, so a tester that edits anything is a defect.
21
+
22
+ Task book, non-engineering roles (explore / plan / coder / tester): five required parameters — a missing, blank or non-string value is refused with it named. A free-text task is an optional supplement, never the whole brief.
23
+ - goal — the goal and why.
24
24
  - knownFacts — the facts you already verified.
25
25
  - acceptance — machine-verifiable criteria.
26
26
  - reportFormat — the delivery-report format.
27
- - scope — scope & forbidden scope: what to read and what not to touch.
27
+ - scope — what to read, and what not to touch.
28
28
 
29
- All five are required: a missing, blank or non-string value is refused with the parameter named. A free-text task is an optional supplement, never the whole brief.
30
-
31
- Engineering roles (eng-coder / eng-designer) take their task book from the batch record, and the part that is their task book differs by seat — no other task text is passed to either:
32
- - batchDoc — the record path. An eng-coder's task book is that record's §2, written and owned by eng-designer; an eng-designer reads the whole record — §1's rulings bind it, and §2 is its own pen.
29
+ Engineering roles take their task book from the batch record; no other task text reaches either:
30
+ - batchDoc — the record path. An eng-coder's task book is that record's §2, written and owned by eng-designer; an eng-designer reads the whole record — §1's rulings bind it, §2 is its own pen.
33
31
  - round — initial | fix.
34
- - files / dependsOn — for scheduling.
35
- - An eng-coder spawn also carries designToken (the write credential) and designId when several designs are open: missing or mismatched = the spawn is refused.
32
+ - files / dependsOn — scheduling.
33
+ - An eng-coder spawn also carries designToken and, when several designs are open, designId.
36
34
 
37
- A record carries one concurrent spawn at a time: a second spawn on a record still in flight is refused, naming the occupant — wait for it to settle, or cancel it. Sequential hand-offs (design → implementation → fix round) pass, because the previous spawn has settled first.
35
+ A record carries one concurrent spawn: a second spawn on a record in flight is refused, naming the occupant. Sequential hand-offs (design → implementation → fix round) pass, because the previous spawn settled first.
38
36
 
39
- Pass one parameter per field — contents only (the runtime adds the labels):
37
+ Pass one parameter per field — contents only, the runtime adds the labels:
40
38
  subagent(role="eng-coder", round="initial", batchDoc="<batch record>", designToken="…", files=[…], async=true)
41
39
  subagent(role="explore", goal="…", knownFacts="…", scope="…", acceptance="…", reportFormat="…", async=true)
42
40
 
43
- Mode filtering: normal mode exposes explore/plan/coder/tester (eng-coder and eng-designer are refused); engineering mode exposes explore/eng-designer/eng-coder/tester (plan and coder are refused — plan is a normal-mode role, coder is replaced by eng-coder; tester is dispatchable in both).
41
+ Mode filtering: normal mode exposes explore / plan / coder / tester; engineering mode exposes explore / eng-designer / eng-coder / tester. A role the mode does not expose is refused (plan is normal-mode only, coder is replaced by eng-coder, tester is dispatchable in both).
44
42
 
45
43
  Async spawn:
46
- - Pass `async: true` — the spawn returns {id, status:"running"} immediately and the report arrives automatically; if your next step needs it, end the turn and let the digest deliver it — do not poll. Omitting `async` is refused, so pass it explicitly.
47
- - Inside subagents (depth>0) spawns are always synchronous — pass `async: false` there (an explicit `async: true` is refused).
44
+ - Pass `async: true` — the spawn returns {id, status:"running"} immediately and the report arrives automatically; if your next step needs it, end the turn and let the digest deliver it. Omitting `async` is refused.
45
+ - At depth>0 spawns are always synchronous: pass `async: false` (an explicit `async: true` is refused).
48
46
 
49
- Pool: async spawns are pooled per role domain — 4 concurrent eng-coders plus 4 concurrent other-role spawns by default (agent.poolLimits overrides both); a full domain queues further spawns with a position while the other keeps starting.
47
+ Pool: async spawns pool per role domain — 4 concurrent eng-coders plus 4 concurrent other-role spawns by default (agent.poolLimits overrides both). A full domain queues with a position while the other keeps starting.
50
48
 
51
- Task scheduling: declare files (the file paths this task will modify) and dependsOn (ids from prior async returns whose outcome this task needs) to let the scheduler order your spawns.
52
- - Overlapping-file tasks serialize and dependents start in order: a conflicting or dependent spawn queues (position/reason) and auto-starts when the conflict clears or the dependency settles (cancel to drop).
53
- - A cancelled/failed dependency leaves it queued marked "dependency cancelled" until you decide. Unknown ids error; a consumed id counts as satisfied.
49
+ Scheduling: declare `files` (the paths this task will modify) and `dependsOn` (ids from prior async returns whose outcome this task needs).
50
+ - Overlapping-file tasks serialize and dependents start in order: a conflicting or dependent spawn queues (position / reason) and auto-starts when the conflict clears or the dependency settles.
51
+ - A cancelled or failed dependency leaves it queued marked "dependency cancelled" until you decide. Unknown ids error; a consumed id counts as satisfied.
54
52
  - Omit both for a plain immediate spawn.
55
53
 
56
- Writing the prompt — the child starts with zero context, so brief it like a colleague who just walked in: goal, what you already know, the specifics.
54
+ The child starts with zero context, so brief it like a colleague who just walked in.
57
55
  - Put exact paths and commands in — do not make it search for what you already know.
58
- - Do not delegate understanding: resolve the paths and the symbols the task hinges on first.
59
- - Once it runs, leave that scope to it — don't redo its searches in parallel or finish manually midway.
56
+ - Do not delegate understanding: resolve the paths and symbols the task hinges on first.
57
+ - Once it runs, leave that scope to it — do not redo its searches in parallel or finish manually midway.
@@ -7,6 +7,8 @@ Statuses: pending | in_progress | done - synonyms (completed/finished/complete,
7
7
  - Mark items done as you complete them; never mark done while tests fail or the work is partial.
8
8
  - title is required and must be non-empty: an item whose title is empty is dropped, and the receipt names it.
9
9
 
10
- Engineering mode: `task` is unavailable - the batch record and the ledger are the tracking authority there. For cross-session / project-level tracking in any mode, use `/ledger`.
10
+ Modes: normal mode (tiny and normal) provides `task` as a lightweight progress checklist only - the batch record and the ledger stay the tracking authority.
11
+ Engineering mode does not provide `task` - the tool is not in that mode's tool table, so its description is not assembled into engineering contexts.
12
+ A pending item neither triggers a completion push-back nor extends the turn. For cross-session / project-level tracking in any mode, use `/ledger`.
11
13
 
12
14
  Returns a one-line receipt - `Task list updated: N/M done` - plus a warning naming every status or title that was normalized or dropped.
@@ -6,6 +6,10 @@ It is a separate book from the local `ledger` - two independent accounts, no syn
6
6
  - `query`: `scope` = `"repo"` (default - the current repo) / `"team"` (every repo in the team); filters `status` (one of the six states `待讨论` / `待设计` / `在途` / `待核销` / `已核销` / `已废弃`) and `owner` (exact username). Each row carries `aged` when it sits in an unsettled state and is older than 30 days.
7
7
  - `count`: the same filters as `query`, and returns the total.
8
8
  - `add`: `title` required (non-blank, ≤200), `detail` (≤4000), `owner` (default = yourself). A new entry always lands in `待讨论`.
9
- - `update`: `id` required; at least one of `title` / `detail` / `owner` / `status`. `status` moves along the same six-state table as the local ledger - `待讨论→待设计` / `待讨论→在途` / `待设计→在途` / `在途→待核销` / `待核销→已核销` / `待核销→在途` / any state but `已废弃` → `已废弃` (`已废弃` has no way out); any edge off that list is refused.
9
+ - `update`: `id` required; `title` / `detail` / `owner` / `status` are each optional, and an omitted one stays unchanged. The client checks nothing beyond `id` — an `update` that changes no field is still sent, and the server alone judges the result.
10
+ `status` is judged by the server, not by this client: the client sends the target state and an illegal edge comes back as a 400.
11
+ The local `ledger` tool's own table allows `待讨论→待设计` / `待讨论→在途` / `待设计→在途` / `在途→待核销` / `在途→待讨论` /
12
+ `待核销→已核销` / `待核销→在途` / `待核销→待讨论` / `待讨论→已废弃` / `待设计→已废弃` / `在途→已废弃` / `待核销→已废弃`,
13
+ and there `已核销` and `已废弃` are both final; this book's server table is not readable from here, so take that list as the client-side reference, not as a copy of the server's.
10
14
  - `close`: `id` + `status` (`已核销` / `已废弃`). `已核销` settles, and only from `待核销` - from any other state it is refused, and the way out is to `update` that entry to `待核销` first. `已废弃` withdraws an entry from any non-archived state.
11
15
  - Login gate: not logged in ⇒ the call fails with a message saying so, and sends no request; 401 (token expired) ⇒ login expired, log in again; server unreachable ⇒ reported as such, with no offline fallback: a retry never serves an old value.
@@ -7,8 +7,10 @@ Use it to see quickly which modules exist and where files live. Skips dotfiles,
7
7
  Parameters:
8
8
  - path: Root directory (default cwd)
9
9
  - depth: Tree depth (default 3, max 6)
10
+ - includeProcessDocs: include docs from process layers (batch records, archived material) - excluded by default; pass `true` to get them back
10
11
 
11
12
  Notes:
12
13
  - Returns the tree as text: directories first (each ending with `/`), files after, both sorted, capped at 200 entries.
13
14
  - Tree-drawing uses `├──`/`└──`/`│`.
15
+ - A file row carries its layer label after the name (`TOOLS.md [design]`); directory rows carry none and process-layer directories stay reachable. When file rows from process layers are excluded (or included on request), a final line reports how many; excluded rows spend none of the 200-entry cap.
14
16
  - Use depth for a shallow overview; use `ls` for one directory, `glob` for a specific file pattern.