raga-cli 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/LICENSE +21 -0
- package/README.md +139 -2
- package/bundled-skills/AGENTS.md +5 -0
- package/bundled-skills/README.md +25 -0
- package/bundled-skills/agents/comment-sicko.json +9 -0
- package/bundled-skills/agents/comment-sicko.md +28 -0
- package/bundled-skills/agents/model-roles.json +41 -0
- package/bundled-skills/agents/poteto-agent.json +9 -0
- package/bundled-skills/agents/poteto-agent.md +4 -0
- package/bundled-skills/agents/worker.json +8 -0
- package/bundled-skills/agents/worker.md +1 -0
- package/bundled-skills/bundle.json +1448 -0
- package/bundled-skills/dependencies.json +40 -0
- package/bundled-skills/docs/guide/01-setup.md +3 -0
- package/bundled-skills/docs/guide/02-peak.md +135 -0
- package/bundled-skills/docs/guide/03-understand.md +79 -0
- package/bundled-skills/docs/guide/04-design.md +133 -0
- package/bundled-skills/docs/guide/05-build-and-clean.md +83 -0
- package/bundled-skills/docs/guide/06-verify-and-ship.md +166 -0
- package/bundled-skills/docs/guide/07-overnight.md +118 -0
- package/bundled-skills/docs/guide/08-principles.md +72 -0
- package/bundled-skills/docs/guide/09-make-it-yours.md +96 -0
- package/bundled-skills/docs/guide/10-recipes-and-pitfalls.md +180 -0
- package/bundled-skills/docs/guide/README.md +38 -0
- package/bundled-skills/docs/guide/images/design.jpg +0 -0
- package/bundled-skills/docs/guide/images/overnight.jpg +0 -0
- package/bundled-skills/docs/guide/images/recipes.jpg +0 -0
- package/bundled-skills/docs/guide/images/router.jpg +0 -0
- package/bundled-skills/docs/guide/images/understanding.jpg +0 -0
- package/bundled-skills/docs/guide/images/verification.jpg +0 -0
- package/bundled-skills/licenses/commander +22 -0
- package/bundled-skills/licenses/cursor-team-kit +21 -0
- package/bundled-skills/licenses/no-mistakes +21 -0
- package/bundled-skills/licenses/pstack +21 -0
- package/bundled-skills/skills/peak/SKILL.md +184 -0
- package/bundled-skills/skills/peak/playbooks/authoring-a-skill.md +12 -0
- package/bundled-skills/skills/peak/playbooks/autonomous-run.md +13 -0
- package/bundled-skills/skills/peak/playbooks/autopilot-full.md +25 -0
- package/bundled-skills/skills/peak/playbooks/autopilot-stack.md +12 -0
- package/bundled-skills/skills/peak/playbooks/babysit.md +18 -0
- package/bundled-skills/skills/peak/playbooks/bug-fix.md +15 -0
- package/bundled-skills/skills/peak/playbooks/eval.md +25 -0
- package/bundled-skills/skills/peak/playbooks/feature.md +21 -0
- package/bundled-skills/skills/peak/playbooks/hillclimb.md +21 -0
- package/bundled-skills/skills/peak/playbooks/investigation.md +14 -0
- package/bundled-skills/skills/peak/playbooks/multi-phase-plan.md +155 -0
- package/bundled-skills/skills/peak/playbooks/opening-a-pr.md +34 -0
- package/bundled-skills/skills/peak/playbooks/orchestrate.md +112 -0
- package/bundled-skills/skills/peak/playbooks/pause-safely.md +10 -0
- package/bundled-skills/skills/peak/playbooks/perf-issue.md +25 -0
- package/bundled-skills/skills/peak/playbooks/prototype.md +14 -0
- package/bundled-skills/skills/peak/playbooks/refactoring.md +16 -0
- package/bundled-skills/skills/peak/playbooks/runtime-forensics.md +11 -0
- package/bundled-skills/skills/peak/playbooks/session-pickup.md +11 -0
- package/bundled-skills/skills/peak/playbooks/shipping.md +12 -0
- package/bundled-skills/skills/peak/playbooks/trace-forensics.md +14 -0
- package/bundled-skills/skills/peak/playbooks/visual-parity.md +11 -0
- package/bundled-skills/skills/peak/playbooks/worktree-cleanup.md +6 -0
- package/bundled-skills/skills/peak/references/architect/SKILL.md +81 -0
- package/bundled-skills/skills/peak/references/architect/references/design-red-flags.md +57 -0
- package/bundled-skills/skills/peak/references/architect/references/rationale-template.md +35 -0
- package/bundled-skills/skills/peak/references/architect/references/runner-prompt.md +20 -0
- package/bundled-skills/skills/peak/references/arena/SKILL.md +50 -0
- package/bundled-skills/skills/peak/references/automate-me/SKILL.md +106 -0
- package/bundled-skills/skills/peak/references/benchmark-checklist/SKILL.md +41 -0
- package/bundled-skills/skills/peak/references/blast-radius/SKILL.md +52 -0
- package/bundled-skills/skills/peak/references/bro/SKILL.md +9 -0
- package/bundled-skills/skills/peak/references/control-cli/SKILL.md +111 -0
- package/bundled-skills/skills/peak/references/control-ui/SKILL.md +111 -0
- package/bundled-skills/skills/peak/references/correct/SKILL.md +34 -0
- package/bundled-skills/skills/peak/references/create-formal-verification-skill/SKILL.md +43 -0
- package/bundled-skills/skills/peak/references/create-skill/SKILL.md +14 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/SKILL.md +46 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/references/feature-map-example/README.md +47 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/references/feature-map-example/create-note.md +39 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/references/feature-map-example/search.md +45 -0
- package/bundled-skills/skills/peak/references/deslop/SKILL.md +24 -0
- package/bundled-skills/skills/peak/references/figure-it-out/SKILL.md +54 -0
- package/bundled-skills/skills/peak/references/how/SKILL.md +38 -0
- package/bundled-skills/skills/peak/references/how/references/explainer-prompt.md +55 -0
- package/bundled-skills/skills/peak/references/how/references/explorer-prompt.md +35 -0
- package/bundled-skills/skills/peak/references/in-your-own-words/SKILL.md +9 -0
- package/bundled-skills/skills/peak/references/interrogate/SKILL.md +76 -0
- package/bundled-skills/skills/peak/references/interrogate/references/code-quality-review.md +47 -0
- package/bundled-skills/skills/peak/references/interrogate/references/lead-judgment.md +39 -0
- package/bundled-skills/skills/peak/references/interrogate/references/reviewer-prompt.md +62 -0
- package/bundled-skills/skills/peak/references/interrogate/references/rubric.md +77 -0
- package/bundled-skills/skills/peak/references/ketchup/SKILL.md +45 -0
- package/bundled-skills/skills/peak/references/maintain-formal-verification-skill/SKILL.md +60 -0
- package/bundled-skills/skills/peak/references/maintain-verification-skill/SKILL.md +41 -0
- package/bundled-skills/skills/peak/references/no-comments/SKILL.md +26 -0
- package/bundled-skills/skills/peak/references/no-mistakes/SKILL.md +20 -0
- package/bundled-skills/skills/peak/references/no-mistakes/upstream/SKILL.md +394 -0
- package/bundled-skills/skills/peak/references/peak-setup/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/poteto-help/SKILL.md +16 -0
- package/bundled-skills/skills/peak/references/poteto-help/references/prompting.md +51 -0
- package/bundled-skills/skills/peak/references/poteto-help/references/recipes.md +51 -0
- package/bundled-skills/skills/peak/references/principle-attack-the-premise/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-boundary-discipline/SKILL.md +36 -0
- package/bundled-skills/skills/peak/references/principle-build-the-lever/SKILL.md +25 -0
- package/bundled-skills/skills/peak/references/principle-encode-lessons-in-structure/SKILL.md +13 -0
- package/bundled-skills/skills/peak/references/principle-exhaust-the-design-space/SKILL.md +11 -0
- package/bundled-skills/skills/peak/references/principle-experience-first/SKILL.md +21 -0
- package/bundled-skills/skills/peak/references/principle-explain-the-number/SKILL.md +19 -0
- package/bundled-skills/skills/peak/references/principle-fix-root-causes/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-foundational-thinking/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-guard-the-context-window/SKILL.md +14 -0
- package/bundled-skills/skills/peak/references/principle-laziness-protocol/SKILL.md +12 -0
- package/bundled-skills/skills/peak/references/principle-make-operations-idempotent/SKILL.md +24 -0
- package/bundled-skills/skills/peak/references/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +16 -0
- package/bundled-skills/skills/peak/references/principle-minimize-reader-load/SKILL.md +20 -0
- package/bundled-skills/skills/peak/references/principle-model-the-domain/SKILL.md +26 -0
- package/bundled-skills/skills/peak/references/principle-never-block-on-the-human/SKILL.md +17 -0
- package/bundled-skills/skills/peak/references/principle-outcome-oriented-execution/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-prove-it-works/SKILL.md +24 -0
- package/bundled-skills/skills/peak/references/principle-redesign-from-first-principles/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/principle-separate-before-serializing-shared-state/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/principle-sequence-verifiable-units/SKILL.md +19 -0
- package/bundled-skills/skills/peak/references/principle-subtract-before-you-add/SKILL.md +20 -0
- package/bundled-skills/skills/peak/references/principle-test-behavior-not-implementation/SKILL.md +22 -0
- package/bundled-skills/skills/peak/references/principle-type-system-discipline/SKILL.md +15 -0
- package/bundled-skills/skills/peak/references/raga-runtime/SKILL.md +37 -0
- package/bundled-skills/skills/peak/references/raga-runtime/managed-tools.mjs +34 -0
- package/bundled-skills/skills/peak/references/raga-runtime/raga_runtime.py +44 -0
- package/bundled-skills/skills/peak/references/recall/SKILL.md +37 -0
- package/bundled-skills/skills/peak/references/reflect/SKILL.md +63 -0
- package/bundled-skills/skills/peak/references/reflect/references/divergent-reviewer.md +38 -0
- package/bundled-skills/skills/peak/references/reflect/references/judgment-reviewer.md +37 -0
- package/bundled-skills/skills/peak/references/reflect/references/synthesizer.md +56 -0
- package/bundled-skills/skills/peak/references/reflect/references/tooling-reviewer.md +48 -0
- package/bundled-skills/skills/peak/references/reviewer-triage.md +142 -0
- package/bundled-skills/skills/peak/references/sharpen/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/show-me-your-work/SKILL.md +84 -0
- package/bundled-skills/skills/peak/references/show-me-your-work/references/decision-log-template.tsv +1 -0
- package/bundled-skills/skills/peak/references/show-me-your-work/scripts/log.sh +42 -0
- package/bundled-skills/skills/peak/references/statechart/SKILL.md +38 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/chart-to-tla.mjs +236 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/compare-charts.mjs +104 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/lib.mjs +725 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/model/OutputFolder.cfg +6 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/model/OutputFolder.map.mjs +106 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/model/OutputFolder.tla +176 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/statechart.mjs +749 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/test/statechart.test.mjs +2790 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/test/sync.mmd +19 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/test/upload.mmd +16 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/tlc-to-chart.mjs +1347 -0
- package/bundled-skills/skills/peak/references/swarm/SKILL.md +43 -0
- package/bundled-skills/skills/peak/references/tdd/SKILL.md +44 -0
- package/bundled-skills/skills/peak/references/teach/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/technical-writing/SKILL.md +108 -0
- package/bundled-skills/skills/peak/references/typescript-best-practices/SKILL.md +33 -0
- package/bundled-skills/skills/peak/references/typescript-best-practices/references/patterns.md +328 -0
- package/bundled-skills/skills/peak/references/unslop/SKILL.md +64 -0
- package/bundled-skills/skills/peak/references/verify-this/SKILL.md +76 -0
- package/bundled-skills/skills/peak/references/why/SKILL.md +100 -0
- package/bundled-skills/skills/peak/references/why/references/epistemics.md +71 -0
- package/bundled-skills/skills/peak/references/why/references/investigator-prompt.md +84 -0
- package/bundled-skills/skills/peak/references/why/references/source-playbook.md +17 -0
- package/bundled-skills/skills/peak/references/why/references/sources/code-archaeology.md +51 -0
- package/bundled-skills/skills/peak/references/why/references/sources/databricks.md +70 -0
- package/bundled-skills/skills/peak/references/why/references/sources/datadog.md +97 -0
- package/bundled-skills/skills/peak/references/why/references/sources/incident-postmortem.md +5 -0
- package/bundled-skills/skills/peak/references/why/references/sources/linear.md +48 -0
- package/bundled-skills/skills/peak/references/why/references/sources/notion.md +55 -0
- package/bundled-skills/skills/peak/references/why/references/sources/sentry.md +66 -0
- package/bundled-skills/skills/peak/references/why/references/sources/slack.md +17 -0
- package/bundled-skills/skills/peak/references/why/references/synthesizer-prompt.md +129 -0
- package/bundled-skills/skills/peak/scripts/check-plan.mjs +205 -0
- package/bundled-skills/skills/peak/scripts/check-plan.test.ts +96 -0
- package/bundled-skills/skills/peak/scripts/orch/orch.test.ts +761 -0
- package/bundled-skills/skills/peak/scripts/orch/orch.ts +588 -0
- package/bundled-skills/skills/peak/scripts/orch/store.ts +1676 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/LICENSE +22 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/esm.mjs +16 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/index.js +24 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/argument.js +149 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/command.js +2778 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/error.js +39 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/help.js +747 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/option.js +379 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/suggestSimilar.js +101 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/package.json +1 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/typings/esm.d.mts +3 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/typings/index.d.ts +1113 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/cli.test.ts +224 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/cli.ts +223 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/fakes.test-helper.ts +129 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/github.test.ts +436 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/github.ts +718 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/policy.test.ts +420 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/policy.ts +836 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/render.ts +169 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/tsconfig.json +13 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/types.compile.ts +93 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/types.ts +413 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/watch-pr +4 -0
- package/bundled-skills/skills/peak/scripts/worktree-audit.sh +4 -0
- package/dist/bundle/chunks/anthropic-messages-BMDYDGHW.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-Q7EZTEHK.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +86 -0
- package/dist/bundle/chunks/chunk-3EGDWOKT.js +2 -0
- package/dist/bundle/chunks/chunk-3V45WARH.js +7 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
- package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
- package/dist/bundle/chunks/chunk-AI2NMHE7.js +1567 -0
- package/dist/bundle/chunks/chunk-C4IJNE7U.js +2 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
- package/dist/bundle/chunks/chunk-G54UBZTF.js +44 -0
- package/dist/bundle/chunks/chunk-H76KZMOI.js +2 -0
- package/dist/bundle/chunks/chunk-IOPE2TJ4.js +131 -0
- package/dist/bundle/chunks/chunk-IXDQLPKS.js +11 -0
- package/dist/bundle/chunks/chunk-J22MF7YW.js +64 -0
- package/dist/bundle/chunks/chunk-JLV25LHE.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-KNY3PXQI.js +2 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-LX24DVQ5.js +2 -0
- package/dist/bundle/chunks/chunk-P2QCWBFM.js +9 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-Q4U25BSY.js +2 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
- package/dist/bundle/chunks/chunk-RFPFZTK2.js +7 -0
- package/dist/bundle/chunks/chunk-RP2WKNT7.js +4 -0
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
- package/dist/bundle/chunks/chunk-UDT647VB.js +82 -0
- package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
- package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
- package/dist/bundle/chunks/chunk-WJGLPWUE.js +16 -0
- package/dist/bundle/chunks/chunk-YMZUNB25.js +2 -0
- package/dist/bundle/chunks/cli-4P6FVVLT.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-S6CT2FXS.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +478 -0
- package/dist/bundle/chunks/easter-egg-3d-65VIC4G2.js +2 -0
- package/dist/bundle/chunks/execute-3H5WKMA3.js +505 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-35NZKG6S.js +2 -0
- package/dist/bundle/chunks/google-vertex-P33AHYYX.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-U4EH6TAM.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-J62DPS2P.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
- package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-4HXATL2M.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-75YYY35N.js +7 -0
- package/dist/bundle/chunks/openai-decisions-HEBEVGA2.js +5 -0
- package/dist/bundle/chunks/openai-responses-UWNAKTBV.js +4 -0
- package/dist/bundle/chunks/openrouter-images-HVOPXKHS.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-DG7CALOV.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-435R6IKY.js +2 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-24HEGHNN.js +2 -0
- package/dist/bundle/chunks/virtual-modules-U3JBUDP7.js +2 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/raga-runtime.js +3 -0
- package/dist/bundle/raga.js +5 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/core/export-html/template.css +1085 -0
- package/dist/core/export-html/template.html +56 -0
- package/dist/core/export-html/template.js +2044 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +79 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/theme/dark.json +78 -0
- package/dist/modes/interactive/theme/light.json +78 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +337 -0
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +463 -0
- package/docs/configuration.md +62 -0
- package/docs/containerization.md +183 -0
- package/docs/custom-provider.md +227 -0
- package/docs/docs.json +220 -0
- package/docs/environment-variables.md +101 -0
- package/docs/extensions.md +400 -0
- package/docs/how-pi-works.md +49 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +39 -0
- package/docs/json.md +226 -0
- package/docs/keybindings.md +195 -0
- package/docs/llama-cpp.md +121 -0
- package/docs/mcp.md +272 -0
- package/docs/message-types.md +279 -0
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +225 -0
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/packages.md +129 -0
- package/docs/prompt-templates.md +59 -0
- package/docs/providers.md +247 -0
- package/docs/quickstart.md +136 -0
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +193 -0
- package/docs/sdk.md +148 -0
- package/docs/security.md +99 -0
- package/docs/session-format.md +293 -0
- package/docs/sessions.md +66 -0
- package/docs/settings.md +184 -0
- package/docs/shell-aliases.md +93 -0
- package/docs/skills.md +93 -0
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +233 -0
- package/docs/termux.md +117 -0
- package/docs/themes.md +138 -0
- package/docs/tmux.md +55 -0
- package/docs/tui.md +195 -0
- package/docs/usage.md +94 -0
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +81 -0
- package/examples/README.md +36 -0
- package/examples/extensions/README.md +214 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +225 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +117 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +617 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +55 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +81 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +175 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +190 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +353 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +57 -0
- package/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +66 -0
- package/examples/extensions/plan-mode/index.ts +394 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +436 -0
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +49 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +118 -0
- package/examples/extensions/question.ts +286 -0
- package/examples/extensions/questionnaire.ts +448 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +326 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +177 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +157 -0
- package/examples/extensions/subagent/index.ts +1038 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +199 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +661 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +75 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +99 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +74 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/examples/sdk/README.md +141 -0
- package/package.json +21 -5
- package/python/raga_rlm/__init__.py +336 -0
- package/python/raga_rlm/repl.py +920 -0
- package/schemas/keybindings.schema.json +393 -0
- package/schemas/models.schema.json +1211 -0
- package/schemas/settings.schema.json +815 -0
- package/schemas/theme.schema.json +365 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { parseMermaid } from "./lib.mjs";
|
|
6
|
+
|
|
7
|
+
const USAGE = "Usage: node chart-to-tla.mjs CHART.mmd --module NAME [--dir OUT]";
|
|
8
|
+
const HELP = `${USAGE}
|
|
9
|
+
|
|
10
|
+
Writes a TLA+ spec, a TLC config, and a reader mapping from a Mermaid stateDiagram-v2.
|
|
11
|
+
statechart.mjs from-chart runs it, then checks each INVARIANT in NAME.cfg alone.
|
|
12
|
+
|
|
13
|
+
Each region becomes one variable whose values are the region's states. Each transition label
|
|
14
|
+
becomes one action. Regions that share a label move together: every region that can take it does,
|
|
15
|
+
and the others stay. A "%% when" line after a transition is its guard: the region can take that
|
|
16
|
+
transition only while the other regions are in, or with "not" are not in, the states it names. An
|
|
17
|
+
unlabeled transition is its own action. Each
|
|
18
|
+
"%% never NAME: A & B -- sentence" line becomes the invariant NAME == ~(A /\\ B). A name in a
|
|
19
|
+
never line is a state, or a composite that stands for every state inside it.
|
|
20
|
+
|
|
21
|
+
--module NAME The TLA+ module name. Required.
|
|
22
|
+
--dir OUT The folder for the files. Default: the chart's folder.
|
|
23
|
+
-h, --help Print this help, and exit 0.
|
|
24
|
+
|
|
25
|
+
Writes NAME.tla, NAME.cfg, and NAME.map.mjs into OUT, and replaces files with those names.
|
|
26
|
+
NAME.cfg has SPECIFICATION Spec, INVARIANT TypeOK, and one INVARIANT per never line.
|
|
27
|
+
NAME.map.mjs gives tlc-to-chart.mjs the reader's words: the region states joined by " | ".
|
|
28
|
+
|
|
29
|
+
Exit codes
|
|
30
|
+
0 It wrote the files.
|
|
31
|
+
1 It cannot read the chart. The error says why.
|
|
32
|
+
2 A bad argument.`;
|
|
33
|
+
const more = "Run node chart-to-tla.mjs --help for the flags.";
|
|
34
|
+
|
|
35
|
+
const args = {};
|
|
36
|
+
for (let i = 2; i < process.argv.length; i++) {
|
|
37
|
+
const a = process.argv[i];
|
|
38
|
+
if (a === "-h" || a === "--help") {
|
|
39
|
+
console.log(HELP);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
} else if (a === "--module") args.module = process.argv[++i];
|
|
42
|
+
else if (a === "--dir") args.dir = process.argv[++i];
|
|
43
|
+
else if (!a.startsWith("-") && !args.chart) args.chart = a;
|
|
44
|
+
else {
|
|
45
|
+
console.error(`unknown argument ${a}. ${more}`);
|
|
46
|
+
process.exit(2);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!args.chart || !/^[A-Za-z][A-Za-z0-9_]*$/.test(args.module ?? "")) {
|
|
50
|
+
console.error(`${USAGE}\n${more}`);
|
|
51
|
+
process.exit(2);
|
|
52
|
+
}
|
|
53
|
+
const dir = args.dir ?? path.dirname(args.chart);
|
|
54
|
+
const { regions, nevers } = parseMermaid(fs.readFileSync(args.chart, "utf8"));
|
|
55
|
+
|
|
56
|
+
const RESERVED = new Set(["vars", "Init", "Next", "Spec", "TypeOK", "Settled"]);
|
|
57
|
+
const taken = new Set(RESERVED);
|
|
58
|
+
function ident(words, lower) {
|
|
59
|
+
const parts = words
|
|
60
|
+
.normalize("NFKD")
|
|
61
|
+
.replace(/[^A-Za-z0-9]+/g, " ")
|
|
62
|
+
.trim()
|
|
63
|
+
.split(" ")
|
|
64
|
+
.filter(Boolean);
|
|
65
|
+
let id =
|
|
66
|
+
parts
|
|
67
|
+
.map((p, i) => (lower && i === 0 ? p[0].toLowerCase() : p[0].toUpperCase()) + p.slice(1))
|
|
68
|
+
.join("") || "Step";
|
|
69
|
+
if (/^[0-9]/.test(id)) id = `${lower ? "r" : "S"}${id}`;
|
|
70
|
+
let unique = id;
|
|
71
|
+
for (let n = 2; taken.has(unique); n++) unique = `${id}${n}`;
|
|
72
|
+
taken.add(unique);
|
|
73
|
+
return unique;
|
|
74
|
+
}
|
|
75
|
+
const str = (s) => `"${s.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
|
76
|
+
const set = (xs) => `{${[...xs].map(str).join(", ")}}`;
|
|
77
|
+
|
|
78
|
+
const vars = Object.entries(regions).map(([name, r]) => {
|
|
79
|
+
if (r.states.size === 0) throw new Error(`region ${name} has no states`);
|
|
80
|
+
if (r.initial.size === 0) throw new Error(`region ${name} has no [*] --> start`);
|
|
81
|
+
return { name, v: ident(name, true), ...r };
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function guardOf(g) {
|
|
85
|
+
if (!g) return null;
|
|
86
|
+
const parts = Object.entries(g.states).map(([name, states]) => {
|
|
87
|
+
const { v } = vars.find((x) => x.name === name);
|
|
88
|
+
return states.length === 1 ? `${v} = ${str(states[0])}` : `${v} \\in ${set(states)}`;
|
|
89
|
+
});
|
|
90
|
+
return g.not ? `~(${parts.join(" \\/ ")})` : parts.join(" /\\ ");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const actions = [];
|
|
94
|
+
const byLabel = new Map();
|
|
95
|
+
for (const [ri, r] of vars.entries()) {
|
|
96
|
+
for (const t of r.transitions) {
|
|
97
|
+
let a = t.label ? byLabel.get(t.label) : null;
|
|
98
|
+
if (!a) {
|
|
99
|
+
a = { label: t.label, moves: new Map() };
|
|
100
|
+
actions.push(a);
|
|
101
|
+
if (t.label) byLabel.set(t.label, a);
|
|
102
|
+
}
|
|
103
|
+
if (!a.moves.has(ri)) a.moves.set(ri, []);
|
|
104
|
+
const moves = a.moves.get(ri);
|
|
105
|
+
const when = guardOf(t.guard);
|
|
106
|
+
if (!moves.some((m) => m.from === t.from && m.to === t.to && m.when === when))
|
|
107
|
+
moves.push({ from: t.from, to: t.to, when });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const a of actions) {
|
|
111
|
+
const only = a.label ? null : [...a.moves.values()][0][0];
|
|
112
|
+
a.name = ident(a.label || `${only.from} to ${only.to}`, false);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const out = [];
|
|
116
|
+
const conjuncts = (lines) => lines.map((l) => ` /\\ ${l}`);
|
|
117
|
+
out.push(`---- MODULE ${args.module} ----`);
|
|
118
|
+
out.push(`\\* Generated by chart-to-tla.mjs from ${path.basename(args.chart)}.`);
|
|
119
|
+
out.push("\\* Each region is one variable and each transition label is one action.");
|
|
120
|
+
out.push("\\* Once you add guards and variables from the real code, this file is the source.");
|
|
121
|
+
out.push(
|
|
122
|
+
`\\* statechart.mjs from-chart ${path.basename(args.chart)} keeps it, checks it, and compares it with the chart.`,
|
|
123
|
+
);
|
|
124
|
+
out.push("");
|
|
125
|
+
out.push(`VARIABLES ${vars.map((x) => x.v).join(", ")}`);
|
|
126
|
+
out.push(`vars == <<${vars.map((x) => x.v).join(", ")}>>`);
|
|
127
|
+
out.push("");
|
|
128
|
+
for (const x of vars)
|
|
129
|
+
out.push(`\\* Region ${x.name}`, `${x.v}States == ${set([...x.states].sort())}`);
|
|
130
|
+
out.push("");
|
|
131
|
+
out.push("TypeOK ==", ...conjuncts(vars.map((x) => `${x.v} \\in ${x.v}States`)));
|
|
132
|
+
out.push("");
|
|
133
|
+
out.push(
|
|
134
|
+
"Init ==",
|
|
135
|
+
...conjuncts(
|
|
136
|
+
vars.map((x) =>
|
|
137
|
+
x.initial.size === 1 ? `${x.v} = ${str([...x.initial][0])}` : `${x.v} \\in ${set(x.initial)}`,
|
|
138
|
+
),
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
const enabled = (v, m) => `${v} = ${str(m.from)}${m.when ? ` /\\ ${m.when}` : ""}`;
|
|
142
|
+
function whetherTakes(a, ri) {
|
|
143
|
+
const { v } = vars[ri];
|
|
144
|
+
const moves = a.moves.get(ri);
|
|
145
|
+
if (moves.every((m) => !m.when)) {
|
|
146
|
+
const from = set(new Set(moves.map((m) => m.from)));
|
|
147
|
+
return { can: `${v} \\in ${from}`, cannot: `${v} \\notin ${from}` };
|
|
148
|
+
}
|
|
149
|
+
const any = moves.map((m) => `(${enabled(v, m)})`).join(" \\/ ");
|
|
150
|
+
return { can: any, cannot: `~(${any})` };
|
|
151
|
+
}
|
|
152
|
+
for (const a of actions) {
|
|
153
|
+
out.push("");
|
|
154
|
+
if (a.label) out.push(`\\* ${a.label}`);
|
|
155
|
+
out.push(`${a.name} ==`);
|
|
156
|
+
const moving = [...a.moves.keys()];
|
|
157
|
+
const shared = moving.length > 1;
|
|
158
|
+
if (shared) out.push(` /\\ (${moving.map((ri) => whetherTakes(a, ri).can).join(" \\/ ")})`);
|
|
159
|
+
for (const ri of moving) {
|
|
160
|
+
const { v } = vars[ri];
|
|
161
|
+
const ds = a.moves.get(ri).map((m) => `(${enabled(v, m)} /\\ ${v}' = ${str(m.to)})`);
|
|
162
|
+
if (shared) ds.push(`(${whetherTakes(a, ri).cannot} /\\ UNCHANGED ${v})`);
|
|
163
|
+
out.push(` /\\ \\/ ${ds[0]}`);
|
|
164
|
+
for (const d of ds.slice(1)) out.push(` \\/ ${d}`);
|
|
165
|
+
}
|
|
166
|
+
const still = vars.filter((_, ri) => !a.moves.has(ri)).map((x) => x.v);
|
|
167
|
+
if (still.length) out.push(` /\\ UNCHANGED <<${still.join(", ")}>>`);
|
|
168
|
+
}
|
|
169
|
+
out.push("");
|
|
170
|
+
out.push(
|
|
171
|
+
actions.length ? `Next == ${actions.map((a) => a.name).join(" \\/ ")}` : "Next == UNCHANGED vars",
|
|
172
|
+
);
|
|
173
|
+
out.push("");
|
|
174
|
+
out.push("Spec == Init /\\ [][Next]_vars");
|
|
175
|
+
|
|
176
|
+
function resolve(item) {
|
|
177
|
+
const hits = [];
|
|
178
|
+
for (const [ri, x] of vars.entries()) {
|
|
179
|
+
const inside = x.states.has(item)
|
|
180
|
+
? [item]
|
|
181
|
+
: [...x.states].filter((s) => s.startsWith(`${item}.`));
|
|
182
|
+
if (inside.length) hits.push({ ri, inside });
|
|
183
|
+
}
|
|
184
|
+
if (hits.length === 0)
|
|
185
|
+
throw new Error(`never line names "${item}", which is not a state in the chart`);
|
|
186
|
+
if (hits.length > 1)
|
|
187
|
+
throw new Error(
|
|
188
|
+
`never line names "${item}", which is a state in regions ${hits.map((h) => vars[h.ri].name).join(" and ")}; rename one`,
|
|
189
|
+
);
|
|
190
|
+
return hits[0];
|
|
191
|
+
}
|
|
192
|
+
const invariants = [];
|
|
193
|
+
for (const n of nevers) {
|
|
194
|
+
if (taken.has(n.name)) throw new Error(`never name ${n.name} is already used in the spec`);
|
|
195
|
+
taken.add(n.name);
|
|
196
|
+
const parts = n.states.map(resolve);
|
|
197
|
+
const regionsUsed = new Set(parts.map((p) => p.ri));
|
|
198
|
+
if (regionsUsed.size !== parts.length)
|
|
199
|
+
throw new Error(
|
|
200
|
+
`never ${n.name} names two states of one region; one region is in one state at a time`,
|
|
201
|
+
);
|
|
202
|
+
const cond = parts.map((p) =>
|
|
203
|
+
p.inside.length === 1
|
|
204
|
+
? `${vars[p.ri].v} = ${str(p.inside[0])}`
|
|
205
|
+
: `${vars[p.ri].v} \\in ${set(p.inside)}`,
|
|
206
|
+
);
|
|
207
|
+
out.push("");
|
|
208
|
+
if (n.sentence) out.push(`\\* ${n.sentence}`);
|
|
209
|
+
out.push(`${n.name} == ~(${cond.join(" /\\ ")})`);
|
|
210
|
+
invariants.push(n.name);
|
|
211
|
+
}
|
|
212
|
+
out.push("", "====", "");
|
|
213
|
+
|
|
214
|
+
const rules = ["TypeOK", ...invariants];
|
|
215
|
+
const cfg = ["SPECIFICATION Spec", ...rules.map((r) => `INVARIANT ${r}`), ""];
|
|
216
|
+
|
|
217
|
+
const labels = Object.fromEntries(actions.map((a) => [a.name, a.label]));
|
|
218
|
+
const map = [
|
|
219
|
+
`// Generated by chart-to-tla.mjs from ${path.basename(args.chart)}. Reader states are the chart's own states.`,
|
|
220
|
+
`export const regions = ${JSON.stringify(vars.map((x) => x.v))};`,
|
|
221
|
+
`const LABELS = ${JSON.stringify(labels, null, "\t")};`,
|
|
222
|
+
"",
|
|
223
|
+
"// The actions the reader takes. facts.settled needs them. Add cause() and detail() as the spec grows.",
|
|
224
|
+
"export const readerActions = [];",
|
|
225
|
+
'export const state = (v) => regions.map((r) => v[r]).join(" | ");',
|
|
226
|
+
"export const step = (action) => LABELS[action] ?? action;",
|
|
227
|
+
"",
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
231
|
+
fs.writeFileSync(path.join(dir, `${args.module}.tla`), out.join("\n"));
|
|
232
|
+
fs.writeFileSync(path.join(dir, `${args.module}.cfg`), cfg.join("\n"));
|
|
233
|
+
fs.writeFileSync(path.join(dir, `${args.module}.map.mjs`), map.join("\n"));
|
|
234
|
+
console.error(
|
|
235
|
+
`${args.module}: ${vars.length} region variable(s), ${actions.length} action(s), rules ${rules.join(" ")} -> ${path.join(dir, args.module)}.{tla,cfg,map.mjs}`,
|
|
236
|
+
);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import { FULL_LABELS, LEGEND_ID, compareCharts, parseMermaid } from "./lib.mjs";
|
|
5
|
+
|
|
6
|
+
const USAGE = "Usage: node compare-charts.mjs EXPECTED.mmd ACTUAL.mmd";
|
|
7
|
+
const HELP = `${USAGE}
|
|
8
|
+
|
|
9
|
+
Compares two Mermaid stateDiagram-v2 charts: reachable states, start states, and labeled
|
|
10
|
+
transitions. statechart.mjs from-chart runs it to check that the spec still draws the chart that
|
|
11
|
+
the reader agreed to.
|
|
12
|
+
|
|
13
|
+
EXPECTED is the agreed chart. ACTUAL is what tlc-to-chart.mjs drew from the spec in the customer
|
|
14
|
+
view with --highlight 0 --full-labels --flat, without --cover, --fixed-dot, or --against-dot. Each
|
|
15
|
+
chart compares as the
|
|
16
|
+
machine that its steps reach from its start states. A chart with parallel regions compares as its
|
|
17
|
+
combined machine, so a guard that blocks a step in only some combinations of regions shows as a
|
|
18
|
+
difference. A "%% when ID, ID" or "%% when not ID, ID" line right after a transition is its guard:
|
|
19
|
+
the step happens only while another region is in, or not in, one of those states. The label ends
|
|
20
|
+
with the guard's words in [ ], which are not part of the label. A combined state is the region
|
|
21
|
+
states joined by " | " in region order, which is what chart-to-tla.mjs's mapping writes. A step that does not change the state is not compared, because
|
|
22
|
+
tlc-to-chart.mjs does not draw it. An edge label "a or b" counts as two labels. An unlabeled edge
|
|
23
|
+
counts only when no labeled edge joins the same two states, because tlc-to-chart.mjs draws only
|
|
24
|
+
the labels.
|
|
25
|
+
|
|
26
|
+
-h, --help Print this help, and exit 0.
|
|
27
|
+
|
|
28
|
+
Prints each difference and then "N difference(s)", or prints "same". Writes no file.
|
|
29
|
+
|
|
30
|
+
Exit codes
|
|
31
|
+
0 The charts are the same.
|
|
32
|
+
1 The charts differ.
|
|
33
|
+
2 A bad argument, a chart that it cannot read, or an ACTUAL chart that is not drawn for
|
|
34
|
+
comparison.`;
|
|
35
|
+
const more = "Run node compare-charts.mjs --help for the flags.";
|
|
36
|
+
|
|
37
|
+
const files = [];
|
|
38
|
+
for (const a of process.argv.slice(2)) {
|
|
39
|
+
if (a === "-h" || a === "--help") {
|
|
40
|
+
console.log(HELP);
|
|
41
|
+
process.exit(0);
|
|
42
|
+
} else if (a.startsWith("-") || files.length === 2) {
|
|
43
|
+
console.error(`unknown argument ${a}. ${more}`);
|
|
44
|
+
process.exit(2);
|
|
45
|
+
} else files.push(a);
|
|
46
|
+
}
|
|
47
|
+
if (files.length < 2) {
|
|
48
|
+
console.error(`${USAGE}\n${more}`);
|
|
49
|
+
process.exit(2);
|
|
50
|
+
}
|
|
51
|
+
const [expectedFile, actualFile] = files;
|
|
52
|
+
|
|
53
|
+
const orExit = (file, f) => {
|
|
54
|
+
try {
|
|
55
|
+
return f();
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(`${file}: ${e.message}`);
|
|
58
|
+
process.exit(2);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const [expectedText, actualText] = files.map((f) => orExit(f, () => fs.readFileSync(f, "utf8")));
|
|
62
|
+
const has = (re) => re.test(actualText);
|
|
63
|
+
const textRefusals = [
|
|
64
|
+
[
|
|
65
|
+
has(/^\s*%% second model/m),
|
|
66
|
+
"it has a second model; draw ACTUAL without --fixed-dot or --against-dot",
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
has(new RegExp(`^\\s*state\\s+"[^"]*"\\s+as\\s+(?!${LEGEND_ID}\\b)\\w+\\s*\\{`, "m")),
|
|
70
|
+
"it has boxes; draw ACTUAL with --flat",
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
has(new RegExp(`^\\s*state\\s+"[^"]*"\\s+as\\s+${LEGEND_ID}\\s*\\{`, "m")) &&
|
|
74
|
+
!actualText.includes(FULL_LABELS),
|
|
75
|
+
"edge labels write shared words once; draw ACTUAL with --full-labels",
|
|
76
|
+
],
|
|
77
|
+
];
|
|
78
|
+
for (const [bad, why] of textRefusals) {
|
|
79
|
+
if (bad) {
|
|
80
|
+
console.error(`${actualFile}: ${why}`);
|
|
81
|
+
process.exit(2);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const expectedRegions = orExit(expectedFile, () => parseMermaid(expectedText).regions);
|
|
85
|
+
const actualRegions = orExit(actualFile, () => parseMermaid(actualText).regions);
|
|
86
|
+
const numbered = Object.values(actualRegions)
|
|
87
|
+
.flatMap((r) => r.transitions)
|
|
88
|
+
.some((t) => /^\d+(, \d+)*\. /.test(t.label));
|
|
89
|
+
if (numbered) {
|
|
90
|
+
console.error(
|
|
91
|
+
`${actualFile}: an edge label is a numbered path step; draw ACTUAL with --highlight 0`,
|
|
92
|
+
);
|
|
93
|
+
process.exit(2);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const rows = compareCharts(expectedRegions, actualRegions);
|
|
97
|
+
let differences = 0;
|
|
98
|
+
for (const [title, xs] of rows) {
|
|
99
|
+
console.log(`${title}:`);
|
|
100
|
+
for (const x of xs) console.log(` ${x}`);
|
|
101
|
+
differences += xs.length;
|
|
102
|
+
}
|
|
103
|
+
console.log(differences === 0 ? "same" : `${differences} difference(s)`);
|
|
104
|
+
process.exit(differences === 0 ? 0 : 1);
|