@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,518 @@
1
+ import {
2
+ listEvidenceOverviews
3
+ } from "./chunk-GNGDQYDU.js";
4
+ import "./chunk-2J63S4SF.js";
5
+ import "./chunk-RQDWMVRB.js";
6
+ import "./chunk-7BHLZB3A.js";
7
+ import "./chunk-TPOCL34A.js";
8
+ import "./chunk-E3NYWENM.js";
9
+ import "./chunk-XV4ZJ6ZM.js";
10
+ import "./chunk-26BZQOAD.js";
11
+ import "./chunk-WD6AJM35.js";
12
+ import "./chunk-QV47YRF4.js";
13
+ import "./chunk-CLJ5HLUD.js";
14
+ import "./chunk-BBUH4VAA.js";
15
+ import "./chunk-GOTUR54M.js";
16
+ import "./chunk-PIDUD6M2.js";
17
+ import {
18
+ printError,
19
+ printOk
20
+ } from "./chunk-67MTHP2E.js";
21
+ import "./chunk-TKHQ4DGZ.js";
22
+ import "./chunk-D5YD55AR.js";
23
+ import "./chunk-JWHCJDCI.js";
24
+ import "./chunk-UHTSULZS.js";
25
+ import "./chunk-5LDRNKX2.js";
26
+ import "./chunk-UGYAX5YI.js";
27
+ import "./chunk-5N2FG33Q.js";
28
+ import "./chunk-VPAWTYLY.js";
29
+ import {
30
+ clioDataDir
31
+ } from "./chunk-X3NE4WVW.js";
32
+ import "./chunk-DXQNI4PC.js";
33
+
34
+ // src/cli/evolve.ts
35
+ import { resolve } from "node:path";
36
+
37
+ // src/domains/evolution/manifest.ts
38
+ import { readFile } from "node:fs/promises";
39
+ var CHANGE_MANIFEST_VERSION = 1;
40
+ var FIRST_EXPLORATORY_ITERATION_ID = "exploratory-1";
41
+ var MANIFEST_AUTHORITY_LEVELS = [
42
+ "prompt",
43
+ "tool-description",
44
+ "tool-implementation",
45
+ "middleware",
46
+ "memory",
47
+ "runtime",
48
+ "safety",
49
+ "schema",
50
+ "cli"
51
+ ];
52
+ var HIGH_AUTHORITY_LEVELS = [
53
+ "tool-implementation",
54
+ "middleware",
55
+ "runtime",
56
+ "safety",
57
+ "schema",
58
+ "cli"
59
+ ];
60
+ var BUDGET_IMPACT_RISKS = ["lower", "same", "higher"];
61
+ async function loadChangeManifestJson(path) {
62
+ let raw;
63
+ try {
64
+ raw = await readFile(path, "utf8");
65
+ } catch (error) {
66
+ if (error.code === "ENOENT") throw new Error(`change manifest not found: ${path}`);
67
+ throw error;
68
+ }
69
+ try {
70
+ return JSON.parse(raw);
71
+ } catch (error) {
72
+ const message = error instanceof Error ? error.message : String(error);
73
+ throw new Error(`${path}: invalid JSON: ${message}`);
74
+ }
75
+ }
76
+ function createChangeManifestTemplate() {
77
+ return {
78
+ version: CHANGE_MANIFEST_VERSION,
79
+ iterationId: FIRST_EXPLORATORY_ITERATION_ID,
80
+ baseGitSha: "0000000000000000000000000000000000000000",
81
+ createdAt: "2026-04-29T00:00:00.000Z",
82
+ changes: [
83
+ {
84
+ id: "change-1",
85
+ componentIds: ["context-file:CLIO-CODER.md"],
86
+ filesChanged: ["CLIO-CODER.md"],
87
+ authorityLevel: "prompt",
88
+ evidenceRefs: [],
89
+ rootCause: "First exploratory iteration; no evidence corpus exists yet.",
90
+ targetedFix: "Describe the smallest proposed harness change.",
91
+ predictedFixes: ["One expected improvement."],
92
+ predictedRegressions: [],
93
+ validationPlan: ["npm run test"],
94
+ rollbackPlan: "Revert the filesChanged entries for this change.",
95
+ expectedBudgetImpact: {
96
+ risk: "same"
97
+ }
98
+ }
99
+ ]
100
+ };
101
+ }
102
+ function isHighAuthorityLevel(level) {
103
+ return HIGH_AUTHORITY_LEVELS.includes(level);
104
+ }
105
+ function allowsEmptyEvidenceRefs(iterationId) {
106
+ return iterationId === FIRST_EXPLORATORY_ITERATION_ID;
107
+ }
108
+ function summarizeChangeManifest(manifest) {
109
+ const authoritySet = /* @__PURE__ */ new Set();
110
+ const componentIds = /* @__PURE__ */ new Set();
111
+ const filesChanged = /* @__PURE__ */ new Set();
112
+ const predictedRegressions = /* @__PURE__ */ new Set();
113
+ let validationPlanCount = 0;
114
+ for (const change of manifest.changes) {
115
+ authoritySet.add(change.authorityLevel);
116
+ for (const componentId of change.componentIds) componentIds.add(componentId);
117
+ for (const file of change.filesChanged) filesChanged.add(file);
118
+ for (const regression of change.predictedRegressions) predictedRegressions.add(regression);
119
+ validationPlanCount += change.validationPlan.length;
120
+ }
121
+ return {
122
+ iterationId: manifest.iterationId,
123
+ baseGitSha: manifest.baseGitSha,
124
+ changeCount: manifest.changes.length,
125
+ authorityLevels: MANIFEST_AUTHORITY_LEVELS.filter((level) => authoritySet.has(level)),
126
+ componentIds: [...componentIds].sort(compareStrings),
127
+ filesChanged: [...filesChanged].sort(compareStrings),
128
+ predictedRegressions: [...predictedRegressions].sort(compareStrings),
129
+ validationPlanCount
130
+ };
131
+ }
132
+ function compareStrings(a, b) {
133
+ return a.localeCompare(b);
134
+ }
135
+
136
+ // src/domains/evolution/validate.ts
137
+ var EVIDENCE_REF_PREFIXES = ["run-", "session-"];
138
+ function validateChangeManifest(value, options) {
139
+ const issues = [];
140
+ if (!isRecord(value)) {
141
+ issues.push({ path: "$", message: "expected manifest object" });
142
+ return invalid(issues);
143
+ }
144
+ if (value.version !== CHANGE_MANIFEST_VERSION) {
145
+ issues.push({ path: "$.version", message: "must equal 1" });
146
+ }
147
+ const iterationId = readRequiredString(value, "$.iterationId", issues);
148
+ const baseGitSha = readRequiredString(value, "$.baseGitSha", issues);
149
+ const createdAt = readRequiredString(value, "$.createdAt", issues);
150
+ const changes = readChanges(value, iterationId, issues, options);
151
+ if (issues.length > 0 || iterationId === null || baseGitSha === null || createdAt === null || changes === null) {
152
+ return invalid(issues);
153
+ }
154
+ return {
155
+ valid: true,
156
+ manifest: {
157
+ version: CHANGE_MANIFEST_VERSION,
158
+ iterationId,
159
+ baseGitSha,
160
+ createdAt,
161
+ changes
162
+ },
163
+ issues: []
164
+ };
165
+ }
166
+ function readChanges(record, iterationId, issues, options) {
167
+ const value = record.changes;
168
+ if (!Array.isArray(value)) {
169
+ issues.push({ path: "$.changes", message: "expected array" });
170
+ return null;
171
+ }
172
+ const changes = [];
173
+ for (let index = 0; index < value.length; index += 1) {
174
+ const change = readChange(value[index], `$.changes[${index}]`, iterationId, issues, options);
175
+ if (change !== null) changes.push(change);
176
+ }
177
+ return changes;
178
+ }
179
+ function readChange(value, path, iterationId, issues, options) {
180
+ if (!isRecord(value)) {
181
+ issues.push({ path, message: "expected object" });
182
+ return null;
183
+ }
184
+ const id = readRequiredString(value, `${path}.id`, issues);
185
+ const componentIds = readRequiredStringArray(value, `${path}.componentIds`, issues);
186
+ const filesChanged = readRequiredStringArray(value, `${path}.filesChanged`, issues);
187
+ const authorityLevel = readAuthorityLevel(value, `${path}.authorityLevel`, issues);
188
+ const evidenceRefs = readRequiredStringArray(value, `${path}.evidenceRefs`, issues);
189
+ const rootCause = readRequiredString(value, `${path}.rootCause`, issues);
190
+ const targetedFix = readRequiredString(value, `${path}.targetedFix`, issues);
191
+ const predictedFixes = readRequiredStringArray(value, `${path}.predictedFixes`, issues);
192
+ const predictedRegressions = readRequiredStringArray(value, `${path}.predictedRegressions`, issues);
193
+ const validationPlan = readRequiredStringArray(value, `${path}.validationPlan`, issues);
194
+ const rollbackPlan = readRequiredString(value, `${path}.rollbackPlan`, issues);
195
+ const expectedBudgetImpact = readExpectedBudgetImpact(value, `${path}.expectedBudgetImpact`, issues);
196
+ if (componentIds !== null && filesChanged !== null && componentIds.length === 0 && filesChanged.length === 0) {
197
+ issues.push({ path, message: "requires at least one componentIds or filesChanged entry" });
198
+ }
199
+ if (authorityLevel !== null && predictedRegressions !== null && isHighAuthorityLevel(authorityLevel)) {
200
+ if (predictedRegressions.length === 0) {
201
+ issues.push({ path: `${path}.predictedRegressions`, message: "high-authority changes require an entry" });
202
+ }
203
+ }
204
+ if (evidenceRefs !== null && evidenceRefs.length === 0) {
205
+ if (iterationId === null || !allowsEmptyEvidenceRefs(iterationId)) {
206
+ issues.push({
207
+ path: `${path}.evidenceRefs`,
208
+ message: "empty evidence refs are allowed only for exploratory-1"
209
+ });
210
+ }
211
+ }
212
+ if (evidenceRefs !== null && evidenceRefs.length > 0 && options?.resolveEvidenceRef !== void 0) {
213
+ checkEvidenceRefs(evidenceRefs, `${path}.evidenceRefs`, options.resolveEvidenceRef, issues);
214
+ }
215
+ if (id === null || componentIds === null || filesChanged === null || authorityLevel === null || evidenceRefs === null || rootCause === null || targetedFix === null || predictedFixes === null || predictedRegressions === null || validationPlan === null || rollbackPlan === null) {
216
+ return null;
217
+ }
218
+ const change = {
219
+ id,
220
+ componentIds,
221
+ filesChanged,
222
+ authorityLevel,
223
+ evidenceRefs,
224
+ rootCause,
225
+ targetedFix,
226
+ predictedFixes,
227
+ predictedRegressions,
228
+ validationPlan,
229
+ rollbackPlan
230
+ };
231
+ if (expectedBudgetImpact !== void 0) change.expectedBudgetImpact = expectedBudgetImpact;
232
+ return change;
233
+ }
234
+ function checkEvidenceRefs(evidenceRefs, path, resolveEvidenceRef, issues) {
235
+ for (let index = 0; index < evidenceRefs.length; index += 1) {
236
+ const ref = evidenceRefs[index];
237
+ if (ref === void 0) continue;
238
+ if (!isEvidenceRefFormat(ref)) {
239
+ issues.push({ path: `${path}[${index}]`, message: "expected a run-<id> or session-<id> bundle id" });
240
+ continue;
241
+ }
242
+ if (!resolveEvidenceRef(ref)) {
243
+ issues.push({ path: `${path}[${index}]`, message: `evidence bundle not found: ${ref}` });
244
+ }
245
+ }
246
+ }
247
+ function isEvidenceRefFormat(ref) {
248
+ for (const prefix of EVIDENCE_REF_PREFIXES) {
249
+ if (ref.startsWith(prefix) && ref.length > prefix.length) return true;
250
+ }
251
+ return false;
252
+ }
253
+ function readRequiredString(record, path, issues) {
254
+ const field = path.slice(path.lastIndexOf(".") + 1);
255
+ const value = record[field];
256
+ if (typeof value !== "string" || value.trim().length === 0) {
257
+ issues.push({ path, message: "expected non-empty string" });
258
+ return null;
259
+ }
260
+ return value;
261
+ }
262
+ function readRequiredStringArray(record, path, issues) {
263
+ const field = path.slice(path.lastIndexOf(".") + 1);
264
+ const value = record[field];
265
+ if (!Array.isArray(value)) {
266
+ issues.push({ path, message: "expected string array" });
267
+ return null;
268
+ }
269
+ const strings = [];
270
+ for (let index = 0; index < value.length; index += 1) {
271
+ const item = value[index];
272
+ if (typeof item !== "string" || item.trim().length === 0) {
273
+ issues.push({ path: `${path}[${index}]`, message: "expected non-empty string" });
274
+ continue;
275
+ }
276
+ strings.push(item);
277
+ }
278
+ return strings;
279
+ }
280
+ function readAuthorityLevel(record, path, issues) {
281
+ const value = record.authorityLevel;
282
+ if (typeof value !== "string" || !isManifestAuthorityLevel(value)) {
283
+ issues.push({ path, message: `expected one of ${MANIFEST_AUTHORITY_LEVELS.join(", ")}` });
284
+ return null;
285
+ }
286
+ return value;
287
+ }
288
+ function readExpectedBudgetImpact(record, path, issues) {
289
+ if (!Object.hasOwn(record, "expectedBudgetImpact")) return void 0;
290
+ const value = record.expectedBudgetImpact;
291
+ if (!isRecord(value)) {
292
+ issues.push({ path, message: "expected object" });
293
+ return void 0;
294
+ }
295
+ const risk = value.risk;
296
+ if (typeof risk !== "string" || !isBudgetImpactRisk(risk)) {
297
+ issues.push({ path: `${path}.risk`, message: `expected one of ${BUDGET_IMPACT_RISKS.join(", ")}` });
298
+ return void 0;
299
+ }
300
+ const impact = { risk };
301
+ const tokenDelta = readOptionalNumber(value, `${path}.tokenDelta`, issues);
302
+ const wallTimeDeltaMs = readOptionalNumber(value, `${path}.wallTimeDeltaMs`, issues);
303
+ if (tokenDelta !== void 0) impact.tokenDelta = tokenDelta;
304
+ if (wallTimeDeltaMs !== void 0) impact.wallTimeDeltaMs = wallTimeDeltaMs;
305
+ return impact;
306
+ }
307
+ function readOptionalNumber(record, path, issues) {
308
+ const field = path.slice(path.lastIndexOf(".") + 1);
309
+ if (!Object.hasOwn(record, field)) return void 0;
310
+ const value = record[field];
311
+ if (typeof value !== "number" || !Number.isFinite(value)) {
312
+ issues.push({ path, message: "expected finite number" });
313
+ return void 0;
314
+ }
315
+ return value;
316
+ }
317
+ function isManifestAuthorityLevel(value) {
318
+ return MANIFEST_AUTHORITY_LEVELS.includes(value);
319
+ }
320
+ function isBudgetImpactRisk(value) {
321
+ return BUDGET_IMPACT_RISKS.includes(value);
322
+ }
323
+ function isRecord(value) {
324
+ return typeof value === "object" && value !== null && !Array.isArray(value);
325
+ }
326
+ function invalid(issues) {
327
+ return { valid: false, issues };
328
+ }
329
+
330
+ // src/cli/evolve.ts
331
+ var HELP = `clio-coder evolve manifest init
332
+ clio-coder evolve manifest validate <path>
333
+ clio-coder evolve manifest summarize <path>
334
+
335
+ Create, validate, or summarize a Clio Coder change manifest. validate and
336
+ summarize resolve each non-empty evidenceRef (run-<id> / session-<id>) against
337
+ the local evidence store, so a manifest that points at a missing bundle fails.
338
+ `;
339
+ async function loadEvidenceRefResolver() {
340
+ let knownIds;
341
+ try {
342
+ const overviews = await listEvidenceOverviews(clioDataDir());
343
+ knownIds = new Set(overviews.map((overview) => overview.evidenceId));
344
+ } catch {
345
+ return { resolveEvidenceRef: () => false, knownCount: 0, resolvable: false };
346
+ }
347
+ return {
348
+ resolveEvidenceRef: (ref) => knownIds.has(ref),
349
+ knownCount: knownIds.size,
350
+ resolvable: true
351
+ };
352
+ }
353
+ function countEvidenceRefs(changes) {
354
+ let total = 0;
355
+ for (const change of changes) total += change.evidenceRefs.length;
356
+ return total;
357
+ }
358
+ function parseEvolveArgs(args) {
359
+ const parsed = { manifest: false, help: false };
360
+ for (let index = 0; index < args.length; index += 1) {
361
+ const arg = args[index];
362
+ if (arg === void 0) continue;
363
+ if (arg === "--help" || arg === "-h") {
364
+ parsed.help = true;
365
+ continue;
366
+ }
367
+ if (!parsed.manifest) {
368
+ if (arg !== "manifest") throw new Error(`unknown evolve argument: ${arg}`);
369
+ parsed.manifest = true;
370
+ continue;
371
+ }
372
+ if (parsed.command === void 0) {
373
+ if (arg === "init" || arg === "validate" || arg === "summarize") {
374
+ parsed.command = arg;
375
+ continue;
376
+ }
377
+ throw new Error(`unknown evolve manifest command: ${arg}`);
378
+ }
379
+ if (parsed.path === void 0 && (parsed.command === "validate" || parsed.command === "summarize")) {
380
+ if (arg.startsWith("-")) throw new Error(`${parsed.command} requires a path`);
381
+ parsed.path = arg;
382
+ continue;
383
+ }
384
+ throw new Error(`unexpected evolve argument: ${arg}`);
385
+ }
386
+ if (parsed.help) return parsed;
387
+ if (!parsed.manifest) throw new Error("evolve requires manifest");
388
+ if (parsed.command === void 0) throw new Error("manifest requires init, validate, or summarize");
389
+ if (parsed.command === "init" && parsed.path !== void 0) throw new Error("init does not accept a path");
390
+ if ((parsed.command === "validate" || parsed.command === "summarize") && parsed.path === void 0) {
391
+ throw new Error(`${parsed.command} requires a path`);
392
+ }
393
+ return parsed;
394
+ }
395
+ async function runEvolveCommand(args) {
396
+ let parsed;
397
+ try {
398
+ parsed = parseEvolveArgs(args);
399
+ } catch (error) {
400
+ printError(error instanceof Error ? error.message : String(error));
401
+ process.stdout.write(HELP);
402
+ return 2;
403
+ }
404
+ if (parsed.help) {
405
+ process.stdout.write(HELP);
406
+ return 0;
407
+ }
408
+ if (parsed.command === "init") {
409
+ process.stdout.write(`${JSON.stringify(createChangeManifestTemplate(), null, 2)}
410
+ `);
411
+ return 0;
412
+ }
413
+ if (parsed.command === "validate") return runValidate(parsed);
414
+ if (parsed.command === "summarize") return runSummarize(parsed);
415
+ printError("manifest requires init, validate, or summarize");
416
+ return 2;
417
+ }
418
+ async function runValidate(parsed) {
419
+ const manifestPath = parsed.path;
420
+ if (manifestPath === void 0) {
421
+ printError("validate requires a path");
422
+ return 2;
423
+ }
424
+ let value;
425
+ const resolvedPath = resolve(manifestPath);
426
+ try {
427
+ value = await loadChangeManifestJson(resolvedPath);
428
+ } catch (error) {
429
+ printError(error instanceof Error ? error.message : String(error));
430
+ return 1;
431
+ }
432
+ const resolver = await loadEvidenceRefResolver();
433
+ const result = validateChangeManifest(value, { resolveEvidenceRef: resolver.resolveEvidenceRef });
434
+ if (!result.valid) {
435
+ renderInvalid(result.issues);
436
+ return 1;
437
+ }
438
+ const refCount = countEvidenceRefs(result.manifest.changes);
439
+ printOk(`manifest valid (${formatCount(result.manifest.changes.length, "change")})`);
440
+ reportRefResolution(refCount, resolver);
441
+ return 0;
442
+ }
443
+ async function runSummarize(parsed) {
444
+ const manifestPath = parsed.path;
445
+ if (manifestPath === void 0) {
446
+ printError("summarize requires a path");
447
+ return 2;
448
+ }
449
+ let value;
450
+ const resolvedPath = resolve(manifestPath);
451
+ try {
452
+ value = await loadChangeManifestJson(resolvedPath);
453
+ } catch (error) {
454
+ printError(error instanceof Error ? error.message : String(error));
455
+ return 1;
456
+ }
457
+ const resolver = await loadEvidenceRefResolver();
458
+ const result = validateChangeManifest(value, { resolveEvidenceRef: resolver.resolveEvidenceRef });
459
+ if (!result.valid) {
460
+ printError("manifest invalid; cannot summarize");
461
+ renderIssues(result.issues);
462
+ return 1;
463
+ }
464
+ const refCount = countEvidenceRefs(result.manifest.changes);
465
+ renderSummary(summarizeChangeManifest(result.manifest));
466
+ reportRefResolution(refCount, resolver);
467
+ return 0;
468
+ }
469
+ function reportRefResolution(refCount, resolver) {
470
+ if (!resolver.resolvable) {
471
+ process.stdout.write("evidence refs: could not read the local evidence store; refs were not resolved\n");
472
+ return;
473
+ }
474
+ if (refCount === 0) {
475
+ process.stdout.write("evidence refs: none to resolve\n");
476
+ return;
477
+ }
478
+ process.stdout.write(
479
+ `evidence refs: ${formatCount(refCount, "ref")} resolved against ${formatCount(resolver.knownCount, "local bundle")}
480
+ `
481
+ );
482
+ }
483
+ function renderInvalid(issues) {
484
+ printError(`manifest invalid (${formatCount(issues.length, "issue", "issues")})`);
485
+ renderIssues(issues);
486
+ }
487
+ function renderIssues(issues) {
488
+ for (const issue of issues) process.stderr.write(` ${issue.path}: ${issue.message}
489
+ `);
490
+ }
491
+ function renderSummary(summary) {
492
+ process.stdout.write(`iteration: ${summary.iterationId}
493
+ `);
494
+ process.stdout.write(`base sha: ${summary.baseGitSha}
495
+ `);
496
+ process.stdout.write(`changes: ${summary.changeCount}
497
+ `);
498
+ process.stdout.write(`authority levels: ${formatList(summary.authorityLevels)}
499
+ `);
500
+ process.stdout.write(`components: ${formatList(summary.componentIds)}
501
+ `);
502
+ process.stdout.write(`files changed: ${formatList(summary.filesChanged)}
503
+ `);
504
+ process.stdout.write(`predicted regressions: ${formatList(summary.predictedRegressions)}
505
+ `);
506
+ process.stdout.write(`validation steps: ${summary.validationPlanCount}
507
+ `);
508
+ }
509
+ function formatList(values) {
510
+ return values.length === 0 ? "none" : values.join(", ");
511
+ }
512
+ function formatCount(count, singular, plural = `${singular}s`) {
513
+ return `${count} ${count === 1 ? singular : plural}`;
514
+ }
515
+ export {
516
+ runEvolveCommand
517
+ };
518
+ //# sourceMappingURL=evolve-YDZSUQYA.js.map