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,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitLab Duo Provider Extension
|
|
3
|
+
*
|
|
4
|
+
* Provides access to GitLab Duo AI models (Claude and GPT) through GitLab's AI Gateway.
|
|
5
|
+
* Delegates to pi-ai's built-in Anthropic and OpenAI streaming implementations.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* pi -e ./packages/coding-agent/examples/extensions/custom-provider-gitlab-duo
|
|
9
|
+
* # Then /login gitlab-duo, or set GITLAB_TOKEN=glpat-...
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type Api,
|
|
14
|
+
type AssistantMessageEventStream,
|
|
15
|
+
anthropicMessagesApi,
|
|
16
|
+
createAssistantMessageEventStream,
|
|
17
|
+
type Model,
|
|
18
|
+
type OAuthCredentials,
|
|
19
|
+
type OAuthLoginCallbacks,
|
|
20
|
+
openAIResponsesApi,
|
|
21
|
+
type SimpleStreamOptions,
|
|
22
|
+
type ThinkingLevelMap,
|
|
23
|
+
type TranscriptContext,
|
|
24
|
+
} from "@earendil-works/pi-ai/compat";
|
|
25
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
26
|
+
|
|
27
|
+
// =============================================================================
|
|
28
|
+
// Constants
|
|
29
|
+
// =============================================================================
|
|
30
|
+
|
|
31
|
+
const GITLAB_COM_URL = "https://gitlab.com";
|
|
32
|
+
const AI_GATEWAY_URL = "https://cloud.gitlab.com";
|
|
33
|
+
const ANTHROPIC_PROXY_URL = `${AI_GATEWAY_URL}/ai/v1/proxy/anthropic/`;
|
|
34
|
+
const OPENAI_PROXY_URL = `${AI_GATEWAY_URL}/ai/v1/proxy/openai/v1`;
|
|
35
|
+
|
|
36
|
+
const BUNDLED_CLIENT_ID = "da4edff2e6ebd2bc3208611e2768bc1c1dd7be791dc5ff26ca34ca9ee44f7d4b";
|
|
37
|
+
const OAUTH_SCOPES = ["api"];
|
|
38
|
+
const REDIRECT_URI = "http://127.0.0.1:8080/callback";
|
|
39
|
+
const DIRECT_ACCESS_TTL = 25 * 60 * 1000;
|
|
40
|
+
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// Models - exported for use by tests
|
|
43
|
+
// =============================================================================
|
|
44
|
+
|
|
45
|
+
type Backend = "anthropic" | "openai";
|
|
46
|
+
|
|
47
|
+
interface GitLabModel {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
backend: Backend;
|
|
51
|
+
baseUrl: string;
|
|
52
|
+
reasoning: boolean;
|
|
53
|
+
thinkingLevelMap?: ThinkingLevelMap;
|
|
54
|
+
input: ("text" | "image")[];
|
|
55
|
+
cost: { input: number; output: number; cacheRead: number; cacheWrite: number };
|
|
56
|
+
contextWindow: number;
|
|
57
|
+
maxTokens: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const MODELS: GitLabModel[] = [
|
|
61
|
+
// Anthropic
|
|
62
|
+
{
|
|
63
|
+
id: "claude-opus-4-8",
|
|
64
|
+
name: "Claude Opus 4.8",
|
|
65
|
+
backend: "anthropic",
|
|
66
|
+
baseUrl: ANTHROPIC_PROXY_URL,
|
|
67
|
+
reasoning: true,
|
|
68
|
+
thinkingLevelMap: { xhigh: "max" },
|
|
69
|
+
input: ["text", "image"],
|
|
70
|
+
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
71
|
+
contextWindow: 1000000,
|
|
72
|
+
maxTokens: 128000,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "claude-sonnet-4-6",
|
|
76
|
+
name: "Claude Sonnet 4.6",
|
|
77
|
+
backend: "anthropic",
|
|
78
|
+
baseUrl: ANTHROPIC_PROXY_URL,
|
|
79
|
+
reasoning: true,
|
|
80
|
+
thinkingLevelMap: { xhigh: "max" },
|
|
81
|
+
input: ["text", "image"],
|
|
82
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
83
|
+
contextWindow: 1000000,
|
|
84
|
+
maxTokens: 64000,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "claude-opus-4-5-20251101",
|
|
88
|
+
name: "Claude Opus 4.5",
|
|
89
|
+
backend: "anthropic",
|
|
90
|
+
baseUrl: ANTHROPIC_PROXY_URL,
|
|
91
|
+
reasoning: true,
|
|
92
|
+
thinkingLevelMap: { xhigh: "max" },
|
|
93
|
+
input: ["text", "image"],
|
|
94
|
+
cost: { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 },
|
|
95
|
+
contextWindow: 200000,
|
|
96
|
+
maxTokens: 32000,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "claude-sonnet-4-5-20250929",
|
|
100
|
+
name: "Claude Sonnet 4.5",
|
|
101
|
+
backend: "anthropic",
|
|
102
|
+
baseUrl: ANTHROPIC_PROXY_URL,
|
|
103
|
+
reasoning: true,
|
|
104
|
+
thinkingLevelMap: { xhigh: "max" },
|
|
105
|
+
input: ["text", "image"],
|
|
106
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
107
|
+
contextWindow: 200000,
|
|
108
|
+
maxTokens: 16384,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "claude-haiku-4-5-20251001",
|
|
112
|
+
name: "Claude Haiku 4.5",
|
|
113
|
+
backend: "anthropic",
|
|
114
|
+
baseUrl: ANTHROPIC_PROXY_URL,
|
|
115
|
+
reasoning: true,
|
|
116
|
+
thinkingLevelMap: { xhigh: "max" },
|
|
117
|
+
input: ["text", "image"],
|
|
118
|
+
cost: { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 },
|
|
119
|
+
contextWindow: 200000,
|
|
120
|
+
maxTokens: 8192,
|
|
121
|
+
},
|
|
122
|
+
// OpenAI (all use Responses API)
|
|
123
|
+
{
|
|
124
|
+
id: "gpt-5.5-2026-04-23",
|
|
125
|
+
name: "GPT-5.5",
|
|
126
|
+
backend: "openai",
|
|
127
|
+
baseUrl: OPENAI_PROXY_URL,
|
|
128
|
+
reasoning: true,
|
|
129
|
+
input: ["text", "image"],
|
|
130
|
+
cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 },
|
|
131
|
+
contextWindow: 272000,
|
|
132
|
+
maxTokens: 128000,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "gpt-5.1-2025-11-13",
|
|
136
|
+
name: "GPT-5.1",
|
|
137
|
+
backend: "openai",
|
|
138
|
+
baseUrl: OPENAI_PROXY_URL,
|
|
139
|
+
reasoning: true,
|
|
140
|
+
input: ["text", "image"],
|
|
141
|
+
cost: { input: 2.5, output: 10, cacheRead: 0, cacheWrite: 0 },
|
|
142
|
+
contextWindow: 128000,
|
|
143
|
+
maxTokens: 16384,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "gpt-5-mini-2025-08-07",
|
|
147
|
+
name: "GPT-5 Mini",
|
|
148
|
+
backend: "openai",
|
|
149
|
+
baseUrl: OPENAI_PROXY_URL,
|
|
150
|
+
reasoning: true,
|
|
151
|
+
input: ["text", "image"],
|
|
152
|
+
cost: { input: 0.15, output: 0.6, cacheRead: 0, cacheWrite: 0 },
|
|
153
|
+
contextWindow: 128000,
|
|
154
|
+
maxTokens: 16384,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: "gpt-5-codex",
|
|
158
|
+
name: "GPT-5 Codex",
|
|
159
|
+
backend: "openai",
|
|
160
|
+
baseUrl: OPENAI_PROXY_URL,
|
|
161
|
+
reasoning: true,
|
|
162
|
+
input: ["text", "image"],
|
|
163
|
+
cost: { input: 2.5, output: 10, cacheRead: 0, cacheWrite: 0 },
|
|
164
|
+
contextWindow: 128000,
|
|
165
|
+
maxTokens: 16384,
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
const MODEL_MAP = new Map(MODELS.map((m) => [m.id, m]));
|
|
170
|
+
|
|
171
|
+
// =============================================================================
|
|
172
|
+
// Direct Access Token Cache
|
|
173
|
+
// =============================================================================
|
|
174
|
+
|
|
175
|
+
interface DirectAccessToken {
|
|
176
|
+
token: string;
|
|
177
|
+
headers: Record<string, string>;
|
|
178
|
+
expiresAt: number;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let cachedDirectAccess: DirectAccessToken | null = null;
|
|
182
|
+
|
|
183
|
+
async function getDirectAccessToken(gitlabAccessToken: string): Promise<DirectAccessToken> {
|
|
184
|
+
const now = Date.now();
|
|
185
|
+
if (cachedDirectAccess && cachedDirectAccess.expiresAt > now) {
|
|
186
|
+
return cachedDirectAccess;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const response = await fetch(`${GITLAB_COM_URL}/api/v4/ai/third_party_agents/direct_access`, {
|
|
190
|
+
method: "POST",
|
|
191
|
+
headers: { Authorization: `Bearer ${gitlabAccessToken}`, "Content-Type": "application/json" },
|
|
192
|
+
body: JSON.stringify({ feature_flags: { DuoAgentPlatformNext: true } }),
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
if (!response.ok) {
|
|
196
|
+
const errorText = await response.text();
|
|
197
|
+
if (response.status === 403) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
`GitLab Duo access denied. Ensure GitLab Duo is enabled for your account. Error: ${errorText}`,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
throw new Error(`Failed to get direct access token: ${response.status} ${errorText}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const data = (await response.json()) as { token: string; headers: Record<string, string> };
|
|
206
|
+
cachedDirectAccess = { token: data.token, headers: data.headers, expiresAt: now + DIRECT_ACCESS_TTL };
|
|
207
|
+
return cachedDirectAccess;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function invalidateDirectAccessToken() {
|
|
211
|
+
cachedDirectAccess = null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// =============================================================================
|
|
215
|
+
// OAuth
|
|
216
|
+
// =============================================================================
|
|
217
|
+
|
|
218
|
+
async function generatePKCE(): Promise<{ verifier: string; challenge: string }> {
|
|
219
|
+
const array = new Uint8Array(32);
|
|
220
|
+
crypto.getRandomValues(array);
|
|
221
|
+
const verifier = btoa(String.fromCharCode(...array))
|
|
222
|
+
.replace(/\+/g, "-")
|
|
223
|
+
.replace(/\//g, "_")
|
|
224
|
+
.replace(/=+$/, "");
|
|
225
|
+
const hash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier));
|
|
226
|
+
const challenge = btoa(String.fromCharCode(...new Uint8Array(hash)))
|
|
227
|
+
.replace(/\+/g, "-")
|
|
228
|
+
.replace(/\//g, "_")
|
|
229
|
+
.replace(/=+$/, "");
|
|
230
|
+
return { verifier, challenge };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async function loginGitLab(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
|
|
234
|
+
const { verifier, challenge } = await generatePKCE();
|
|
235
|
+
const authParams = new URLSearchParams({
|
|
236
|
+
client_id: BUNDLED_CLIENT_ID,
|
|
237
|
+
redirect_uri: REDIRECT_URI,
|
|
238
|
+
response_type: "code",
|
|
239
|
+
scope: OAUTH_SCOPES.join(" "),
|
|
240
|
+
code_challenge: challenge,
|
|
241
|
+
code_challenge_method: "S256",
|
|
242
|
+
state: crypto.randomUUID(),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
callbacks.onAuth({ url: `${GITLAB_COM_URL}/oauth/authorize?${authParams.toString()}` });
|
|
246
|
+
const callbackUrl = await callbacks.onPrompt({ message: "Paste the callback URL:" });
|
|
247
|
+
const code = new URL(callbackUrl).searchParams.get("code");
|
|
248
|
+
if (!code) throw new Error("No authorization code found in callback URL");
|
|
249
|
+
|
|
250
|
+
const tokenResponse = await fetch(`${GITLAB_COM_URL}/oauth/token`, {
|
|
251
|
+
method: "POST",
|
|
252
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
253
|
+
body: new URLSearchParams({
|
|
254
|
+
client_id: BUNDLED_CLIENT_ID,
|
|
255
|
+
grant_type: "authorization_code",
|
|
256
|
+
code,
|
|
257
|
+
code_verifier: verifier,
|
|
258
|
+
redirect_uri: REDIRECT_URI,
|
|
259
|
+
}).toString(),
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
if (!tokenResponse.ok) throw new Error(`Token exchange failed: ${await tokenResponse.text()}`);
|
|
263
|
+
const data = (await tokenResponse.json()) as {
|
|
264
|
+
access_token: string;
|
|
265
|
+
refresh_token: string;
|
|
266
|
+
expires_in: number;
|
|
267
|
+
created_at: number;
|
|
268
|
+
};
|
|
269
|
+
invalidateDirectAccessToken();
|
|
270
|
+
return {
|
|
271
|
+
refresh: data.refresh_token,
|
|
272
|
+
access: data.access_token,
|
|
273
|
+
expires: (data.created_at + data.expires_in) * 1000 - 5 * 60 * 1000,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function refreshGitLabToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials> {
|
|
278
|
+
const response = await fetch(`${GITLAB_COM_URL}/oauth/token`, {
|
|
279
|
+
method: "POST",
|
|
280
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
281
|
+
body: new URLSearchParams({
|
|
282
|
+
client_id: BUNDLED_CLIENT_ID,
|
|
283
|
+
grant_type: "refresh_token",
|
|
284
|
+
refresh_token: credentials.refresh,
|
|
285
|
+
}).toString(),
|
|
286
|
+
signal,
|
|
287
|
+
});
|
|
288
|
+
if (!response.ok) throw new Error(`Token refresh failed: ${await response.text()}`);
|
|
289
|
+
const data = (await response.json()) as {
|
|
290
|
+
access_token: string;
|
|
291
|
+
refresh_token: string;
|
|
292
|
+
expires_in: number;
|
|
293
|
+
created_at: number;
|
|
294
|
+
};
|
|
295
|
+
invalidateDirectAccessToken();
|
|
296
|
+
return {
|
|
297
|
+
refresh: data.refresh_token,
|
|
298
|
+
access: data.access_token,
|
|
299
|
+
expires: (data.created_at + data.expires_in) * 1000 - 5 * 60 * 1000,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// =============================================================================
|
|
304
|
+
// Stream Function
|
|
305
|
+
// =============================================================================
|
|
306
|
+
|
|
307
|
+
export function streamGitLabDuo(
|
|
308
|
+
model: Model<Api>,
|
|
309
|
+
context: TranscriptContext,
|
|
310
|
+
options?: SimpleStreamOptions,
|
|
311
|
+
): AssistantMessageEventStream {
|
|
312
|
+
const stream = createAssistantMessageEventStream();
|
|
313
|
+
|
|
314
|
+
(async () => {
|
|
315
|
+
try {
|
|
316
|
+
const gitlabAccessToken = options?.apiKey;
|
|
317
|
+
if (!gitlabAccessToken) throw new Error("No GitLab access token. Run /login gitlab-duo or set GITLAB_TOKEN");
|
|
318
|
+
|
|
319
|
+
const cfg = MODEL_MAP.get(model.id);
|
|
320
|
+
if (!cfg) throw new Error(`Unknown model: ${model.id}`);
|
|
321
|
+
|
|
322
|
+
const directAccess = await getDirectAccessToken(gitlabAccessToken);
|
|
323
|
+
const modelWithBaseUrl = { ...model, baseUrl: cfg.baseUrl };
|
|
324
|
+
const headers = { ...directAccess.headers, Authorization: `Bearer ${directAccess.token}` };
|
|
325
|
+
const streamOptions = { ...options, apiKey: "gitlab-duo", headers };
|
|
326
|
+
|
|
327
|
+
const innerStream =
|
|
328
|
+
cfg.backend === "anthropic"
|
|
329
|
+
? anthropicMessagesApi().streamSimple(
|
|
330
|
+
{
|
|
331
|
+
...(modelWithBaseUrl as Model<"anthropic-messages">),
|
|
332
|
+
compat: {
|
|
333
|
+
...(modelWithBaseUrl as Model<"anthropic-messages">).compat,
|
|
334
|
+
forceAdaptiveThinking: true,
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
context,
|
|
338
|
+
streamOptions,
|
|
339
|
+
)
|
|
340
|
+
: openAIResponsesApi().streamSimple(
|
|
341
|
+
modelWithBaseUrl as Model<"openai-responses">,
|
|
342
|
+
context,
|
|
343
|
+
streamOptions,
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
for await (const event of innerStream) stream.push(event);
|
|
347
|
+
stream.end();
|
|
348
|
+
} catch (error) {
|
|
349
|
+
stream.push({
|
|
350
|
+
type: "error",
|
|
351
|
+
reason: "error",
|
|
352
|
+
error: {
|
|
353
|
+
role: "assistant",
|
|
354
|
+
content: [],
|
|
355
|
+
api: model.api,
|
|
356
|
+
provider: model.provider,
|
|
357
|
+
model: model.id,
|
|
358
|
+
usage: {
|
|
359
|
+
input: 0,
|
|
360
|
+
output: 0,
|
|
361
|
+
cacheRead: 0,
|
|
362
|
+
cacheWrite: 0,
|
|
363
|
+
totalTokens: 0,
|
|
364
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
365
|
+
},
|
|
366
|
+
stopReason: "error",
|
|
367
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
368
|
+
timestamp: Date.now(),
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
stream.end();
|
|
372
|
+
}
|
|
373
|
+
})();
|
|
374
|
+
|
|
375
|
+
return stream;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// =============================================================================
|
|
379
|
+
// Extension Entry Point
|
|
380
|
+
// =============================================================================
|
|
381
|
+
|
|
382
|
+
export default function (pi: ExtensionAPI) {
|
|
383
|
+
pi.registerProvider("gitlab-duo", {
|
|
384
|
+
baseUrl: AI_GATEWAY_URL,
|
|
385
|
+
apiKey: "$GITLAB_TOKEN",
|
|
386
|
+
api: "gitlab-duo-api",
|
|
387
|
+
models: MODELS.map(({ id, name, reasoning, thinkingLevelMap, input, cost, contextWindow, maxTokens }) => ({
|
|
388
|
+
id,
|
|
389
|
+
name,
|
|
390
|
+
reasoning,
|
|
391
|
+
thinkingLevelMap,
|
|
392
|
+
input,
|
|
393
|
+
cost,
|
|
394
|
+
contextWindow,
|
|
395
|
+
maxTokens,
|
|
396
|
+
})),
|
|
397
|
+
oauth: {
|
|
398
|
+
name: "GitLab Duo",
|
|
399
|
+
login: loginGitLab,
|
|
400
|
+
refreshToken: refreshGitLabToken,
|
|
401
|
+
getApiKey: (cred) => cred.access,
|
|
402
|
+
},
|
|
403
|
+
streamSimple: streamGitLabDuo,
|
|
404
|
+
});
|
|
405
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-extension-custom-provider-gitlab-duo",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.4.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"clean": "echo 'nothing to clean'",
|
|
8
|
+
"build": "echo 'nothing to build'",
|
|
9
|
+
"check": "echo 'nothing to check'"
|
|
10
|
+
},
|
|
11
|
+
"pi": {
|
|
12
|
+
"extensions": [
|
|
13
|
+
"./index.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test script for GitLab Duo extension
|
|
3
|
+
* Run: node test.ts [model-id] [--thinking]
|
|
4
|
+
*
|
|
5
|
+
* Examples:
|
|
6
|
+
* node test.ts # Test default (claude-sonnet-4-5-20250929)
|
|
7
|
+
* node test.ts gpt-5-codex # Test GPT-5 Codex
|
|
8
|
+
* node test.ts claude-sonnet-4-5-20250929 --thinking
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { type Api, type Context, type Model, registerApiProvider, streamSimple } from "@earendil-works/pi-ai/compat";
|
|
12
|
+
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
import { readFileSync } from "fs";
|
|
14
|
+
import { join } from "path";
|
|
15
|
+
import { MODELS, streamGitLabDuo } from "./index.ts";
|
|
16
|
+
|
|
17
|
+
const MODEL_MAP = new Map(MODELS.map((m) => [m.id, m]));
|
|
18
|
+
|
|
19
|
+
async function main() {
|
|
20
|
+
const modelId = process.argv[2] || "claude-sonnet-4-5-20250929";
|
|
21
|
+
const useThinking = process.argv.includes("--thinking");
|
|
22
|
+
|
|
23
|
+
const cfg = MODEL_MAP.get(modelId);
|
|
24
|
+
if (!cfg) {
|
|
25
|
+
console.error(`Unknown model: ${modelId}`);
|
|
26
|
+
console.error("Available:", MODELS.map((m) => m.id).join(", "));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Read auth
|
|
31
|
+
const authPath = join(getAgentDir(), "extensions", "auth.json");
|
|
32
|
+
const authData = JSON.parse(readFileSync(authPath, "utf-8"));
|
|
33
|
+
const gitlabCred = authData["gitlab-duo"];
|
|
34
|
+
if (!gitlabCred?.access) {
|
|
35
|
+
console.error("No gitlab-duo credentials. Run /login gitlab-duo first.");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Register provider
|
|
40
|
+
registerApiProvider({
|
|
41
|
+
api: "gitlab-duo-api" as Api,
|
|
42
|
+
stream: streamGitLabDuo,
|
|
43
|
+
streamSimple: streamGitLabDuo,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Create model
|
|
47
|
+
const model: Model<Api> = {
|
|
48
|
+
id: cfg.id,
|
|
49
|
+
name: cfg.name,
|
|
50
|
+
api: "gitlab-duo-api" as Api,
|
|
51
|
+
provider: "gitlab-duo",
|
|
52
|
+
baseUrl: cfg.baseUrl,
|
|
53
|
+
reasoning: cfg.reasoning,
|
|
54
|
+
input: cfg.input,
|
|
55
|
+
cost: cfg.cost,
|
|
56
|
+
contextWindow: cfg.contextWindow,
|
|
57
|
+
maxTokens: cfg.maxTokens,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const context: Context = {
|
|
61
|
+
messages: [{ role: "user", content: "Say hello in exactly 3 words.", timestamp: Date.now() }],
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
console.log(`Model: ${model.id}, Backend: ${cfg.backend}, Thinking: ${useThinking}`);
|
|
65
|
+
|
|
66
|
+
const stream = streamSimple(model, context, {
|
|
67
|
+
apiKey: gitlabCred.access,
|
|
68
|
+
maxTokens: 100,
|
|
69
|
+
reasoning: useThinking ? "low" : undefined,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
for await (const event of stream) {
|
|
73
|
+
if (event.type === "thinking_start") console.log("[Thinking]");
|
|
74
|
+
else if (event.type === "thinking_delta") process.stdout.write(event.delta);
|
|
75
|
+
else if (event.type === "thinking_end") console.log("\n[/Thinking]\n");
|
|
76
|
+
else if (event.type === "text_delta") process.stdout.write(event.delta);
|
|
77
|
+
else if (event.type === "error") console.error("\nError:", event.error.errorMessage);
|
|
78
|
+
else if (event.type === "done") console.log("\n\nDone!", event.reason, event.message.usage);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw provider event viewer.
|
|
3
|
+
*
|
|
4
|
+
* Usage: /debug-provider [on|off]
|
|
5
|
+
* With no argument, the command toggles capture. Captured events are persisted
|
|
6
|
+
* as expandable custom entries.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { type ExtensionAPI, keyHint } from "@earendil-works/pi-coding-agent";
|
|
10
|
+
import { Box, Text } from "@earendil-works/pi-tui";
|
|
11
|
+
|
|
12
|
+
const ENTRY_TYPE = "debug-provider-events";
|
|
13
|
+
const STATUS_KEY = "debug-provider";
|
|
14
|
+
|
|
15
|
+
interface ProviderDebugEntry {
|
|
16
|
+
provider: string;
|
|
17
|
+
api: string;
|
|
18
|
+
model: string;
|
|
19
|
+
events: unknown[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function (pi: ExtensionAPI) {
|
|
23
|
+
let enabled = false;
|
|
24
|
+
let activeEvents: unknown[] | undefined;
|
|
25
|
+
let completedEntry: ProviderDebugEntry | undefined;
|
|
26
|
+
|
|
27
|
+
pi.registerEntryRenderer<ProviderDebugEntry>(ENTRY_TYPE, (entry, { expanded }, theme) => {
|
|
28
|
+
const data = entry.data;
|
|
29
|
+
if (!data) return new Text(theme.fg("warning", "[provider debug] Missing event data"), 0, 0);
|
|
30
|
+
|
|
31
|
+
const box = new Box(1, 1, (text) => theme.bg("customMessageBg", text));
|
|
32
|
+
const count = `${data.events.length} event${data.events.length === 1 ? "" : "s"}`;
|
|
33
|
+
const expandHint = expanded ? "" : ` (${keyHint("app.tools.expand", "to view events")})`;
|
|
34
|
+
box.addChild(
|
|
35
|
+
new Text(
|
|
36
|
+
`${theme.fg("accent", "[provider debug]")} ${data.provider}/${data.model} (${data.api}) · ${count}${expandHint}`,
|
|
37
|
+
0,
|
|
38
|
+
0,
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
if (expanded) {
|
|
42
|
+
box.addChild(new Text(JSON.stringify(data.events, null, 2), 0, 0));
|
|
43
|
+
}
|
|
44
|
+
return box;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
pi.registerCommand("debug-provider", {
|
|
48
|
+
description: "Toggle capture of raw provider stream events",
|
|
49
|
+
handler: async (args, ctx) => {
|
|
50
|
+
const requestedState = args.trim().toLowerCase();
|
|
51
|
+
if (requestedState !== "" && requestedState !== "on" && requestedState !== "off") {
|
|
52
|
+
ctx.ui.notify("Usage: /debug-provider [on|off]", "warning");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
enabled = requestedState === "" ? !enabled : requestedState === "on";
|
|
57
|
+
if (!enabled) {
|
|
58
|
+
activeEvents = undefined;
|
|
59
|
+
completedEntry = undefined;
|
|
60
|
+
}
|
|
61
|
+
ctx.ui.setStatus(STATUS_KEY, enabled ? "provider debug" : undefined);
|
|
62
|
+
ctx.ui.notify(`Provider event capture ${enabled ? "enabled" : "disabled"}`, "info");
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
pi.on("turn_start", () => {
|
|
67
|
+
activeEvents = enabled ? [] : undefined;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
pi.on("provider_stream_event", (event) => {
|
|
71
|
+
activeEvents?.push(structuredClone(event.data));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
pi.on("message_end", (event) => {
|
|
75
|
+
if (event.message.role !== "assistant" || !activeEvents) return;
|
|
76
|
+
completedEntry = {
|
|
77
|
+
provider: event.message.provider,
|
|
78
|
+
api: event.message.api,
|
|
79
|
+
model: event.message.model,
|
|
80
|
+
events: activeEvents,
|
|
81
|
+
};
|
|
82
|
+
activeEvents = undefined;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
pi.on("turn_end", () => {
|
|
86
|
+
if (!completedEntry) return;
|
|
87
|
+
pi.appendEntry<ProviderDebugEntry>(ENTRY_TYPE, completedEntry);
|
|
88
|
+
completedEntry = undefined;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dirty Repo Guard Extension
|
|
3
|
+
*
|
|
4
|
+
* Prevents session changes when there are uncommitted git changes.
|
|
5
|
+
* Useful to ensure work is committed before switching context.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
async function checkDirtyRepo(
|
|
11
|
+
pi: ExtensionAPI,
|
|
12
|
+
ctx: ExtensionContext,
|
|
13
|
+
action: string,
|
|
14
|
+
): Promise<{ cancel: boolean } | undefined> {
|
|
15
|
+
// Check for uncommitted changes
|
|
16
|
+
const { stdout, code } = await pi.exec("git", ["status", "--porcelain"]);
|
|
17
|
+
|
|
18
|
+
if (code !== 0) {
|
|
19
|
+
// Not a git repo, allow the action
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const hasChanges = stdout.trim().length > 0;
|
|
24
|
+
if (!hasChanges) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!ctx.hasUI) {
|
|
29
|
+
// In non-interactive mode, block by default
|
|
30
|
+
return { cancel: true };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Count changed files
|
|
34
|
+
const changedFiles = stdout.trim().split("\n").filter(Boolean).length;
|
|
35
|
+
|
|
36
|
+
const choice = await ctx.ui.select(`You have ${changedFiles} uncommitted file(s). ${action} anyway?`, [
|
|
37
|
+
"Yes, proceed anyway",
|
|
38
|
+
"No, let me commit first",
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
if (choice !== "Yes, proceed anyway") {
|
|
42
|
+
ctx.ui.notify("Commit your changes first", "warning");
|
|
43
|
+
return { cancel: true };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default function (pi: ExtensionAPI) {
|
|
48
|
+
pi.on("session_before_switch", async (event, ctx) => {
|
|
49
|
+
const action = event.reason === "new" ? "new session" : "switch session";
|
|
50
|
+
return checkDirtyRepo(pi, ctx, action);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
pi.on("session_before_fork", async (_event, ctx) => {
|
|
54
|
+
return checkDirtyRepo(pi, ctx, "fork");
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# DOOM Overlay Demo
|
|
2
|
+
|
|
3
|
+
Play DOOM as an overlay in pi. Demonstrates that the overlay system can handle real-time game rendering at 35 FPS.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pi --extension ./examples/extensions/doom-overlay
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Then run:
|
|
12
|
+
```
|
|
13
|
+
/doom-overlay
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The shareware WAD file (~4MB) is auto-downloaded on first run.
|
|
17
|
+
|
|
18
|
+
## Controls
|
|
19
|
+
|
|
20
|
+
| Action | Keys |
|
|
21
|
+
|--------|------|
|
|
22
|
+
| Move | WASD or Arrow Keys |
|
|
23
|
+
| Run | Shift + WASD |
|
|
24
|
+
| Fire | F or Ctrl |
|
|
25
|
+
| Use/Open | Space |
|
|
26
|
+
| Weapons | 1-7 |
|
|
27
|
+
| Map | Tab |
|
|
28
|
+
| Menu | Escape |
|
|
29
|
+
| Pause/Quit | Q |
|
|
30
|
+
|
|
31
|
+
## How It Works
|
|
32
|
+
|
|
33
|
+
DOOM runs as WebAssembly compiled from [doomgeneric](https://github.com/ozkl/doomgeneric). Each frame is rendered using half-block characters (▀) with 24-bit color, where the top pixel is the foreground color and the bottom pixel is the background color.
|
|
34
|
+
|
|
35
|
+
The overlay uses:
|
|
36
|
+
- `width: "90%"` - 90% of terminal width
|
|
37
|
+
- `maxHeight: "80%"` - Maximum 80% of terminal height
|
|
38
|
+
- `anchor: "center"` - Centered in terminal
|
|
39
|
+
|
|
40
|
+
Height is calculated from width to maintain DOOM's 3.2:1 aspect ratio (accounting for half-block rendering).
|
|
41
|
+
|
|
42
|
+
## Credits
|
|
43
|
+
|
|
44
|
+
- [id Software](https://github.com/id-Software/DOOM) for the original DOOM
|
|
45
|
+
- [doomgeneric](https://github.com/ozkl/doomgeneric) for the portable DOOM implementation
|
|
46
|
+
- [pi-doom](https://github.com/badlogic/pi-doom) for the original pi integration
|