@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,461 @@
1
+ // src/core/guardrails.ts
2
+ var GUARDRAIL_DEFAULTS = {
3
+ turnToolCallBudget: 60,
4
+ workerToolCallCap: 150,
5
+ maxDispatchRuns: 1e3,
6
+ readMaxBytes: 50 * 1024,
7
+ observationTurnBudgetBytes: 192 * 1024,
8
+ internalDispatchTimeoutMs: 15 * 60 * 1e3
9
+ };
10
+ var GUARDRAIL_ENV_VARS = {
11
+ turnToolCallBudget: "CLIO_CODER_TURN_TOOL_CALL_BUDGET",
12
+ workerToolCallCap: "CLIO_CODER_WORKER_TOOL_CALL_CAP",
13
+ maxDispatchRuns: "CLIO_CODER_MAX_RUNS",
14
+ readMaxBytes: "CLIO_CODER_READ_MAX_BYTES",
15
+ observationTurnBudgetBytes: "CLIO_CODER_OBSERVATION_TURN_BUDGET_BYTES",
16
+ internalDispatchTimeoutMs: "CLIO_CODER_INTERNAL_DISPATCH_TIMEOUT_MS"
17
+ };
18
+ function workerSynthesisReserveDirective(remaining, cap) {
19
+ return `budget reserve: only ${remaining} of your ${cap} tool calls remain, and they are reserved for verification reads and synthesis. Stop broad exploration now: re-read the locations you will cite, then answer in prose. Calls that are not reads will be blocked.`;
20
+ }
21
+ function workerSynthesisReserveBlockReason(tool, remaining, cap) {
22
+ return `workerToolCallReserve: only ${remaining} of ${cap} tool calls remain and they are reserved for verification reads and synthesis; ${tool} is not a read. Re-read any locations you will cite, then answer in prose from what you have gathered.`;
23
+ }
24
+ function workerToolCallCapExceededReason(cap) {
25
+ return `workerToolCallCap reached (${cap}); abort run`;
26
+ }
27
+ function isWorkerToolCallCapExceededReason(reason) {
28
+ return /^workerToolCallCap reached \([1-9]\d*\); abort run$/.test(reason);
29
+ }
30
+ function workerToolCallCapSynthesisReason(cap) {
31
+ return `workerToolCallCap reached (${cap}); tool calls are now disabled for the rest of this run. Everything you retrieved is already in the conversation above. Answer the operator now, in plain prose, from what you have gathered. Do not write tool-call markup such as <tool_call> blocks; tool calls are disabled and will not run.`;
32
+ }
33
+ function isWorkerToolCallCapSynthesisReason(reason) {
34
+ return /^workerToolCallCap reached \([1-9]\d*\); tool calls are now disabled/.test(reason);
35
+ }
36
+ function mentionsWorkerToolCallCap(text) {
37
+ return typeof text === "string" && /workerToolCallCap reached \([1-9]\d*\)/.test(text);
38
+ }
39
+ var configured = {};
40
+ function configureGuardrails(values) {
41
+ configured = { ...values ?? {} };
42
+ }
43
+ function parsePositiveSafeInt(raw) {
44
+ if (raw === void 0) return void 0;
45
+ const normalized = raw.trim();
46
+ if (!/^[1-9]\d*$/.test(normalized)) return void 0;
47
+ const parsed = Number(normalized);
48
+ return Number.isSafeInteger(parsed) ? parsed : void 0;
49
+ }
50
+ function resolveGuardrail(key, env = process.env) {
51
+ return parsePositiveSafeInt(env[GUARDRAIL_ENV_VARS[key]]) ?? configured[key] ?? GUARDRAIL_DEFAULTS[key];
52
+ }
53
+
54
+ // src/core/defaults.ts
55
+ var THINKING_LEVELS = [
56
+ "off",
57
+ "minimal",
58
+ "low",
59
+ "medium",
60
+ "high",
61
+ "xhigh",
62
+ "max"
63
+ ];
64
+ var DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS = 3e4;
65
+ var DEFAULT_DELEGATION_TURN_TIMEOUT_MS = 3e5;
66
+ var DEFAULT_DELEGATION_PERMISSION_TIMEOUT_MS = 12e4;
67
+ var ACTIVE_ROUTING_ROLES = ["researcher", "verifier", "reviewer", "judge"];
68
+ var ACTIVE_ROUTING_POSTURES = ["quality", "balanced", "latency", "economy"];
69
+ var ACTIVE_AGENT_AUTOMATION_ROLES = ["builder", "researcher", "verifier", "reviewer", "judge"];
70
+ var DEFAULT_SETTINGS = {
71
+ version: 1,
72
+ identity: "clio",
73
+ autonomy: "auto-edit",
74
+ targets: [],
75
+ runtimePlugins: [],
76
+ orchestrator: {
77
+ target: null,
78
+ model: null,
79
+ thinkingLevel: "off"
80
+ },
81
+ // Optional small-model plane for task-memory maintenance. An unset target
82
+ // keeps proactive memory in its deterministic rules-only tier.
83
+ background: {
84
+ target: null,
85
+ model: null,
86
+ thinkingLevel: "off"
87
+ },
88
+ memory: {
89
+ intervention: {
90
+ enabled: true,
91
+ everyNTools: 10,
92
+ windowSteps: 8,
93
+ maxTokens: 400,
94
+ // A memory step runs detached from the turn that triggered it, so a
95
+ // generous deadline costs no interactive latency. Measured steps on a
96
+ // small local route ranged past two minutes, and a deadline shorter than
97
+ // the model discards finished work as a timeout.
98
+ timeoutMs: 18e4
99
+ }
100
+ },
101
+ workers: {
102
+ default: {
103
+ target: null,
104
+ model: null,
105
+ thinkingLevel: "off"
106
+ },
107
+ profiles: {},
108
+ agentBindings: {},
109
+ maxRetries: 2,
110
+ onPermission: "deny",
111
+ escalation: { timeoutMs: 12e4, fallback: "deny" },
112
+ resilienceCooldownMs: 15e3
113
+ },
114
+ fleet: {
115
+ nodes: []
116
+ },
117
+ routing: {
118
+ activeRoles: [],
119
+ activePostures: [],
120
+ agentAutomation: { activeAgentRoles: [] }
121
+ },
122
+ scope: [],
123
+ modelSelector: {
124
+ favorites: [],
125
+ recentLimit: 12
126
+ },
127
+ budget: {
128
+ sessionCeilingUsd: 5,
129
+ concurrency: "auto"
130
+ },
131
+ defaults: {
132
+ // Output tokens requested per turn, applied to every target. The value is
133
+ // always clamped down to the model's known max-output cap and the
134
+ // remaining context window at request time, so a model that supports less
135
+ // automatically gets less. 0 disables the global default and falls back to
136
+ // per-model caps only.
137
+ maxTokens: 32768
138
+ },
139
+ theme: "default",
140
+ terminal: {
141
+ showTerminalProgress: false,
142
+ outputVerbosity: "default"
143
+ },
144
+ skills: {
145
+ trustProjectCompatRoots: false
146
+ },
147
+ delegation: {
148
+ agents: [],
149
+ defaults: {
150
+ connectTimeoutMs: DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS,
151
+ turnTimeoutMs: DEFAULT_DELEGATION_TURN_TIMEOUT_MS,
152
+ permissionTimeoutMs: DEFAULT_DELEGATION_PERMISSION_TIMEOUT_MS,
153
+ toolGovernance: "clio-policy"
154
+ }
155
+ },
156
+ // User keybinding overrides. Each id maps to a single KeyId string or a
157
+ // list of KeyIds. The interactive keybinding manager reads this table
158
+ // and layers it on top of CLIO_KEYBINDINGS defaults (src/domains/config/
159
+ // keybindings.ts).
160
+ keybindings: {},
161
+ compaction: {
162
+ auto: true,
163
+ threshold: 0.8,
164
+ excludeLastTurns: 6
165
+ },
166
+ retry: {
167
+ enabled: true,
168
+ maxRetries: 3,
169
+ baseDelayMs: 2e3,
170
+ maxDelayMs: 6e4
171
+ },
172
+ // Numeric backstops that bound runaway agent behavior. Settings are the
173
+ // primary home; each value also has a per-process env override for CI and
174
+ // one-off experiments (core/guardrails.ts documents both).
175
+ guardrails: { ...GUARDRAIL_DEFAULTS }
176
+ };
177
+ var DEFAULT_SETTINGS_YAML = `# Clio Coder settings. Written once on first install.
178
+ # The file is machine-owned: \`clio-coder configure\`, \`clio-coder targets\`, and the TUI
179
+ # rewrite it whole, and comments (including these) do not survive that write.
180
+ # Docs: https://github.com/iowarp/clio-coder
181
+ #
182
+ # Default location:
183
+ # Linux: ~/.config/clio-coder/settings.yaml
184
+ # macOS: ~/Library/Application Support/clio-coder/config/settings.yaml
185
+ # Windows: %APPDATA%/clio-coder/config/settings.yaml
186
+ # Set CLIO_CODER_HOME for a single-tree install, or CLIO_CODER_CONFIG_DIR / CLIO_CODER_DATA_DIR /
187
+ # CLIO_CODER_STATE_DIR / CLIO_CODER_CACHE_DIR to override each directory separately.
188
+ #
189
+ # Common first run after installation:
190
+ # 1. Repair/create local state: clio-coder doctor --fix
191
+ # 2. List runtimes: clio-coder configure --list
192
+ # 3. Configure one target with your runtime/model (examples below).
193
+ # 4. Select and probe it: clio-coder targets use <id> && clio-coder targets --probe
194
+ # 5. Launch: clio-coder
195
+
196
+ version: 1
197
+ identity: clio
198
+ autonomy: auto-edit # read-only | suggest | auto-edit | full-auto
199
+
200
+ # Inference targets. Each entry becomes selectable for chat and workers.
201
+ # Add entries via \`clio-coder configure\` or \`clio-coder targets add\`
202
+ # or hand-edit. \`runtime\` must match an id registered in the runtime registry
203
+ # (cloud APIs, local HTTP engines, or third-party plugins in the \`runtimes/\`
204
+ # directory next to this file).
205
+ targets: []
206
+ # Local runtime examples (uncomment/adapt one; replace your-model-id):
207
+ # clio-coder configure --id local-lmstudio --runtime lmstudio-native --url http://localhost:1234 --model your-model-id --set-orchestrator --set-fleet-default
208
+ # clio-coder configure --id local-ollama --runtime ollama-native --url http://localhost:11434 --model your-model-id --set-orchestrator --set-fleet-default
209
+ # clio-coder configure --id local-llamacpp --runtime llamacpp --url http://127.0.0.1:8080 --model your-model-id --set-orchestrator --set-fleet-default
210
+ # clio-coder configure --id local-vllm --runtime vllm --url http://localhost:8000 --model your-model-id --set-orchestrator --set-fleet-default
211
+ # clio-coder configure --id local-sglang --runtime sglang --url http://localhost:30000 --model your-model-id --set-orchestrator --set-fleet-default
212
+ # Add --context-window <tokens>, --max-tokens <tokens>, or --reasoning true
213
+ # only when you have runtime/model-specific values to override probe results.
214
+ #
215
+ # Example target block equivalent to one configured local runtime:
216
+ # targets:
217
+ # - id: local-lmstudio
218
+ # runtime: lmstudio-native
219
+ # url: http://localhost:1234
220
+ # defaultModel: your-model-id
221
+ # capabilities:
222
+ # reasoning: true
223
+
224
+ # Optional npm packages that export clioRuntimes: RuntimeDescriptor[].
225
+ runtimePlugins: []
226
+
227
+ # Orchestrator target for the interactive loop. \`target\` refers to
228
+ # targets[].id; \`model\` is the wire model id to request.
229
+ # Keep thinkingLevel off unless a target/model supports explicit reasoning levels.
230
+ orchestrator:
231
+ target: null
232
+ model: null
233
+ thinkingLevel: off
234
+
235
+ # Optional background target for proactive task memory. Leave unset for the
236
+ # zero-cost rules-only tier; setting it opts this session into LLM memory steps.
237
+ background:
238
+ target: null
239
+ model: null
240
+ thinkingLevel: off
241
+
242
+ memory:
243
+ intervention:
244
+ enabled: true
245
+ everyNTools: 10
246
+ windowSteps: 8
247
+ maxTokens: 400
248
+ timeoutMs: 180000
249
+
250
+ # Worker targets for dispatch. \`default\` preserves the legacy behavior when a
251
+ # recipe or request does not specify an override. \`profiles\` are named
252
+ # target/model/thinking choices. \`agentBindings\` pins native Clio agents,
253
+ # including shadow agents such as scout/researcher/provenance, to a profile.
254
+ workers:
255
+ default:
256
+ target: null
257
+ model: null
258
+ thinkingLevel: off
259
+ profiles: {}
260
+ # Example profile entry:
261
+ # profiles:
262
+ # fast-local:
263
+ # target: local-lmstudio
264
+ # model: your-model-id
265
+ # thinkingLevel: off
266
+ # agentBindings maps agent id -> profiles key, e.g. scout: fast-local.
267
+ agentBindings: {}
268
+ maxRetries: 2
269
+ # onPermission: what a worker does when a tool call needs interactive
270
+ # permission. "deny" turns it into a structured tool denial and the run
271
+ # continues; "fail" finalizes the run as failed/permission_required;
272
+ # "escalate" hands the ask to the interactive operator (timeout fallback
273
+ # below keeps the run non-stall).
274
+ onPermission: deny
275
+ # escalation: bounds for the escalate posture. A parked ask with no operator
276
+ # decision within timeoutMs applies the fallback deny/fail.
277
+ escalation:
278
+ timeoutMs: 120000
279
+ fallback: deny
280
+ resilienceCooldownMs: 15000
281
+
282
+ # Fleet worker nodes reachable over SSH. The implicit \`local\` node always
283
+ # exists and is never declared. A node becomes dispatch-eligible only after
284
+ # \`clio-coder doctor\` verifies SSH reachability, a version-matched clio-coder, path
285
+ # parity for the project root (shared filesystem), and a writable state dir.
286
+ # residency defaults to observe: remote workers never evict models resident
287
+ # on their node (set manage per node to opt into the reconciler).
288
+ fleet:
289
+ nodes: []
290
+ # - id: node-a
291
+ # host: node-a.example.net
292
+ # user: me
293
+ # identityFile: ~/.ssh/id_fleet
294
+ # labels: [cpu]
295
+ # maxWorkers: 2
296
+ # - id: node-b
297
+ # host: node-b.example.net
298
+ # maxWorkers: 1
299
+ # residency: observe
300
+
301
+ # Joint route selection is shadow-only unless both the execution role and the
302
+ # requested posture are named here. Manual pins remain exact and fail closed.
303
+ routing:
304
+ activeRoles: [] # researcher | verifier | reviewer | judge
305
+ activePostures: [] # quality | balanced | latency | economy
306
+ # Agent changes remain advisory unless the concrete agent/role pair appears
307
+ # here. Exact pairs avoid implicitly approving an agents \xD7 roles cross-product.
308
+ agentAutomation:
309
+ activeAgentRoles: []
310
+
311
+ # Alt+J / Alt+K cycling order: plain target ids or "target/model" refs.
312
+ scope: []
313
+
314
+ # /models focused picker. Favorites are exact "target/model" refs shown before
315
+ # the full search catalog. Recently selected models are runtime state and live
316
+ # in the state dir (recent-models.json), not in this file.
317
+ modelSelector:
318
+ favorites: []
319
+ recentLimit: 12
320
+
321
+ # Session budget guardrails.
322
+ budget:
323
+ sessionCeilingUsd: 5
324
+ concurrency: auto # auto or a positive integer
325
+
326
+ # Global request defaults applied to every target.
327
+ # maxTokens output tokens requested per turn. Always clamped down to the
328
+ # model's known max-output cap and the remaining context window,
329
+ # so models that support less automatically get less. Set 0 to
330
+ # fall back to per-model caps only.
331
+ defaults:
332
+ maxTokens: 32768
333
+
334
+ theme: default
335
+ terminal:
336
+ # OSC 9;4 terminal progress badges are opt-in; some terminals surface these
337
+ # in taskbars/tabs and keep them visible for long-running agent work.
338
+ showTerminalProgress: false
339
+ # Transcript detail: minimal, default, or verbose. Also changeable with /output.
340
+ outputVerbosity: default
341
+
342
+ # Skills are local prompt resources. Project-local compatibility roots such as
343
+ # .agents/skills, .claude/skills, .codex/skills, .github/skills, and
344
+ # .opencode/skills stay hidden from model invocation unless this is true or
345
+ # CLIO_CODER_TRUST_PROJECT_SKILLS=1 is set for the process.
346
+ skills:
347
+ trustProjectCompatRoots: false
348
+
349
+ # External coding agents that speak Agent Client Protocol v1 over stdio.
350
+ # These are delegated harnesses, not model targets, so they stay outside
351
+ # targets[], orchestrator, workers, and model pickers.
352
+ delegation:
353
+ defaults:
354
+ connectTimeoutMs: ${DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS}
355
+ turnTimeoutMs: ${DEFAULT_DELEGATION_TURN_TIMEOUT_MS}
356
+ permissionTimeoutMs: ${DEFAULT_DELEGATION_PERMISSION_TIMEOUT_MS}
357
+ toolGovernance: clio-policy # clio-policy | agent-managed | deny-all
358
+ agents: []
359
+ # OpenCode native ACP:
360
+ # - id: opencode
361
+ # command: opencode
362
+ # args: [acp, --cwd, .]
363
+ # toolGovernance: clio-policy
364
+ # labels:
365
+ # specialty: coding
366
+ #
367
+ # Codex via an ACP adapter:
368
+ # - id: codex
369
+ # command: npx
370
+ # args: [-y, "@agentclientprotocol/codex-acp"]
371
+ # toolGovernance: clio-policy
372
+ # labels:
373
+ # specialty: coding
374
+ #
375
+ # Claude Code via its ACP adapter (runs on your Claude Pro/Max subscription;
376
+ # the claude CLI has no ACP of its own, so this adapter bridges the Claude
377
+ # Code SDK). Tool calls are gated by Clio safety under clio-policy; switch to
378
+ # agent-managed to let Claude Code govern its own tools.
379
+ # - id: claude-code
380
+ # command: npx
381
+ # args: [-y, "@zed-industries/claude-code-acp"]
382
+ # toolGovernance: clio-policy
383
+ # labels:
384
+ # specialty: coding
385
+
386
+ keybindings: {}
387
+
388
+ # Context compaction controls.
389
+ # auto master switch for the pre-request compaction trigger.
390
+ # Manual /compact always runs the LLM summary.
391
+ # threshold pressure = estimated_tokens / context_window. Crossing
392
+ # it masks stale tool observations first, then runs a
393
+ # full LLM summary if pressure stays above the threshold.
394
+ # excludeLastTurns recent user turns protected from observation masking.
395
+ # model optional pattern (e.g. provider/summary-model-id) for a
396
+ # dedicated summarization model. Absent \u21D2 orchestrator target.
397
+ # systemPrompt optional path to a prompt-override file.
398
+ compaction:
399
+ auto: true
400
+ threshold: 0.8
401
+ excludeLastTurns: 6
402
+ # model: provider/summary-model-id
403
+ # systemPrompt: ~/.config/clio-coder/prompts/compaction.md
404
+
405
+ # Transient provider/stream retry controls for interactive chat.
406
+ # Retryable errors include overloads, rate limits, 5xx responses, network
407
+ # resets, and timeouts. Context overflow uses compaction recovery instead.
408
+ # Dispatched worker runs retry under workers.maxRetries, not this block.
409
+ retry:
410
+ enabled: true
411
+ maxRetries: 3
412
+ baseDelayMs: 2000
413
+ maxDelayMs: 60000
414
+
415
+ # Guardrails: numeric backstops that bound runaway agent behavior.
416
+ # turnToolCallBudget orchestrator per-turn soft tool-call budget;
417
+ # the hard interrupt ceiling sits 15 above it.
418
+ # workerToolCallCap ceiling on tool calls a dispatched worker may
419
+ # execute; the agent recipe's own budget is what
420
+ # normally binds, and refused calls never spend it.
421
+ # maxDispatchRuns dispatch run-ledger retention cap.
422
+ # readMaxBytes per-call byte cap for the read tool.
423
+ # observationTurnBudgetBytes shared per-turn byte pool for observation tools.
424
+ # internalDispatchTimeoutMs wall-clock cap for one internal generator
425
+ # dispatch (wiki documenter, bootstrap scout).
426
+ # Each value also has a per-process env override (CLIO_CODER_TURN_TOOL_CALL_BUDGET,
427
+ # CLIO_CODER_WORKER_TOOL_CALL_CAP, CLIO_CODER_MAX_RUNS, CLIO_CODER_READ_MAX_BYTES,
428
+ # CLIO_CODER_OBSERVATION_TURN_BUDGET_BYTES, CLIO_CODER_INTERNAL_DISPATCH_TIMEOUT_MS) meant
429
+ # for CI and one-off experiments.
430
+ guardrails:
431
+ turnToolCallBudget: 60
432
+ workerToolCallCap: 150
433
+ maxDispatchRuns: 1000
434
+ readMaxBytes: 51200
435
+ observationTurnBudgetBytes: 196608
436
+ internalDispatchTimeoutMs: 900000
437
+ `;
438
+
439
+ export {
440
+ GUARDRAIL_DEFAULTS,
441
+ GUARDRAIL_ENV_VARS,
442
+ workerSynthesisReserveDirective,
443
+ workerSynthesisReserveBlockReason,
444
+ workerToolCallCapExceededReason,
445
+ isWorkerToolCallCapExceededReason,
446
+ workerToolCallCapSynthesisReason,
447
+ isWorkerToolCallCapSynthesisReason,
448
+ mentionsWorkerToolCallCap,
449
+ configureGuardrails,
450
+ resolveGuardrail,
451
+ THINKING_LEVELS,
452
+ DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS,
453
+ DEFAULT_DELEGATION_TURN_TIMEOUT_MS,
454
+ DEFAULT_DELEGATION_PERMISSION_TIMEOUT_MS,
455
+ ACTIVE_ROUTING_ROLES,
456
+ ACTIVE_ROUTING_POSTURES,
457
+ ACTIVE_AGENT_AUTOMATION_ROLES,
458
+ DEFAULT_SETTINGS,
459
+ DEFAULT_SETTINGS_YAML
460
+ };
461
+ //# sourceMappingURL=chunk-UHTSULZS.js.map
@@ -0,0 +1,128 @@
1
+ import {
2
+ settingsPath,
3
+ validateSettings
4
+ } from "./chunk-JWHCJDCI.js";
5
+
6
+ // src/core/settings-layers.ts
7
+ import { existsSync, readFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { parse as parseYaml } from "yaml";
10
+ var CREDENTIAL_KEYS = /* @__PURE__ */ new Set(["auth", "apikey", "api_key", "token", "secret", "password"]);
11
+ function isRecord(value) {
12
+ return value !== null && typeof value === "object" && !Array.isArray(value);
13
+ }
14
+ function readRawLayer(origin, path, issues) {
15
+ if (!existsSync(path)) return { origin, path, blob: void 0 };
16
+ let parsed;
17
+ try {
18
+ parsed = parseYaml(readFileSync(path, "utf8"));
19
+ } catch (err) {
20
+ issues.push({ origin, path, message: `invalid YAML: ${err instanceof Error ? err.message : String(err)}` });
21
+ return { origin, path, blob: void 0 };
22
+ }
23
+ if (parsed === null || parsed === void 0) return { origin, path, blob: {} };
24
+ if (!isRecord(parsed)) {
25
+ issues.push({ origin, path, message: "settings file must be a mapping at the root" });
26
+ return { origin, path, blob: void 0 };
27
+ }
28
+ return { origin, path, blob: parsed };
29
+ }
30
+ function stripCredentials(value, origin, path, issues) {
31
+ if (Array.isArray(value)) {
32
+ return value.map((item, index) => stripCredentials(item, origin, `${path}[${index}]`, issues));
33
+ }
34
+ if (!isRecord(value)) return value;
35
+ const out = {};
36
+ for (const [key, child] of Object.entries(value)) {
37
+ if (CREDENTIAL_KEYS.has(key.toLowerCase())) {
38
+ issues.push({
39
+ origin,
40
+ path: path ? `${path}.${key}` : key,
41
+ message: "credentials are not allowed in project settings; key ignored"
42
+ });
43
+ continue;
44
+ }
45
+ out[key] = stripCredentials(child, origin, path ? `${path}.${key}` : key, issues);
46
+ }
47
+ return out;
48
+ }
49
+ function mergeLayersWithSources(layers) {
50
+ const merged = {};
51
+ const sources = {};
52
+ for (const layer of layers) {
53
+ if (layer.blob === void 0) continue;
54
+ mergeInto(merged, layer.blob, layer.origin, "", sources);
55
+ }
56
+ return { merged, sources };
57
+ }
58
+ function mergeInto(target, source, origin, prefix, sources) {
59
+ for (const [key, value] of Object.entries(source)) {
60
+ const path = prefix ? `${prefix}.${key}` : key;
61
+ if (isRecord(value)) {
62
+ const existing = target[key];
63
+ const nested = isRecord(existing) ? existing : {};
64
+ mergeInto(nested, value, origin, path, sources);
65
+ target[key] = nested;
66
+ sources[path] = origin;
67
+ } else {
68
+ target[key] = Array.isArray(value) ? [...value] : value;
69
+ sources[path] = origin;
70
+ }
71
+ }
72
+ }
73
+ function readLayeredSettings(cwd, options = {}) {
74
+ const issues = [];
75
+ const userFile = options.userPath ?? settingsPath();
76
+ const projectFile = join(cwd, ".clio-coder", "settings.yaml");
77
+ const localFile = join(cwd, ".clio-coder", "settings.local.yaml");
78
+ const user = readRawLayer("user", userFile, issues);
79
+ const projectRaw = readRawLayer("project", projectFile, issues);
80
+ const localRaw = readRawLayer("project.local", localFile, issues);
81
+ const project = {
82
+ ...projectRaw,
83
+ blob: projectRaw.blob === void 0 ? void 0 : stripCredentials(projectRaw.blob, "project", "", issues)
84
+ };
85
+ const local = {
86
+ ...localRaw,
87
+ blob: localRaw.blob === void 0 ? void 0 : stripCredentials(localRaw.blob, "project.local", "", issues)
88
+ };
89
+ const { merged, sources } = mergeLayersWithSources([user, project, local]);
90
+ const validation = validateSettings(merged);
91
+ for (const issue of validation.issues) {
92
+ issues.push({ origin: settingsSourceFor(sources, issue.path), path: issue.path, message: issue.message });
93
+ }
94
+ return {
95
+ settings: validation.settings,
96
+ sources,
97
+ issues,
98
+ layers: [
99
+ { origin: "built-in", path: "(defaults)", present: true },
100
+ { origin: "user", path: userFile, present: user.blob !== void 0 },
101
+ { origin: "project", path: projectFile, present: projectRaw.blob !== void 0 },
102
+ { origin: "project.local", path: localFile, present: localRaw.blob !== void 0 }
103
+ ]
104
+ };
105
+ }
106
+ function settingsSourceFor(sources, keyPath) {
107
+ let prefix = keyPath;
108
+ while (prefix.length > 0) {
109
+ const direct = sources[prefix];
110
+ if (direct) return direct;
111
+ const bracket = prefix.lastIndexOf("[");
112
+ if (bracket >= 0) {
113
+ const arrayKey = prefix.slice(0, bracket);
114
+ const hit = sources[arrayKey];
115
+ if (hit) return hit;
116
+ }
117
+ const dot = prefix.lastIndexOf(".");
118
+ if (dot < 0) break;
119
+ prefix = prefix.slice(0, dot);
120
+ }
121
+ return "built-in";
122
+ }
123
+
124
+ export {
125
+ readLayeredSettings,
126
+ settingsSourceFor
127
+ };
128
+ //# sourceMappingURL=chunk-UU3R62TT.js.map