@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,62 +1,73 @@
1
1
  aliases: 台账, 待办, 项目记录
2
2
  ## Ledger — the project's todo book
3
- **What it is**: the project's **todo book** — a **requirement pool** (user requirement points) plus **tech todos** (engineering debt); persists across sessions, and it is the **only todo-tracking surface** (checklist retired).
4
- **Where it lives**: keyed by **project root**, stored in the **user data directory** (outside the work tree — in the tree it travels with every clone and disappears with the project tree; no file left in the project); an empty read = that project has no ledger yet (the first write creates it).
5
- **Six states**: 待讨论 → 待设计 → 在途 → 待核销 (the four **unsettled states**); **已核销 / 已废弃 = archive states** (soft delete — settled entries leave the unsettled surface).
6
- **Who reads / writes**: **reads = every role** (`ledger` (action=query/count); `cwd` defaults to the session project root — pass an absolute path to touch another project); **writes = the main agent only** (subagent tool assemblies carry no write command).
7
- **Subagent view**: the ledger is your **input** (this batch's entries come with the spawn), **not your write surface** — new findings go back to your parent, which books them.
8
- **A note is not a ledger**: an **unresolved** gap / difference / limitation resting in prose, comments or inline notes is seen by nobody and cashed by nobody — fix it, surface it upward, or get it booked, so it lands on a **visible todo surface**.
9
- A "noted on the record" registration inside a doc is valid **only for ruled items** (judgment + reasons + resolution window).
10
- **Anchors & detail**: entries hang on **pointers** (requirement-doc section / batch-record section / evidence line).
3
+ Use the ledger as the project's only todo-tracking surface.
4
+ It contains the requirement pool for user requirement points and tech todos for engineering debt, and persists across sessions.
5
+ Store it by project root in the user data directory, outside the work tree; leave no ledger file in the project.
6
+ An empty read means no ledger exists yet; the first write creates it.
7
+ Use six states: 待讨论 → 待设计 → 在途 → 待核销 are unsettled; 已核销 and 已废弃 are archive states.
8
+ Every role may read with `ledger` `action=query/count`.
9
+ `cwd` defaults to the session project root; pass an absolute path for another project.
10
+ Only the main agent writes ledger rows; subagent assemblies have no write command.
11
+ Treat the ledger as a subagent's input, not its write surface; send new findings to the parent for booking.
12
+ Fix, escalate or book every unresolved gap, difference or limitation instead of leaving it only in prose, comments or inline notes.
13
+ Use an in-document "noted on the record" registration only for ruled items with judgment, reasons and a resolution window.
14
+ Anchor entries to requirement-doc sections, batch-record sections or evidence lines.
11
15
 
12
16
  ## Batch record — the carrier of task flow
13
- **What it is**: the **batch record** = the **carrier** of task flow — the single file threading one implementation round from start to closeout.
14
- The path is the one your task book carries (`batchDoc`) — the project declares where its batch records live, so never guess a path (relative paths resolve against the session cwd first, then candidate project roots, or absolute).
15
- A hard-coded path breaks the moment the batch record moves.
16
- **Disposable by design — it may be cleaned up at any time**: a batch record is a **one-off execution record**; the whole set **must be deletable at any moment**.
17
- **⚠️ Deletable ≠ delete-after-every-round** — nothing in this mechanism deletes a record automatically; tend to it **when the cost of keeping it outweighs its value**, e.g. it has been polluted and repairing it costs more than dropping it.
18
- **A batch record may be dropped whole**: anything that must outlive the round lives in the requirement/design docs.
19
- Dropping one is a maintainer's decision; no schedule does it.
20
- **Practical consequence**: no mechanism, a decision or a criterion lives only there — it can be dropped whole, and whatever lives only there disappears with it; if deleting every batch record would lose something, that something is in the wrong document.
21
- Cited only from batch records to spec docs, and not the reverse — a spec doc that cites a batch record breaks the moment the record is deleted.
22
- **Mode scope**: the documentation system is the same across all modes; the difference from engineering mode = whether strong process constraints apply.
23
- **Six-segment map (one segment, one author)**: §1 discussion = the main agent.
24
- §2 batch task & design = eng-designer (engineering) ∥ the main agent (normal) · §3 design review findings = the review subagent (advisor).
25
- §4 user approval = the main agent · §5 implementation record = eng-coder (engineering) ∥ the implementer (normal — the main agent working directly ∥ a coder taking it on).
26
- §6 verification & closeout = the main agent (the parent, as seen by subagents).
27
- **Writing means**: the `batch` tool — **no path parameter** (the target record is bound to you at spawn); **the segment number follows from your identity**; if the write does not land ⇒ say "§× not written" plainly in your report.
28
- **The task book itself**: `batchDoc` = the batch-record path — §2 of that record for eng-coder, the whole record for eng-designer (mandatory on every eng-designer / eng-coder spawn); unreadable ⇒ refused — executing without it runs a whole round on a guessed direction, so bounce it back.
29
- **This section maps the segments only**: each segment and its author — structure rules, gates and the lifecycle are not restated here.
30
- **Per repo, its own record**: batch records live in their own repo — the base root resolves from the session anchor's project declaration.
31
- **A cross-repo create is refused — that is the correct behavior**, because a cross-repo record cannot be created or closed and a workaround only produces an account that does not exist.
32
- A task spanning several repos ⇒ **each repo gets its own record and its own batch**.
33
- ## Doc vs process — state goes in the state doc, process in the process doc
34
- **Process lives in the process doc; state lives in the state doc** — a mixed doc makes the reader work out which value is still alive.
35
- The **process doc = the batch record** — how this one round was run.
36
- The **state doc = requirement docs / design docs** — what is true now, and how it is built now.
37
- **A state doc** states what is true now. History lives in git; a past value left in the doc is retrieved as current guidance.
38
- **Why (three layers — miss one and you get the boundary cases wrong)**:
39
- ① **Reader side** — a state doc's reader is always asking "what is it **now**"; hand them a run of historical values and they must work out which one is still alive = **their judgment wasted**.
40
- ② **Retrieval side** — a stale value gets retrieved and **read as the current way** ⇒ this is not tidiness, it is **error propagation**.
41
- ③ **Lifetime side** — a state doc **lives long**; what goes in **cannot be cleaned out**. A process doc **can be cleaned up whole** (a maintainer may drop an entire record without losing normative content) ⇒ process has to live there to be **cleanable at all**.
42
- **The test is one question**: *would this sentence still mean something once this round is over?* Yes ⇒ it is state; keep it. No ⇒ it is process; delete it.
43
- **Process (delete-eligible in a state doc)**: symptom · root cause · problem statement · reproduction · trial readings · experimental rejection details · change trail · superseded values.
17
+ Use one batch record to carry one implementation round from start through closeout.
18
+ Take its path from `batchDoc`; resolve relative paths against session cwd first, then candidate project roots, or use an absolute path.
19
+ Never guess or hard-code the batch-record location.
20
+ Treat every batch record as disposable execution history that a maintainer may delete whole.
21
+ Do not delete records automatically or after every round.
22
+ Tend to one when keeping it costs more than its value, such as when repair costs more than dropping a polluted record.
23
+ Keep every lasting mechanism, decision and criterion in requirement or design docs so deleting all batch records loses nothing.
24
+ Only batch records cite spec docs, never the reverse.
25
+ Use the same documentation system in all modes; engineering mode adds strong process constraints.
44
26
 
45
- **State (keep)**: the current rule · current value · current contract · current acceptance criterion · current boundary · decision + its one-line reason · design-level rejected alternatives and their lasting reasons.
27
+ Assign one author to each segment:
28
+ - §1 discussion: main agent.
29
+ - §2 batch task and design: eng-designer in engineering mode; main agent in normal mode.
30
+ - §3 design review findings: review subagent (advisor).
31
+ - §4 user approval: main agent.
32
+ - §5 implementation record: eng-coder in engineering mode; the implementer in normal mode, whether main agent or coder.
33
+ - §6 verification and closeout: main agent, called the parent by subagents.
46
34
 
47
- Mechanism-body sentences, directory-ownership sentences, template / placeholder forms, and a date that is part of a rule also stay.
48
- **Common sense — every mode and every role**: this is not an engineering-mode rule; the same split holds in normal mode and for every role that writes a doc.
35
+ Write each segment only during its own step:
36
+ | Segment | Written |
37
+ |---|---|
38
+ | §1 | while discussion runs; record a ruling in its turn |
39
+ | §2 | at design time |
40
+ | §3 | at the end of each review round |
41
+ | §4 | when the user approves |
42
+ | §5 | when implementation is delivered |
43
+ | §6 | only at closeout; keep it empty before then |
49
44
 
50
- ## Work structure (board → domain → file)
45
+ Write through the `batch` tool without a path parameter.
46
+ The spawn binds the target record and your identity determines the segment.
47
+ If a write fails, state "§× not written" plainly in your report.
48
+ `batchDoc` is mandatory for every eng-designer and eng-coder spawn.
49
+ For eng-coder, §2 is the task book; for eng-designer, the whole record is.
50
+ Refuse and bounce back an unreadable task book.
51
+ Keep each repo's records in that repo, resolving the base root from the session anchor's project declaration.
52
+ Refuse cross-repo creation.
53
+ Give each repo its own record and batch when work spans repositories.
51
54
 
52
- **Work structure (code tree ∥ doc tree) comes in three tiers: board → domain → file** — board = a business board; domain = a directory (the **concurrency-isolation unit**); file = a single file.
55
+ ## Doc vs process — state goes in the state doc, process in the process doc
56
+ Put process in the batch record and current state in requirement and design docs.
57
+ State docs answer what is true and how the system is built now; keep historical values in git.
58
+ Use this test: if a sentence remains meaningful after the round, keep it as state; otherwise treat it as process.
59
+ Remove process material from state docs: symptoms, root causes, problem statements, reproductions, trial readings, experimental rejection details, change trails and superseded values.
60
+ Keep current rules, values, contracts, acceptance criteria, boundaries, decisions with one-line reasons, and rejected design alternatives with lasting reasons.
61
+ Keep mechanism bodies, directory ownership, template and placeholder forms, and dates that form part of a rule.
62
+ Apply this split in every mode and every doc-writing role.
53
63
 
54
- **Why domains**: the root of write conflicts = two pieces of parallel work editing the same set of files — overwriting each other, stepping on each other, rework.
55
- **How to draw domains**: things that always move together ⇒ one document; things that never move together ⇒ separate.
56
- Split this way, and parallel work stays in separate domains without interfering; **get the domains right, and parallel write conflicts stay low enough** — get them wrong, and the conflict only surfaces at runtime.
64
+ ## Work structure (boards, domains and files)
57
65
 
58
- **Four rules**:
59
- - **① Domain = the concurrency-isolation unit**: parallel work moves within its own domains — no pull between domains; a piece of work lands only in its own domain.
60
- - **② Stand the domain directory up from day one** (even with a single file inside): starting late = existing files must move — moving = path churn + broken references; stand it up first, and later splits never move what is already there.
61
- - **③ Splits always land inside the domain**: new files go into the same domain directory — **zero cross-domain churn ∥ zero path rearrangement**, zero disturbance outside the domain.
62
- - **④ Code tree and doc tree move in step**: modules mirrored — when the code splits out a module, the doc tree splits out the matching domain at the corresponding position; the two trees keep one module structure.
66
+ Organize code and doc trees as boards, domains and files.
67
+ A board is a business board, a domain is a directory and concurrency-isolation unit, and a file is one file.
68
+ Put things that always move together in one document and separate things that do not.
69
+ Follow four rules:
70
+ - **① Domain = the concurrency-isolation unit**: keep parallel work inside its own domains and land each piece only in its domain.
71
+ - **② Stand the domain directory up from day one**, even with one file, so later splits do not move existing paths.
72
+ - **③ Keep splits inside the domain**: put new files in the same domain directory and avoid cross-domain path churn.
73
+ - **④ Move code and doc trees in step**: when code gains a module, create the matching doc domain at the corresponding position.
@@ -1,18 +1,17 @@
1
1
  aliases: 补丁, 多档修改, 批量写盘
2
- **Use it for whole-file and multi-file changes:** creating MULTIPLE new files at once (`--- /dev/null` header per file), whole-file replacement, and cross-file refactors — one unified-diff call covers the whole change. A batched call is one permission ask and one turn instead of N separate calls.
2
+ **Use it for whole-file and multi-file changes**: creating several new files at once (`--- /dev/null` header per file), whole-file replacement, and cross-file refactors — one unified-diff call covers the whole change.
3
+ All-or-nothing: every hunk is checked before anything is written, one permission ask and one turn instead of N separate calls.
3
4
 
4
5
  Parameters:
5
- - patch (required): Unified diff text. One `--- a/path` / `+++ b/path` header pair per file, then `@@ -old,count +new,count @@` hunks. Use `--- /dev/null` to create a new file. The `+++ b/path` pair may be omitted for existing files — a lone `--- a/path` (or `--- b/path`) header followed directly by hunks applies to that path (new files still need `--- /dev/null` + `+++ b/path`).
6
+ - patch (required): unified diff text. One `--- a/path` / `+++ b/path` header pair per file, then `@@ -old,count +new,count @@` hunks. `--- /dev/null` creates a new file. The `+++ b/path` pair may be omitted for existing files — a lone `--- a/path` (or `--- b/path`) header followed directly by hunks applies to that path; new files still need `--- /dev/null` + `+++ b/path`.
7
+ - ledger: the in-flight ledger row this call serves — `"#N"` or `"N"`.
8
+ - project: the project root holding `PROJECT-MANIFEST.json` (absolute or cwd-relative).
6
9
 
7
10
  Notes:
8
- - Hunk header "@@" without coordinates is accepted: a coordinate-less hunk is located by its context and removed (-) lines and applies only on a unique match. A pure-addition hunk needs at least 2 context lines; a hunk that removes something is anchored by that sequence, so one context line is enough.
9
- - Returns the applied-file summary (`Applied patch to N file(s)` plus per-file change lines and syntax-check notes for changed .mjs files)
10
- - A failure in the write phase reports every file block in patch order (`modified` / `created` / `not committed`),
11
- the block that failed as `<path> — failed: <reason>`, and a final line
12
- `apply_patch: <k>/<M> file(s) applied, <M−k> failed` plus the committed paths.
13
- Files already committed stay on disk and are never rolled back.
14
- - Use this for multi-file changes (e.g. rename an interface + update all callers) — one call, every hunk is checked before anything is written
15
- - Hunks are located by their context/removed lines, not line numbers — but the context must match the file EXACTLY. Read the files first and generate the patch from actual content
16
- - If a hunk's context matches multiple locations it is rejected — add more surrounding context lines
17
- - Deleting files is not supported — use the delete tool
18
- - For single-file edits, edit is simpler; for full rewrites, write is simpler
11
+ - A hunk header `@@` without coordinates is accepted: that hunk is located by its context and removed (-) lines and applies only on a unique match.
12
+ A pure-addition hunk needs at least 2 context lines. A hunk that removes at least one line is anchored by those removed lines,
13
+ so it may carry no context at all — a context line is a courtesy there, not a requirement.
14
+ - Hunks are located by context and removed lines, not line numbers, and the context must match the file EXACTLY: read the files first and build the patch from actual content. A context matching several locations is rejected — add surrounding lines.
15
+ - For one file, `edit` is simpler; to rewrite a file whole, `write` is simpler. Deleting files is not supported — use `delete`.
16
+ - Returns the applied-file summary (`Applied patch to N file(s)`, per-file change lines, syntax-check notes for changed .mjs files).
17
+ - A failure in the write phase reports every file block in patch order (`modified` / `created` / `not committed`), the failed block as `<path> — failed: <reason>`, and a final line `apply_patch: <k>/<M> file(s) applied, <M−k> failed` plus the committed paths. Files already committed stay on disk and are never rolled back.
@@ -12,8 +12,12 @@ Use for running commands, builds, tests.
12
12
  Parameters:
13
13
  - command (required): Shell command to execute
14
14
  - timeout: Timeout in milliseconds (default 120000 for synchronous runs; background runs have no default — an explicit timeout still applies; no upper bound)
15
- - filter: Optional — a regex; only output lines matching it are returned (case-insensitive). Use instead of hand-writing a pipe into `findstr`/`grep`.
15
+ - filter: Optional — a regex; only output lines matching it are returned (case-insensitive). Synchronous runs only: a background run has no result to filter, so it returns a note and you grep its log instead.
16
+ Use it instead of hand-writing a pipe into `findstr`/`grep`.
16
17
  - async: Run in the background (default false) — returns an ack at once (bash#<id>, log path); the result arrives as a digest when the process exits. Depth-0 only.
18
+ - ledger: the in-flight ledger row this call serves — `"#N"` or `"N"`.
19
+ - project: the project root holding `PROJECT-MANIFEST.json` (absolute or cwd-relative).
20
+ `bash` has no locating parameter of its own, and `project` does not change where the command runs.
17
21
 
18
22
  Output format:
19
23
  ```
@@ -29,11 +33,16 @@ Output format:
29
33
  Notes:
30
34
  - There is NO TTY — editors, pagers (vim, less), and interactive prompts WILL hang. Always pass non-interactive flags: `git commit -m`, `git --no-pager`, `-y`/`--yes` where applicable
31
35
  - The environment sets GIT_PAGER=cat, PAGER=cat, EDITOR=true, TERM=dumb — but still always use non-interactive flags
32
- - Output is capped at ~200K chars; if you need more, redirect to a file and read it. Truncated output ends with a `[... truncated: N chars omitted]` marker — the missing tail may contain errors, so read the saved log file's tail before trusting success. Use `filter` to narrow instead of hand-piping.
36
+ - Output is capped twice, in characters, by two independent limits. Each stream (stdout and stderr) keeps accumulating only while its buffer is under 2,000,000 characters; beyond that the rest of that stream is dropped with no notice.
37
+ The assembled result is then cut to 200,000 characters, and a cut result ends with `[... truncated: N chars omitted — redirect to a file if you need the full output]`, where N counts what this second cut removed.
38
+ The missing tail may contain errors, so read the saved log file's tail before trusting success.
39
+ Use `filter` to narrow instead of hand-piping.
40
+ Redirecting to a file to rescue a large output is one of the two exceptions to the NEVER rule at the end of this list: those bytes come from the command, not from you.
33
41
  - Check `[stderr]` for error messages, warnings, and diagnostic output — it is separated from `[stdout]` so you can quickly identify problems.
34
- - Shell identity: the bash tool's shell is NOT fixed — it depends on configuration and environment. The current executor is declared in the Executor line above; write commands for THAT shell, and when a command fails read its error output to identify the actual shell.
42
+ - Shell identity: the bash tool's shell is NOT fixed — it depends on configuration and environment. The current executor is declared in the session head's `Shell:` item, together with the version it reports; write commands for THAT shell, and when a command fails read its error output to identify the actual shell.
35
43
  - Never use bash to read, copy, or transmit secret files (.env, keys, tokens)
36
44
  - Do NOT run destructive commands (rm -rf, force-push, drop table) without explicit user confirmation
37
45
  - After commands that change files (git checkout, npm install, etc.), repo_outline and code_search may be stale — re-run them to get current results.
38
46
  - Prefer read/glob/grep/ls for file operations inside the project — file tools and bash reach the same paths (no directory restriction).
39
- - NEVER use bash to write or modify files (echo/sed/printf > file, cat << EOF, etc.). Use write/edit/insert_after/apply_patch instead — they handle encoding, escaping, and EOL conventions correctly.
47
+ - NEVER write or modify file CONTENT through bash (`echo > file`, `sed -i`, `printf >`, heredoc, …). Use write/edit/insert_after/apply_patch instead — they handle encoding, escaping, and EOL conventions correctly.
48
+ Two things this rule does not forbid: redirecting a command's own output to a file to rescue a large result (see the output-cap note above), and `bash mkdir`, which creates a directory and writes no content.
@@ -1,12 +1,19 @@
1
1
  aliases: 批次档, 实施记录, 工程实施
2
- Three steps: `append` (add text to the END of §5), `edit` (replace one anchored range inside it), `status` (your section's status line).
2
+ Three write steps: `append` (add text to the END of §5), `edit` (replace one anchored range inside it), `status` (§5's status line).
3
3
 
4
- The record is the one bound to this spawn; its path arrives with the spawn, so there is no path parameter — one record serves one concurrent spawn, and yours is the in-flight one you were given.
4
+ The record is the one bound to this spawn and its path arrives with the spawn, so there is no path parameter — one record serves one concurrent spawn, and yours is the in-flight one you were given.
5
5
 
6
- - `append` — `text` goes to the end of §5. Limit 20000 characters per call; longer is refused, so split it. A line that STARTS with the status-line form (`**状态行**:…`) is refused: that line has exactly one writer (`status`). Quote it with a leading `> `, or write prose. The implementation record is where the delivery summary, the decision-disclosure table, the audit and review rounds and the terminal state land — write it as the round actually ran.
6
+ `read` is on this face too and writes nothing: with no `segment` it returns the record's section index, and with `segment` + `offset` one window of that section (1-based, at most 200 lines; the receipt names the next `offset`).
7
+ It reads the whole record, not only §5 — §1 carries the rulings and §2 the task book.
8
+
9
+ - `append` — `text` goes to the end of §5. Limit 20000 characters per call; longer is refused, so split it.
10
+ A line that STARTS with the status-line form (`**状态行**:…`) is refused: no channel adds such a line here,
11
+ and this channel may only make such lines fewer, never more.
12
+ Quote it with a leading `> `, or write prose.
13
+ The delivery summary, the decision-disclosure table, the audit and review rounds and the terminal state land here — write it as the round actually ran.
7
14
  - `edit` — `oldText` must match exactly once, byte for byte, inside §5; `newText` replaces it (empty `newText` deletes it). Refused with nothing written: a blank `oldText`, zero hits, two or more hits (the matching lines are named), an anchor crossing the section boundary, an anchor touching the protected status line, and a replacement that would introduce a status line or leave more of them than before.
8
- - `status` — `value` carries exactly ONE legal keyword of §5's own word list (`实施完成`) plus decoration (surrounding symbols, a trailing ISO date, whitespace); prose goes to `note` and lands as a parenthetical.
15
+ - `status` — `value` carries exactly ONE legal keyword of §5's word list — `进行中` (in flight) or `实施完成` (that section's done word) — plus decoration (surrounding symbols, a trailing ISO date, whitespace); prose goes to `note` and lands as a parenthetical.
9
16
 
10
- `segment` names the section you are writing — `"§5"` is this face's pen. Everything else on the record belongs to another author: §1 discussion, §2 design, §3 design review findings, §4 user approval and §6 verification are written by their own seats, and writing them is refused.
17
+ `segment` names the section you write — `"§5"` is this face's pen. Everything else belongs to another author: §1 discussion, §2 design, §3 design review findings, §4 user approval and §6 verification are written by their own seats, and writing them is refused.
11
18
 
12
- The record is a process document: it can be dropped whole once the round closes, so nothing normative may live only in it — a rule that must outlive the round belongs in the design document.
19
+ The record is a process document, droppable whole once the round closes, so nothing normative may live only in it — a rule that must outlive the round belongs in the design document.
@@ -1,12 +1,20 @@
1
1
  aliases: 批次档, 设计段, 工程设计
2
- Three steps: `append` (add text to the END of §2), `edit` (replace one anchored range inside it), `status` (your section's status line).
2
+ Three write steps: `append` (add text to the END of §2), `edit` (replace one anchored range inside it), `status` (§2's status line).
3
3
 
4
- The record is the one bound to this spawn; its path arrives with the spawn, so there is no path parameter — one record serves one concurrent spawn, and yours is the in-flight one you were given.
4
+ The record is the one bound to this spawn and its path arrives with the spawn, so there is no path parameter — one record serves one concurrent spawn, and yours is the in-flight one you were given.
5
5
 
6
- - `append` — `text` goes to the end of §2. Limit 20000 characters per call; longer is refused, so split it. A line that STARTS with the status-line form (`**状态行**:…`) is refused: that line has exactly one writer (`status`). Quote it with a leading `> `, or write prose.
6
+ `read` is on this face too and writes nothing: with no `segment` it returns the record's section index, and with `segment` + `offset` one window of that section (1-based, at most 200 lines; the receipt names the next `offset`).
7
+ It reads the whole record, not only §2 — §1 carries the rulings and §3 the previous round.
8
+
9
+ - `append` — `text` goes to the end of §2. Limit 20000 characters per call; longer is refused, so split it.
10
+ A line that STARTS with the status-line form (`**状态行**:…`) is refused: no channel adds such a line here,
11
+ and this channel may only make such lines fewer, never more.
12
+ Quote it with a leading `> `, or write prose.
7
13
  - `edit` — `oldText` must match exactly once, byte for byte, inside §2; `newText` replaces it (empty `newText` deletes it). Refused with nothing written: a blank `oldText`, zero hits, two or more hits (the matching lines are named), an anchor crossing the section boundary, an anchor touching the protected status line, and a replacement that would introduce a status line or leave more of them than before.
8
- - `status` — `value` carries exactly ONE legal keyword of §2's own word list (`设计完成`) plus decoration (surrounding symbols, a trailing ISO date, whitespace); prose goes to `note` and lands as a parenthetical. Reading a section's status needs exactly one status line in its header zone — with two or more it reads as unset and `status` refuses, naming the repair order.
14
+ - `status` — `value` carries exactly ONE legal keyword of §2's word list — `进行中` (in flight) or `设计完成` (that section's done word) — plus decoration
15
+ (surrounding symbols, a trailing ISO date, whitespace); prose goes to `note` and lands as a parenthetical.
16
+ Reading a status needs exactly one status line in the header zone — with two or more it reads as unset and `status` refuses, naming the repair order.
9
17
 
10
- `segment` names the section you are writing — `"§2"` is this face's pen. Everything else on the record belongs to another author: §1 discussion, §3 design review findings, §4 user approval, §5 implementation record and §6 verification are written by their own seats, and writing them is refused.
18
+ `segment` names the section you write — `"§2"` is this face's pen. Everything else belongs to another author: §1 discussion, §3 design review findings, §4 user approval, §5 implementation record and §6 verification are written by their own seats, and writing them is refused.
11
19
 
12
- The record is a process document: it can be dropped whole once the round closes, so nothing normative may live only in it.
20
+ The record is a process document, droppable whole once the round closes, so nothing normative may live only in it.
@@ -1,12 +1,18 @@
1
1
  aliases: 批次档, 评审轮次, 评审结论
2
- Three steps: `append` (add a round to the END of §3), `edit` (replace one anchored range inside it), `status` (your section's status line).
2
+ Three write steps: `append` (add a round to the END of §3), `edit` (replace one anchored range inside it), `status` (§3's status line).
3
3
 
4
- The record is the one bound to this review instance; its path arrives with the instance key, so there is no path parameter.
4
+ The record is the one bound to this review instance and its path arrives with the instance key, so there is no path parameter.
5
5
 
6
- - `append` — a design-review round belongs here: one row per finding (`#` / severity / status / evidence) where the evidence cell holds a pointer — a section number, a symbol name, or the exact words of the line — plus the VERDICT line and the counts. The report's own paragraphs stay out of the record. The round heading (`### 轮次 N(评审子代理)`) is generated by the tool — do not write your own; it would be dropped. Limit 20000 characters per call. A line that STARTS with the status-line form (`**状态行**:…`) is refused: that line has exactly one writer (`status`).
6
+ `read` is on this face too and writes nothing: with no `segment` it returns the record's section index, and with `segment` + `offset` one window of that section (1-based, at most 200 lines; the receipt names the next `offset`).
7
+ It reads the whole record, not only §3 — §1 carries the rulings and §2 the task book this review judges.
8
+
9
+ - `append` — a design-review round belongs here: one row per finding (`#` / severity / status / evidence), the evidence cell holding a pointer — a section number, a symbol name, or the exact words of the line — plus the VERDICT line and the counts.
10
+ The report's own paragraphs stay out. The round heading (`### 轮次 N(评审子代理)`) is tool-generated; do not write your own, it would be dropped. Limit 20000 characters per call.
11
+ A line that STARTS with the status-line form (`**状态行**:…`) is refused: no channel adds such a line here,
12
+ and this channel may only make such lines fewer, never more.
7
13
  - `edit` — `oldText` must match exactly once, byte for byte, inside §3; `newText` replaces it (empty `newText` deletes it). Refused with nothing written: a blank `oldText`, zero hits, two or more hits, an anchor crossing the section boundary, an anchor touching the protected status line, and a replacement that would introduce a status line or leave more of them than before.
8
- - `status` — `value` carries exactly ONE legal keyword of §3's own word list (`评审通过`) plus decoration (surrounding symbols, a trailing ISO date, whitespace); prose goes to `note` and lands as a parenthetical.
14
+ - `status` — `value` carries exactly ONE legal keyword of §3's word list — `进行中` (in flight) or `评审通过` (that section's done word) — plus decoration (surrounding symbols, a trailing ISO date, whitespace); prose goes to `note` and lands as a parenthetical.
9
15
 
10
- `segment` names the section you are writing — `"§3"` is this face's pen. Everything else on the record belongs to another author: §1 discussion, §2 design, §4 user approval, §5 implementation record and §6 verification are written by their own seats, and writing them is refused.
16
+ `segment` names the section you write — `"§3"` is this face's pen. Everything else belongs to another author: §1 discussion, §2 design, §4 user approval, §5 implementation record and §6 verification are written by their own seats, and writing them is refused.
11
17
 
12
- A finding enters the record only with a pointer that resolves — an evidence cell that points at nothing is a reading, not proof that the thing exists.
18
+ A finding enters the record only with a pointer that resolves — an evidence cell pointing at nothing is a reading, not proof the thing exists.