raga-cli 0.0.0-stage → 0.9.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 +118 -0
- package/LICENSE +21 -0
- package/README.md +162 -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 +1514 -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/bend/SKILL.md +58 -0
- package/bundled-skills/skills/bend/bend_tool.py +144 -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 +51 -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 +55 -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/bundled-skills/skills/raga-artifacts/SKILL.md +117 -0
- package/bundled-skills/skills/raga-artifacts/artifact.mjs +254 -0
- package/bundled-skills/skills/raga-artifacts/artifact_tool.py +55 -0
- package/bundled-skills/skills/raga-artifacts/diagrams.md +641 -0
- package/bundled-skills/skills/raga-artifacts/templates/doc.html +124 -0
- package/bundled-skills/skills/raga-artifacts/templates/slides.html +138 -0
- package/dist/bundle/chunks/anthropic-messages-BMDYDGHW.js +6 -0
- package/dist/bundle/chunks/anthropic.js +68 -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-3MNXTBQ3.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-CF5GWZHW.js +31 -0
- package/dist/bundle/chunks/chunk-ENUUAC3O.js +131 -0
- package/dist/bundle/chunks/chunk-F7LFZTHT.js +1591 -0
- package/dist/bundle/chunks/chunk-G54UBZTF.js +44 -0
- package/dist/bundle/chunks/chunk-H76KZMOI.js +2 -0
- package/dist/bundle/chunks/chunk-IXDQLPKS.js +11 -0
- package/dist/bundle/chunks/chunk-JLV25LHE.js +2 -0
- package/dist/bundle/chunks/chunk-JQDZ4Z7L.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-NP6TH6UT.js +64 -0
- package/dist/bundle/chunks/chunk-OPPYO2IE.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-S5J3UB5O.js +75 -0
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -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/cli-QLDCDYOR.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-NPDBBPPF.js +2 -0
- package/dist/bundle/chunks/execute-WPTMS4XG.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 +68 -0
- package/dist/bundle/chunks/openai-codex-responses-4HXATL2M.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +68 -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 +68 -0
- package/dist/bundle/chunks/pi-messages-DG7CALOV.js +8 -0
- package/dist/bundle/chunks/radius.js +68 -0
- package/dist/bundle/chunks/runtime-N5MUH2WA.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-4I6Y6DPQ.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 +343 -0
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +489 -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 +149 -0
- package/docs/security.md +99 -0
- package/docs/session-format.md +293 -0
- package/docs/sessions.md +66 -0
- package/docs/settings.md +185 -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 +352 -0
- package/python/raga_rlm/mlx_models.py +265 -0
- package/python/raga_rlm/repl.py +920 -0
- package/schemas/keybindings.schema.json +441 -0
- package/schemas/models.schema.json +1211 -0
- package/schemas/settings.schema.json +829 -0
- package/schemas/theme.schema.json +365 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example extension demonstrating timed dialogs with live countdown.
|
|
3
|
+
*
|
|
4
|
+
* Commands:
|
|
5
|
+
* - /timed - Shows confirm dialog that auto-cancels after 5 seconds with countdown
|
|
6
|
+
* - /timed-select - Shows select dialog that auto-cancels after 10 seconds with countdown
|
|
7
|
+
* - /timed-signal - Shows confirm using AbortSignal (manual approach)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
export default function (pi: ExtensionAPI) {
|
|
13
|
+
// Simple approach: use timeout option (recommended)
|
|
14
|
+
pi.registerCommand("timed", {
|
|
15
|
+
description: "Show a timed confirmation dialog (auto-cancels in 5s with countdown)",
|
|
16
|
+
handler: async (_args, ctx) => {
|
|
17
|
+
const confirmed = await ctx.ui.confirm(
|
|
18
|
+
"Timed Confirmation",
|
|
19
|
+
"This dialog will auto-cancel in 5 seconds. Confirm?",
|
|
20
|
+
{ timeout: 5000 },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (confirmed) {
|
|
24
|
+
ctx.ui.notify("Confirmed by user!", "info");
|
|
25
|
+
} else {
|
|
26
|
+
ctx.ui.notify("Cancelled or timed out", "info");
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
pi.registerCommand("timed-select", {
|
|
32
|
+
description: "Show a timed select dialog (auto-cancels in 10s with countdown)",
|
|
33
|
+
handler: async (_args, ctx) => {
|
|
34
|
+
const choice = await ctx.ui.select("Pick an option", ["Option A", "Option B", "Option C"], { timeout: 10000 });
|
|
35
|
+
|
|
36
|
+
if (choice) {
|
|
37
|
+
ctx.ui.notify(`Selected: ${choice}`, "info");
|
|
38
|
+
} else {
|
|
39
|
+
ctx.ui.notify("Selection cancelled or timed out", "info");
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Manual approach: use AbortSignal for more control
|
|
45
|
+
pi.registerCommand("timed-signal", {
|
|
46
|
+
description: "Show a timed confirm using AbortSignal (manual approach)",
|
|
47
|
+
handler: async (_args, ctx) => {
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
50
|
+
|
|
51
|
+
ctx.ui.notify("Dialog will auto-cancel in 5 seconds...", "info");
|
|
52
|
+
|
|
53
|
+
const confirmed = await ctx.ui.confirm(
|
|
54
|
+
"Timed Confirmation",
|
|
55
|
+
"This dialog will auto-cancel in 5 seconds. Confirm?",
|
|
56
|
+
{ signal: controller.signal },
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
clearTimeout(timeoutId);
|
|
60
|
+
|
|
61
|
+
if (confirmed) {
|
|
62
|
+
ctx.ui.notify("Confirmed by user!", "info");
|
|
63
|
+
} else if (controller.signal.aborted) {
|
|
64
|
+
ctx.ui.notify("Dialog timed out (auto-cancelled)", "warning");
|
|
65
|
+
} else {
|
|
66
|
+
ctx.ui.notify("Cancelled by user", "info");
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Titlebar Spinner Extension
|
|
3
|
+
*
|
|
4
|
+
* Shows a braille spinner animation in the terminal title while the agent is working.
|
|
5
|
+
* Uses `ctx.ui.setTitle()` to update the terminal title via the extension API.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* pi --extension examples/extensions/titlebar-spinner.ts
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
|
|
14
|
+
const BRAILLE_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
15
|
+
|
|
16
|
+
function getBaseTitle(pi: ExtensionAPI): string {
|
|
17
|
+
const cwd = path.basename(process.cwd());
|
|
18
|
+
const session = pi.getSessionName();
|
|
19
|
+
return session ? `π - ${session} - ${cwd}` : `π - ${cwd}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function (pi: ExtensionAPI) {
|
|
23
|
+
let timer: ReturnType<typeof setInterval> | null = null;
|
|
24
|
+
let frameIndex = 0;
|
|
25
|
+
|
|
26
|
+
function stopAnimation(ctx: ExtensionContext) {
|
|
27
|
+
if (timer) {
|
|
28
|
+
clearInterval(timer);
|
|
29
|
+
timer = null;
|
|
30
|
+
}
|
|
31
|
+
frameIndex = 0;
|
|
32
|
+
ctx.ui.setTitle(getBaseTitle(pi));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function startAnimation(ctx: ExtensionContext) {
|
|
36
|
+
stopAnimation(ctx);
|
|
37
|
+
timer = setInterval(() => {
|
|
38
|
+
const frame = BRAILLE_FRAMES[frameIndex % BRAILLE_FRAMES.length];
|
|
39
|
+
const cwd = path.basename(process.cwd());
|
|
40
|
+
const session = pi.getSessionName();
|
|
41
|
+
const title = session ? `${frame} π - ${session} - ${cwd}` : `${frame} π - ${cwd}`;
|
|
42
|
+
ctx.ui.setTitle(title);
|
|
43
|
+
frameIndex++;
|
|
44
|
+
}, 80);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pi.on("agent_start", async (_event, ctx) => {
|
|
48
|
+
startAnimation(ctx);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
pi.on("agent_settled", async (_event, ctx) => {
|
|
52
|
+
stopAnimation(ctx);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
56
|
+
stopAnimation(ctx);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Extension - Demonstrates state management via session entries
|
|
3
|
+
*
|
|
4
|
+
* This extension:
|
|
5
|
+
* - Registers a `todo` tool for the LLM to manage todos
|
|
6
|
+
* - Registers a `/todos` command for users to view the list
|
|
7
|
+
*
|
|
8
|
+
* State is stored in tool result details (not external files), which allows
|
|
9
|
+
* proper branching - when you branch, the todo state is automatically
|
|
10
|
+
* correct for that point in history.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { StringEnum } from "@earendil-works/pi-ai";
|
|
14
|
+
import type { ExtensionAPI, ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import { matchesKey, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
16
|
+
import { Type } from "typebox";
|
|
17
|
+
|
|
18
|
+
interface Todo {
|
|
19
|
+
id: number;
|
|
20
|
+
text: string;
|
|
21
|
+
done: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface TodoDetails {
|
|
25
|
+
action: "list" | "add" | "toggle" | "clear";
|
|
26
|
+
todos: Todo[];
|
|
27
|
+
nextId: number;
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const TodoParams = Type.Object({
|
|
32
|
+
action: StringEnum(["list", "add", "toggle", "clear"] as const),
|
|
33
|
+
text: Type.Optional(Type.String({ description: "Todo text (for add)" })),
|
|
34
|
+
id: Type.Optional(Type.Number({ description: "Todo ID (for toggle)" })),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* UI component for the /todos command
|
|
39
|
+
*/
|
|
40
|
+
class TodoListComponent {
|
|
41
|
+
private todos: Todo[];
|
|
42
|
+
private theme: Theme;
|
|
43
|
+
private onClose: () => void;
|
|
44
|
+
private cachedWidth?: number;
|
|
45
|
+
private cachedLines?: string[];
|
|
46
|
+
|
|
47
|
+
constructor(todos: Todo[], theme: Theme, onClose: () => void) {
|
|
48
|
+
this.todos = todos;
|
|
49
|
+
this.theme = theme;
|
|
50
|
+
this.onClose = onClose;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
handleInput(data: string): void {
|
|
54
|
+
if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
|
|
55
|
+
this.onClose();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
render(width: number): string[] {
|
|
60
|
+
if (this.cachedLines && this.cachedWidth === width) {
|
|
61
|
+
return this.cachedLines;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const lines: string[] = [];
|
|
65
|
+
const th = this.theme;
|
|
66
|
+
|
|
67
|
+
lines.push("");
|
|
68
|
+
const title = th.fg("accent", " Todos ");
|
|
69
|
+
const headerLine =
|
|
70
|
+
th.fg("borderMuted", "─".repeat(3)) + title + th.fg("borderMuted", "─".repeat(Math.max(0, width - 10)));
|
|
71
|
+
lines.push(truncateToWidth(headerLine, width));
|
|
72
|
+
lines.push("");
|
|
73
|
+
|
|
74
|
+
if (this.todos.length === 0) {
|
|
75
|
+
lines.push(truncateToWidth(` ${th.fg("dim", "No todos yet. Ask the agent to add some!")}`, width));
|
|
76
|
+
} else {
|
|
77
|
+
const done = this.todos.filter((t) => t.done).length;
|
|
78
|
+
const total = this.todos.length;
|
|
79
|
+
lines.push(truncateToWidth(` ${th.fg("muted", `${done}/${total} completed`)}`, width));
|
|
80
|
+
lines.push("");
|
|
81
|
+
|
|
82
|
+
for (const todo of this.todos) {
|
|
83
|
+
const check = todo.done ? th.fg("success", "✓") : th.fg("dim", "○");
|
|
84
|
+
const id = th.fg("accent", `#${todo.id}`);
|
|
85
|
+
const text = todo.done ? th.fg("dim", todo.text) : th.fg("text", todo.text);
|
|
86
|
+
lines.push(truncateToWidth(` ${check} ${id} ${text}`, width));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
lines.push("");
|
|
91
|
+
lines.push(truncateToWidth(` ${th.fg("dim", "Press Escape to close")}`, width));
|
|
92
|
+
lines.push("");
|
|
93
|
+
|
|
94
|
+
this.cachedWidth = width;
|
|
95
|
+
this.cachedLines = lines;
|
|
96
|
+
return lines;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
invalidate(): void {
|
|
100
|
+
this.cachedWidth = undefined;
|
|
101
|
+
this.cachedLines = undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default function (pi: ExtensionAPI) {
|
|
106
|
+
// In-memory state (reconstructed from session on load)
|
|
107
|
+
let todos: Todo[] = [];
|
|
108
|
+
let nextId = 1;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Reconstruct state from session entries.
|
|
112
|
+
* Scans tool results for this tool and applies them in order.
|
|
113
|
+
*/
|
|
114
|
+
const reconstructState = (ctx: ExtensionContext) => {
|
|
115
|
+
todos = [];
|
|
116
|
+
nextId = 1;
|
|
117
|
+
|
|
118
|
+
for (const entry of ctx.sessionManager.getBranch()) {
|
|
119
|
+
if (entry.type !== "message") continue;
|
|
120
|
+
const msg = entry.message;
|
|
121
|
+
if (msg.role !== "toolResult" || msg.toolName !== "todo") continue;
|
|
122
|
+
|
|
123
|
+
const details = msg.details as TodoDetails | undefined;
|
|
124
|
+
if (details) {
|
|
125
|
+
todos = details.todos;
|
|
126
|
+
nextId = details.nextId;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Reconstruct state on session events
|
|
132
|
+
pi.on("session_start", async (_event, ctx) => reconstructState(ctx));
|
|
133
|
+
pi.on("session_tree", async (_event, ctx) => reconstructState(ctx));
|
|
134
|
+
|
|
135
|
+
// Register the todo tool for the LLM
|
|
136
|
+
pi.registerTool({
|
|
137
|
+
name: "todo",
|
|
138
|
+
label: "Todo",
|
|
139
|
+
description: "Manage a todo list. Actions: list, add (text), toggle (id), clear",
|
|
140
|
+
parameters: TodoParams,
|
|
141
|
+
|
|
142
|
+
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
143
|
+
switch (params.action) {
|
|
144
|
+
case "list":
|
|
145
|
+
return {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
text: todos.length
|
|
150
|
+
? todos.map((t) => `[${t.done ? "x" : " "}] #${t.id}: ${t.text}`).join("\n")
|
|
151
|
+
: "No todos",
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
details: { action: "list", todos: [...todos], nextId } as TodoDetails,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
case "add": {
|
|
158
|
+
if (!params.text) {
|
|
159
|
+
return {
|
|
160
|
+
content: [{ type: "text", text: "Error: text required for add" }],
|
|
161
|
+
details: { action: "add", todos: [...todos], nextId, error: "text required" } as TodoDetails,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const newTodo: Todo = { id: nextId++, text: params.text, done: false };
|
|
165
|
+
todos.push(newTodo);
|
|
166
|
+
return {
|
|
167
|
+
content: [{ type: "text", text: `Added todo #${newTodo.id}: ${newTodo.text}` }],
|
|
168
|
+
details: { action: "add", todos: [...todos], nextId } as TodoDetails,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
case "toggle": {
|
|
173
|
+
if (params.id === undefined) {
|
|
174
|
+
return {
|
|
175
|
+
content: [{ type: "text", text: "Error: id required for toggle" }],
|
|
176
|
+
details: { action: "toggle", todos: [...todos], nextId, error: "id required" } as TodoDetails,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const todo = todos.find((t) => t.id === params.id);
|
|
180
|
+
if (!todo) {
|
|
181
|
+
return {
|
|
182
|
+
content: [{ type: "text", text: `Todo #${params.id} not found` }],
|
|
183
|
+
details: {
|
|
184
|
+
action: "toggle",
|
|
185
|
+
todos: [...todos],
|
|
186
|
+
nextId,
|
|
187
|
+
error: `#${params.id} not found`,
|
|
188
|
+
} as TodoDetails,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
todo.done = !todo.done;
|
|
192
|
+
return {
|
|
193
|
+
content: [{ type: "text", text: `Todo #${todo.id} ${todo.done ? "completed" : "uncompleted"}` }],
|
|
194
|
+
details: { action: "toggle", todos: [...todos], nextId } as TodoDetails,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
case "clear": {
|
|
199
|
+
const count = todos.length;
|
|
200
|
+
todos = [];
|
|
201
|
+
nextId = 1;
|
|
202
|
+
return {
|
|
203
|
+
content: [{ type: "text", text: `Cleared ${count} todos` }],
|
|
204
|
+
details: { action: "clear", todos: [], nextId: 1 } as TodoDetails,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
default:
|
|
209
|
+
return {
|
|
210
|
+
content: [{ type: "text", text: `Unknown action: ${params.action}` }],
|
|
211
|
+
details: {
|
|
212
|
+
action: "list",
|
|
213
|
+
todos: [...todos],
|
|
214
|
+
nextId,
|
|
215
|
+
error: `unknown action: ${params.action}`,
|
|
216
|
+
} as TodoDetails,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
renderCall(args, theme, _context) {
|
|
222
|
+
let text = theme.fg("toolTitle", theme.bold("todo ")) + theme.fg("muted", args.action);
|
|
223
|
+
if (args.text) text += ` ${theme.fg("dim", `"${args.text}"`)}`;
|
|
224
|
+
if (args.id !== undefined) text += ` ${theme.fg("accent", `#${args.id}`)}`;
|
|
225
|
+
return new Text(text, 0, 0);
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
renderResult(result, { expanded }, theme, _context) {
|
|
229
|
+
const details = result.details as TodoDetails | undefined;
|
|
230
|
+
if (!details) {
|
|
231
|
+
const text = result.content[0];
|
|
232
|
+
return new Text(text?.type === "text" ? text.text : "", 0, 0);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (details.error) {
|
|
236
|
+
return new Text(theme.fg("error", `Error: ${details.error}`), 0, 0);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const todoList = details.todos;
|
|
240
|
+
|
|
241
|
+
switch (details.action) {
|
|
242
|
+
case "list": {
|
|
243
|
+
if (todoList.length === 0) {
|
|
244
|
+
return new Text(theme.fg("dim", "No todos"), 0, 0);
|
|
245
|
+
}
|
|
246
|
+
let listText = theme.fg("muted", `${todoList.length} todo(s):`);
|
|
247
|
+
const display = expanded ? todoList : todoList.slice(0, 5);
|
|
248
|
+
for (const t of display) {
|
|
249
|
+
const check = t.done ? theme.fg("success", "✓") : theme.fg("dim", "○");
|
|
250
|
+
const itemText = t.done ? theme.fg("dim", t.text) : theme.fg("muted", t.text);
|
|
251
|
+
listText += `\n${check} ${theme.fg("accent", `#${t.id}`)} ${itemText}`;
|
|
252
|
+
}
|
|
253
|
+
if (!expanded && todoList.length > 5) {
|
|
254
|
+
listText += `\n${theme.fg("dim", `... ${todoList.length - 5} more`)}`;
|
|
255
|
+
}
|
|
256
|
+
return new Text(listText, 0, 0);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
case "add": {
|
|
260
|
+
const added = todoList[todoList.length - 1];
|
|
261
|
+
return new Text(
|
|
262
|
+
theme.fg("success", "✓ Added ") +
|
|
263
|
+
theme.fg("accent", `#${added.id}`) +
|
|
264
|
+
" " +
|
|
265
|
+
theme.fg("muted", added.text),
|
|
266
|
+
0,
|
|
267
|
+
0,
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
case "toggle": {
|
|
272
|
+
const text = result.content[0];
|
|
273
|
+
const msg = text?.type === "text" ? text.text : "";
|
|
274
|
+
return new Text(theme.fg("success", "✓ ") + theme.fg("muted", msg), 0, 0);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
case "clear":
|
|
278
|
+
return new Text(theme.fg("success", "✓ ") + theme.fg("muted", "Cleared all todos"), 0, 0);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// Register the /todos command for users
|
|
284
|
+
pi.registerCommand("todos", {
|
|
285
|
+
description: "Show all todos on the current branch",
|
|
286
|
+
handler: async (_args, ctx) => {
|
|
287
|
+
if (ctx.mode !== "tui") {
|
|
288
|
+
ctx.ui.notify("/todos requires interactive mode", "error");
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
await ctx.ui.custom<void>((_tui, theme, _kb, done) => {
|
|
293
|
+
return new TodoListComponent(todos, theme, () => done());
|
|
294
|
+
});
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Override Example - Demonstrates overriding built-in tools
|
|
3
|
+
*
|
|
4
|
+
* Extensions can register tools with the same name as built-in tools to replace them.
|
|
5
|
+
* This is useful for:
|
|
6
|
+
* - Adding logging or auditing to tool calls
|
|
7
|
+
* - Implementing access control or sandboxing
|
|
8
|
+
* - Routing tool calls to remote systems (e.g., pi-ssh-remote)
|
|
9
|
+
* - Modifying tool behavior for specific workflows
|
|
10
|
+
*
|
|
11
|
+
* This example overrides the `read` tool to:
|
|
12
|
+
* 1. Log all file access to a log file
|
|
13
|
+
* 2. Block access to sensitive paths (e.g., .env files)
|
|
14
|
+
* 3. Delegate to the original read implementation for allowed files
|
|
15
|
+
*
|
|
16
|
+
* Since no custom renderCall/renderResult are provided, the built-in renderer
|
|
17
|
+
* is used automatically (syntax highlighting, line numbers, truncation warnings).
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* pi -e ./tool-override.ts
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { TextContent } from "@earendil-works/pi-ai";
|
|
24
|
+
import { type ExtensionAPI, getAgentDir, withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
25
|
+
import { constants, readFileSync } from "fs";
|
|
26
|
+
import { access, appendFile, readFile } from "fs/promises";
|
|
27
|
+
import { join, resolve } from "path";
|
|
28
|
+
import { Type } from "typebox";
|
|
29
|
+
|
|
30
|
+
const LOG_FILE = join(getAgentDir(), "read-access.log");
|
|
31
|
+
|
|
32
|
+
// Paths that are blocked from reading
|
|
33
|
+
const BLOCKED_PATTERNS = [
|
|
34
|
+
/\.env$/,
|
|
35
|
+
/\.env\..+$/,
|
|
36
|
+
/secrets?\.(json|yaml|yml|toml)$/i,
|
|
37
|
+
/credentials?\.(json|yaml|yml|toml)$/i,
|
|
38
|
+
/\/\.ssh\//,
|
|
39
|
+
/\/\.aws\//,
|
|
40
|
+
/\/\.gnupg\//,
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
function isBlockedPath(path: string): boolean {
|
|
44
|
+
return BLOCKED_PATTERNS.some((pattern) => pattern.test(path));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function logAccess(path: string, allowed: boolean, reason?: string) {
|
|
48
|
+
const timestamp = new Date().toISOString();
|
|
49
|
+
const status = allowed ? "ALLOWED" : "BLOCKED";
|
|
50
|
+
const msg = reason ? ` (${reason})` : "";
|
|
51
|
+
const line = `[${timestamp}] ${status}: ${path}${msg}\n`;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
await withFileMutationQueue(LOG_FILE, async () => {
|
|
55
|
+
await appendFile(LOG_FILE, line);
|
|
56
|
+
});
|
|
57
|
+
} catch {
|
|
58
|
+
// Ignore logging errors
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const readSchema = Type.Object({
|
|
63
|
+
path: Type.String({ description: "Path to the file to read (relative or absolute)" }),
|
|
64
|
+
offset: Type.Optional(Type.Number({ description: "Line number to start reading from (1-indexed)" })),
|
|
65
|
+
limit: Type.Optional(Type.Number({ description: "Maximum number of lines to read" })),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export default function (pi: ExtensionAPI) {
|
|
69
|
+
pi.registerTool({
|
|
70
|
+
name: "read", // Same name as built-in - this will override it
|
|
71
|
+
label: "read (audited)",
|
|
72
|
+
description:
|
|
73
|
+
"Read the contents of a file with access logging. Some sensitive paths (.env, secrets, credentials) are blocked.",
|
|
74
|
+
parameters: readSchema,
|
|
75
|
+
|
|
76
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
77
|
+
const { path, offset, limit } = params;
|
|
78
|
+
const absolutePath = resolve(ctx.cwd, path);
|
|
79
|
+
|
|
80
|
+
// Check if path is blocked
|
|
81
|
+
if (isBlockedPath(absolutePath)) {
|
|
82
|
+
await logAccess(absolutePath, false, "matches blocked pattern");
|
|
83
|
+
return {
|
|
84
|
+
content: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
text: `Access denied: "${path}" matches a blocked pattern (sensitive file). This tool blocks access to .env files, secrets, credentials, and SSH/AWS/GPG directories.`,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
details: { blocked: true },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Log allowed access
|
|
95
|
+
await logAccess(absolutePath, true);
|
|
96
|
+
|
|
97
|
+
// Perform the actual read (simplified implementation)
|
|
98
|
+
try {
|
|
99
|
+
await access(absolutePath, constants.R_OK);
|
|
100
|
+
const content = await readFile(absolutePath, "utf-8");
|
|
101
|
+
const lines = content.split("\n");
|
|
102
|
+
|
|
103
|
+
// Apply offset and limit
|
|
104
|
+
const startLine = offset ? Math.max(0, offset - 1) : 0;
|
|
105
|
+
const endLine = limit ? startLine + limit : lines.length;
|
|
106
|
+
const selectedLines = lines.slice(startLine, endLine);
|
|
107
|
+
|
|
108
|
+
// Basic truncation (50KB limit)
|
|
109
|
+
let text = selectedLines.join("\n");
|
|
110
|
+
const maxBytes = 50 * 1024;
|
|
111
|
+
if (Buffer.byteLength(text, "utf-8") > maxBytes) {
|
|
112
|
+
text = `${text.slice(0, maxBytes)}\n\n[Output truncated at 50KB]`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text }] as TextContent[],
|
|
117
|
+
details: { lines: lines.length },
|
|
118
|
+
};
|
|
119
|
+
} catch (error: any) {
|
|
120
|
+
return {
|
|
121
|
+
content: [{ type: "text", text: `Error reading file: ${error.message}` }] as TextContent[],
|
|
122
|
+
details: { error: true },
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
// No renderCall/renderResult - uses built-in renderer automatically
|
|
128
|
+
// (syntax highlighting, line numbers, truncation warnings, etc.)
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Also register a command to view the access log
|
|
132
|
+
pi.registerCommand("read-log", {
|
|
133
|
+
description: "View the file access log",
|
|
134
|
+
handler: async (_args, ctx) => {
|
|
135
|
+
try {
|
|
136
|
+
const log = readFileSync(LOG_FILE, "utf-8");
|
|
137
|
+
const lines = log.trim().split("\n").slice(-20); // Last 20 entries
|
|
138
|
+
ctx.ui.notify(`Recent file access:\n${lines.join("\n")}`, "info");
|
|
139
|
+
} catch {
|
|
140
|
+
ctx.ui.notify("No access log found", "info");
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|