@iowarp/clio-coder 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/CHANGELOG.md +407 -0
  2. package/CODE_OF_CONDUCT.md +21 -0
  3. package/CONTRIBUTING.md +224 -0
  4. package/LICENSE +202 -0
  5. package/NOTICE +9 -0
  6. package/README.md +798 -0
  7. package/SECURITY.md +72 -0
  8. package/assets/clio-coder-logo-128.webp +0 -0
  9. package/damage-control-rules.yaml +419 -0
  10. package/dist/acp-UMLFVA3F.js +92 -0
  11. package/dist/agents-Q4MYPMUW.js +91 -0
  12. package/dist/auth-O6HYIJ6J.js +521 -0
  13. package/dist/chunk-262G75JS.js +35 -0
  14. package/dist/chunk-26BZQOAD.js +1281 -0
  15. package/dist/chunk-2J63S4SF.js +508 -0
  16. package/dist/chunk-3DANZDGR.js +717 -0
  17. package/dist/chunk-4UQA7NCT.js +29 -0
  18. package/dist/chunk-527KG6XR.js +497 -0
  19. package/dist/chunk-5LDRNKX2.js +1063 -0
  20. package/dist/chunk-5N2FG33Q.js +25 -0
  21. package/dist/chunk-67MTHP2E.js +135 -0
  22. package/dist/chunk-6CWDTGUC.js +20 -0
  23. package/dist/chunk-7BHLZB3A.js +2115 -0
  24. package/dist/chunk-7RBKDI66.js +348 -0
  25. package/dist/chunk-AMFR5YA3.js +541 -0
  26. package/dist/chunk-BBUH4VAA.js +1224 -0
  27. package/dist/chunk-BYEU76JP.js +899 -0
  28. package/dist/chunk-CLJ5HLUD.js +458 -0
  29. package/dist/chunk-D5YD55AR.js +116 -0
  30. package/dist/chunk-DXQNI4PC.js +61 -0
  31. package/dist/chunk-E3NYWENM.js +1004 -0
  32. package/dist/chunk-GNGDQYDU.js +34688 -0
  33. package/dist/chunk-GOTUR54M.js +9 -0
  34. package/dist/chunk-HBU5MTAM.js +41 -0
  35. package/dist/chunk-HMYNFFY4.js +28 -0
  36. package/dist/chunk-JPOWPFCU.js +1010 -0
  37. package/dist/chunk-JWHCJDCI.js +1215 -0
  38. package/dist/chunk-KBR4MZZR.js +41 -0
  39. package/dist/chunk-KKKPTZLM.js +93 -0
  40. package/dist/chunk-ME6DNWIU.js +66 -0
  41. package/dist/chunk-NI4DEJMC.js +88 -0
  42. package/dist/chunk-O4EJEDHO.js +659 -0
  43. package/dist/chunk-PIDUD6M2.js +31 -0
  44. package/dist/chunk-PS4PFJQP.js +29459 -0
  45. package/dist/chunk-QV47YRF4.js +48 -0
  46. package/dist/chunk-RQDWMVRB.js +279 -0
  47. package/dist/chunk-TFSSEXL6.js +136 -0
  48. package/dist/chunk-TKHQ4DGZ.js +8290 -0
  49. package/dist/chunk-TPOCL34A.js +2876 -0
  50. package/dist/chunk-UGYAX5YI.js +565 -0
  51. package/dist/chunk-UHTSULZS.js +461 -0
  52. package/dist/chunk-UU3R62TT.js +128 -0
  53. package/dist/chunk-UWIJNAOB.js +3906 -0
  54. package/dist/chunk-VOO7NYPP.js +914 -0
  55. package/dist/chunk-VPAWTYLY.js +117 -0
  56. package/dist/chunk-WD6AJM35.js +1216 -0
  57. package/dist/chunk-X3BR7HWV.js +115 -0
  58. package/dist/chunk-X3NE4WVW.js +120 -0
  59. package/dist/chunk-XNISANGE.js +1395 -0
  60. package/dist/chunk-XV4ZJ6ZM.js +3177 -0
  61. package/dist/cli/index.js +236 -0
  62. package/dist/clio-KIQ5SNDS.js +53 -0
  63. package/dist/components-JVHMUBEB.js +653 -0
  64. package/dist/config-ZFCDBMDC.js +372 -0
  65. package/dist/configure-G4E3A2PG.js +27 -0
  66. package/dist/context-CDXTP2MP.js +293 -0
  67. package/dist/context-E3KIFVXI.js +185 -0
  68. package/dist/context-clear-3F4PLXOS.js +102 -0
  69. package/dist/context-index-Q7YSYTR3.js +106 -0
  70. package/dist/docs-YIETIWZI.js +280 -0
  71. package/dist/doctor-M5HJJZOL.js +61 -0
  72. package/dist/domains/agents/builtins/architect.md +33 -0
  73. package/dist/domains/agents/builtins/coder.md +31 -0
  74. package/dist/domains/agents/builtins/context-bootstrap.md +38 -0
  75. package/dist/domains/agents/builtins/debugger.md +30 -0
  76. package/dist/domains/agents/builtins/documenter.md +31 -0
  77. package/dist/domains/agents/builtins/git-master.md +30 -0
  78. package/dist/domains/agents/builtins/provenance.md +30 -0
  79. package/dist/domains/agents/builtins/researcher.md +71 -0
  80. package/dist/domains/agents/builtins/scout.md +42 -0
  81. package/dist/domains/agents/builtins/tester.md +31 -0
  82. package/dist/domains/agents/builtins/verifier.md +30 -0
  83. package/dist/domains/agents/builtins/wiki-writer.md +41 -0
  84. package/dist/eval-B3KZZESM.js +2674 -0
  85. package/dist/evidence-V67CHM35.js +233 -0
  86. package/dist/evolve-YDZSUQYA.js +518 -0
  87. package/dist/extensions-SRG7XCAH.js +207 -0
  88. package/dist/fleet-CA2CRTVG.js +760 -0
  89. package/dist/fleet-preflight-CLIAX7YR.js +21 -0
  90. package/dist/init-2OZDJE2D.js +227 -0
  91. package/dist/memory-3PIQQAKX.js +207 -0
  92. package/dist/models-DY35XI7Y.js +237 -0
  93. package/dist/paths-5OMXW7Z4.js +57 -0
  94. package/dist/preload-KZVHET2B.js +11 -0
  95. package/dist/reset-PIFYNOS3.js +216 -0
  96. package/dist/run-3VSPP24F.js +735 -0
  97. package/dist/share-D36RQCXM.js +241 -0
  98. package/dist/skills-F2MRLELY.js +445 -0
  99. package/dist/skills-eval-E2ZTW4PL.js +932 -0
  100. package/dist/targets-DZMEZAH4.js +977 -0
  101. package/dist/trace-7NYCUI2J.js +250 -0
  102. package/dist/uninstall-AD3JWHBB.js +322 -0
  103. package/dist/upgrade-WYYBKGDY.js +301 -0
  104. package/dist/usage-ULIDAGFF.js +755 -0
  105. package/dist/version-ROZ6CZKH.js +16 -0
  106. package/dist/wiki-generate-PKFIX6OB.js +377 -0
  107. package/dist/worker/entry.js +1739 -0
  108. package/docs/README.md +93 -0
  109. package/docs/acp.md +120 -0
  110. package/docs/alcf-provider.md +72 -0
  111. package/docs/architecture.md +172 -0
  112. package/docs/artifact-versions.md +54 -0
  113. package/docs/built-in-agents.md +265 -0
  114. package/docs/capacity-and-scheduling.md +97 -0
  115. package/docs/commands-and-modes.md +554 -0
  116. package/docs/config-knobs-audit.md +115 -0
  117. package/docs/configuration-and-targets.md +812 -0
  118. package/docs/context-engine.md +236 -0
  119. package/docs/dispatch-architecture-rationale.md +126 -0
  120. package/docs/documentation-coverage.md +46 -0
  121. package/docs/documentation-guide.md +166 -0
  122. package/docs/environment-variables.md +105 -0
  123. package/docs/eval-runner.md +205 -0
  124. package/docs/evals-internal.md +298 -0
  125. package/docs/evidence-and-memory.md +243 -0
  126. package/docs/evolution.md +143 -0
  127. package/docs/exit-codes-and-output.md +74 -0
  128. package/docs/extensions-and-sharing.md +306 -0
  129. package/docs/fleet-demo-runbook.md +179 -0
  130. package/docs/fleet-dispatch.md +591 -0
  131. package/docs/glossary.md +75 -0
  132. package/docs/html/agents_blueprint.html +936 -0
  133. package/docs/html/alcf_blueprint.html +324 -0
  134. package/docs/html/architecture_blueprint.html +850 -0
  135. package/docs/html/commands_blueprint.html +794 -0
  136. package/docs/html/config_knobs_audit_blueprint.html +178 -0
  137. package/docs/html/configuration_blueprint.html +1080 -0
  138. package/docs/html/context_blueprint.html +603 -0
  139. package/docs/html/documentation_blueprint.html +832 -0
  140. package/docs/html/environment_blueprint.html +404 -0
  141. package/docs/html/eval_blueprint.html +743 -0
  142. package/docs/html/evals_internal_blueprint.html +190 -0
  143. package/docs/html/evolution_blueprint.html +674 -0
  144. package/docs/html/extensions_blueprint.html +2065 -0
  145. package/docs/html/fleet_dispatch_blueprint.html +286 -0
  146. package/docs/html/index.html +919 -0
  147. package/docs/html/lifecycle_blueprint.html +723 -0
  148. package/docs/html/memory_blueprint.html +699 -0
  149. package/docs/html/middleware_blueprint.html +664 -0
  150. package/docs/html/models_blueprint.html +2366 -0
  151. package/docs/html/observability_blueprint.html +683 -0
  152. package/docs/html/provider_adapter_blueprint.html +245 -0
  153. package/docs/html/safety_blueprint.html +1386 -0
  154. package/docs/html/shared.css +571 -0
  155. package/docs/html/shared.js +143 -0
  156. package/docs/html/skills_blueprint.html +671 -0
  157. package/docs/html/soak_blueprint.html +182 -0
  158. package/docs/html/tool_usage_blueprint.html +350 -0
  159. package/docs/html/tools_blueprint.html +2249 -0
  160. package/docs/html/trace_blueprint.html +235 -0
  161. package/docs/html/tui_design_blueprint.html +314 -0
  162. package/docs/html/validation_blueprint.html +961 -0
  163. package/docs/html/worker_dispatch_blueprint.html +231 -0
  164. package/docs/installation-and-lifecycle.md +308 -0
  165. package/docs/middleware-and-components.md +148 -0
  166. package/docs/model-catalog.md +189 -0
  167. package/docs/observability.md +233 -0
  168. package/docs/proactive-memory.md +452 -0
  169. package/docs/prompt-envelope-and-tools.md +142 -0
  170. package/docs/provider-adapter-cookbook.md +148 -0
  171. package/docs/release-cut-checklist.md +138 -0
  172. package/docs/safety-model.md +357 -0
  173. package/docs/scientific-validation.md +105 -0
  174. package/docs/session-lifecycle.md +156 -0
  175. package/docs/skills-marketplace.md +46 -0
  176. package/docs/tool-usage.md +527 -0
  177. package/docs/trace-store.md +132 -0
  178. package/docs/troubleshooting.md +33 -0
  179. package/docs/tui-design.md +239 -0
  180. package/docs/worker-dispatch-mechanics.md +242 -0
  181. package/package.json +132 -0
  182. package/skills/README.md +408 -0
  183. package/skills/git/commit-crafting/SKILL.md +79 -0
  184. package/skills/git/commit-crafting/evals.md +92 -0
  185. package/skills/git/create-pr/SKILL.md +116 -0
  186. package/skills/git/create-pr/evals.md +114 -0
  187. package/skills/git/investigate-issue/SKILL.md +139 -0
  188. package/skills/git/investigate-issue/evals.md +94 -0
  189. package/skills/git/resolve-merge-conflicts/SKILL.md +96 -0
  190. package/skills/git/resolve-merge-conflicts/evals.md +58 -0
  191. package/skills/git/review-changes/SKILL.md +103 -0
  192. package/skills/git/review-changes/evals.md +85 -0
  193. package/skills/git/worktree-create/SKILL.md +92 -0
  194. package/skills/git/worktree-create/evals.md +97 -0
  195. package/skills/git/worktree-create/references/worktree-setup.md +66 -0
  196. package/skills/git/worktree-merge/SKILL.md +95 -0
  197. package/skills/git/worktree-merge/evals.md +114 -0
  198. package/skills/skill-marketplace.json +261 -0
  199. package/skills/workflow/cut-it/SKILL.md +86 -0
  200. package/skills/workflow/cut-it/evals.md +42 -0
  201. package/src/domains/agents/builtins/architect.md +33 -0
  202. package/src/domains/agents/builtins/coder.md +31 -0
  203. package/src/domains/agents/builtins/context-bootstrap.md +38 -0
  204. package/src/domains/agents/builtins/debugger.md +30 -0
  205. package/src/domains/agents/builtins/documenter.md +31 -0
  206. package/src/domains/agents/builtins/git-master.md +30 -0
  207. package/src/domains/agents/builtins/provenance.md +30 -0
  208. package/src/domains/agents/builtins/researcher.md +71 -0
  209. package/src/domains/agents/builtins/scout.md +42 -0
  210. package/src/domains/agents/builtins/tester.md +31 -0
  211. package/src/domains/agents/builtins/verifier.md +30 -0
  212. package/src/domains/agents/builtins/wiki-writer.md +41 -0
  213. package/src/domains/agents/fleets/build-review.md +34 -0
  214. package/src/domains/agents/fleets/build-test.md +35 -0
  215. package/src/domains/agents/fleets/sdlc.md +86 -0
  216. package/src/domains/prompts/fragments/identity/clio-worker.md +11 -0
  217. package/src/domains/prompts/fragments/identity/clio.md +26 -0
  218. package/src/domains/prompts/fragments/operating/contract.md +64 -0
  219. package/src/domains/prompts/fragments/safety/auto-edit.md +14 -0
  220. package/src/domains/prompts/fragments/safety/full-auto.md +14 -0
  221. package/src/domains/prompts/fragments/safety/read-only.md +13 -0
  222. package/src/domains/prompts/fragments/safety/suggest.md +13 -0
  223. package/src/domains/prompts/fragments/wiki/page.md +75 -0
  224. package/src/domains/prompts/fragments/wiki/plan.md +48 -0
  225. package/src/domains/providers/models/cloud-models/alcf.yaml +40 -0
  226. package/src/domains/providers/models/local-models/clio-local-coding-targets.yaml +993 -0
@@ -0,0 +1,527 @@
1
+ # Tool Usage Reference
2
+
3
+ > [!TIP]
4
+ > **Interactive Spec Available:** An interactive seven-plane tool atlas and observation envelope truncation/offload calculator is located at [docs/html/tool_usage_blueprint.html](html/tool_usage_blueprint.html) (Version: 0.3.0).
5
+
6
+ This is the deep usage reference behind the deliberately terse tool descriptions in the prompt envelope. Toolkit v2 keeps rich guidance out of tool descriptions and puts it here, where `context(scope="docs", query=...)` retrieves it section by section. Each tool below has its own self-contained `##` section covering the argument surface, defaults, truncation and continuation behavior, and concrete calls. Source of truth is `src/tools/`.
7
+
8
+ In Clio Coder v0.3.0, `src/tools/agent-tools.ts` serves as the single agent-tool adapter across both orchestrator and worker runtimes. Both surfaces resolve their executable tools through the exact same `effectiveToolNames` narrowing, ensuring that attested tool schemas never drift from the tools available at runtime. Tools are keyed strictly by the `ToolName` union with no alias table. Argument leniency for weak-model callers is provided exclusively by per-tool `prepareArguments` normalizers declared on `ToolSpec`.
9
+
10
+ ## Observation envelope: truncation notices, offload, next hints, and the turn budget
11
+
12
+ The six OBSERVE tools (read, grep, find, ls, code_nav, context) share one result envelope, implemented in `src/tools/observation.ts`.
13
+
14
+ Per-call byte caps: read 50KB (env `CLIO_CODER_READ_MAX_BYTES`), grep 16KB for mode=content and 8KB for mode=files/count, find 8KB, ls 8KB, code_nav 16KB, context 16KB for scope=docs and 50KB for scope=skills/workspace.
15
+
16
+ Truncated text results append exactly one notice line:
17
+
18
+ ```text
19
+ [<tool>: <shown>/<total> <unit> shown (<shownSize> of <totalSize>) | full: <offloadPath> | next: <exact-call>]
20
+ ```
21
+
22
+ Segments that do not apply are omitted. `<total>` renders as `N+` when the search stopped early at its item limit, so the true total was never counted. `next:` is an exact argument fragment (for example `limit=200` or `offset=451`); re-issue the same call with that argument changed to continue.
23
+
24
+ Offload: when the byte cap cut content that was already collected, the complete rendering is written to `<clio-coder state dir>/scratch/<sessionId>/<toolCallId>.txt` and the notice's `full:` segment names the path. Read it with `read` using offset/limit. Tools offload only when the byte cap cut collected content; a bare item-limit truncation continues via `next` and does not offload. `read` never offloads, because the source file is directly re-addressable via `offset`.
25
+
26
+ JSON-format results (code_nav, context scope=docs/workspace) never get an appended notice. An oversize JSON payload is replaced whole by the parseable stub `{"error":"result exceeded <cap>","offloadPath":"...","next":"..."}` so the model never receives JSON cut mid-document. Empty results are also valid JSON with empty arrays and `next` populated.
27
+
28
+ Turn budget: all six OBSERVE tools draw from one shared pool of 192KB per turn (env `CLIO_CODER_OBSERVATION_TURN_BUDGET_BYTES`, keyed on `sessionId:turnId`). When the remaining pool shrinks a call below its self cap, a note is appended naming the bytes already used. When the pool is exhausted, the call short-circuits with `[observation budget exhausted for this turn before <tool> ...]` instead of paying for a search whose output cannot be returned. Use narrower arguments or continue in a follow-up turn.
29
+
30
+ ## read: page through a file with offset, limit, and tail
31
+
32
+ Reads one UTF-8 text file. Source: `src/tools/read.ts`.
33
+
34
+ Arguments:
35
+
36
+ - `path` (required). Relative or absolute; `~` expands to the home directory.
37
+ - `offset` (optional). 1-indexed start line; default 1.
38
+ - `limit` (optional). Max lines to return.
39
+ - `tail` (optional). Return the last N lines (jump to EOF). Overrides offset/limit.
40
+
41
+ Each call is capped at 2000 lines or 50KB, whichever hits first (`CLIO_CODER_READ_MAX_BYTES` overrides the byte cap; the per-turn observation budget can shrink it further). Files larger than 20MB error outright; use grep/find to locate the relevant region instead. A missing file errors with a hint to locate it via code_nav, find, or ls.
42
+
43
+ Continuation: a truncated result's notice carries `next: offset=<first unshown line>`. read does not offload; the file itself is the continuation source. If a single line exceeds the byte cap, the result is that line's UTF-8 prefix plus an explanatory note suggesting grep with a narrower pattern or edit with exact surrounding text. An `offset` beyond EOF errors with the file's total line count.
44
+
45
+ Reach for read when you know the path and need contents. Use grep first to find where something lives, then read the cited region with offset/limit instead of paging a large file from the top. Use `tail` for logs and build output where the interesting lines are at the end.
46
+
47
+ ```text
48
+ read(path="src/tools/observation.ts")
49
+ read(path="src/interactive/chat-loop.ts", offset=451, limit=120)
50
+ read(path="build.log", tail=100)
51
+ ```
52
+
53
+ ## edit: exact text replacements in one file
54
+
55
+ Applies targeted replacements to an existing file. Sources: `src/tools/edit.ts`, `src/tools/edit-diff.ts`.
56
+
57
+ Arguments:
58
+
59
+ - `path` (required).
60
+ - `edits` (required). Array of `{oldText, newText}` objects. Each `oldText` must match exactly one region of the original file, and regions must not overlap.
61
+
62
+ Matching runs a cascade: exact substring match first, then a fuzzy match that normalizes Unicode punctuation, non-breaking spaces, and trailing whitespace, then an indentation-relaxed match that compares lines with leading whitespace stripped and re-applies the file's actual indentation to `newText`. If `oldText` matches more than once the call errors and asks for more surrounding context; if it matches nowhere the call errors telling you the text must match exactly including whitespace and newlines; if the result would be byte-identical the call errors with "No changes made".
63
+
64
+ The file's BOM and CRLF/LF line endings are preserved: content is normalized to LF for matching and the original ending restored on write. Same-file mutations from edit and write are serialized through a mutation queue. Success returns `edited <path>: N replacement(s)` plus a one-line validation nudge (rerun the failing test or verify; navigation tools do not validate edits), with `details = {diff, firstChangedLine, paths}`.
65
+
66
+ Argument tolerance: `edits` sent as a JSON string is parsed, and a legacy top-level `{oldText, newText}` pair is folded into `edits`.
67
+
68
+ Prefer edit over write for any change to an existing file; the diff in details is the review surface. Batch related changes to one file into a single call with multiple disjoint edits.
69
+
70
+ ```text
71
+ edit(path="src/tools/ls.ts", edits=[{oldText: "const DEFAULT_LIMIT = 500;", newText: "const DEFAULT_LIMIT = 1000;"}])
72
+ edit(path="README.md", edits=[
73
+ {oldText: "## Install", newText: "## Installation"},
74
+ {oldText: "npm i clio", newText: "npm install clio"}
75
+ ])
76
+ ```
77
+
78
+ ## write: create or overwrite a whole file
79
+
80
+ Writes a complete UTF-8 file, creating parent directories as needed and overwriting silently if the file exists. Source: `src/tools/write.ts`.
81
+
82
+ Arguments:
83
+
84
+ - `path` (required).
85
+ - `content` (required). The full file contents.
86
+
87
+ Success reports the byte count written. If the previous content ended with a newline and the new content does not, the result appends a note so the dropped trailing newline is visible. Writes to the same path are serialized with edit through the file mutation queue.
88
+
89
+ Use write for new files or full regeneration. Use edit for surgical changes to an existing file; write replaces everything and produces no diff.
90
+
91
+ ```text
92
+ write(path="src/tools/new-tool.ts", content="import { Type } from \"typebox\";\n...")
93
+ write(path=".clio-coder/notes/session.md", content="# Session notes\n\n...")
94
+ ```
95
+
96
+ ## bash: run a shell command
97
+
98
+ Executes a command in a fresh `/bin/bash` per call and returns combined stdout and stderr. The login environment is captured once per process (one `bash -lc 'env -0'`) and reused, so every call gets the profile-shaped PATH without re-sourcing the profile chain; when the capture fails the tool falls back to per-call `-lc`. Sources: `src/tools/bash.ts`, `src/core/bash-exec.ts`.
99
+
100
+ Arguments:
101
+
102
+ - `command` (required).
103
+ - `cwd` (optional). Working directory; resolved against the session workspace and rejected when it escapes it. The safety net blocks an escaping cwd at admission, and the tool enforces the same rule itself.
104
+ - `timeout_ms` (optional). Default 300000 (5 minutes).
105
+
106
+ Workspace containment: commands whose filesystem targets resolve outside the session workspace escalate to `system_modify` and ask for one-shot confirmation at every autonomy level (headless runs deny asks). Recognized targets are shell redirects, `tee`/`mkdir`/`touch` path operands, `cp`/`mv`/`ln` destinations, in-place `sed -i` operands, and any `cd`/`pushd` whose directory leaves the workspace, since a `cd` outside re-bases every relative path that follows it. Inside-workspace equivalents stay plain `execute` with no new prompts.
107
+
108
+ Output shaping is tail-biased: the display keeps the LAST 16KB / 2000 lines, because the failing assertion, compiler error, and exit summary live at the end. Before truncating, the full output is spilled to the per-session scratch file and the appended note names the path; read it with offset/limit. A command producing more than 16MB of output is stopped with an error. A timeout or nonzero exit returns the shaped output plus a status line (`bash: command timed out after <ms>ms`, `bash: command failed (exit N)`).
109
+
110
+ Reach for bash for builds, git, package managers, and anything without a dedicated tool. Prefer the dedicated tools over their shell equivalents: grep/find/read/ls get envelope truncation, exact continuation hints, and the shared ignore policy that `cat`, shell `grep`, and shell `find` do not. Prefer `verify` over bash for declared package.json verification scripts, since verify produces typed evidence.
111
+
112
+ ```text
113
+ bash(command="git status --short")
114
+ bash(command="git log --oneline -10")
115
+ bash(command="npm run build", timeout_ms=600000)
116
+ ```
117
+
118
+ ## grep: search file contents with ripgrep
119
+
120
+ Content search over a directory or single file, backed by ripgrep with a bounded pure-Node fallback when rg is not on PATH. Source: `src/tools/grep.ts`.
121
+
122
+ Arguments:
123
+
124
+ - `pattern` (required). Regex by default.
125
+ - `path` (optional). Directory or file; default `.`.
126
+ - `mode` (optional). `content` (default) returns matching lines with paths and line numbers, `files` returns only matching file paths (rg `-l`), `count` returns per-file match counts (rg `-c`).
127
+ - `glob` (optional). File filter, e.g. `*.ts`.
128
+ - `ignore_case` (optional boolean).
129
+ - `literal` (optional boolean). Treat the pattern as fixed text.
130
+ - `context` (optional). Context lines per match; mode=content only. Context comes from rg's `--json` stream, never a second file read.
131
+ - `limit` (optional). Max matches; default 100.
132
+ - `include_ignored` (optional boolean).
133
+
134
+ Visibility follows the shared ignore policy (`src/tools/ignore-policy.ts`): `.gitignore` is honored natively, `.clio-coder`/`.fallow`/`.git` are always excluded, and a fixed generated-dirs list (`node_modules`, `dist`, `build`, `coverage`, `target`, `.venv`, `.next`, `.cache`, `.pytest_cache`, `.turbo`) is force-excluded even when a project forgot to gitignore it. `include_ignored=true` lifts the gitignore and generated layers together; the clio-internal layer always stands. Pointing `path` directly inside an excluded directory searches it. grep and find answer visibility from the same policy, so `grep mode=files` and `find` never disagree about which paths exist.
135
+
136
+ Rendering: match lines print as `path:line: text`, context lines as `path-line- text`. Lines longer than 500 characters are cut with a note suggesting read for the full line. No matches returns `No matches found`.
137
+
138
+ Truncation: hitting the match limit gives `next: limit=<2x>` with the total rendered as `N+`. Hitting the byte cap (16KB content, 8KB files/count) offloads the full rendering and, in content mode, suggests `next: mode=files`. Searches are killed after 30 seconds with a hint to narrow the pattern, path, or glob.
139
+
140
+ The fallback searcher (rg absent) skips files over 20MB and binary files, walks the same ignored-dir set, and stops at the match limit.
141
+
142
+ Reach for grep to find where something lives; use mode=files to map breadth cheaply before reading, and mode=count to size a rename or sweep.
143
+
144
+ ```text
145
+ grep(pattern="finalizeObservation", path="src", mode="files")
146
+ grep(pattern="observationBudget", glob="*.ts", ignore_case=true)
147
+ grep(pattern="TODO|FIXME", path="src/tools", context=2, limit=50)
148
+ grep(pattern="reserveObservation(", literal=true, path="src")
149
+ ```
150
+
151
+ ## find: locate files and directories by glob pattern
152
+
153
+ Finds paths matching a glob, backed by fd with a bounded dirent-only fallback walker. Source: `src/tools/find.ts`.
154
+
155
+ Arguments:
156
+
157
+ - `pattern` (required). Glob dialect: `*`, `**`, `?`, `[abc]`.
158
+ - `path` (optional). Directory to search; default `.`.
159
+ - `order` (optional). `path` (default, fd's native order) or `mtime` (newest first).
160
+ - `limit` (optional). Max results; default 500.
161
+ - `include_ignored` (optional boolean).
162
+
163
+ Results are relative to the search directory, with a `/` suffix on directories. A bare pattern like `*.md` matches at any depth; a pattern containing `/` matches against the search-root-relative path and is auto-prefixed with `**/` unless anchored with `/` or `**/`. Visibility follows the same shared ignore policy as grep (see the grep section); `include_ignored=true` reveals the same extra paths in both tools.
164
+
165
+ `order="mtime"` never walks the whole tree: it collects a bounded candidate set of `max(4 * limit, 2000)` paths, stats only those, sorts newest first, and slices to `limit`. `details.candidates = {cap, collected, capHit, note?}` records the bound; when the cap was hit the ordering is approximate and `next: order=path` is suggested.
166
+
167
+ Truncation: hitting the result limit gives `next: limit=<2x>` with the total rendered as `N+`; the 8KB byte cap offloads the full path list. No matches returns `No files found matching pattern`. Searches are killed after 30 seconds.
168
+
169
+ Reach for find when you know the file's name or shape; use `order="mtime"` with a small limit to answer "what changed recently". When you know contents but not names, use `grep mode=files` instead.
170
+
171
+ ```text
172
+ find(pattern="*.test.ts", path="tests")
173
+ find(pattern="src/**/*.ts", limit=200)
174
+ find(pattern="*", path="src/tools", order="mtime", limit=10)
175
+ find(pattern="**/dist/**", include_ignored=true)
176
+ ```
177
+
178
+ ## ls: list one directory
179
+
180
+ Lists the entries of a single directory, non-recursive. Source: `src/tools/ls.ts`.
181
+
182
+ Arguments:
183
+
184
+ - `path` (optional). Default `.`.
185
+ - `limit` (optional). Max entries; default 500.
186
+
187
+ Entries are sorted alphabetically case-insensitively, directories carry a `/` suffix, and dotfiles are included. ls reads the directory raw and applies no ignore policy, so `node_modules/` and `.git/` appear if present. Entries that vanish or cannot be statted mid-scan are skipped. An empty directory returns `(empty directory)`.
188
+
189
+ Truncation: hitting the entry limit gives `next: limit=<2x>`; the 8KB byte cap offloads the full listing. Reach for ls to orient in one directory; use find for recursive matching.
190
+
191
+ ```text
192
+ ls()
193
+ ls(path="src/tools")
194
+ ls(path="docs", limit=100)
195
+ ```
196
+
197
+ ## credential_present: check environment or file for a credential key
198
+
199
+ Checks whether a credential key is present in the process environment or an env-style file (like `.env`) without ever returning the value of the credential. Source: `src/tools/credential-present.ts`. Read class; parallel.
200
+
201
+ Arguments:
202
+
203
+ - `name` (required). Credential key name, e.g. `OPENAI_API_KEY`. Must match `[A-Za-z_][A-Za-z0-9_]*`.
204
+ - `source` (optional). One of `auto`, `environment` (or `env`), or `file`. Default `auto`.
205
+ - `auto`: Checks the process environment, and checks the env-style file if `file` is supplied.
206
+ - `environment`/`env`: Checks only the process environment.
207
+ - `file`: Checks only the env-style file.
208
+ - `file` (optional). Env-style file path to check, e.g. `.env`.
209
+
210
+ Returns a JSON presence summary mapping containing:
211
+ - `name`: The checked credential key name.
212
+ - `present`: Boolean indicating if the credential is found in any checked source.
213
+ - `source`: The source that matched (`environment`, `file`, `both`, or `none`).
214
+ - `checked`: Array listing the sources actually checked (`environment` and/or `file`).
215
+ - `file`: The env-style file path checked, if applicable.
216
+ - `fileMissing`: True if the file path was specified but does not exist.
217
+
218
+ ```text
219
+ credential_present(name="OPENAI_API_KEY")
220
+ credential_present(name="MY_SECRET_KEY", source="file", file=".env")
221
+ ```
222
+
223
+ ## dispatch: run bounded tasks on fleet agents
224
+
225
+ Dispatches one or more tasks to Clio fleet agents and returns per-run receipt summaries. Source: `src/tools/dispatch.ts`.
226
+
227
+ Arguments:
228
+
229
+ - `task` (required for the singular form unless `list:true`). One worker assignment/instruction string. It is distinct from briefing.
230
+ - `tasks` (required for the batch form unless `list:true`). Array of task strings or `{task, agent, target, model, cwd, briefing}` objects. Per-item fields override the top-level defaults below. Supplying both `task` and `tasks` is an error.
231
+ - `mode` (optional). `parallel` (default) runs items concurrently; `sequential` runs them one at a time, each completing before the next dispatches. A single task always runs down the sequential path.
232
+ - `detach` (optional boolean). For parallel fan-out, returns the durable batch id and assignment ids after registration while the shared event consumer continues in the background. An assignment id equals its first attempt's run id. This is the parent model's route to mid-run monitor/steer; ordinary synchronous, sequential, and pipeline calls auto-wait for each assignment's terminal attempt.
233
+ - `list` (optional boolean). Returns the agent catalog instead of dispatching.
234
+ - `agent` (optional). Default agent recipe for items that do not name one; default `coder`. `agent_id` is accepted as an alias inside items.
235
+ - `target` (optional). Default configured target id.
236
+ - `model` (optional). Default model override.
237
+ - `node` (optional). Default fleet-node pin.
238
+ - `failover` (optional). `none|approved|automatic`. Manual target/model/node pins default to `none`; `approved` requires `allowed_candidates`; `automatic` permits route-part-aware infrastructure failover.
239
+ - `allowed_candidates` (optional). Ordered exact `{agent, target, model, node}` tuples. Valid only with `failover:"approved"`; retries cannot escape this envelope.
240
+ - `thinking_level` (optional). One of `off|minimal|low|medium|high|xhigh|max`, applied to all items.
241
+ - `cwd` (optional). Default agent working directory.
242
+ - `timeout_ms` (optional). Aborts the whole dispatch; in sequential mode remaining tasks are skipped and the skip is reported.
243
+ - `briefing` (optional string, top-level default or per-task override). Parent-composed context/data, not worker instructions: it cannot replace `task`. It is trimmed and omitted when blank, rejected above 12,000 UTF-8 bytes, sent as its own delimited untrusted dynamic message, and retained only as byte/hash provenance. The shared value applies to string tasks and object tasks without an override; an object-level briefing wins.
244
+ - `max_output_bytes` (optional). Summary byte budget; default 20000, split across runs with at least 1024 bytes each.
245
+
246
+ Argument tolerance: `tasks` sent as a JSON string is parsed and a single object or bare string is wrapped into an array. The top-level singular `task` is first-class. Briefing-only calls fail with guidance that briefing is context and cannot replace a task.
247
+
248
+ Output is one batch-shaped summary even for a single task: a header `dispatch (<mode>) total=N failed=M`, the assignment id list, then one terminal-attempt receipt line per assignment (run id, agent, exit code, target, model, tokens, receipt path, verification state, failure message if any) followed by the worker's final assistant text. `details = {mode, assignmentIds, receiptCount, failedCount, runs[]}`, and each `runs[]` entry carries distinct `assignmentId` and terminal `runId` fields plus the structured `verification` state and `receiptIntegrity` result. There is no `runIds` compatibility alias. Any terminal attempt with a nonzero exit turns the whole result into an error carrying the same summary. A run that succeeded without a single successful tool call carries a `note=` marker; do not treat such a run as validated work.
249
+
250
+ The summary separates four things that must never be conflated: `receipt_integrity=verified/v15/sha256` comes only from verification against the ledger; `evidence_verification=<state>/<basis>` describes validation evidence; `briefing=bytes:<n> sha256:<hash>` authenticates parent-supplied data; and `project_context=...` authenticates the independently rendered bounded project message. A tampered receipt renders a head-anchored `RECEIPT INTEGRITY FAILED` banner. A read-only Scout can have verified integrity with `not_applicable/read-only-agent` evidence. Missing briefing is `briefing=none`, never a project-context hash.
251
+
252
+ Exit zero is insufficient without a durable deliverable. A successful native or ACP run must seal a nonempty `output.state="final"`. Otherwise it fails with `worker_final_output_missing`; any unfinished text remains partial diagnostics and automatic retry is suppressed. Live tool-use preambles never replace a missing receipt answer.
253
+
254
+ Sealed receipts are the durable evidence; worker prose remains advisory until verified or spot-checked. Treat a successful reconnaissance receipt as an index and normally spot-check no more than six risk-weighted citations. Parent spot-checking is not independent specialist confirmation. For detached work, `wait` only observes; `collect` closes the batch and is required before final synthesis. Collection resolves each assignment to its terminal attempt and includes `assignmentId`, `terminalRunId`, and `attemptRunIds`; each failed earlier attempt remains available through monitor/ledger receipt lookup. A successful steer records ordered byte/hash/timestamp and acknowledgement provenance without storing prose. After a loop guard blocks a repeated call, do not retry the same call or a syntactic variant. When a report is requested but file modification is forbidden, answer in the final assistant response rather than creating `REPORT.md`.
255
+
256
+ ```text
257
+ dispatch(list=true)
258
+ dispatch(agent="debugger", task="Adversarially verify the strict v15 receipt boundary", briefing="Prior receipt R1 cited receipt-integrity.ts and left these claims unresolved", detach=true)
259
+ dispatch(tasks=["Run the contract tests in tests/contracts/dispatch.test.ts and report each failure with its assertion"])
260
+ dispatch(tasks=[
261
+ {agent: "researcher", task: "Map every caller of finalizeObservation and summarize the envelope shapes"},
262
+ {agent: "coder", task: "Fix the failing assertion in tests/contracts/safety.test.ts; run verify(check=\"test\") before finishing"}
263
+ ], mode="parallel")
264
+ dispatch(tasks=["Refactor step 1", "Refactor step 2"], mode="sequential", timeout_ms=600000)
265
+ ```
266
+
267
+ ## verify: run declared verification checks
268
+
269
+ One EXECUTE entry point for declared verification. Sources: `src/tools/verify/index.ts`, `src/tools/verify/scripts.ts`, `src/tools/verify/frontend.ts`.
270
+
271
+ Arguments:
272
+
273
+ - `check` (optional). A declared package.json script name or `"frontend"`. Omit to list available checks.
274
+ - `path` (check=frontend). Artifact file under the workspace root.
275
+ - `args` (optional). Extra arguments passed to the script after `--`. A JSON-string array is tolerated and parsed.
276
+ - `browser` (check=frontend). `auto` (default), `required`, or `off`.
277
+ - `cwd` (optional). Working directory.
278
+ - `timeout_ms` (optional). Default 120000.
279
+
280
+ `verify()` with no check lists declared checks grouped by source; today the only source is package.json scripts whose names match the verification family `test*/lint*/build*/typecheck*/check*/format*/ci*` (a family prefix, optionally followed by `:`, `.`, or `-` and a suffix, e.g. `test:unit`). `verify(check="typecheck")` runs `npm run typecheck` through the safe-exec spine with no shell; output is capped at 600000 bytes and `details = {command, cwd, exitCode, durationMs, timedOut, outputCapped}`. A script name outside the family is rejected with a pointer to run it through bash.
281
+
282
+ `verify(check="frontend", path=<file>)` validates an HTML, CSS, or JavaScript artifact without shell access. The path must stay inside the workspace root and end in `.html`, `.htm`, `.css`, `.js`, `.mjs`, or `.cjs`. Checks per type: HTML tag balance (comment-aware, HTML5 optional end tags honored), inline and referenced script syntax (classic scripts parsed in-process, modules via `node --check`), inline and linked CSS brace/string/comment balance, local script and stylesheet references resolved and existence-checked (external and root-relative references are skipped), and an optional headless browser load. `browser="auto"` warns when no chromium/chrome/edge executable is on PATH, `"required"` fails, `"off"` skips. Each check reports pass, warn, fail, or skip; any fail makes the whole result an error. `details = {action: "verify", check: "frontend", path, browserMode, status, checks}`.
283
+
284
+ Prefer verify over bash for the verification family: the typed result feeds the finish contract as validation evidence.
285
+
286
+ ```text
287
+ verify()
288
+ verify(check="typecheck")
289
+ verify(check="test", args=["tests/contracts/dispatch.test.ts"])
290
+ verify(check="frontend", path="site/index.html", browser="off")
291
+ ```
292
+
293
+ ## git: read-only inspection of git repository state
294
+
295
+ Executes read-only inspection commands against the local git repository. Source: `src/tools/safe-exec.ts`. Read class; parallel.
296
+
297
+ Arguments:
298
+
299
+ - `op` (required). The inspection operation to run: `status`, `diff`, or `log`.
300
+ - `path` (optional). Limit diff/log to a specific file or directory path.
301
+ - `cached` (optional boolean). For `op="diff"`: staged changes (`--cached`).
302
+ - `stat` (optional boolean). For `op="diff"`: summary only (`--stat`).
303
+ - `name_only` (optional boolean). For `op="diff"`: file names only.
304
+ - `limit` (optional number). For `op="log"`: commits to show (default 20, max 200).
305
+ - `cwd` (optional). Working directory.
306
+
307
+ Commands map directly to git subprocess execution:
308
+ - `op="status"` runs `git status --short --branch`.
309
+ - `op="diff"` runs `git diff` with optional `--cached`, `--stat`, or `--name-only` flags.
310
+ - `op="log"` runs `git log --oneline -n <limit>` listing recent commit shas and subjects.
311
+
312
+ ```text
313
+ git(op="status")
314
+ git(op="diff", stat=true)
315
+ git(op="diff", path="src/tools/safe-exec.ts")
316
+ git(op="log", limit=10)
317
+ ```
318
+
319
+ ## context: workspace snapshot, docs retrieval, and skills
320
+
321
+ One OBSERVE entry point for material about the working environment rather than the tree itself. Sources: `src/tools/context/index.ts`, `src/tools/context/docs-engine.ts`.
322
+
323
+ Arguments:
324
+
325
+ - `scope` (required). `workspace`, `docs`, or `skills`.
326
+ - `query` (scope=docs). Question or terms; omit to list the corpus (files plus doc/section counts) instead of searching.
327
+ - `limit` (scope=docs). Max sections; default 5, max 12.
328
+ - `name` (scope=skills). Skill to load; omit to list.
329
+ - `include_tree` (scope=skills, boolean). List up to 50 files under the skill's base_dir.
330
+
331
+ `scope="workspace"` returns the session's git/project snapshot as JSON, probing and caching it on first call. When model-visible skills are installed, the payload carries a one-line `skills` pointer (count plus the suggest protocol) so orientation surfaces the catalog; the pointer never includes catalog entries and never changes the load gate. It requires a bound session; worker registries without one get a clean error. 50KB cap.
332
+
333
+ `scope="docs"` runs deterministic, offline retrieval over Clio's bundled docs (every `docs/*.md` plus README.md, CHANGELOG.md, and CLIO-CODER.md), indexed as heading-delimited sections with light stemming, Clio vocabulary aliases, phrase boosts, and BM25-style body scoring. The JSON payload carries `corpus`, the expanded `terms`, and ranked `results` with `file`, `heading`, `breadcrumb`, `anchor`, `lines`, `snippet`, `score`, `coverage`, `matchedTerms`, and `signals`, plus an `omitted` count. Follow the `followUp` guidance: read the cited file and line range when you need the full section. Empty results are still valid JSON with `next` populated (the closest vocabulary expansion, or `query=overview`). 16KB cap; an oversize payload is replaced by the parseable JSON stub. The old `docs_search` `file` filter was dropped in the consolidation. Omitting `query` returns the corpus listing (the file set plus doc and section counts, the same `corpus` shape a search carries) so the model can pick a term without wasting a round on a `requires query` error.
334
+
335
+ `scope="skills"` with no `name` lists installed skills with descriptions; the listing asks the model to match the current task against the catalog and, on a fit, to open its reply with `Suggested skill: /skill:<name>` (a comma-separated sequence when skills compose) and wait for the operator. Loading a body is policy-gated: a skill loads only after an explicit operator request (a `/skill:<name>` or `/skill <name>` task, including one picked from the Skills Hub), and recipe-bound workers may load only their declared skills. A load attempt without a pending request is denied with the model's compliant next move spelled out: do not retry, open the reply with the `Suggested skill: /skill:<name>` line and wait for the operator, or continue without skills. On the first substantive turn of a session with model-visible skills installed, a once-per-session middleware reminder in the user message teaches the same protocol. A pending request's task text is surfaced with the body. Marketplace-installed skills are drift-checked against their pinned hash; a mismatch annotates the result with a `skill_drift` warning but never blocks. 50KB cap; a truncated body offloads in full.
336
+
337
+ ```text
338
+ context(scope="workspace")
339
+ context(scope="docs", query="dispatch receipts evidence", limit=8)
340
+ context(scope="skills")
341
+ context(scope="skills", name="context-prime", include_tree=true)
342
+ ```
343
+
344
+ ## code_nav: navigate the codewiki index
345
+
346
+ Structural navigation over the persisted codewiki index (`.clio-coder/codewiki.json`)
347
+ and the optional Markdown wiki metadata. The index is built by context init,
348
+ refresh, or index commands and can be rebuilt/backfilled on tool demand. Source:
349
+ `src/tools/codewiki/code-nav.ts`.
350
+
351
+ Arguments:
352
+
353
+ - `mode` (required). `symbol`, `path`, `entries`, `outline`, `deps`, `dependents`, or `wiki`.
354
+ - `query` (required for every mode except `entries` and `wiki`). Symbol name, indexed path, path pattern, or path substring.
355
+ - `limit` (optional). Default 50 (25 for `entries`), max 200.
356
+
357
+ Modes:
358
+
359
+ - `symbol`: returns declaration records for an exact symbol name, including path, line, kind, and signature.
360
+ - `path`: returns indexed files whose paths match a glob, `/regex/flags`, regex-looking pattern, or substring.
361
+ - `entries`: returns likely entry points ranked from file roles and `package.json` `main`/`bin`.
362
+ - `outline`: returns declarations in one indexed file, sorted by line.
363
+ - `deps`: returns one indexed file's internal and external imports.
364
+ - `dependents`: returns indexed files that import the target file.
365
+ - `wiki`: returns Markdown wiki pages plus absent/fresh/stale wiki state and layout warnings.
366
+
367
+ For `outline`, `deps`, and `dependents` the query must resolve to exactly one indexed file: an exact path or a substring matching one path. An ambiguous substring errors with the match count. Output is always parseable JSON (empty results carry empty arrays, an `omitted` count, and `next`); an omitted remainder suggests `next: limit=<2x>`. 16KB cap with the JSON stub on overflow.
368
+
369
+ Reach for code_nav instead of grep when you want a definition site, a file's structure, change-impact fan-out, or wiki inventory; it reads local artifacts, not the tree.
370
+
371
+ ```text
372
+ code_nav(mode="symbol", query="finalizeObservation")
373
+ code_nav(mode="outline", query="src/tools/grep.ts")
374
+ code_nav(mode="dependents", query="src/tools/observation.ts")
375
+ code_nav(mode="entries")
376
+ code_nav(mode="wiki")
377
+ ```
378
+
379
+ ## web_fetch: fetch http(s) URLs and convert HTML to markdown
380
+
381
+ Fetches content from an http(s) URL. HTML content is automatically cleaned and converted to readable Markdown. Source: `src/tools/web-fetch.ts`. Read class; parallel.
382
+
383
+ Arguments:
384
+
385
+ - `url` (required). Fully-qualified http(s) URL.
386
+ - `method` (optional). HTTP method (default `GET`).
387
+ - `headers` (optional). Key-value request headers.
388
+ - `body` (optional). Request body string.
389
+ - `timeout_ms` (optional). Request timeout in milliseconds (default 30000).
390
+ - `max_bytes` (optional). Max bytes returned (default 600000, capped at 5MB).
391
+ - `format` (optional). Content parsing format: `auto` (default, converts HTML to Markdown), `markdown`, or `raw`.
392
+
393
+ Specialized behaviors:
394
+ - **ArXiv Papers**: If the URL points to an arXiv paper or abstract page (such as `arxiv.org/abs/...` or `alphaxiv.org/...`), it automatically retrieves paper metadata, abstract, and any AlphaXiv markdown overview.
395
+ - **ArXiv API Query**: If the URL points to the arXiv search API, it parses the Atom XML and returns a structured markdown listing of papers.
396
+ - **Git Repo Tree Summary**: If the URL points to a GitHub or GitLab directory tree (such as `github.com/.../tree/...`), it fetches repository contents, summarizes the directory tree, and preloads the first few markdown files (e.g. README/SKILL/INSTALL).
397
+ - **HTML Cleaning**: For regular websites, boilerplate content (scripts, styles, svg, iframe, forms) is stripped, and the main article/content area is extracted and parsed into Markdown.
398
+ - **Binary formats**: Non-text, binary, or unsupported content types are rejected.
399
+
400
+ ```text
401
+ web_fetch(url="https://arxiv.org/abs/2303.17564")
402
+ web_fetch(url="https://github.com/iowarp/clio-coder/tree/main/docs")
403
+ web_fetch(url="https://example.com", format="raw")
404
+ ```
405
+
406
+ ## monitor: inspect dispatched runs
407
+
408
+ Read-only visibility into known synchronous and detached dispatched runs, built on the dispatch domain's ledger, live snapshot, and instance-scoped event tails. Synchronous dispatch auto-waits. The interactive operator/TUI can inspect an active synchronous run through the dispatch contract, but the parent model cannot schedule monitor while its sequential synchronous dispatch call is pending; it must choose `detach:true` to receive ids first. Source: `src/tools/monitor.ts`. Read class; runs in parallel with other reads.
409
+
410
+ Arguments:
411
+
412
+ - `run_id` (optional). A run id from dispatch output or `monitor(mode="list")`.
413
+ - `mode` (optional). `list`, `status`, `peek`, `receipt`, `wait`, `collect`, or `tools`. Default is `status` when `run_id` is given, `list` otherwise.
414
+
415
+ Modes:
416
+
417
+ - `list`: up to 20 known runs, newest first, scoped to this session when it has runs and otherwise all sessions. Each line carries the run id, agent, state, start time, tokens, and receipt path.
418
+ - `status`: one run's state and outcome, target/model/runtime, start/end times, exit code, tokens, cost, and receipt path. A still-running run adds a live line with phase, heartbeat, elapsed seconds, and token count.
419
+ - `peek`: the bounded tail of the run's recent events buffered in this process (an in-process ring of 100 events per run across at most 64 runs, heartbeats excluded, 8KB output with the oldest entries trimmed first). Runs dispatched by another process, or before this process started, have no tail; monitor says so and points at `mode="receipt"` or `mode="status"`.
420
+ - `receipt`: the stored receipt JSON, truncated at 14KB with a note naming the receipt path so you can read the rest.
421
+ - `wait`: bounded observation of one run until it becomes terminal or the timeout elapses; timeout never cancels the run.
422
+ - `collect`: a non-blocking barrier snapshot for a detached `batch_id` or explicit `run_ids`, returning full results once all are terminal.
423
+ - `tools`: what a run executed, from this process's bounded event buffer plus the integrity-verified receipt totals. The buffer records tool name and outcome, not command arguments, and the answer says so; a run from another process may have no buffer at all.
424
+
425
+ Use monitor to check on detached parallel workers without interrupting them; pair with steer when a native run needs correction.
426
+
427
+ ```text
428
+ monitor(mode="list")
429
+ monitor(run_id="run-01H...")
430
+ monitor(run_id="run-01H...", mode="peek")
431
+ monitor(run_id="run-01H...", mode="receipt")
432
+ monitor(run_id="run-01H...", mode="tools")
433
+ ```
434
+
435
+ ## steer: guide or cancel a running worker
436
+
437
+ Controls a running dispatched worker whose id is already available. Parent-model mid-run control requires detached dispatch because dispatch and steer are sequential; the interactive operator/TUI can steer an active synchronous HTTP or SDK worker through the dispatch contract. Source: `src/tools/steer.ts`. Dispatch class; sequential.
438
+
439
+ Arguments:
440
+
441
+ - `run_id` (required). A run id from dispatch output or `monitor(mode="list")`.
442
+ - `action` (required). `guide` or `cancel`.
443
+ - `message` (required for `guide`). The steering text.
444
+
445
+ `action="guide"` injects the message through the dispatch contract's stdin steer channel; an HTTP or SDK worker sees it as a user message at its next turn boundary. The worker acknowledges only after its runtime accepts the guidance. Single-shot subprocess runtimes (Claude CLI and Antigravity) and ACP delegation do not expose live input and return the contract's structured unsupported-steering error.
446
+
447
+ `action="cancel"` aborts a non-terminal run; the run finalizes with `outcome=canceled` and its receipt records the cancellation. A run that already finished (completed, failed, interrupted, stale, or dead) errors with its state, since there is nothing to cancel.
448
+
449
+ Prefer guide over cancel-and-redispatch when the worker is on track but needs a scope correction; the worker keeps its context.
450
+
451
+ ```text
452
+ steer(run_id="run-01H...", action="guide", message="Skip the docs sweep; limit the fix to tests/contracts and report the diff.")
453
+ steer(run_id="run-01H...", action="cancel")
454
+ ```
455
+
456
+ ## tasks: the session task board
457
+
458
+ Declares and tracks the agent's own working plan. Source: `src/tools/tasks.ts`. Read class (never gated); sequential.
459
+
460
+ Arguments:
461
+
462
+ - `action` (required). `plan`, `add`, `start`, `done`, `block`, `drop`, or `list`.
463
+ - `title` (required for `plan`). The board title.
464
+ - `tasks` (required for `plan` and `add`). Task titles as an array of strings.
465
+ - `id` (required for `start`, `done`, `block`, `drop`). A task id like `t2`.
466
+ - `note` (optional). Evidence of completion on `done`; the reason on `block` (required there) and `drop`.
467
+
468
+ `action="plan"` declares a titled board and replaces any prior board; tasks get sequential ids `t1..tN` and start pending. `start` marks one task active and parks any other active task back to pending, so the board always names exactly one current focus. `done` completes a task; its `note` is recorded on the session ledger as passed validation evidence, so a completed task carries its receipt rather than a bare status flip. `block` requires a reason and is the honest state for work waiting on the operator; blocked tasks never trigger the turn-end nudge. `drop` cancels a task; ids are never reused. Every action returns the whole rendered board, so the current state always sits in the latest tool result.
469
+
470
+ Every mutation persists a full-snapshot `taskLedger` entry in the session ledger: the board replays from the JSONL alone, survives `/resume` and `/fork`, costs nothing at compaction, and feeds the footer tasks row plus the `/tasks` overlay. When a tool-calling turn settles while pending or active tasks remain, the `nudge.open-tasks` middleware carries the turn onward once with the open-task list; record the honest state (`done` with evidence, `block` with a reason, or `drop`) instead of stopping with a stale board.
471
+
472
+ Dispatched runs link to the live board through the ledger's `activeRunIds` field: the orchestrator attaches a run when its worker process goes live and detaches it when the run finalizes, so a snapshot records which fleet runs were serving the board. The linkage is process-live, so a refold after `/resume` or `/fork` restores it empty (the runs ended with the process that dispatched them). Claude SDK/CLI workers map their `TodoWrite` calls onto this tool, so a Claude worker's todo list lands on the same board rather than writing a separate artifact.
473
+
474
+ ```text
475
+ tasks(action="plan", title="Fix the flaky scheduler test", tasks=["reproduce the failure", "isolate the race", "fix and verify"])
476
+ tasks(action="start", id="t1")
477
+ tasks(action="done", id="t1", note="reproduced 3/3 with CLIO_CODER_SEED=7; failure in tests/contracts/scheduler.test.ts:88")
478
+ tasks(action="block", id="t2", note="needs operator decision on the retry policy")
479
+ tasks(action="list")
480
+ ```
481
+
482
+ ## ask_user: host-owned operator interviews
483
+
484
+ Runs a host-owned interactive interview or single-question prompt with the operator, recording decisions and/or free-form answers. Source: `src/tools/ask-user.ts`. Read class; sequential.
485
+
486
+ Arguments:
487
+
488
+ - `action` (optional). `ask` (default) to present questions; `complete` to finalise the interview and record compact decisions.
489
+ - `mode` (optional). `round` (default) to batch multiple questions; `single_question` for exactly one question.
490
+ - `questions` (optional array). For `action="ask"`, up to four question objects containing:
491
+ - `question` (required): Question text prompt.
492
+ - `header` (optional): Short header.
493
+ - `options` (optional array): Suggested choices (`{label, description}`).
494
+ - `multi_select` (optional boolean): Allows multiple selections.
495
+ - `decisions` (optional array). For `action="complete"`, key-value objects representing settled configurations.
496
+ - `summary` (optional). Closeout explanation for `action="complete"`.
497
+ - `max_rounds` (optional number). Round limit for this interview (default 6, max 24).
498
+
499
+ The tool manages a stateful operator interview. The UI presents choices (with an implicit "Other" option for custom text input). Once completed, the final decisions are persisted as standard configurations in the session ledger, allowing the agent to proceed with operators' inputs or defaults.
500
+
501
+ Ask only when blocked on a decision the request does not answer. Never ask about anything the operator already stated: a request that names its own scope ("all tools", "read only") has answered the interview before it starts.
502
+
503
+ ```text
504
+ ask_user(action="ask", questions=[{question: "Which database should we use?", options: [{label: "SQLite", description: "Local database"}, {label: "PostgreSQL"}]}])
505
+ ask_user(action="complete", summary="Operator selected SQLite.", decisions=[{key: "db_choice", value: "SQLite"}])
506
+ ```
507
+
508
+ ## artifact: plans, reviews, and reports
509
+
510
+ Terminal document writers behind one surface. Source: `src/tools/artifact.ts`.
511
+
512
+ Arguments:
513
+
514
+ - `kind` (required). `plan`, `review`, or `report`.
515
+ - `content` (required). Full Markdown body.
516
+ - `title` (optional). Document title.
517
+ - `path` (optional). Override the default artifact path.
518
+
519
+ `kind=plan|review|report` writes a Markdown document to PLAN.md, REVIEW.md, or REPORT.md at the project root by default; `path` may override the destination but must stay inside the workspace. When `content` does not already start with `#`, a non-empty `title` is prepended as an H1. These kinds are TERMINAL: writing the artifact completes the turn and the harness skips the follow-up model call, so the artifact body itself is the answer. Put everything the reader needs in `content`; there is no closing message after the write.
520
+
521
+ Skills are not artifacts. A skill is a `SKILL.md` folder written with the ordinary write tool into `.clio-coder/skills/<name>/` (or the user skill store) and validated by the skills loader; the `skill-craft` shipped skill documents the format and craft rules.
522
+
523
+ ```text
524
+ artifact(kind="plan", content="# Migration plan\n\n## Step 1 ...")
525
+ artifact(kind="report", title="Benchmark results", path="docs/reports/bench.md", content="...")
526
+ artifact(kind="review", content="# Review: toolkit-v2\n\n## Findings ...")
527
+ ```