raga-cli 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/LICENSE +21 -0
- package/README.md +139 -2
- package/bundled-skills/AGENTS.md +5 -0
- package/bundled-skills/README.md +25 -0
- package/bundled-skills/agents/comment-sicko.json +9 -0
- package/bundled-skills/agents/comment-sicko.md +28 -0
- package/bundled-skills/agents/model-roles.json +41 -0
- package/bundled-skills/agents/poteto-agent.json +9 -0
- package/bundled-skills/agents/poteto-agent.md +4 -0
- package/bundled-skills/agents/worker.json +8 -0
- package/bundled-skills/agents/worker.md +1 -0
- package/bundled-skills/bundle.json +1448 -0
- package/bundled-skills/dependencies.json +40 -0
- package/bundled-skills/docs/guide/01-setup.md +3 -0
- package/bundled-skills/docs/guide/02-peak.md +135 -0
- package/bundled-skills/docs/guide/03-understand.md +79 -0
- package/bundled-skills/docs/guide/04-design.md +133 -0
- package/bundled-skills/docs/guide/05-build-and-clean.md +83 -0
- package/bundled-skills/docs/guide/06-verify-and-ship.md +166 -0
- package/bundled-skills/docs/guide/07-overnight.md +118 -0
- package/bundled-skills/docs/guide/08-principles.md +72 -0
- package/bundled-skills/docs/guide/09-make-it-yours.md +96 -0
- package/bundled-skills/docs/guide/10-recipes-and-pitfalls.md +180 -0
- package/bundled-skills/docs/guide/README.md +38 -0
- package/bundled-skills/docs/guide/images/design.jpg +0 -0
- package/bundled-skills/docs/guide/images/overnight.jpg +0 -0
- package/bundled-skills/docs/guide/images/recipes.jpg +0 -0
- package/bundled-skills/docs/guide/images/router.jpg +0 -0
- package/bundled-skills/docs/guide/images/understanding.jpg +0 -0
- package/bundled-skills/docs/guide/images/verification.jpg +0 -0
- package/bundled-skills/licenses/commander +22 -0
- package/bundled-skills/licenses/cursor-team-kit +21 -0
- package/bundled-skills/licenses/no-mistakes +21 -0
- package/bundled-skills/licenses/pstack +21 -0
- package/bundled-skills/skills/peak/SKILL.md +184 -0
- package/bundled-skills/skills/peak/playbooks/authoring-a-skill.md +12 -0
- package/bundled-skills/skills/peak/playbooks/autonomous-run.md +13 -0
- package/bundled-skills/skills/peak/playbooks/autopilot-full.md +25 -0
- package/bundled-skills/skills/peak/playbooks/autopilot-stack.md +12 -0
- package/bundled-skills/skills/peak/playbooks/babysit.md +18 -0
- package/bundled-skills/skills/peak/playbooks/bug-fix.md +15 -0
- package/bundled-skills/skills/peak/playbooks/eval.md +25 -0
- package/bundled-skills/skills/peak/playbooks/feature.md +21 -0
- package/bundled-skills/skills/peak/playbooks/hillclimb.md +21 -0
- package/bundled-skills/skills/peak/playbooks/investigation.md +14 -0
- package/bundled-skills/skills/peak/playbooks/multi-phase-plan.md +155 -0
- package/bundled-skills/skills/peak/playbooks/opening-a-pr.md +34 -0
- package/bundled-skills/skills/peak/playbooks/orchestrate.md +112 -0
- package/bundled-skills/skills/peak/playbooks/pause-safely.md +10 -0
- package/bundled-skills/skills/peak/playbooks/perf-issue.md +25 -0
- package/bundled-skills/skills/peak/playbooks/prototype.md +14 -0
- package/bundled-skills/skills/peak/playbooks/refactoring.md +16 -0
- package/bundled-skills/skills/peak/playbooks/runtime-forensics.md +11 -0
- package/bundled-skills/skills/peak/playbooks/session-pickup.md +11 -0
- package/bundled-skills/skills/peak/playbooks/shipping.md +12 -0
- package/bundled-skills/skills/peak/playbooks/trace-forensics.md +14 -0
- package/bundled-skills/skills/peak/playbooks/visual-parity.md +11 -0
- package/bundled-skills/skills/peak/playbooks/worktree-cleanup.md +6 -0
- package/bundled-skills/skills/peak/references/architect/SKILL.md +81 -0
- package/bundled-skills/skills/peak/references/architect/references/design-red-flags.md +57 -0
- package/bundled-skills/skills/peak/references/architect/references/rationale-template.md +35 -0
- package/bundled-skills/skills/peak/references/architect/references/runner-prompt.md +20 -0
- package/bundled-skills/skills/peak/references/arena/SKILL.md +50 -0
- package/bundled-skills/skills/peak/references/automate-me/SKILL.md +106 -0
- package/bundled-skills/skills/peak/references/benchmark-checklist/SKILL.md +41 -0
- package/bundled-skills/skills/peak/references/blast-radius/SKILL.md +52 -0
- package/bundled-skills/skills/peak/references/bro/SKILL.md +9 -0
- package/bundled-skills/skills/peak/references/control-cli/SKILL.md +111 -0
- package/bundled-skills/skills/peak/references/control-ui/SKILL.md +111 -0
- package/bundled-skills/skills/peak/references/correct/SKILL.md +34 -0
- package/bundled-skills/skills/peak/references/create-formal-verification-skill/SKILL.md +43 -0
- package/bundled-skills/skills/peak/references/create-skill/SKILL.md +14 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/SKILL.md +46 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/references/feature-map-example/README.md +47 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/references/feature-map-example/create-note.md +39 -0
- package/bundled-skills/skills/peak/references/create-verification-skill/references/feature-map-example/search.md +45 -0
- package/bundled-skills/skills/peak/references/deslop/SKILL.md +24 -0
- package/bundled-skills/skills/peak/references/figure-it-out/SKILL.md +54 -0
- package/bundled-skills/skills/peak/references/how/SKILL.md +38 -0
- package/bundled-skills/skills/peak/references/how/references/explainer-prompt.md +55 -0
- package/bundled-skills/skills/peak/references/how/references/explorer-prompt.md +35 -0
- package/bundled-skills/skills/peak/references/in-your-own-words/SKILL.md +9 -0
- package/bundled-skills/skills/peak/references/interrogate/SKILL.md +76 -0
- package/bundled-skills/skills/peak/references/interrogate/references/code-quality-review.md +47 -0
- package/bundled-skills/skills/peak/references/interrogate/references/lead-judgment.md +39 -0
- package/bundled-skills/skills/peak/references/interrogate/references/reviewer-prompt.md +62 -0
- package/bundled-skills/skills/peak/references/interrogate/references/rubric.md +77 -0
- package/bundled-skills/skills/peak/references/ketchup/SKILL.md +45 -0
- package/bundled-skills/skills/peak/references/maintain-formal-verification-skill/SKILL.md +60 -0
- package/bundled-skills/skills/peak/references/maintain-verification-skill/SKILL.md +41 -0
- package/bundled-skills/skills/peak/references/no-comments/SKILL.md +26 -0
- package/bundled-skills/skills/peak/references/no-mistakes/SKILL.md +20 -0
- package/bundled-skills/skills/peak/references/no-mistakes/upstream/SKILL.md +394 -0
- package/bundled-skills/skills/peak/references/peak-setup/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/poteto-help/SKILL.md +16 -0
- package/bundled-skills/skills/peak/references/poteto-help/references/prompting.md +51 -0
- package/bundled-skills/skills/peak/references/poteto-help/references/recipes.md +51 -0
- package/bundled-skills/skills/peak/references/principle-attack-the-premise/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-boundary-discipline/SKILL.md +36 -0
- package/bundled-skills/skills/peak/references/principle-build-the-lever/SKILL.md +25 -0
- package/bundled-skills/skills/peak/references/principle-encode-lessons-in-structure/SKILL.md +13 -0
- package/bundled-skills/skills/peak/references/principle-exhaust-the-design-space/SKILL.md +11 -0
- package/bundled-skills/skills/peak/references/principle-experience-first/SKILL.md +21 -0
- package/bundled-skills/skills/peak/references/principle-explain-the-number/SKILL.md +19 -0
- package/bundled-skills/skills/peak/references/principle-fix-root-causes/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-foundational-thinking/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-guard-the-context-window/SKILL.md +14 -0
- package/bundled-skills/skills/peak/references/principle-laziness-protocol/SKILL.md +12 -0
- package/bundled-skills/skills/peak/references/principle-make-operations-idempotent/SKILL.md +24 -0
- package/bundled-skills/skills/peak/references/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +16 -0
- package/bundled-skills/skills/peak/references/principle-minimize-reader-load/SKILL.md +20 -0
- package/bundled-skills/skills/peak/references/principle-model-the-domain/SKILL.md +26 -0
- package/bundled-skills/skills/peak/references/principle-never-block-on-the-human/SKILL.md +17 -0
- package/bundled-skills/skills/peak/references/principle-outcome-oriented-execution/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/principle-prove-it-works/SKILL.md +24 -0
- package/bundled-skills/skills/peak/references/principle-redesign-from-first-principles/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/principle-separate-before-serializing-shared-state/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/principle-sequence-verifiable-units/SKILL.md +19 -0
- package/bundled-skills/skills/peak/references/principle-subtract-before-you-add/SKILL.md +20 -0
- package/bundled-skills/skills/peak/references/principle-test-behavior-not-implementation/SKILL.md +22 -0
- package/bundled-skills/skills/peak/references/principle-type-system-discipline/SKILL.md +15 -0
- package/bundled-skills/skills/peak/references/raga-runtime/SKILL.md +37 -0
- package/bundled-skills/skills/peak/references/raga-runtime/managed-tools.mjs +34 -0
- package/bundled-skills/skills/peak/references/raga-runtime/raga_runtime.py +44 -0
- package/bundled-skills/skills/peak/references/recall/SKILL.md +37 -0
- package/bundled-skills/skills/peak/references/reflect/SKILL.md +63 -0
- package/bundled-skills/skills/peak/references/reflect/references/divergent-reviewer.md +38 -0
- package/bundled-skills/skills/peak/references/reflect/references/judgment-reviewer.md +37 -0
- package/bundled-skills/skills/peak/references/reflect/references/synthesizer.md +56 -0
- package/bundled-skills/skills/peak/references/reflect/references/tooling-reviewer.md +48 -0
- package/bundled-skills/skills/peak/references/reviewer-triage.md +142 -0
- package/bundled-skills/skills/peak/references/sharpen/SKILL.md +18 -0
- package/bundled-skills/skills/peak/references/show-me-your-work/SKILL.md +84 -0
- package/bundled-skills/skills/peak/references/show-me-your-work/references/decision-log-template.tsv +1 -0
- package/bundled-skills/skills/peak/references/show-me-your-work/scripts/log.sh +42 -0
- package/bundled-skills/skills/peak/references/statechart/SKILL.md +38 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/chart-to-tla.mjs +236 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/compare-charts.mjs +104 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/lib.mjs +725 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/model/OutputFolder.cfg +6 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/model/OutputFolder.map.mjs +106 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/model/OutputFolder.tla +176 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/statechart.mjs +749 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/test/statechart.test.mjs +2790 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/test/sync.mmd +19 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/test/upload.mmd +16 -0
- package/bundled-skills/skills/peak/references/statechart/scripts/tlc-to-chart.mjs +1347 -0
- package/bundled-skills/skills/peak/references/swarm/SKILL.md +43 -0
- package/bundled-skills/skills/peak/references/tdd/SKILL.md +44 -0
- package/bundled-skills/skills/peak/references/teach/SKILL.md +23 -0
- package/bundled-skills/skills/peak/references/technical-writing/SKILL.md +108 -0
- package/bundled-skills/skills/peak/references/typescript-best-practices/SKILL.md +33 -0
- package/bundled-skills/skills/peak/references/typescript-best-practices/references/patterns.md +328 -0
- package/bundled-skills/skills/peak/references/unslop/SKILL.md +64 -0
- package/bundled-skills/skills/peak/references/verify-this/SKILL.md +76 -0
- package/bundled-skills/skills/peak/references/why/SKILL.md +100 -0
- package/bundled-skills/skills/peak/references/why/references/epistemics.md +71 -0
- package/bundled-skills/skills/peak/references/why/references/investigator-prompt.md +84 -0
- package/bundled-skills/skills/peak/references/why/references/source-playbook.md +17 -0
- package/bundled-skills/skills/peak/references/why/references/sources/code-archaeology.md +51 -0
- package/bundled-skills/skills/peak/references/why/references/sources/databricks.md +70 -0
- package/bundled-skills/skills/peak/references/why/references/sources/datadog.md +97 -0
- package/bundled-skills/skills/peak/references/why/references/sources/incident-postmortem.md +5 -0
- package/bundled-skills/skills/peak/references/why/references/sources/linear.md +48 -0
- package/bundled-skills/skills/peak/references/why/references/sources/notion.md +55 -0
- package/bundled-skills/skills/peak/references/why/references/sources/sentry.md +66 -0
- package/bundled-skills/skills/peak/references/why/references/sources/slack.md +17 -0
- package/bundled-skills/skills/peak/references/why/references/synthesizer-prompt.md +129 -0
- package/bundled-skills/skills/peak/scripts/check-plan.mjs +205 -0
- package/bundled-skills/skills/peak/scripts/check-plan.test.ts +96 -0
- package/bundled-skills/skills/peak/scripts/orch/orch.test.ts +761 -0
- package/bundled-skills/skills/peak/scripts/orch/orch.ts +588 -0
- package/bundled-skills/skills/peak/scripts/orch/store.ts +1676 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/LICENSE +22 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/esm.mjs +16 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/index.js +24 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/argument.js +149 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/command.js +2778 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/error.js +39 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/help.js +747 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/option.js +379 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/lib/suggestSimilar.js +101 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/package.json +1 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/typings/esm.d.mts +3 -0
- package/bundled-skills/skills/peak/scripts/vendor/commander/typings/index.d.ts +1113 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/cli.test.ts +224 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/cli.ts +223 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/fakes.test-helper.ts +129 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/github.test.ts +436 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/github.ts +718 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/policy.test.ts +420 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/policy.ts +836 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/render.ts +169 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/tsconfig.json +13 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/types.compile.ts +93 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/types.ts +413 -0
- package/bundled-skills/skills/peak/scripts/watch-pr/watch-pr +4 -0
- package/bundled-skills/skills/peak/scripts/worktree-audit.sh +4 -0
- package/dist/bundle/chunks/anthropic-messages-BMDYDGHW.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-Q7EZTEHK.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +86 -0
- package/dist/bundle/chunks/chunk-3EGDWOKT.js +2 -0
- package/dist/bundle/chunks/chunk-3V45WARH.js +7 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
- package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
- package/dist/bundle/chunks/chunk-AI2NMHE7.js +1567 -0
- package/dist/bundle/chunks/chunk-C4IJNE7U.js +2 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
- package/dist/bundle/chunks/chunk-G54UBZTF.js +44 -0
- package/dist/bundle/chunks/chunk-H76KZMOI.js +2 -0
- package/dist/bundle/chunks/chunk-IOPE2TJ4.js +131 -0
- package/dist/bundle/chunks/chunk-IXDQLPKS.js +11 -0
- package/dist/bundle/chunks/chunk-J22MF7YW.js +64 -0
- package/dist/bundle/chunks/chunk-JLV25LHE.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-KNY3PXQI.js +2 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-LX24DVQ5.js +2 -0
- package/dist/bundle/chunks/chunk-P2QCWBFM.js +9 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-Q4U25BSY.js +2 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
- package/dist/bundle/chunks/chunk-RFPFZTK2.js +7 -0
- package/dist/bundle/chunks/chunk-RP2WKNT7.js +4 -0
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
- package/dist/bundle/chunks/chunk-UDT647VB.js +82 -0
- package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
- package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
- package/dist/bundle/chunks/chunk-WJGLPWUE.js +16 -0
- package/dist/bundle/chunks/chunk-YMZUNB25.js +2 -0
- package/dist/bundle/chunks/cli-4P6FVVLT.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-S6CT2FXS.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +478 -0
- package/dist/bundle/chunks/easter-egg-3d-65VIC4G2.js +2 -0
- package/dist/bundle/chunks/execute-3H5WKMA3.js +505 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-35NZKG6S.js +2 -0
- package/dist/bundle/chunks/google-vertex-P33AHYYX.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-U4EH6TAM.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-J62DPS2P.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
- package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-4HXATL2M.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-75YYY35N.js +7 -0
- package/dist/bundle/chunks/openai-decisions-HEBEVGA2.js +5 -0
- package/dist/bundle/chunks/openai-responses-UWNAKTBV.js +4 -0
- package/dist/bundle/chunks/openrouter-images-HVOPXKHS.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-DG7CALOV.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-435R6IKY.js +2 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-24HEGHNN.js +2 -0
- package/dist/bundle/chunks/virtual-modules-U3JBUDP7.js +2 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/raga-runtime.js +3 -0
- package/dist/bundle/raga.js +5 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/core/export-html/template.css +1085 -0
- package/dist/core/export-html/template.html +56 -0
- package/dist/core/export-html/template.js +2044 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +79 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/theme/dark.json +78 -0
- package/dist/modes/interactive/theme/light.json +78 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +337 -0
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +463 -0
- package/docs/configuration.md +62 -0
- package/docs/containerization.md +183 -0
- package/docs/custom-provider.md +227 -0
- package/docs/docs.json +220 -0
- package/docs/environment-variables.md +101 -0
- package/docs/extensions.md +400 -0
- package/docs/how-pi-works.md +49 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +39 -0
- package/docs/json.md +226 -0
- package/docs/keybindings.md +195 -0
- package/docs/llama-cpp.md +121 -0
- package/docs/mcp.md +272 -0
- package/docs/message-types.md +279 -0
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +225 -0
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/packages.md +129 -0
- package/docs/prompt-templates.md +59 -0
- package/docs/providers.md +247 -0
- package/docs/quickstart.md +136 -0
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +193 -0
- package/docs/sdk.md +148 -0
- package/docs/security.md +99 -0
- package/docs/session-format.md +293 -0
- package/docs/sessions.md +66 -0
- package/docs/settings.md +184 -0
- package/docs/shell-aliases.md +93 -0
- package/docs/skills.md +93 -0
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +233 -0
- package/docs/termux.md +117 -0
- package/docs/themes.md +138 -0
- package/docs/tmux.md +55 -0
- package/docs/tui.md +195 -0
- package/docs/usage.md +94 -0
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +81 -0
- package/examples/README.md +36 -0
- package/examples/extensions/README.md +214 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +225 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +117 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +617 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +405 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +55 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +81 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +175 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +190 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +353 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +57 -0
- package/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +66 -0
- package/examples/extensions/plan-mode/index.ts +394 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +436 -0
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +49 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +118 -0
- package/examples/extensions/question.ts +286 -0
- package/examples/extensions/questionnaire.ts +448 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +326 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +177 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +157 -0
- package/examples/extensions/subagent/index.ts +1038 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +199 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +661 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +75 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +99 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +74 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/examples/sdk/README.md +141 -0
- package/package.json +21 -5
- package/python/raga_rlm/__init__.py +336 -0
- package/python/raga_rlm/repl.py +920 -0
- package/schemas/keybindings.schema.json +393 -0
- package/schemas/models.schema.json +1211 -0
- package/schemas/settings.schema.json +815 -0
- package/schemas/theme.schema.json +365 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Extension UI Example (TUI)
|
|
3
|
+
*
|
|
4
|
+
* A lightweight TUI chat client that spawns the agent in RPC mode.
|
|
5
|
+
* Demonstrates how to build a custom UI on top of the RPC protocol,
|
|
6
|
+
* including handling extension UI requests (select, confirm, input, editor).
|
|
7
|
+
*
|
|
8
|
+
* Usage: node examples/rpc-extension-ui.ts
|
|
9
|
+
*
|
|
10
|
+
* Slash commands:
|
|
11
|
+
* /select - demo select dialog
|
|
12
|
+
* /confirm - demo confirm dialog
|
|
13
|
+
* /input - demo input dialog
|
|
14
|
+
* /editor - demo editor dialog
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
import { StringDecoder } from "node:string_decoder";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import {
|
|
22
|
+
type Component,
|
|
23
|
+
Container,
|
|
24
|
+
Input,
|
|
25
|
+
matchesKey,
|
|
26
|
+
ProcessTerminal,
|
|
27
|
+
SelectList,
|
|
28
|
+
type TUI,
|
|
29
|
+
TuiMainScreen,
|
|
30
|
+
} from "@earendil-works/pi-tui";
|
|
31
|
+
|
|
32
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// ANSI helpers
|
|
36
|
+
// ============================================================================
|
|
37
|
+
|
|
38
|
+
const GREEN = "\x1b[32m";
|
|
39
|
+
const YELLOW = "\x1b[33m";
|
|
40
|
+
const BLUE = "\x1b[34m";
|
|
41
|
+
const MAGENTA = "\x1b[35m";
|
|
42
|
+
const RED = "\x1b[31m";
|
|
43
|
+
const DIM = "\x1b[2m";
|
|
44
|
+
const BOLD = "\x1b[1m";
|
|
45
|
+
const RESET = "\x1b[0m";
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Extension UI request type (subset of rpc-types.ts)
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
interface ExtensionUIRequest {
|
|
52
|
+
type: "extension_ui_request";
|
|
53
|
+
id: string;
|
|
54
|
+
method: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
options?: string[];
|
|
57
|
+
message?: string;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
prefill?: string;
|
|
60
|
+
notifyType?: "info" | "warning" | "error";
|
|
61
|
+
statusKey?: string;
|
|
62
|
+
statusText?: string;
|
|
63
|
+
widgetKey?: string;
|
|
64
|
+
widgetLines?: string[];
|
|
65
|
+
text?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Output log: accumulates styled lines, renders the tail that fits
|
|
70
|
+
// ============================================================================
|
|
71
|
+
|
|
72
|
+
class OutputLog implements Component {
|
|
73
|
+
private lines: string[] = [];
|
|
74
|
+
private maxLines = 1000;
|
|
75
|
+
private visibleLines = 0;
|
|
76
|
+
|
|
77
|
+
setVisibleLines(n: number): void {
|
|
78
|
+
this.visibleLines = n;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
append(line: string): void {
|
|
82
|
+
this.lines.push(line);
|
|
83
|
+
if (this.lines.length > this.maxLines) {
|
|
84
|
+
this.lines = this.lines.slice(-this.maxLines);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
appendRaw(text: string): void {
|
|
89
|
+
if (this.lines.length === 0) {
|
|
90
|
+
this.lines.push(text);
|
|
91
|
+
} else {
|
|
92
|
+
this.lines[this.lines.length - 1] += text;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
invalidate(): void {}
|
|
97
|
+
|
|
98
|
+
render(width: number): string[] {
|
|
99
|
+
if (this.lines.length === 0) return [""];
|
|
100
|
+
const n = this.visibleLines > 0 ? this.visibleLines : this.lines.length;
|
|
101
|
+
return this.lines.slice(-n).map((l) => l.slice(0, width));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// Loading indicator: "Agent: Working." -> ".." -> "..." -> "."
|
|
107
|
+
// ============================================================================
|
|
108
|
+
|
|
109
|
+
class LoadingIndicator implements Component {
|
|
110
|
+
private dots = 1;
|
|
111
|
+
private intervalId: NodeJS.Timeout | null = null;
|
|
112
|
+
private tui: TUI | null = null;
|
|
113
|
+
|
|
114
|
+
start(tui: TUI): void {
|
|
115
|
+
this.tui = tui;
|
|
116
|
+
this.dots = 1;
|
|
117
|
+
this.intervalId = setInterval(() => {
|
|
118
|
+
this.dots = (this.dots % 3) + 1;
|
|
119
|
+
this.tui?.requestRender();
|
|
120
|
+
}, 400);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
stop(): void {
|
|
124
|
+
if (this.intervalId) {
|
|
125
|
+
clearInterval(this.intervalId);
|
|
126
|
+
this.intervalId = null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
invalidate(): void {}
|
|
131
|
+
|
|
132
|
+
render(_width: number): string[] {
|
|
133
|
+
return [`${BLUE}${BOLD}Agent:${RESET} ${DIM}Working${".".repeat(this.dots)}${RESET}`];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ============================================================================
|
|
138
|
+
// Prompt input: label + single-line input
|
|
139
|
+
// ============================================================================
|
|
140
|
+
|
|
141
|
+
class PromptInput implements Component {
|
|
142
|
+
readonly input: Input;
|
|
143
|
+
onCtrlD?: () => void;
|
|
144
|
+
|
|
145
|
+
constructor() {
|
|
146
|
+
this.input = new Input();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
handleInput(data: string): void {
|
|
150
|
+
if (matchesKey(data, "ctrl+d")) {
|
|
151
|
+
this.onCtrlD?.();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.input.handleInput(data);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
invalidate(): void {
|
|
158
|
+
this.input.invalidate();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
render(width: number): string[] {
|
|
162
|
+
return [`${GREEN}${BOLD}You:${RESET}`, ...this.input.render(width)];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ============================================================================
|
|
167
|
+
// Dialog components: replace the prompt input during interactive requests
|
|
168
|
+
// ============================================================================
|
|
169
|
+
|
|
170
|
+
class SelectDialog implements Component {
|
|
171
|
+
private list: SelectList;
|
|
172
|
+
private title: string;
|
|
173
|
+
onSelect?: (value: string) => void;
|
|
174
|
+
onCancel?: () => void;
|
|
175
|
+
|
|
176
|
+
constructor(title: string, options: string[]) {
|
|
177
|
+
this.title = title;
|
|
178
|
+
const items = options.map((o) => ({ value: o, label: o }));
|
|
179
|
+
this.list = new SelectList(items, Math.min(items.length, 8), {
|
|
180
|
+
selectedPrefix: (t) => `${MAGENTA}${t}${RESET}`,
|
|
181
|
+
selectedText: (t) => `${MAGENTA}${t}${RESET}`,
|
|
182
|
+
description: (t) => `${DIM}${t}${RESET}`,
|
|
183
|
+
scrollInfo: (t) => `${DIM}${t}${RESET}`,
|
|
184
|
+
noMatch: (t) => `${YELLOW}${t}${RESET}`,
|
|
185
|
+
});
|
|
186
|
+
this.list.onSelect = (item) => this.onSelect?.(item.value);
|
|
187
|
+
this.list.onCancel = () => this.onCancel?.();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
handleInput(data: string): void {
|
|
191
|
+
this.list.handleInput(data);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
invalidate(): void {
|
|
195
|
+
this.list.invalidate();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
render(width: number): string[] {
|
|
199
|
+
return [
|
|
200
|
+
`${MAGENTA}${BOLD}${this.title}${RESET}`,
|
|
201
|
+
...this.list.render(width),
|
|
202
|
+
`${DIM}Up/Down, Enter to select, Esc to cancel${RESET}`,
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
class InputDialog implements Component {
|
|
208
|
+
private dialogInput: Input;
|
|
209
|
+
private title: string;
|
|
210
|
+
onCtrlD?: () => void;
|
|
211
|
+
|
|
212
|
+
constructor(title: string, prefill?: string) {
|
|
213
|
+
this.title = title;
|
|
214
|
+
this.dialogInput = new Input();
|
|
215
|
+
if (prefill) this.dialogInput.setValue(prefill);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
set onSubmit(fn: ((value: string) => void) | undefined) {
|
|
219
|
+
this.dialogInput.onSubmit = fn;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
set onEscape(fn: (() => void) | undefined) {
|
|
223
|
+
this.dialogInput.onEscape = fn;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
get inputComponent(): Input {
|
|
227
|
+
return this.dialogInput;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
handleInput(data: string): void {
|
|
231
|
+
if (matchesKey(data, "ctrl+d")) {
|
|
232
|
+
this.onCtrlD?.();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.dialogInput.handleInput(data);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
invalidate(): void {
|
|
239
|
+
this.dialogInput.invalidate();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
render(width: number): string[] {
|
|
243
|
+
return [
|
|
244
|
+
`${MAGENTA}${BOLD}${this.title}${RESET}`,
|
|
245
|
+
...this.dialogInput.render(width),
|
|
246
|
+
`${DIM}Enter to submit, Esc to cancel${RESET}`,
|
|
247
|
+
];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ============================================================================
|
|
252
|
+
// Main
|
|
253
|
+
// ============================================================================
|
|
254
|
+
|
|
255
|
+
async function main() {
|
|
256
|
+
const extensionPath = join(__dirname, "extensions/rpc-demo.ts");
|
|
257
|
+
const cliPath = join(__dirname, "../dist/cli.js");
|
|
258
|
+
|
|
259
|
+
const agent = spawn(
|
|
260
|
+
"node",
|
|
261
|
+
[cliPath, "--mode", "rpc", "--no-session", "--no-extensions", "--extension", extensionPath],
|
|
262
|
+
{ stdio: ["pipe", "pipe", "pipe"] },
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
let stderr = "";
|
|
266
|
+
agent.stderr?.on("data", (data: Buffer) => {
|
|
267
|
+
stderr += data.toString();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
271
|
+
if (agent.exitCode !== null) {
|
|
272
|
+
console.error(`Agent exited immediately. Stderr:\n${stderr}`);
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// -- TUI setup --
|
|
277
|
+
|
|
278
|
+
const terminal = new ProcessTerminal();
|
|
279
|
+
const tui: TUI = new TuiMainScreen(terminal);
|
|
280
|
+
|
|
281
|
+
const outputLog = new OutputLog();
|
|
282
|
+
const loadingIndicator = new LoadingIndicator();
|
|
283
|
+
const promptInput = new PromptInput();
|
|
284
|
+
|
|
285
|
+
const root = new Container();
|
|
286
|
+
root.addChild(outputLog);
|
|
287
|
+
root.addChild(promptInput);
|
|
288
|
+
|
|
289
|
+
tui.addChild(root);
|
|
290
|
+
tui.setFocus(promptInput.input);
|
|
291
|
+
|
|
292
|
+
// -- Agent communication --
|
|
293
|
+
|
|
294
|
+
function send(obj: Record<string, unknown>): void {
|
|
295
|
+
agent.stdin!.write(`${JSON.stringify(obj)}\n`);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
let isStreaming = false;
|
|
299
|
+
let hasTextOutput = false;
|
|
300
|
+
|
|
301
|
+
function exit(): void {
|
|
302
|
+
tui.stop();
|
|
303
|
+
agent.kill("SIGTERM");
|
|
304
|
+
process.exit(0);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// -- Bottom area management --
|
|
308
|
+
// The bottom of the screen is either the prompt input or a dialog.
|
|
309
|
+
// These helpers swap between them.
|
|
310
|
+
|
|
311
|
+
let activeDialog: Component | null = null;
|
|
312
|
+
|
|
313
|
+
function setBottomComponent(component: Component): void {
|
|
314
|
+
root.clear();
|
|
315
|
+
root.addChild(outputLog);
|
|
316
|
+
if (isStreaming) root.addChild(loadingIndicator);
|
|
317
|
+
root.addChild(component);
|
|
318
|
+
tui.setFocus(component);
|
|
319
|
+
tui.requestRender();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function showPrompt(): void {
|
|
323
|
+
activeDialog = null;
|
|
324
|
+
setBottomComponent(promptInput);
|
|
325
|
+
tui.setFocus(promptInput.input);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function showDialog(dialog: Component): void {
|
|
329
|
+
activeDialog = dialog;
|
|
330
|
+
setBottomComponent(dialog);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function showLoading(): void {
|
|
334
|
+
if (!isStreaming) {
|
|
335
|
+
isStreaming = true;
|
|
336
|
+
hasTextOutput = false;
|
|
337
|
+
root.clear();
|
|
338
|
+
root.addChild(outputLog);
|
|
339
|
+
root.addChild(loadingIndicator);
|
|
340
|
+
root.addChild(activeDialog ?? promptInput);
|
|
341
|
+
if (!activeDialog) tui.setFocus(promptInput.input);
|
|
342
|
+
loadingIndicator.start(tui);
|
|
343
|
+
tui.requestRender();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function hideLoading(): void {
|
|
348
|
+
loadingIndicator.stop();
|
|
349
|
+
root.clear();
|
|
350
|
+
root.addChild(outputLog);
|
|
351
|
+
root.addChild(activeDialog ?? promptInput);
|
|
352
|
+
if (!activeDialog) tui.setFocus(promptInput.input);
|
|
353
|
+
tui.requestRender();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// -- Extension UI dialog handling --
|
|
357
|
+
|
|
358
|
+
function showSelectDialog(title: string, options: string[], onDone: (value: string | undefined) => void): void {
|
|
359
|
+
const dialog = new SelectDialog(title, options);
|
|
360
|
+
dialog.onSelect = (value) => {
|
|
361
|
+
showPrompt();
|
|
362
|
+
onDone(value);
|
|
363
|
+
};
|
|
364
|
+
dialog.onCancel = () => {
|
|
365
|
+
showPrompt();
|
|
366
|
+
onDone(undefined);
|
|
367
|
+
};
|
|
368
|
+
showDialog(dialog);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function showInputDialog(title: string, prefill?: string, onDone?: (value: string | undefined) => void): void {
|
|
372
|
+
const dialog = new InputDialog(title, prefill);
|
|
373
|
+
dialog.onSubmit = (value) => {
|
|
374
|
+
showPrompt();
|
|
375
|
+
onDone?.(value.trim() || undefined);
|
|
376
|
+
};
|
|
377
|
+
dialog.onEscape = () => {
|
|
378
|
+
showPrompt();
|
|
379
|
+
onDone?.(undefined);
|
|
380
|
+
};
|
|
381
|
+
dialog.onCtrlD = exit;
|
|
382
|
+
showDialog(dialog);
|
|
383
|
+
tui.setFocus(dialog.inputComponent);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function handleExtensionUI(req: ExtensionUIRequest): void {
|
|
387
|
+
const { id, method } = req;
|
|
388
|
+
|
|
389
|
+
switch (method) {
|
|
390
|
+
// Dialog methods: replace prompt with interactive component
|
|
391
|
+
case "select": {
|
|
392
|
+
showSelectDialog(req.title ?? "Select", req.options ?? [], (value) => {
|
|
393
|
+
if (value !== undefined) {
|
|
394
|
+
send({ type: "extension_ui_response", id, value });
|
|
395
|
+
} else {
|
|
396
|
+
send({ type: "extension_ui_response", id, cancelled: true });
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
case "confirm": {
|
|
403
|
+
const title = req.message ? `${req.title}: ${req.message}` : (req.title ?? "Confirm");
|
|
404
|
+
showSelectDialog(title, ["Yes", "No"], (value) => {
|
|
405
|
+
send({ type: "extension_ui_response", id, confirmed: value === "Yes" });
|
|
406
|
+
});
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
case "input": {
|
|
411
|
+
const title = req.placeholder ? `${req.title} (${req.placeholder})` : (req.title ?? "Input");
|
|
412
|
+
showInputDialog(title, undefined, (value) => {
|
|
413
|
+
if (value !== undefined) {
|
|
414
|
+
send({ type: "extension_ui_response", id, value });
|
|
415
|
+
} else {
|
|
416
|
+
send({ type: "extension_ui_response", id, cancelled: true });
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
case "editor": {
|
|
423
|
+
const prefill = req.prefill?.replace(/\n/g, " ");
|
|
424
|
+
showInputDialog(req.title ?? "Editor", prefill, (value) => {
|
|
425
|
+
if (value !== undefined) {
|
|
426
|
+
send({ type: "extension_ui_response", id, value });
|
|
427
|
+
} else {
|
|
428
|
+
send({ type: "extension_ui_response", id, cancelled: true });
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Fire-and-forget methods: display as notification
|
|
435
|
+
case "notify": {
|
|
436
|
+
const notifyType = (req.notifyType as string) ?? "info";
|
|
437
|
+
const color = notifyType === "error" ? RED : notifyType === "warning" ? YELLOW : MAGENTA;
|
|
438
|
+
outputLog.append(`${color}${BOLD}Notification:${RESET} ${req.message}`);
|
|
439
|
+
tui.requestRender();
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
case "setStatus":
|
|
444
|
+
outputLog.append(
|
|
445
|
+
`${MAGENTA}${BOLD}Notification:${RESET} ${DIM}[status: ${req.statusKey}]${RESET} ${req.statusText ?? "(cleared)"}`,
|
|
446
|
+
);
|
|
447
|
+
tui.requestRender();
|
|
448
|
+
break;
|
|
449
|
+
|
|
450
|
+
case "setWidget": {
|
|
451
|
+
const lines = req.widgetLines;
|
|
452
|
+
if (lines && lines.length > 0) {
|
|
453
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} ${DIM}[widget: ${req.widgetKey}]${RESET}`);
|
|
454
|
+
for (const wl of lines) {
|
|
455
|
+
outputLog.append(` ${DIM}${wl}${RESET}`);
|
|
456
|
+
}
|
|
457
|
+
tui.requestRender();
|
|
458
|
+
}
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
case "set_editor_text":
|
|
463
|
+
promptInput.input.setValue((req.text as string) ?? "");
|
|
464
|
+
tui.requestRender();
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// -- Slash commands (local, not sent to agent) --
|
|
470
|
+
|
|
471
|
+
function handleSlashCommand(cmd: string): boolean {
|
|
472
|
+
switch (cmd) {
|
|
473
|
+
case "/select":
|
|
474
|
+
showSelectDialog("Pick a color", ["Red", "Green", "Blue", "Yellow"], (value) => {
|
|
475
|
+
if (value) {
|
|
476
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} You picked: ${value}`);
|
|
477
|
+
} else {
|
|
478
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Selection cancelled`);
|
|
479
|
+
}
|
|
480
|
+
tui.requestRender();
|
|
481
|
+
});
|
|
482
|
+
return true;
|
|
483
|
+
|
|
484
|
+
case "/confirm":
|
|
485
|
+
showSelectDialog("Are you sure?", ["Yes", "No"], (value) => {
|
|
486
|
+
const confirmed = value === "Yes";
|
|
487
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Confirmed: ${confirmed}`);
|
|
488
|
+
tui.requestRender();
|
|
489
|
+
});
|
|
490
|
+
return true;
|
|
491
|
+
|
|
492
|
+
case "/input":
|
|
493
|
+
showInputDialog("Enter your name", undefined, (value) => {
|
|
494
|
+
if (value) {
|
|
495
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} You entered: ${value}`);
|
|
496
|
+
} else {
|
|
497
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Input cancelled`);
|
|
498
|
+
}
|
|
499
|
+
tui.requestRender();
|
|
500
|
+
});
|
|
501
|
+
return true;
|
|
502
|
+
|
|
503
|
+
case "/editor":
|
|
504
|
+
showInputDialog("Edit text", "Hello, world!", (value) => {
|
|
505
|
+
if (value) {
|
|
506
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Submitted: ${value}`);
|
|
507
|
+
} else {
|
|
508
|
+
outputLog.append(`${MAGENTA}${BOLD}Notification:${RESET} Editor cancelled`);
|
|
509
|
+
}
|
|
510
|
+
tui.requestRender();
|
|
511
|
+
});
|
|
512
|
+
return true;
|
|
513
|
+
|
|
514
|
+
default:
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// -- Process agent stdout --
|
|
520
|
+
|
|
521
|
+
function handleAgentLine(line: string): void {
|
|
522
|
+
let data: Record<string, unknown>;
|
|
523
|
+
try {
|
|
524
|
+
data = JSON.parse(line);
|
|
525
|
+
} catch {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (data.type === "response" && !data.success) {
|
|
530
|
+
outputLog.append(`${RED}[error]${RESET} ${data.command}: ${data.error}`);
|
|
531
|
+
tui.requestRender();
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (data.type === "agent_start") {
|
|
536
|
+
showLoading();
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (data.type === "extension_ui_request") {
|
|
541
|
+
handleExtensionUI(data as unknown as ExtensionUIRequest);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (data.type === "message_update") {
|
|
546
|
+
const evt = data.assistantMessageEvent as Record<string, unknown> | undefined;
|
|
547
|
+
if (evt?.type === "text_delta") {
|
|
548
|
+
if (!hasTextOutput) {
|
|
549
|
+
hasTextOutput = true;
|
|
550
|
+
outputLog.append("");
|
|
551
|
+
outputLog.append(`${BLUE}${BOLD}Agent:${RESET}`);
|
|
552
|
+
}
|
|
553
|
+
const delta = evt.delta as string;
|
|
554
|
+
const parts = delta.split("\n");
|
|
555
|
+
for (let i = 0; i < parts.length; i++) {
|
|
556
|
+
if (i > 0) outputLog.append("");
|
|
557
|
+
if (parts[i]) outputLog.appendRaw(parts[i]);
|
|
558
|
+
}
|
|
559
|
+
tui.requestRender();
|
|
560
|
+
}
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (data.type === "tool_execution_start") {
|
|
565
|
+
outputLog.append(`${DIM}[tool: ${data.toolName}]${RESET}`);
|
|
566
|
+
tui.requestRender();
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (data.type === "tool_execution_end") {
|
|
571
|
+
const result = JSON.stringify(data.result).slice(0, 120);
|
|
572
|
+
outputLog.append(`${DIM}[result: ${result}...]${RESET}`);
|
|
573
|
+
tui.requestRender();
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (data.type === "agent_settled") {
|
|
578
|
+
isStreaming = false;
|
|
579
|
+
hideLoading();
|
|
580
|
+
outputLog.append("");
|
|
581
|
+
tui.requestRender();
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const stdoutDecoder = new StringDecoder("utf8");
|
|
587
|
+
let stdoutBuffer = "";
|
|
588
|
+
|
|
589
|
+
agent.stdout!.on("data", (chunk: Buffer) => {
|
|
590
|
+
stdoutBuffer += stdoutDecoder.write(chunk);
|
|
591
|
+
while (true) {
|
|
592
|
+
const newlineIndex = stdoutBuffer.indexOf("\n");
|
|
593
|
+
if (newlineIndex === -1) break;
|
|
594
|
+
|
|
595
|
+
const line = stdoutBuffer.slice(0, newlineIndex);
|
|
596
|
+
stdoutBuffer = stdoutBuffer.slice(newlineIndex + 1);
|
|
597
|
+
handleAgentLine(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
agent.stdout!.on("end", () => {
|
|
602
|
+
stdoutBuffer += stdoutDecoder.end();
|
|
603
|
+
if (stdoutBuffer.length > 0) {
|
|
604
|
+
handleAgentLine(stdoutBuffer.endsWith("\r") ? stdoutBuffer.slice(0, -1) : stdoutBuffer);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// -- User input --
|
|
609
|
+
|
|
610
|
+
promptInput.input.onSubmit = (value) => {
|
|
611
|
+
const trimmed = value.trim();
|
|
612
|
+
if (!trimmed) return;
|
|
613
|
+
|
|
614
|
+
promptInput.input.setValue("");
|
|
615
|
+
|
|
616
|
+
if (handleSlashCommand(trimmed)) {
|
|
617
|
+
outputLog.append(`${GREEN}${BOLD}You:${RESET} ${trimmed}`);
|
|
618
|
+
tui.requestRender();
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
outputLog.append(`${GREEN}${BOLD}You:${RESET} ${trimmed}`);
|
|
623
|
+
send({ type: "prompt", message: trimmed });
|
|
624
|
+
tui.requestRender();
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
promptInput.onCtrlD = exit;
|
|
628
|
+
|
|
629
|
+
promptInput.input.onEscape = () => {
|
|
630
|
+
if (isStreaming) {
|
|
631
|
+
send({ type: "abort" });
|
|
632
|
+
outputLog.append(`${YELLOW}[aborted]${RESET}`);
|
|
633
|
+
tui.requestRender();
|
|
634
|
+
} else {
|
|
635
|
+
exit();
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// -- Agent exit --
|
|
640
|
+
|
|
641
|
+
agent.on("exit", (code) => {
|
|
642
|
+
tui.stop();
|
|
643
|
+
if (stderr) console.error(stderr);
|
|
644
|
+
console.log(`Agent exited with code ${code}`);
|
|
645
|
+
process.exit(code ?? 0);
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
// -- Start --
|
|
649
|
+
|
|
650
|
+
outputLog.append(`${BOLD}RPC Chat${RESET}`);
|
|
651
|
+
outputLog.append(`${DIM}Type a message and press Enter. Esc to abort or exit. Ctrl+D to quit.${RESET}`);
|
|
652
|
+
outputLog.append(`${DIM}Slash commands: /select /confirm /input /editor${RESET}`);
|
|
653
|
+
outputLog.append("");
|
|
654
|
+
|
|
655
|
+
tui.start();
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
main().catch((err) => {
|
|
659
|
+
console.error(err);
|
|
660
|
+
process.exit(1);
|
|
661
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal SDK Usage
|
|
3
|
+
*
|
|
4
|
+
* Uses all defaults: discovers skills, extensions, tools, context files
|
|
5
|
+
* from cwd and ~/.pi/agent. Model chosen from settings or first available.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createAgentSession } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
const { session } = await createAgentSession();
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
session.subscribe((event) => {
|
|
14
|
+
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
15
|
+
process.stdout.write(event.assistantMessageEvent.delta);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
await session.prompt("What files are in the current directory?");
|
|
20
|
+
session.state.messages.forEach((msg) => {
|
|
21
|
+
console.log(msg);
|
|
22
|
+
});
|
|
23
|
+
console.log();
|
|
24
|
+
} finally {
|
|
25
|
+
session.dispose();
|
|
26
|
+
}
|