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,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Questionnaire Tool - Unified tool for asking single or multiple questions
|
|
3
|
+
*
|
|
4
|
+
* Single question: simple options list
|
|
5
|
+
* Multiple questions: tab bar navigation between questions
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import {
|
|
10
|
+
Editor,
|
|
11
|
+
type EditorTheme,
|
|
12
|
+
Key,
|
|
13
|
+
matchesKey,
|
|
14
|
+
Text,
|
|
15
|
+
visibleWidth,
|
|
16
|
+
wrapTextWithAnsi,
|
|
17
|
+
} from "@earendil-works/pi-tui";
|
|
18
|
+
import { Type } from "typebox";
|
|
19
|
+
|
|
20
|
+
// Types
|
|
21
|
+
interface QuestionOption {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type RenderOption = QuestionOption & { isOther?: boolean };
|
|
28
|
+
|
|
29
|
+
interface Question {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
prompt: string;
|
|
33
|
+
options: QuestionOption[];
|
|
34
|
+
allowOther: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Answer {
|
|
38
|
+
id: string;
|
|
39
|
+
value: string;
|
|
40
|
+
label: string;
|
|
41
|
+
wasCustom: boolean;
|
|
42
|
+
index?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface QuestionnaireResult {
|
|
46
|
+
questions: Question[];
|
|
47
|
+
answers: Answer[];
|
|
48
|
+
cancelled: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Schema
|
|
52
|
+
const QuestionOptionSchema = Type.Object({
|
|
53
|
+
value: Type.String({ description: "The value returned when selected" }),
|
|
54
|
+
label: Type.String({ description: "Display label for the option" }),
|
|
55
|
+
description: Type.Optional(Type.String({ description: "Optional description shown below label" })),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const QuestionSchema = Type.Object({
|
|
59
|
+
id: Type.String({ description: "Unique identifier for this question" }),
|
|
60
|
+
label: Type.Optional(
|
|
61
|
+
Type.String({
|
|
62
|
+
description: "Short contextual label for tab bar, e.g. 'Scope', 'Priority' (defaults to Q1, Q2)",
|
|
63
|
+
}),
|
|
64
|
+
),
|
|
65
|
+
prompt: Type.String({ description: "The full question text to display" }),
|
|
66
|
+
options: Type.Array(QuestionOptionSchema, { description: "Available options to choose from" }),
|
|
67
|
+
allowOther: Type.Optional(Type.Boolean({ description: "Allow 'Type something' option (default: true)" })),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const QuestionnaireParams = Type.Object({
|
|
71
|
+
questions: Type.Array(QuestionSchema, { description: "Questions to ask the user" }),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
function errorResult(
|
|
75
|
+
message: string,
|
|
76
|
+
questions: Question[] = [],
|
|
77
|
+
): { content: { type: "text"; text: string }[]; details: QuestionnaireResult } {
|
|
78
|
+
return {
|
|
79
|
+
content: [{ type: "text", text: message }],
|
|
80
|
+
details: { questions, answers: [], cancelled: true },
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default function questionnaire(pi: ExtensionAPI) {
|
|
85
|
+
pi.registerTool({
|
|
86
|
+
name: "questionnaire",
|
|
87
|
+
label: "Questionnaire",
|
|
88
|
+
description:
|
|
89
|
+
"Ask the user one or more questions. Use for clarifying requirements, getting preferences, or confirming decisions. For single questions, shows a simple option list. For multiple questions, shows a tab-based interface.",
|
|
90
|
+
parameters: QuestionnaireParams,
|
|
91
|
+
|
|
92
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
93
|
+
if (ctx.mode !== "tui") {
|
|
94
|
+
return errorResult("Error: UI not available (running in non-interactive mode)");
|
|
95
|
+
}
|
|
96
|
+
if (params.questions.length === 0) {
|
|
97
|
+
return errorResult("Error: No questions provided");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Normalize questions with defaults
|
|
101
|
+
const questions: Question[] = params.questions.map((q, i) => ({
|
|
102
|
+
...q,
|
|
103
|
+
label: q.label || `Q${i + 1}`,
|
|
104
|
+
allowOther: q.allowOther !== false,
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
const isMulti = questions.length > 1;
|
|
108
|
+
const totalTabs = questions.length + 1; // questions + Submit
|
|
109
|
+
|
|
110
|
+
const result = await ctx.ui.custom<QuestionnaireResult>((tui, theme, _kb, done) => {
|
|
111
|
+
// State
|
|
112
|
+
let currentTab = 0;
|
|
113
|
+
let optionIndex = 0;
|
|
114
|
+
let inputMode = false;
|
|
115
|
+
let inputQuestionId: string | null = null;
|
|
116
|
+
let cachedLines: string[] | undefined;
|
|
117
|
+
const answers = new Map<string, Answer>();
|
|
118
|
+
|
|
119
|
+
// Editor for "Type something" option
|
|
120
|
+
const editorTheme: EditorTheme = {
|
|
121
|
+
borderColor: (s) => theme.fg("accent", s),
|
|
122
|
+
selectList: {
|
|
123
|
+
selectedPrefix: (t) => theme.fg("accent", t),
|
|
124
|
+
selectedText: (t) => theme.fg("accent", t),
|
|
125
|
+
description: (t) => theme.fg("muted", t),
|
|
126
|
+
scrollInfo: (t) => theme.fg("dim", t),
|
|
127
|
+
noMatch: (t) => theme.fg("warning", t),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
const editor = new Editor(tui, editorTheme);
|
|
131
|
+
|
|
132
|
+
// Helpers
|
|
133
|
+
function refresh() {
|
|
134
|
+
cachedLines = undefined;
|
|
135
|
+
tui.requestRender();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function submit(cancelled: boolean) {
|
|
139
|
+
done({ questions, answers: Array.from(answers.values()), cancelled });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function currentQuestion(): Question | undefined {
|
|
143
|
+
return questions[currentTab];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function currentOptions(): RenderOption[] {
|
|
147
|
+
const q = currentQuestion();
|
|
148
|
+
if (!q) return [];
|
|
149
|
+
const opts: RenderOption[] = [...q.options];
|
|
150
|
+
if (q.allowOther) {
|
|
151
|
+
opts.push({ value: "__other__", label: "Type something.", isOther: true });
|
|
152
|
+
}
|
|
153
|
+
return opts;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function allAnswered(): boolean {
|
|
157
|
+
return questions.every((q) => answers.has(q.id));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function advanceAfterAnswer() {
|
|
161
|
+
if (!isMulti) {
|
|
162
|
+
submit(false);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (currentTab < questions.length - 1) {
|
|
166
|
+
currentTab++;
|
|
167
|
+
} else {
|
|
168
|
+
currentTab = questions.length; // Submit tab
|
|
169
|
+
}
|
|
170
|
+
optionIndex = 0;
|
|
171
|
+
refresh();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function saveAnswer(questionId: string, value: string, label: string, wasCustom: boolean, index?: number) {
|
|
175
|
+
answers.set(questionId, { id: questionId, value, label, wasCustom, index });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Editor submit callback
|
|
179
|
+
editor.onSubmit = (value) => {
|
|
180
|
+
if (!inputQuestionId) return;
|
|
181
|
+
const trimmed = value.trim() || "(no response)";
|
|
182
|
+
saveAnswer(inputQuestionId, trimmed, trimmed, true);
|
|
183
|
+
inputMode = false;
|
|
184
|
+
inputQuestionId = null;
|
|
185
|
+
editor.setText("");
|
|
186
|
+
advanceAfterAnswer();
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
function handleInput(data: string) {
|
|
190
|
+
// Input mode: route to editor
|
|
191
|
+
if (inputMode) {
|
|
192
|
+
if (matchesKey(data, Key.escape)) {
|
|
193
|
+
inputMode = false;
|
|
194
|
+
inputQuestionId = null;
|
|
195
|
+
editor.setText("");
|
|
196
|
+
refresh();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
editor.handleInput(data);
|
|
200
|
+
refresh();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const q = currentQuestion();
|
|
205
|
+
const opts = currentOptions();
|
|
206
|
+
|
|
207
|
+
// Tab navigation (multi-question only)
|
|
208
|
+
if (isMulti) {
|
|
209
|
+
if (matchesKey(data, Key.tab) || matchesKey(data, Key.right)) {
|
|
210
|
+
currentTab = (currentTab + 1) % totalTabs;
|
|
211
|
+
optionIndex = 0;
|
|
212
|
+
refresh();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (matchesKey(data, Key.shift("tab")) || matchesKey(data, Key.left)) {
|
|
216
|
+
currentTab = (currentTab - 1 + totalTabs) % totalTabs;
|
|
217
|
+
optionIndex = 0;
|
|
218
|
+
refresh();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Submit tab
|
|
224
|
+
if (currentTab === questions.length) {
|
|
225
|
+
if (matchesKey(data, Key.enter) && allAnswered()) {
|
|
226
|
+
submit(false);
|
|
227
|
+
} else if (matchesKey(data, Key.escape)) {
|
|
228
|
+
submit(true);
|
|
229
|
+
}
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Option navigation
|
|
234
|
+
if (matchesKey(data, Key.up)) {
|
|
235
|
+
optionIndex = Math.max(0, optionIndex - 1);
|
|
236
|
+
refresh();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (matchesKey(data, Key.down)) {
|
|
240
|
+
optionIndex = Math.min(opts.length - 1, optionIndex + 1);
|
|
241
|
+
refresh();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Select option
|
|
246
|
+
if (matchesKey(data, Key.enter) && q) {
|
|
247
|
+
const opt = opts[optionIndex];
|
|
248
|
+
if (opt.isOther) {
|
|
249
|
+
inputMode = true;
|
|
250
|
+
inputQuestionId = q.id;
|
|
251
|
+
editor.setText("");
|
|
252
|
+
refresh();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
saveAnswer(q.id, opt.value, opt.label, false, optionIndex + 1);
|
|
256
|
+
advanceAfterAnswer();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Cancel
|
|
261
|
+
if (matchesKey(data, Key.escape)) {
|
|
262
|
+
submit(true);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function render(width: number): string[] {
|
|
267
|
+
if (cachedLines) return cachedLines;
|
|
268
|
+
|
|
269
|
+
const lines: string[] = [];
|
|
270
|
+
const renderWidth = Math.max(1, width);
|
|
271
|
+
const q = currentQuestion();
|
|
272
|
+
const opts = currentOptions();
|
|
273
|
+
|
|
274
|
+
function addWrapped(text: string) {
|
|
275
|
+
lines.push(...wrapTextWithAnsi(text, renderWidth));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function addWrappedWithPrefix(prefix: string, text: string) {
|
|
279
|
+
const prefixWidth = visibleWidth(prefix);
|
|
280
|
+
if (prefixWidth >= renderWidth) {
|
|
281
|
+
addWrapped(prefix + text);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const wrapped = wrapTextWithAnsi(text, renderWidth - prefixWidth);
|
|
285
|
+
const continuationPrefix = " ".repeat(prefixWidth);
|
|
286
|
+
for (let i = 0; i < wrapped.length; i++) {
|
|
287
|
+
lines.push(`${i === 0 ? prefix : continuationPrefix}${wrapped[i]}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
292
|
+
|
|
293
|
+
// Tab bar (multi-question only)
|
|
294
|
+
if (isMulti) {
|
|
295
|
+
const tabs: string[] = ["← "];
|
|
296
|
+
for (let i = 0; i < questions.length; i++) {
|
|
297
|
+
const isActive = i === currentTab;
|
|
298
|
+
const isAnswered = answers.has(questions[i].id);
|
|
299
|
+
const lbl = questions[i].label;
|
|
300
|
+
const box = isAnswered ? "■" : "□";
|
|
301
|
+
const color = isAnswered ? "success" : "muted";
|
|
302
|
+
const text = ` ${box} ${lbl} `;
|
|
303
|
+
const styled = isActive ? theme.bg("selectedBg", theme.fg("text", text)) : theme.fg(color, text);
|
|
304
|
+
tabs.push(`${styled} `);
|
|
305
|
+
}
|
|
306
|
+
const canSubmit = allAnswered();
|
|
307
|
+
const isSubmitTab = currentTab === questions.length;
|
|
308
|
+
const submitText = " ✓ Submit ";
|
|
309
|
+
const submitStyled = isSubmitTab
|
|
310
|
+
? theme.bg("selectedBg", theme.fg("text", submitText))
|
|
311
|
+
: theme.fg(canSubmit ? "success" : "dim", submitText);
|
|
312
|
+
tabs.push(`${submitStyled} →`);
|
|
313
|
+
addWrappedWithPrefix(" ", tabs.join(""));
|
|
314
|
+
lines.push("");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Helper to render options list
|
|
318
|
+
function renderOptions() {
|
|
319
|
+
for (let i = 0; i < opts.length; i++) {
|
|
320
|
+
const opt = opts[i];
|
|
321
|
+
const selected = i === optionIndex;
|
|
322
|
+
const isOther = opt.isOther === true;
|
|
323
|
+
const prefix = selected ? theme.fg("accent", "> ") : " ";
|
|
324
|
+
const label = `${i + 1}. ${opt.label}${isOther && inputMode ? " ✎" : ""}`;
|
|
325
|
+
const color = selected || (isOther && inputMode) ? "accent" : "text";
|
|
326
|
+
|
|
327
|
+
addWrappedWithPrefix(prefix, theme.fg(color, label));
|
|
328
|
+
if (opt.description) {
|
|
329
|
+
addWrappedWithPrefix(" ", theme.fg("muted", opt.description));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Content
|
|
335
|
+
if (inputMode && q) {
|
|
336
|
+
addWrappedWithPrefix(" ", theme.fg("text", q.prompt));
|
|
337
|
+
lines.push("");
|
|
338
|
+
// Show options for reference
|
|
339
|
+
renderOptions();
|
|
340
|
+
lines.push("");
|
|
341
|
+
addWrappedWithPrefix(" ", theme.fg("muted", "Your answer:"));
|
|
342
|
+
for (const line of editor.render(Math.max(1, renderWidth - 2))) {
|
|
343
|
+
lines.push(` ${line}`);
|
|
344
|
+
}
|
|
345
|
+
lines.push("");
|
|
346
|
+
addWrappedWithPrefix(" ", theme.fg("dim", "Enter to submit • Esc to cancel"));
|
|
347
|
+
} else if (currentTab === questions.length) {
|
|
348
|
+
addWrappedWithPrefix(" ", theme.fg("accent", theme.bold("Ready to submit")));
|
|
349
|
+
lines.push("");
|
|
350
|
+
for (const question of questions) {
|
|
351
|
+
const answer = answers.get(question.id);
|
|
352
|
+
if (answer) {
|
|
353
|
+
const prefix = answer.wasCustom ? "(wrote) " : "";
|
|
354
|
+
const summary = `${theme.fg("muted", `${question.label}: `)}${theme.fg("text", prefix + answer.label)}`;
|
|
355
|
+
addWrappedWithPrefix(" ", summary);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
lines.push("");
|
|
359
|
+
if (allAnswered()) {
|
|
360
|
+
addWrappedWithPrefix(" ", theme.fg("success", "Press Enter to submit"));
|
|
361
|
+
} else {
|
|
362
|
+
const missing = questions
|
|
363
|
+
.filter((q) => !answers.has(q.id))
|
|
364
|
+
.map((q) => q.label)
|
|
365
|
+
.join(", ");
|
|
366
|
+
addWrappedWithPrefix(" ", theme.fg("warning", `Unanswered: ${missing}`));
|
|
367
|
+
}
|
|
368
|
+
} else if (q) {
|
|
369
|
+
addWrappedWithPrefix(" ", theme.fg("text", q.prompt));
|
|
370
|
+
lines.push("");
|
|
371
|
+
renderOptions();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
lines.push("");
|
|
375
|
+
if (!inputMode) {
|
|
376
|
+
const help = isMulti
|
|
377
|
+
? "Tab/←→ navigate • ↑↓ select • Enter confirm • Esc cancel"
|
|
378
|
+
: "↑↓ navigate • Enter select • Esc cancel";
|
|
379
|
+
addWrappedWithPrefix(" ", theme.fg("dim", help));
|
|
380
|
+
}
|
|
381
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
382
|
+
|
|
383
|
+
cachedLines = lines;
|
|
384
|
+
return lines;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return {
|
|
388
|
+
render,
|
|
389
|
+
invalidate: () => {
|
|
390
|
+
cachedLines = undefined;
|
|
391
|
+
},
|
|
392
|
+
handleInput,
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
if (result.cancelled) {
|
|
397
|
+
return {
|
|
398
|
+
content: [{ type: "text", text: "User cancelled the questionnaire" }],
|
|
399
|
+
details: result,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const answerLines = result.answers.map((a) => {
|
|
404
|
+
const qLabel = questions.find((q) => q.id === a.id)?.label || a.id;
|
|
405
|
+
if (a.wasCustom) {
|
|
406
|
+
return `${qLabel}: user wrote: ${a.label}`;
|
|
407
|
+
}
|
|
408
|
+
return `${qLabel}: user selected: ${a.index}. ${a.label}`;
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
return {
|
|
412
|
+
content: [{ type: "text", text: answerLines.join("\n") }],
|
|
413
|
+
details: result,
|
|
414
|
+
};
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
renderCall(args, theme, _context) {
|
|
418
|
+
const qs = (args.questions as Question[]) || [];
|
|
419
|
+
const count = qs.length;
|
|
420
|
+
const labels = qs.map((q) => q.label || q.id).join(", ");
|
|
421
|
+
let text = theme.fg("toolTitle", theme.bold("questionnaire "));
|
|
422
|
+
text += theme.fg("muted", `${count} question${count !== 1 ? "s" : ""}`);
|
|
423
|
+
if (labels) {
|
|
424
|
+
text += theme.fg("dim", ` (${labels})`);
|
|
425
|
+
}
|
|
426
|
+
return new Text(text, 0, 0);
|
|
427
|
+
},
|
|
428
|
+
|
|
429
|
+
renderResult(result, _options, theme, _context) {
|
|
430
|
+
const details = result.details as QuestionnaireResult | undefined;
|
|
431
|
+
if (!details) {
|
|
432
|
+
const text = result.content[0];
|
|
433
|
+
return new Text(text?.type === "text" ? text.text : "", 0, 0);
|
|
434
|
+
}
|
|
435
|
+
if (details.cancelled) {
|
|
436
|
+
return new Text(theme.fg("warning", "Cancelled"), 0, 0);
|
|
437
|
+
}
|
|
438
|
+
const lines = details.answers.map((a) => {
|
|
439
|
+
if (a.wasCustom) {
|
|
440
|
+
return `${theme.fg("success", "✓ ")}${theme.fg("accent", a.id)}: ${theme.fg("muted", "(wrote) ")}${a.label}`;
|
|
441
|
+
}
|
|
442
|
+
const display = a.index ? `${a.index}. ${a.label}` : a.label;
|
|
443
|
+
return `${theme.fg("success", "✓ ")}${theme.fg("accent", a.id)}: ${display}`;
|
|
444
|
+
});
|
|
445
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rainbow Editor - highlights "ultrathink" with animated shine effect
|
|
3
|
+
*
|
|
4
|
+
* Usage: pi --extension ./examples/extensions/rainbow-editor.ts
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { CustomEditor, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
|
|
9
|
+
// Base colors (coral → yellow → green → teal → blue → purple → pink)
|
|
10
|
+
const COLORS: [number, number, number][] = [
|
|
11
|
+
[233, 137, 115], // coral
|
|
12
|
+
[228, 186, 103], // yellow
|
|
13
|
+
[141, 192, 122], // green
|
|
14
|
+
[102, 194, 179], // teal
|
|
15
|
+
[121, 157, 207], // blue
|
|
16
|
+
[157, 134, 195], // purple
|
|
17
|
+
[206, 130, 172], // pink
|
|
18
|
+
];
|
|
19
|
+
const RESET = "\x1b[0m";
|
|
20
|
+
|
|
21
|
+
function brighten(rgb: [number, number, number], factor: number): string {
|
|
22
|
+
const [r, g, b] = rgb.map((c) => Math.round(c + (255 - c) * factor));
|
|
23
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function colorize(text: string, shinePos: number): string {
|
|
27
|
+
return (
|
|
28
|
+
[...text]
|
|
29
|
+
.map((c, i) => {
|
|
30
|
+
const baseColor = COLORS[i % COLORS.length]!;
|
|
31
|
+
// 3-letter shine: center bright, adjacent dimmer
|
|
32
|
+
let factor = 0;
|
|
33
|
+
if (shinePos >= 0) {
|
|
34
|
+
const dist = Math.abs(i - shinePos);
|
|
35
|
+
if (dist === 0) factor = 0.7;
|
|
36
|
+
else if (dist === 1) factor = 0.35;
|
|
37
|
+
}
|
|
38
|
+
return `${brighten(baseColor, factor)}${c}`;
|
|
39
|
+
})
|
|
40
|
+
.join("") + RESET
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class RainbowEditor extends CustomEditor {
|
|
45
|
+
private animationTimer?: ReturnType<typeof setInterval>;
|
|
46
|
+
private frame = 0;
|
|
47
|
+
|
|
48
|
+
private hasUltrathink(): boolean {
|
|
49
|
+
return /ultrathink/i.test(this.getText());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private startAnimation(): void {
|
|
53
|
+
if (this.animationTimer) return;
|
|
54
|
+
this.animationTimer = setInterval(() => {
|
|
55
|
+
this.frame++;
|
|
56
|
+
this.tui.requestRender();
|
|
57
|
+
}, 60);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private stopAnimation(): void {
|
|
61
|
+
if (this.animationTimer) {
|
|
62
|
+
clearInterval(this.animationTimer);
|
|
63
|
+
this.animationTimer = undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
handleInput(data: string): void {
|
|
68
|
+
super.handleInput(data);
|
|
69
|
+
if (this.hasUltrathink()) {
|
|
70
|
+
this.startAnimation();
|
|
71
|
+
} else {
|
|
72
|
+
this.stopAnimation();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
render(width: number): string[] {
|
|
77
|
+
// Cycle: 10 shine positions + 10 pause frames
|
|
78
|
+
const cycle = this.frame % 20;
|
|
79
|
+
const shinePos = cycle < 10 ? cycle : -1; // -1 means no shine (pause)
|
|
80
|
+
return super.render(width).map((line) => line.replace(/ultrathink/gi, (m) => colorize(m, shinePos)));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default function (pi: ExtensionAPI) {
|
|
85
|
+
pi.on("session_start", (_event, ctx) => {
|
|
86
|
+
ctx.ui.setEditorComponent((tui, theme, kb) => new RainbowEditor(tui, theme, kb));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reload Runtime Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates ctx.reload() from ExtensionCommandContext and an LLM-callable
|
|
5
|
+
* tool that queues a follow-up command to trigger reload.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import { Type } from "typebox";
|
|
10
|
+
|
|
11
|
+
export default function (pi: ExtensionAPI) {
|
|
12
|
+
// Command entrypoint for reload.
|
|
13
|
+
// Treat reload as terminal for this handler.
|
|
14
|
+
pi.registerCommand("reload-runtime", {
|
|
15
|
+
description: "Reload extensions, skills, prompts, themes, and context files",
|
|
16
|
+
handler: async (_args, ctx) => {
|
|
17
|
+
await ctx.reload();
|
|
18
|
+
return;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// LLM-callable tool. Tools get ExtensionContext, so they cannot call ctx.reload() directly.
|
|
23
|
+
// Instead, queue a follow-up user command that executes the command above.
|
|
24
|
+
pi.registerTool({
|
|
25
|
+
name: "reload_runtime",
|
|
26
|
+
label: "Reload Runtime",
|
|
27
|
+
description: "Reload extensions, skills, prompts, themes, and context files",
|
|
28
|
+
parameters: Type.Object({}),
|
|
29
|
+
async execute() {
|
|
30
|
+
pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
|
|
31
|
+
return {
|
|
32
|
+
content: [{ type: "text", text: "Queued /reload-runtime as a follow-up command." }],
|
|
33
|
+
details: {},
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Extension UI Demo
|
|
3
|
+
*
|
|
4
|
+
* Purpose-built extension that exercises all RPC-supported extension UI methods.
|
|
5
|
+
* Designed to be loaded alongside the rpc-extension-ui-example.ts script to
|
|
6
|
+
* demonstrate the full extension UI protocol.
|
|
7
|
+
*
|
|
8
|
+
* UI methods exercised:
|
|
9
|
+
* - select() - on tool_call for dangerous bash commands
|
|
10
|
+
* - confirm() - on session_before_switch
|
|
11
|
+
* - input() - via /rpc-input command
|
|
12
|
+
* - editor() - via /rpc-editor command
|
|
13
|
+
* - notify() - after each dialog completes
|
|
14
|
+
* - setStatus() - on turn_start/turn_end
|
|
15
|
+
* - setWidget() - on session_start
|
|
16
|
+
* - setTitle() - on session_start
|
|
17
|
+
* - setEditorText() - via /rpc-prefill command
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
21
|
+
|
|
22
|
+
export default function (pi: ExtensionAPI) {
|
|
23
|
+
let turnCount = 0;
|
|
24
|
+
|
|
25
|
+
// -- setTitle, setWidget, setStatus on session lifecycle --
|
|
26
|
+
|
|
27
|
+
pi.on("session_start", async (event, ctx) => {
|
|
28
|
+
ctx.ui.setTitle(event.reason === "new" ? "pi RPC Demo (new session)" : "pi RPC Demo");
|
|
29
|
+
ctx.ui.setWidget("rpc-demo", ["--- RPC Extension UI Demo ---", "Loaded and ready."]);
|
|
30
|
+
ctx.ui.setStatus("rpc-demo", `Turns: ${turnCount}`);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// -- setStatus on turn lifecycle --
|
|
34
|
+
|
|
35
|
+
pi.on("turn_start", async (_event, ctx) => {
|
|
36
|
+
turnCount++;
|
|
37
|
+
ctx.ui.setStatus("rpc-demo", `Turn ${turnCount} running...`);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
pi.on("turn_end", async (_event, ctx) => {
|
|
41
|
+
ctx.ui.setStatus("rpc-demo", `Turn ${turnCount} done`);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// -- select on dangerous tool calls --
|
|
45
|
+
|
|
46
|
+
pi.on("tool_call", async (event, ctx) => {
|
|
47
|
+
if (event.toolName !== "bash") return undefined;
|
|
48
|
+
|
|
49
|
+
const command = event.input.command as string;
|
|
50
|
+
const isDangerous = /\brm\s+(-rf?|--recursive)/i.test(command) || /\bsudo\b/i.test(command);
|
|
51
|
+
|
|
52
|
+
if (isDangerous) {
|
|
53
|
+
if (!ctx.hasUI) {
|
|
54
|
+
return { block: true, reason: "Dangerous command blocked (no UI)" };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const choice = await ctx.ui.select(`Dangerous command: ${command}`, ["Allow", "Block"]);
|
|
58
|
+
if (choice !== "Allow") {
|
|
59
|
+
ctx.ui.notify("Command blocked by user", "warning");
|
|
60
|
+
return { block: true, reason: "Blocked by user" };
|
|
61
|
+
}
|
|
62
|
+
ctx.ui.notify("Command allowed", "info");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return undefined;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// -- confirm on session clear --
|
|
69
|
+
|
|
70
|
+
pi.on("session_before_switch", async (event, ctx) => {
|
|
71
|
+
if (event.reason !== "new") return;
|
|
72
|
+
if (!ctx.hasUI) return;
|
|
73
|
+
|
|
74
|
+
const confirmed = await ctx.ui.confirm("Clear session?", "All messages will be lost.");
|
|
75
|
+
if (!confirmed) {
|
|
76
|
+
ctx.ui.notify("Clear cancelled", "info");
|
|
77
|
+
return { cancel: true };
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// -- input via command --
|
|
82
|
+
|
|
83
|
+
pi.registerCommand("rpc-input", {
|
|
84
|
+
description: "Prompt for text input (demonstrates ctx.ui.input in RPC)",
|
|
85
|
+
handler: async (_args, ctx) => {
|
|
86
|
+
const value = await ctx.ui.input("Enter a value", "type something...");
|
|
87
|
+
if (value) {
|
|
88
|
+
ctx.ui.notify(`You entered: ${value}`, "info");
|
|
89
|
+
} else {
|
|
90
|
+
ctx.ui.notify("Input cancelled", "info");
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// -- editor via command --
|
|
96
|
+
|
|
97
|
+
pi.registerCommand("rpc-editor", {
|
|
98
|
+
description: "Open multi-line editor (demonstrates ctx.ui.editor in RPC)",
|
|
99
|
+
handler: async (_args, ctx) => {
|
|
100
|
+
const text = await ctx.ui.editor("Edit some text", "Line 1\nLine 2\nLine 3");
|
|
101
|
+
if (text) {
|
|
102
|
+
ctx.ui.notify(`Editor submitted (${text.split("\n").length} lines)`, "info");
|
|
103
|
+
} else {
|
|
104
|
+
ctx.ui.notify("Editor cancelled", "info");
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// -- setEditorText via command --
|
|
110
|
+
|
|
111
|
+
pi.registerCommand("rpc-prefill", {
|
|
112
|
+
description: "Prefill the input editor (demonstrates ctx.ui.setEditorText in RPC)",
|
|
113
|
+
handler: async (_args, ctx) => {
|
|
114
|
+
ctx.ui.setEditorText("This text was set by the rpc-demo extension.");
|
|
115
|
+
ctx.ui.notify("Editor prefilled", "info");
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|