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,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session runtime
|
|
3
|
+
*
|
|
4
|
+
* Use AgentSessionRuntime when you need to replace the active AgentSession,
|
|
5
|
+
* for example for new-session, resume, fork, or import flows.
|
|
6
|
+
*
|
|
7
|
+
* The important pattern is: after the runtime replaces the active session,
|
|
8
|
+
* rebind any session-local subscriptions and extension bindings to `runtime.session`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
type CreateAgentSessionRuntimeFactory,
|
|
13
|
+
createAgentSessionFromServices,
|
|
14
|
+
createAgentSessionRuntime,
|
|
15
|
+
createAgentSessionServices,
|
|
16
|
+
getAgentDir,
|
|
17
|
+
SessionManager,
|
|
18
|
+
} from "@earendil-works/pi-coding-agent";
|
|
19
|
+
|
|
20
|
+
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
21
|
+
const services = await createAgentSessionServices({ cwd });
|
|
22
|
+
return {
|
|
23
|
+
...(await createAgentSessionFromServices({
|
|
24
|
+
services,
|
|
25
|
+
sessionManager,
|
|
26
|
+
sessionStartEvent,
|
|
27
|
+
})),
|
|
28
|
+
services,
|
|
29
|
+
diagnostics: services.diagnostics,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const runtime = await createAgentSessionRuntime(createRuntime, {
|
|
33
|
+
cwd: process.cwd(),
|
|
34
|
+
agentDir: getAgentDir(),
|
|
35
|
+
sessionManager: SessionManager.create(process.cwd()),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
let unsubscribe: (() => void) | undefined;
|
|
39
|
+
|
|
40
|
+
async function bindSession() {
|
|
41
|
+
unsubscribe?.();
|
|
42
|
+
const session = runtime.session;
|
|
43
|
+
await session.bindExtensions({});
|
|
44
|
+
unsubscribe = session.subscribe((event) => {
|
|
45
|
+
if (event.type === "queue_update") {
|
|
46
|
+
console.log("Queued:", event.steering.length + event.followUp.length);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return session;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let session = await bindSession();
|
|
53
|
+
const originalSessionFile = session.sessionFile;
|
|
54
|
+
console.log("Initial session:", originalSessionFile);
|
|
55
|
+
|
|
56
|
+
await runtime.newSession();
|
|
57
|
+
session = await bindSession();
|
|
58
|
+
console.log("After newSession():", session.sessionFile);
|
|
59
|
+
|
|
60
|
+
if (originalSessionFile) {
|
|
61
|
+
await runtime.switchSession(originalSessionFile);
|
|
62
|
+
session = await bindSession();
|
|
63
|
+
console.log("After switchSession():", session.sessionFile);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
unsubscribe?.();
|
|
67
|
+
await runtime.dispose();
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codemode, Tool Search, and MCP
|
|
3
|
+
*
|
|
4
|
+
* The CLI loads `codemode`, `tool_search`, and MCP as built-in extensions. SDK sessions add
|
|
5
|
+
* them to the resource loader's extension factories.
|
|
6
|
+
*
|
|
7
|
+
* `codemode` and `tool_search` are registered inactive. Enable them through the `defaultTools` setting
|
|
8
|
+
* (`tools` would also restrict the session to the named tools, which hides MCP tools), or let the
|
|
9
|
+
* MCP extension activate them: `codemode` for servers with `codemode` exposure, `tool_search` for
|
|
10
|
+
* servers with `deferred` exposure.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
createAgentSession,
|
|
15
|
+
createCodemodeExtension,
|
|
16
|
+
createMcpExtension,
|
|
17
|
+
createToolSearchExtension,
|
|
18
|
+
DefaultResourceLoader,
|
|
19
|
+
getAgentDir,
|
|
20
|
+
SessionManager,
|
|
21
|
+
SettingsManager,
|
|
22
|
+
} from "@earendil-works/pi-coding-agent";
|
|
23
|
+
|
|
24
|
+
const cwd = process.cwd();
|
|
25
|
+
|
|
26
|
+
const resourceLoader = new DefaultResourceLoader({
|
|
27
|
+
cwd,
|
|
28
|
+
agentDir: getAgentDir(),
|
|
29
|
+
extensionFactories: [
|
|
30
|
+
createCodemodeExtension({ mode: "on" }),
|
|
31
|
+
createToolSearchExtension(),
|
|
32
|
+
// Reads mcp.json from the agent directory and the trusted project, like the CLI.
|
|
33
|
+
createMcpExtension(),
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
await resourceLoader.reload();
|
|
37
|
+
|
|
38
|
+
const settingsManager = SettingsManager.create(cwd);
|
|
39
|
+
// `+name` adds to the configured default tools instead of replacing them.
|
|
40
|
+
settingsManager.applyOverrides({ defaultTools: ["+codemode", "+tool_search"] });
|
|
41
|
+
|
|
42
|
+
const { session } = await createAgentSession({
|
|
43
|
+
resourceLoader,
|
|
44
|
+
settingsManager,
|
|
45
|
+
sessionManager: SessionManager.inMemory(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
// Emits session_start, which connects the MCP servers in the background.
|
|
50
|
+
await session.bindExtensions({});
|
|
51
|
+
console.log("Active tools:", session.getActiveToolNames().join(", "));
|
|
52
|
+
session.subscribe((event) => {
|
|
53
|
+
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
54
|
+
process.stdout.write(event.assistantMessageEvent.delta);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
await session.prompt("Use codemode to count the TypeScript files in src/ and list the three largest.");
|
|
58
|
+
console.log();
|
|
59
|
+
} finally {
|
|
60
|
+
session.dispose();
|
|
61
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# SDK Examples
|
|
2
|
+
|
|
3
|
+
Programmatic usage of pi-coding-agent via `createAgentSession()` and `createAgentSessionRuntime()`.
|
|
4
|
+
|
|
5
|
+
The runtime example shows how to build a recreate function that closes over process-global fixed inputs and recreates cwd-bound services and sessions as the active session cwd changes.
|
|
6
|
+
|
|
7
|
+
## Examples
|
|
8
|
+
|
|
9
|
+
| File | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `01-minimal.ts` | Simplest usage with all defaults |
|
|
12
|
+
| `02-custom-model.ts` | Select model and thinking level |
|
|
13
|
+
| `03-custom-prompt.ts` | Replace or modify system prompt |
|
|
14
|
+
| `04-skills.ts` | Discover, filter, or replace skills |
|
|
15
|
+
| `05-tools.ts` | Built-in tool allowlists |
|
|
16
|
+
| `06-extensions.ts` | Logging, blocking, result modification |
|
|
17
|
+
| `07-context-files.ts` | AGENTS.md context files |
|
|
18
|
+
| `08-prompt-templates.ts` | File-based prompt templates |
|
|
19
|
+
| `09-api-keys-and-oauth.ts` | API key resolution, OAuth config |
|
|
20
|
+
| `10-settings.ts` | Override compaction, retry, terminal settings |
|
|
21
|
+
| `11-sessions.ts` | In-memory, persistent, continue, list sessions |
|
|
22
|
+
| `12-full-control.ts` | Replace everything, no discovery |
|
|
23
|
+
| `13-session-runtime.ts` | Manage runtime-backed session replacement |
|
|
24
|
+
| `14-codemode-mcp.ts` | Add the `codemode`, `tool_search`, and MCP extensions |
|
|
25
|
+
|
|
26
|
+
## Running
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cd packages/coding-agent
|
|
30
|
+
node examples/sdk/01-minimal.ts
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Reference
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { getModel } from "@earendil-works/pi-ai";
|
|
37
|
+
import {
|
|
38
|
+
createAgentSession,
|
|
39
|
+
DefaultResourceLoader,
|
|
40
|
+
ModelRuntime,
|
|
41
|
+
SessionManager,
|
|
42
|
+
SettingsManager,
|
|
43
|
+
} from "@earendil-works/pi-coding-agent";
|
|
44
|
+
|
|
45
|
+
const modelRuntime = await ModelRuntime.create();
|
|
46
|
+
|
|
47
|
+
// Minimal
|
|
48
|
+
const { session } = await createAgentSession({ modelRuntime });
|
|
49
|
+
|
|
50
|
+
// Custom model
|
|
51
|
+
const model = getModel("anthropic", "claude-opus-4-5");
|
|
52
|
+
const { session } = await createAgentSession({ model, thinkingLevel: "high", modelRuntime });
|
|
53
|
+
|
|
54
|
+
// Modify prompt
|
|
55
|
+
const loader = new DefaultResourceLoader({
|
|
56
|
+
systemPromptOverride: (base) => `${base}\n\nBe concise.`,
|
|
57
|
+
});
|
|
58
|
+
await loader.reload();
|
|
59
|
+
const { session } = await createAgentSession({ resourceLoader: loader, modelRuntime });
|
|
60
|
+
|
|
61
|
+
// Read-only
|
|
62
|
+
const { session } = await createAgentSession({ tools: ["read", "grep", "find", "ls"], modelRuntime });
|
|
63
|
+
|
|
64
|
+
// In-memory
|
|
65
|
+
const { session } = await createAgentSession({
|
|
66
|
+
sessionManager: SessionManager.inMemory(),
|
|
67
|
+
modelRuntime,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Full control
|
|
71
|
+
const customRuntime = await ModelRuntime.create({
|
|
72
|
+
authPath: "/my/app/auth.json",
|
|
73
|
+
modelsPath: "/my/app/models.json",
|
|
74
|
+
});
|
|
75
|
+
await customRuntime.setRuntimeApiKey("anthropic", process.env.MY_KEY!);
|
|
76
|
+
|
|
77
|
+
const resourceLoader = new DefaultResourceLoader({
|
|
78
|
+
systemPromptOverride: () => "You are helpful.",
|
|
79
|
+
extensionFactories: [myExtension],
|
|
80
|
+
skillsOverride: () => ({ skills: [], diagnostics: [] }),
|
|
81
|
+
agentsFilesOverride: () => ({ agentsFiles: [] }),
|
|
82
|
+
promptsOverride: () => ({ prompts: [], diagnostics: [] }),
|
|
83
|
+
});
|
|
84
|
+
await resourceLoader.reload();
|
|
85
|
+
|
|
86
|
+
const { session } = await createAgentSession({
|
|
87
|
+
model,
|
|
88
|
+
modelRuntime: customRuntime,
|
|
89
|
+
resourceLoader,
|
|
90
|
+
tools: ["read", "bash", "my_tool"],
|
|
91
|
+
customTools: [myTool],
|
|
92
|
+
sessionManager: SessionManager.inMemory(),
|
|
93
|
+
settingsManager: SettingsManager.inMemory(),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Run prompts
|
|
97
|
+
session.subscribe((event) => {
|
|
98
|
+
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
99
|
+
process.stdout.write(event.assistantMessageEvent.delta);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
await session.prompt("Hello");
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Options
|
|
106
|
+
|
|
107
|
+
| Option | Default | Description |
|
|
108
|
+
|--------|---------|-------------|
|
|
109
|
+
| `modelRuntime` | Runtime using `agentDir/auth.json` and `models.json` | Canonical model and authentication runtime |
|
|
110
|
+
| `cwd` | `process.cwd()` | Working directory |
|
|
111
|
+
| `agentDir` | `~/.pi/agent` | Config directory |
|
|
112
|
+
| `model` | From settings/first available | Model to use |
|
|
113
|
+
| `thinkingLevel` | From settings/"off" | off, low, medium, high |
|
|
114
|
+
| `tools` | `["read", "bash", "edit", "write"]` built-ins | Allowlist tool names across built-in, extension, and custom tools |
|
|
115
|
+
| `customTools` | `[]` | Additional tool definitions |
|
|
116
|
+
| `resourceLoader` | DefaultResourceLoader | Resource loader for extensions, skills, prompts, themes, and context files |
|
|
117
|
+
| `sessionManager` | `SessionManager.create(cwd)` | Persistence |
|
|
118
|
+
| `settingsManager` | `SettingsManager.create(cwd, agentDir)` | Settings overrides |
|
|
119
|
+
|
|
120
|
+
## Events
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
session.subscribe((event) => {
|
|
124
|
+
switch (event.type) {
|
|
125
|
+
case "message_update":
|
|
126
|
+
if (event.assistantMessageEvent.type === "text_delta") {
|
|
127
|
+
process.stdout.write(event.assistantMessageEvent.delta);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case "tool_execution_start":
|
|
131
|
+
console.log(`Tool: ${event.toolName}`);
|
|
132
|
+
break;
|
|
133
|
+
case "tool_execution_end":
|
|
134
|
+
console.log(`Result: ${event.result}`);
|
|
135
|
+
break;
|
|
136
|
+
case "agent_settled":
|
|
137
|
+
console.log("Done");
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "raga-cli",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Raga, a coding agent for long tasks with a persistent Python kernel (a fork of pi)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mr-jones123/raga.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"raga": "dist/bundle/raga.js"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22.19.0"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@silvia-odwyer/photon-node": "0.3.4",
|
|
19
|
+
"jiti": "2.7.0",
|
|
20
|
+
"quickjs-wasi": "3.6.2"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# Adapted from Prime Agent (MIT), github.com/PrimeIntellect-ai/prime-agent
|
|
2
|
+
"""The names the model calls from the RLM kernel namespace.
|
|
3
|
+
|
|
4
|
+
`bootstrap(namespace)` binds them once at kernel startup. Every host-backed
|
|
5
|
+
function is a coroutine that sends one `host_request` and awaits the reply.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
from collections.abc import Iterator, Mapping
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
# The kernel starts in the session cwd; `read` resolves relative paths against it even after a cell chdirs.
|
|
15
|
+
_SESSION_CWD = os.getcwd()
|
|
16
|
+
_RESTRICTED = os.environ.get("RAGA_RESTRICTED") == "1"
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"BOOTSTRAP_NAMES",
|
|
20
|
+
"CELLS_OUTPUT_BUDGET",
|
|
21
|
+
"Context",
|
|
22
|
+
"HostError",
|
|
23
|
+
"Inputs",
|
|
24
|
+
"ToolError",
|
|
25
|
+
"answer",
|
|
26
|
+
"bash",
|
|
27
|
+
"bootstrap",
|
|
28
|
+
"cells",
|
|
29
|
+
"context",
|
|
30
|
+
"edit",
|
|
31
|
+
"host_request",
|
|
32
|
+
"llm_batch",
|
|
33
|
+
"llm_query",
|
|
34
|
+
"memory",
|
|
35
|
+
"instance",
|
|
36
|
+
"read",
|
|
37
|
+
"record_cell",
|
|
38
|
+
"rlm_query",
|
|
39
|
+
"set_context",
|
|
40
|
+
"write",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class HostError(Exception):
|
|
45
|
+
"""The host answered a host_request with an error."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ToolError(Exception):
|
|
49
|
+
"""A pi tool reported an error; the message is the tool output."""
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def host_request(data: dict[str, Any]) -> Any:
|
|
53
|
+
"""Send one typed request to the host; return its result or raise HostError."""
|
|
54
|
+
# Imported lazily: `python -m raga_rlm.repl` imports this package before the
|
|
55
|
+
# kernel module registers itself as `raga_rlm.repl`.
|
|
56
|
+
from . import repl
|
|
57
|
+
|
|
58
|
+
reply = await repl.host_request(data)
|
|
59
|
+
if reply.get("status") == "ok":
|
|
60
|
+
return reply.get("result")
|
|
61
|
+
raise HostError(str(reply.get("error", "host request failed")))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async def _tool(name: str, args: dict[str, Any]) -> str:
|
|
65
|
+
result = await host_request({"type": "tool.call", "name": name, "args": args})
|
|
66
|
+
text = str(result.get("text", "")) if isinstance(result, dict) else str(result)
|
|
67
|
+
if isinstance(result, dict) and result.get("is_error"):
|
|
68
|
+
raise ToolError(text)
|
|
69
|
+
return text
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _drop_none(**fields: Any) -> dict[str, Any]:
|
|
73
|
+
return {key: value for key, value in fields.items() if value is not None}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def bash(command: str, timeout: float | None = None) -> str:
|
|
77
|
+
"""Run a shell command under the session's execution policy and return its output."""
|
|
78
|
+
return await _tool("bash", _drop_none(command=command, timeout=timeout))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
async def read(path: str, offset: int | None = None, limit: int | None = None) -> str:
|
|
82
|
+
"""Return the file's text, whole unless `offset` (1-indexed first line) or `limit` (line count) is given."""
|
|
83
|
+
with open(os.path.join(_SESSION_CWD, os.path.expanduser(path)), encoding="utf-8", errors="replace") as fh:
|
|
84
|
+
text = fh.read()
|
|
85
|
+
if offset is None and limit is None:
|
|
86
|
+
return text
|
|
87
|
+
lines = text.splitlines(keepends=True)
|
|
88
|
+
start = max((offset or 1) - 1, 0)
|
|
89
|
+
end = len(lines) if limit is None else start + limit
|
|
90
|
+
return "".join(lines[start:end])
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
async def edit(path: str, edits: list[Any]) -> str:
|
|
94
|
+
"""Apply exact replacements. `edits` holds (old, new) tuples or {"oldText","newText"} dicts."""
|
|
95
|
+
normalized: list[dict[str, str]] = []
|
|
96
|
+
for item in edits:
|
|
97
|
+
if isinstance(item, dict):
|
|
98
|
+
if "oldText" not in item or "newText" not in item:
|
|
99
|
+
raise ValueError('edit dicts need "oldText" and "newText"')
|
|
100
|
+
normalized.append({"oldText": item["oldText"], "newText": item["newText"]})
|
|
101
|
+
elif isinstance(item, (tuple, list)) and len(item) == 2:
|
|
102
|
+
normalized.append({"oldText": item[0], "newText": item[1]})
|
|
103
|
+
else:
|
|
104
|
+
raise TypeError("each edit must be an (old, new) tuple or an oldText/newText dict")
|
|
105
|
+
if _RESTRICTED:
|
|
106
|
+
target = os.path.join(_SESSION_CWD, os.path.expanduser(path))
|
|
107
|
+
with open(target, encoding="utf-8", newline="") as fh:
|
|
108
|
+
content = fh.read()
|
|
109
|
+
for item in normalized:
|
|
110
|
+
old, new = item["oldText"], item["newText"]
|
|
111
|
+
if not isinstance(old, str) or not isinstance(new, str) or not old:
|
|
112
|
+
raise ValueError("edits need nonempty oldText and string newText")
|
|
113
|
+
if content.count(old) != 1:
|
|
114
|
+
raise ToolError("Each edit must match exactly one occurrence")
|
|
115
|
+
content = content.replace(old, new, 1)
|
|
116
|
+
with open(target, "w", encoding="utf-8", newline="") as fh:
|
|
117
|
+
fh.write(content)
|
|
118
|
+
return f"Edited {path}"
|
|
119
|
+
return await _tool("edit", {"path": path, "edits": normalized})
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
async def write(path: str, content: str) -> str:
|
|
123
|
+
"""Write UTF-8 content under the session's filesystem policy."""
|
|
124
|
+
if _RESTRICTED:
|
|
125
|
+
target = os.path.join(_SESSION_CWD, os.path.expanduser(path))
|
|
126
|
+
os.makedirs(os.path.dirname(target), exist_ok=True)
|
|
127
|
+
with open(target, "w", encoding="utf-8", newline="") as fh:
|
|
128
|
+
fh.write(content)
|
|
129
|
+
return f"Wrote {path}"
|
|
130
|
+
return await _tool("write", {"path": path, "content": content})
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
async def llm_query(prompt: str, system: str | None = None, model: str | None = None) -> str:
|
|
134
|
+
"""One sub-LLM call with no tools."""
|
|
135
|
+
result = await host_request({"type": "llm.query", **_drop_none(prompt=prompt, system=system, model=model)})
|
|
136
|
+
return result["text"]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
async def llm_batch(prompts: list[str], system: str | None = None, model: str | None = None) -> list[str]:
|
|
140
|
+
"""Parallel sub-LLM calls; the host bounds concurrency."""
|
|
141
|
+
payload = _drop_none(prompts=list(prompts), system=system, model=model)
|
|
142
|
+
result = await host_request({"type": "llm.batch", **payload})
|
|
143
|
+
return list(result["texts"])
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
async def rlm_query(
|
|
147
|
+
task: str,
|
|
148
|
+
context: Any = None,
|
|
149
|
+
model: str | None = None,
|
|
150
|
+
max_turns: int | None = None,
|
|
151
|
+
*,
|
|
152
|
+
read_only: bool = False,
|
|
153
|
+
details: bool = False,
|
|
154
|
+
) -> str | dict[str, Any]:
|
|
155
|
+
"""Run a child. Instance writers get isolated checkouts; details includes the change artifact."""
|
|
156
|
+
payload = _drop_none(task=task, context=context, model=model, max_turns=max_turns, read_only=read_only)
|
|
157
|
+
result = await host_request({"type": "rlm.query", **payload})
|
|
158
|
+
return result if details else result["answer"]
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class Inputs(Mapping[str, str]):
|
|
162
|
+
"""Input names mapped to file contents. Each file is read the first time its key is read, then cached."""
|
|
163
|
+
|
|
164
|
+
def __init__(self, paths: dict[str, str] | None = None) -> None:
|
|
165
|
+
self._paths = dict(paths or {})
|
|
166
|
+
self._texts: dict[str, str] = {}
|
|
167
|
+
|
|
168
|
+
def __getitem__(self, name: str) -> str:
|
|
169
|
+
if name not in self._texts:
|
|
170
|
+
with open(self._paths[name], encoding="utf-8", errors="replace") as fh:
|
|
171
|
+
self._texts[name] = fh.read()
|
|
172
|
+
return self._texts[name]
|
|
173
|
+
|
|
174
|
+
def __iter__(self) -> Iterator[str]:
|
|
175
|
+
return iter(self._paths)
|
|
176
|
+
|
|
177
|
+
def __len__(self) -> int:
|
|
178
|
+
return len(self._paths)
|
|
179
|
+
|
|
180
|
+
def path(self, name: str) -> str:
|
|
181
|
+
"""The file behind `name`, without reading it."""
|
|
182
|
+
return self._paths[name]
|
|
183
|
+
|
|
184
|
+
def __repr__(self) -> str:
|
|
185
|
+
return f"Inputs({self._paths!r})"
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class Context:
|
|
189
|
+
"""`task` is the first user prompt, `inputs` holds large inputs, `data` is a JSON value from the parent."""
|
|
190
|
+
|
|
191
|
+
def __init__(self) -> None:
|
|
192
|
+
self.task: str = ""
|
|
193
|
+
self.inputs: Inputs = Inputs()
|
|
194
|
+
self.data: Any = None
|
|
195
|
+
|
|
196
|
+
async def history(self, offset: int = 0, limit: int | None = None) -> list[dict[str, Any]]:
|
|
197
|
+
"""Return the session's messages as {"role", "text"} dicts."""
|
|
198
|
+
result = await host_request({"type": "context.history", **_drop_none(offset=offset, limit=limit)})
|
|
199
|
+
return list(result["messages"])
|
|
200
|
+
|
|
201
|
+
def __repr__(self) -> str:
|
|
202
|
+
return (
|
|
203
|
+
f"Context(task={self.task!r}, inputs=<{len(self.inputs)} keys: {sorted(self.inputs)!r}>, "
|
|
204
|
+
f"data=<{type(self.data).__name__}>)"
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class Memory:
|
|
209
|
+
"""Scoped retrieval and unreviewed observations. Entries never grant permissions."""
|
|
210
|
+
|
|
211
|
+
async def search(self, query: str, *, task_type: str | None = None, max_chars: int = 4000, limit: int = 5) -> dict[str, Any]:
|
|
212
|
+
return await host_request({
|
|
213
|
+
"type": "memory.search",
|
|
214
|
+
**_drop_none(query=query, task_type=task_type, max_chars=max_chars, limit=limit),
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
async def get(self, entry_id: str) -> dict[str, Any]:
|
|
218
|
+
return await host_request({"type": "memory.get", "id": entry_id})
|
|
219
|
+
|
|
220
|
+
async def observe(self, text: str, evidence: list[str]) -> dict[str, Any]:
|
|
221
|
+
return await host_request({"type": "memory.observe", "text": text, "evidence": evidence})
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class Instance:
|
|
225
|
+
"""Inspect the pinned harness and propose changes without activating them."""
|
|
226
|
+
|
|
227
|
+
async def info(self) -> dict[str, Any]:
|
|
228
|
+
return await host_request({"type": "instance.info"})
|
|
229
|
+
|
|
230
|
+
async def child_patch(self, workspace_id: str) -> dict[str, Any]:
|
|
231
|
+
return await host_request({"type": "instance.child_patch", "workspace_id": workspace_id})
|
|
232
|
+
|
|
233
|
+
async def integrate(
|
|
234
|
+
self, workspace_ids: list[str], command: str, args: list[str] | None = None, *, timeout_ms: int = 120000
|
|
235
|
+
) -> dict[str, Any]:
|
|
236
|
+
return await host_request({
|
|
237
|
+
"type": "instance.integrate",
|
|
238
|
+
"workspace_ids": workspace_ids,
|
|
239
|
+
"command": command,
|
|
240
|
+
"args": args or [],
|
|
241
|
+
"timeout_ms": timeout_ms,
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
async def candidate_create(self) -> dict[str, Any]:
|
|
245
|
+
return await host_request({"type": "instance.candidate.create"})
|
|
246
|
+
|
|
247
|
+
async def candidate_read(self, candidate_id: str, path: str) -> str:
|
|
248
|
+
return await host_request({"type": "instance.candidate.read", "id": candidate_id, "path": path})
|
|
249
|
+
|
|
250
|
+
async def candidate_write(self, candidate_id: str, path: str, content: str) -> dict[str, Any]:
|
|
251
|
+
return await host_request({"type": "instance.candidate.write", "id": candidate_id, "path": path, "content": content})
|
|
252
|
+
|
|
253
|
+
async def candidate_commit(self, candidate_id: str, message: str) -> dict[str, Any]:
|
|
254
|
+
return await host_request({"type": "instance.candidate.commit", "id": candidate_id, "message": message})
|
|
255
|
+
|
|
256
|
+
async def no_mistakes(self, action: str, **options: Any) -> Any:
|
|
257
|
+
return await host_request({"type": "instance.no_mistakes", "action": action, "options": options})
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
memory = Memory()
|
|
261
|
+
instance = Instance()
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
context = Context()
|
|
265
|
+
answer: dict[str, Any] = {"content": "", "ready": False}
|
|
266
|
+
cells: list[dict[str, Any]] = []
|
|
267
|
+
# Characters of stdout and stderr that the newest `cells` entries keep in full.
|
|
268
|
+
CELLS_OUTPUT_BUDGET = 32 * 1024 * 1024
|
|
269
|
+
_DROPPED_PREFIX = "[output dropped to bound memory: "
|
|
270
|
+
|
|
271
|
+
BOOTSTRAP_NAMES = frozenset(
|
|
272
|
+
{
|
|
273
|
+
"bash",
|
|
274
|
+
"read",
|
|
275
|
+
"edit",
|
|
276
|
+
"write",
|
|
277
|
+
"llm_query",
|
|
278
|
+
"llm_batch",
|
|
279
|
+
"rlm_query",
|
|
280
|
+
"memory",
|
|
281
|
+
"instance",
|
|
282
|
+
"context",
|
|
283
|
+
"answer",
|
|
284
|
+
"cells",
|
|
285
|
+
"HostError",
|
|
286
|
+
"ToolError",
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def bootstrap(namespace: dict[str, Any]) -> None:
|
|
292
|
+
"""Bind the Python API into the kernel namespace."""
|
|
293
|
+
for name in BOOTSTRAP_NAMES:
|
|
294
|
+
namespace[name] = globals()[name]
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def set_context(task: str, inputs: dict[str, str], data: Any = None) -> None:
|
|
298
|
+
"""Fill `context.task`, `context.inputs`, and `context.data`; `inputs` maps names to file paths."""
|
|
299
|
+
if not isinstance(task, str):
|
|
300
|
+
raise TypeError("task must be a string")
|
|
301
|
+
if not isinstance(inputs, dict) or not all(isinstance(k, str) and isinstance(v, str) for k, v in inputs.items()):
|
|
302
|
+
raise TypeError("inputs must map names to file paths")
|
|
303
|
+
context.task = task
|
|
304
|
+
context.inputs = Inputs(inputs)
|
|
305
|
+
context.data = data
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def record_cell(entry: dict[str, Any]) -> None:
|
|
309
|
+
"""Append one finished cell; called by the kernel.
|
|
310
|
+
|
|
311
|
+
The newest cells keep full stdout and stderr up to CELLS_OUTPUT_BUDGET
|
|
312
|
+
characters in total; older cells keep code, result, and error only. The
|
|
313
|
+
newest cell always keeps its output.
|
|
314
|
+
"""
|
|
315
|
+
cells.append(entry)
|
|
316
|
+
kept = 0
|
|
317
|
+
evicting = False
|
|
318
|
+
for index, cell in enumerate(reversed(cells)):
|
|
319
|
+
if not isinstance(cell, dict):
|
|
320
|
+
continue
|
|
321
|
+
live = {
|
|
322
|
+
key: text
|
|
323
|
+
for key in ("stdout", "stderr")
|
|
324
|
+
if isinstance(text := cell.get(key), str) and text and not _is_dropped(text)
|
|
325
|
+
}
|
|
326
|
+
size = sum(len(text) for text in live.values())
|
|
327
|
+
if not evicting and (index == 0 or kept + size <= CELLS_OUTPUT_BUDGET):
|
|
328
|
+
kept += size
|
|
329
|
+
continue
|
|
330
|
+
evicting = True
|
|
331
|
+
for key, text in live.items():
|
|
332
|
+
cell[key] = f"{_DROPPED_PREFIX}{len(text)} characters]"
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def _is_dropped(text: str) -> bool:
|
|
336
|
+
return text.startswith(_DROPPED_PREFIX) and text.endswith(" characters]")
|