@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,185 @@
1
+ import {
2
+ ContextDomainModule,
3
+ OPERATOR_PROFILE_MAX_CHARS,
4
+ WIKI_DEPTH_STRATEGY,
5
+ adoptionSnapshotsHash,
6
+ adoptionSourcesChanged,
7
+ assembleWikiTree,
8
+ buildCandidatePlan,
9
+ buildWikiPagePrompt,
10
+ buildWikiPlanPrompt,
11
+ createContextDomainModule,
12
+ fallbackBootstrapOutput,
13
+ loadOperatorProfile,
14
+ loadProjectRules,
15
+ pagePathForArea,
16
+ parseClioMd,
17
+ planWikiGeneration,
18
+ renderImportedAgentContext,
19
+ renderOperatorProfile,
20
+ renderPromptContext,
21
+ runBootstrap,
22
+ runContextClear,
23
+ runContextRefresh,
24
+ runWikiGenerate,
25
+ scanAgentConfigs,
26
+ selectActiveRules,
27
+ serializeClioMd,
28
+ tryReadClioMd
29
+ } from "./chunk-UWIJNAOB.js";
30
+ import {
31
+ renderCodewikiDigest
32
+ } from "./chunk-X3BR7HWV.js";
33
+ import "./chunk-VOO7NYPP.js";
34
+ import {
35
+ MAX_PAGE_ATTEMPTS,
36
+ WIKI_INDEX,
37
+ WIKI_PLAN_FILE,
38
+ WIKI_QUICKSTART,
39
+ changedPathsSince,
40
+ computeWikiContentHash,
41
+ computeWikiContentHashOfDir,
42
+ currentWikiGitHead,
43
+ isGeneratedWikiFile,
44
+ isWikiMeta,
45
+ listWikiPages,
46
+ listWikiPagesInDir,
47
+ pendingPages,
48
+ readWikiMeta,
49
+ readWikiPage,
50
+ readWikiPlanFile,
51
+ renderWikiPage,
52
+ sanitizePagePath,
53
+ sanitizeWikiPlan,
54
+ scopePlanForUpdate,
55
+ validateWikiMeta,
56
+ wikiCompleteness,
57
+ wikiCompletenessFromMeta,
58
+ wikiDir,
59
+ wikiMarkdownFilesInDir,
60
+ wikiMetaPath,
61
+ wikiStaleness,
62
+ wikiStalenessAsync,
63
+ writeWikiMeta,
64
+ writeWikiPlanFile
65
+ } from "./chunk-GNGDQYDU.js";
66
+ import "./chunk-2J63S4SF.js";
67
+ import {
68
+ computeFingerprint,
69
+ computeFingerprintAsync,
70
+ isStale,
71
+ readClioState,
72
+ writeClioState
73
+ } from "./chunk-RQDWMVRB.js";
74
+ import "./chunk-7BHLZB3A.js";
75
+ import {
76
+ CODEWIKI_VERSION,
77
+ INDEX_SLICE_MS,
78
+ buildCodewiki,
79
+ codewikiEntries,
80
+ codewikiNeedsBackfill,
81
+ createSlicer,
82
+ readCodewiki,
83
+ readCodewikiAsync,
84
+ structuralCodewikiHash,
85
+ syncCodewiki,
86
+ updateCodewikiPaths,
87
+ writeCodewiki
88
+ } from "./chunk-TPOCL34A.js";
89
+ import "./chunk-E3NYWENM.js";
90
+ import "./chunk-XV4ZJ6ZM.js";
91
+ import "./chunk-26BZQOAD.js";
92
+ import "./chunk-WD6AJM35.js";
93
+ import "./chunk-QV47YRF4.js";
94
+ import "./chunk-CLJ5HLUD.js";
95
+ import "./chunk-BBUH4VAA.js";
96
+ import "./chunk-GOTUR54M.js";
97
+ import "./chunk-KBR4MZZR.js";
98
+ import "./chunk-TKHQ4DGZ.js";
99
+ import "./chunk-D5YD55AR.js";
100
+ import "./chunk-JWHCJDCI.js";
101
+ import "./chunk-UHTSULZS.js";
102
+ import "./chunk-5LDRNKX2.js";
103
+ import "./chunk-UGYAX5YI.js";
104
+ import "./chunk-5N2FG33Q.js";
105
+ import "./chunk-VPAWTYLY.js";
106
+ import "./chunk-X3NE4WVW.js";
107
+ import "./chunk-DXQNI4PC.js";
108
+ export {
109
+ CODEWIKI_VERSION,
110
+ ContextDomainModule,
111
+ INDEX_SLICE_MS,
112
+ MAX_PAGE_ATTEMPTS,
113
+ OPERATOR_PROFILE_MAX_CHARS,
114
+ WIKI_DEPTH_STRATEGY,
115
+ WIKI_INDEX,
116
+ WIKI_PLAN_FILE,
117
+ WIKI_QUICKSTART,
118
+ adoptionSnapshotsHash,
119
+ adoptionSourcesChanged,
120
+ assembleWikiTree,
121
+ buildCandidatePlan,
122
+ buildCodewiki,
123
+ buildWikiPagePrompt,
124
+ buildWikiPlanPrompt,
125
+ changedPathsSince,
126
+ codewikiEntries,
127
+ codewikiNeedsBackfill,
128
+ computeFingerprint,
129
+ computeFingerprintAsync,
130
+ computeWikiContentHash,
131
+ computeWikiContentHashOfDir,
132
+ createContextDomainModule,
133
+ createSlicer,
134
+ currentWikiGitHead,
135
+ fallbackBootstrapOutput,
136
+ isGeneratedWikiFile,
137
+ isStale,
138
+ isWikiMeta,
139
+ listWikiPages,
140
+ listWikiPagesInDir,
141
+ loadOperatorProfile,
142
+ loadProjectRules,
143
+ pagePathForArea,
144
+ parseClioMd,
145
+ pendingPages,
146
+ planWikiGeneration,
147
+ readClioState,
148
+ readCodewiki,
149
+ readCodewikiAsync,
150
+ readWikiMeta,
151
+ readWikiPage,
152
+ readWikiPlanFile,
153
+ renderCodewikiDigest,
154
+ renderImportedAgentContext,
155
+ renderOperatorProfile,
156
+ renderPromptContext,
157
+ renderWikiPage,
158
+ runBootstrap,
159
+ runContextClear,
160
+ runContextRefresh,
161
+ runWikiGenerate,
162
+ sanitizePagePath,
163
+ sanitizeWikiPlan,
164
+ scanAgentConfigs,
165
+ scopePlanForUpdate,
166
+ selectActiveRules,
167
+ serializeClioMd,
168
+ structuralCodewikiHash,
169
+ syncCodewiki,
170
+ tryReadClioMd,
171
+ updateCodewikiPaths,
172
+ validateWikiMeta,
173
+ wikiCompleteness,
174
+ wikiCompletenessFromMeta,
175
+ wikiDir,
176
+ wikiMarkdownFilesInDir,
177
+ wikiMetaPath,
178
+ wikiStaleness,
179
+ wikiStalenessAsync,
180
+ writeClioState,
181
+ writeCodewiki,
182
+ writeWikiMeta,
183
+ writeWikiPlanFile
184
+ };
185
+ //# sourceMappingURL=context-E3KIFVXI.js.map
@@ -0,0 +1,102 @@
1
+ import {
2
+ runContextClear
3
+ } from "./chunk-UWIJNAOB.js";
4
+ import "./chunk-X3BR7HWV.js";
5
+ import "./chunk-VOO7NYPP.js";
6
+ import "./chunk-GNGDQYDU.js";
7
+ import "./chunk-2J63S4SF.js";
8
+ import "./chunk-RQDWMVRB.js";
9
+ import "./chunk-7BHLZB3A.js";
10
+ import "./chunk-TPOCL34A.js";
11
+ import "./chunk-E3NYWENM.js";
12
+ import "./chunk-XV4ZJ6ZM.js";
13
+ import "./chunk-26BZQOAD.js";
14
+ import "./chunk-WD6AJM35.js";
15
+ import "./chunk-QV47YRF4.js";
16
+ import "./chunk-CLJ5HLUD.js";
17
+ import "./chunk-BBUH4VAA.js";
18
+ import "./chunk-GOTUR54M.js";
19
+ import "./chunk-KBR4MZZR.js";
20
+ import "./chunk-TKHQ4DGZ.js";
21
+ import "./chunk-D5YD55AR.js";
22
+ import "./chunk-JWHCJDCI.js";
23
+ import "./chunk-UHTSULZS.js";
24
+ import "./chunk-5LDRNKX2.js";
25
+ import "./chunk-UGYAX5YI.js";
26
+ import "./chunk-5N2FG33Q.js";
27
+ import "./chunk-VPAWTYLY.js";
28
+ import "./chunk-X3NE4WVW.js";
29
+ import "./chunk-DXQNI4PC.js";
30
+
31
+ // src/cli/context-clear.ts
32
+ import { stdin as input, stdout as output } from "node:process";
33
+ import { createInterface } from "node:readline/promises";
34
+ var HELP = `Usage:
35
+ clio-coder context reset [--all] [--yes]
36
+
37
+ Clear accumulated project context owned by the context engine:
38
+ .clio-coder/codewiki.json, .clio-coder/state.json, .clio-coder/handoffs/, and .clio-coder/proposals/.
39
+
40
+ Preserves by default: CLIO-CODER.md, .clio-coder/agents/, .clio-coder/skills/, and .clio-coder/wiki/.
41
+
42
+ Options:
43
+ --all also remove CLIO-CODER.md after a second confirmation
44
+ --yes, -y answer every confirmation, required when stdin is not a terminal
45
+ `;
46
+ function hasFlag(args, name) {
47
+ return args.includes(name);
48
+ }
49
+ async function confirm(question) {
50
+ if (!input.isTTY) return false;
51
+ const rl = createInterface({ input, output });
52
+ try {
53
+ const answer = await rl.question(question);
54
+ const normalized = answer.trim().toLowerCase();
55
+ return normalized === "y" || normalized === "yes";
56
+ } finally {
57
+ rl.close();
58
+ }
59
+ }
60
+ async function runContextClearCommand(args) {
61
+ if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
62
+ process.stdout.write(HELP);
63
+ return 0;
64
+ }
65
+ for (const arg of args) {
66
+ if (arg !== "--all" && arg !== "--yes" && arg !== "-y") {
67
+ process.stderr.write(`clio-coder context reset: unknown flag ${arg}
68
+ `);
69
+ process.stdout.write(HELP);
70
+ return 2;
71
+ }
72
+ }
73
+ const all = hasFlag(args, "--all");
74
+ const assumeYes = hasFlag(args, "--yes") || hasFlag(args, "-y");
75
+ if (!assumeYes && !input.isTTY) {
76
+ process.stderr.write("clio-coder context reset: stdin is not a terminal; pass --yes to confirm non-interactively\n");
77
+ }
78
+ const answer = (question) => assumeYes ? Promise.resolve(true) : confirm(question);
79
+ try {
80
+ await runContextClear({
81
+ cwd: process.cwd(),
82
+ all,
83
+ io: {
84
+ stdout: (s) => process.stdout.write(s),
85
+ stderr: (s) => process.stderr.write(s)
86
+ },
87
+ confirmContext: () => answer(
88
+ "Clear .clio-coder/codewiki.json, .clio-coder/state.json, .clio-coder/handoffs/, and .clio-coder/proposals/? [y/N] "
89
+ ),
90
+ confirmAll: () => answer("Also remove CLIO-CODER.md? [y/N] ")
91
+ });
92
+ return 0;
93
+ } catch (err) {
94
+ process.stderr.write(`clio-coder context reset failed: ${err instanceof Error ? err.message : String(err)}
95
+ `);
96
+ return 1;
97
+ }
98
+ }
99
+ export {
100
+ runContextClearCommand
101
+ };
102
+ //# sourceMappingURL=context-clear-3F4PLXOS.js.map
@@ -0,0 +1,106 @@
1
+ import {
2
+ computeFingerprint,
3
+ readClioState,
4
+ statePath,
5
+ writeClioState
6
+ } from "./chunk-RQDWMVRB.js";
7
+ import {
8
+ buildCodewiki,
9
+ codewikiPath,
10
+ detectProjectProfile,
11
+ structuralCodewikiHash,
12
+ writeCodewiki
13
+ } from "./chunk-TPOCL34A.js";
14
+ import "./chunk-VPAWTYLY.js";
15
+
16
+ // src/cli/context-index.ts
17
+ var HELP = `Usage:
18
+ clio-coder context index [--json]
19
+
20
+ Build the structural codewiki index for the current repository without model calls.
21
+ Writes .clio-coder/codewiki.json and .clio-coder/state.json, then prints source coverage.
22
+
23
+ Options:
24
+ --json print machine-readable coverage and hash details
25
+ `;
26
+ function hasFlag(args, name) {
27
+ return args.includes(name);
28
+ }
29
+ function languageCounts(profile) {
30
+ return Object.fromEntries(
31
+ Object.entries(profile.languageCounts).filter(([, count]) => count > 0).sort(([a], [b]) => a.localeCompare(b))
32
+ );
33
+ }
34
+ function formatCounts(counts) {
35
+ const parts = Object.entries(counts).map(([language, count]) => `${language}=${count}`);
36
+ return parts.length > 0 ? parts.join(", ") : "none";
37
+ }
38
+ function indexedSourceCount(codewiki) {
39
+ return codewiki.files.filter((file) => file.lang !== "config").length;
40
+ }
41
+ async function runContextIndexCommand(args) {
42
+ if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
43
+ process.stdout.write(HELP);
44
+ return 0;
45
+ }
46
+ const allowed = /* @__PURE__ */ new Set(["--json"]);
47
+ for (const arg of args) {
48
+ if (!allowed.has(arg)) {
49
+ process.stderr.write(`clio-coder context index: unknown flag ${arg}
50
+ `);
51
+ return 2;
52
+ }
53
+ }
54
+ const cwd = process.cwd();
55
+ const now = (/* @__PURE__ */ new Date()).toISOString();
56
+ const profile = detectProjectProfile(cwd);
57
+ const codewiki = await buildCodewiki({ cwd, language: profile.projectType });
58
+ writeCodewiki(cwd, codewiki);
59
+ const prev = readClioState(cwd);
60
+ const fingerprint = computeFingerprint(cwd, codewiki);
61
+ writeClioState(cwd, {
62
+ version: 1,
63
+ projectType: profile.projectType,
64
+ fingerprint,
65
+ codewikiVersion: codewiki.version,
66
+ ...prev?.contextSources ? { contextSources: prev.contextSources } : {},
67
+ ...prev?.contextSourceHash ? { contextSourceHash: prev.contextSourceHash } : {},
68
+ ...prev?.lastBootstrap ? { lastBootstrap: prev.lastBootstrap } : {},
69
+ ...prev?.lastInitAt ? { lastInitAt: prev.lastInitAt } : {},
70
+ lastSessionAt: prev?.lastSessionAt ?? now,
71
+ lastIndexedAt: now
72
+ });
73
+ const indexed = indexedSourceCount(codewiki);
74
+ const coverage = profile.sourceFiles === 0 ? 1 : indexed / profile.sourceFiles;
75
+ const counts = languageCounts(profile);
76
+ const payload = {
77
+ projectType: profile.projectType,
78
+ sourceFiles: profile.sourceFiles,
79
+ indexedSourceFiles: indexed,
80
+ coverage,
81
+ languageCounts: counts,
82
+ codewikiPath: codewikiPath(cwd),
83
+ statePath: statePath(cwd),
84
+ structuralHash: structuralCodewikiHash(codewiki)
85
+ };
86
+ if (hasFlag(args, "--json")) {
87
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}
88
+ `);
89
+ return 0;
90
+ }
91
+ process.stdout.write(
92
+ [
93
+ `clio-coder context index indexed ${indexed}/${profile.sourceFiles} source file${profile.sourceFiles === 1 ? "" : "s"} (${(coverage * 100).toFixed(1)}%)`,
94
+ ` language ${profile.projectType}; counts ${formatCounts(counts)}`,
95
+ ` codewiki ${payload.codewikiPath}`,
96
+ ` state ${payload.statePath}`,
97
+ ` structural hash ${payload.structuralHash}`,
98
+ ""
99
+ ].join("\n")
100
+ );
101
+ return 0;
102
+ }
103
+ export {
104
+ runContextIndexCommand
105
+ };
106
+ //# sourceMappingURL=context-index-Q7YSYTR3.js.map
@@ -0,0 +1,280 @@
1
+ import "./chunk-PIDUD6M2.js";
2
+ import {
3
+ printError,
4
+ printHeader
5
+ } from "./chunk-67MTHP2E.js";
6
+ import "./chunk-5LDRNKX2.js";
7
+ import "./chunk-VPAWTYLY.js";
8
+ import "./chunk-X3NE4WVW.js";
9
+ import {
10
+ resolvePackageRoot
11
+ } from "./chunk-DXQNI4PC.js";
12
+
13
+ // src/cli/docs.ts
14
+ import { spawn } from "node:child_process";
15
+ import { createReadStream, readdirSync, statSync } from "node:fs";
16
+ import { createServer } from "node:http";
17
+ import { relative, resolve } from "node:path";
18
+ import chalk from "chalk";
19
+ var HOST = "127.0.0.1";
20
+ var HELP = `clio-coder docs [topic] [--no-open]
21
+
22
+ Serve Clio Coder's bundled HTML documentation locally and open it in a browser.
23
+ The server binds an ephemeral port on 127.0.0.1 only; it keeps no state, runs no
24
+ daemon, and reaches no external network. Press Ctrl+C to stop it.
25
+
26
+ Arguments:
27
+ [topic] deep-link a specific blueprint (for example: safety, configuration,
28
+ tools). Omit to open the documentation menu.
29
+
30
+ Flags:
31
+ --no-open do not launch a browser; just print the URL.
32
+ --help, -h this message.
33
+ `;
34
+ var CONTENT_TYPES = {
35
+ ".html": "text/html; charset=utf-8",
36
+ ".htm": "text/html; charset=utf-8",
37
+ ".css": "text/css; charset=utf-8",
38
+ ".js": "text/javascript; charset=utf-8",
39
+ ".mjs": "text/javascript; charset=utf-8",
40
+ ".json": "application/json; charset=utf-8",
41
+ ".svg": "image/svg+xml",
42
+ ".png": "image/png",
43
+ ".webp": "image/webp",
44
+ ".jpg": "image/jpeg",
45
+ ".jpeg": "image/jpeg",
46
+ ".gif": "image/gif",
47
+ ".ico": "image/x-icon",
48
+ ".woff": "font/woff",
49
+ ".woff2": "font/woff2",
50
+ ".ttf": "font/ttf",
51
+ ".map": "application/json; charset=utf-8",
52
+ ".txt": "text/plain; charset=utf-8"
53
+ };
54
+ function resolveDocsHtmlDir() {
55
+ return resolve(resolvePackageRoot(), "docs", "html");
56
+ }
57
+ function contentTypeFor(filePath) {
58
+ const dot = filePath.lastIndexOf(".");
59
+ if (dot === -1) return "application/octet-stream";
60
+ return CONTENT_TYPES[filePath.slice(dot).toLowerCase()] ?? "application/octet-stream";
61
+ }
62
+ function resolveRequestPath(rawUrl) {
63
+ const pathPart = (rawUrl.split(/[?#]/, 1)[0] ?? "").trim();
64
+ let decoded;
65
+ try {
66
+ decoded = decodeURIComponent(pathPart);
67
+ } catch {
68
+ return { ok: false, reason: "bad-request" };
69
+ }
70
+ if (decoded.includes("\0")) return { ok: false, reason: "forbidden" };
71
+ const segments = decoded.split(/[/\\]/).filter((segment) => segment.length > 0 && segment !== ".");
72
+ if (segments.length === 0) return { ok: true, relative: "index.html" };
73
+ for (const segment of segments) {
74
+ if (segment === "..") return { ok: false, reason: "forbidden" };
75
+ }
76
+ return { ok: true, relative: segments.join("/") };
77
+ }
78
+ function titleize(topic) {
79
+ return topic.split(/[-_]+/).filter((word) => word.length > 0).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
80
+ }
81
+ function synthesizeMenu(fileNames) {
82
+ const entries = [];
83
+ for (const name of fileNames) {
84
+ if (!name.toLowerCase().endsWith(".html")) continue;
85
+ if (name.toLowerCase() === "index.html") continue;
86
+ const topic = name.replace(/\.html$/i, "").replace(/_blueprint$/i, "");
87
+ entries.push({ topic, file: name, label: titleize(topic) });
88
+ }
89
+ entries.sort((a, b) => a.topic.localeCompare(b.topic));
90
+ return entries;
91
+ }
92
+ function topicToFile(topic, fileNames) {
93
+ const wanted = topic.trim().toLowerCase().replace(/\.html$/i, "");
94
+ if (wanted.length === 0) return null;
95
+ for (const candidate of [`${wanted}.html`, `${wanted}_blueprint.html`]) {
96
+ const match = fileNames.find((name) => name.toLowerCase() === candidate);
97
+ if (match) return match;
98
+ }
99
+ const hit = synthesizeMenu(fileNames).find((entry) => entry.topic.toLowerCase() === wanted);
100
+ return hit ? hit.file : null;
101
+ }
102
+ function isWithin(child, parent) {
103
+ const rel = relative(parent, child);
104
+ return rel === "" || !rel.startsWith("..") && !rel.startsWith(`..${"/"}`) && !/^([A-Za-z]:)?[/\\]/.test(rel);
105
+ }
106
+ function listHtmlFiles(htmlDir) {
107
+ try {
108
+ return readdirSync(htmlDir).filter((name) => name.toLowerCase().endsWith(".html")).sort((a, b) => a.localeCompare(b));
109
+ } catch {
110
+ return [];
111
+ }
112
+ }
113
+ function createDocsRequestHandler(htmlDir) {
114
+ const root = resolve(htmlDir);
115
+ return (req, res) => {
116
+ if (req.method !== "GET" && req.method !== "HEAD") {
117
+ res.writeHead(405, { "content-type": "text/plain; charset=utf-8", allow: "GET, HEAD" });
118
+ res.end("method not allowed");
119
+ return;
120
+ }
121
+ const resolved = resolveRequestPath(req.url ?? "/");
122
+ if (!resolved.ok) {
123
+ const status = resolved.reason === "forbidden" ? 403 : 400;
124
+ res.writeHead(status, { "content-type": "text/plain; charset=utf-8" });
125
+ res.end(resolved.reason);
126
+ return;
127
+ }
128
+ const target = resolve(root, resolved.relative);
129
+ if (!isWithin(target, root)) {
130
+ res.writeHead(403, { "content-type": "text/plain; charset=utf-8" });
131
+ res.end("forbidden");
132
+ return;
133
+ }
134
+ let size = null;
135
+ try {
136
+ const stat = statSync(target);
137
+ if (stat.isFile()) size = stat.size;
138
+ } catch {
139
+ size = null;
140
+ }
141
+ if (size === null) {
142
+ res.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
143
+ res.end("not found");
144
+ return;
145
+ }
146
+ const headers = {
147
+ "content-type": contentTypeFor(target),
148
+ "content-length": String(size),
149
+ "cache-control": "no-store"
150
+ };
151
+ if (req.method === "HEAD") {
152
+ res.writeHead(200, headers);
153
+ res.end();
154
+ return;
155
+ }
156
+ res.writeHead(200, headers);
157
+ const stream = createReadStream(target);
158
+ stream.on("error", () => {
159
+ if (!res.writableEnded) res.end();
160
+ });
161
+ stream.pipe(res);
162
+ };
163
+ }
164
+ async function startDocsServer(options) {
165
+ const host = options.host ?? HOST;
166
+ const server = createServer(createDocsRequestHandler(options.htmlDir));
167
+ await new Promise((resolveListen, rejectListen) => {
168
+ const onError = (err) => rejectListen(err);
169
+ server.once("error", onError);
170
+ server.listen(options.port ?? 0, host, () => {
171
+ server.removeListener("error", onError);
172
+ resolveListen();
173
+ });
174
+ });
175
+ const address = server.address();
176
+ const port = address.port;
177
+ return {
178
+ server,
179
+ port,
180
+ url: `http://${host}:${port}/`,
181
+ close: () => new Promise((resolveClose) => server.close(() => resolveClose()))
182
+ };
183
+ }
184
+ function openBrowser(url) {
185
+ const platform = process.platform;
186
+ const command = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : "xdg-open";
187
+ const args = platform === "win32" ? ["/c", "start", "", url] : [url];
188
+ try {
189
+ const child = spawn(command, args, { stdio: "ignore", detached: true });
190
+ child.on("error", () => {
191
+ });
192
+ child.unref();
193
+ } catch {
194
+ }
195
+ }
196
+ function waitForShutdown() {
197
+ return new Promise((resolveShutdown) => {
198
+ const onSignal = () => {
199
+ process.removeListener("SIGINT", onSignal);
200
+ process.removeListener("SIGTERM", onSignal);
201
+ resolveShutdown();
202
+ };
203
+ process.once("SIGINT", onSignal);
204
+ process.once("SIGTERM", onSignal);
205
+ });
206
+ }
207
+ async function runDocsCommand(args = []) {
208
+ if (args.includes("--help") || args.includes("-h")) {
209
+ process.stdout.write(HELP);
210
+ return 0;
211
+ }
212
+ let noOpen = false;
213
+ const positionals = [];
214
+ for (const arg of args) {
215
+ if (arg === "--no-open") {
216
+ noOpen = true;
217
+ continue;
218
+ }
219
+ if (arg.startsWith("-")) {
220
+ printError(`unknown flag: ${arg}`);
221
+ process.stdout.write(HELP);
222
+ return 2;
223
+ }
224
+ positionals.push(arg);
225
+ }
226
+ if (positionals.length > 1) {
227
+ printError("docs accepts at most one [topic]");
228
+ process.stdout.write(HELP);
229
+ return 2;
230
+ }
231
+ let htmlDir;
232
+ try {
233
+ htmlDir = resolveDocsHtmlDir();
234
+ } catch (err) {
235
+ printError(`could not resolve bundled docs: ${err instanceof Error ? err.message : String(err)}`);
236
+ return 1;
237
+ }
238
+ const files = listHtmlFiles(htmlDir);
239
+ if (files.length === 0) {
240
+ printError(`no bundled HTML docs found at ${htmlDir}`);
241
+ return 1;
242
+ }
243
+ let landing = "index.html";
244
+ const topic = positionals[0];
245
+ if (topic !== void 0) {
246
+ const file = topicToFile(topic, files);
247
+ if (!file) {
248
+ printError(`unknown docs topic: ${topic}`);
249
+ const topics = synthesizeMenu(files).map((entry) => entry.topic);
250
+ if (topics.length > 0) process.stdout.write(` available topics: ${topics.join(", ")}
251
+ `);
252
+ return 2;
253
+ }
254
+ landing = file;
255
+ }
256
+ const handle = await startDocsServer({ htmlDir });
257
+ const landingUrl = landing === "index.html" ? handle.url : `${handle.url}${landing}`;
258
+ printHeader("Clio docs viewer");
259
+ process.stdout.write(` serving ${htmlDir}
260
+ `);
261
+ process.stdout.write(` open ${chalk.cyan(landingUrl)}
262
+ `);
263
+ process.stdout.write(" bound to 127.0.0.1 only: no external network, no daemon, no state.\n");
264
+ process.stdout.write(" press Ctrl+C to stop.\n");
265
+ if (!noOpen) openBrowser(landingUrl);
266
+ await waitForShutdown();
267
+ await handle.close();
268
+ process.stdout.write("docs viewer stopped.\n");
269
+ return 0;
270
+ }
271
+ export {
272
+ contentTypeFor,
273
+ resolveDocsHtmlDir,
274
+ resolveRequestPath,
275
+ runDocsCommand,
276
+ startDocsServer,
277
+ synthesizeMenu,
278
+ topicToFile
279
+ };
280
+ //# sourceMappingURL=docs-YIETIWZI.js.map