@iowarp/clio-coder 0.3.0 → 0.3.2
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.
- package/CHANGELOG.md +123 -2
- package/CONTRIBUTING.md +23 -23
- package/README.md +295 -627
- package/dist/acp-BIYHVZIM.js +128 -0
- package/dist/{agents-Q4MYPMUW.js → agents-YT6SSRIT.js} +52 -27
- package/dist/assets/codewiki.json +1 -0
- package/dist/assets/grammars/notices/@vscode__tree-sitter-wasm/LICENSE +21 -0
- package/dist/assets/grammars/notices/@vscode__tree-sitter-wasm/cgmanifest.json +16 -0
- package/dist/assets/grammars/notices/tree-sitter-wasms/LICENSE +24 -0
- package/dist/assets/grammars/tree-sitter-c-sharp.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-c.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-cpp.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-go.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-java.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-javascript.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-python.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-ruby.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-rust.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-tsx.wasm +0 -0
- package/dist/assets/grammars/tree-sitter-typescript.wasm +0 -0
- package/dist/assets/grammars/tree-sitter.wasm +0 -0
- package/dist/{auth-O6HYIJ6J.js → auth-5TWEIYDN.js} +30 -15
- package/dist/chunk-2EHAIA3X.js +481 -0
- package/dist/{chunk-ME6DNWIU.js → chunk-2IR2NMPA.js} +12 -4
- package/dist/chunk-2SFS6XQE.js +122 -0
- package/dist/{chunk-KKKPTZLM.js → chunk-2STGEDFV.js} +8 -1
- package/dist/chunk-2VTFPG5O.js +48 -0
- package/dist/chunk-3I7MS7N2.js +40 -0
- package/dist/chunk-3R73A4XB.js +69 -0
- package/dist/{chunk-JPOWPFCU.js → chunk-3ZXDFGR5.js} +52 -23
- package/dist/chunk-4BJ5BYCE.js +61 -0
- package/dist/{chunk-26BZQOAD.js → chunk-4BPJXDWC.js} +161 -260
- package/dist/chunk-4KLWL3UC.js +18 -0
- package/dist/{chunk-5LDRNKX2.js → chunk-4VP4KH3K.js} +161 -262
- package/dist/chunk-4ZG3XFUR.js +77 -0
- package/dist/chunk-5B2AEOW5.js +5407 -0
- package/dist/chunk-5TSRNF4G.js +510 -0
- package/dist/{chunk-WD6AJM35.js → chunk-5UUP6MWO.js} +48 -69
- package/dist/{chunk-X3BR7HWV.js → chunk-5WIGXA4T.js} +7 -1
- package/dist/chunk-65DEGPJ6.js +52 -0
- package/dist/chunk-6EJMN2Y3.js +17 -0
- package/dist/chunk-6EJV5X2W.js +16405 -0
- package/dist/chunk-6N5PTWMY.js +136 -0
- package/dist/chunk-6XLNIQDB.js +27 -0
- package/dist/{chunk-XNISANGE.js → chunk-77VKQEHF.js} +171 -74
- package/dist/chunk-7CR24IG7.js +242 -0
- package/dist/{chunk-UWIJNAOB.js → chunk-7EYHLWU7.js} +907 -638
- package/dist/chunk-7MNJORFF.js +22 -0
- package/dist/{chunk-JWHCJDCI.js → chunk-A3CYT5EX.js} +257 -79
- package/dist/chunk-AGYYIBLL.js +1069 -0
- package/dist/chunk-AO4RKG4M.js +277 -0
- package/dist/chunk-APJ265NV.js +7410 -0
- package/dist/chunk-ARBGF5F7.js +174 -0
- package/dist/{chunk-TFSSEXL6.js → chunk-BMEMKKIT.js} +14 -4
- package/dist/{chunk-X3NE4WVW.js → chunk-BNAZZHFG.js} +7 -1
- package/dist/chunk-CBCAPZAA.js +229 -0
- package/dist/{chunk-QV47YRF4.js → chunk-CGKSTWHD.js} +7 -1
- package/dist/chunk-CMZWFGD2.js +352 -0
- package/dist/chunk-ECH6PKUQ.js +39 -0
- package/dist/{chunk-67MTHP2E.js → chunk-ED4KHGC3.js} +13 -5
- package/dist/chunk-EKMEHE4H.js +340 -0
- package/dist/{chunk-O4EJEDHO.js → chunk-EPVUXGXG.js} +50 -35
- package/dist/chunk-FCSXB6T2.js +338 -0
- package/dist/chunk-FJ3H4MN5.js +48 -0
- package/dist/chunk-FQ4SKYE4.js +29 -0
- package/dist/chunk-G2DE3C7R.js +644 -0
- package/dist/chunk-G4BMMOKF.js +182 -0
- package/dist/{chunk-7BHLZB3A.js → chunk-GGXXDWE4.js} +190 -1218
- package/dist/chunk-HC4CLZ2Y.js +68 -0
- package/dist/{chunk-E3NYWENM.js → chunk-HFSBBKSQ.js} +55 -61
- package/dist/chunk-HKIYEGME.js +30 -0
- package/dist/chunk-I4HZDVNP.js +73 -0
- package/dist/chunk-IGLFWIYI.js +161 -0
- package/dist/chunk-IHXBNWMM.js +137 -0
- package/dist/chunk-IKCO5N3L.js +162 -0
- package/dist/chunk-IR4CFBFN.js +56 -0
- package/dist/{chunk-DXQNI4PC.js → chunk-IWHMRKLL.js} +8 -1
- package/dist/{chunk-VOO7NYPP.js → chunk-J5HN4RYU.js} +27 -9
- package/dist/{chunk-4UQA7NCT.js → chunk-J5Q24KAG.js} +7 -2
- package/dist/{chunk-KBR4MZZR.js → chunk-JVCV3ICN.js} +7 -1
- package/dist/chunk-KJ5LWLOE.js +1077 -0
- package/dist/chunk-LBMZMYH2.js +285 -0
- package/dist/{chunk-3DANZDGR.js → chunk-LBNRH5WM.js} +100 -161
- package/dist/{chunk-TKHQ4DGZ.js → chunk-LZSJBIVT.js} +7358 -7414
- package/dist/{chunk-UGYAX5YI.js → chunk-M6SHUN7Q.js} +13 -8
- package/dist/chunk-MAW544W2.js +1882 -0
- package/dist/chunk-MBS4V7ZP.js +217 -0
- package/dist/{chunk-2J63S4SF.js → chunk-MFFY33HR.js} +167 -140
- package/dist/chunk-MNA4JGU4.js +255 -0
- package/dist/chunk-MQSRRFWA.js +3428 -0
- package/dist/{chunk-RQDWMVRB.js → chunk-MVVUPGPW.js} +138 -137
- package/dist/chunk-OAO4GE4M.js +619 -0
- package/dist/chunk-OHHN2SO4.js +5135 -0
- package/dist/chunk-OKGUZO2U.js +34 -0
- package/dist/{chunk-BBUH4VAA.js → chunk-OOJYHWRB.js} +60 -361
- package/dist/{chunk-D5YD55AR.js → chunk-OQ33BKR3.js} +12 -1
- package/dist/chunk-OQE5J4C6.js +73 -0
- package/dist/{chunk-AMFR5YA3.js → chunk-ORBHGJC5.js} +26 -12
- package/dist/chunk-POHLU5DW.js +1186 -0
- package/dist/chunk-QKMUKYO7.js +4961 -0
- package/dist/{chunk-7RBKDI66.js → chunk-QTYWRVRA.js} +104 -12
- package/dist/{chunk-5N2FG33Q.js → chunk-R346GLFC.js} +7 -1
- package/dist/chunk-SRF2PJNW.js +184 -0
- package/dist/chunk-SST6Z5JA.js +80 -0
- package/dist/{chunk-XV4ZJ6ZM.js → chunk-STBPMHSX.js} +473 -1194
- package/dist/{chunk-HBU5MTAM.js → chunk-SVNXH4L2.js} +7 -1
- package/dist/chunk-T6YILFSB.js +80 -0
- package/dist/chunk-TXOTCRLG.js +15 -0
- package/dist/chunk-TZTZS7QK.js +227 -0
- package/dist/chunk-UOV2BYIW.js +107 -0
- package/dist/{chunk-527KG6XR.js → chunk-V4RXGQ5Q.js} +72 -185
- package/dist/chunk-VAKQQHWR.js +434 -0
- package/dist/chunk-VG7TBQIY.js +128 -0
- package/dist/chunk-VJWL6YS5.js +244 -0
- package/dist/chunk-WEH5XRJQ.js +32 -0
- package/dist/{chunk-VPAWTYLY.js → chunk-WEPFGWHJ.js} +7 -1
- package/dist/chunk-WMSVI4G2.js +2095 -0
- package/dist/chunk-WVO7V2QY.js +797 -0
- package/dist/chunk-X4RCMKVQ.js +641 -0
- package/dist/chunk-X75S7HFS.js +374 -0
- package/dist/chunk-XN3L4EYL.js +46 -0
- package/dist/{chunk-HMYNFFY4.js → chunk-XPLRXC72.js} +7 -2
- package/dist/{chunk-PIDUD6M2.js → chunk-YCWGATWI.js} +12 -5
- package/dist/chunk-YHZX5GEU.js +193 -0
- package/dist/chunk-YXLYO42X.js +91 -0
- package/dist/{chunk-UHTSULZS.js → chunk-ZDOOVTXZ.js} +38 -73
- package/dist/chunk-ZI647VB5.js +37 -0
- package/dist/{chunk-CLJ5HLUD.js → chunk-ZWLZP4ZT.js} +25 -6
- package/dist/cli/index.js +70 -56
- package/dist/clio-4LY5K2AC.js +25 -0
- package/dist/code-nav-7AX6FYE6.js +600 -0
- package/dist/codewiki/build-worker.js +66 -0
- package/dist/compile-cache-CVJMMODC.js +18 -0
- package/dist/{components-JVHMUBEB.js → components-KELWS457.js} +31 -9
- package/dist/{config-ZFCDBMDC.js → config-GTLUW2PR.js} +104 -56
- package/dist/configure-R6A64DHX.js +42 -0
- package/dist/context-5VKGUVJJ.js +866 -0
- package/dist/{context-CDXTP2MP.js → context-JFZEJ7W5.js} +21 -13
- package/dist/{context-E3KIFVXI.js → context-RW5HC47S.js} +77 -36
- package/dist/{context-clear-3F4PLXOS.js → context-clear-6ZHBAZZT.js} +64 -30
- package/dist/{context-index-Q7YSYTR3.js → context-index-BZ4UYMTC.js} +36 -24
- package/dist/dispatch-runner-VKBRCWQC.js +1997 -0
- package/dist/{docs-YIETIWZI.js → docs-2C2LTVT2.js} +32 -13
- package/dist/doctor-KI767GSN.js +87 -0
- package/dist/{eval-B3KZZESM.js → eval-XSSNATB4.js} +93 -27
- package/dist/{evidence-V67CHM35.js → evidence-UA6AWDQQ.js} +55 -27
- package/dist/{evolve-YDZSUQYA.js → evolve-QNTFGV6Z.js} +59 -26
- package/dist/{extensions-SRG7XCAH.js → extensions-QVDOHDGJ.js} +23 -8
- package/dist/{fleet-CA2CRTVG.js → fleet-Q7UOMUSG.js} +173 -56
- package/dist/fleet-preflight-DDN536IT.js +26 -0
- package/dist/{init-2OZDJE2D.js → init-WBB65ZHQ.js} +79 -34
- package/dist/{memory-3PIQQAKX.js → memory-MD3O64RI.js} +57 -28
- package/dist/{models-DY35XI7Y.js → models-BZU34YWD.js} +49 -24
- package/dist/monitor-MEQA5C3I.js +661 -0
- package/dist/{chunk-PS4PFJQP.js → orchestrator-CGFKEP27.js} +22837 -18564
- package/dist/{paths-5OMXW7Z4.js → paths-UXLN5YYZ.js} +17 -6
- package/dist/preload-P6DGH2PZ.js +13 -0
- package/dist/{reset-PIFYNOS3.js → reset-L2FQEE3E.js} +25 -13
- package/dist/{run-3VSPP24F.js → run-IV4Q6RLN.js} +115 -63
- package/dist/{share-D36RQCXM.js → share-S5BZQC5I.js} +23 -10
- package/dist/{skills-F2MRLELY.js → skills-LQEKRDTN.js} +42 -15
- package/dist/{skills-eval-E2ZTW4PL.js → skills-eval-3DC4HEWS.js} +90 -45
- package/dist/steer-GGWFUJUD.js +77 -0
- package/dist/{targets-DZMEZAH4.js → targets-C4SSGQOB.js} +78 -60
- package/dist/terminal-lease-IT5JW2NR.js +395 -0
- package/dist/{trace-7NYCUI2J.js → trace-PNCASAXC.js} +48 -17
- package/dist/tree-sitter-HGKH6LG4.js +4673 -0
- package/dist/{uninstall-AD3JWHBB.js → uninstall-FZCQCDKC.js} +19 -8
- package/dist/{upgrade-WYYBKGDY.js → upgrade-7TT7SQ3G.js} +66 -24
- package/dist/{usage-ULIDAGFF.js → usage-GV4PKT3M.js} +71 -32
- package/dist/verify-G6V4D2G7.js +716 -0
- package/dist/version-KGEG7EPO.js +21 -0
- package/dist/web-fetch-2YHJ3KTG.js +638 -0
- package/dist/{wiki-generate-PKFIX6OB.js → wiki-generate-DQF6Z66B.js} +98 -48
- package/dist/worker/entry.js +297 -54
- package/dist/workspace-G4ZWUIPR.js +22 -0
- package/docs/README.md +29 -21
- package/docs/acp.md +191 -16
- package/docs/alcf-provider.md +1 -1
- package/docs/architecture.md +157 -7
- package/docs/artifact-placement.md +101 -0
- package/docs/artifact-versions.md +1 -1
- package/docs/built-in-agents.md +4 -2
- package/docs/capacity-and-scheduling.md +1 -1
- package/docs/commands-and-modes.md +224 -97
- package/docs/config-knobs-audit.md +1 -3
- package/docs/configuration-and-targets.md +236 -38
- package/docs/context-engine.md +34 -7
- package/docs/development-pipeline.md +102 -0
- package/docs/dispatch-architecture-rationale.md +1 -1
- package/docs/documentation-coverage.md +4 -4
- package/docs/documentation-guide.md +3 -3
- package/docs/environment-variables.md +15 -6
- package/docs/eval-runner.md +3 -3
- package/docs/evals-internal.md +2 -2
- package/docs/evidence-and-memory.md +10 -2
- package/docs/evolution.md +2 -2
- package/docs/exit-codes-and-output.md +15 -9
- package/docs/extensions-and-sharing.md +25 -18
- package/docs/fleet-demo-runbook.md +22 -23
- package/docs/fleet-dispatch.md +117 -16
- package/docs/git-commit-provenance.md +120 -0
- package/docs/glossary.md +107 -15
- package/docs/installation-and-lifecycle.md +75 -17
- package/docs/middleware-and-components.md +1 -1
- package/docs/model-catalog.md +46 -15
- package/docs/observability.md +8 -5
- package/docs/performance-methodology.md +491 -0
- package/docs/pi-boundary.md +72 -0
- package/docs/proactive-memory.md +14 -14
- package/docs/prompt-envelope-and-tools.md +25 -4
- package/docs/provider-adapter-cookbook.md +57 -4
- package/docs/release-cut-checklist.md +129 -111
- package/docs/safety-model.md +28 -8
- package/docs/scientific-validation.md +3 -3
- package/docs/session-lifecycle.md +55 -12
- package/docs/skills-marketplace.md +12 -8
- package/docs/time-conventions.md +101 -0
- package/docs/tool-usage.md +6 -5
- package/docs/trace-store.md +1 -1
- package/docs/troubleshooting.md +10 -7
- package/docs/tui-design.md +121 -28
- package/docs/worker-dispatch-mechanics.md +3 -3
- package/package.json +33 -36
- package/skills/README.md +5 -6
- package/skills/coding/ast-grep/SKILL.md +136 -0
- package/skills/coding/ast-grep/evals.md +56 -0
- package/skills/coding/ast-grep/references/rule_reference.md +297 -0
- package/skills/coding/coding-standards/SKILL.md +113 -0
- package/skills/coding/coding-standards/evals.md +34 -0
- package/skills/coding/prototype/SKILL.md +86 -0
- package/skills/coding/prototype/evals.md +42 -0
- package/skills/coding/prototype/references/LOGIC.md +67 -0
- package/skills/coding/prototype/references/UI.md +112 -0
- package/skills/coding/tdd/SKILL.md +101 -0
- package/skills/coding/tdd/evals.md +41 -0
- package/skills/coding/tdd/references/mocking.md +59 -0
- package/skills/coding/tdd/references/tests.md +77 -0
- package/skills/context/context-handoff/SKILL.md +126 -0
- package/skills/context/context-handoff/evals.md +57 -0
- package/skills/context/context-handoff/scripts/new-handoff.sh +26 -0
- package/skills/context/context-prime/SKILL.md +95 -0
- package/skills/context/context-prime/evals.md +54 -0
- package/skills/git/file-ticket/SKILL.md +107 -0
- package/skills/git/file-ticket/evals.md +54 -0
- package/skills/git/fix-issue/SKILL.md +106 -0
- package/skills/git/fix-issue/evals.md +71 -0
- package/skills/git/ship/SKILL.md +92 -0
- package/skills/git/ship/evals.md +72 -0
- package/skills/meta/clio-dev/SKILL.md +91 -0
- package/skills/meta/clio-dev/evals.md +45 -0
- package/skills/meta/clio-test/SKILL.md +130 -0
- package/skills/meta/clio-test/evals.md +43 -0
- package/skills/meta/clio-test/references/harness.md +97 -0
- package/skills/meta/clio-test/references/test-map.md +59 -0
- package/skills/meta/credentials/SKILL.md +125 -0
- package/skills/meta/credentials/evals.md +104 -0
- package/skills/meta/find-skills/SKILL.md +72 -0
- package/skills/meta/find-skills/evals.md +47 -0
- package/skills/meta/herdr/SKILL.md +127 -0
- package/skills/meta/herdr/evals.md +38 -0
- package/skills/meta/skill-craft/SKILL.md +102 -0
- package/skills/meta/skill-craft/evals.md +41 -0
- package/skills/planning/architecture/SKILL.md +129 -0
- package/skills/planning/architecture/evals.md +36 -0
- package/skills/planning/backlog/SKILL.md +90 -0
- package/skills/planning/backlog/evals.md +43 -0
- package/skills/planning/prd/SKILL.md +82 -0
- package/skills/planning/prd/evals.md +49 -0
- package/skills/planning/product-intent/SKILL.md +112 -0
- package/skills/planning/product-intent/evals.md +36 -0
- package/skills/planning/tech-spec/SKILL.md +115 -0
- package/skills/planning/tech-spec/evals.md +47 -0
- package/skills/registry.yaml +136 -0
- package/skills/research/arxiv-literature/SKILL.md +104 -0
- package/skills/research/arxiv-literature/evals.md +58 -0
- package/skills/research/experiment-protocol/SKILL.md +122 -0
- package/skills/research/experiment-protocol/evals.md +91 -0
- package/skills/research/scientific-debugging/SKILL.md +119 -0
- package/skills/research/scientific-debugging/evals.md +138 -0
- package/skills/research/scientific-modernization/SKILL.md +138 -0
- package/skills/research/scientific-modernization/evals.md +84 -0
- package/skills/skill-marketplace.json +12 -20
- package/skills/workflow/design-council/SKILL.md +139 -0
- package/skills/workflow/design-council/evals.md +97 -0
- package/skills/workflow/grill-me/SKILL.md +186 -0
- package/skills/workflow/grill-me/evals.md +78 -0
- package/skills/workflow/workflow-distiller/SKILL.md +136 -0
- package/skills/workflow/workflow-distiller/evals.md +107 -0
- package/src/cli/acp.ts +115 -0
- package/src/cli/agents.ts +60 -0
- package/src/cli/args.ts +280 -0
- package/src/cli/argv.ts +170 -0
- package/src/cli/ask.ts +34 -0
- package/src/cli/auth.ts +468 -0
- package/src/cli/bootstrap-generate.ts +498 -0
- package/src/cli/clio.ts +96 -0
- package/src/cli/components.ts +195 -0
- package/src/cli/config-inspect.ts +336 -0
- package/src/cli/config.ts +72 -0
- package/src/cli/configure-interop.ts +67 -0
- package/src/cli/configure-layout.ts +172 -0
- package/src/cli/configure.ts +1525 -0
- package/src/cli/context-clear.ts +76 -0
- package/src/cli/context-index.ts +100 -0
- package/src/cli/context.ts +321 -0
- package/src/cli/default-target.ts +55 -0
- package/src/cli/docs.ts +346 -0
- package/src/cli/doctor.ts +54 -0
- package/src/cli/eval.ts +315 -0
- package/src/cli/evidence.ts +225 -0
- package/src/cli/evolve.ts +219 -0
- package/src/cli/extensions.ts +214 -0
- package/src/cli/fleet.ts +868 -0
- package/src/cli/index.ts +338 -0
- package/src/cli/init.ts +219 -0
- package/src/cli/initial-message.ts +47 -0
- package/src/cli/internal-dispatch.ts +55 -0
- package/src/cli/memory.ts +182 -0
- package/src/cli/models.ts +257 -0
- package/src/cli/modes/json-stream.ts +121 -0
- package/src/cli/modes/jsonl.ts +9 -0
- package/src/cli/modes/print.ts +604 -0
- package/src/cli/oauth-manual-input.ts +72 -0
- package/src/cli/oauth-select.ts +36 -0
- package/src/cli/output-guard.ts +48 -0
- package/src/cli/paths.ts +44 -0
- package/src/cli/provider-target.ts +113 -0
- package/src/cli/removal.ts +72 -0
- package/src/cli/reset.ts +253 -0
- package/src/cli/run.ts +497 -0
- package/src/cli/share.ts +243 -0
- package/src/cli/shared.ts +60 -0
- package/src/cli/skills-eval.ts +1240 -0
- package/src/cli/skills.ts +485 -0
- package/src/cli/steer-channel.ts +86 -0
- package/src/cli/targets.ts +1154 -0
- package/src/cli/text-layout.ts +112 -0
- package/src/cli/trace.ts +322 -0
- package/src/cli/uninstall.ts +405 -0
- package/src/cli/upgrade.ts +286 -0
- package/src/cli/usage.ts +876 -0
- package/src/cli/validate-model.ts +28 -0
- package/src/cli/version.ts +7 -0
- package/src/cli/wiki-generate.ts +510 -0
- package/src/core/agent-environment.ts +7 -0
- package/src/core/artifact-paths.ts +43 -0
- package/src/core/bash-exec.ts +313 -0
- package/src/core/boot-trace.ts +42 -0
- package/src/core/bus-events.ts +744 -0
- package/src/core/bus-trace.ts +53 -0
- package/src/core/c-header-language.ts +265 -0
- package/src/core/clio-repo.ts +78 -0
- package/src/core/commit-attribution.ts +157 -0
- package/src/core/compile-cache.ts +159 -0
- package/src/core/config.ts +1722 -0
- package/src/core/context-floor.ts +33 -0
- package/src/core/defaults.ts +659 -0
- package/src/core/domain-loader.ts +177 -0
- package/src/core/event-bus.ts +94 -0
- package/src/core/file-references.ts +282 -0
- package/src/core/git-commit-attribution.ts +362 -0
- package/src/core/guardrails.ts +185 -0
- package/src/core/headless-permission.ts +21 -0
- package/src/core/incomplete-installation.ts +45 -0
- package/src/core/init.ts +223 -0
- package/src/core/json-payload.ts +58 -0
- package/src/core/package-root.ts +54 -0
- package/src/core/path-canonical.ts +37 -0
- package/src/core/process-identity.ts +41 -0
- package/src/core/recent-models.ts +91 -0
- package/src/core/residency-protection.ts +56 -0
- package/src/core/resolve-config-value.ts +88 -0
- package/src/core/response-schema.ts +279 -0
- package/src/core/run-overrides.ts +77 -0
- package/src/core/safe-exec.ts +205 -0
- package/src/core/safe-id.ts +37 -0
- package/src/core/safe-resource-write.ts +162 -0
- package/src/core/session-routing.ts +339 -0
- package/src/core/settings-layers.ts +354 -0
- package/src/core/shared-bus.ts +8 -0
- package/src/core/shell-quote.ts +26 -0
- package/src/core/skill-activation.ts +190 -0
- package/src/core/startup-timer.ts +37 -0
- package/src/core/state-file-lock.ts +219 -0
- package/src/core/termination.ts +275 -0
- package/src/core/timers.ts +38 -0
- package/src/core/tool-names.ts +65 -0
- package/src/core/verification-scripts.ts +13 -0
- package/src/core/workspace-files.ts +492 -0
- package/src/core/xdg.ts +177 -0
- package/src/domains/agents/builtins/architect.md +4 -4
- package/src/domains/agents/builtins/coder.md +3 -2
- package/src/domains/agents/builtins/debugger.md +1 -1
- package/src/domains/agents/builtins/documenter.md +1 -1
- package/src/domains/agents/builtins/git-master.md +3 -3
- package/src/domains/agents/builtins/provenance.md +1 -1
- package/src/domains/agents/builtins/researcher.md +1 -1
- package/src/domains/agents/builtins/scout.md +1 -1
- package/src/domains/agents/builtins/tester.md +1 -1
- package/src/domains/agents/builtins/verifier.md +1 -1
- package/src/domains/agents/builtins/wiki-writer.md +1 -1
- package/src/domains/agents/catalog.ts +172 -0
- package/src/domains/agents/contract.ts +16 -0
- package/src/domains/agents/extension.ts +110 -0
- package/src/domains/agents/fleet-commands.ts +154 -0
- package/src/domains/agents/fleet-contract.ts +797 -0
- package/src/domains/agents/frontmatter.ts +40 -0
- package/src/domains/agents/index.ts +102 -0
- package/src/domains/agents/manifest.ts +6 -0
- package/src/domains/agents/recipe-schema.ts +202 -0
- package/src/domains/agents/recipe.ts +125 -0
- package/src/domains/agents/registry.ts +111 -0
- package/src/domains/agents/result-contract.ts +1265 -0
- package/src/domains/agents/spec.ts +371 -0
- package/src/domains/agents/write-boundary.ts +109 -0
- package/src/domains/components/diff.ts +99 -0
- package/src/domains/components/hash.ts +21 -0
- package/src/domains/components/index.ts +3 -0
- package/src/domains/components/scan.ts +304 -0
- package/src/domains/components/snapshot.ts +108 -0
- package/src/domains/components/types.ts +82 -0
- package/src/domains/config/agent-namespace.ts +13 -0
- package/src/domains/config/classify.ts +106 -0
- package/src/domains/config/contract.ts +22 -0
- package/src/domains/config/extension.ts +142 -0
- package/src/domains/config/index.ts +23 -0
- package/src/domains/config/keybindings.ts +200 -0
- package/src/domains/config/manifest.ts +6 -0
- package/src/domains/config/watcher.ts +41 -0
- package/src/domains/context/adoption.ts +880 -0
- package/src/domains/context/bootstrap-prompt.ts +273 -0
- package/src/domains/context/bootstrap.ts +1502 -0
- package/src/domains/context/clear.ts +91 -0
- package/src/domains/context/clio-md.ts +429 -0
- package/src/domains/context/codewiki/artifact.ts +400 -0
- package/src/domains/context/codewiki/build-worker-protocol.ts +24 -0
- package/src/domains/context/codewiki/build-worker.ts +54 -0
- package/src/domains/context/codewiki/cmake.ts +356 -0
- package/src/domains/context/codewiki/cooperative.ts +46 -0
- package/src/domains/context/codewiki/coordinator.ts +182 -0
- package/src/domains/context/codewiki/digest.ts +135 -0
- package/src/domains/context/codewiki/grammar-assets.ts +33 -0
- package/src/domains/context/codewiki/indexer.ts +1529 -0
- package/src/domains/context/codewiki/paths.ts +67 -0
- package/src/domains/context/codewiki/schema.ts +80 -0
- package/src/domains/context/codewiki/tree-sitter.ts +771 -0
- package/src/domains/context/contract.ts +68 -0
- package/src/domains/context/excluded-dirs.ts +1 -0
- package/src/domains/context/extension.ts +358 -0
- package/src/domains/context/fingerprint.ts +198 -0
- package/src/domains/context/index.ts +154 -0
- package/src/domains/context/init-options.ts +69 -0
- package/src/domains/context/manifest.ts +6 -0
- package/src/domains/context/operator-profile.ts +157 -0
- package/src/domains/context/project-metadata.ts +529 -0
- package/src/domains/context/project-rules.ts +227 -0
- package/src/domains/context/prompt-context.ts +61 -0
- package/src/domains/context/refresh.ts +178 -0
- package/src/domains/context/runtime.ts +17 -0
- package/src/domains/context/sibling-files.ts +10 -0
- package/src/domains/context/state.ts +237 -0
- package/src/domains/context/wiki/assemble.ts +303 -0
- package/src/domains/context/wiki/frontmatter.ts +210 -0
- package/src/domains/context/wiki/generate.ts +595 -0
- package/src/domains/context/wiki/layout.ts +111 -0
- package/src/domains/context/wiki/meta.ts +221 -0
- package/src/domains/context/wiki/plan-store.ts +217 -0
- package/src/domains/context/wiki/plan.ts +250 -0
- package/src/domains/context/wiki/prompts.ts +283 -0
- package/src/domains/context/wiki/staleness.ts +198 -0
- package/src/domains/dispatch/active-route-planner.ts +168 -0
- package/src/domains/dispatch/admission-queue.ts +150 -0
- package/src/domains/dispatch/admission.ts +334 -0
- package/src/domains/dispatch/agent-candidates.ts +307 -0
- package/src/domains/dispatch/agent-ledger-hub.ts +71 -0
- package/src/domains/dispatch/agent-ledger-store.ts +257 -0
- package/src/domains/dispatch/agent-ledger.ts +212 -0
- package/src/domains/dispatch/agent-plan-adapter.ts +85 -0
- package/src/domains/dispatch/assignment-events.ts +132 -0
- package/src/domains/dispatch/assignment-reconcile.ts +76 -0
- package/src/domains/dispatch/assignment-store.ts +162 -0
- package/src/domains/dispatch/assignment.ts +278 -0
- package/src/domains/dispatch/backoff.ts +59 -0
- package/src/domains/dispatch/batch-store.ts +134 -0
- package/src/domains/dispatch/batch-tracker.ts +66 -0
- package/src/domains/dispatch/capability-match.ts +155 -0
- package/src/domains/dispatch/capacity-lease.ts +413 -0
- package/src/domains/dispatch/code-step-store.ts +52 -0
- package/src/domains/dispatch/code-step.ts +387 -0
- package/src/domains/dispatch/contract.ts +278 -0
- package/src/domains/dispatch/dedup.ts +133 -0
- package/src/domains/dispatch/event-pump.ts +251 -0
- package/src/domains/dispatch/execution-handoff.ts +29 -0
- package/src/domains/dispatch/execution-plan.ts +328 -0
- package/src/domains/dispatch/execution-role.ts +277 -0
- package/src/domains/dispatch/execution-scheduler.ts +583 -0
- package/src/domains/dispatch/extension.ts +6006 -0
- package/src/domains/dispatch/failure-classification.ts +147 -0
- package/src/domains/dispatch/fleet-commit-attribution.ts +56 -0
- package/src/domains/dispatch/fleet-plan.ts +225 -0
- package/src/domains/dispatch/fleet-preflight.ts +394 -0
- package/src/domains/dispatch/gate-decisions.ts +1040 -0
- package/src/domains/dispatch/gate-role-prompts.ts +58 -0
- package/src/domains/dispatch/heartbeat.ts +27 -0
- package/src/domains/dispatch/index.ts +137 -0
- package/src/domains/dispatch/joint-route-adapter.ts +114 -0
- package/src/domains/dispatch/joint-route-resolver.ts +283 -0
- package/src/domains/dispatch/manifest.ts +6 -0
- package/src/domains/dispatch/orphan-recovery.ts +266 -0
- package/src/domains/dispatch/outcome.ts +109 -0
- package/src/domains/dispatch/phase-timing.ts +47 -0
- package/src/domains/dispatch/placement.ts +202 -0
- package/src/domains/dispatch/receipt-findings.ts +255 -0
- package/src/domains/dispatch/receipt-integrity.ts +383 -0
- package/src/domains/dispatch/recovery-candidates.ts +74 -0
- package/src/domains/dispatch/reproducibility.ts +48 -0
- package/src/domains/dispatch/reservation-store.ts +501 -0
- package/src/domains/dispatch/route-approval.ts +177 -0
- package/src/domains/dispatch/route-candidates.ts +57 -0
- package/src/domains/dispatch/route-decision.ts +1079 -0
- package/src/domains/dispatch/route-facts.ts +187 -0
- package/src/domains/dispatch/route-history.ts +238 -0
- package/src/domains/dispatch/route-observer.ts +488 -0
- package/src/domains/dispatch/route-policy.ts +327 -0
- package/src/domains/dispatch/route-quality.ts +256 -0
- package/src/domains/dispatch/route-readiness.ts +120 -0
- package/src/domains/dispatch/routing-intent.ts +287 -0
- package/src/domains/dispatch/run-identity.ts +56 -0
- package/src/domains/dispatch/scout-transition.ts +130 -0
- package/src/domains/dispatch/state.ts +302 -0
- package/src/domains/dispatch/tool-stats.ts +132 -0
- package/src/domains/dispatch/transport.ts +210 -0
- package/src/domains/dispatch/types.ts +799 -0
- package/src/domains/dispatch/validation-grounding.ts +154 -0
- package/src/domains/dispatch/validation.ts +721 -0
- package/src/domains/dispatch/worker-protocol.ts +275 -0
- package/src/domains/dispatch/worker-spawn.ts +585 -0
- package/src/domains/dispatch/write-boundary-enforcer.ts +97 -0
- package/src/domains/dispatch/write-boundary.ts +426 -0
- package/src/domains/eval/artifacts/redact.ts +42 -0
- package/src/domains/eval/artifacts/store.ts +173 -0
- package/src/domains/eval/compare/compare.ts +33 -0
- package/src/domains/eval/compare/gates.ts +66 -0
- package/src/domains/eval/compare/thresholds.ts +92 -0
- package/src/domains/eval/harness-metrics.ts +62 -0
- package/src/domains/eval/index.ts +66 -0
- package/src/domains/eval/metrics/chaos-stream.ts +93 -0
- package/src/domains/eval/metrics/context.ts +34 -0
- package/src/domains/eval/metrics/coverage.ts +21 -0
- package/src/domains/eval/metrics/evidence.ts +182 -0
- package/src/domains/eval/metrics/fleet-loop-stream.ts +196 -0
- package/src/domains/eval/metrics/invariants.ts +736 -0
- package/src/domains/eval/metrics/latency.ts +4 -0
- package/src/domains/eval/metrics/token-stream.ts +139 -0
- package/src/domains/eval/metrics/tokens.ts +51 -0
- package/src/domains/eval/metrics/tool-calls.ts +7 -0
- package/src/domains/eval/proactive-memory.ts +279 -0
- package/src/domains/eval/provenance.ts +35 -0
- package/src/domains/eval/report.ts +234 -0
- package/src/domains/eval/reports/json.ts +5 -0
- package/src/domains/eval/reports/junit.ts +23 -0
- package/src/domains/eval/reports/markdown.ts +20 -0
- package/src/domains/eval/reports/swe-jsonl.ts +16 -0
- package/src/domains/eval/reports/text.ts +25 -0
- package/src/domains/eval/run-compare.ts +274 -0
- package/src/domains/eval/runner.ts +244 -0
- package/src/domains/eval/runners/clio-run.ts +148 -0
- package/src/domains/eval/runners/context-index.ts +56 -0
- package/src/domains/eval/runners/context-init.ts +203 -0
- package/src/domains/eval/runners/external-command.ts +350 -0
- package/src/domains/eval/runtime-paths.ts +171 -0
- package/src/domains/eval/schema/artifact.ts +75 -0
- package/src/domains/eval/schema/suite.ts +235 -0
- package/src/domains/eval/schema/validate.ts +339 -0
- package/src/domains/eval/store.ts +392 -0
- package/src/domains/eval/suites/load.ts +74 -0
- package/src/domains/eval/suites/matrix.ts +19 -0
- package/src/domains/eval/suites/resolve.ts +44 -0
- package/src/domains/eval/suites/run.ts +325 -0
- package/src/domains/eval/task-file.ts +186 -0
- package/src/domains/eval/types.ts +140 -0
- package/src/domains/eval/verifiers/command.ts +27 -0
- package/src/domains/eval/verifiers/file-exists.ts +6 -0
- package/src/domains/eval/verifiers/patch.ts +22 -0
- package/src/domains/eval/workspaces/git.ts +41 -0
- package/src/domains/eval/workspaces/local.ts +17 -0
- package/src/domains/eval/workspaces/temp-copy.ts +29 -0
- package/src/domains/evidence/build.ts +1754 -0
- package/src/domains/evidence/eval.ts +605 -0
- package/src/domains/evidence/failure-attribution.ts +54 -0
- package/src/domains/evidence/finish-contract-map.ts +42 -0
- package/src/domains/evidence/index.ts +55 -0
- package/src/domains/evidence/provenance.ts +200 -0
- package/src/domains/evidence/redact.ts +81 -0
- package/src/domains/evidence/store.ts +291 -0
- package/src/domains/evidence/types.ts +325 -0
- package/src/domains/evolution/SELF_EDIT_GATE.md +91 -0
- package/src/domains/evolution/index.ts +26 -0
- package/src/domains/evolution/manifest.ts +154 -0
- package/src/domains/evolution/validate.ts +304 -0
- package/src/domains/extensions/contract.ts +22 -0
- package/src/domains/extensions/discovery.ts +193 -0
- package/src/domains/extensions/extension.ts +46 -0
- package/src/domains/extensions/index.ts +34 -0
- package/src/domains/extensions/manager.ts +30 -0
- package/src/domains/extensions/manifest.ts +6 -0
- package/src/domains/extensions/resources.ts +38 -0
- package/src/domains/extensions/state.ts +224 -0
- package/src/domains/extensions/types.ts +83 -0
- package/src/domains/interop/consent.ts +185 -0
- package/src/domains/interop/contract.ts +29 -0
- package/src/domains/interop/detect.ts +173 -0
- package/src/domains/interop/extension.ts +59 -0
- package/src/domains/interop/index.ts +34 -0
- package/src/domains/interop/manifest.ts +6 -0
- package/src/domains/interop/registry.ts +139 -0
- package/src/domains/interop/state.ts +92 -0
- package/src/domains/interop/types.ts +109 -0
- package/src/domains/lifecycle/contract.ts +11 -0
- package/src/domains/lifecycle/doctor.ts +536 -0
- package/src/domains/lifecycle/extension.ts +23 -0
- package/src/domains/lifecycle/index.ts +21 -0
- package/src/domains/lifecycle/install-method.ts +51 -0
- package/src/domains/lifecycle/manifest.ts +6 -0
- package/src/domains/lifecycle/migrations/2026-08-18-lmstudio-runtime-id.ts +52 -0
- package/src/domains/lifecycle/migrations/index.ts +114 -0
- package/src/domains/lifecycle/state.ts +93 -0
- package/src/domains/lifecycle/upgrade-notice.ts +35 -0
- package/src/domains/lifecycle/version.ts +35 -0
- package/src/domains/memory/index.ts +128 -0
- package/src/domains/memory/operations.ts +143 -0
- package/src/domains/memory/prompt-section.ts +86 -0
- package/src/domains/memory/proposal.ts +180 -0
- package/src/domains/memory/store.ts +163 -0
- package/src/domains/memory/task-bank.ts +229 -0
- package/src/domains/memory/task-memory-handoff.ts +222 -0
- package/src/domains/memory/task-memory-policy.ts +602 -0
- package/src/domains/memory/task-memory-status.ts +58 -0
- package/src/domains/memory/task-memory-telemetry.ts +346 -0
- package/src/domains/memory/task-memory-trace.ts +89 -0
- package/src/domains/memory/types.ts +74 -0
- package/src/domains/memory/validate.ts +297 -0
- package/src/domains/middleware/budget.ts +216 -0
- package/src/domains/middleware/contract.ts +35 -0
- package/src/domains/middleware/dispatch-nudge.ts +469 -0
- package/src/domains/middleware/extension.ts +129 -0
- package/src/domains/middleware/hook-receipts.ts +70 -0
- package/src/domains/middleware/hooks-io.ts +186 -0
- package/src/domains/middleware/hooks.ts +432 -0
- package/src/domains/middleware/index.ts +154 -0
- package/src/domains/middleware/manifest.ts +6 -0
- package/src/domains/middleware/memory-intervention.ts +701 -0
- package/src/domains/middleware/rules.ts +42 -0
- package/src/domains/middleware/runtime.ts +333 -0
- package/src/domains/middleware/skills-reminder.ts +202 -0
- package/src/domains/middleware/snapshot.ts +71 -0
- package/src/domains/middleware/stalled-turn.ts +71 -0
- package/src/domains/middleware/task-board-reminder.ts +87 -0
- package/src/domains/middleware/task-nudge.ts +77 -0
- package/src/domains/middleware/tool-choice-control.ts +42 -0
- package/src/domains/middleware/types.ts +131 -0
- package/src/domains/middleware/validate.ts +329 -0
- package/src/domains/observability/accountability.ts +67 -0
- package/src/domains/observability/contract.ts +168 -0
- package/src/domains/observability/cost.ts +206 -0
- package/src/domains/observability/evidence-index.ts +123 -0
- package/src/domains/observability/extension.ts +281 -0
- package/src/domains/observability/index.ts +78 -0
- package/src/domains/observability/manifest.ts +10 -0
- package/src/domains/observability/metrics.ts +37 -0
- package/src/domains/observability/projection.ts +477 -0
- package/src/domains/observability/telemetry.ts +89 -0
- package/src/domains/observability/trace-store.ts +1454 -0
- package/src/domains/prompts/compiler.ts +614 -0
- package/src/domains/prompts/contract.ts +46 -0
- package/src/domains/prompts/extension.ts +336 -0
- package/src/domains/prompts/fragment-loader.ts +138 -0
- package/src/domains/prompts/fragments/identity/clio.md +5 -6
- package/src/domains/prompts/fragments/identity/docs-routing.md +10 -0
- package/src/domains/prompts/fragments/identity/self-awareness.md +19 -0
- package/src/domains/prompts/fragments/operating/contract.md +4 -41
- package/src/domains/prompts/fragments/operating/delegation.md +42 -0
- package/src/domains/prompts/fragments/operating/skills.md +26 -0
- package/src/domains/prompts/fragments/operating/worker.md +16 -0
- package/src/domains/prompts/fragments/safety/auto-edit.md +5 -5
- package/src/domains/prompts/fragments/safety/full-auto.md +3 -3
- package/src/domains/prompts/fragments/safety/read-only.md +4 -4
- package/src/domains/prompts/fragments/safety/suggest.md +2 -2
- package/src/domains/prompts/fragments/wiki/page.md +10 -0
- package/src/domains/prompts/fragments/wiki/plan.md +10 -0
- package/src/domains/prompts/hash.ts +73 -0
- package/src/domains/prompts/index.ts +32 -0
- package/src/domains/prompts/manifest.ts +8 -0
- package/src/domains/prompts/memory-intervention.ts +57 -0
- package/src/domains/prompts/preload.ts +82 -0
- package/src/domains/providers/auth/api-key.ts +47 -0
- package/src/domains/providers/auth/backend-file.ts +79 -0
- package/src/domains/providers/auth/backend-memory.ts +72 -0
- package/src/domains/providers/auth/boot-status.ts +65 -0
- package/src/domains/providers/auth/index.ts +37 -0
- package/src/domains/providers/auth/oauth.ts +37 -0
- package/src/domains/providers/auth/storage.ts +726 -0
- package/src/domains/providers/capabilities.ts +58 -0
- package/src/domains/providers/catalog.ts +162 -0
- package/src/domains/providers/contract.ts +162 -0
- package/src/domains/providers/credentials.ts +20 -0
- package/src/domains/providers/eligibility.ts +24 -0
- package/src/domains/providers/errors.ts +64 -0
- package/src/domains/providers/extension.ts +548 -0
- package/src/domains/providers/index.ts +142 -0
- package/src/domains/providers/knowledge-base-path.ts +102 -0
- package/src/domains/providers/manifest.ts +6 -0
- package/src/domains/providers/model-capabilities.ts +136 -0
- package/src/domains/providers/model-discovery.ts +144 -0
- package/src/domains/providers/model-family.ts +32 -0
- package/src/domains/providers/model-runtime-capabilities.ts +723 -0
- package/src/domains/providers/models/local-models/clio-local-coding-targets.yaml +120 -37
- package/src/domains/providers/plugins.ts +61 -0
- package/src/domains/providers/probe/fingerprint.ts +64 -0
- package/src/domains/providers/probe/http.ts +114 -0
- package/src/domains/providers/probe/reasoning.ts +111 -0
- package/src/domains/providers/registry.ts +187 -0
- package/src/domains/providers/resolver.ts +156 -0
- package/src/domains/providers/runtime-resolution.ts +720 -0
- package/src/domains/providers/runtimes/antigravity/antigravity-code.ts +90 -0
- package/src/domains/providers/runtimes/boot-manifest.ts +55 -0
- package/src/domains/providers/runtimes/builtins.ts +78 -0
- package/src/domains/providers/runtimes/claude/claude-code.ts +38 -0
- package/src/domains/providers/runtimes/claude/claude-sdk.ts +38 -0
- package/src/domains/providers/runtimes/claude/common.ts +55 -0
- package/src/domains/providers/runtimes/cloud/alcf.ts +171 -0
- package/src/domains/providers/runtimes/cloud/anthropic-max.ts +71 -0
- package/src/domains/providers/runtimes/cloud/anthropic.ts +43 -0
- package/src/domains/providers/runtimes/cloud/bedrock.ts +35 -0
- package/src/domains/providers/runtimes/cloud/deepseek.ts +50 -0
- package/src/domains/providers/runtimes/cloud/google.ts +41 -0
- package/src/domains/providers/runtimes/cloud/groq.ts +46 -0
- package/src/domains/providers/runtimes/cloud/mistral.ts +46 -0
- package/src/domains/providers/runtimes/cloud/openai-codex.ts +49 -0
- package/src/domains/providers/runtimes/cloud/openai.ts +46 -0
- package/src/domains/providers/runtimes/cloud/openrouter.ts +111 -0
- package/src/domains/providers/runtimes/common/lmstudio-http.ts +423 -0
- package/src/domains/providers/runtimes/common/local-synth.ts +164 -0
- package/src/domains/providers/runtimes/common/probe-helpers.ts +474 -0
- package/src/domains/providers/runtimes/local-native/lemonade-anthropic.ts +27 -0
- package/src/domains/providers/runtimes/local-native/lemonade-openai.ts +26 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-anthropic.ts +88 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-completion.ts +207 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-embed.ts +180 -0
- package/src/domains/providers/runtimes/local-native/llamacpp-rerank.ts +126 -0
- package/src/domains/providers/runtimes/local-native/llamacpp.ts +98 -0
- package/src/domains/providers/runtimes/local-native/lmstudio.ts +241 -0
- package/src/domains/providers/runtimes/local-native/ollama-native.ts +117 -0
- package/src/domains/providers/runtimes/local-native/sglang.ts +26 -0
- package/src/domains/providers/runtimes/local-native/vllm.ts +27 -0
- package/src/domains/providers/runtimes/protocol/anthropic-compat.ts +104 -0
- package/src/domains/providers/runtimes/protocol/anthropic-messages.ts +28 -0
- package/src/domains/providers/runtimes/protocol/bedrock.ts +26 -0
- package/src/domains/providers/runtimes/protocol/google.ts +27 -0
- package/src/domains/providers/runtimes/protocol/openai-compat.ts +145 -0
- package/src/domains/providers/support.ts +241 -0
- package/src/domains/providers/thinking-control-policy.ts +85 -0
- package/src/domains/providers/types/capability-flags.ts +114 -0
- package/src/domains/providers/types/cost-provenance.ts +7 -0
- package/src/domains/providers/types/inference.ts +41 -0
- package/src/domains/providers/types/knowledge-base.ts +156 -0
- package/src/domains/providers/types/local-model-quirks.ts +216 -0
- package/src/domains/providers/types/runtime-descriptor.ts +181 -0
- package/src/domains/providers/types/target-descriptor.ts +60 -0
- package/src/domains/resources/collision.ts +92 -0
- package/src/domains/resources/common-loader.ts +140 -0
- package/src/domains/resources/contract.ts +24 -0
- package/src/domains/resources/extension.ts +59 -0
- package/src/domains/resources/index.ts +74 -0
- package/src/domains/resources/loader.ts +85 -0
- package/src/domains/resources/manifest.ts +6 -0
- package/src/domains/resources/prompts/loader.ts +246 -0
- package/src/domains/resources/prompts/substitute.ts +1 -0
- package/src/domains/resources/skills/content-hash.ts +107 -0
- package/src/domains/resources/skills/evals.ts +175 -0
- package/src/domains/resources/skills/install.ts +427 -0
- package/src/domains/resources/skills/loader.ts +985 -0
- package/src/domains/resources/skills/marketplace.ts +301 -0
- package/src/domains/resources/skills/provenance-pin.ts +115 -0
- package/src/domains/safety/action-classifier.ts +270 -0
- package/src/domains/safety/approval-axis.ts +23 -0
- package/src/domains/safety/audit.ts +493 -0
- package/src/domains/safety/autonomy.ts +174 -0
- package/src/domains/safety/call-target.ts +59 -0
- package/src/domains/safety/contract.ts +65 -0
- package/src/domains/safety/damage-control.ts +44 -0
- package/src/domains/safety/default-path-policy.ts +117 -0
- package/src/domains/safety/extension.ts +383 -0
- package/src/domains/safety/finish-contract-registration.ts +128 -0
- package/src/domains/safety/finish-contract.ts +554 -0
- package/src/domains/safety/index.ts +44 -0
- package/src/domains/safety/loop-detector.ts +143 -0
- package/src/domains/safety/manifest.ts +6 -0
- package/src/domains/safety/path-policy.ts +164 -0
- package/src/domains/safety/policy-engine.ts +994 -0
- package/src/domains/safety/project-policy.ts +391 -0
- package/src/domains/safety/protected-artifacts-registration.ts +189 -0
- package/src/domains/safety/protected-artifacts.ts +993 -0
- package/src/domains/safety/rejection-feedback.ts +102 -0
- package/src/domains/safety/rigor.ts +72 -0
- package/src/domains/safety/rule-compiler.ts +48 -0
- package/src/domains/safety/rule-pack-loader.ts +92 -0
- package/src/domains/safety/run-effects.ts +197 -0
- package/src/domains/safety/scope.ts +61 -0
- package/src/domains/scheduling/budget.ts +35 -0
- package/src/domains/scheduling/cluster.ts +175 -0
- package/src/domains/scheduling/contract.ts +30 -0
- package/src/domains/scheduling/extension.ts +91 -0
- package/src/domains/scheduling/index.ts +12 -0
- package/src/domains/scheduling/manifest.ts +6 -0
- package/src/domains/session/archive-readers.ts +208 -0
- package/src/domains/session/checkpoint.ts +38 -0
- package/src/domains/session/compaction/auto.ts +89 -0
- package/src/domains/session/compaction/branch-summary.ts +187 -0
- package/src/domains/session/compaction/compact.ts +493 -0
- package/src/domains/session/compaction/cut-point.ts +172 -0
- package/src/domains/session/compaction/defaults.ts +34 -0
- package/src/domains/session/compaction/mask-observations.ts +265 -0
- package/src/domains/session/compaction/session-entries.ts +18 -0
- package/src/domains/session/compaction/tokens.ts +148 -0
- package/src/domains/session/context-accounting.ts +583 -0
- package/src/domains/session/context-ledger.ts +362 -0
- package/src/domains/session/contract.ts +159 -0
- package/src/domains/session/cwd-fallback.ts +65 -0
- package/src/domains/session/decision-board.ts +190 -0
- package/src/domains/session/entries.ts +572 -0
- package/src/domains/session/extension.ts +403 -0
- package/src/domains/session/history.ts +172 -0
- package/src/domains/session/index.ts +84 -0
- package/src/domains/session/manager.ts +128 -0
- package/src/domains/session/manifest.ts +6 -0
- package/src/domains/session/migrations/index.ts +27 -0
- package/src/domains/session/prompt-manifest.ts +173 -0
- package/src/domains/session/protected-artifact-journal.ts +241 -0
- package/src/domains/session/protected-artifacts.ts +90 -0
- package/src/domains/session/retry.ts +230 -0
- package/src/domains/session/session-artifacts.ts +107 -0
- package/src/domains/session/task-board.ts +569 -0
- package/src/domains/session/tree/active-path.ts +137 -0
- package/src/domains/session/tree/fork.ts +159 -0
- package/src/domains/session/tree/manager.ts +128 -0
- package/src/domains/session/tree/navigator.ts +177 -0
- package/src/domains/session/tree/preview.ts +259 -0
- package/src/domains/session/usage.ts +148 -0
- package/src/domains/session/workspace/git-probe.ts +167 -0
- package/src/domains/session/workspace/index.ts +4 -0
- package/src/domains/session/workspace/project-type.ts +217 -0
- package/src/domains/session/workspace/snapshot.ts +74 -0
- package/src/domains/share/archive.ts +684 -0
- package/src/domains/share/contract.ts +9 -0
- package/src/domains/share/extension.ts +26 -0
- package/src/domains/share/index.ts +28 -0
- package/src/domains/share/manifest.ts +6 -0
- package/src/domains/user-tasks/store.ts +297 -0
- package/src/engine/acp/adapter.ts +397 -0
- package/src/engine/acp/errors.ts +128 -0
- package/src/engine/acp/event-mapper.ts +154 -0
- package/src/engine/acp/server.ts +2238 -0
- package/src/engine/acp/tool-mediator.ts +686 -0
- package/src/engine/acp/transport.ts +775 -0
- package/src/engine/acp/types.ts +196 -0
- package/src/engine/agent.ts +29 -0
- package/src/engine/ai.ts +207 -0
- package/src/engine/alcf-oauth.ts +205 -0
- package/src/engine/antigravity/subprocess-runtime.ts +205 -0
- package/src/engine/api-registry.ts +223 -0
- package/src/engine/apis/degraded-inference.ts +95 -0
- package/src/engine/apis/index.ts +16 -0
- package/src/engine/apis/llamacpp-residency.ts +292 -0
- package/src/engine/apis/lmstudio-residency.ts +76 -0
- package/src/engine/apis/lmstudio.ts +243 -0
- package/src/engine/apis/ollama-native.ts +528 -0
- package/src/engine/apis/openai-completions.ts +795 -0
- package/src/engine/apis/output-budget.ts +99 -0
- package/src/engine/apis/residency-lock.ts +29 -0
- package/src/engine/apis/residency.ts +776 -0
- package/src/engine/apis/resident-models.ts +42 -0
- package/src/engine/apis/sampling-overrides.ts +38 -0
- package/src/engine/apis/types.ts +16 -0
- package/src/engine/claude/sdk-runtime.ts +685 -0
- package/src/engine/claude/session-id.ts +5 -0
- package/src/engine/claude/subprocess-runtime.ts +316 -0
- package/src/engine/claude/tool-safety.ts +400 -0
- package/src/engine/env-api-keys.ts +98 -0
- package/src/engine/external-subprocess.ts +23 -0
- package/src/engine/gemma-channel-filter.ts +223 -0
- package/src/engine/harmony-response.ts +165 -0
- package/src/engine/instrumented-tui.ts +192 -0
- package/src/engine/loop-guard.ts +1127 -0
- package/src/engine/messages.ts +14 -0
- package/src/engine/models.ts +42 -0
- package/src/engine/oauth.ts +196 -0
- package/src/engine/pi-mono-names.ts +13 -0
- package/src/engine/prompt-templates.ts +1 -0
- package/src/engine/provider-payload.ts +272 -0
- package/src/engine/select-list.ts +53 -0
- package/src/engine/session.ts +834 -0
- package/src/engine/strip-tokenizer-sentinels.ts +125 -0
- package/src/engine/truncate.ts +9 -0
- package/src/engine/tui.ts +111 -0
- package/src/engine/types.ts +63 -0
- package/src/engine/worker-events.ts +100 -0
- package/src/engine/worker-runtime-capabilities.ts +5 -0
- package/src/engine/worker-runtime.ts +1022 -0
- package/src/engine/worker-tools.ts +208 -0
- package/src/entry/boot-options.ts +50 -0
- package/src/entry/orchestrator.ts +2011 -0
- package/src/interactive/application-controller.ts +433 -0
- package/src/interactive/bus-notices.ts +265 -0
- package/src/interactive/chat-loop-messages.ts +626 -0
- package/src/interactive/chat-loop-policy.ts +18 -0
- package/src/interactive/chat-loop.ts +1090 -0
- package/src/interactive/chat-panel.ts +1820 -0
- package/src/interactive/chat-renderer.ts +1228 -0
- package/src/interactive/clio-editor.ts +161 -0
- package/src/interactive/command-fallbacks.ts +23 -0
- package/src/interactive/command-output.ts +85 -0
- package/src/interactive/context-activity.ts +203 -0
- package/src/interactive/context-meter.ts +223 -0
- package/src/interactive/context-overlay.ts +246 -0
- package/src/interactive/cost-overlay.ts +279 -0
- package/src/interactive/dispatch-board.ts +1319 -0
- package/src/interactive/dispatch-steering.ts +86 -0
- package/src/interactive/editor-bash.ts +46 -0
- package/src/interactive/editor-steer.ts +51 -0
- package/src/interactive/editor-submit.ts +507 -0
- package/src/interactive/export-html/ansi-to-html.ts +161 -0
- package/src/interactive/export-html/index.ts +51 -0
- package/src/interactive/export-html/template.ts +45 -0
- package/src/interactive/export-html/tool-renderer.ts +54 -0
- package/src/interactive/external-editor.ts +67 -0
- package/src/interactive/follow-up-queue-panel.ts +75 -0
- package/src/interactive/footer/dashboard.ts +538 -0
- package/src/interactive/footer/notifications.ts +275 -0
- package/src/interactive/footer/widgets.ts +1264 -0
- package/src/interactive/footer-panel.ts +187 -0
- package/src/interactive/format-time.ts +97 -0
- package/src/interactive/index.ts +11 -0
- package/src/interactive/interactive-application.ts +939 -0
- package/src/interactive/interactive-event-projection.ts +385 -0
- package/src/interactive/interactive-input-runtime.ts +307 -0
- package/src/interactive/interactive-presentation.ts +584 -0
- package/src/interactive/interactive-shell.ts +388 -0
- package/src/interactive/interactive-slash-runtime.ts +554 -0
- package/src/interactive/interactive-subscriptions.ts +111 -0
- package/src/interactive/interactive-tickers.ts +183 -0
- package/src/interactive/keybinding-manager.ts +496 -0
- package/src/interactive/layout.ts +57 -0
- package/src/interactive/leader-key.ts +143 -0
- package/src/interactive/loop-guard-interrupt.ts +101 -0
- package/src/interactive/memory-overlay.ts +280 -0
- package/src/interactive/overlay-ask-user-lifecycle.ts +110 -0
- package/src/interactive/overlay-auth-lifecycle.ts +308 -0
- package/src/interactive/overlay-frame.ts +502 -0
- package/src/interactive/overlay-general-openers.ts +274 -0
- package/src/interactive/overlay-key-routing.ts +216 -0
- package/src/interactive/overlay-lifecycle.ts +426 -0
- package/src/interactive/overlay-model-selectors.ts +127 -0
- package/src/interactive/overlay-permission-lifecycle.ts +345 -0
- package/src/interactive/overlay-resource-openers.ts +112 -0
- package/src/interactive/overlay-session-lifecycle.ts +327 -0
- package/src/interactive/overlay-transitions.ts +57 -0
- package/src/interactive/overlays/agents.ts +69 -0
- package/src/interactive/overlays/ask-user.ts +921 -0
- package/src/interactive/overlays/auth-dialog.ts +221 -0
- package/src/interactive/overlays/context-reset.ts +108 -0
- package/src/interactive/overlays/cwd-fallback.ts +141 -0
- package/src/interactive/overlays/decisions.ts +300 -0
- package/src/interactive/overlays/extensions.ts +54 -0
- package/src/interactive/overlays/help-reference.ts +145 -0
- package/src/interactive/overlays/interop.ts +139 -0
- package/src/interactive/overlays/keybinding-detail.ts +90 -0
- package/src/interactive/overlays/list-overlay.ts +606 -0
- package/src/interactive/overlays/message-picker.ts +155 -0
- package/src/interactive/overlays/model-selector.ts +1109 -0
- package/src/interactive/overlays/prompts.ts +72 -0
- package/src/interactive/overlays/session-selector-search.ts +31 -0
- package/src/interactive/overlays/session-selector.ts +284 -0
- package/src/interactive/overlays/settings.ts +3451 -0
- package/src/interactive/overlays/skills-hub.ts +237 -0
- package/src/interactive/overlays/tree-selector.ts +422 -0
- package/src/interactive/permission-overlay.ts +170 -0
- package/src/interactive/render-trace.ts +534 -0
- package/src/interactive/renderers/branch-summary.ts +86 -0
- package/src/interactive/renderers/code-ink.ts +420 -0
- package/src/interactive/renderers/compaction-summary.ts +112 -0
- package/src/interactive/renderers/diff.ts +137 -0
- package/src/interactive/renderers/mermaid.ts +53 -0
- package/src/interactive/renderers/notice.ts +28 -0
- package/src/interactive/renderers/retry-status.ts +31 -0
- package/src/interactive/renderers/structured.ts +89 -0
- package/src/interactive/renderers/tool-execution.ts +1357 -0
- package/src/interactive/renderers/worker-entry.ts +280 -0
- package/src/interactive/session-last-turn.ts +186 -0
- package/src/interactive/session-switch-settlement.ts +10 -0
- package/src/interactive/session-transcript.ts +105 -0
- package/src/interactive/session-usage-reseed.ts +74 -0
- package/src/interactive/slash-autocomplete.ts +256 -0
- package/src/interactive/slash-commands.ts +1407 -0
- package/src/interactive/slash-spec.ts +424 -0
- package/src/interactive/status/controller.ts +260 -0
- package/src/interactive/status/index.ts +23 -0
- package/src/interactive/status/state-machine.ts +530 -0
- package/src/interactive/status/summary.ts +170 -0
- package/src/interactive/status/types.ts +121 -0
- package/src/interactive/status/verbs.ts +163 -0
- package/src/interactive/status/watchdog.ts +24 -0
- package/src/interactive/stdout-backpressure.ts +99 -0
- package/src/interactive/stream-pacer.ts +530 -0
- package/src/interactive/stream-pacing-policy.ts +66 -0
- package/src/interactive/tasks-overlay.ts +540 -0
- package/src/interactive/terminal-lease.ts +485 -0
- package/src/interactive/theme/components.ts +55 -0
- package/src/interactive/theme/glyphs.ts +70 -0
- package/src/interactive/theme/index.ts +15 -0
- package/src/interactive/theme/labels.ts +88 -0
- package/src/interactive/theme/rules.ts +138 -0
- package/src/interactive/theme/segments.ts +88 -0
- package/src/interactive/theme/tokens.ts +121 -0
- package/src/interactive/thinking-level-policy.ts +6 -0
- package/src/interactive/tool-prose-loop.ts +122 -0
- package/src/interactive/tool-prose-registration.ts +48 -0
- package/src/interactive/turn-context.ts +855 -0
- package/src/interactive/turn-middleware.ts +283 -0
- package/src/interactive/turn-persistence.ts +458 -0
- package/src/interactive/turn-queues.ts +181 -0
- package/src/interactive/turn-recovery.ts +323 -0
- package/src/interactive/turn-runtime.ts +869 -0
- package/src/interactive/turn-state.ts +133 -0
- package/src/interactive/view/artifacts.ts +1452 -0
- package/src/interactive/view/view-overlay.ts +735 -0
- package/src/interactive/welcome-dashboard.ts +537 -0
- package/src/interactive/worker-receipts.ts +143 -0
- package/src/interactive/worker-replay.ts +111 -0
- package/src/interactive/worker-share.ts +100 -0
- package/src/interactive/worker-stream.ts +446 -0
- package/src/interactive/workspace-facts.ts +141 -0
- package/src/tools/agent-tools.ts +402 -0
- package/src/tools/artifact.ts +103 -0
- package/src/tools/ask-user.ts +666 -0
- package/src/tools/bash.ts +204 -0
- package/src/tools/bootstrap.ts +77 -0
- package/src/tools/builtin-tool-catalog.ts +265 -0
- package/src/tools/codewiki/code-nav-surface.ts +29 -0
- package/src/tools/codewiki/code-nav.ts +549 -0
- package/src/tools/codewiki/shared.ts +118 -0
- package/src/tools/compete-worktrees.ts +898 -0
- package/src/tools/context/docs-engine.ts +630 -0
- package/src/tools/context/index.ts +514 -0
- package/src/tools/context/surface.ts +19 -0
- package/src/tools/core-bootstrap.ts +168 -0
- package/src/tools/credential-present.ts +151 -0
- package/src/tools/dispatch-admission.ts +533 -0
- package/src/tools/dispatch-arguments.ts +228 -0
- package/src/tools/dispatch-background.ts +54 -0
- package/src/tools/dispatch-event-text.ts +6 -0
- package/src/tools/dispatch-plan.ts +746 -0
- package/src/tools/dispatch-run-events.ts +238 -0
- package/src/tools/dispatch-runner.ts +2370 -0
- package/src/tools/dispatch-scout-admission.ts +295 -0
- package/src/tools/dispatch-scout.ts +461 -0
- package/src/tools/dispatch-types.ts +77 -0
- package/src/tools/dispatch.ts +244 -0
- package/src/tools/edit-diff.ts +534 -0
- package/src/tools/edit.ts +128 -0
- package/src/tools/executables.ts +22 -0
- package/src/tools/file-mutation-queue.ts +35 -0
- package/src/tools/find.ts +294 -0
- package/src/tools/grep.ts +495 -0
- package/src/tools/ignore-policy.ts +169 -0
- package/src/tools/lazy-tool.ts +60 -0
- package/src/tools/ledger.ts +206 -0
- package/src/tools/ls.ts +110 -0
- package/src/tools/monitor-surface.ts +36 -0
- package/src/tools/monitor.ts +767 -0
- package/src/tools/network-policy.ts +29 -0
- package/src/tools/observation.ts +421 -0
- package/src/tools/observers.ts +99 -0
- package/src/tools/path-utils.ts +79 -0
- package/src/tools/policy.ts +154 -0
- package/src/tools/profiles.ts +108 -0
- package/src/tools/read.ts +173 -0
- package/src/tools/registry.ts +1169 -0
- package/src/tools/result-shaping.ts +204 -0
- package/src/tools/safe-exec.ts +128 -0
- package/src/tools/spawn-hygiene.ts +182 -0
- package/src/tools/steer-surface.ts +17 -0
- package/src/tools/steer.ts +77 -0
- package/src/tools/tasks.ts +265 -0
- package/src/tools/truncate-utf8.ts +17 -0
- package/src/tools/truncate.ts +43 -0
- package/src/tools/verify/frontend.ts +687 -0
- package/src/tools/verify/index.ts +31 -0
- package/src/tools/verify/scripts.ts +108 -0
- package/src/tools/verify/surface.ts +46 -0
- package/src/tools/web-fetch-surface.ts +23 -0
- package/src/tools/web-fetch.ts +759 -0
- package/src/tools/worker-evidence.ts +215 -0
- package/src/tools/write.ts +57 -0
- package/src/utils/exif-orientation.ts +192 -0
- package/src/utils/git.ts +24 -0
- package/src/utils/image-resize.ts +148 -0
- package/src/utils/photon.ts +103 -0
- package/src/worker/control-lane.ts +22 -0
- package/src/worker/entry.ts +294 -0
- package/src/worker/event-projection.ts +56 -0
- package/src/worker/heartbeat.ts +24 -0
- package/src/worker/ledger-mirror.ts +95 -0
- package/src/worker/ndjson.ts +40 -0
- package/src/worker/protocol.ts +529 -0
- package/src/worker/resource-facts.ts +79 -0
- package/src/worker/runtime-registry.ts +12 -0
- package/src/worker/spec-contract.ts +675 -0
- package/src/worker/stdin-demux.ts +316 -0
- package/dist/acp-UMLFVA3F.js +0 -92
- package/dist/chunk-262G75JS.js +0 -35
- package/dist/chunk-6CWDTGUC.js +0 -20
- package/dist/chunk-BYEU76JP.js +0 -899
- package/dist/chunk-GNGDQYDU.js +0 -34688
- package/dist/chunk-GOTUR54M.js +0 -9
- package/dist/chunk-NI4DEJMC.js +0 -88
- package/dist/chunk-TPOCL34A.js +0 -2876
- package/dist/chunk-UU3R62TT.js +0 -128
- package/dist/clio-KIQ5SNDS.js +0 -53
- package/dist/configure-G4E3A2PG.js +0 -27
- package/dist/doctor-M5HJJZOL.js +0 -61
- package/dist/domains/agents/builtins/architect.md +0 -33
- package/dist/domains/agents/builtins/coder.md +0 -31
- package/dist/domains/agents/builtins/context-bootstrap.md +0 -38
- package/dist/domains/agents/builtins/debugger.md +0 -30
- package/dist/domains/agents/builtins/documenter.md +0 -31
- package/dist/domains/agents/builtins/git-master.md +0 -30
- package/dist/domains/agents/builtins/provenance.md +0 -30
- package/dist/domains/agents/builtins/researcher.md +0 -71
- package/dist/domains/agents/builtins/scout.md +0 -42
- package/dist/domains/agents/builtins/tester.md +0 -31
- package/dist/domains/agents/builtins/verifier.md +0 -30
- package/dist/domains/agents/builtins/wiki-writer.md +0 -41
- package/dist/fleet-preflight-CLIAX7YR.js +0 -21
- package/dist/preload-KZVHET2B.js +0 -11
- package/dist/version-ROZ6CZKH.js +0 -16
- package/docs/html/agents_blueprint.html +0 -936
- package/docs/html/alcf_blueprint.html +0 -324
- package/docs/html/architecture_blueprint.html +0 -850
- package/docs/html/commands_blueprint.html +0 -794
- package/docs/html/config_knobs_audit_blueprint.html +0 -178
- package/docs/html/configuration_blueprint.html +0 -1080
- package/docs/html/context_blueprint.html +0 -603
- package/docs/html/documentation_blueprint.html +0 -832
- package/docs/html/environment_blueprint.html +0 -404
- package/docs/html/eval_blueprint.html +0 -743
- package/docs/html/evals_internal_blueprint.html +0 -190
- package/docs/html/evolution_blueprint.html +0 -674
- package/docs/html/extensions_blueprint.html +0 -2065
- package/docs/html/fleet_dispatch_blueprint.html +0 -286
- package/docs/html/index.html +0 -919
- package/docs/html/lifecycle_blueprint.html +0 -723
- package/docs/html/memory_blueprint.html +0 -699
- package/docs/html/middleware_blueprint.html +0 -664
- package/docs/html/models_blueprint.html +0 -2366
- package/docs/html/observability_blueprint.html +0 -683
- package/docs/html/provider_adapter_blueprint.html +0 -245
- package/docs/html/safety_blueprint.html +0 -1386
- package/docs/html/shared.css +0 -571
- package/docs/html/shared.js +0 -143
- package/docs/html/skills_blueprint.html +0 -671
- package/docs/html/soak_blueprint.html +0 -182
- package/docs/html/tool_usage_blueprint.html +0 -350
- package/docs/html/tools_blueprint.html +0 -2249
- package/docs/html/trace_blueprint.html +0 -235
- package/docs/html/tui_design_blueprint.html +0 -314
- package/docs/html/validation_blueprint.html +0 -961
- package/docs/html/worker_dispatch_blueprint.html +0 -231
- package/skills/git/commit-crafting/SKILL.md +0 -79
- package/skills/git/commit-crafting/evals.md +0 -92
- package/skills/git/create-pr/SKILL.md +0 -116
- package/skills/git/create-pr/evals.md +0 -114
- package/skills/git/investigate-issue/SKILL.md +0 -139
- package/skills/git/investigate-issue/evals.md +0 -94
- package/skills/git/review-changes/SKILL.md +0 -103
- package/skills/git/review-changes/evals.md +0 -85
|
@@ -1,22 +1,24 @@
|
|
|
1
|
+
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
1
2
|
import {
|
|
2
3
|
renderCodewikiDigest
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5WIGXA4T.js";
|
|
4
5
|
import {
|
|
5
6
|
loadMemoryRecordsSync
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-J5HN4RYU.js";
|
|
8
|
+
import {
|
|
9
|
+
sha256
|
|
10
|
+
} from "./chunk-6EJV5X2W.js";
|
|
7
11
|
import {
|
|
8
12
|
WIKI_INDEX,
|
|
9
13
|
WIKI_PLAN_FILE,
|
|
10
14
|
WIKI_QUICKSTART,
|
|
11
15
|
changedPathsSince,
|
|
12
|
-
compileGlobRegex,
|
|
13
16
|
computeWikiContentHash,
|
|
14
17
|
computeWikiContentHashOfDir,
|
|
15
18
|
currentWikiGitHead,
|
|
16
19
|
isGeneratedWikiFile,
|
|
17
20
|
listWikiPages,
|
|
18
21
|
listWikiPagesInDir,
|
|
19
|
-
normalizeGlobInput,
|
|
20
22
|
readWikiMeta,
|
|
21
23
|
readWikiPage,
|
|
22
24
|
readWikiPlanFile,
|
|
@@ -31,53 +33,66 @@ import {
|
|
|
31
33
|
wikiStaleness,
|
|
32
34
|
writeWikiMeta,
|
|
33
35
|
writeWikiPlanFile
|
|
34
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-X4RCMKVQ.js";
|
|
35
37
|
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
buildCodewikiCandidate,
|
|
39
|
+
coordinateCodewikiExclusive,
|
|
40
|
+
coordinateCodewikiWrite,
|
|
41
|
+
drainCodewikiWrites,
|
|
40
42
|
readClioState,
|
|
41
43
|
statePath,
|
|
42
44
|
writeClioState
|
|
43
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-MVVUPGPW.js";
|
|
46
|
+
import {
|
|
47
|
+
compileGlobRegex,
|
|
48
|
+
normalizeGlobInput
|
|
49
|
+
} from "./chunk-VG7TBQIY.js";
|
|
50
|
+
import {
|
|
51
|
+
detectProjectType
|
|
52
|
+
} from "./chunk-YHZX5GEU.js";
|
|
53
|
+
import {
|
|
54
|
+
computeFingerprintCached,
|
|
55
|
+
isStale
|
|
56
|
+
} from "./chunk-VJWL6YS5.js";
|
|
44
57
|
import {
|
|
45
|
-
buildCodewiki,
|
|
46
|
-
codewikiNeedsBackfill,
|
|
47
58
|
codewikiPath,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
enumerateWorkspaceFiles,
|
|
51
|
-
parseCodewikiRaw,
|
|
52
|
-
readCodewiki,
|
|
53
|
-
readCodewikiAsync,
|
|
54
|
-
syncCodewiki,
|
|
55
|
-
updateCodewikiPaths,
|
|
56
|
-
writeCodewiki
|
|
57
|
-
} from "./chunk-TPOCL34A.js";
|
|
59
|
+
readCodewiki
|
|
60
|
+
} from "./chunk-LBMZMYH2.js";
|
|
58
61
|
import {
|
|
59
|
-
|
|
60
|
-
} from "./chunk-
|
|
62
|
+
enumerateWorkspaceFiles
|
|
63
|
+
} from "./chunk-EKMEHE4H.js";
|
|
61
64
|
import {
|
|
62
65
|
ceilChars
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-LZSJBIVT.js";
|
|
64
67
|
import {
|
|
65
|
-
|
|
66
|
-
} from "./chunk-
|
|
68
|
+
INTEROP_AGENT_KINDS
|
|
69
|
+
} from "./chunk-IHXBNWMM.js";
|
|
70
|
+
import {
|
|
71
|
+
require_dist
|
|
72
|
+
} from "./chunk-APJ265NV.js";
|
|
67
73
|
import {
|
|
68
74
|
clioDataDir,
|
|
69
75
|
resolveClioDirs
|
|
70
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-BNAZZHFG.js";
|
|
77
|
+
import {
|
|
78
|
+
BusChannels
|
|
79
|
+
} from "./chunk-OQ33BKR3.js";
|
|
80
|
+
import {
|
|
81
|
+
classifyProjectPreload
|
|
82
|
+
} from "./chunk-JVCV3ICN.js";
|
|
71
83
|
import {
|
|
72
84
|
resolvePackageRoot
|
|
73
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-IWHMRKLL.js";
|
|
86
|
+
import {
|
|
87
|
+
__toESM,
|
|
88
|
+
init_esm_shims
|
|
89
|
+
} from "./chunk-3R73A4XB.js";
|
|
74
90
|
|
|
75
|
-
// src/domains/context/
|
|
76
|
-
|
|
77
|
-
import { existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
|
|
78
|
-
import { isAbsolute, relative as relative3 } from "node:path";
|
|
91
|
+
// src/domains/context/index.ts
|
|
92
|
+
init_esm_shims();
|
|
79
93
|
|
|
80
94
|
// src/domains/context/adoption.ts
|
|
95
|
+
init_esm_shims();
|
|
81
96
|
import { createHash } from "node:crypto";
|
|
82
97
|
import { existsSync, lstatSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
83
98
|
import { homedir } from "node:os";
|
|
@@ -125,6 +140,13 @@ var GENERATED_OR_SECRET_DIRS = /* @__PURE__ */ new Set([
|
|
|
125
140
|
"state",
|
|
126
141
|
"projects"
|
|
127
142
|
]);
|
|
143
|
+
var NESTED_INSTRUCTION_PROVIDERS = new Map(
|
|
144
|
+
INTEROP_AGENT_KINDS.flatMap((kind) => {
|
|
145
|
+
const provider = kind.adoptionProvider;
|
|
146
|
+
if (provider === void 0) return [];
|
|
147
|
+
return kind.instructionFiles.filter((file) => !file.includes("/")).map((file) => [file, provider]);
|
|
148
|
+
})
|
|
149
|
+
);
|
|
128
150
|
var UNSAFE_FILE_NAME_RE = /(^\.env(?:\.|$)|secret|credential|token|password|history|cache|session|\.log$|state\.json$)/i;
|
|
129
151
|
var RULE_KEYWORDS = /\b(always|never|must|should|prefer|avoid|do not|don't|use|run|keep|write|allow|allows|deny|denies|enable|enables|define|defines)\b/i;
|
|
130
152
|
var SECRET_LINE_PATTERNS = [
|
|
@@ -136,7 +158,7 @@ var SECRET_LINE_PATTERNS = [
|
|
|
136
158
|
/\bxox[baprs]-[A-Za-z0-9-]{20,}\b/,
|
|
137
159
|
/\bAIza[0-9A-Za-z_-]{20,}\b/
|
|
138
160
|
];
|
|
139
|
-
function
|
|
161
|
+
function sha2562(text) {
|
|
140
162
|
return createHash("sha256").update(text).digest("hex");
|
|
141
163
|
}
|
|
142
164
|
function normalizeText(text) {
|
|
@@ -213,8 +235,8 @@ function discoverCandidateSpecs(cwd, home, includeGlobal) {
|
|
|
213
235
|
const specs = [];
|
|
214
236
|
const seen = /* @__PURE__ */ new Set();
|
|
215
237
|
let order = 0;
|
|
216
|
-
const add = (
|
|
217
|
-
const abs = resolve(
|
|
238
|
+
const add = (path2, scope, provider, kind) => {
|
|
239
|
+
const abs = resolve(path2);
|
|
218
240
|
if (seen.has(abs)) return;
|
|
219
241
|
seen.add(abs);
|
|
220
242
|
const scopedDir = scope === "project" && kind === "instructions" ? relative(cwd, dirname(abs)) : "";
|
|
@@ -234,31 +256,26 @@ function discoverCandidateSpecs(cwd, home, includeGlobal) {
|
|
|
234
256
|
const addProjectDir = (relPath, provider, kind, maxDepth, accept) => {
|
|
235
257
|
for (const filePath of collectFiles(join(cwd, relPath), maxDepth, accept)) add(filePath, "project", provider, kind);
|
|
236
258
|
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
addProject(join(".codex", "AGENTS.md"), "codex", "instructions");
|
|
242
|
-
addProject("GEMINI.md", "gemini", "instructions");
|
|
243
|
-
addProject(join(".gemini", "GEMINI.md"), "gemini", "instructions");
|
|
244
|
-
addProject(join(".github", "copilot-instructions.md"), "copilot", "instructions");
|
|
259
|
+
for (const kind of INTEROP_AGENT_KINDS) {
|
|
260
|
+
if (kind.adoptionProvider === void 0) continue;
|
|
261
|
+
for (const file of kind.instructionFiles) addProject(file, kind.adoptionProvider, "instructions");
|
|
262
|
+
}
|
|
245
263
|
const visibleWorkspaceFiles = enumerateWorkspaceFiles(cwd);
|
|
246
264
|
for (const relPath of visibleWorkspaceFiles) {
|
|
247
265
|
const parts = relPath.split("/");
|
|
248
266
|
if (parts.length - 1 > 6) continue;
|
|
249
267
|
const name2 = parts.at(-1);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
add(filePath, "project", provider, "instructions");
|
|
268
|
+
const provider = name2 === void 0 ? void 0 : NESTED_INSTRUCTION_PROVIDERS.get(name2);
|
|
269
|
+
if (provider === void 0) continue;
|
|
270
|
+
add(join(cwd, relPath), "project", provider, "instructions");
|
|
254
271
|
}
|
|
255
272
|
addProject(join(".claude", "settings.json"), "claude-code", "settings");
|
|
256
273
|
addProjectDir(join(".claude", "commands"), "claude-code", "command", 3, markdownLike);
|
|
257
274
|
addProjectDir(join(".claude", "agents"), "claude-code", "agent", 2, markdownLike);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
275
|
+
for (const kind of INTEROP_AGENT_KINDS) {
|
|
276
|
+
if (kind.adoptionProvider === void 0 || kind.projectSkillRoot === void 0) continue;
|
|
277
|
+
addProjectDir(kind.projectSkillRoot, kind.adoptionProvider, "skill", 4, markdownLike);
|
|
278
|
+
}
|
|
262
279
|
addProject(join(".gemini", "settings.json"), "gemini", "settings");
|
|
263
280
|
addProject(join(".gemini", "config.json"), "gemini", "settings");
|
|
264
281
|
addProjectDir(
|
|
@@ -276,7 +293,6 @@ function discoverCandidateSpecs(cwd, home, includeGlobal) {
|
|
|
276
293
|
(filePath) => markdownLike(filePath) || jsonLike(filePath)
|
|
277
294
|
);
|
|
278
295
|
addProjectDir(join(".cursor", "rules"), "cursor", "rule", 0, markdownLike);
|
|
279
|
-
addProjectDir(join(".github", "skills"), "copilot", "skill", 4, markdownLike);
|
|
280
296
|
if (includeGlobal) add(join(home, ".codex", "AGENTS.md"), "global", "codex", "instructions");
|
|
281
297
|
return specs.filter((spec) => existsSync(spec.path));
|
|
282
298
|
}
|
|
@@ -492,7 +508,7 @@ function rejectedCandidate(spec, displayPath2, reason, evidence) {
|
|
|
492
508
|
kind: spec.kind,
|
|
493
509
|
...spec.directoryScope ? { directoryScope: spec.directoryScope } : {},
|
|
494
510
|
reason,
|
|
495
|
-
fingerprintSha256:
|
|
511
|
+
fingerprintSha256: sha2562(`rejected\0${reason}\0${evidence}`)
|
|
496
512
|
};
|
|
497
513
|
}
|
|
498
514
|
function statEvidence(stat) {
|
|
@@ -541,7 +557,7 @@ function readCandidate(spec, cwd, home) {
|
|
|
541
557
|
kindLabel: KIND_LABELS[spec.kind],
|
|
542
558
|
...spec.directoryScope ? { directoryScope: spec.directoryScope } : {},
|
|
543
559
|
content,
|
|
544
|
-
contentSha256:
|
|
560
|
+
contentSha256: sha2562(content),
|
|
545
561
|
byteLength: Buffer.byteLength(content, "utf8"),
|
|
546
562
|
itemCount: rules.length,
|
|
547
563
|
order: spec.order
|
|
@@ -605,7 +621,7 @@ function scanAgentConfigs(options) {
|
|
|
605
621
|
kind: result.kind,
|
|
606
622
|
...result.directoryScope ? { directoryScope: result.directoryScope } : {},
|
|
607
623
|
reason: "aggregate source byte budget exceeded",
|
|
608
|
-
fingerprintSha256:
|
|
624
|
+
fingerprintSha256: sha2562(`rejected\0aggregate source byte budget exceeded\0${result.contentSha256}`)
|
|
609
625
|
});
|
|
610
626
|
continue;
|
|
611
627
|
}
|
|
@@ -631,8 +647,8 @@ function scanAgentConfigs(options) {
|
|
|
631
647
|
};
|
|
632
648
|
}
|
|
633
649
|
function renderSourceList(paths) {
|
|
634
|
-
if (paths.length <= 3) return paths.map((
|
|
635
|
-
return `${paths.slice(0, 3).map((
|
|
650
|
+
if (paths.length <= 3) return paths.map((path2) => `\`${path2}\``).join(", ");
|
|
651
|
+
return `${paths.slice(0, 3).map((path2) => `\`${path2}\``).join(", ")} +${paths.length - 3} more`;
|
|
636
652
|
}
|
|
637
653
|
function quoteShort(text) {
|
|
638
654
|
const cleaned = text.replace(/\s+/g, " ").trim();
|
|
@@ -736,13 +752,15 @@ function adoptionSourcesChanged(snapshots, options = {}) {
|
|
|
736
752
|
}
|
|
737
753
|
|
|
738
754
|
// src/domains/context/bootstrap.ts
|
|
755
|
+
init_esm_shims();
|
|
739
756
|
import { execFileSync } from "node:child_process";
|
|
740
757
|
import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync4, writeFileSync } from "node:fs";
|
|
741
|
-
import { dirname as
|
|
758
|
+
import { dirname as dirname3, join as join4, parse } from "node:path";
|
|
742
759
|
|
|
743
760
|
// src/domains/context/clio-md.ts
|
|
744
|
-
|
|
745
|
-
import {
|
|
761
|
+
init_esm_shims();
|
|
762
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
|
|
763
|
+
import { basename as basename2, dirname as dirname2, join as join2, resolve as resolve2 } from "node:path";
|
|
746
764
|
var FOOTER_RE = /<!--\s*clio:fingerprint v1\s*\n([\s\S]*?)\n\s*-->/;
|
|
747
765
|
var H1_RE = /^#\s+(.+?)\s*$/gm;
|
|
748
766
|
var H2_RE = /^##\s+(.+?)\s*$/gm;
|
|
@@ -954,7 +972,10 @@ function serializeClioMd(input) {
|
|
|
954
972
|
function renderProjectTypeFragment(projectType) {
|
|
955
973
|
return `<project-type>${projectType}</project-type>`;
|
|
956
974
|
}
|
|
957
|
-
function
|
|
975
|
+
function escapeXmlAttribute(value) {
|
|
976
|
+
return value.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">");
|
|
977
|
+
}
|
|
978
|
+
function renderProjectContextFragment(parsed, sourcePath) {
|
|
958
979
|
const sections = [`# ${parsed.projectName}`, parsed.identity];
|
|
959
980
|
if (parsed.conventions.length > 0) {
|
|
960
981
|
sections.push("## Conventions", ...parsed.conventions.map((item) => `- ${item}`));
|
|
@@ -968,29 +989,88 @@ function renderProjectContextFragment(parsed) {
|
|
|
968
989
|
if (parsed.importedAgentContext) {
|
|
969
990
|
sections.push("## Imported agent context", parsed.importedAgentContext);
|
|
970
991
|
}
|
|
971
|
-
|
|
992
|
+
const source = sourcePath ? ` path="${escapeXmlAttribute(sourcePath)}"` : "";
|
|
993
|
+
return `<project-context${source}>
|
|
972
994
|
${sections.join("\n\n")}
|
|
973
995
|
</project-context>`;
|
|
974
996
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
997
|
+
var PROJECT_CONTEXT_CANDIDATES = ["CLIO-CODER.override.md", "CLIO-CODER.md"];
|
|
998
|
+
function selectedClioMdPath(directory) {
|
|
999
|
+
for (const filename of PROJECT_CONTEXT_CANDIDATES) {
|
|
1000
|
+
const filePath = join2(directory, filename);
|
|
1001
|
+
if (!existsSync2(filePath)) continue;
|
|
1002
|
+
try {
|
|
1003
|
+
if (statSync2(filePath).isFile()) return filePath;
|
|
1004
|
+
} catch {
|
|
1005
|
+
return filePath;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
return null;
|
|
1009
|
+
}
|
|
1010
|
+
function readClioMdPath(filePath) {
|
|
978
1011
|
let content;
|
|
979
1012
|
try {
|
|
980
1013
|
content = readFileSync2(filePath, "utf8");
|
|
981
1014
|
} catch (err) {
|
|
982
|
-
|
|
983
|
-
return { ok: false, error: message };
|
|
1015
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
984
1016
|
}
|
|
985
1017
|
const parsed = parseClioMd(content);
|
|
986
1018
|
if (!parsed.ok) return { ok: false, error: parsed.errors.join("; ") };
|
|
987
1019
|
return { ok: true, value: parsed.value };
|
|
988
1020
|
}
|
|
1021
|
+
function mergeClioMdFiles(files) {
|
|
1022
|
+
const nearest = files.at(-1)?.value;
|
|
1023
|
+
if (!nearest) return null;
|
|
1024
|
+
return {
|
|
1025
|
+
projectName: nearest.projectName,
|
|
1026
|
+
identity: files.map((file) => file.value.identity).join("\n\n"),
|
|
1027
|
+
conventions: files.flatMap((file) => file.value.conventions),
|
|
1028
|
+
invariants: files.flatMap((file) => file.value.invariants),
|
|
1029
|
+
sections: files.flatMap((file) => file.value.sections),
|
|
1030
|
+
importedAgentContext: files.map((file) => file.value.importedAgentContext).filter((value) => value !== null).join("\n\n") || null,
|
|
1031
|
+
fingerprint: nearest.fingerprint,
|
|
1032
|
+
firstInit: nearest.firstInit,
|
|
1033
|
+
warnings: files.flatMap((file) => file.value.warnings)
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
function loadProjectClioMd(cwd) {
|
|
1037
|
+
const directories = [];
|
|
1038
|
+
let directory = resolve2(cwd);
|
|
1039
|
+
while (true) {
|
|
1040
|
+
directories.unshift(directory);
|
|
1041
|
+
const parent = dirname2(directory);
|
|
1042
|
+
if (parent === directory) break;
|
|
1043
|
+
directory = parent;
|
|
1044
|
+
}
|
|
1045
|
+
const selectedPaths = [];
|
|
1046
|
+
for (const current of directories) {
|
|
1047
|
+
const selected = selectedClioMdPath(current);
|
|
1048
|
+
if (!selected) continue;
|
|
1049
|
+
if (basename2(selected) === "CLIO-CODER.override.md") {
|
|
1050
|
+
selectedPaths.length = 0;
|
|
1051
|
+
}
|
|
1052
|
+
selectedPaths.push(selected);
|
|
1053
|
+
}
|
|
1054
|
+
const files = [];
|
|
1055
|
+
const errors = [];
|
|
1056
|
+
for (const filePath of selectedPaths) {
|
|
1057
|
+
const read = readClioMdPath(filePath);
|
|
1058
|
+
if (read.ok) files.push({ path: filePath, value: read.value });
|
|
1059
|
+
else errors.push({ path: filePath, error: read.error });
|
|
1060
|
+
}
|
|
1061
|
+
return { files, errors, value: mergeClioMdFiles(files) };
|
|
1062
|
+
}
|
|
1063
|
+
function tryReadClioMd(cwd) {
|
|
1064
|
+
const filePath = join2(cwd, "CLIO-CODER.md");
|
|
1065
|
+
if (!existsSync2(filePath)) return null;
|
|
1066
|
+
return readClioMdPath(filePath);
|
|
1067
|
+
}
|
|
989
1068
|
|
|
990
1069
|
// src/domains/context/project-metadata.ts
|
|
1070
|
+
init_esm_shims();
|
|
1071
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
991
1072
|
import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync3 } from "node:fs";
|
|
992
1073
|
import { join as join3 } from "node:path";
|
|
993
|
-
import { parse as parseYaml } from "yaml";
|
|
994
1074
|
var MAX_DESCRIPTION_CHARS = 400;
|
|
995
1075
|
var MAX_NAME_CHARS = 80;
|
|
996
1076
|
function readText(cwd, relative6) {
|
|
@@ -1042,6 +1122,14 @@ function tomlTableValue(raw, table, key) {
|
|
|
1042
1122
|
}
|
|
1043
1123
|
return null;
|
|
1044
1124
|
}
|
|
1125
|
+
function hasTomlTable(raw, table) {
|
|
1126
|
+
const header = `[${table}]`;
|
|
1127
|
+
return raw.split(/\r?\n/u).some((line) => {
|
|
1128
|
+
const trimmed = line.trim();
|
|
1129
|
+
if (!trimmed.startsWith(header)) return false;
|
|
1130
|
+
return /^\s*(?:#.*)?$/u.test(trimmed.slice(header.length));
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1045
1133
|
function keyEqualsValue(raw, key) {
|
|
1046
1134
|
const match = new RegExp(`^[ \\t]*${key}[ \\t]*(?:\\+?=)[ \\t]*(.+)$`, "mu").exec(raw);
|
|
1047
1135
|
const value = match?.[1]?.trim();
|
|
@@ -1073,7 +1161,7 @@ function yamlRecord(cwd, relative6) {
|
|
|
1073
1161
|
const raw = readText(cwd, relative6);
|
|
1074
1162
|
if (raw === null) return null;
|
|
1075
1163
|
try {
|
|
1076
|
-
const parsed =
|
|
1164
|
+
const parsed = (0, import_yaml.parse)(raw);
|
|
1077
1165
|
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : null;
|
|
1078
1166
|
} catch {
|
|
1079
1167
|
return null;
|
|
@@ -1329,17 +1417,17 @@ function readProjectMetadata(cwd) {
|
|
|
1329
1417
|
}
|
|
1330
1418
|
|
|
1331
1419
|
// src/domains/context/prompt-context.ts
|
|
1420
|
+
init_esm_shims();
|
|
1332
1421
|
function renderPromptContext(cwd) {
|
|
1333
1422
|
const projectType = detectProjectType(cwd);
|
|
1334
1423
|
const pieces = [renderProjectTypeFragment(projectType)];
|
|
1335
1424
|
const warnings = [];
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1425
|
+
const loadedClioMd = loadProjectClioMd(cwd);
|
|
1426
|
+
const clioMd = loadedClioMd.value;
|
|
1427
|
+
for (const file of loadedClioMd.files) pieces.push(renderProjectContextFragment(file.value, file.path));
|
|
1428
|
+
for (const issue of loadedClioMd.errors) {
|
|
1429
|
+
warnings.push(`clio: malformed ${issue.path} ignored: ${issue.error}`);
|
|
1341
1430
|
}
|
|
1342
|
-
if (clio && !clio.ok) warnings.push(`clio: malformed CLIO-CODER.md ignored: ${clio.error}`);
|
|
1343
1431
|
const codewiki = readCodewiki(cwd);
|
|
1344
1432
|
if (codewiki) {
|
|
1345
1433
|
const state = readClioState(cwd);
|
|
@@ -1361,7 +1449,7 @@ function renderPromptContext(cwd) {
|
|
|
1361
1449
|
const suffix = notes.length > 0 ? ` (${notes.join("; ")}; run clio-coder context wiki --update)` : "";
|
|
1362
1450
|
pieces.push(`<wiki>${pages.length} pages at .clio-coder/wiki (start: quickstart.md)${suffix}</wiki>`);
|
|
1363
1451
|
}
|
|
1364
|
-
return { text: pieces.join("\n\n"), clioMd, warnings };
|
|
1452
|
+
return { text: pieces.join("\n\n"), clioMd, warnings, handbookFiles: loadedClioMd.files.map((file) => file.path) };
|
|
1365
1453
|
}
|
|
1366
1454
|
|
|
1367
1455
|
// src/domains/context/bootstrap.ts
|
|
@@ -1440,7 +1528,7 @@ function resolveDefaultIdentity(cwd, projectType, files) {
|
|
|
1440
1528
|
if (/Clio owns the agent loop/i.test(context) && /pi-(?:ai|SDK)/i.test(context)) {
|
|
1441
1529
|
return {
|
|
1442
1530
|
text: [
|
|
1443
|
-
"Clio Coder is IOWarp's orchestrator coding agent, named for the Greek muse of history and developed by the Gnosis Research Center at Illinois Tech
|
|
1531
|
+
"Clio Coder is IOWarp's orchestrator coding agent, named for the Greek muse of history and developed by the Gnosis Research Center at Illinois Tech (github.com/grc-iit, @grc-iit) and the IOWarp team. CLIO stands for Context Layer for Input/Output.",
|
|
1444
1532
|
"pi-ai is accessed through the engine boundary.",
|
|
1445
1533
|
"Clio owns the agent loop, TUI, session format, tool registry, and identity."
|
|
1446
1534
|
].join(" "),
|
|
@@ -1483,14 +1571,35 @@ function harvestSiblingBullets(files) {
|
|
|
1483
1571
|
}
|
|
1484
1572
|
return out3;
|
|
1485
1573
|
}
|
|
1486
|
-
function
|
|
1574
|
+
function localImportExtension(codewiki) {
|
|
1575
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1576
|
+
let total = 0;
|
|
1577
|
+
for (const file of codewiki.files) {
|
|
1578
|
+
for (const specifier of file.imports) {
|
|
1579
|
+
if (!specifier.startsWith(".")) continue;
|
|
1580
|
+
total += 1;
|
|
1581
|
+
const extension = /\.([A-Za-z0-9]+)$/.exec(specifier)?.[1];
|
|
1582
|
+
const key = extension === void 0 ? "" : `.${extension}`;
|
|
1583
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
if (total < 4) return null;
|
|
1587
|
+
for (const [extension, count] of counts) {
|
|
1588
|
+
if (extension.length > 0 && count / total >= 0.8) return extension;
|
|
1589
|
+
}
|
|
1590
|
+
return null;
|
|
1591
|
+
}
|
|
1592
|
+
function inferConventions(cwd, files, codewiki) {
|
|
1487
1593
|
const conventions = [];
|
|
1488
1594
|
const context = allContextText(files);
|
|
1489
1595
|
const pkg = readJsonFile(join4(cwd, "package.json"));
|
|
1490
1596
|
const packageText = typeof pkg === "object" && pkg !== null ? JSON.stringify(pkg) : "";
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1597
|
+
const declaredJs = /Local imports end in `?\.js`?/i.test(context);
|
|
1598
|
+
const importExtension = declaredJs ? ".js" : localImportExtension(codewiki);
|
|
1599
|
+
if (importExtension !== null) {
|
|
1600
|
+
pushUnique(conventions, `Local imports end in \`${importExtension}\`.`);
|
|
1601
|
+
}
|
|
1602
|
+
if (/node:test/i.test(context) || /node --import tsx --test|node --test/.test(packageText)) {
|
|
1494
1603
|
pushUnique(conventions, "Tests use `node:test`.");
|
|
1495
1604
|
}
|
|
1496
1605
|
if (/No em-dash|em-dash/i.test(context)) {
|
|
@@ -1555,6 +1664,44 @@ function packageManager(cwd) {
|
|
|
1555
1664
|
return "npm";
|
|
1556
1665
|
}
|
|
1557
1666
|
var MUTATING_SCRIPT_RE = /(?:^|\s)--(?:fix|write)(?:\s|$)/;
|
|
1667
|
+
function cmakePresetName(presets, key) {
|
|
1668
|
+
if (typeof presets !== "object" || presets === null || Array.isArray(presets)) return null;
|
|
1669
|
+
const list = presets[key];
|
|
1670
|
+
if (!Array.isArray(list)) return null;
|
|
1671
|
+
for (const entry of list) {
|
|
1672
|
+
if (entry?.hidden === true) continue;
|
|
1673
|
+
const name2 = stringField2(entry, "name");
|
|
1674
|
+
if (name2 !== null) return name2;
|
|
1675
|
+
}
|
|
1676
|
+
return null;
|
|
1677
|
+
}
|
|
1678
|
+
function cmakeVerificationLines(cwd) {
|
|
1679
|
+
const presets = readJsonFile(join4(cwd, "CMakePresets.json"));
|
|
1680
|
+
if (presets === null) return [];
|
|
1681
|
+
const configure = cmakePresetName(presets, "configurePresets");
|
|
1682
|
+
const build = cmakePresetName(presets, "buildPresets");
|
|
1683
|
+
const test = cmakePresetName(presets, "testPresets");
|
|
1684
|
+
const lines = [];
|
|
1685
|
+
if (configure !== null) lines.push(`Configure with \`cmake --preset ${configure}\`.`);
|
|
1686
|
+
if (build !== null) lines.push(`Build with \`cmake --build --preset ${build}\`.`);
|
|
1687
|
+
if (test !== null) lines.push(`Run tests with \`ctest --preset ${test}\`.`);
|
|
1688
|
+
return lines;
|
|
1689
|
+
}
|
|
1690
|
+
function pythonVerificationLines(cwd) {
|
|
1691
|
+
let pyproject = "";
|
|
1692
|
+
try {
|
|
1693
|
+
pyproject = readFileSync4(join4(cwd, "pyproject.toml"), "utf8");
|
|
1694
|
+
} catch {
|
|
1695
|
+
pyproject = "";
|
|
1696
|
+
}
|
|
1697
|
+
if (existsSync4(join4(cwd, "tox.ini")) || hasTomlTable(pyproject, "tool.tox")) {
|
|
1698
|
+
return ["Run `tox` before handoff."];
|
|
1699
|
+
}
|
|
1700
|
+
if (existsSync4(join4(cwd, "pytest.ini")) || hasTomlTable(pyproject, "tool.pytest.ini_options")) {
|
|
1701
|
+
return ["Run `pytest` before handoff."];
|
|
1702
|
+
}
|
|
1703
|
+
return [];
|
|
1704
|
+
}
|
|
1558
1705
|
function verificationSection(cwd) {
|
|
1559
1706
|
const scripts = packageScripts(cwd);
|
|
1560
1707
|
const pm = packageManager(cwd);
|
|
@@ -1582,6 +1729,14 @@ function verificationSection(cwd) {
|
|
|
1582
1729
|
if (hasScript("ci")) {
|
|
1583
1730
|
lines.push(`Use ${command("ci")} for the full local gate before committing broad or shared behavior changes.`);
|
|
1584
1731
|
}
|
|
1732
|
+
lines.push(...cmakeVerificationLines(cwd));
|
|
1733
|
+
if (existsSync4(join4(cwd, "Cargo.toml"))) {
|
|
1734
|
+
lines.push("Run `cargo build` and `cargo test` before handoff.");
|
|
1735
|
+
}
|
|
1736
|
+
if (existsSync4(join4(cwd, "go.mod"))) {
|
|
1737
|
+
lines.push("Run `go build ./...` and `go test ./...` before handoff.");
|
|
1738
|
+
}
|
|
1739
|
+
lines.push(...pythonVerificationLines(cwd));
|
|
1585
1740
|
if (lines.length === 0) return null;
|
|
1586
1741
|
return { title: "Verification expectations", body: lines.join(" ") };
|
|
1587
1742
|
}
|
|
@@ -1610,9 +1765,25 @@ function createModelGroundingCorpus(input) {
|
|
|
1610
1765
|
return { lower: evidence.toLowerCase(), indexedPaths };
|
|
1611
1766
|
}
|
|
1612
1767
|
var CODE_TOKEN_RE = /`([^`\n]+)`/g;
|
|
1613
|
-
|
|
1768
|
+
var CITED_LOCATION_RE = /^(.*[^:]):(\d+)(?:[-:]\d+)?$/;
|
|
1769
|
+
var CITED_CALL_RE = /^(.+?)\(\s*\)$/;
|
|
1770
|
+
function groundedName(token, evidence) {
|
|
1614
1771
|
return evidence.lower.includes(token.toLowerCase()) || evidence.indexedPaths.has(token.replace(/^\.\//, ""));
|
|
1615
1772
|
}
|
|
1773
|
+
function citedNames(token) {
|
|
1774
|
+
const names = [];
|
|
1775
|
+
let current = token;
|
|
1776
|
+
for (let round = 0; round < 2; round += 1) {
|
|
1777
|
+
const next = (CITED_CALL_RE.exec(current)?.[1] ?? CITED_LOCATION_RE.exec(current)?.[1])?.trim();
|
|
1778
|
+
if (next === void 0 || next.length === 0 || next === current) break;
|
|
1779
|
+
names.push(next);
|
|
1780
|
+
current = next;
|
|
1781
|
+
}
|
|
1782
|
+
return names;
|
|
1783
|
+
}
|
|
1784
|
+
function groundedToken(token, evidence) {
|
|
1785
|
+
return groundedName(token, evidence) || citedNames(token).some((name2) => groundedName(name2, evidence));
|
|
1786
|
+
}
|
|
1616
1787
|
function groundedModelBody(body, evidence) {
|
|
1617
1788
|
const kept = [];
|
|
1618
1789
|
let inFence = false;
|
|
@@ -1650,7 +1821,7 @@ function stabilizeGeneratedOutput(input, base, onModelSectionRetained, groundMod
|
|
|
1650
1821
|
const existing = input.existingClioMd;
|
|
1651
1822
|
const conventions = [];
|
|
1652
1823
|
for (const convention of existing?.conventions ?? []) pushUnique(conventions, convention);
|
|
1653
|
-
for (const convention of inferConventions(input.cwd, input.
|
|
1824
|
+
for (const convention of inferConventions(input.cwd, input.siblingFiles, input.codewiki)) {
|
|
1654
1825
|
pushUnique(conventions, convention);
|
|
1655
1826
|
}
|
|
1656
1827
|
const invariants = [];
|
|
@@ -1693,12 +1864,10 @@ function stabilizeGeneratedOutput(input, base, onModelSectionRetained, groundMod
|
|
|
1693
1864
|
function codewikiSections(codewiki) {
|
|
1694
1865
|
const sections = [];
|
|
1695
1866
|
const entryPoints = codewikiEntryPoints(codewiki, 8);
|
|
1696
|
-
const indexedCount = indexedSourceFileCount(codewiki);
|
|
1697
1867
|
if (entryPoints.length > 0) {
|
|
1698
1868
|
sections.push({
|
|
1699
1869
|
title: "Context retrieval",
|
|
1700
1870
|
body: [
|
|
1701
|
-
`The codewiki currently indexes ${indexedCount} source file${indexedCount === 1 ? "" : "s"}.`,
|
|
1702
1871
|
`Start orientation with these indexed entry points: ${entryPoints.map((entry) => `\`${entry}\``).join(", ")}.`,
|
|
1703
1872
|
"Use `code_nav` (modes: symbol, path, entries, outline, deps, dependents, wiki) before broad reads when the task is navigational."
|
|
1704
1873
|
].join(" ")
|
|
@@ -1731,7 +1900,7 @@ function heuristicBootstrapOutputSync(input) {
|
|
|
1731
1900
|
return stabilizeGeneratedOutput(input, {
|
|
1732
1901
|
projectName: projectName(input.cwd),
|
|
1733
1902
|
identity: resolveDefaultIdentity(input.cwd, input.projectType, input.siblingFiles).text,
|
|
1734
|
-
conventions: inferConventions(input.cwd, input.
|
|
1903
|
+
conventions: inferConventions(input.cwd, input.siblingFiles, input.codewiki),
|
|
1735
1904
|
invariants: inferInvariants(input.siblingFiles),
|
|
1736
1905
|
sections: inferHeuristicSections(input)
|
|
1737
1906
|
});
|
|
@@ -1794,7 +1963,7 @@ function countStatusLines(status) {
|
|
|
1794
1963
|
return status.split("\n").map((line) => line.trim()).filter(Boolean).length;
|
|
1795
1964
|
}
|
|
1796
1965
|
function basenameList(paths) {
|
|
1797
|
-
const names = paths.map((
|
|
1966
|
+
const names = paths.map((path2) => parse(path2).base).sort((a, b) => a.localeCompare(b));
|
|
1798
1967
|
if (names.length === 0) return "";
|
|
1799
1968
|
if (names.length <= 3) return names.join(", ");
|
|
1800
1969
|
return `${names.slice(0, 3).join(", ")} +${names.length - 3}`;
|
|
@@ -1916,7 +2085,7 @@ function serializeBootstrapOutput(output) {
|
|
|
1916
2085
|
}
|
|
1917
2086
|
function writeClioMdFile(cwd, output) {
|
|
1918
2087
|
const clioMdPath = join4(cwd, "CLIO-CODER.md");
|
|
1919
|
-
mkdirSync(
|
|
2088
|
+
mkdirSync(dirname3(clioMdPath), { recursive: true });
|
|
1920
2089
|
const serialized = serializeBootstrapOutput(output);
|
|
1921
2090
|
const parsed = parseClioMd(serialized);
|
|
1922
2091
|
if (!parsed.ok) throw new Error(`bootstrap produced invalid CLIO-CODER.md: ${parsed.errors.join("; ")}`);
|
|
@@ -1974,8 +2143,7 @@ function durableGenerationTelemetry(telemetry) {
|
|
|
1974
2143
|
}
|
|
1975
2144
|
return state;
|
|
1976
2145
|
}
|
|
1977
|
-
function writeProjectState(cwd, projectType, now, indexedAt, adoption, recordAdoption, codewikiVersion, generation, generated) {
|
|
1978
|
-
const finalFingerprint = computeFingerprint(cwd);
|
|
2146
|
+
function writeProjectState(cwd, projectType, now, indexedAt, adoption, recordAdoption, codewikiVersion, fingerprint, generation, generated) {
|
|
1979
2147
|
const statePath2 = statePath(cwd);
|
|
1980
2148
|
const prev = readClioState(cwd);
|
|
1981
2149
|
const lastBootstrap = generated ? durableGenerationTelemetry(generation) : prev?.lastBootstrap ?? durableGenerationTelemetry(generation);
|
|
@@ -1984,7 +2152,7 @@ function writeProjectState(cwd, projectType, now, indexedAt, adoption, recordAdo
|
|
|
1984
2152
|
writeClioState(cwd, {
|
|
1985
2153
|
version: 1,
|
|
1986
2154
|
projectType,
|
|
1987
|
-
fingerprint
|
|
2155
|
+
fingerprint,
|
|
1988
2156
|
codewikiVersion,
|
|
1989
2157
|
lastInitAt: now.toISOString(),
|
|
1990
2158
|
lastSessionAt: now.toISOString(),
|
|
@@ -1995,13 +2163,12 @@ function writeProjectState(cwd, projectType, now, indexedAt, adoption, recordAdo
|
|
|
1995
2163
|
});
|
|
1996
2164
|
return statePath2;
|
|
1997
2165
|
}
|
|
1998
|
-
function persistCodewikiForGeneration(cwd, projectType, indexedAt, codewiki) {
|
|
1999
|
-
writeCodewiki(cwd, codewiki);
|
|
2166
|
+
function persistCodewikiForGeneration(cwd, projectType, indexedAt, codewiki, fingerprint) {
|
|
2000
2167
|
const prev = readClioState(cwd);
|
|
2001
2168
|
writeClioState(cwd, {
|
|
2002
2169
|
version: 1,
|
|
2003
2170
|
projectType,
|
|
2004
|
-
fingerprint
|
|
2171
|
+
fingerprint,
|
|
2005
2172
|
codewikiVersion: codewiki.version,
|
|
2006
2173
|
...prev?.contextSources ? { contextSources: prev.contextSources } : {},
|
|
2007
2174
|
...prev?.contextSourceHash ? { contextSourceHash: prev.contextSourceHash } : {},
|
|
@@ -2038,7 +2205,7 @@ function codewikiEntryPoints(codewiki, limit = 6) {
|
|
|
2038
2205
|
if (!("toFileId" in edge)) continue;
|
|
2039
2206
|
inDegree.set(edge.toFileId, (inDegree.get(edge.toFileId) ?? 0) + 1);
|
|
2040
2207
|
}
|
|
2041
|
-
const ranked = [...inDegree.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([fileId]) => fileById.get(fileId)?.path).filter((
|
|
2208
|
+
const ranked = [...inDegree.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([fileId]) => fileById.get(fileId)?.path).filter((path2) => typeof path2 === "string").filter((path2) => !tagged.includes(path2));
|
|
2042
2209
|
return [...tagged, ...ranked].slice(0, limit);
|
|
2043
2210
|
}
|
|
2044
2211
|
async function runBootstrap(input = {}) {
|
|
@@ -2066,7 +2233,21 @@ async function runBootstrap(input = {}) {
|
|
|
2066
2233
|
const now = input.now?.() ?? /* @__PURE__ */ new Date();
|
|
2067
2234
|
const indexedAt = now.toISOString();
|
|
2068
2235
|
progress(input, { phase: "codewiki", status: "started", message: "building codewiki index" });
|
|
2069
|
-
|
|
2236
|
+
let codewiki;
|
|
2237
|
+
let codewikiFingerprint;
|
|
2238
|
+
if (input.preview === true) {
|
|
2239
|
+
const candidate = await buildCodewikiCandidate(cwd, projectType);
|
|
2240
|
+
codewiki = candidate.codewiki;
|
|
2241
|
+
codewikiFingerprint = candidate.fingerprint;
|
|
2242
|
+
} else {
|
|
2243
|
+
const coordinated = await coordinateCodewikiWrite(cwd, () => ({ kind: "build", cwd, language: projectType }), {
|
|
2244
|
+
beforeCommit: (_result, workspace) => ensureGitignore(workspace, input),
|
|
2245
|
+
afterCommit: ({ codewiki: committed, fingerprint }, workspace) => persistCodewikiForGeneration(workspace, projectType, indexedAt, committed, fingerprint)
|
|
2246
|
+
});
|
|
2247
|
+
if (!coordinated) throw new Error("codewiki bootstrap transaction did not commit");
|
|
2248
|
+
codewiki = coordinated.codewiki;
|
|
2249
|
+
codewikiFingerprint = coordinated.worker.fingerprint;
|
|
2250
|
+
}
|
|
2070
2251
|
const codewikiEntryCount = indexedSourceFileCount(codewiki);
|
|
2071
2252
|
progress(input, {
|
|
2072
2253
|
phase: "codewiki",
|
|
@@ -2075,10 +2256,6 @@ async function runBootstrap(input = {}) {
|
|
|
2075
2256
|
current: codewikiEntryCount,
|
|
2076
2257
|
total: codewikiEntryCount
|
|
2077
2258
|
});
|
|
2078
|
-
if (input.preview !== true) {
|
|
2079
|
-
await ensureGitignore(cwd, input);
|
|
2080
|
-
persistCodewikiForGeneration(cwd, projectType, indexedAt, codewiki);
|
|
2081
|
-
}
|
|
2082
2259
|
const hadClioMd = existsSync4(join4(cwd, "CLIO-CODER.md"));
|
|
2083
2260
|
const useExistingClioMdAsSource = hadClioMd && input.rewriteClioMd !== true;
|
|
2084
2261
|
const existingClioMdText = useExistingClioMdAsSource ? readExistingClioMdText(cwd) : null;
|
|
@@ -2224,6 +2401,7 @@ async function runBootstrap(input = {}) {
|
|
|
2224
2401
|
adoption,
|
|
2225
2402
|
adoptionApplied,
|
|
2226
2403
|
codewiki.version,
|
|
2404
|
+
codewikiFingerprint,
|
|
2227
2405
|
generation,
|
|
2228
2406
|
shouldGenerate
|
|
2229
2407
|
);
|
|
@@ -2272,6 +2450,7 @@ async function runBootstrap(input = {}) {
|
|
|
2272
2450
|
}
|
|
2273
2451
|
|
|
2274
2452
|
// src/domains/context/clear.ts
|
|
2453
|
+
init_esm_shims();
|
|
2275
2454
|
import { existsSync as existsSync5, rmSync } from "node:fs";
|
|
2276
2455
|
import { join as join5 } from "node:path";
|
|
2277
2456
|
var ACCUMULATED_CONTEXT_PATHS = [
|
|
@@ -2282,6 +2461,7 @@ var ACCUMULATED_CONTEXT_PATHS = [
|
|
|
2282
2461
|
];
|
|
2283
2462
|
var PRESERVED_CONTEXT_PATHS = [
|
|
2284
2463
|
"CLIO-CODER.md",
|
|
2464
|
+
"CLIO-CODER.override.md",
|
|
2285
2465
|
".clio-coder/agents",
|
|
2286
2466
|
".clio-coder/skills",
|
|
2287
2467
|
".clio-coder/wiki"
|
|
@@ -2305,17 +2485,20 @@ async function runContextClear(input = {}) {
|
|
|
2305
2485
|
out2(input.io, "clio-coder context reset cancelled; no files removed.\n");
|
|
2306
2486
|
return { action: "cancelled", removed: [], preserved: [...PRESERVED_CONTEXT_PATHS] };
|
|
2307
2487
|
}
|
|
2308
|
-
const removed =
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2488
|
+
const { removed, preserved } = await coordinateCodewikiExclusive(cwd, async (workspace) => {
|
|
2489
|
+
const removed2 = [];
|
|
2490
|
+
for (const relPath of ACCUMULATED_CONTEXT_PATHS) removeIfPresent(workspace, relPath, removed2);
|
|
2491
|
+
const preserved2 = [...PRESERVED_CONTEXT_PATHS];
|
|
2492
|
+
if (input.all === true) {
|
|
2493
|
+
const confirmedAll = await input.confirmAll?.();
|
|
2494
|
+
if (confirmedAll === true) {
|
|
2495
|
+
removeIfPresent(workspace, "CLIO-CODER.md", removed2);
|
|
2496
|
+
const index = preserved2.indexOf("CLIO-CODER.md");
|
|
2497
|
+
if (index !== -1) preserved2.splice(index, 1);
|
|
2498
|
+
}
|
|
2317
2499
|
}
|
|
2318
|
-
|
|
2500
|
+
return { removed: removed2, preserved: preserved2 };
|
|
2501
|
+
});
|
|
2319
2502
|
out2(
|
|
2320
2503
|
input.io,
|
|
2321
2504
|
[
|
|
@@ -2327,107 +2510,358 @@ async function runContextClear(input = {}) {
|
|
|
2327
2510
|
return { action: "cleared", removed, preserved };
|
|
2328
2511
|
}
|
|
2329
2512
|
|
|
2330
|
-
// src/domains/context/
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
import {
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
readFileSync as readFileSync6,
|
|
2344
|
-
renameSync,
|
|
2345
|
-
rmSync as rmSync3,
|
|
2346
|
-
statSync as statSync2,
|
|
2347
|
-
writeSync
|
|
2348
|
-
} from "node:fs";
|
|
2349
|
-
import { dirname as dirname4, join as join7 } from "node:path";
|
|
2350
|
-
|
|
2351
|
-
// src/domains/context/wiki/assemble.ts
|
|
2352
|
-
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
2353
|
-
import { basename as basename2, dirname as dirname3, join as join6, normalize, posix, relative as relative2 } from "node:path";
|
|
2354
|
-
var SOURCE_CITATION = /`((?:src|tests?|scripts|benchmarks|docs|packages|apps|lib|config|\.github)\/[^`\s:#]+)(?::(\d+)(?:-\d+)?)?(?::[A-Za-z_$][\w$.-]*)?`/g;
|
|
2355
|
-
var INTERNAL_LINK = /\[[^\]]*\]\((?![a-z][a-z\d+.-]*:|\/\/|#)([^)\s]+\.md)(?:#[^)\s]*)?\)/gi;
|
|
2356
|
-
var REPAIR_NOTE = /^<!-- clio:wiki .*-->$/gm;
|
|
2357
|
-
function readText2(filePath) {
|
|
2358
|
-
try {
|
|
2359
|
-
return readFileSync5(filePath, "utf8");
|
|
2360
|
-
} catch {
|
|
2361
|
-
return "";
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
function writeText(filePath, text) {
|
|
2365
|
-
mkdirSync2(dirname3(filePath), { recursive: true });
|
|
2366
|
-
writeFileSync2(filePath, text, "utf8");
|
|
2513
|
+
// src/domains/context/operator-profile.ts
|
|
2514
|
+
init_esm_shims();
|
|
2515
|
+
var import_yaml2 = __toESM(require_dist(), 1);
|
|
2516
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
2517
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
2518
|
+
import { join as join6 } from "node:path";
|
|
2519
|
+
var RESPONSE_POSTURES = ["concise", "balanced", "thorough"];
|
|
2520
|
+
var VALIDATION_PREFERENCES = ["tests-first", "manual", "trust"];
|
|
2521
|
+
var COMMIT_MESSAGE_STYLES = ["conventional", "descriptive", "terse"];
|
|
2522
|
+
var OPERATOR_PROFILE_MAX_CHARS = 700;
|
|
2523
|
+
var OPERATOR_PROFILE_MAX_LOCAL_PATHS = 8;
|
|
2524
|
+
function isRecord2(value) {
|
|
2525
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2367
2526
|
}
|
|
2368
|
-
function
|
|
2369
|
-
|
|
2527
|
+
function readEnum(value, allowed, field, issues) {
|
|
2528
|
+
if (value === void 0) return void 0;
|
|
2529
|
+
if (typeof value === "string" && allowed.includes(value)) return value;
|
|
2530
|
+
issues.push(`${field} must be one of ${allowed.join(", ")}`);
|
|
2531
|
+
return void 0;
|
|
2370
2532
|
}
|
|
2371
|
-
function
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2533
|
+
function readProfileBlob(value, issues) {
|
|
2534
|
+
if (!isRecord2(value)) {
|
|
2535
|
+
if (value !== null && value !== void 0) issues.push("profile must be a mapping at the root");
|
|
2536
|
+
return {};
|
|
2537
|
+
}
|
|
2538
|
+
const profile = {};
|
|
2539
|
+
const posture = readEnum(value.responsePosture, RESPONSE_POSTURES, "responsePosture", issues);
|
|
2540
|
+
if (posture) profile.responsePosture = posture;
|
|
2541
|
+
const validation = readEnum(value.validationPreference, VALIDATION_PREFERENCES, "validationPreference", issues);
|
|
2542
|
+
if (validation) profile.validationPreference = validation;
|
|
2543
|
+
const commit = readEnum(value.commitMessageStyle, COMMIT_MESSAGE_STYLES, "commitMessageStyle", issues);
|
|
2544
|
+
if (commit) profile.commitMessageStyle = commit;
|
|
2545
|
+
if (value.localOnlyPaths !== void 0) {
|
|
2546
|
+
if (Array.isArray(value.localOnlyPaths)) {
|
|
2547
|
+
const paths = value.localOnlyPaths.filter((item) => typeof item === "string" && item.length > 0);
|
|
2548
|
+
if (paths.length > 0) profile.localOnlyPaths = paths.slice(0, OPERATOR_PROFILE_MAX_LOCAL_PATHS);
|
|
2549
|
+
} else {
|
|
2550
|
+
issues.push("localOnlyPaths must be an array of strings");
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
return profile;
|
|
2380
2554
|
}
|
|
2381
|
-
function
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
return {
|
|
2555
|
+
function readProfileFile(path2, issues) {
|
|
2556
|
+
if (!existsSync6(path2)) return { profile: {}, present: false };
|
|
2557
|
+
try {
|
|
2558
|
+
return { profile: readProfileBlob((0, import_yaml2.parse)(readFileSync5(path2, "utf8")), issues), present: true };
|
|
2559
|
+
} catch (err) {
|
|
2560
|
+
issues.push(`${path2}: invalid YAML: ${err instanceof Error ? err.message : String(err)}`);
|
|
2561
|
+
return { profile: {}, present: false };
|
|
2388
2562
|
}
|
|
2563
|
+
}
|
|
2564
|
+
function loadOperatorProfile(cwd, options = {}) {
|
|
2389
2565
|
const issues = [];
|
|
2390
|
-
|
|
2391
|
-
|
|
2566
|
+
const userPath = options.userPath ?? join6(resolveClioDirs().config, "profile.yaml");
|
|
2567
|
+
const projectPath = join6(cwd, ".clio-coder", "profile.yaml");
|
|
2568
|
+
const user = readProfileFile(userPath, issues);
|
|
2569
|
+
const project = readProfileFile(projectPath, issues);
|
|
2570
|
+
const profile = { ...user.profile, ...project.profile };
|
|
2571
|
+
let origin = "none";
|
|
2572
|
+
let sourcePath;
|
|
2573
|
+
if (project.present) {
|
|
2574
|
+
origin = "project";
|
|
2575
|
+
sourcePath = projectPath;
|
|
2576
|
+
} else if (user.present) {
|
|
2577
|
+
origin = "user";
|
|
2578
|
+
sourcePath = userPath;
|
|
2392
2579
|
}
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
}
|
|
2580
|
+
const result = { profile, origin, issues };
|
|
2581
|
+
if (sourcePath !== void 0) {
|
|
2582
|
+
result.sourcePath = sourcePath;
|
|
2583
|
+
result.hash = createHash2("sha256").update(JSON.stringify(profile)).digest("hex").slice(0, 16);
|
|
2398
2584
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2585
|
+
return result;
|
|
2586
|
+
}
|
|
2587
|
+
function renderOperatorProfile(profile) {
|
|
2588
|
+
const lines = [];
|
|
2589
|
+
if (profile.responsePosture) lines.push(`- Response posture: ${profile.responsePosture}.`);
|
|
2590
|
+
if (profile.validationPreference) lines.push(`- Validation preference: ${profile.validationPreference}.`);
|
|
2591
|
+
if (profile.commitMessageStyle) lines.push(`- Commit-message style: ${profile.commitMessageStyle}.`);
|
|
2592
|
+
if (profile.localOnlyPaths && profile.localOnlyPaths.length > 0) {
|
|
2593
|
+
lines.push(`- Keep local-only (do not push or share): ${profile.localOnlyPaths.join(", ")}.`);
|
|
2405
2594
|
}
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2595
|
+
if (lines.length === 0) return { text: "", tokenEstimate: 0 };
|
|
2596
|
+
const full = `## Operator profile
|
|
2597
|
+
${lines.join("\n")}`;
|
|
2598
|
+
const text = full.length > OPERATOR_PROFILE_MAX_CHARS ? `${full.slice(0, OPERATOR_PROFILE_MAX_CHARS - 1)}\u2026` : full;
|
|
2599
|
+
return { text, tokenEstimate: ceilChars(text.length) };
|
|
2410
2600
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2601
|
+
|
|
2602
|
+
// src/domains/context/project-rules.ts
|
|
2603
|
+
init_esm_shims();
|
|
2604
|
+
var import_yaml3 = __toESM(require_dist(), 1);
|
|
2605
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
2606
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
2607
|
+
import { join as join7, relative as relative2, sep as sep2 } from "node:path";
|
|
2608
|
+
var FRONTMATTER_RE = /^---\n([\s\S]*?)\n---\n?/;
|
|
2609
|
+
function isRecord3(value) {
|
|
2610
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2414
2611
|
}
|
|
2415
|
-
function
|
|
2416
|
-
|
|
2612
|
+
function readStringArray(value) {
|
|
2613
|
+
if (!Array.isArray(value)) return void 0;
|
|
2614
|
+
const out3 = [];
|
|
2615
|
+
for (const item of value) {
|
|
2616
|
+
if (typeof item === "string" && item.length > 0) out3.push(item);
|
|
2617
|
+
}
|
|
2618
|
+
return out3.length > 0 ? out3 : void 0;
|
|
2417
2619
|
}
|
|
2418
|
-
function
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2620
|
+
function validateGlobArray(value, field, id, issues) {
|
|
2621
|
+
const parsed = readStringArray(value);
|
|
2622
|
+
if (parsed === void 0) {
|
|
2623
|
+
issues.push(`${id}: frontmatter ${field} must be a non-empty string array`);
|
|
2624
|
+
return void 0;
|
|
2625
|
+
}
|
|
2626
|
+
for (const pattern of parsed) {
|
|
2627
|
+
try {
|
|
2628
|
+
compileGlobRegex(pattern);
|
|
2629
|
+
} catch (err) {
|
|
2630
|
+
issues.push(
|
|
2631
|
+
`${id}: invalid ${field} glob ${JSON.stringify(pattern)}: ${err instanceof Error ? err.message : String(err)}`
|
|
2632
|
+
);
|
|
2633
|
+
return void 0;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
return parsed;
|
|
2422
2637
|
}
|
|
2423
|
-
function
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2638
|
+
function walkMarkdown(dir, root, out3) {
|
|
2639
|
+
let entries;
|
|
2640
|
+
try {
|
|
2641
|
+
entries = readdirSync3(dir, { withFileTypes: true });
|
|
2642
|
+
} catch {
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
for (const entry of entries) {
|
|
2646
|
+
const full = join7(dir, entry.name);
|
|
2647
|
+
if (entry.isDirectory()) walkMarkdown(full, root, out3);
|
|
2648
|
+
else if (entry.isFile() && entry.name.endsWith(".md")) out3.push(full);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
function parseRule(filePath, root, issues) {
|
|
2652
|
+
let text;
|
|
2653
|
+
try {
|
|
2654
|
+
text = readFileSync6(filePath, "utf8").replace(/\r\n/g, "\n");
|
|
2655
|
+
} catch (err) {
|
|
2656
|
+
issues.push(`${filePath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2657
|
+
return { excludes: [] };
|
|
2658
|
+
}
|
|
2659
|
+
const id = relative2(root, filePath).split(sep2).join("/");
|
|
2660
|
+
let body = text;
|
|
2661
|
+
let paths;
|
|
2662
|
+
let excludes = [];
|
|
2663
|
+
let enabled = true;
|
|
2664
|
+
let description2;
|
|
2665
|
+
let invalidFrontmatter = false;
|
|
2666
|
+
const match = FRONTMATTER_RE.exec(text);
|
|
2667
|
+
if (match) {
|
|
2668
|
+
body = text.slice(match[0].length);
|
|
2669
|
+
try {
|
|
2670
|
+
const front = (0, import_yaml3.parse)(match[1] ?? "");
|
|
2671
|
+
if (isRecord3(front)) {
|
|
2672
|
+
if (Object.hasOwn(front, "paths")) {
|
|
2673
|
+
const parsedPaths = validateGlobArray(front.paths, "paths", id, issues);
|
|
2674
|
+
if (parsedPaths === void 0) invalidFrontmatter = true;
|
|
2675
|
+
else paths = parsedPaths;
|
|
2676
|
+
}
|
|
2677
|
+
if (Object.hasOwn(front, "excludes")) {
|
|
2678
|
+
const parsedExcludes = validateGlobArray(front.excludes, "excludes", id, issues);
|
|
2679
|
+
if (parsedExcludes === void 0) invalidFrontmatter = true;
|
|
2680
|
+
else excludes = parsedExcludes;
|
|
2681
|
+
}
|
|
2682
|
+
if (Object.hasOwn(front, "enabled")) {
|
|
2683
|
+
if (typeof front.enabled === "boolean") enabled = front.enabled;
|
|
2684
|
+
else {
|
|
2685
|
+
issues.push(`${id}: frontmatter enabled must be a boolean`);
|
|
2686
|
+
invalidFrontmatter = true;
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
if (Object.hasOwn(front, "description")) {
|
|
2690
|
+
if (typeof front.description === "string") description2 = front.description;
|
|
2691
|
+
else {
|
|
2692
|
+
issues.push(`${id}: frontmatter description must be a string`);
|
|
2693
|
+
invalidFrontmatter = true;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
} else if (front !== null && front !== void 0) {
|
|
2697
|
+
issues.push(`${id}: frontmatter must be a mapping`);
|
|
2698
|
+
invalidFrontmatter = true;
|
|
2699
|
+
}
|
|
2700
|
+
} catch (err) {
|
|
2701
|
+
issues.push(`${id}: invalid frontmatter: ${err instanceof Error ? err.message : String(err)}`);
|
|
2702
|
+
invalidFrontmatter = true;
|
|
2703
|
+
}
|
|
2704
|
+
} else if (text.startsWith("---\n")) {
|
|
2705
|
+
issues.push(`${id}: invalid frontmatter: missing closing marker`);
|
|
2706
|
+
invalidFrontmatter = true;
|
|
2707
|
+
}
|
|
2708
|
+
if (invalidFrontmatter) return { excludes: [] };
|
|
2709
|
+
const trimmedBody = body.trim();
|
|
2710
|
+
const hash = createHash3("sha256").update(trimmedBody).digest("hex").slice(0, 16);
|
|
2711
|
+
const rule = {
|
|
2712
|
+
id,
|
|
2713
|
+
sourcePath: join7(".clio-coder", "rules", id),
|
|
2714
|
+
hash,
|
|
2715
|
+
tokenEstimate: ceilChars(trimmedBody.length),
|
|
2716
|
+
enabled,
|
|
2717
|
+
body: trimmedBody
|
|
2718
|
+
};
|
|
2719
|
+
if (paths !== void 0) rule.paths = paths;
|
|
2720
|
+
if (description2 !== void 0) rule.description = description2;
|
|
2721
|
+
return { rule, excludes };
|
|
2722
|
+
}
|
|
2723
|
+
function loadProjectRules(cwd) {
|
|
2724
|
+
const root = join7(cwd, ".clio-coder", "rules");
|
|
2725
|
+
const issues = [];
|
|
2726
|
+
const files = [];
|
|
2727
|
+
walkMarkdown(root, root, files);
|
|
2728
|
+
files.sort();
|
|
2729
|
+
const rules = [];
|
|
2730
|
+
const excludeSet = /* @__PURE__ */ new Set();
|
|
2731
|
+
for (const file of files) {
|
|
2732
|
+
const parsed = parseRule(file, root, issues);
|
|
2733
|
+
if (parsed.rule) rules.push(parsed.rule);
|
|
2734
|
+
for (const glob of parsed.excludes) excludeSet.add(glob);
|
|
2735
|
+
}
|
|
2736
|
+
rules.sort((a, b) => a.id.localeCompare(b.id));
|
|
2737
|
+
return { rules, excludes: [...excludeSet], issues };
|
|
2738
|
+
}
|
|
2739
|
+
function ruleMatchesAnyPath(rule, workingPaths) {
|
|
2740
|
+
for (const pattern of rule.paths ?? []) {
|
|
2741
|
+
let regex;
|
|
2742
|
+
try {
|
|
2743
|
+
regex = compileGlobRegex(pattern);
|
|
2744
|
+
} catch {
|
|
2745
|
+
continue;
|
|
2746
|
+
}
|
|
2747
|
+
for (const path2 of workingPaths) {
|
|
2748
|
+
if (regex.test(normalizeGlobInput(path2))) return true;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
return false;
|
|
2752
|
+
}
|
|
2753
|
+
function selectActiveRules(rules, workingContextPaths) {
|
|
2754
|
+
return rules.filter((rule) => {
|
|
2755
|
+
if (!rule.enabled) return false;
|
|
2756
|
+
if (rule.paths === void 0) return true;
|
|
2757
|
+
return ruleMatchesAnyPath(rule, workingContextPaths);
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
// src/domains/context/refresh.ts
|
|
2762
|
+
init_esm_shims();
|
|
2763
|
+
import { writeFileSync as writeFileSync3 } from "node:fs";
|
|
2764
|
+
import { join as join10 } from "node:path";
|
|
2765
|
+
|
|
2766
|
+
// src/domains/context/wiki/generate.ts
|
|
2767
|
+
init_esm_shims();
|
|
2768
|
+
import {
|
|
2769
|
+
closeSync,
|
|
2770
|
+
copyFileSync,
|
|
2771
|
+
existsSync as existsSync7,
|
|
2772
|
+
mkdirSync as mkdirSync3,
|
|
2773
|
+
mkdtempSync,
|
|
2774
|
+
openSync,
|
|
2775
|
+
readdirSync as readdirSync4,
|
|
2776
|
+
readFileSync as readFileSync8,
|
|
2777
|
+
renameSync,
|
|
2778
|
+
rmSync as rmSync3,
|
|
2779
|
+
statSync as statSync3,
|
|
2780
|
+
writeSync
|
|
2781
|
+
} from "node:fs";
|
|
2782
|
+
import { dirname as dirname5, join as join9 } from "node:path";
|
|
2783
|
+
|
|
2784
|
+
// src/domains/context/wiki/assemble.ts
|
|
2785
|
+
init_esm_shims();
|
|
2786
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync7, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
2787
|
+
import { basename as basename3, dirname as dirname4, join as join8, normalize, posix, relative as relative3 } from "node:path";
|
|
2788
|
+
var SOURCE_CITATION = /`((?:src|tests?|scripts|benchmarks|docs|packages|apps|lib|config|\.github)\/[^`\s:#]+)(?::(\d+)(?:-\d+)?)?(?::[A-Za-z_$][\w$.-]*)?`/g;
|
|
2789
|
+
var INTERNAL_LINK = /\[[^\]]*\]\((?![a-z][a-z\d+.-]*:|\/\/|#)([^)\s]+\.md)(?:#[^)\s]*)?\)/gi;
|
|
2790
|
+
var REPAIR_NOTE = /^<!-- clio:wiki .*-->$/gm;
|
|
2791
|
+
function readText2(filePath) {
|
|
2792
|
+
try {
|
|
2793
|
+
return readFileSync7(filePath, "utf8");
|
|
2794
|
+
} catch {
|
|
2795
|
+
return "";
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
function writeText(filePath, text) {
|
|
2799
|
+
mkdirSync2(dirname4(filePath), { recursive: true });
|
|
2800
|
+
writeFileSync2(filePath, text, "utf8");
|
|
2801
|
+
}
|
|
2802
|
+
function stripRepairNotes(body) {
|
|
2803
|
+
return body.replace(REPAIR_NOTE, "").replace(/\n{3,}/g, "\n\n");
|
|
2804
|
+
}
|
|
2805
|
+
function renderRepairNote(issues) {
|
|
2806
|
+
const links = issues.filter((issue) => issue.kind === "link").map((issue) => issue.reference);
|
|
2807
|
+
const citations = issues.filter((issue) => issue.kind === "citation").map((issue) => issue.reference);
|
|
2808
|
+
const parts = [];
|
|
2809
|
+
if (links.length > 0) parts.push(`unresolved links: ${[...new Set(links)].join(", ")}`);
|
|
2810
|
+
if (citations.length > 0) parts.push(`unresolved sources: ${[...new Set(citations)].join(", ")}`);
|
|
2811
|
+
return parts.length === 0 ? "" : `
|
|
2812
|
+
<!-- clio:wiki ${parts.join("; ")} -->
|
|
2813
|
+
`;
|
|
2814
|
+
}
|
|
2815
|
+
function repairPage(dir, sourceRoot, relPath, knownPages) {
|
|
2816
|
+
const filePath = join8(dir, relPath);
|
|
2817
|
+
const original = readText2(filePath);
|
|
2818
|
+
const parsed = readWikiPage({ pagePath: relPath, content: original, sourceRoot });
|
|
2819
|
+
const body = stripRepairNotes(parsed.body);
|
|
2820
|
+
if (body.replace(/^#.*$/gm, "").trim().length === 0) {
|
|
2821
|
+
return { metadata: parsed.metadata, changed: false, issues: [], empty: true };
|
|
2822
|
+
}
|
|
2823
|
+
const issues = [];
|
|
2824
|
+
for (const cited of parsed.unresolvedPaths) {
|
|
2825
|
+
issues.push({ page: relPath, kind: "citation", reference: cited });
|
|
2826
|
+
}
|
|
2827
|
+
for (const match of body.matchAll(SOURCE_CITATION)) {
|
|
2828
|
+
const cited = match[1] ?? "";
|
|
2829
|
+
if (resolveSourcePath(sourceRoot, cited) === null) {
|
|
2830
|
+
issues.push({ page: relPath, kind: "citation", reference: cited });
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
for (const match of body.matchAll(INTERNAL_LINK)) {
|
|
2834
|
+
const href = match[1] ?? "";
|
|
2835
|
+
const target = posix.normalize(posix.join(posix.dirname(relPath), href));
|
|
2836
|
+
if (target.startsWith("..") || !knownPages.has(target)) {
|
|
2837
|
+
issues.push({ page: relPath, kind: "link", reference: href });
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
const rebuilt = `${renderWikiPage(parsed.metadata, body).trimEnd()}
|
|
2841
|
+
${renderRepairNote(issues)}`;
|
|
2842
|
+
if (rebuilt !== original) writeText(filePath, rebuilt);
|
|
2843
|
+
return { metadata: parsed.metadata, changed: rebuilt !== original, issues, empty: false };
|
|
2844
|
+
}
|
|
2845
|
+
function linkTo(fromDir, target) {
|
|
2846
|
+
const href = posix.relative(fromDir === "." ? "" : fromDir, target);
|
|
2847
|
+
return href.length > 0 ? href : posix.basename(target);
|
|
2848
|
+
}
|
|
2849
|
+
function escapeCell(value) {
|
|
2850
|
+
return value.replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
|
2851
|
+
}
|
|
2852
|
+
function codeList(values, limit) {
|
|
2853
|
+
if (values.length === 0) return "\u2014";
|
|
2854
|
+
const shown = values.slice(0, limit).map((value) => `\`${escapeCell(value)}\``);
|
|
2855
|
+
return values.length > limit ? `${shown.join(", ")}, \u2026` : shown.join(", ");
|
|
2856
|
+
}
|
|
2857
|
+
function renderQuickstart(sourceRoot, plan, pages) {
|
|
2858
|
+
const content = pages.filter((page) => page.path !== WIKI_QUICKSTART);
|
|
2859
|
+
const lines = [`# ${basename3(sourceRoot)} wiki`, ""];
|
|
2860
|
+
if (plan.overview.trim().length > 0) lines.push(plan.overview.trim(), "");
|
|
2861
|
+
lines.push(
|
|
2862
|
+
`This wiki is generated by \`clio-coder context wiki\` from ${content.length} page${content.length === 1 ? "" : "s"}. Each page opens with front matter naming the sources, symbols, and tests it documents.`,
|
|
2863
|
+
"",
|
|
2864
|
+
"## Pages",
|
|
2431
2865
|
""
|
|
2432
2866
|
);
|
|
2433
2867
|
let currentSection = null;
|
|
@@ -2491,7 +2925,7 @@ function assembleWikiTree(input) {
|
|
|
2491
2925
|
for (const relPath of authored) {
|
|
2492
2926
|
const result = repairPage(dir, sourceRoot, relPath, knownPages);
|
|
2493
2927
|
if (result.empty) {
|
|
2494
|
-
rmSync2(
|
|
2928
|
+
rmSync2(join8(dir, relPath), { force: true });
|
|
2495
2929
|
dropped.push(relPath);
|
|
2496
2930
|
continue;
|
|
2497
2931
|
}
|
|
@@ -2499,7 +2933,7 @@ function assembleWikiTree(input) {
|
|
|
2499
2933
|
issues.push(...result.issues);
|
|
2500
2934
|
assembled.push({ path: relPath, metadata: result.metadata });
|
|
2501
2935
|
}
|
|
2502
|
-
writeText(
|
|
2936
|
+
writeText(join8(dir, WIKI_QUICKSTART), renderQuickstart(sourceRoot, input.plan, assembled));
|
|
2503
2937
|
const directories = /* @__PURE__ */ new Set(["."]);
|
|
2504
2938
|
for (const page of assembled) {
|
|
2505
2939
|
let section = posix.dirname(page.path);
|
|
@@ -2512,12 +2946,12 @@ function assembleWikiTree(input) {
|
|
|
2512
2946
|
const pagesHere = assembled.filter((page) => posix.dirname(page.path) === directory);
|
|
2513
2947
|
const sectionsHere = [...directories].filter((candidate) => candidate !== "." && posix.dirname(candidate) === directory).sort();
|
|
2514
2948
|
const indexPath = directory === "." ? WIKI_INDEX : `${directory}/${WIKI_INDEX}`;
|
|
2515
|
-
writeText(
|
|
2949
|
+
writeText(join8(dir, indexPath), renderIndex(directory, pagesHere, sectionsHere));
|
|
2516
2950
|
}
|
|
2517
2951
|
for (const relPath of wikiMarkdownFilesInDir(dir)) {
|
|
2518
2952
|
if (!isGeneratedWikiFile(relPath) || relPath === WIKI_QUICKSTART) continue;
|
|
2519
2953
|
const directory = posix.dirname(relPath);
|
|
2520
|
-
if (!directories.has(directory)) rmSync2(
|
|
2954
|
+
if (!directories.has(directory)) rmSync2(join8(dir, relPath), { force: true });
|
|
2521
2955
|
}
|
|
2522
2956
|
return { pages: listWikiPagesInDir(dir), repaired, dropped, issues };
|
|
2523
2957
|
}
|
|
@@ -2525,26 +2959,27 @@ function pageSourceIndex(dir, sourceRoot) {
|
|
|
2525
2959
|
const index = /* @__PURE__ */ new Map();
|
|
2526
2960
|
for (const relPath of wikiMarkdownFilesInDir(dir)) {
|
|
2527
2961
|
if (isGeneratedWikiFile(relPath)) continue;
|
|
2528
|
-
const { metadata } = readWikiPage({ pagePath: relPath, content: readText2(
|
|
2962
|
+
const { metadata } = readWikiPage({ pagePath: relPath, content: readText2(join8(dir, relPath)), sourceRoot });
|
|
2529
2963
|
index.set(relPath, [...metadata.sources, ...metadata.tests]);
|
|
2530
2964
|
}
|
|
2531
2965
|
return index;
|
|
2532
2966
|
}
|
|
2533
2967
|
function normalizeRepoPath(sourceRoot, candidate) {
|
|
2534
|
-
const resolved = normalize(
|
|
2535
|
-
const rel =
|
|
2968
|
+
const resolved = normalize(join8(sourceRoot, candidate));
|
|
2969
|
+
const rel = relative3(sourceRoot, resolved);
|
|
2536
2970
|
return rel.split("\\").join("/");
|
|
2537
2971
|
}
|
|
2538
2972
|
|
|
2539
2973
|
// src/domains/context/wiki/plan.ts
|
|
2974
|
+
init_esm_shims();
|
|
2540
2975
|
var WIKI_DEPTH_STRATEGY = {
|
|
2541
2976
|
simple: { areaDepth: 1, areaShare: 0.08, minAreaLines: 400 },
|
|
2542
2977
|
medium: { areaDepth: 2, areaShare: 0.03, minAreaLines: 250 },
|
|
2543
2978
|
detailed: { areaDepth: 3, areaShare: 8e-3, minAreaLines: 150 }
|
|
2544
2979
|
};
|
|
2545
2980
|
var MAX_PAGE_SOURCES = 8;
|
|
2546
|
-
function areaForPath(
|
|
2547
|
-
const directories =
|
|
2981
|
+
function areaForPath(path2, maxDepth) {
|
|
2982
|
+
const directories = path2.split("/").filter(Boolean).slice(0, -1);
|
|
2548
2983
|
if (directories.length === 0) return ".";
|
|
2549
2984
|
return directories.slice(0, Math.max(1, maxDepth)).join("/");
|
|
2550
2985
|
}
|
|
@@ -2636,14 +3071,14 @@ function dedupePagePaths(plan) {
|
|
|
2636
3071
|
const seen = /* @__PURE__ */ new Set();
|
|
2637
3072
|
const pages = [];
|
|
2638
3073
|
for (const page of plan.pages) {
|
|
2639
|
-
let
|
|
3074
|
+
let path2 = page.path;
|
|
2640
3075
|
let suffix = 2;
|
|
2641
|
-
while (seen.has(
|
|
2642
|
-
|
|
3076
|
+
while (seen.has(path2)) {
|
|
3077
|
+
path2 = page.path.replace(/\.md$/, `-${suffix}.md`);
|
|
2643
3078
|
suffix += 1;
|
|
2644
3079
|
}
|
|
2645
|
-
seen.add(
|
|
2646
|
-
pages.push({ ...page, path });
|
|
3080
|
+
seen.add(path2);
|
|
3081
|
+
pages.push({ ...page, path: path2 });
|
|
2647
3082
|
}
|
|
2648
3083
|
return { ...plan, pages };
|
|
2649
3084
|
}
|
|
@@ -2663,29 +3098,38 @@ function indexedSourceFileCount2(codewiki) {
|
|
|
2663
3098
|
return codewiki.files.filter((file) => file.lang !== "config").length;
|
|
2664
3099
|
}
|
|
2665
3100
|
async function loadOrBuildCodewiki(cwd) {
|
|
2666
|
-
const existing = readCodewiki(cwd);
|
|
2667
|
-
const prev = readClioState(cwd);
|
|
2668
|
-
if (existing && !codewikiNeedsBackfill(existing)) {
|
|
2669
|
-
const fingerprint = computeFingerprint(cwd, existing);
|
|
2670
|
-
if (prev && !isStale(prev.fingerprint, fingerprint)) return existing;
|
|
2671
|
-
}
|
|
2672
3101
|
const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2673
3102
|
const projectType = detectProjectType(cwd);
|
|
2674
|
-
const
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
3103
|
+
const coordinated = await coordinateCodewikiWrite(
|
|
3104
|
+
cwd,
|
|
3105
|
+
(current, workspace) => ({
|
|
3106
|
+
kind: "ensure",
|
|
3107
|
+
cwd: workspace,
|
|
3108
|
+
language: projectType,
|
|
3109
|
+
current,
|
|
3110
|
+
previous: readClioState(workspace)?.fingerprint ?? null
|
|
3111
|
+
}),
|
|
3112
|
+
{
|
|
3113
|
+
afterCommit: ({ codewiki, fingerprint, changed }, workspace) => {
|
|
3114
|
+
const prev = readClioState(workspace);
|
|
3115
|
+
if (!changed && prev) return;
|
|
3116
|
+
writeClioState(workspace, {
|
|
3117
|
+
version: 1,
|
|
3118
|
+
projectType: prev?.projectType ?? projectType,
|
|
3119
|
+
fingerprint,
|
|
3120
|
+
codewikiVersion: codewiki.version,
|
|
3121
|
+
...prev?.contextSources ? { contextSources: prev.contextSources } : {},
|
|
3122
|
+
...prev?.contextSourceHash ? { contextSourceHash: prev.contextSourceHash } : {},
|
|
3123
|
+
...prev?.lastBootstrap ? { lastBootstrap: prev.lastBootstrap } : {},
|
|
3124
|
+
...prev?.lastInitAt ? { lastInitAt: prev.lastInitAt } : {},
|
|
3125
|
+
lastSessionAt: prev?.lastSessionAt ?? generatedAt,
|
|
3126
|
+
lastIndexedAt: generatedAt
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
);
|
|
3131
|
+
if (!coordinated) throw new Error("codewiki wiki transaction did not commit");
|
|
3132
|
+
return { codewiki: coordinated.codewiki, fingerprint: coordinated.worker.fingerprint };
|
|
2689
3133
|
}
|
|
2690
3134
|
function failed(problems, pages) {
|
|
2691
3135
|
return { status: "failed", pages, problems };
|
|
@@ -2694,7 +3138,7 @@ var STAGING_PREFIX = "wiki-staging-";
|
|
|
2694
3138
|
var WIKI_PREV_DIR = "wiki-prev";
|
|
2695
3139
|
var WIKI_LOCK_FILE = "wiki.lock";
|
|
2696
3140
|
function clioDir(cwd) {
|
|
2697
|
-
return
|
|
3141
|
+
return join9(cwd, ".clio-coder");
|
|
2698
3142
|
}
|
|
2699
3143
|
function isProcessAlive(pid) {
|
|
2700
3144
|
try {
|
|
@@ -2706,7 +3150,7 @@ function isProcessAlive(pid) {
|
|
|
2706
3150
|
}
|
|
2707
3151
|
function readLockPid(lockPath) {
|
|
2708
3152
|
try {
|
|
2709
|
-
const parsed = Number.parseInt(
|
|
3153
|
+
const parsed = Number.parseInt(readFileSync8(lockPath, "utf8").trim(), 10);
|
|
2710
3154
|
return Number.isInteger(parsed) && parsed > 0 ? parsed : null;
|
|
2711
3155
|
} catch {
|
|
2712
3156
|
return null;
|
|
@@ -2715,7 +3159,7 @@ function readLockPid(lockPath) {
|
|
|
2715
3159
|
function acquireWikiLock(cwd) {
|
|
2716
3160
|
const dir = clioDir(cwd);
|
|
2717
3161
|
mkdirSync3(dir, { recursive: true });
|
|
2718
|
-
const lockPath =
|
|
3162
|
+
const lockPath = join9(dir, WIKI_LOCK_FILE);
|
|
2719
3163
|
const release = () => {
|
|
2720
3164
|
try {
|
|
2721
3165
|
rmSync3(lockPath, { force: true });
|
|
@@ -2765,10 +3209,10 @@ function removeDir(dir) {
|
|
|
2765
3209
|
function seedStaging(cwd, stagingDir) {
|
|
2766
3210
|
const source = wikiDir(cwd);
|
|
2767
3211
|
for (const relPath of wikiMarkdownFilesInDir(source)) {
|
|
2768
|
-
const target =
|
|
2769
|
-
mkdirSync3(
|
|
3212
|
+
const target = join9(stagingDir, relPath);
|
|
3213
|
+
mkdirSync3(dirname5(target), { recursive: true });
|
|
2770
3214
|
try {
|
|
2771
|
-
copyFileSync(
|
|
3215
|
+
copyFileSync(join9(source, relPath), target);
|
|
2772
3216
|
} catch {
|
|
2773
3217
|
}
|
|
2774
3218
|
}
|
|
@@ -2778,29 +3222,29 @@ function adoptOrCreateStaging(cwd) {
|
|
|
2778
3222
|
mkdirSync3(dir, { recursive: true });
|
|
2779
3223
|
let entries;
|
|
2780
3224
|
try {
|
|
2781
|
-
entries =
|
|
3225
|
+
entries = readdirSync4(dir, { withFileTypes: true });
|
|
2782
3226
|
} catch {
|
|
2783
3227
|
entries = [];
|
|
2784
3228
|
}
|
|
2785
|
-
const candidates = entries.filter((entry) => entry.isDirectory() && entry.name.startsWith(STAGING_PREFIX)).map((entry) =>
|
|
2786
|
-
const at =
|
|
2787
|
-
const bt =
|
|
3229
|
+
const candidates = entries.filter((entry) => entry.isDirectory() && entry.name.startsWith(STAGING_PREFIX)).map((entry) => join9(dir, entry.name)).sort((a, b) => {
|
|
3230
|
+
const at = statSync3(a).mtimeMs;
|
|
3231
|
+
const bt = statSync3(b).mtimeMs;
|
|
2788
3232
|
return bt - at;
|
|
2789
3233
|
});
|
|
2790
|
-
const resumable = candidates.find((candidate) =>
|
|
3234
|
+
const resumable = candidates.find((candidate) => existsSync7(join9(candidate, WIKI_PLAN_FILE)));
|
|
2791
3235
|
for (const candidate of candidates) {
|
|
2792
3236
|
if (candidate !== resumable) removeDir(candidate);
|
|
2793
3237
|
}
|
|
2794
3238
|
if (resumable !== void 0) return { dir: resumable, adopted: true };
|
|
2795
|
-
const fresh = mkdtempSync(
|
|
3239
|
+
const fresh = mkdtempSync(join9(dir, STAGING_PREFIX));
|
|
2796
3240
|
seedStaging(cwd, fresh);
|
|
2797
3241
|
return { dir: fresh, adopted: false };
|
|
2798
3242
|
}
|
|
2799
3243
|
function promoteStaging(cwd, stagingDir, writeMeta) {
|
|
2800
3244
|
const wiki = wikiDir(cwd);
|
|
2801
|
-
const prev =
|
|
3245
|
+
const prev = join9(clioDir(cwd), WIKI_PREV_DIR);
|
|
2802
3246
|
removeDir(prev);
|
|
2803
|
-
const hadWiki =
|
|
3247
|
+
const hadWiki = existsSync7(wiki);
|
|
2804
3248
|
if (hadWiki) renameSync(wiki, prev);
|
|
2805
3249
|
try {
|
|
2806
3250
|
renameSync(stagingDir, wiki);
|
|
@@ -2828,7 +3272,7 @@ function resolvePlan(input) {
|
|
|
2828
3272
|
if (input.mode === "update" && input.previousPlan !== void 0) {
|
|
2829
3273
|
const pageSources = pageSourceIndex(input.stagingDir, input.cwd);
|
|
2830
3274
|
const changed = new Set(
|
|
2831
|
-
changedPathsSince(input.cwd, input.gitHead).map((
|
|
3275
|
+
changedPathsSince(input.cwd, input.gitHead).map((path2) => normalizeRepoPath(input.cwd, path2))
|
|
2832
3276
|
);
|
|
2833
3277
|
return {
|
|
2834
3278
|
plan: scopePlanForUpdate({
|
|
@@ -2877,8 +3321,8 @@ async function runWikiGenerate(input = { model: "configured-clio-target" }) {
|
|
|
2877
3321
|
}
|
|
2878
3322
|
try {
|
|
2879
3323
|
progress2(input, { phase: "codewiki", status: "started", message: "loading codewiki for wiki generation" });
|
|
2880
|
-
const codewiki = await loadOrBuildCodewiki(cwd);
|
|
2881
|
-
const sourceTreeHash =
|
|
3324
|
+
const { codewiki, fingerprint } = await loadOrBuildCodewiki(cwd);
|
|
3325
|
+
const sourceTreeHash = fingerprint.treeHash;
|
|
2882
3326
|
const generation = planWikiGeneration(codewiki, input.depth ?? "auto");
|
|
2883
3327
|
progress2(input, {
|
|
2884
3328
|
phase: "codewiki",
|
|
@@ -2952,7 +3396,7 @@ async function runWikiGenerate(input = { model: "configured-clio-target" }) {
|
|
|
2952
3396
|
message: `assembled ${report.pages.length} page${report.pages.length === 1 ? "" : "s"}`,
|
|
2953
3397
|
detail: `${report.repaired} repaired; ${report.issues.length} unresolved reference${report.issues.length === 1 ? "" : "s"}` + (report.dropped.length > 0 ? `; ${report.dropped.length} empty page dropped` : "") + (pendingCount > 0 ? `; ${pendingCount} page${pendingCount === 1 ? "" : "s"} still to write` : "")
|
|
2954
3398
|
});
|
|
2955
|
-
rmSync3(
|
|
3399
|
+
rmSync3(join9(staging.dir, WIKI_PLAN_FILE), { force: true });
|
|
2956
3400
|
const afterHash = computeWikiContentHashOfDir(staging.dir);
|
|
2957
3401
|
const stagedPages = listWikiPagesInDir(staging.dir);
|
|
2958
3402
|
const problems = report.issues.map((issue) => `${issue.page} has an unresolved ${issue.kind}: ${issue.reference}`);
|
|
@@ -3035,7 +3479,7 @@ function curateClioMd(cwd, codewiki) {
|
|
|
3035
3479
|
});
|
|
3036
3480
|
if (!changed) return "unchanged";
|
|
3037
3481
|
writeFileSync3(
|
|
3038
|
-
|
|
3482
|
+
join10(cwd, "CLIO-CODER.md"),
|
|
3039
3483
|
serializeClioMd({
|
|
3040
3484
|
projectName: handbook.projectName,
|
|
3041
3485
|
identity: handbook.identity,
|
|
@@ -3070,23 +3514,30 @@ async function runContextRefresh(input = {}) {
|
|
|
3070
3514
|
const projectType = prev?.projectType ?? detectProjectType(cwd);
|
|
3071
3515
|
const indexedAt = now().toISOString();
|
|
3072
3516
|
input.onProgress?.({ phase: "codewiki", status: "started", message: "rebuilding codewiki" });
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
const
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3517
|
+
let fingerprint;
|
|
3518
|
+
let clioMd = "absent";
|
|
3519
|
+
const coordinated = await coordinateCodewikiWrite(cwd, () => ({ kind: "build", cwd, language: projectType }), {
|
|
3520
|
+
afterCommit: (result, workspace) => {
|
|
3521
|
+
fingerprint = result.fingerprint;
|
|
3522
|
+
clioMd = curateClioMd(workspace, result.codewiki);
|
|
3523
|
+
input.onProgress?.({ phase: "state", status: "running", message: "writing state" });
|
|
3524
|
+
const latest = readClioState(workspace);
|
|
3525
|
+
writeClioState(workspace, {
|
|
3526
|
+
version: 1,
|
|
3527
|
+
projectType,
|
|
3528
|
+
fingerprint: result.fingerprint,
|
|
3529
|
+
codewikiVersion: result.codewiki.version,
|
|
3530
|
+
...latest?.contextSources ? { contextSources: latest.contextSources } : {},
|
|
3531
|
+
...latest?.contextSourceHash ? { contextSourceHash: latest.contextSourceHash } : {},
|
|
3532
|
+
...latest?.lastBootstrap ? { lastBootstrap: latest.lastBootstrap } : {},
|
|
3533
|
+
...latest?.lastInitAt ? { lastInitAt: latest.lastInitAt } : {},
|
|
3534
|
+
lastSessionAt: latest?.lastSessionAt ?? indexedAt,
|
|
3535
|
+
lastIndexedAt: indexedAt
|
|
3536
|
+
});
|
|
3537
|
+
}
|
|
3089
3538
|
});
|
|
3539
|
+
if (!coordinated || !fingerprint) throw new Error("codewiki refresh transaction did not commit");
|
|
3540
|
+
const codewiki = coordinated.codewiki;
|
|
3090
3541
|
const entries = indexedSourceFileCount3(codewiki);
|
|
3091
3542
|
let wikiResult;
|
|
3092
3543
|
let hint;
|
|
@@ -3103,7 +3554,8 @@ async function runContextRefresh(input = {}) {
|
|
|
3103
3554
|
} else if (hasWiki) {
|
|
3104
3555
|
hint = incompleteWikiHint(cwd) ?? (wikiStaleness(cwd).state === "stale" ? STALE_WIKI_REFRESH_HINT : void 0);
|
|
3105
3556
|
}
|
|
3106
|
-
const
|
|
3557
|
+
const committedClioMd = clioMd;
|
|
3558
|
+
const handbookNote = committedClioMd === "updated" ? "; CLIO-CODER.md index sections updated" : "";
|
|
3107
3559
|
input.io?.stdout(
|
|
3108
3560
|
`clio-coder context refresh: codewiki rebuilt (${entries} source file${entries === 1 ? "" : "s"})${handbookNote}
|
|
3109
3561
|
`
|
|
@@ -3113,17 +3565,23 @@ async function runContextRefresh(input = {}) {
|
|
|
3113
3565
|
action: "refreshed",
|
|
3114
3566
|
codewikiEntries: entries,
|
|
3115
3567
|
fingerprint,
|
|
3116
|
-
clioMd,
|
|
3568
|
+
clioMd: committedClioMd,
|
|
3117
3569
|
...wikiResult ? { wiki: wikiResult } : {},
|
|
3118
3570
|
...hint ? { hint } : {}
|
|
3119
3571
|
};
|
|
3120
3572
|
}
|
|
3121
3573
|
|
|
3574
|
+
// src/domains/context/runtime.ts
|
|
3575
|
+
init_esm_shims();
|
|
3576
|
+
|
|
3122
3577
|
// src/domains/context/extension.ts
|
|
3123
|
-
|
|
3578
|
+
init_esm_shims();
|
|
3579
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
3580
|
+
import { isAbsolute, join as join11, relative as relative4, resolve as resolve3 } from "node:path";
|
|
3581
|
+
function persistState(cwd, fingerprint, indexedAt, prev, codewikiVersion, projectType) {
|
|
3124
3582
|
writeClioState(cwd, {
|
|
3125
3583
|
version: 1,
|
|
3126
|
-
projectType: prev?.projectType ??
|
|
3584
|
+
projectType: prev?.projectType ?? projectType,
|
|
3127
3585
|
fingerprint,
|
|
3128
3586
|
codewikiVersion,
|
|
3129
3587
|
...prev?.contextSources ? { contextSources: prev.contextSources } : {},
|
|
@@ -3137,23 +3595,26 @@ function persistState(cwd, fingerprint, indexedAt, prev, codewikiVersion) {
|
|
|
3137
3595
|
async function ensureCodewikiFresh(cwd) {
|
|
3138
3596
|
if (process.env.CLIO_CODER_BOOTSTRAP_GENERATE_CHILD === "1") return;
|
|
3139
3597
|
const state = readClioState(cwd);
|
|
3140
|
-
if (!state && !
|
|
3141
|
-
const slicer = createSlicer();
|
|
3142
|
-
const codewiki = await readCodewikiAsync(cwd);
|
|
3143
|
-
const fingerprint = await computeFingerprintAsync(cwd, codewiki, { slicer });
|
|
3144
|
-
const stale = !state || isStale(state.fingerprint, fingerprint) || !existsSync7(codewikiPath(cwd)) || !codewiki || codewikiNeedsBackfill(codewiki);
|
|
3145
|
-
if (!stale) return;
|
|
3598
|
+
if (!state && !existsSync8(codewikiPath(cwd))) return;
|
|
3146
3599
|
const indexedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3600
|
+
await coordinateCodewikiWrite(
|
|
3601
|
+
cwd,
|
|
3602
|
+
(current, workspace) => {
|
|
3603
|
+
const language = readClioState(workspace)?.projectType ?? current?.language;
|
|
3604
|
+
return {
|
|
3605
|
+
kind: "ensure",
|
|
3606
|
+
cwd,
|
|
3607
|
+
...language ? { language } : {},
|
|
3608
|
+
current,
|
|
3609
|
+
previous: readClioState(workspace)?.fingerprint ?? null
|
|
3610
|
+
};
|
|
3611
|
+
},
|
|
3612
|
+
{
|
|
3613
|
+
afterCommit: ({ codewiki, fingerprint }, workspace) => persistState(workspace, fingerprint, indexedAt, readClioState(workspace), codewiki.version, codewiki.language)
|
|
3614
|
+
}
|
|
3615
|
+
);
|
|
3151
3616
|
}
|
|
3152
3617
|
var CONTEXT_STATE_CACHE_TTL_MS = 1500;
|
|
3153
|
-
var CODEWIKI_CACHE_LIMIT = 4;
|
|
3154
|
-
function codewikiContentHash(raw) {
|
|
3155
|
-
return createHash2("sha256").update(raw).digest("hex");
|
|
3156
|
-
}
|
|
3157
3618
|
function memoryCount() {
|
|
3158
3619
|
try {
|
|
3159
3620
|
return loadMemoryRecordsSync(clioDataDir()).length;
|
|
@@ -3162,11 +3623,12 @@ function memoryCount() {
|
|
|
3162
3623
|
}
|
|
3163
3624
|
}
|
|
3164
3625
|
function resolveClioMdState(cwd) {
|
|
3165
|
-
const clio =
|
|
3166
|
-
if (
|
|
3167
|
-
if (
|
|
3626
|
+
const clio = loadProjectClioMd(cwd);
|
|
3627
|
+
if (clio.files.length === 0 && clio.errors.length === 0) return "none";
|
|
3628
|
+
if (clio.errors.length > 0) return "malformed";
|
|
3168
3629
|
const state = readClioState(cwd);
|
|
3169
|
-
|
|
3630
|
+
const localStandardIsEffective = clio.files.some((file) => file.path === join11(resolve3(cwd), "CLIO-CODER.md"));
|
|
3631
|
+
if (localStandardIsEffective && state?.contextSources !== void 0 && adoptionSourcesChanged(state.contextSources, { cwd })) {
|
|
3170
3632
|
return "stale";
|
|
3171
3633
|
}
|
|
3172
3634
|
return "ok";
|
|
@@ -3195,12 +3657,12 @@ function collectStartupHints(cwd, options = {}) {
|
|
|
3195
3657
|
} catch {
|
|
3196
3658
|
projectType = "unknown";
|
|
3197
3659
|
}
|
|
3198
|
-
const clio =
|
|
3199
|
-
if (
|
|
3660
|
+
const clio = loadProjectClioMd(cwd);
|
|
3661
|
+
if (clio.files.length === 0 && clio.errors.length === 0 && projectType !== "unknown" && options.noContextFiles !== true) {
|
|
3200
3662
|
hints.push("clio: No CLIO-CODER.md detected. Run /context init to explore the repo and bootstrap context.");
|
|
3201
3663
|
}
|
|
3202
|
-
|
|
3203
|
-
hints.push(`clio: malformed
|
|
3664
|
+
for (const issue of clio.errors) {
|
|
3665
|
+
hints.push(`clio: malformed ${issue.path} ignored: ${issue.error}`);
|
|
3204
3666
|
}
|
|
3205
3667
|
const state = readClioState(cwd);
|
|
3206
3668
|
if (!state) return hints;
|
|
@@ -3211,44 +3673,9 @@ function collectStartupHints(cwd, options = {}) {
|
|
|
3211
3673
|
}
|
|
3212
3674
|
function createContextBundle(_context, options = {}) {
|
|
3213
3675
|
let lastCwd = process.cwd();
|
|
3676
|
+
let stopping = false;
|
|
3214
3677
|
let startupHints = [];
|
|
3215
3678
|
const contextState = createContextStateReader();
|
|
3216
|
-
const codewikiCache = /* @__PURE__ */ new Map();
|
|
3217
|
-
const rememberCodewiki = (cwd, hash, codewiki) => {
|
|
3218
|
-
codewikiCache.delete(cwd);
|
|
3219
|
-
codewikiCache.set(cwd, { hash, codewiki });
|
|
3220
|
-
while (codewikiCache.size > CODEWIKI_CACHE_LIMIT) {
|
|
3221
|
-
const oldest = codewikiCache.keys().next().value;
|
|
3222
|
-
if (oldest === void 0) break;
|
|
3223
|
-
codewikiCache.delete(oldest);
|
|
3224
|
-
}
|
|
3225
|
-
};
|
|
3226
|
-
const readCachedCodewiki = (cwd) => {
|
|
3227
|
-
let raw;
|
|
3228
|
-
try {
|
|
3229
|
-
raw = readFileSync7(codewikiPath(cwd), "utf8");
|
|
3230
|
-
} catch {
|
|
3231
|
-
codewikiCache.delete(cwd);
|
|
3232
|
-
return null;
|
|
3233
|
-
}
|
|
3234
|
-
const hash = codewikiContentHash(raw);
|
|
3235
|
-
const cached = codewikiCache.get(cwd);
|
|
3236
|
-
if (cached && cached.hash === hash) {
|
|
3237
|
-
rememberCodewiki(cwd, hash, cached.codewiki);
|
|
3238
|
-
return cached.codewiki;
|
|
3239
|
-
}
|
|
3240
|
-
const codewiki = parseCodewikiRaw(raw);
|
|
3241
|
-
if (!codewiki) {
|
|
3242
|
-
codewikiCache.delete(cwd);
|
|
3243
|
-
return null;
|
|
3244
|
-
}
|
|
3245
|
-
rememberCodewiki(cwd, hash, codewiki);
|
|
3246
|
-
return codewiki;
|
|
3247
|
-
};
|
|
3248
|
-
const writeCachedCodewiki = (cwd, codewiki) => {
|
|
3249
|
-
const serialized = writeCodewiki(cwd, codewiki);
|
|
3250
|
-
rememberCodewiki(cwd, codewikiContentHash(serialized), codewiki);
|
|
3251
|
-
};
|
|
3252
3679
|
const onStart = () => {
|
|
3253
3680
|
lastCwd = process.cwd();
|
|
3254
3681
|
void ensureCodewikiFresh(lastCwd).catch(() => {
|
|
@@ -3260,23 +3687,30 @@ function createContextBundle(_context, options = {}) {
|
|
|
3260
3687
|
};
|
|
3261
3688
|
let incrementalQueue = Promise.resolve();
|
|
3262
3689
|
const noteFileChanges = (paths, cwd = lastCwd) => {
|
|
3690
|
+
if (stopping) return;
|
|
3691
|
+
const workspace = resolve3(cwd);
|
|
3263
3692
|
incrementalQueue = incrementalQueue.then(async () => {
|
|
3264
3693
|
if (paths.length === 0) return;
|
|
3265
|
-
const
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3694
|
+
const rel = paths.map((p) => isAbsolute(p) ? relative4(workspace, p) : p).filter((p) => p.length > 0 && !p.startsWith(".."));
|
|
3695
|
+
await coordinateCodewikiWrite(
|
|
3696
|
+
workspace,
|
|
3697
|
+
(current) => current ? { kind: "incremental", cwd: workspace, current, paths: rel } : null,
|
|
3698
|
+
{
|
|
3699
|
+
requireExisting: true,
|
|
3700
|
+
afterCommit: ({ codewiki, fingerprint, changed }, committedWorkspace) => {
|
|
3701
|
+
if (!changed) return;
|
|
3702
|
+
persistState(
|
|
3703
|
+
committedWorkspace,
|
|
3704
|
+
fingerprint,
|
|
3705
|
+
(/* @__PURE__ */ new Date()).toISOString(),
|
|
3706
|
+
readClioState(committedWorkspace),
|
|
3707
|
+
codewiki.version,
|
|
3708
|
+
codewiki.language
|
|
3709
|
+
);
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
);
|
|
3713
|
+
contextState.invalidate(workspace);
|
|
3280
3714
|
}).catch(() => {
|
|
3281
3715
|
});
|
|
3282
3716
|
};
|
|
@@ -3286,33 +3720,13 @@ function createContextBundle(_context, options = {}) {
|
|
|
3286
3720
|
unsubscribeSessionStart = _context.bus.on(BusChannels.SessionStart, onStart);
|
|
3287
3721
|
},
|
|
3288
3722
|
async stop() {
|
|
3723
|
+
stopping = true;
|
|
3289
3724
|
unsubscribeSessionStart?.();
|
|
3290
3725
|
unsubscribeSessionStart = null;
|
|
3291
|
-
await incrementalQueue;
|
|
3292
|
-
const slicer = createSlicer();
|
|
3293
|
-
const projectType = detectProjectType(lastCwd);
|
|
3726
|
+
await Promise.all([incrementalQueue, drainCodewikiWrites(lastCwd)]);
|
|
3294
3727
|
const state = readClioState(lastCwd);
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
let lastIndexedAt = state?.lastIndexedAt;
|
|
3298
|
-
if (!state || isStale(state.fingerprint, fingerprint) || !codewiki || codewikiNeedsBackfill(codewiki)) {
|
|
3299
|
-
lastIndexedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3300
|
-
codewiki = codewiki ? await syncCodewiki(lastCwd, codewiki, { slicer }) : await buildCodewiki({ cwd: lastCwd, language: projectType, generatedAt: lastIndexedAt }, { slicer });
|
|
3301
|
-
writeCachedCodewiki(lastCwd, codewiki);
|
|
3302
|
-
fingerprint = await computeFingerprintAsync(lastCwd, codewiki, { slicer });
|
|
3303
|
-
}
|
|
3304
|
-
writeClioState(lastCwd, {
|
|
3305
|
-
version: 1,
|
|
3306
|
-
projectType,
|
|
3307
|
-
fingerprint,
|
|
3308
|
-
...codewiki ? { codewikiVersion: codewiki.version } : {},
|
|
3309
|
-
...state?.contextSources ? { contextSources: state.contextSources } : {},
|
|
3310
|
-
...state?.contextSourceHash ? { contextSourceHash: state.contextSourceHash } : {},
|
|
3311
|
-
...state?.lastBootstrap ? { lastBootstrap: state.lastBootstrap } : {},
|
|
3312
|
-
...state?.lastInitAt ? { lastInitAt: state.lastInitAt } : {},
|
|
3313
|
-
lastSessionAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3314
|
-
...lastIndexedAt ? { lastIndexedAt } : {}
|
|
3315
|
-
});
|
|
3728
|
+
if (!state) return;
|
|
3729
|
+
writeClioState(lastCwd, { ...state, lastSessionAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
3316
3730
|
}
|
|
3317
3731
|
};
|
|
3318
3732
|
const contract = {
|
|
@@ -3403,16 +3817,13 @@ function createContextBundle(_context, options = {}) {
|
|
|
3403
3817
|
},
|
|
3404
3818
|
renderPromptContext,
|
|
3405
3819
|
projectStructuredContext(cwd = process.cwd()) {
|
|
3406
|
-
const clio =
|
|
3407
|
-
if (!clio
|
|
3408
|
-
const
|
|
3409
|
-
(section) => section.title.toLowerCase() === "verification expectations"
|
|
3410
|
-
);
|
|
3411
|
-
const verificationBody = verification?.body.trim() ?? "";
|
|
3820
|
+
const clio = loadProjectClioMd(cwd).value;
|
|
3821
|
+
if (!clio) return null;
|
|
3822
|
+
const verificationBody = clio.sections.filter((section) => section.title.toLowerCase() === "verification expectations").map((section) => section.body.trim()).filter((body) => body.length > 0).join("\n\n");
|
|
3412
3823
|
return {
|
|
3413
|
-
projectName: clio.
|
|
3414
|
-
conventions: [...clio.
|
|
3415
|
-
invariants: [...clio.
|
|
3824
|
+
projectName: clio.projectName,
|
|
3825
|
+
conventions: [...clio.conventions],
|
|
3826
|
+
invariants: [...clio.invariants],
|
|
3416
3827
|
...verificationBody.length > 0 ? { verificationExpectations: verificationBody } : {}
|
|
3417
3828
|
};
|
|
3418
3829
|
},
|
|
@@ -3424,266 +3835,134 @@ function createContextBundle(_context, options = {}) {
|
|
|
3424
3835
|
}
|
|
3425
3836
|
|
|
3426
3837
|
// src/domains/context/manifest.ts
|
|
3838
|
+
init_esm_shims();
|
|
3427
3839
|
var ContextManifest = {
|
|
3428
3840
|
name: "context",
|
|
3429
3841
|
dependsOn: ["resources"]
|
|
3430
3842
|
};
|
|
3431
3843
|
|
|
3432
|
-
// src/domains/context/
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
function isRecord2(value) {
|
|
3443
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3444
|
-
}
|
|
3445
|
-
function readEnum(value, allowed, field, issues) {
|
|
3446
|
-
if (value === void 0) return void 0;
|
|
3447
|
-
if (typeof value === "string" && allowed.includes(value)) return value;
|
|
3448
|
-
issues.push(`${field} must be one of ${allowed.join(", ")}`);
|
|
3449
|
-
return void 0;
|
|
3450
|
-
}
|
|
3451
|
-
function readProfileBlob(value, issues) {
|
|
3452
|
-
if (!isRecord2(value)) {
|
|
3453
|
-
if (value !== null && value !== void 0) issues.push("profile must be a mapping at the root");
|
|
3454
|
-
return {};
|
|
3455
|
-
}
|
|
3456
|
-
const profile = {};
|
|
3457
|
-
const posture = readEnum(value.responsePosture, RESPONSE_POSTURES, "responsePosture", issues);
|
|
3458
|
-
if (posture) profile.responsePosture = posture;
|
|
3459
|
-
const validation = readEnum(value.validationPreference, VALIDATION_PREFERENCES, "validationPreference", issues);
|
|
3460
|
-
if (validation) profile.validationPreference = validation;
|
|
3461
|
-
const commit = readEnum(value.commitMessageStyle, COMMIT_MESSAGE_STYLES, "commitMessageStyle", issues);
|
|
3462
|
-
if (commit) profile.commitMessageStyle = commit;
|
|
3463
|
-
if (value.localOnlyPaths !== void 0) {
|
|
3464
|
-
if (Array.isArray(value.localOnlyPaths)) {
|
|
3465
|
-
const paths = value.localOnlyPaths.filter((item) => typeof item === "string" && item.length > 0);
|
|
3466
|
-
if (paths.length > 0) profile.localOnlyPaths = paths.slice(0, OPERATOR_PROFILE_MAX_LOCAL_PATHS);
|
|
3467
|
-
} else {
|
|
3468
|
-
issues.push("localOnlyPaths must be an array of strings");
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
return profile;
|
|
3472
|
-
}
|
|
3473
|
-
function readProfileFile(path, issues) {
|
|
3474
|
-
if (!existsSync8(path)) return { profile: {}, present: false };
|
|
3475
|
-
try {
|
|
3476
|
-
return { profile: readProfileBlob(parseYaml2(readFileSync8(path, "utf8")), issues), present: true };
|
|
3477
|
-
} catch (err) {
|
|
3478
|
-
issues.push(`${path}: invalid YAML: ${err instanceof Error ? err.message : String(err)}`);
|
|
3479
|
-
return { profile: {}, present: false };
|
|
3480
|
-
}
|
|
3481
|
-
}
|
|
3482
|
-
function loadOperatorProfile(cwd, options = {}) {
|
|
3483
|
-
const issues = [];
|
|
3484
|
-
const userPath = options.userPath ?? join9(resolveClioDirs().config, "profile.yaml");
|
|
3485
|
-
const projectPath = join9(cwd, ".clio-coder", "profile.yaml");
|
|
3486
|
-
const user = readProfileFile(userPath, issues);
|
|
3487
|
-
const project = readProfileFile(projectPath, issues);
|
|
3488
|
-
const profile = { ...user.profile, ...project.profile };
|
|
3489
|
-
let origin = "none";
|
|
3490
|
-
let sourcePath;
|
|
3491
|
-
if (project.present) {
|
|
3492
|
-
origin = "project";
|
|
3493
|
-
sourcePath = projectPath;
|
|
3494
|
-
} else if (user.present) {
|
|
3495
|
-
origin = "user";
|
|
3496
|
-
sourcePath = userPath;
|
|
3497
|
-
}
|
|
3498
|
-
const result = { profile, origin, issues };
|
|
3499
|
-
if (sourcePath !== void 0) {
|
|
3500
|
-
result.sourcePath = sourcePath;
|
|
3501
|
-
result.hash = createHash3("sha256").update(JSON.stringify(profile)).digest("hex").slice(0, 16);
|
|
3502
|
-
}
|
|
3503
|
-
return result;
|
|
3504
|
-
}
|
|
3505
|
-
function renderOperatorProfile(profile) {
|
|
3506
|
-
const lines = [];
|
|
3507
|
-
if (profile.responsePosture) lines.push(`- Response posture: ${profile.responsePosture}.`);
|
|
3508
|
-
if (profile.validationPreference) lines.push(`- Validation preference: ${profile.validationPreference}.`);
|
|
3509
|
-
if (profile.commitMessageStyle) lines.push(`- Commit-message style: ${profile.commitMessageStyle}.`);
|
|
3510
|
-
if (profile.localOnlyPaths && profile.localOnlyPaths.length > 0) {
|
|
3511
|
-
lines.push(`- Keep local-only (do not push or share): ${profile.localOnlyPaths.join(", ")}.`);
|
|
3512
|
-
}
|
|
3513
|
-
if (lines.length === 0) return { text: "", tokenEstimate: 0 };
|
|
3514
|
-
const full = `## Operator profile
|
|
3515
|
-
${lines.join("\n")}`;
|
|
3516
|
-
const text = full.length > OPERATOR_PROFILE_MAX_CHARS ? `${full.slice(0, OPERATOR_PROFILE_MAX_CHARS - 1)}\u2026` : full;
|
|
3517
|
-
return { text, tokenEstimate: ceilChars(text.length) };
|
|
3844
|
+
// src/domains/context/runtime.ts
|
|
3845
|
+
var ContextDomainModule = {
|
|
3846
|
+
manifest: ContextManifest,
|
|
3847
|
+
createExtension: createContextBundle
|
|
3848
|
+
};
|
|
3849
|
+
function createContextDomainModule(options = {}) {
|
|
3850
|
+
return {
|
|
3851
|
+
manifest: ContextManifest,
|
|
3852
|
+
createExtension: (context) => createContextBundle(context, options)
|
|
3853
|
+
};
|
|
3518
3854
|
}
|
|
3519
3855
|
|
|
3520
|
-
// src/domains/context/
|
|
3521
|
-
|
|
3522
|
-
import {
|
|
3523
|
-
import {
|
|
3524
|
-
import {
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3856
|
+
// src/domains/context/wiki/prompts.ts
|
|
3857
|
+
init_esm_shims();
|
|
3858
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
3859
|
+
import { existsSync as existsSync9, realpathSync, statSync as statSync4 } from "node:fs";
|
|
3860
|
+
import { isAbsolute as isAbsolute2, join as join12, relative as relative5 } from "node:path";
|
|
3861
|
+
|
|
3862
|
+
// src/domains/prompts/fragment-loader.ts
|
|
3863
|
+
init_esm_shims();
|
|
3864
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
3865
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync9 } from "node:fs";
|
|
3866
|
+
import path from "node:path";
|
|
3867
|
+
var frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
3868
|
+
var fragmentIdRegex = /^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/;
|
|
3869
|
+
function defaultRootDir() {
|
|
3870
|
+
return path.join(resolvePackageRoot(), "src", "domains", "prompts", "fragments");
|
|
3871
|
+
}
|
|
3872
|
+
function walk(root) {
|
|
3531
3873
|
const out3 = [];
|
|
3532
|
-
for (const item of value) {
|
|
3533
|
-
if (typeof item === "string" && item.length > 0) out3.push(item);
|
|
3534
|
-
}
|
|
3535
|
-
return out3.length > 0 ? out3 : void 0;
|
|
3536
|
-
}
|
|
3537
|
-
function validateGlobArray(value, field, id, issues) {
|
|
3538
|
-
const parsed = readStringArray(value);
|
|
3539
|
-
if (parsed === void 0) {
|
|
3540
|
-
issues.push(`${id}: frontmatter ${field} must be a non-empty string array`);
|
|
3541
|
-
return void 0;
|
|
3542
|
-
}
|
|
3543
|
-
for (const pattern of parsed) {
|
|
3544
|
-
try {
|
|
3545
|
-
compileGlobRegex(pattern);
|
|
3546
|
-
} catch (err) {
|
|
3547
|
-
issues.push(
|
|
3548
|
-
`${id}: invalid ${field} glob ${JSON.stringify(pattern)}: ${err instanceof Error ? err.message : String(err)}`
|
|
3549
|
-
);
|
|
3550
|
-
return void 0;
|
|
3551
|
-
}
|
|
3552
|
-
}
|
|
3553
|
-
return parsed;
|
|
3554
|
-
}
|
|
3555
|
-
function walkMarkdown(dir, root, out3) {
|
|
3556
3874
|
let entries;
|
|
3557
3875
|
try {
|
|
3558
|
-
entries =
|
|
3876
|
+
entries = readdirSync5(root, { withFileTypes: true });
|
|
3559
3877
|
} catch {
|
|
3560
|
-
return;
|
|
3878
|
+
return out3;
|
|
3561
3879
|
}
|
|
3562
3880
|
for (const entry of entries) {
|
|
3563
|
-
const full =
|
|
3564
|
-
if (entry.isDirectory())
|
|
3565
|
-
|
|
3881
|
+
const full = path.join(root, entry.name);
|
|
3882
|
+
if (entry.isDirectory()) {
|
|
3883
|
+
out3.push(...walk(full));
|
|
3884
|
+
continue;
|
|
3885
|
+
}
|
|
3886
|
+
if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
3887
|
+
out3.push(full);
|
|
3888
|
+
}
|
|
3566
3889
|
}
|
|
3890
|
+
return out3.sort((left, right) => left.localeCompare(right));
|
|
3567
3891
|
}
|
|
3568
|
-
function
|
|
3569
|
-
|
|
3892
|
+
function parseFragment(filePath, rootDir) {
|
|
3893
|
+
const raw = readFileSync9(filePath, "utf8");
|
|
3894
|
+
const rawRel = path.relative(rootDir, filePath);
|
|
3895
|
+
const relPath = rawRel.split(path.sep).join("/");
|
|
3896
|
+
const match = raw.match(frontmatterRegex);
|
|
3897
|
+
if (!match) {
|
|
3898
|
+
throw new Error(`fragment-loader: ${relPath}: missing or malformed YAML frontmatter`);
|
|
3899
|
+
}
|
|
3900
|
+
const frontmatterText = match[1] ?? "";
|
|
3901
|
+
const body = match[2] ?? "";
|
|
3902
|
+
let parsed;
|
|
3570
3903
|
try {
|
|
3571
|
-
|
|
3904
|
+
parsed = import_yaml4.default.parse(frontmatterText);
|
|
3572
3905
|
} catch (err) {
|
|
3573
|
-
|
|
3574
|
-
|
|
3906
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
3907
|
+
throw new Error(`fragment-loader: ${relPath}: invalid YAML frontmatter (${reason})`);
|
|
3575
3908
|
}
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
let paths;
|
|
3579
|
-
let excludes = [];
|
|
3580
|
-
let enabled = true;
|
|
3581
|
-
let description2;
|
|
3582
|
-
let invalidFrontmatter = false;
|
|
3583
|
-
const match = FRONTMATTER_RE.exec(text);
|
|
3584
|
-
if (match) {
|
|
3585
|
-
body = text.slice(match[0].length);
|
|
3586
|
-
try {
|
|
3587
|
-
const front = parseYaml3(match[1] ?? "");
|
|
3588
|
-
if (isRecord3(front)) {
|
|
3589
|
-
if (Object.hasOwn(front, "paths")) {
|
|
3590
|
-
const parsedPaths = validateGlobArray(front.paths, "paths", id, issues);
|
|
3591
|
-
if (parsedPaths === void 0) invalidFrontmatter = true;
|
|
3592
|
-
else paths = parsedPaths;
|
|
3593
|
-
}
|
|
3594
|
-
if (Object.hasOwn(front, "excludes")) {
|
|
3595
|
-
const parsedExcludes = validateGlobArray(front.excludes, "excludes", id, issues);
|
|
3596
|
-
if (parsedExcludes === void 0) invalidFrontmatter = true;
|
|
3597
|
-
else excludes = parsedExcludes;
|
|
3598
|
-
}
|
|
3599
|
-
if (Object.hasOwn(front, "enabled")) {
|
|
3600
|
-
if (typeof front.enabled === "boolean") enabled = front.enabled;
|
|
3601
|
-
else {
|
|
3602
|
-
issues.push(`${id}: frontmatter enabled must be a boolean`);
|
|
3603
|
-
invalidFrontmatter = true;
|
|
3604
|
-
}
|
|
3605
|
-
}
|
|
3606
|
-
if (Object.hasOwn(front, "description")) {
|
|
3607
|
-
if (typeof front.description === "string") description2 = front.description;
|
|
3608
|
-
else {
|
|
3609
|
-
issues.push(`${id}: frontmatter description must be a string`);
|
|
3610
|
-
invalidFrontmatter = true;
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
3613
|
-
} else if (front !== null && front !== void 0) {
|
|
3614
|
-
issues.push(`${id}: frontmatter must be a mapping`);
|
|
3615
|
-
invalidFrontmatter = true;
|
|
3616
|
-
}
|
|
3617
|
-
} catch (err) {
|
|
3618
|
-
issues.push(`${id}: invalid frontmatter: ${err instanceof Error ? err.message : String(err)}`);
|
|
3619
|
-
invalidFrontmatter = true;
|
|
3620
|
-
}
|
|
3621
|
-
} else if (text.startsWith("---\n")) {
|
|
3622
|
-
issues.push(`${id}: invalid frontmatter: missing closing marker`);
|
|
3623
|
-
invalidFrontmatter = true;
|
|
3909
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
3910
|
+
throw new Error(`fragment-loader: ${relPath}: frontmatter must be a YAML object`);
|
|
3624
3911
|
}
|
|
3625
|
-
|
|
3626
|
-
const
|
|
3627
|
-
|
|
3628
|
-
|
|
3912
|
+
const fm = parsed;
|
|
3913
|
+
const id = fm.id;
|
|
3914
|
+
if (typeof id !== "string" || !fragmentIdRegex.test(id)) {
|
|
3915
|
+
throw new Error(`fragment-loader: ${relPath}: frontmatter.id must be a dot-separated namespace`);
|
|
3916
|
+
}
|
|
3917
|
+
const version = fm.version;
|
|
3918
|
+
if (version !== 1) {
|
|
3919
|
+
throw new Error(`fragment-loader: ${relPath}: frontmatter.version must be 1`);
|
|
3920
|
+
}
|
|
3921
|
+
const description2 = fm.description;
|
|
3922
|
+
if (typeof description2 !== "string" || description2.trim() === "") {
|
|
3923
|
+
throw new Error(`fragment-loader: ${relPath}: frontmatter.description must be a non-empty string`);
|
|
3924
|
+
}
|
|
3925
|
+
const dynamicRaw = fm.dynamic;
|
|
3926
|
+
if (dynamicRaw !== void 0 && typeof dynamicRaw !== "boolean") {
|
|
3927
|
+
throw new Error(`fragment-loader: ${relPath}: frontmatter.dynamic must be a boolean when present`);
|
|
3928
|
+
}
|
|
3929
|
+
return {
|
|
3930
|
+
path: filePath,
|
|
3931
|
+
relPath,
|
|
3629
3932
|
id,
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3933
|
+
version,
|
|
3934
|
+
description: description2,
|
|
3935
|
+
dynamic: dynamicRaw === true,
|
|
3936
|
+
body,
|
|
3937
|
+
contentHash: sha256(raw)
|
|
3635
3938
|
};
|
|
3636
|
-
if (paths !== void 0) rule.paths = paths;
|
|
3637
|
-
if (description2 !== void 0) rule.description = description2;
|
|
3638
|
-
return { rule, excludes };
|
|
3639
3939
|
}
|
|
3640
|
-
function
|
|
3641
|
-
const
|
|
3642
|
-
const
|
|
3643
|
-
const files =
|
|
3644
|
-
|
|
3645
|
-
files.sort();
|
|
3646
|
-
const rules = [];
|
|
3647
|
-
const excludeSet = /* @__PURE__ */ new Set();
|
|
3940
|
+
function loadFragments(options) {
|
|
3941
|
+
const rootDir = typeof options === "string" ? options : options?.rootDir;
|
|
3942
|
+
const resolvedRoot = rootDir ? path.resolve(rootDir) : defaultRootDir();
|
|
3943
|
+
const files = walk(resolvedRoot);
|
|
3944
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3648
3945
|
for (const file of files) {
|
|
3649
|
-
const
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
}
|
|
3656
|
-
function ruleMatchesAnyPath(rule, workingPaths) {
|
|
3657
|
-
for (const pattern of rule.paths ?? []) {
|
|
3658
|
-
let regex;
|
|
3659
|
-
try {
|
|
3660
|
-
regex = compileGlobRegex(pattern);
|
|
3661
|
-
} catch {
|
|
3662
|
-
continue;
|
|
3663
|
-
}
|
|
3664
|
-
for (const path of workingPaths) {
|
|
3665
|
-
if (regex.test(normalizeGlobInput(path))) return true;
|
|
3946
|
+
const fragment = parseFragment(file, resolvedRoot);
|
|
3947
|
+
const existing = byId.get(fragment.id);
|
|
3948
|
+
if (existing) {
|
|
3949
|
+
throw new Error(
|
|
3950
|
+
`fragment-loader: duplicate fragment id "${fragment.id}" in ${existing.relPath} and ${fragment.relPath}`
|
|
3951
|
+
);
|
|
3666
3952
|
}
|
|
3953
|
+
byId.set(fragment.id, fragment);
|
|
3667
3954
|
}
|
|
3668
|
-
return
|
|
3669
|
-
}
|
|
3670
|
-
function selectActiveRules(rules, workingContextPaths) {
|
|
3671
|
-
return rules.filter((rule) => {
|
|
3672
|
-
if (!rule.enabled) return false;
|
|
3673
|
-
if (rule.paths === void 0) return true;
|
|
3674
|
-
return ruleMatchesAnyPath(rule, workingContextPaths);
|
|
3675
|
-
});
|
|
3955
|
+
return { byId, rootDir: resolvedRoot };
|
|
3676
3956
|
}
|
|
3677
3957
|
|
|
3678
3958
|
// src/domains/context/wiki/prompts.ts
|
|
3679
|
-
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
3680
|
-
import { existsSync as existsSync9, readFileSync as readFileSync10, realpathSync, statSync as statSync3 } from "node:fs";
|
|
3681
|
-
import { isAbsolute as isAbsolute2, join as join11, relative as relative5 } from "node:path";
|
|
3682
|
-
function fragmentPath(fragment) {
|
|
3683
|
-
return join11(resolvePackageRoot(), "src", "domains", "prompts", "fragments", "wiki", `${fragment}.md`);
|
|
3684
|
-
}
|
|
3685
3959
|
function readWikiFragment(fragment, substitutions) {
|
|
3686
|
-
|
|
3960
|
+
const id = `wiki.${fragment}`;
|
|
3961
|
+
const loaded = loadFragments().byId.get(id);
|
|
3962
|
+
if (!loaded) {
|
|
3963
|
+
throw new Error(`context/wiki: fragment "${id}" not found; check prompts/fragments/wiki/${fragment}.md frontmatter`);
|
|
3964
|
+
}
|
|
3965
|
+
let text = loaded.body.trim();
|
|
3687
3966
|
for (const [token, value] of Object.entries(substitutions)) {
|
|
3688
3967
|
text = text.split(`{{${token}}}`).join(value);
|
|
3689
3968
|
}
|
|
@@ -3713,11 +3992,11 @@ function repositoryGuidancePaths(cwd) {
|
|
|
3713
3992
|
const seen = /* @__PURE__ */ new Set();
|
|
3714
3993
|
const paths = [];
|
|
3715
3994
|
for (const relPath of REPOSITORY_GUIDANCE_CANDIDATES) {
|
|
3716
|
-
const absPath =
|
|
3995
|
+
const absPath = join12(cwd, relPath);
|
|
3717
3996
|
if (!existsSync9(absPath)) continue;
|
|
3718
3997
|
try {
|
|
3719
3998
|
const resolved = realpathSync(absPath);
|
|
3720
|
-
const stat =
|
|
3999
|
+
const stat = statSync4(resolved);
|
|
3721
4000
|
if (!isWithin(root, resolved) || !stat.isFile() || stat.size === 0 || seen.has(resolved)) continue;
|
|
3722
4001
|
seen.add(resolved);
|
|
3723
4002
|
paths.push(relPath);
|
|
@@ -3733,7 +4012,7 @@ function repositoryGuidance(cwd) {
|
|
|
3733
4012
|
}
|
|
3734
4013
|
return [
|
|
3735
4014
|
"Read every detected instruction file before drafting:",
|
|
3736
|
-
...paths.map((
|
|
4015
|
+
...paths.map((path2) => `- ${path2}`),
|
|
3737
4016
|
"Treat these files as repository instructions, not implementation proof. If one designates a planning, specification, or engineering-truth authority, read that authority before making status claims, then verify mutable implementation claims against live source, configuration, and tests."
|
|
3738
4017
|
].join("\n");
|
|
3739
4018
|
}
|
|
@@ -3784,7 +4063,7 @@ function buildWikiPlanPrompt(input) {
|
|
|
3784
4063
|
const plan = input.plan ?? generation.plan;
|
|
3785
4064
|
const unclaimed = input.unclaimedAreas ?? [];
|
|
3786
4065
|
const sections = [
|
|
3787
|
-
readWikiFragment("plan", { planPath:
|
|
4066
|
+
readWikiFragment("plan", { planPath: join12(input.outputDir, WIKI_PLAN_FILE) }),
|
|
3788
4067
|
"## Repository scale",
|
|
3789
4068
|
`${generation.sourceFiles} indexed source files, ${generation.sourceLines} source lines, decomposed at ${generation.depth} depth into ${generation.plan.pages.length} candidate pages.`,
|
|
3790
4069
|
"## Candidate plan",
|
|
@@ -3834,7 +4113,7 @@ function buildWikiPagePrompt(input) {
|
|
|
3834
4113
|
const siblingLines = input.siblings.filter((sibling) => sibling.path !== page.path).map((sibling) => `- ${sibling.path} \u2014 ${sibling.title}`);
|
|
3835
4114
|
const sections = [
|
|
3836
4115
|
readWikiFragment("page", {
|
|
3837
|
-
pagePath:
|
|
4116
|
+
pagePath: join12(input.outputDir, page.path),
|
|
3838
4117
|
pageRelPath: page.path,
|
|
3839
4118
|
pageTitle: page.title
|
|
3840
4119
|
}),
|
|
@@ -3855,25 +4134,13 @@ ${page.sources.map((source) => `- ${source}`).join("\n")}` : "No anchor sources
|
|
|
3855
4134
|
if (input.seeded) {
|
|
3856
4135
|
sections.push(
|
|
3857
4136
|
"## Revision",
|
|
3858
|
-
`A previous version of this page is already at ${
|
|
4137
|
+
`A previous version of this page is already at ${join12(input.outputDir, page.path)}. Read it first and revise it in place. Correct what the current source contradicts and fill what it omits; keep accurate prose as it stands.`
|
|
3859
4138
|
);
|
|
3860
4139
|
}
|
|
3861
4140
|
return `${sections.join("\n\n")}
|
|
3862
4141
|
`;
|
|
3863
4142
|
}
|
|
3864
4143
|
|
|
3865
|
-
// src/domains/context/index.ts
|
|
3866
|
-
var ContextDomainModule = {
|
|
3867
|
-
manifest: ContextManifest,
|
|
3868
|
-
createExtension: createContextBundle
|
|
3869
|
-
};
|
|
3870
|
-
function createContextDomainModule(options = {}) {
|
|
3871
|
-
return {
|
|
3872
|
-
manifest: ContextManifest,
|
|
3873
|
-
createExtension: (context) => createContextBundle(context, options)
|
|
3874
|
-
};
|
|
3875
|
-
}
|
|
3876
|
-
|
|
3877
4144
|
export {
|
|
3878
4145
|
adoptionSnapshotsHash,
|
|
3879
4146
|
scanAgentConfigs,
|
|
@@ -3881,11 +4148,17 @@ export {
|
|
|
3881
4148
|
adoptionSourcesChanged,
|
|
3882
4149
|
parseClioMd,
|
|
3883
4150
|
serializeClioMd,
|
|
4151
|
+
loadProjectClioMd,
|
|
3884
4152
|
tryReadClioMd,
|
|
3885
4153
|
renderPromptContext,
|
|
3886
4154
|
fallbackBootstrapOutput,
|
|
3887
4155
|
runBootstrap,
|
|
3888
4156
|
runContextClear,
|
|
4157
|
+
OPERATOR_PROFILE_MAX_CHARS,
|
|
4158
|
+
loadOperatorProfile,
|
|
4159
|
+
renderOperatorProfile,
|
|
4160
|
+
loadProjectRules,
|
|
4161
|
+
selectActiveRules,
|
|
3889
4162
|
assembleWikiTree,
|
|
3890
4163
|
WIKI_DEPTH_STRATEGY,
|
|
3891
4164
|
pagePathForArea,
|
|
@@ -3893,14 +4166,10 @@ export {
|
|
|
3893
4166
|
planWikiGeneration,
|
|
3894
4167
|
runWikiGenerate,
|
|
3895
4168
|
runContextRefresh,
|
|
3896
|
-
OPERATOR_PROFILE_MAX_CHARS,
|
|
3897
|
-
loadOperatorProfile,
|
|
3898
|
-
renderOperatorProfile,
|
|
3899
|
-
loadProjectRules,
|
|
3900
|
-
selectActiveRules,
|
|
3901
|
-
buildWikiPlanPrompt,
|
|
3902
|
-
buildWikiPagePrompt,
|
|
3903
4169
|
ContextDomainModule,
|
|
3904
|
-
createContextDomainModule
|
|
4170
|
+
createContextDomainModule,
|
|
4171
|
+
loadFragments,
|
|
4172
|
+
buildWikiPlanPrompt,
|
|
4173
|
+
buildWikiPagePrompt
|
|
3905
4174
|
};
|
|
3906
|
-
//# sourceMappingURL=chunk-
|
|
4175
|
+
//# sourceMappingURL=chunk-7EYHLWU7.js.map
|