@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,132 @@
1
+ # Trace store contract
2
+
3
+ > [!TIP]
4
+ > **Interactive Spec Available:** An interactive trace database viewer, schema inspector, and SQL query validator simulator is located at [docs/html/trace_blueprint.html](html/trace_blueprint.html) (Version: 0.3.0).
5
+
6
+ Clio's trace database is a rebuildable, queryable mirror. Receipts, session
7
+ ledgers, gate artifacts, and evidence remain the source of truth. Removing
8
+ `<state-dir>/trace.sqlite` loses no authoritative run data.
9
+
10
+ ## Connection and version contract
11
+
12
+ The writer creates `trace.sqlite` beside the other machine-produced state and
13
+ opens every writable connection with:
14
+
15
+ ```sql
16
+ PRAGMA journal_mode=WAL;
17
+ PRAGMA synchronous=NORMAL;
18
+ PRAGMA busy_timeout=5000;
19
+ ```
20
+
21
+ Readers open SQLite in read-only mode and set `busy_timeout=5000`. They verify
22
+ that `meta.schema_version` is exactly `1`; a missing or unknown version is an
23
+ error. A read-only connection queries the existing journal mode but does not
24
+ try to change it, because changing journal mode is a database write.
25
+
26
+ ## Tables
27
+
28
+ The seven Clio trace tables are `runs`, `phases`, `events`, `envelopes`,
29
+ `gate_results`, `agent_sessions`, and `processes`; `meta` carries the schema
30
+ version. Runs use terminal run ids. Interactive session turns are also recorded
31
+ as `runs` rows using `assignment_id = "session"`. A phase belongs to a run and carries its
32
+ assignment/worker-facing name, kind, owner, attempt, timing, status, itemized
33
+ token spend, optional itemized dollar spend, total dollar spend, and context
34
+ occupancy. Missing historical or unavailable component costs are `NULL`, never
35
+ zero.
36
+
37
+ `events` is append-ordered by SQLite `rowid`. All events carry `run_id`,
38
+ `phase_id`, `type`, `name`, `started_at`, and a bounded JSON payload. Only
39
+ `tool_call` is a span: it has both `started_at` and `ended_at`; all other event
40
+ types are point events with `ended_at IS NULL`. A real tool call is folded into
41
+ one row keyed by its worker tool-call id. Its payload carries the readable tool
42
+ name, arguments, bounded result snippet, success, duration, and agent.
43
+
44
+ Gate checks are stored as `checks_json` arrays of `{item, ok, note}`. They are
45
+ projected only from successfully parsed typed reviewer/judge results, never by
46
+ scraping prose. Worker/model/session occupancy is mirrored in `agent_sessions`.
47
+ `violations_json` is derived from failed checks. `processes.command` is a
48
+ redacted display projection of the argv observed when a pid was registered;
49
+ `command_digest` is the SHA-256 identity of the exact JSON-encoded argv.
50
+ Consumers must compare the digest of the pid's current argv before ever
51
+ signalling it; the trace CLI and UI are listing/read-only surfaces and never
52
+ signal processes.
53
+
54
+ ## Polling contract
55
+
56
+ Live and historical consumers use the same cursor query:
57
+
58
+ ```sql
59
+ SELECT rowid, event_id, run_id, phase_id, parent_id, type, name,
60
+ payload_json, tokens, started_at, ended_at
61
+ FROM events
62
+ WHERE run_id = ? AND rowid > ?
63
+ ORDER BY rowid
64
+ LIMIT ?;
65
+ ```
66
+
67
+ The limit is capped at 500. A consumer retains the highest returned `rowid` and
68
+ passes it as the next cursor. A live view polls this query every 500 ms and
69
+ drains additional pages without overlap. History performs the identical query
70
+ at a slower cadence or only on demand. There is no ingest endpoint, push
71
+ transport, WebSocket, replay mode, or separate backfill path.
72
+
73
+ ## Failure behavior
74
+
75
+ The observability subscriber schedules each dispatch event onto a serialized,
76
+ best-effort queue capped at 2,048 pending writes. Lifecycle, terminal,
77
+ tool-span, attempt, and usage facts are retained; display-only progress may be
78
+ dropped with a warning when the cap is full. SQLite work never runs in the
79
+ worker event pump and never participates in receipt correctness.
80
+ Write/open/schema failures emit one bounded `[clio:trace]` warning and degrade
81
+ the mirror without failing the run. The Node.js `node:sqlite` `ExperimentalWarning` is suppressed by default via a scoped listener filter, which can be carved out by passing `--trace-warnings`. Domain shutdown prioritizes flushing trace
82
+ writes before slower evidence builds.
83
+
84
+ ## CLI Commands
85
+
86
+ The `clio-coder trace` command surfaces 6 subcommands for inspecting and querying the SQLite trace mirror:
87
+
88
+ ```bash
89
+ clio-coder trace runs [--db PATH] [--limit N]
90
+ clio-coder trace phases <runId> [--db PATH]
91
+ clio-coder trace tail <runId> [--follow] [--db PATH]
92
+ clio-coder trace procs <runId> [--db PATH]
93
+ clio-coder trace sql <SELECT query> [--db PATH]
94
+ clio-coder trace ui [--db PATH] [--port N]
95
+ ```
96
+
97
+ `clio-coder trace --help` and every subcommand `--help` print usage and exit with code 0.
98
+
99
+ ### Database Resolution and Error Handling
100
+
101
+ When resolving the SQLite database path:
102
+ - **Default Database Path:** If `--db` is omitted and no database has been created yet, `clio-coder trace` prints an informational notice (`no trace database yet at <path>`) and exits cleanly with code 0.
103
+ - **Explicit Database Path:** If an explicit `--db <path>` is specified but does not exist, `clio-coder trace` prints `error: trace database not found: <path>` and exits with code 1.
104
+
105
+ ### Subcommand Specifications
106
+
107
+ 1. **`runs`**: Lists recent dispatch runs from the trace store. `--limit` sets maximum rows (1 to 500, default 50). Formats status, start time, total tokens, total USD cost, and run ID.
108
+ 2. **`phases`**: Lists sequence phases for a designated `runId`. Displays status, attempt, owner, total tokens, USD cost, and phase name.
109
+ 3. **`tail`**: Displays append-ordered event rows for a designated `runId`. When `--follow` is specified, polls for new events every 500 ms until two consecutive idle polls observe a finished run status.
110
+ 4. **`procs`**: Lists orchestrator and worker process executions associated with a `runId`. Displays state (`live` or `ended`), PID, process kind, name, and command string.
111
+ 5. **`sql`**: Executes a single read-only `SELECT` or `WITH` SQL statement against the SQLite trace database. The subcommand enforces read-only access: queries containing semicolons or data mutation keywords (`INSERT`, `UPDATE`, `DELETE`, `CREATE`, etc.) are rejected with exit code 2. BigInt numbers in result objects format as JSON strings.
112
+ 6. **`ui`**: Launches the web-based interactive trace viewer server on the specified `--port` (default 0). This subcommand requires a source checkout containing `apps/trace-viewer/server.mjs`.
113
+
114
+ ### Trace Viewer Surface
115
+
116
+ The viewer binds to `127.0.0.1` only and serves a read-only JSON API beside the static page:
117
+
118
+ | Endpoint | Source |
119
+ | --- | --- |
120
+ | `GET /api/health` | Schema version handshake. |
121
+ | `GET /api/runs[?limit=N]` | `runs`, newest first. |
122
+ | `GET /api/runs/:runId` | One `runs` row. |
123
+ | `GET /api/runs/:runId/phases` | `phases`, ordered by `seq`. |
124
+ | `GET /api/runs/:runId/events[?after=cursor&limit=N]` | `events` by rowid cursor, capped at 500 per page. |
125
+ | `GET /api/runs/:runId/gates` | `gate_results`. |
126
+ | `GET /api/runs/:runId/envelopes` | `envelopes`. |
127
+ | `GET /api/runs/:runId/processes` | `processes`. |
128
+ | `GET /api/runs/:runId/receipt` | Sidecars beside the database: `<stateDir>/receipts/<runId>.json` and the matching `<stateDir>/evidence-index.json` row. |
129
+
130
+ The receipt endpoint derives `<stateDir>` from the directory holding the trace database, since `clio-coder trace ui` reads `<stateDir>/trace.sqlite`. A mirror copied away from its state directory has no sidecars, so a missing, unreadable, or malformed file yields a `null` half with HTTP 200 rather than an error. The response drops `output`, `upstreamResponses`, `routeDecision`, `briefing`, and `steering`: the panel renders provenance, not transcripts.
131
+
132
+ The run page renders the task request, wall-clock duration, phase description, failure reason and retry count, a chronological log of every event type with its payload, gate verdicts and violations, the run's processes, and a receipt panel covering outcome, verification state and basis, spend, per-tool call statistics, safety counters, findings, and build provenance. Fields the harness never sealed read as absent rather than as zero.
@@ -0,0 +1,33 @@
1
+ # Troubleshooting & Error Remediation
2
+
3
+ This guide provides concrete, actionable remediation procedures for operational errors, permission denials, target connection failures, and system diagnostics in Clio Coder `v0.3.0`.
4
+
5
+ ---
6
+
7
+ ## Error Catalog & Remediation Matrix
8
+
9
+ | User-Facing Error / Notice | Cause | Actionable Remediation |
10
+ | :--- | :--- | :--- |
11
+ | `clio-coder run cannot confirm permission requests; rerun interactively to approve this action.` | A tool call required manual permission confirmation during a non-interactive headless `clio-coder run` execution. | Run the command interactively in the TUI (`clio`) to grant one-shot approval, adjust the workspace policy in `.clio-coder/safety.yaml`, or run with `--autonomy full-auto` if safe. |
12
+ | `no trace database yet at <path>` | The trace mirror database has not been initialized because no interactive sessions or dispatches have executed yet. | Execute a turn or dispatch a task. In SQLite trace commands, this notice is informational (exit code `0`). |
13
+ | `error: trace database not found: <path>` | An explicit `--db <path>` flag was provided pointing to a nonexistent database file. | Verify the database path or omit `--db` to use the default state directory database (`<stateDir>/trace.sqlite`). |
14
+ | `no local skill marketplace catalog or index configured` | Neither a local `skills/` catalog directory nor a valid JSON index at `CLIO_CODER_SKILL_MARKETPLACE_INDEX` was found. | Point `CLIO_CODER_SKILL_MARKETPLACE_INDEX` at a valid `skill-marketplace.json` file or install a skill directly via `clio-coder skills install <path\|github-url>`. |
15
+ | `<arg> is a global option and must come before the subcommand: clio-coder <usage> <command> ...` | A global CLI option (such as `--cwd`, `--config-dir`, or `--state-dir`) was placed after the subcommand name. | Move the flag before the subcommand name (e.g. `clio-coder --cwd /path run ...` instead of `clio-coder run --cwd /path ...`). |
16
+ | `target <id> is not registered` | The designated target ID does not exist in `settings.yaml`. | Run `clio-coder targets` to view available targets, or configure a new target using `clio-coder targets add <id> --runtime <type> --base-url <url>`. |
17
+ | `budget: ceiling must be >= 0 (got <val>)` | An invalid negative budget ceiling was passed to the session or dispatch configuration. | Pass a non-negative USD budget value (e.g. `--budget-usd 5.0`). |
18
+ | `worker_final_output_missing` | A worker process completed execution with exit code 0 but failed to emit a valid final answer before the stream closed. | Check the worker event log using `clio-coder trace tail <runId>` or inspect the receipt via `monitor(run_id="<id>", mode="receipt")`. |
19
+ | `vram_capacity_fit_failure` | The model could not be scheduled or loaded due to insufficient GPU VRAM capacity on the target node. | Select a smaller quantized model variant, reduce context window size, or route to an alternative fleet node with greater memory capacity. |
20
+ | `loop_guard_tools_disabled_exhausted` | The loop detector identified repeated unproductive tool calls with identical arguments and disabled tool execution. | Inspect model prompts and provide clearer intermediate steering instructions to prevent recursive tool loops. |
21
+ | `Node.js ExperimentalWarning: SQLite is an experimental feature` | Node.js emitted an experimental feature warning for `node:sqlite`. | By default, Clio suppresses this warning via a scoped filter. If visible when running scripts directly, pass `--trace-warnings` to control diagnostics. |
22
+ | `cwd-fallback: no-cwd / missing / not-a-directory` | The session recorded in `meta.json` points to a workspace directory that has been deleted, unmounted, or renamed. | When prompted by the `cwd-fallback` overlay, select a valid existing directory to re-anchor the session. |
23
+
24
+ ---
25
+
26
+ ## Diagnostic Commands
27
+
28
+ When encountering unexpected system behavior:
29
+
30
+ 1. **System Health Check**: Run `clio-coder doctor` (or `clio-coder doctor --fix` to auto-repair state directory permissions and configuration defaults).
31
+ 2. **Target Connectivity Probe**: Run `clio-coder configure --probe` to verify authentication and reachability for all configured LLM providers.
32
+ 3. **Trace Store Inspection**: Run `clio-coder trace runs` and `clio-coder trace tail <runId>` to inspect event logs, durations, and tool outputs.
33
+ 4. **Receipt Validation**: Run `clio-coder evidence inspect <runId>` or `/view verify <runId>` to check cryptographic integrity and execution telemetry.
@@ -0,0 +1,239 @@
1
+ # Clio TUI Design System
2
+
3
+ > [!TIP]
4
+ > **Interactive Spec Available:** An interactive color/glyph token laboratory and terminal transcript preview renderer is located at [docs/html/tui_design_blueprint.html](html/tui_design_blueprint.html) (Version: 0.3.0).
5
+
6
+ This document is the reference specification for the Clio Coder TUI visual layout, styling, and behavior. It describes color semantics, the glyph vocabulary, structural recipes, and state choreography for all surfaces under [src/interactive/](../src/interactive/).
7
+
8
+ The governing principle: **the user reads state from color, structure from frames, and identity from brand marks.** Everything that is not state or structure remains visually quiet.
9
+
10
+ ---
11
+
12
+ ## 1. Color System
13
+
14
+ All color styling is defined in [src/interactive/theme/tokens.ts](../src/interactive/theme/tokens.ts). No raw SGR sequences, `38;2;`/`38;5;` ANSI escape fragments, or hardcoded hex colors are allowed outside this theme module.
15
+
16
+ ### 1.1 Color Tokens
17
+
18
+ | Token | Value (truecolor) | Role |
19
+ |---|---|---|
20
+ | `accent` | `rgb(70, 229, 208)` (Teal) | Brand and interactivity: frame titles, selection highlight, keybinding/slash-command affordances, agent voice glyphs, tool verbs, and active/writing phases. |
21
+ | `accentDeep` | `rgb(31, 183, 166)` | Structural emphasis only: bold CAPS section tags. |
22
+ | `action` | `rgb(255, 126, 41)` (Orange) | Active autonomous operations: dispatching phase pills, active fleet badges, running fleet indicators, and user-steering queues. |
23
+ | `success` | `rgb(87, 227, 137)` (Green) | Positive outcomes: success indicators (`✓`), ok health status, clean git trees, and output-token count updates. |
24
+ | `warning` | `rgb(255, 180, 84)` (Amber) | Real warnings only: stale data, dirty trees, retry status, blocked tools, and truncation. |
25
+ | `error` | `rgb(255, 92, 102)` (Red) | Failures: error indicators (`✗`), error rails, stuck states, and error message text. |
26
+ | `info` | `rgb(91, 168, 255)` (Blue) | Informational messages, notices, and system-prompt meters. |
27
+ | `reason` | `rgb(157, 140, 255)` (Purple) | Reasoning-related status: thinking phases, thinking rails, reasoning-token metrics, and context compacting. |
28
+ | `dim` | `rgb(106, 122, 133)` | Scaffolding elements: separators, key names, keyboard shortcut hints, durations, and timestamps. |
29
+ | `muted` | `rgb(138, 153, 164)` | Secondary content: paths, previews, counts, and non-status values. |
30
+ | `title` | alias of `accent` | Semantic title token mapping. |
31
+ | `frame` | `rgb(47, 93, 90)` | Borders, rules, inner dividers, and unused context space. |
32
+ | `frameStrong` | `rgb(42, 171, 158)` | The active editor input rail background. |
33
+
34
+ ### 1.2 Placement Rules
35
+
36
+ - Color is used functionally to indicate state. If removing a color does not lose information, the text is colored using `dim`, `muted`, or left unstyled.
37
+ - `warning` amber is reserved for true warnings. Costs and neutral telemetry numbers use `muted`.
38
+ - `accentDeep` is used only in section tags. Metric values (such as TTFT, tokens-per-second, and autonomy status) use `muted`.
39
+ - Per-surface color budgets limit noise: chip strips use at most one non-neutral token per chip, and framed cards use at most one status token alongside neutral colors.
40
+
41
+ ---
42
+
43
+ ## 2. Glyph Vocabulary
44
+
45
+ All symbols are defined as constants in [src/interactive/theme/glyphs.ts](../src/interactive/theme/glyphs.ts). Rendering code reference these names instead of embedding hardcoded glyph literals.
46
+
47
+ | Glyph | Name | Meaning | Used by |
48
+ |---|---|---|---|
49
+ | `>C_` | `brand` | Clio wordmark | Welcome header and dashboard header only. |
50
+ | `✦` | `agent` | Agent voice | Chat reply prefix (accent; error red on failed turns). |
51
+ | `›` | `user` | User voice | Chat user prefix (accent); steering queue marker (action). |
52
+ | `❯` | `cursor` | Selection focus | Settings, list overlays, selectors. |
53
+ | `▸` | `toolHeader` | Tool ledger line | Tool sublines and expanded tool headers. |
54
+ | `✓` | `ok` | Success | Everywhere. |
55
+ | `✗` | `error` | Failure | Everywhere. |
56
+ | `⊘` | `cancelled` | Cancelled or aborted | Everywhere. |
57
+ | `⚠` | `warn` | Warning block | Notices, stuck phase. |
58
+ | `!` | `warnInline` | Inline warning mark | Git dirty, stale rows, fleet row warnings. |
59
+ | `ℹ` | `info` | Informational notice | Notification surfaces. |
60
+ | `●` | `running` | Live run (static form) | Dispatch rows when not animated, health ok. |
61
+ | `◌` | `queued` | Queued or idle | Queued dispatch rows, idle phase. |
62
+ | `⣾⣽⣻⢿⡿⣟⣯⣷` | `SPINNER_FRAMES` | Live activity | Phase pill and running dispatch rows. |
63
+ | `◔ ◐ ◑` | `phaseWaiting/phaseThinking/phaseWriting` | Turn progression | Phase pill. |
64
+ | `⚙` | `phaseTool` | Tool executing | Phase pill. |
65
+ | `⏸` | `phaseBlocked` | Awaiting confirmation | Phase pill. |
66
+ | `↻` | `phaseRetry` | Retrying | Phase pill, retry notices. |
67
+ | `♻` | `phaseCompact` | Compacting | Phase pill. |
68
+ | `⇲` | `phaseDispatch` | Dispatching (action orange) | Phase pill. |
69
+ | `↑ ↓` | `up/down` | Input and output tokens; scroll | Everywhere. |
70
+ | `⚡` | `speed` | Throughput | Everywhere. |
71
+ | `▰ ▱` | `contextFull/contextFree` | Context meter cells | Meters. |
72
+ | `▒` | `contextReserve` | Autocompact reserve cells | Context meters. |
73
+ | `█ ░` | `barFull/barEmpty` | Wide-glyph fallback | Meters. |
74
+ | `│` | `rail` | Body rail and section bar | Tool bodies, thinking rail, column separators. |
75
+ | `─` | (rules) | Horizontal rule and borders | Frames and rules. |
76
+ | `╌` | `innerDivider` | Divider inside a frame | Task island, any framed list. |
77
+ | `·` | (dotSep) | Chip separator (dim) | Everywhere. |
78
+ | `◆ ◇` | `active/scoped` | Active and scoped marks | Model selector, thinking selector. |
79
+
80
+ ---
81
+
82
+ ## 3. Formatting Rules
83
+
84
+ Standardized formatters live in [src/interactive/theme/labels.ts](../src/interactive/theme/labels.ts) and other shared UI modules:
85
+
86
+ - **Duration**: `formatCompactMs` is the unified duration formatter, yielding compact outputs (`860ms`, `4.2s`, `42s`, `1m36s`).
87
+ - **Token Counts**: `formatFooterTokens` formats footer and chip counts (`842`, `12.4k`, `1.2M`). Full numeric strings via `toLocaleString` are reserved for detailed tables like the context legend.
88
+ - **Cost**: The shared `formatUsd` formatter handles dollar values, printing up to four decimal places when under one cent.
89
+ - **Model IDs**: `abbreviateModelId` keeps whole dash-separated parts of model names up to 18 characters; if the parts still overflow, it clips the ID at 18 characters.
90
+
91
+ ---
92
+
93
+ ## 4. Structural Layouts
94
+
95
+ ### 4.1 The Island (Framed Block)
96
+
97
+ Rendered via `frame()` in [src/interactive/theme/rules.ts](../src/interactive/theme/rules.ts):
98
+
99
+ ```
100
+ ┌─ Title ──────────────────────────── meta ─┐
101
+ │ body line │
102
+ │ body line │
103
+ └───────────────────────────────────────────┘
104
+ ```
105
+
106
+ - Corners and borders use `frame`.
107
+ - `Title` is written in bold `title` color, padded with exactly one space on each side.
108
+ - The right-aligned `meta` field is drawn in `dim` color before the closing corner.
109
+ - Body rows use the vertical rail `│` with one space of padding.
110
+ - Inner dividers use `╌` in `frame` color.
111
+
112
+ ### 4.2 The Overlay
113
+
114
+ Overlay frames share the island's top border rules and include keyboard shortcut hints in the bottom border:
115
+
116
+ ```
117
+ └─ [Tab] mode · [Esc] close ─────────────────┘
118
+ ```
119
+
120
+ ### 4.3 Section Headers
121
+
122
+ - **Panel Section Tag**: Bold CAPS in `accentDeep`.
123
+ - **List Group Header**: A leading rule followed by the label, e.g. `── Label` in `dim`.
124
+
125
+ ### 4.4 Key-Value Rows
126
+
127
+ Drawn as `<key padded, dim> <value>`, where the value defaults to `muted` unless a semantic token applies.
128
+
129
+ ### 4.5 The Status Pill
130
+
131
+ ```
132
+ <spinner|glyph> <label> [ · badge]
133
+ ```
134
+
135
+ - For active phases, the animated spinner frames replace the static phase glyph.
136
+ - Spinner, glyph, and label all use the current phase's token color.
137
+ - Badges are separated by dim dots: `· fleet 2` (action), `· tools 1` (muted).
138
+
139
+ ### 4.6 Narrow Terminal Behavior
140
+
141
+ All TUI overlays and cards support compact widths down to 40 columns:
142
+ - Split overlays such as `/view` fall back to a single pane layout with `[Tab]` switching between the artifact list and details.
143
+ - Keybinding hints, cards, and markdown detail text wrap fluidly without horizontal clipping.
144
+
145
+
146
+ ---
147
+
148
+ ## 5. State Choreography
149
+
150
+ The Clio screen maintains a fixed structure: banner, transcript, editor rail, and footer. State is signaled through the status pill in the footer and matches the following table:
151
+
152
+ | State | Pill | Transcript Echo | Action Orange? |
153
+ |---|---|---|---|
154
+ | idle | `◌ idle · tools none` (muted) | None; last-turn telemetry on line 2 | No |
155
+ | preparing / waiting | spinner + `waiting` (info) | None | No |
156
+ | thinking | spinner + `thinking` (reason) | Dim `Thinking (N tokens)...` marker | No |
157
+ | writing | spinner + `writing` (accent) | Streaming markdown text | No |
158
+ | tool running | spinner + `tool <name>` (accent) | `▸` tool execution ledger line | No |
159
+ | blocked | `⏸ blocked` (warning) | Permission prompt surface | No |
160
+ | retrying | `↻ retry 2/5` (warning) | Dim retry details line | No |
161
+ | compacting | spinner + `compacting` (reason) | None | No |
162
+ | dispatching / fleet live | spinner + `dispatch` (action) | Task island status updates | Yes |
163
+ | stuck | `⚠ stuck 12s` (error) | Inline watchdog warning | No |
164
+ | done | `✓ done` (success), then telemetry | Settled transcript blocks | No |
165
+
166
+ ---
167
+
168
+ ## 6. Agent and Transcript Formatting
169
+
170
+ ### 6.1 Voices
171
+ - **User**: `› text` with the user glyph in `accent`.
172
+ - **Agent**: `✦ text` with the agent glyph in `accent` (turning `error` red on failed turns, along with the text message).
173
+
174
+ ### 6.2 Thinking Blocks
175
+ Drawn as a folded dim marker (`Thinking (N tokens)...` or `Thinking...`), which expands into a body using the `reason` color vertical `│` rail. Cap of 12 lines.
176
+
177
+ ### 6.3 Tool Ledger
178
+ Tool lines wrap as a single composed block:
179
+ ```
180
+ ▸ verb object · resource · facts · size ✓ · 230ms · full: path (ctrl+o)
181
+ ```
182
+ - Verb is bold `accent`, tail details are `dim`, status glyph is semantic (`✓`/`✗`), and the keyboard shortcut hint is appended at the end.
183
+
184
+ ### 6.4 Editor Rail
185
+ The right-hand label shows `model · thinking`. Thinking level colors map as: `off` (dim), `minimal`/`low` (muted), and `medium` and above (purple `reason`).
186
+
187
+ ### 6.5 Transcript Notices
188
+ Replay and system tags (e.g. `[retry]`, `[model]`) are wrapped in `dim` brackets with a `muted` message. Retry tags use `warning` amber.
189
+
190
+ ### 6.6 Code Ink (Syntax Highlighting)
191
+
192
+ Syntax highlighting within code blocks is handled by [src/interactive/renderers/code-ink.ts](../src/interactive/renderers/code-ink.ts). It maps a restricted set of four tokens to stay quiet:
193
+
194
+ - **Comments**: `dim`
195
+ - **String Literals**: `success`
196
+ - **Language Keywords**: `reason`
197
+ - **Numeric Literals**: `info`
198
+
199
+ All other code elements (identifiers, types, function names, punctuation) remain plain. Diff blocks highlight added lines with `success` green and removed lines with `error` red.
200
+
201
+ ---
202
+
203
+ ## 7. v0.2.9 TUI & Cost Provenance Transformations
204
+
205
+ ### 7.1 Fleet Visibility Across Surfaces
206
+ - **Dispatch Board**: Displays per-run status cards with node assignments (`local` vs remote node ID), reroute badges, gate indicators (`gate reviewer c2`), live tool activity, and context occupancy meters.
207
+ - **`/fleet` Overlay**: Modal overlay allowing operators to view running dispatches, inspect node capabilities, edit profile node pins, and monitor worker heartbeats.
208
+ - **Parked Tools & Approvals**: Parked tool calls awaiting permission are rendered as `⏸ awaiting approval` with explicit approval prompts. Input overlays stay modal during active runs so background completions do not displace open dialogs.
209
+
210
+ ### 7.2 Cost Provenance & Evidence Rendering
211
+ - **Session vs Run Provenance**: The Activity footer renders session token/cost totals, while the dispatch board and `/fleet` overlay render per-run worker tokens and cost with `known`, `estimated`, or `unknown` provenance markers. The current surfaces do not present a separate orchestrator-versus-worker algebra.
212
+ - **Proof Markers**: Dispatch cards and `/fleet` rows render evidence readiness as `proof` markers (`pending`, `ready`, or `failed`) from the observability projection. Model-facing dispatch and monitor output use `receipt_integrity=verified/v15/sha256` and a separate `evidence_verification` label; the TUI does not emit a `[VERIFIED_RECEIPT_OK]` badge.
213
+
214
+ ---
215
+
216
+ ## 8. Shared Vocabulary
217
+
218
+ One quantity gets one word, and every surface that shows it uses that word. A user comparing the transcript, the footer, and an overlay is checking whether Clio is telling a consistent story; a synonym reads as a discrepancy. `tests/contracts/usage-vocabulary.test.ts` holds the pairs that had drifted.
219
+
220
+ | Concept | Word | Surfaces |
221
+ | --- | --- | --- |
222
+ | One model API call | `call` | Chat panel `turn · in N over M calls`, `/cost` `model calls`, `/cost` `(avg/call …)` |
223
+ | One user-to-assistant exchange | `turn` | Chat panel `turn · …`, `/cost` `turns` |
224
+ | Provider-reported reasoning tokens | `reasoning N provider` | Chat panel |
225
+ | Reasoning tokens estimated from displayed text | `reasoning ≈N estimated` | Chat panel; the footer carries the same `≈` on `r≈N` |
226
+ | Reasoning tokens in the cost tally | `reasoning N provider-reported only` | `/cost`. This tally never estimates, so it disagrees with the panel on a model that reports nothing, and the row says which one it is. |
227
+ | Thinking level a model cannot turn off | `forced` | Editor rail, model overlay, thinking cycle (`thinkingLevelDisplayWord`) |
228
+ | Thinking level on a model with only on and off | `on` / `off` | Same surfaces |
229
+
230
+ ### 8.1 Slash-Command Failures
231
+
232
+ Two shapes, both ending at something the user can act on.
233
+
234
+ - A command that exists but was called wrongly prints the reason and then that command's usage line: `<reason>. usage: /<name> …`.
235
+ - A command-shaped token that is not a command prints `/<token> is not a command. Type /help for the list.` and is never sent to the model as chat. The escape for a line that starts with a slash is a leading backslash, so `\/tmp is full` reaches the model as `/tmp is full`. A leading space does not work and never did, because the editor trims the submitted line before the parser sees it.
236
+
237
+ ### 8.2 Memory Step Rows
238
+
239
+ `/memory` activity rows read `<trigger> <decision> <reason>`, followed by `<N>w` when the step wrote to the bank and `<N> cited` when it cited entries, then the tier and latency. `describeTaskMemoryActivity` is the one place that builds this string.