ronin-skillforce 0.0.0-stage → 0.1.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 +26 -0
- package/LICENSE +21 -0
- package/README.md +225 -2
- package/bin/cli.js +811 -0
- package/bin/commands/check.js +298 -0
- package/bin/commands/create.js +169 -0
- package/bin/commands/doctor.js +392 -0
- package/bin/commands/import.js +557 -0
- package/bin/commands/next.js +125 -0
- package/bin/commands/review.js +207 -0
- package/bin/commands/status.js +114 -0
- package/bin/commands/studio.js +497 -0
- package/bin/commands/trail.js +211 -0
- package/bin/commands/web.js +350 -0
- package/bin/course-reader.js +611 -0
- package/bin/node-version.js +60 -0
- package/bin/platforms/_shared.js +211 -0
- package/bin/platforms/claude.js +104 -0
- package/bin/platforms/cursor.js +49 -0
- package/bin/platforms/gemini.js +65 -0
- package/bin/platforms/opencode.js +95 -0
- package/bin/registry-helpers.js +504 -0
- package/bin/static-server.js +153 -0
- package/bin/studio-store.js +94 -0
- package/bin/sync-shared.sh +5 -0
- package/package.json +91 -4
- package/plugin.json +139 -0
- package/shared/SKILL.md +568 -0
- package/shared/agents/coach.md +225 -0
- package/shared/agents/navigator.md +215 -0
- package/shared/agents/professor.md +372 -0
- package/shared/agents/researcher.md +181 -0
- package/shared/agents/spotter.md +129 -0
- package/shared/commands/professor/archive.md +103 -0
- package/shared/commands/professor/capstone-review.md +79 -0
- package/shared/commands/professor/capstone.md +34 -0
- package/shared/commands/professor/discuss.md +18 -0
- package/shared/commands/professor/done.md +44 -0
- package/shared/commands/professor/export.md +69 -0
- package/shared/commands/professor/hint.md +108 -0
- package/shared/commands/professor/navigator.md +67 -0
- package/shared/commands/professor/new-topic.md +73 -0
- package/shared/commands/professor/next.md +174 -0
- package/shared/commands/professor/note.md +63 -0
- package/shared/commands/professor/onboard.md +95 -0
- package/shared/commands/professor/progress.md +46 -0
- package/shared/commands/professor/publish.md +93 -0
- package/shared/commands/professor/quiz.md +27 -0
- package/shared/commands/professor/recall.md +74 -0
- package/shared/commands/professor/review.md +43 -0
- package/shared/commands/professor/schedule.md +75 -0
- package/shared/commands/professor/skill-export.md +87 -0
- package/shared/commands/professor/spotter.md +76 -0
- package/shared/commands/professor/stuck.md +27 -0
- package/shared/commands/professor/switch.md +50 -0
- package/shared/commands/professor/syllabus.md +9 -0
- package/shared/commands/professor/template-export.md +91 -0
- package/shared/commands/professor/template-import.md +111 -0
- package/shared/commands/professor/worktrees.md +58 -0
- package/shared/hooks/pre-compact.js +232 -0
- package/studio/README.md +313 -0
- package/studio/dist/assets/BetaReportPanel-8NrDLiPm.js +1 -0
- package/studio/dist/assets/Capstone-Cv9kH6LY.js +6 -0
- package/studio/dist/assets/CodeWorkspace-BwCEINWo.js +2 -0
- package/studio/dist/assets/Course-BJ_hafUP.js +1 -0
- package/studio/dist/assets/Editor-CV0mNhlz.js +53 -0
- package/studio/dist/assets/Home-C1ry89ak.js +1 -0
- package/studio/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/studio/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/studio/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/studio/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/studio/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/studio/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/studio/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/studio/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/studio/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/studio/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/studio/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/studio/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/studio/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/studio/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/studio/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/studio/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/studio/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/studio/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/studio/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/studio/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/studio/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/studio/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/studio/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/studio/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/studio/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/studio/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/studio/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/studio/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/studio/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/studio/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/studio/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/studio/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/studio/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/studio/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/studio/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/studio/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/studio/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/studio/dist/assets/Lesson-2e9TD9yL.js +2 -0
- package/studio/dist/assets/NewCourse-BZeOg2xn.js +952 -0
- package/studio/dist/assets/Progress-CRc_xEWC.js +1 -0
- package/studio/dist/assets/Review-6QEbHEfk.js +1 -0
- package/studio/dist/assets/Settings-NFnqVQui.js +1 -0
- package/studio/dist/assets/TutorPanel-DXQ6Z3BY.js +123 -0
- package/studio/dist/assets/abnfDiagram-WEYOIA3C-qeSjKlGM.js +1 -0
- package/studio/dist/assets/anthropic-D7NiQCUH.js +15 -0
- package/studio/dist/assets/arc-Y1ARJVZ4.js +1 -0
- package/studio/dist/assets/architecture-WOLXFQ4H-COG-m35l.js +1 -0
- package/studio/dist/assets/architectureDiagram-ZHVYKT53-VO7uKoeD.js +36 -0
- package/studio/dist/assets/array-BifhSqXX.js +1 -0
- package/studio/dist/assets/blockDiagram-RJAE7QA3-BGJF_qiL.js +140 -0
- package/studio/dist/assets/bridge-BTh0AeNX.js +1 -0
- package/studio/dist/assets/c4Diagram-XDPPPE54-C-S10RgU.js +38 -0
- package/studio/dist/assets/capstone-Amn6Hztq.js +135 -0
- package/studio/dist/assets/card-store-BrbrtX9w.js +1 -0
- package/studio/dist/assets/channel-SJiUQu_N.js +1 -0
- package/studio/dist/assets/chunk-2E7WHVMD-fv-iqTyC.js +88 -0
- package/studio/dist/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/studio/dist/assets/chunk-4EMNKR2T-CY9IZrgv.js +1 -0
- package/studio/dist/assets/chunk-55XCU76K-DyTZz7v_.js +1 -0
- package/studio/dist/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
- package/studio/dist/assets/chunk-7S6XSTFO-BNMzTLRW.js +2 -0
- package/studio/dist/assets/chunk-AQDTSKZB-CEYANohH.js +72 -0
- package/studio/dist/assets/chunk-DSNLSHJZ-CDk5EXjH.js +129 -0
- package/studio/dist/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
- package/studio/dist/assets/chunk-HAGFOTED-hNAi1zh_.js +62 -0
- package/studio/dist/assets/chunk-HNE4Q36P-COJnSYoZ.js +1 -0
- package/studio/dist/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
- package/studio/dist/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/studio/dist/assets/chunk-NGNAAXSQ-C2Wy9Xmz.js +136 -0
- package/studio/dist/assets/chunk-NQOKRVIF-BU6KVxRr.js +213 -0
- package/studio/dist/assets/chunk-UHW7PFBP-DYvxL9JG.js +1 -0
- package/studio/dist/assets/chunk-VQ5W62QI-CuRfk65j.js +1 -0
- package/studio/dist/assets/chunk-WQQL4CDK-KaG7x-Mb.js +10 -0
- package/studio/dist/assets/chunk-XXDRQBXY-CnbRkih_.js +1 -0
- package/studio/dist/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/studio/dist/assets/chunk-YZO67HFG-DbuqIZmk.js +1 -0
- package/studio/dist/assets/chunk-ZAUX2LTX-bk4ivUmc.js +1 -0
- package/studio/dist/assets/chunk-ZCHMQSOR-B_LElfwh.js +2 -0
- package/studio/dist/assets/classDiagram-v2-4MYWR3UA-DtCJ6H_X.js +217 -0
- package/studio/dist/assets/cose-bilkent-JH36ORCC-DMBAZFnj.js +1 -0
- package/studio/dist/assets/course-export-DpaOTT3a.js +1 -0
- package/studio/dist/assets/cynefin-EF2NZ3EQ-D9btHJvU.js +1 -0
- package/studio/dist/assets/cynefinDiagram-WF24UDRP-CsFJuv27.js +62 -0
- package/studio/dist/assets/cytoscape.esm-CHBj4VkZ.js +321 -0
- package/studio/dist/assets/dagre-NK4GIZVX-Cg1Duec7.js +4 -0
- package/studio/dist/assets/defaultLocale-BFoDCU3G.js +1 -0
- package/studio/dist/assets/diagram-CBK3MWTC-_KU2m5gd.js +24 -0
- package/studio/dist/assets/diagram-I5XIIV2D-5RaBrwUA.js +24 -0
- package/studio/dist/assets/diagram-ODIL2UCW-C0VKxoD3.js +30 -0
- package/studio/dist/assets/diagram-PFBEJUXE-BaHcZEP2.js +3 -0
- package/studio/dist/assets/diagram-RJA3I4VV-cwSAZ90p.js +41 -0
- package/studio/dist/assets/diagram-TYUNFSNR-BJImxCEN.js +200 -0
- package/studio/dist/assets/dist-CumnGVmJ.js +1 -0
- package/studio/dist/assets/ebnfDiagram-V4P3TTPT-OQQLRXcm.js +1 -0
- package/studio/dist/assets/elk-QONTBCTQ-BJGhQHxQ.js +27 -0
- package/studio/dist/assets/erDiagram-KYQIGQAA-D91EKSep.js +99 -0
- package/studio/dist/assets/error-BTdmRKoB.js +1 -0
- package/studio/dist/assets/errors-BZa_CNHL.js +1 -0
- package/studio/dist/assets/eventmodeling-K75KTNOO-DgdTRgnw.js +1 -0
- package/studio/dist/assets/fetch-local-DG3O3hmQ.js +4 -0
- package/studio/dist/assets/flowDiagram-IUGLLWBU-CVnJYMum.js +1 -0
- package/studio/dist/assets/ganttDiagram-R7GPNTJY-CSYLPWEI.js +292 -0
- package/studio/dist/assets/gitGraph-VSP46ZUC-D6GWaV9y.js +1 -0
- package/studio/dist/assets/gitGraphDiagram-PDYL7XHY-CaV31bvT.js +106 -0
- package/studio/dist/assets/graphlib-DS17s2tU.js +1 -0
- package/studio/dist/assets/index-CVenTTOY.css +2 -0
- package/studio/dist/assets/index-DioXTZVc.js +313 -0
- package/studio/dist/assets/info-OHQRW6UA-BN-x8GoN.js +1 -0
- package/studio/dist/assets/infoDiagram-MVDRKAX5-CIose_cy.js +2 -0
- package/studio/dist/assets/init-C-OQMol4.js +1 -0
- package/studio/dist/assets/ishikawaDiagram-HPEHV2GE-DCihSNBw.js +70 -0
- package/studio/dist/assets/journeyDiagram-BOSHW7O7-Bz3o3RIX.js +139 -0
- package/studio/dist/assets/js.worker-AD7DjksO.js +4 -0
- package/studio/dist/assets/kanban-definition-FNSA4HC5-BUyqvlFE.js +89 -0
- package/studio/dist/assets/katex-B_JcIwqj.js +257 -0
- package/studio/dist/assets/katex-BgsA2lO1.css +1 -0
- package/studio/dist/assets/line-B08T8KlK.js +1 -0
- package/studio/dist/assets/linear-C9iwaMOi.js +1 -0
- package/studio/dist/assets/mermaid-parser.core-BYwreSUy.js +7 -0
- package/studio/dist/assets/mermaid.core-DTO1oDmq.js +44 -0
- package/studio/dist/assets/mindmap-definition-6OY57UG3-BGLwKheY.js +98 -0
- package/studio/dist/assets/node.browser-BISniYn8.js +1 -0
- package/studio/dist/assets/node.browser-HQ5SKBOf.js +1 -0
- package/studio/dist/assets/ollama-De5w84tG.js +1 -0
- package/studio/dist/assets/openai-compatible-Joy1oK3L.js +1 -0
- package/studio/dist/assets/ordinal-BDEzSJ7C.js +1 -0
- package/studio/dist/assets/packet-JDAUHWVQ-CDIMjHS_.js +1 -0
- package/studio/dist/assets/path-fybaL0A-.js +1 -0
- package/studio/dist/assets/pegDiagram-ECIUJNBX-DWXm4mwS.js +1 -0
- package/studio/dist/assets/pie-XZMESJXO-CY3QQiKZ.js +1 -0
- package/studio/dist/assets/pieDiagram-GNMPY74T-M1aCnI7W.js +39 -0
- package/studio/dist/assets/python.worker-CzTrFdd9.js +24 -0
- package/studio/dist/assets/quadrantDiagram-D57K4MC3-BFFtO7U5.js +7 -0
- package/studio/dist/assets/radar-ABXABTNO-DT0W4_Xn.js +1 -0
- package/studio/dist/assets/railroad-I3PHUGI6-_VCpgZR5.js +1 -0
- package/studio/dist/assets/railroad-abnf-LNEFI6M7-DkSpQ5YY.js +1 -0
- package/studio/dist/assets/railroad-ebnf-DWYD2UWJ-BqWILdGb.js +1 -0
- package/studio/dist/assets/railroad-peg-JR7BVNR7-BB0bQL-Z.js +1 -0
- package/studio/dist/assets/railroadDiagram-Y72NRBL7-CjLKjIdJ.js +1 -0
- package/studio/dist/assets/react-B8SKf8RM.js +1 -0
- package/studio/dist/assets/rehype-katex-C-sKddsH.js +259 -0
- package/studio/dist/assets/remark-math-C-ox67hE.js +5 -0
- package/studio/dist/assets/requirementDiagram-EQYSW5RA-CnwzZqR8.js +84 -0
- package/studio/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
- package/studio/dist/assets/rough.esm-Dy-Kn_BL.js +1 -0
- package/studio/dist/assets/sankeyDiagram-SY24JHO5-CPDugTUl.js +40 -0
- package/studio/dist/assets/schemas-BOc2YsOP.js +55 -0
- package/studio/dist/assets/sequenceDiagram-BLEHNHQU-1dLfeU9Y.js +169 -0
- package/studio/dist/assets/settings-DhwuyNPU.js +1 -0
- package/studio/dist/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
- package/studio/dist/assets/spec-nAnsSMkw.js +1 -0
- package/studio/dist/assets/sql-wasm-C1D_RJuy.wasm +0 -0
- package/studio/dist/assets/sql.worker-D7pBHOrq.js +4 -0
- package/studio/dist/assets/src-BWF7jMDv.js +1 -0
- package/studio/dist/assets/stateDiagram-v2-A6IESKWZ-DR7CmEjj.js +291 -0
- package/studio/dist/assets/swimlanes-B3ENRKFQ-BAWB9omQ.js +1 -0
- package/studio/dist/assets/swimlanesDiagram-AYQRV4AK-qeuHru16.js +8 -0
- package/studio/dist/assets/timeline-definition-JXYKGLGB-DNkj8z77.js +120 -0
- package/studio/dist/assets/treeView-D4JQ5SDB-BA-ouhMb.js +1 -0
- package/studio/dist/assets/treemap-SAJKECNS-BrrGxsAb.js +1 -0
- package/studio/dist/assets/useStream-rdsR6A7P.js +1 -0
- package/studio/dist/assets/usecaseDiagram-WPOLBNNX-BB3D0Dt_.js +328 -0
- package/studio/dist/assets/vennDiagram-Q3Y3IDCW-BrtqtKTE.js +34 -0
- package/studio/dist/assets/wardley-7MLQ67FV-BKkemDql.js +1 -0
- package/studio/dist/assets/wardleyDiagram-IVAIDKWA-DFnI3P5z.js +78 -0
- package/studio/dist/assets/xychartDiagram-4URNHDU4-Da0DZG_q.js +7 -0
- package/studio/dist/index.html +20 -0
- package/studio/dist/preview.html +22 -0
- package/studio/migrations/0001_init.sql +188 -0
- package/studio/migrations/0002_external_ids.sql +20 -0
- package/studio/migrations/0003_course_language.sql +12 -0
- package/studio/migrations/0004_capstone.sql +51 -0
- package/studio/migrations/0005_beta_loop.sql +73 -0
- package/studio/migrations/0006_interactive_exercises.sql +49 -0
- package/studio/src/lib/activity.js +92 -0
- package/studio/src/lib/ai/anthropic.js +109 -0
- package/studio/src/lib/ai/bridge.js +126 -0
- package/studio/src/lib/ai/catalog.js +160 -0
- package/studio/src/lib/ai/config.js +70 -0
- package/studio/src/lib/ai/errors.js +95 -0
- package/studio/src/lib/ai/fetch-local.js +104 -0
- package/studio/src/lib/ai/index.js +194 -0
- package/studio/src/lib/ai/ollama.js +136 -0
- package/studio/src/lib/ai/openai-compatible.js +101 -0
- package/studio/src/lib/ai/provider-utils.js +107 -0
- package/studio/src/lib/ai/sse.js +99 -0
- package/studio/src/lib/ai/status.js +92 -0
- package/studio/src/lib/ai/useStream.js +109 -0
- package/studio/src/lib/beta/metrics.js +147 -0
- package/studio/src/lib/beta/report.js +134 -0
- package/studio/src/lib/capstone-evidence.js +758 -0
- package/studio/src/lib/capstone.js +663 -0
- package/studio/src/lib/chat-store.js +128 -0
- package/studio/src/lib/course-export.js +38 -0
- package/studio/src/lib/course.js +187 -0
- package/studio/src/lib/exercises/journal-entry.js +259 -0
- package/studio/src/lib/exercises/placement.js +31 -0
- package/studio/src/lib/exercises/registry.js +19 -0
- package/studio/src/lib/exercises/spec.js +129 -0
- package/studio/src/lib/i18n/detect.js +162 -0
- package/studio/src/lib/i18n/en/app.json +23 -0
- package/studio/src/lib/i18n/en/betaReport.json +55 -0
- package/studio/src/lib/i18n/en/capstone.json +57 -0
- package/studio/src/lib/i18n/en/common.json +25 -0
- package/studio/src/lib/i18n/en/course.json +27 -0
- package/studio/src/lib/i18n/en/data.json +35 -0
- package/studio/src/lib/i18n/en/durability.json +5 -0
- package/studio/src/lib/i18n/en/errors.json +20 -0
- package/studio/src/lib/i18n/en/exercises.json +55 -0
- package/studio/src/lib/i18n/en/externalEvidence.json +76 -0
- package/studio/src/lib/i18n/en/home.json +18 -0
- package/studio/src/lib/i18n/en/lesson.json +33 -0
- package/studio/src/lib/i18n/en/nav.json +8 -0
- package/studio/src/lib/i18n/en/newCourse.json +51 -0
- package/studio/src/lib/i18n/en/onboarding.json +35 -0
- package/studio/src/lib/i18n/en/playwrightTemplate.json +20 -0
- package/studio/src/lib/i18n/en/practice.json +79 -0
- package/studio/src/lib/i18n/en/provider.json +27 -0
- package/studio/src/lib/i18n/en/providerMeta.json +26 -0
- package/studio/src/lib/i18n/en/reflection.json +17 -0
- package/studio/src/lib/i18n/en/revision.json +52 -0
- package/studio/src/lib/i18n/en/runnerNotice.json +14 -0
- package/studio/src/lib/i18n/en/settings.json +12 -0
- package/studio/src/lib/i18n/en/storage.json +49 -0
- package/studio/src/lib/i18n/en/tutor.json +39 -0
- package/studio/src/lib/i18n/en/workspace.json +50 -0
- package/studio/src/lib/i18n/index.js +144 -0
- package/studio/src/lib/i18n/languages.js +93 -0
- package/studio/src/lib/i18n/vi/app.json +23 -0
- package/studio/src/lib/i18n/vi/betaReport.json +55 -0
- package/studio/src/lib/i18n/vi/capstone.json +57 -0
- package/studio/src/lib/i18n/vi/common.json +25 -0
- package/studio/src/lib/i18n/vi/course.json +27 -0
- package/studio/src/lib/i18n/vi/data.json +35 -0
- package/studio/src/lib/i18n/vi/durability.json +5 -0
- package/studio/src/lib/i18n/vi/errors.json +20 -0
- package/studio/src/lib/i18n/vi/exercises.json +55 -0
- package/studio/src/lib/i18n/vi/externalEvidence.json +76 -0
- package/studio/src/lib/i18n/vi/home.json +18 -0
- package/studio/src/lib/i18n/vi/lesson.json +33 -0
- package/studio/src/lib/i18n/vi/nav.json +8 -0
- package/studio/src/lib/i18n/vi/newCourse.json +51 -0
- package/studio/src/lib/i18n/vi/onboarding.json +35 -0
- package/studio/src/lib/i18n/vi/playwrightTemplate.json +20 -0
- package/studio/src/lib/i18n/vi/practice.json +79 -0
- package/studio/src/lib/i18n/vi/provider.json +27 -0
- package/studio/src/lib/i18n/vi/providerMeta.json +26 -0
- package/studio/src/lib/i18n/vi/reflection.json +17 -0
- package/studio/src/lib/i18n/vi/revision.json +52 -0
- package/studio/src/lib/i18n/vi/runnerNotice.json +14 -0
- package/studio/src/lib/i18n/vi/settings.json +12 -0
- package/studio/src/lib/i18n/vi/storage.json +49 -0
- package/studio/src/lib/i18n/vi/tutor.json +39 -0
- package/studio/src/lib/i18n/vi/workspace.json +50 -0
- package/studio/src/lib/ids.js +10 -0
- package/studio/src/lib/json.js +26 -0
- package/studio/src/lib/markdown.js +74 -0
- package/studio/src/lib/prompts/base.js +139 -0
- package/studio/src/lib/prompts/capstone.js +777 -0
- package/studio/src/lib/prompts/course.js +150 -0
- package/studio/src/lib/prompts/lesson.js +275 -0
- package/studio/src/lib/prompts/practice.js +511 -0
- package/studio/src/lib/prompts/tutor.js +509 -0
- package/studio/src/lib/repo/blocked-adapter.js +69 -0
- package/studio/src/lib/repo/events.js +239 -0
- package/studio/src/lib/repo/idb-adapter.js +226 -0
- package/studio/src/lib/repo/index.js +1315 -0
- package/studio/src/lib/repo/memory-adapter.js +115 -0
- package/studio/src/lib/repo/remote-adapter.js +158 -0
- package/studio/src/lib/repo/schema.js +143 -0
- package/studio/src/lib/repo/select-adapter.js +345 -0
- package/studio/src/lib/router.js +71 -0
- package/studio/src/lib/runner/browser.js +244 -0
- package/studio/src/lib/runner/checks.js +248 -0
- package/studio/src/lib/runner/current-code.js +98 -0
- package/studio/src/lib/runner/esm-cjs.js +109 -0
- package/studio/src/lib/runner/hash.js +34 -0
- package/studio/src/lib/runner/history.js +48 -0
- package/studio/src/lib/runner/index.js +168 -0
- package/studio/src/lib/runner/languages.js +258 -0
- package/studio/src/lib/runner/local.js +139 -0
- package/studio/src/lib/runner/path.js +104 -0
- package/studio/src/lib/runner/skeleton.js +315 -0
- package/studio/src/lib/runner/strip-types.js +134 -0
- package/studio/src/lib/settings.js +399 -0
- package/studio/src/lib/srs.js +39 -0
- package/templates/agent/settings.json +6 -0
- package/templates/claude/plugin.json +139 -0
- package/templates/claude/settings.json +15 -0
- package/templates/cursor/professor.mdc +4 -0
- package/templates/cursor/settings.json +18 -0
- package/templates/gemini/GEMINI.md +28 -0
- package/templates/gemini/settings.json +5 -0
- package/templates/opencode/opencode.json +3 -0
- package/templates/researcher/README.md +61 -0
- package/templates/researcher/settings.json +18 -0
- package/web/client/components.json +15 -0
- package/web/client/index.html +12 -0
- package/web/client/package-lock.json +8732 -0
- package/web/client/package.json +39 -0
- package/web/client/postcss.config.js +6 -0
- package/web/client/src/App.jsx +140 -0
- package/web/client/src/api/client.js +357 -0
- package/web/client/src/components/ChatPanel.jsx +417 -0
- package/web/client/src/components/CommandPills.jsx +50 -0
- package/web/client/src/components/DeprecationBanner.jsx +21 -0
- package/web/client/src/components/ExerciseEditor.jsx +164 -0
- package/web/client/src/components/Header.jsx +119 -0
- package/web/client/src/components/LecturePanel.jsx +342 -0
- package/web/client/src/components/MobileTabSwitcher.jsx +51 -0
- package/web/client/src/components/SplitPane.jsx +42 -0
- package/web/client/src/components/ui/alert.jsx +38 -0
- package/web/client/src/components/ui/badge.jsx +24 -0
- package/web/client/src/components/ui/button.jsx +23 -0
- package/web/client/src/components/ui/select.jsx +74 -0
- package/web/client/src/hooks/useSSE.js +152 -0
- package/web/client/src/hooks/useWebSocket.js +98 -0
- package/web/client/src/index.css +23 -0
- package/web/client/src/lib/utils.js +6 -0
- package/web/client/src/main.jsx +12 -0
- package/web/client/src/utils/markdown.js +50 -0
- package/web/client/tailwind.config.js +8 -0
- package/web/client/vite.config.js +21 -0
- package/web/dist/assets/index-C1W0eXIQ.js +294 -0
- package/web/dist/assets/index-C3OUx70T.css +1 -0
- package/web/dist/index.html +13 -0
- package/web/lecture-archive.js +172 -0
- package/web/legacy-server.js +1277 -0
- package/web/package-lock.json +855 -0
- package/web/package.json +10 -0
- package/web/security.js +1016 -0
- package/web/server.js +390 -0
- package/web/studio-api/agents.js +580 -0
- package/web/studio-api/bridge.js +199 -0
- package/web/studio-api/db.js +66 -0
- package/web/studio-api/guards.js +201 -0
- package/web/studio-api/health.js +538 -0
- package/web/studio-api.js +214 -0
- package/web/studio-db.js +380 -0
- package/web/studio-runner.js +568 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* studio-api/agents.js — local agent runners for the bridge.
|
|
3
|
+
*
|
|
4
|
+
* Owns the process-isolation and per-CLI stream-json parsing for every bridge agent. Extracted
|
|
5
|
+
* verbatim from `web/studio-api.js` (Phase 1 seam split). Phase 2 will extend this module with the
|
|
6
|
+
* permission-flag denylist (`buildAgentArgs`).
|
|
7
|
+
*/
|
|
8
|
+
import { spawn } from 'child_process';
|
|
9
|
+
import { mkdtempSync, rmSync } from 'fs';
|
|
10
|
+
import { tmpdir } from 'os';
|
|
11
|
+
import { join } from 'path';
|
|
12
|
+
|
|
13
|
+
import { AGENT_BINARIES, describeNoOutput, ollamaHttpFailure, resolveOllamaModel } from './health.js';
|
|
14
|
+
import * as security from '../security.js';
|
|
15
|
+
|
|
16
|
+
// Permission map injected into OpenCode so the tutor cannot touch the learner's files.
|
|
17
|
+
const OPENCODE_PERMISSION_DENY = {
|
|
18
|
+
edit: 'deny',
|
|
19
|
+
bash: 'deny',
|
|
20
|
+
webfetch: 'deny',
|
|
21
|
+
websearch: 'deny',
|
|
22
|
+
task: 'deny',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/* ------------------------------------------------------------------ process isolation */
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create a throwaway working directory for agent CLIs. OpenCode/Cursor are full coding agents:
|
|
29
|
+
* run in the repo they would read project files and inflate the prompt (~37K input tokens for a
|
|
30
|
+
* one-word reply). A fresh empty dir keeps the tutor text-only and cheap.
|
|
31
|
+
* @param {(...a:any[])=>void} log
|
|
32
|
+
* @returns {string|undefined}
|
|
33
|
+
*/
|
|
34
|
+
function makeTempCwd(log) {
|
|
35
|
+
try {
|
|
36
|
+
return mkdtempSync(join(tmpdir(), 'professor-'));
|
|
37
|
+
} catch (err) {
|
|
38
|
+
log('[studio agent] could not create temp cwd:', err.message);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Remove a temp cwd created by makeTempCwd (idempotent). */
|
|
44
|
+
function cleanupTempCwd(dir, log) {
|
|
45
|
+
if (!dir) return;
|
|
46
|
+
try {
|
|
47
|
+
rmSync(dir, { recursive: true, force: true });
|
|
48
|
+
} catch (err) {
|
|
49
|
+
log('[studio agent] could not remove temp cwd:', err.message);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Environment for the OpenCode CLI: the allowlisted env plus a server-built deny permission profile
|
|
55
|
+
* so the tutor cannot touch the learner's files. An inherited `OPENCODE_CONFIG_CONTENT` is never
|
|
56
|
+
* copied; only a server/test `extraEnv` value may contribute extra config.
|
|
57
|
+
* @param {Record<string, string|undefined>} [extraEnv]
|
|
58
|
+
* @returns {Record<string, string>}
|
|
59
|
+
*/
|
|
60
|
+
function opencodeEnv(extraEnv = {}) {
|
|
61
|
+
const env = security.buildAgentEnv('opencode', process.env, { extraEnv });
|
|
62
|
+
let config = {};
|
|
63
|
+
if (env.OPENCODE_CONFIG_CONTENT) {
|
|
64
|
+
try {
|
|
65
|
+
config = JSON.parse(env.OPENCODE_CONFIG_CONTENT) || {};
|
|
66
|
+
} catch {
|
|
67
|
+
config = {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
config.permission = { ...(config.permission || {}), ...OPENCODE_PERMISSION_DENY };
|
|
71
|
+
env.OPENCODE_CONFIG_CONTENT = JSON.stringify(config);
|
|
72
|
+
return env;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resolve an agent binary without a shell and bail out on a Windows `.cmd`/`.bat` shim (D-16).
|
|
77
|
+
* @param {string} command
|
|
78
|
+
* @param {{ platform?: string, pathValue?: string, fs?: object, pathext?: string }} [opts]
|
|
79
|
+
* @returns {string|null}
|
|
80
|
+
*/
|
|
81
|
+
export function resolveAgentCommand(command, opts = {}) {
|
|
82
|
+
const platform = opts.platform || process.platform;
|
|
83
|
+
const resolved = security.resolveExecutable(command, { ...opts, platform });
|
|
84
|
+
if (resolved && security.isWindowsCommandShim(resolved, platform)) {
|
|
85
|
+
const err = new Error(security.unsupportedWindowsShimMessage(command, resolved));
|
|
86
|
+
err.code = 'unsupported_windows_shim';
|
|
87
|
+
err.path = resolved;
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
return resolved;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* ------------------------------------------------------------------ agent runners */
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Each runner takes a context and returns `{ kill() }`, calling `onText`/`onError`/`onDone`.
|
|
97
|
+
* @typedef {{ system: string, prompt: string, model?: string, messages: object[],
|
|
98
|
+
* onText: (t:string)=>void, onError: (e:{message:string,code:string}) => void,
|
|
99
|
+
* onDone: ()=>void, log: (...a:any[])=>void }} RunContext
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/** Wire stdout (JSON lines) and stderr (diagnostic lines) readers; returns a flusher for the tail. */
|
|
103
|
+
function attachStreams(proc, { onLine, onStderr, log }) {
|
|
104
|
+
let buffer = '';
|
|
105
|
+
proc.stdout.on('data', (chunk) => {
|
|
106
|
+
buffer += chunk.toString();
|
|
107
|
+
const lines = buffer.split('\n');
|
|
108
|
+
buffer = lines.pop() ?? '';
|
|
109
|
+
for (const line of lines) if (line.trim()) onLine(line);
|
|
110
|
+
});
|
|
111
|
+
proc.stderr.on('data', (chunk) => {
|
|
112
|
+
const text = chunk.toString();
|
|
113
|
+
for (const part of text.split('\n')) {
|
|
114
|
+
const trimmed = part.trim();
|
|
115
|
+
if (trimmed) onStderr?.(trimmed);
|
|
116
|
+
}
|
|
117
|
+
log('[studio agent stderr]', text.slice(0, 300));
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
flush() {
|
|
121
|
+
const tail = buffer.trim();
|
|
122
|
+
buffer = '';
|
|
123
|
+
if (tail) onLine(tail);
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Map an unexpected Windows spawn failure to the documented shim/beta error (D-16). */
|
|
129
|
+
function spawnFailure(spec, err) {
|
|
130
|
+
if (process.platform === 'win32' && ['EINVAL', 'ENOENT', 'EPERM'].includes(err?.code)) {
|
|
131
|
+
return {
|
|
132
|
+
message: security.unsupportedWindowsShimMessage(spec.label, spec.command),
|
|
133
|
+
code: 'unsupported_windows_shim',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return { message: `${spec.label} failed to start: ${err.message}`, code: 'server' };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Shared runner for CLI agents that emit newline-delimited JSON. Handles the temp cwd, stderr
|
|
141
|
+
* capture, the "streamed nothing" fallback and the actionable diagnosis on a non-zero exit.
|
|
142
|
+
*/
|
|
143
|
+
function runJsonCli(ctx, spec) {
|
|
144
|
+
const { onText, onError, onDone, log } = ctx;
|
|
145
|
+
const args = spec.args(ctx);
|
|
146
|
+
const env = spec.env || {};
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
security.assertSafeAgentInvocation(spec.agent, args, env);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
onError({ message: err.message, code: 'unsafe_invocation' });
|
|
152
|
+
onDone();
|
|
153
|
+
return { kill() {} };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const cwd = spec.tempCwd === false ? undefined : makeTempCwd(log);
|
|
157
|
+
|
|
158
|
+
let command = spec.command;
|
|
159
|
+
try {
|
|
160
|
+
const resolved = resolveAgentCommand(spec.command);
|
|
161
|
+
if (resolved) command = resolved;
|
|
162
|
+
} catch (err) {
|
|
163
|
+
cleanupTempCwd(cwd, log);
|
|
164
|
+
onError({ message: err.message, code: err.code || 'unsupported_windows_shim' });
|
|
165
|
+
onDone();
|
|
166
|
+
return { kill() {} };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let proc;
|
|
170
|
+
try {
|
|
171
|
+
proc = spawn(command, args, {
|
|
172
|
+
cwd: cwd || spec.cwd,
|
|
173
|
+
env,
|
|
174
|
+
shell: false,
|
|
175
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
176
|
+
});
|
|
177
|
+
} catch (err) {
|
|
178
|
+
cleanupTempCwd(cwd, log);
|
|
179
|
+
const failure = spawnFailure(spec, err);
|
|
180
|
+
onError(failure);
|
|
181
|
+
onDone();
|
|
182
|
+
return { kill() {} };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let streamed = false;
|
|
186
|
+
let resultText = '';
|
|
187
|
+
let lastStep = '';
|
|
188
|
+
const stderrLines = [];
|
|
189
|
+
const errorLines = [];
|
|
190
|
+
let finished = false;
|
|
191
|
+
const finish = (err) => {
|
|
192
|
+
if (finished) return;
|
|
193
|
+
finished = true;
|
|
194
|
+
if (err) onError(err);
|
|
195
|
+
cleanupTempCwd(cwd, log);
|
|
196
|
+
onDone();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const io = attachStreams(proc, {
|
|
200
|
+
log,
|
|
201
|
+
onStderr: (line) => stderrLines.push(line),
|
|
202
|
+
onLine: (line) => {
|
|
203
|
+
let event;
|
|
204
|
+
try {
|
|
205
|
+
event = JSON.parse(line);
|
|
206
|
+
} catch {
|
|
207
|
+
if (spec.textOnNonJson) {
|
|
208
|
+
streamed = true;
|
|
209
|
+
onText(`${line.trim()}\n`);
|
|
210
|
+
} else {
|
|
211
|
+
log('[studio agent non-json]', line.slice(0, 200));
|
|
212
|
+
}
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const text = spec.extract?.(event);
|
|
216
|
+
if (text) {
|
|
217
|
+
streamed = true;
|
|
218
|
+
onText(text);
|
|
219
|
+
}
|
|
220
|
+
const final = spec.finalText?.(event);
|
|
221
|
+
if (typeof final === 'string' && final) resultText = final;
|
|
222
|
+
// Some agents report failures as a structured event on stdout (OpenCode `type:"error"`),
|
|
223
|
+
// not stderr — capture it so a non-zero exit is never reported without a reason.
|
|
224
|
+
const errText = spec.errorText?.(event);
|
|
225
|
+
if (errText) errorLines.push(errText);
|
|
226
|
+
const step = spec.step?.(event);
|
|
227
|
+
if (step) lastStep = step;
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
proc.on('error', (err) => finish(spawnFailure(spec, err)));
|
|
232
|
+
proc.on('close', (code) => {
|
|
233
|
+
io.flush();
|
|
234
|
+
if (!streamed && resultText) onText(resultText);
|
|
235
|
+
// Any run that ends without text is a failure — even exit 0 (an agent that looped on denied
|
|
236
|
+
// tools, or returned an empty reply). Never leave the client with a silent empty stream.
|
|
237
|
+
if (!streamed && !resultText) {
|
|
238
|
+
const stderr = [...errorLines, ...stderrLines].join('\n');
|
|
239
|
+
const diag = describeNoOutput(spec.agent, { stderr, exitCode: code, lastStep });
|
|
240
|
+
// A named model that fails opaquely is most often the culprit — point the user at the picker.
|
|
241
|
+
if (!diag.hint && ctx.model) diag.hint = 'If you picked a model, try another (or Default) in Settings.';
|
|
242
|
+
return finish(diag);
|
|
243
|
+
}
|
|
244
|
+
finish();
|
|
245
|
+
});
|
|
246
|
+
return { kill: () => proc.kill('SIGTERM') };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* -- per-agent stream-json extractors (fixture-tested in studio/test/agent-parsers.test.js) -- */
|
|
250
|
+
|
|
251
|
+
/** Claude Code `--include-partial-messages`: text arrives as `stream_event` `text_delta`s. */
|
|
252
|
+
export function extractClaudeText(event) {
|
|
253
|
+
if (!event || typeof event !== 'object') return null;
|
|
254
|
+
if (event.type === 'stream_event') {
|
|
255
|
+
const text = event.event?.delta?.text;
|
|
256
|
+
return typeof text === 'string' && text ? text : null;
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** OpenCode `run --format json` emits `{"type":"text","part":{"type":"text","text":"…"}}`. */
|
|
262
|
+
export function extractOpencodeText(event) {
|
|
263
|
+
if (!event || typeof event !== 'object') return null;
|
|
264
|
+
if (event.type === 'text' && event.part?.type === 'text' && typeof event.part.text === 'string') {
|
|
265
|
+
return event.part.text;
|
|
266
|
+
}
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Gemini CLI `-o stream-json` emits `{"type":"message","role":"assistant","content":"…","delta":true}`. */
|
|
271
|
+
export function extractGeminiText(event) {
|
|
272
|
+
if (!event || typeof event !== 'object') return null;
|
|
273
|
+
if (event.type === 'message' && event.role === 'assistant' && event.delta !== false) {
|
|
274
|
+
return typeof event.content === 'string' && event.content ? event.content : null;
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Antigravity `--output-format stream-json` emits `step_update.text_delta` for agent responses. */
|
|
280
|
+
export function extractAntigravityText(event) {
|
|
281
|
+
if (!event || typeof event !== 'object') return null;
|
|
282
|
+
const su = event.event === 'step_update' ? event.step_update : null;
|
|
283
|
+
if (su && su.step_type === 'agent_response' && typeof su.text_delta === 'string' && su.text_delta) {
|
|
284
|
+
return su.text_delta;
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Short "step_type state" label for the last Antigravity step (used in no-output diagnostics). */
|
|
290
|
+
export function antigravityStep(event) {
|
|
291
|
+
const su = event?.event === 'step_update' ? event.step_update : null;
|
|
292
|
+
if (!su) return null;
|
|
293
|
+
return [su.step_type, su.state].filter(Boolean).join(' ') || null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Antigravity reports a failed tool step (e.g. a headless permission denial) on that step. */
|
|
297
|
+
export function antigravityErrorText(event) {
|
|
298
|
+
const su = event?.event === 'step_update' ? event.step_update : null;
|
|
299
|
+
if (!su || su.state !== 'ERROR') return null;
|
|
300
|
+
const tool = su.tool_info?.error?.message || su.tool_info?.error?.type;
|
|
301
|
+
return tool || su.error?.message || `${su.step_type || 'step'} failed`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Antigravity prompt guard. With a flattened `[System]…USER:…` prompt, `--mode plan` makes agy try
|
|
306
|
+
* a command tool that headless mode auto-denies, so it exits 0 with NO text. The explicit
|
|
307
|
+
* plain-text instruction reliably suppresses tool use while `--mode plan` keeps the run read-only.
|
|
308
|
+
* @param {{ prompt: string, model?: string }} ctx
|
|
309
|
+
*/
|
|
310
|
+
export function antigravityArgs({ prompt, model }) {
|
|
311
|
+
const guarded = `${prompt}\n\nRespond in plain text only. Do not use any tools.`;
|
|
312
|
+
const args = ['-p', guarded, '--output-format', 'stream-json', '--mode', 'plan'];
|
|
313
|
+
if (model) args.push('--model', model);
|
|
314
|
+
return args;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** Claude/Cursor emit a final `{"type":"result","result":"…"}` with the whole reply. */
|
|
318
|
+
function resultText(event) {
|
|
319
|
+
return event?.type === 'result' && typeof event.result === 'string' ? event.result : null;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Antigravity's final `{"event":"result","result":{"response":"…"}}`. */
|
|
323
|
+
function antigravityResultText(event) {
|
|
324
|
+
return event?.event === 'result' && typeof event.result?.response === 'string' ? event.result.response : null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** OpenCode reports failures as `{"type":"error","error":{"data":{"message":"…"}}}` on stdout. */
|
|
328
|
+
export function opencodeErrorText(event) {
|
|
329
|
+
if (event?.type !== 'error') return null;
|
|
330
|
+
return event.error?.data?.message || event.error?.message || 'OpenCode reported an error';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Claude/Cursor mark failures with `{"type":"result","is_error":true,"result":"…"}`. */
|
|
334
|
+
export function claudeErrorText(event) {
|
|
335
|
+
if (event?.type !== 'result' || !event.is_error) return null;
|
|
336
|
+
return typeof event.result === 'string' && event.result ? event.result : event.subtype || 'Agent reported an error';
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Gemini reports failures as `{"type":"error","message":"…"}`. */
|
|
340
|
+
export function geminiErrorText(event) {
|
|
341
|
+
if (event?.type !== 'error') return null;
|
|
342
|
+
return event.message || 'Gemini reported an error';
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* The exact safe argv for an agent. This is the single place that builds flags; no bypass flag is
|
|
347
|
+
* ever added, and `assertSafeAgentInvocation` re-checks the result immediately before spawn (D-15).
|
|
348
|
+
* @param {string} agent
|
|
349
|
+
* @param {{ system?: string, prompt: string, model?: string }} ctx
|
|
350
|
+
* @returns {string[]}
|
|
351
|
+
*/
|
|
352
|
+
export function buildAgentArgs(agent, ctx) {
|
|
353
|
+
const { system, prompt, model } = ctx || {};
|
|
354
|
+
switch (agent) {
|
|
355
|
+
case 'claude': {
|
|
356
|
+
const args = [
|
|
357
|
+
'--print',
|
|
358
|
+
'--output-format',
|
|
359
|
+
'stream-json',
|
|
360
|
+
'--include-partial-messages',
|
|
361
|
+
'--verbose',
|
|
362
|
+
];
|
|
363
|
+
if (system) args.push('--system-prompt', system);
|
|
364
|
+
args.push(prompt);
|
|
365
|
+
return args;
|
|
366
|
+
}
|
|
367
|
+
case 'cursor': {
|
|
368
|
+
const args = ['--print', '--output-format', 'stream-json', '--stream-partial-output'];
|
|
369
|
+
if (model) args.push('--model', model);
|
|
370
|
+
args.push(prompt);
|
|
371
|
+
return args;
|
|
372
|
+
}
|
|
373
|
+
case 'opencode': {
|
|
374
|
+
const args = ['run', '--format', 'json'];
|
|
375
|
+
if (model) args.push('--model', model);
|
|
376
|
+
args.push(prompt);
|
|
377
|
+
return args;
|
|
378
|
+
}
|
|
379
|
+
case 'gemini': {
|
|
380
|
+
const args = ['-p', prompt, '-o', 'stream-json', '--approval-mode', 'plan'];
|
|
381
|
+
if (model) args.push('-m', model);
|
|
382
|
+
return args;
|
|
383
|
+
}
|
|
384
|
+
case 'antigravity':
|
|
385
|
+
return antigravityArgs(ctx || {});
|
|
386
|
+
default:
|
|
387
|
+
throw new Error(`Unknown agent: ${agent}`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function cursorBinary() {
|
|
392
|
+
for (const binary of AGENT_BINARIES.cursor) {
|
|
393
|
+
const resolved = security.resolveExecutable(binary);
|
|
394
|
+
if (resolved) return resolved;
|
|
395
|
+
}
|
|
396
|
+
return 'agent';
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function spawnClaude({ extraEnv, ...ctx }) {
|
|
400
|
+
return runJsonCli(ctx, {
|
|
401
|
+
agent: 'claude',
|
|
402
|
+
label: 'Claude Code CLI',
|
|
403
|
+
command: 'claude',
|
|
404
|
+
args: () => buildAgentArgs('claude', ctx),
|
|
405
|
+
env: security.buildAgentEnv('claude', process.env, { extraEnv }),
|
|
406
|
+
extract: extractClaudeText,
|
|
407
|
+
finalText: resultText,
|
|
408
|
+
errorText: claudeErrorText,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function spawnCursor({ extraEnv, ...ctx }) {
|
|
413
|
+
// Cursor streams deltas like Claude; if it only sends a cumulative `assistant` message, emit the
|
|
414
|
+
// delta once. Prefer deltas, and never double-emit.
|
|
415
|
+
let sawStream = false;
|
|
416
|
+
let lastAssistant = '';
|
|
417
|
+
const extract = (event) => {
|
|
418
|
+
if (event?.type === 'stream_event') {
|
|
419
|
+
const text = event.event?.delta?.text;
|
|
420
|
+
if (text) {
|
|
421
|
+
sawStream = true;
|
|
422
|
+
return text;
|
|
423
|
+
}
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
if (event?.type === 'assistant' && !sawStream) {
|
|
427
|
+
const text = (event.message?.content || [])
|
|
428
|
+
.filter((p) => p.type === 'text')
|
|
429
|
+
.map((p) => p.text)
|
|
430
|
+
.join('');
|
|
431
|
+
if (!text) return null;
|
|
432
|
+
if (text.startsWith(lastAssistant)) {
|
|
433
|
+
const delta = text.slice(lastAssistant.length);
|
|
434
|
+
lastAssistant = text;
|
|
435
|
+
return delta || null;
|
|
436
|
+
}
|
|
437
|
+
lastAssistant = text;
|
|
438
|
+
return text;
|
|
439
|
+
}
|
|
440
|
+
return null;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
return runJsonCli(ctx, {
|
|
444
|
+
agent: 'cursor',
|
|
445
|
+
label: 'Cursor CLI',
|
|
446
|
+
command: cursorBinary(),
|
|
447
|
+
args: () => buildAgentArgs('cursor', ctx),
|
|
448
|
+
env: security.buildAgentEnv('cursor', process.env, { extraEnv }),
|
|
449
|
+
tempCwd: true,
|
|
450
|
+
extract,
|
|
451
|
+
finalText: resultText,
|
|
452
|
+
errorText: claudeErrorText,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function spawnOpencode({ extraEnv, ...ctx }) {
|
|
457
|
+
return runJsonCli(ctx, {
|
|
458
|
+
agent: 'opencode',
|
|
459
|
+
label: 'OpenCode',
|
|
460
|
+
command: 'opencode',
|
|
461
|
+
args: () => buildAgentArgs('opencode', ctx),
|
|
462
|
+
env: opencodeEnv(extraEnv),
|
|
463
|
+
tempCwd: true,
|
|
464
|
+
textOnNonJson: true,
|
|
465
|
+
extract: extractOpencodeText,
|
|
466
|
+
errorText: opencodeErrorText,
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function spawnGemini({ extraEnv, ...ctx }) {
|
|
471
|
+
return runJsonCli(ctx, {
|
|
472
|
+
agent: 'gemini',
|
|
473
|
+
label: 'Gemini CLI',
|
|
474
|
+
command: 'gemini',
|
|
475
|
+
args: () => buildAgentArgs('gemini', ctx),
|
|
476
|
+
env: security.buildAgentEnv('gemini', process.env, { extraEnv }),
|
|
477
|
+
tempCwd: true,
|
|
478
|
+
extract: extractGeminiText,
|
|
479
|
+
errorText: geminiErrorText,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function spawnAntigravity({ extraEnv, ...ctx }) {
|
|
484
|
+
// `--mode plan` keeps the run read-only; `antigravityArgs` also appends the plain-text instruction
|
|
485
|
+
// that stops agy from burning the turn on a tool headless mode would auto-deny (see below).
|
|
486
|
+
// `--disable-slash-commands` cancels plan mode and `--sandbox` made no difference, so neither is used.
|
|
487
|
+
return runJsonCli(ctx, {
|
|
488
|
+
agent: 'antigravity',
|
|
489
|
+
label: 'Antigravity',
|
|
490
|
+
command: 'agy',
|
|
491
|
+
args: () => buildAgentArgs('antigravity', ctx),
|
|
492
|
+
env: security.buildAgentEnv('antigravity', process.env, { extraEnv }),
|
|
493
|
+
tempCwd: true,
|
|
494
|
+
extract: extractAntigravityText,
|
|
495
|
+
finalText: antigravityResultText,
|
|
496
|
+
errorText: antigravityErrorText,
|
|
497
|
+
step: antigravityStep,
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function runOllama(ctx) {
|
|
502
|
+
const { messages, system, model, onText, onError, onDone, log } = ctx;
|
|
503
|
+
const chatMessages = [];
|
|
504
|
+
if (system) chatMessages.push({ role: 'system', content: system });
|
|
505
|
+
for (const m of messages || []) chatMessages.push({ role: m.role, content: m.content });
|
|
506
|
+
|
|
507
|
+
const controller = new AbortController();
|
|
508
|
+
(async () => {
|
|
509
|
+
// "Default" is resolved at run time (RON-208): chosen model → OLLAMA_MODEL → first installed.
|
|
510
|
+
// Never a hard-coded name, which may not be installed.
|
|
511
|
+
const resolved = await resolveOllamaModel({ model, env: process.env });
|
|
512
|
+
if (!resolved.ok) {
|
|
513
|
+
// `localize` tells the Studio client to render the code's catalog copy instead of this
|
|
514
|
+
// English text (LANG-02); the message/hint stay useful for non-Studio API consumers.
|
|
515
|
+
onError({ message: resolved.message, code: resolved.code, hint: resolved.hint, localize: true });
|
|
516
|
+
onDone();
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
const base = resolved.base;
|
|
520
|
+
const selected = resolved.model;
|
|
521
|
+
try {
|
|
522
|
+
const response = await fetch(`${base}/api/chat`, {
|
|
523
|
+
method: 'POST',
|
|
524
|
+
headers: { 'Content-Type': 'application/json' },
|
|
525
|
+
body: JSON.stringify({ model: selected, messages: chatMessages, stream: true }),
|
|
526
|
+
signal: controller.signal,
|
|
527
|
+
});
|
|
528
|
+
if (!response.ok) {
|
|
529
|
+
const text = await response.text().catch(() => '');
|
|
530
|
+
onError(ollamaHttpFailure(response.status, { model: selected, body: text }));
|
|
531
|
+
onDone();
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const reader = response.body.getReader();
|
|
535
|
+
const decoder = new TextDecoder();
|
|
536
|
+
let buffer = '';
|
|
537
|
+
while (true) {
|
|
538
|
+
const { done, value } = await reader.read();
|
|
539
|
+
if (done) break;
|
|
540
|
+
buffer += decoder.decode(value, { stream: true });
|
|
541
|
+
const lines = buffer.split('\n');
|
|
542
|
+
buffer = lines.pop() ?? '';
|
|
543
|
+
for (const line of lines) {
|
|
544
|
+
if (!line.trim()) continue;
|
|
545
|
+
try {
|
|
546
|
+
const parsed = JSON.parse(line);
|
|
547
|
+
const token = parsed.message?.content || '';
|
|
548
|
+
if (token) onText(token);
|
|
549
|
+
} catch {
|
|
550
|
+
/* ignore malformed NDJSON line */
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
onDone();
|
|
555
|
+
} catch (err) {
|
|
556
|
+
if (err?.name === 'AbortError') return;
|
|
557
|
+
log('[studio ollama error]', err.message);
|
|
558
|
+
onError({
|
|
559
|
+
message: `Ollama is not reachable at ${base}.`,
|
|
560
|
+
code: 'not_running',
|
|
561
|
+
hint: 'Start the Ollama app or run `ollama serve`.',
|
|
562
|
+
localize: true,
|
|
563
|
+
});
|
|
564
|
+
onDone();
|
|
565
|
+
}
|
|
566
|
+
})();
|
|
567
|
+
return { kill: () => controller.abort() };
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/** @returns {Record<string, (ctx: RunContext) => {kill:()=>void}|Promise<{kill:()=>void}>>} */
|
|
571
|
+
export function defaultAgentRunners({ extraEnv = {} } = {}) {
|
|
572
|
+
return {
|
|
573
|
+
claude: (ctx) => spawnClaude({ ...ctx, extraEnv }),
|
|
574
|
+
opencode: (ctx) => spawnOpencode({ ...ctx, extraEnv }),
|
|
575
|
+
cursor: (ctx) => spawnCursor({ ...ctx, extraEnv }),
|
|
576
|
+
gemini: (ctx) => spawnGemini({ ...ctx, extraEnv }),
|
|
577
|
+
antigravity: (ctx) => spawnAntigravity({ ...ctx, extraEnv }),
|
|
578
|
+
ollama: runOllama,
|
|
579
|
+
};
|
|
580
|
+
}
|