@uniqbit/mate-core 0.18.5 → 1.0.0-canary.2
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/claude-capability-plugins/companion-mentions/.claude-plugin/marketplace.json +14 -0
- package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +8 -0
- package/claude-capability-plugins/companion-mentions/hooks/companion.ts +457 -0
- package/claude-capability-plugins/companion-mentions/hooks/hooks.json +1 -0
- package/claude-capability-plugins/companion-mentions/hooks/register.ts +403 -0
- package/claude-plugin/hooks/companion-instructions.mjs +9 -0
- package/claude-plugin/hooks/hooks.json +21 -2
- package/claude-plugin/hooks/tokensave-route.mjs +52 -0
- package/opencode-plugin/src/server.ts +4 -0
- package/opencode-plugin/src/tui.tsx +2 -0
- package/opencode-plugin/tui.tsx +2 -0
- package/package.json +52 -15
- package/src/brand/art.generated.ts +69 -0
- package/src/brand/index.ts +12 -0
- package/src/brand/palette.ts +19 -0
- package/src/brand/svg.generated.ts +8 -0
- package/src/brand/terminal.ts +88 -0
- package/src/brand/types.ts +33 -0
- package/src/cli/commands/artifact/apply-context.ts +275 -0
- package/src/cli/commands/artifact/artifact.ts +12 -0
- package/src/cli/commands/artifact/delivery/archive.ts +125 -0
- package/src/cli/commands/artifact/delivery/branch-flags.ts +55 -0
- package/src/cli/commands/artifact/delivery/environment.ts +127 -0
- package/src/cli/commands/artifact/delivery/link.ts +174 -0
- package/src/cli/commands/artifact/delivery/output.ts +89 -0
- package/src/cli/commands/artifact/finish/command.ts +83 -8
- package/src/cli/commands/artifact/finish/engine.ts +91 -14
- package/src/cli/commands/artifact/finish/finisher.ts +10 -0
- package/src/cli/commands/artifact/finish/git.ts +132 -19
- package/src/cli/commands/artifact/finish/openspec.ts +182 -138
- package/src/cli/commands/artifact/finish/secret-scan.ts +43 -0
- package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
- package/src/cli/commands/artifact/pending/command.ts +31 -3
- package/src/cli/commands/artifact/pending/discovery.ts +21 -57
- package/src/cli/commands/cap/graphify.ts +52 -3
- package/src/cli/commands/cap/index-cmd.ts +71 -15
- package/src/cli/commands/cap/openspec.ts +13 -25
- package/src/cli/commands/cap/tokensave.ts +7 -5
- package/src/cli/commands/companion/link.ts +14 -1
- package/src/cli/commands/companion/open.ts +68 -46
- package/src/cli/commands/companion/sync.ts +10 -0
- package/src/cli/commands/companion/tui.ts +17 -7
- package/src/cli/commands/companion/update.ts +143 -48
- package/src/cli/commands/doctor.ts +195 -7
- package/src/cli/commands/factory/factory.ts +301 -0
- package/src/cli/commands/install.ts +133 -9
- package/src/cli/commands/launch/shared.ts +16 -11
- package/src/cli/commands/plugin/install.ts +9 -4
- package/src/cli/commands/plugin/plugin.ts +3 -2
- package/src/cli/commands/report/adapter.ts +11 -2
- package/src/cli/commands/report/contract.ts +21 -0
- package/src/cli/commands/report/highlight.ts +34 -4
- package/src/cli/commands/report/index.ts +20 -1
- package/src/cli/commands/report/markdown.ts +110 -0
- package/src/cli/commands/report/palette.ts +118 -0
- package/src/cli/commands/report/renderer.ts +456 -153
- package/src/cli/commands/report/types.ts +16 -0
- package/src/cli/commands/session/context.ts +102 -0
- package/src/cli/commands/setup.ts +50 -24
- package/src/cli/commands/studio/factory-credential.ts +49 -0
- package/src/cli/commands/studio/index.ts +29 -2
- package/src/cli/commands/studio/openspec-cli.ts +10 -58
- package/src/cli/commands/studio/payload.ts +249 -15
- package/src/cli/commands/studio/routes.ts +41 -6
- package/src/cli/commands/studio/selection.ts +161 -17
- package/src/cli/commands/studio/server.ts +404 -324
- package/src/cli/commands/studio/services.ts +60 -0
- package/src/cli/commands/studio/studio-app.ts +67 -0
- package/src/cli/commands/studio/terminal-assets.ts +21 -33
- package/src/cli/commands/studio/terminal.ts +85 -15
- package/src/cli/commands/studio/views/model.ts +18 -0
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +267 -0
- package/src/cli/commands/studio/views/vault/view.ts +185 -0
- package/src/cli/commands/studio/workset-session.ts +131 -0
- package/src/cli/commands/unwrap.ts +8 -0
- package/src/cli/commands/update.ts +27 -1
- package/src/cli/commands/working/cleanup.ts +10 -1
- package/src/cli/commands/working/link.ts +76 -0
- package/src/cli/commands/working/working.ts +10 -0
- package/src/cli/commands/working/worktree.ts +356 -0
- package/src/cli/commands/wrap.ts +5 -13
- package/src/cli/companion-link-wizard.tsx +2 -0
- package/src/cli/companion-selector.tsx +2 -0
- package/src/cli/confirm.ts +2 -0
- package/src/cli/install-plan.tsx +127 -160
- package/src/cli/launch-selector.tsx +2 -0
- package/src/cli/main.ts +22 -1
- package/src/cli/parse-flags.ts +32 -6
- package/src/cli/repo-list-table.tsx +2 -0
- package/src/cli/setup-selector.tsx +86 -151
- package/src/cli/usage.ts +14 -0
- package/src/create-mate.ts +5 -4
- package/src/hooks/companion-instructions.ts +190 -0
- package/src/hooks/hook-io.ts +63 -0
- package/src/hooks/session-banner.ts +21 -29
- package/src/hooks/session-guidance.ts +9 -17
- package/src/hooks/session-prepare.ts +115 -28
- package/src/hooks/tokensave-route.ts +26 -0
- package/src/hooks/validate-artifact-path.ts +82 -24
- package/src/index.ts +4 -0
- package/src/lib/apply-context/fingerprint.ts +174 -0
- package/src/lib/apply-context/protocol.ts +193 -0
- package/src/lib/change-layout.ts +154 -0
- package/src/lib/components/confirm-prompt.tsx +21 -9
- package/src/lib/components/select-menu.tsx +10 -3
- package/src/lib/components/spinner.tsx +4 -2
- package/src/lib/components/startup-progress.tsx +227 -41
- package/src/lib/components/text-input-display.tsx +2 -0
- package/src/lib/components/wizard-footer.tsx +2 -0
- package/src/lib/components/wizard-header.tsx +16 -12
- package/src/lib/context-mode-package.ts +24 -11
- package/src/lib/delivery/archive-change.ts +166 -0
- package/src/lib/delivery/branches.ts +132 -0
- package/src/lib/delivery/environment.ts +35 -0
- package/src/lib/delivery/forge.ts +279 -0
- package/src/lib/delivery/merge-git.ts +261 -0
- package/src/lib/delivery/overlap.ts +209 -0
- package/src/lib/delivery/record-delivery.ts +283 -0
- package/src/lib/delivery/record.ts +403 -0
- package/src/lib/delivery/refresh.ts +268 -0
- package/src/lib/delivery/repository-access.ts +141 -0
- package/src/lib/delivery/resolve-branch.ts +162 -0
- package/src/lib/delivery/stages.ts +111 -0
- package/src/lib/delivery/token.ts +24 -0
- package/src/lib/factory/attach-client.ts +113 -0
- package/src/lib/factory/attach.ts +178 -0
- package/src/lib/factory/broker.ts +190 -0
- package/src/lib/factory/bun-commands.ts +39 -0
- package/src/lib/factory/client.ts +92 -0
- package/src/lib/factory/command.ts +61 -0
- package/src/lib/factory/credential-store.ts +153 -0
- package/src/lib/factory/frames.ts +77 -0
- package/src/lib/factory/ids.ts +58 -0
- package/src/lib/factory/keyed-serial.ts +27 -0
- package/src/lib/factory/outcomes/actions.ts +114 -0
- package/src/lib/factory/outcomes/index.ts +381 -0
- package/src/lib/factory/outcomes/lifecycle.ts +205 -0
- package/src/lib/factory/outcomes/runs.ts +81 -0
- package/src/lib/factory/outcomes/sessions.ts +38 -0
- package/src/lib/factory/prepare.ts +49 -0
- package/src/lib/factory/pty.ts +103 -0
- package/src/lib/factory/runner/companion-context.ts +178 -0
- package/src/lib/factory/runner/control.ts +92 -0
- package/src/lib/factory/runner/harness-agent.ts +250 -0
- package/src/lib/factory/runner/live.ts +159 -0
- package/src/lib/factory/runner/questions.ts +22 -0
- package/src/lib/factory/runner/rank.ts +26 -0
- package/src/lib/factory/runner/run-policy.ts +12 -0
- package/src/lib/factory/runner/run.ts +199 -0
- package/src/lib/factory/runner/scheduler.ts +416 -0
- package/src/lib/factory/runner/state.ts +233 -0
- package/src/lib/factory/runner/workflow.ts +542 -0
- package/src/lib/factory/runtime.ts +972 -0
- package/src/lib/factory/sandbox.ts +292 -0
- package/src/lib/factory/worktree-branch.ts +17 -0
- package/src/lib/frontmatter.ts +18 -0
- package/src/lib/install.ts +66 -14
- package/src/lib/live-progress.ts +36 -0
- package/src/lib/member-choices.ts +67 -0
- package/src/lib/opencode-plugin-package.ts +5 -5
- package/src/lib/openspec-cli.ts +116 -0
- package/src/lib/openspec-scopes.ts +86 -0
- package/src/lib/orchestrator/adapters/base.ts +55 -22
- package/src/lib/orchestrator/adapters/claude-args.ts +50 -0
- package/src/lib/orchestrator/adapters/claude.ts +54 -41
- package/src/lib/orchestrator/adapters/opencode.ts +2 -0
- package/src/lib/orchestrator/config-store.ts +3 -2
- package/src/lib/orchestrator/editor.ts +31 -25
- package/src/lib/orchestrator/openspec-store.ts +14 -54
- package/src/lib/orchestrator/projection-claude-commands.ts +36 -0
- package/src/lib/orchestrator/projection-claude-links.ts +159 -0
- package/src/lib/orchestrator/projection-claude-skills.ts +19 -137
- package/src/lib/orchestrator/projection-entries.ts +100 -34
- package/src/lib/orchestrator/projection-opencode-copies.ts +32 -15
- package/src/lib/orchestrator/projection-openspec-store.ts +54 -9
- package/src/lib/orchestrator/projection-runtime-documents.ts +15 -6
- package/src/lib/orchestrator/projection-types.ts +36 -1
- package/src/lib/orchestrator/refresh-working-claude-links.ts +87 -0
- package/src/lib/orchestrator/session-context-link.ts +67 -0
- package/src/lib/orchestrator/session-prepare.ts +45 -5
- package/src/lib/orchestrator/setup-compatibilities.ts +56 -70
- package/src/lib/orchestrator/types.ts +7 -2
- package/src/lib/orchestrator/working-repo-projection.ts +50 -7
- package/src/lib/orchestrator/workspace-document.ts +105 -0
- package/src/lib/orchestrator/wrap-pass.ts +22 -1
- package/src/lib/package-paths.ts +37 -0
- package/src/lib/runtime-directory-refresh.ts +17 -1
- package/src/lib/workset/record.ts +513 -0
- package/src/lib/workset/repositories.ts +55 -0
- package/src/lib/workset/stage.ts +148 -0
- package/src/lib/workset/stages.ts +113 -0
- package/src/lib/workset/worktree-index.ts +116 -0
- package/src/lib/workset/worktree.ts +830 -0
- package/src/opencode/companion-hooks.ts +109 -7
- package/src/opencode/companion-policy.ts +37 -18
- package/src/opencode/enter-worktree.ts +72 -0
- package/src/opencode/projected-guidance.ts +4 -1
- package/src/opencode/session-prepare.ts +2 -1
- package/src/opencode/tui.tsx +13 -6
- package/src/plugins.ts +1 -0
- package/src/runtime/artifact-refusal.ts +63 -0
- package/src/runtime/claude-delivery-plan.ts +107 -8
- package/src/runtime/commit-attribution-guard.ts +181 -0
- package/src/runtime/companion-git.ts +52 -10
- package/src/runtime/companion-guidance.ts +20 -8
- package/src/runtime/companion-instructions.ts +340 -0
- package/src/runtime/companion-lock.ts +30 -7
- package/src/runtime/env.ts +48 -3
- package/src/runtime/error-message.ts +4 -0
- package/src/runtime/git-layout.ts +219 -0
- package/src/runtime/index.ts +29 -0
- package/src/runtime/managed-block.ts +117 -0
- package/src/runtime/markdown-scan.ts +266 -0
- package/src/runtime/physical-path.ts +111 -0
- package/src/runtime/policy.ts +50 -2
- package/src/runtime/projected-flag.ts +7 -0
- package/src/runtime/projected-guidance.ts +1 -0
- package/src/runtime/runtime-directory.ts +5 -0
- package/src/runtime/runtime-document-manifest.ts +62 -11
- package/src/runtime/secret-guard.ts +162 -0
- package/src/runtime/secret-patterns.ts +397 -0
- package/src/runtime/secret-scan.ts +90 -0
- package/src/runtime/session-context.ts +98 -0
- package/src/runtime/session-kind.ts +13 -0
- package/src/runtime/shell-heredoc.ts +81 -0
- package/src/runtime/tokensave-route.ts +152 -0
- package/src/runtime/wrap-state.ts +44 -2
- package/src/runtime/write-atomic.ts +64 -0
- package/src/studio.ts +124 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +14 -10
- package/src/templates/capabilities/openspec-cap/mate-minimal/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +18 -102
- package/src/templates/capabilities/openspec-cap/mate-v1/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +20 -14
- package/src/templates/mate-skills/THIRD-PARTY-NOTICES.md +40 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +134 -0
- package/src/templates/mate-skills/agents/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +200 -0
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +86 -0
- package/src/templates/mate-skills/{claude/mate-openspec-backfill → agents/mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +66 -0
- package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +11 -4
- package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +12 -5
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +108 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +47 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-propose.md +169 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/agents/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
- package/src/templates/mate-skills/{claude/mate-artifact-publish → agents/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +95 -16
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +87 -68
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +134 -0
- package/src/templates/mate-skills/claude/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +200 -0
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +86 -0
- package/src/templates/mate-skills/{agents/mate-openspec-backfill → claude/mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +66 -0
- package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +11 -4
- package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +12 -5
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +108 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +47 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-propose.md +169 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/claude/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +111 -24
- package/src/templates/mate-skills/{agents/mate-artifact-publish → claude/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +95 -16
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +87 -68
- package/src/templates/mate-skills/openspec-references.ts +142 -0
- package/src/templates/root/TEMPLATE_AGENTS.md +2 -2
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +3938 -391
- package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
- package/src/tools/setup/capabilities/context-mode.ts +56 -7
- package/src/tools/setup/capabilities/graphify-gate.ts +31 -0
- package/src/tools/setup/capabilities/graphify-secrets.ts +243 -0
- package/src/tools/setup/capabilities/graphify.ts +46 -7
- package/src/tools/setup/capabilities/openspec.ts +163 -272
- package/src/tools/setup/capabilities/react-doctor.ts +8 -1
- package/src/tools/setup/capabilities/rtk.ts +4 -0
- package/src/tools/setup/capabilities/tokensave.ts +113 -71
- package/src/tools/setup/context-services.ts +9 -17
- package/src/tools/setup/dynamic-plugins/install.ts +24 -28
- package/src/tools/setup/engine.ts +100 -23
- package/src/tools/setup/install-contract.ts +8 -0
- package/src/tools/setup/managed-output.ts +51 -0
- package/src/tools/setup/mate-skill-copies.ts +51 -0
- package/src/tools/setup/mate.ts +86 -11
- package/src/tools/setup/package-managers/uv.ts +73 -11
- package/src/tools/setup/plugin.ts +40 -0
- package/src/tools/setup/plugins/guidance.ts +7 -4
- package/src/tools/setup/providers/agent-file-sections.ts +4 -2
- package/src/tools/setup/providers/claude-attribution.ts +65 -0
- package/src/tools/setup/providers/claude-plugin-folders.ts +625 -0
- package/src/tools/setup/providers/claude-plugin-hooks.ts +51 -19
- package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
- package/src/tools/setup/providers/claude.ts +290 -8
- package/src/tools/setup/providers/opencode.ts +180 -1
- package/src/tools/setup/utils.ts +18 -4
- package/src/tools/setup/working-repo-cleanup.ts +29 -1
- package/src/tools/setup/working-repo-local-state.ts +252 -75
- package/src/tools/setup.ts +183 -26
- package/studio-dist/client/assets/companion-view-Csva26Ir.js +1 -0
- package/studio-dist/client/assets/delivery-path-DJMpRmiY.js +1 -0
- package/studio-dist/client/assets/dist-Dm7MtyHc.js +5 -0
- package/studio-dist/client/assets/factory-B7l9ZQyx.js +4 -0
- package/studio-dist/client/assets/index-n6uo_92S.js +40 -0
- package/studio-dist/client/assets/preload-helper-BLdHbfdN.js +1 -0
- package/studio-dist/client/assets/prepaint-CD5OpmTM.js +24 -0
- package/studio-dist/client/assets/queries-CN3JwMBX.js +1 -0
- package/studio-dist/client/assets/react-CabXf2Ds.js +1 -0
- package/studio-dist/client/assets/report-time-Dc-KOqQu.js +1 -0
- package/studio-dist/client/assets/reports-C01RsnMA.js +1 -0
- package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
- package/studio-dist/client/assets/routes-4pbC-2Hj.js +1 -0
- package/studio-dist/client/assets/skills-CihQganl.js +1 -0
- package/studio-dist/client/assets/spec-areas-C2L48N4C.js +1 -0
- package/studio-dist/client/assets/specs-D24_35_K.js +1 -0
- package/studio-dist/client/assets/studio-DKxfi691.css +1 -0
- package/studio-dist/client/assets/studio-queries-rvbJupCy.js +3 -0
- package/studio-dist/client/assets/terminal-eU5fzQzv.css +1 -0
- package/studio-dist/client/assets/vault-Bd4CQiTK.js +1 -0
- package/studio-dist/client/assets/warnings-V_Ys51wJ.js +1 -0
- package/studio-dist/client/assets/wasm-inline-C2en61B5.js +1 -0
- package/studio-dist/client/assets/workflow-BJejeVwQ.js +1 -0
- package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-BQKuMdJW.js +3881 -0
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +85 -0
- package/studio-dist/server/assets/actions-Bvgj9eb8.js +54 -0
- package/studio-dist/server/assets/actions-D8erOphH.js +44 -0
- package/studio-dist/server/assets/companion-view-aBady57v.js +33 -0
- package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +459 -0
- package/studio-dist/server/assets/createServerRpc-tK2lE9R2.js +11 -0
- package/studio-dist/server/assets/delivery-path-BkKNjgkf.js +778 -0
- package/studio-dist/server/assets/dist-DpJWKyCm.js +5582 -0
- package/studio-dist/server/assets/empty-plugin-adapters-Cipd4ZH4.js +4 -0
- package/studio-dist/server/assets/factory-D6xnjedJ.js +2385 -0
- package/studio-dist/server/assets/factory-DT3UzHlh.js +68 -0
- package/studio-dist/server/assets/model-PyPALjii.js +18 -0
- package/studio-dist/server/assets/prepaint-BMke0fo1.js +41 -0
- package/studio-dist/server/assets/queries-Ag2iL8q2.js +107 -0
- package/studio-dist/server/assets/react-COs0LHn-.js +51 -0
- package/studio-dist/server/assets/report-time-DAfzln-N.js +8 -0
- package/studio-dist/server/assets/reports-BnUNJVtx.js +126 -0
- package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +34 -0
- package/studio-dist/server/assets/router-BH--drIx.js +4298 -0
- package/studio-dist/server/assets/routes-khSDK1bV.js +361 -0
- package/studio-dist/server/assets/search-JAKurDNh.js +36 -0
- package/studio-dist/server/assets/shell-CboT2f66.js +51 -0
- package/studio-dist/server/assets/skills-MWYnWoKs.js +106 -0
- package/studio-dist/server/assets/spec-areas-DcnO6vW-.js +16 -0
- package/studio-dist/server/assets/specs-DE3w8hZP.js +155 -0
- package/studio-dist/server/assets/start-BW5ovN0k.js +33 -0
- package/studio-dist/server/assets/studio-BeltxxKt.js +216 -0
- package/studio-dist/server/assets/studio-queries-CLnP9kGu.js +3365 -0
- package/studio-dist/server/assets/utils-C9CX1kcy.js +221 -0
- package/studio-dist/server/assets/vault-BGulVoNh.js +70 -0
- package/studio-dist/server/assets/vault-CuyyhLyB.js +832 -0
- package/studio-dist/server/assets/views-Bd7cRr27.js +82 -0
- package/studio-dist/server/assets/warnings-BH05rOuG.js +15 -0
- package/studio-dist/server/assets/wasm-inline-CNeBKGwC.js +3 -0
- package/studio-dist/server/assets/workflow-BSuIKWqH.js +42 -0
- package/studio-dist/server/server.js +16220 -0
- package/wrappers/bin/graphify +52 -4
- package/wrappers/bin/openspec +33 -9
- package/wrappers/lib/graphify-gate.mjs +8 -0
- package/src/cli/commands/studio/views/client.ts +0 -654
- package/src/cli/commands/studio/views/companion-picker.tsx +0 -95
- package/src/cli/commands/studio/views/companion-selector.tsx +0 -94
- package/src/cli/commands/studio/views/dashboard/changes.tsx +0 -107
- package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
- package/src/cli/commands/studio/views/document.tsx +0 -842
- package/src/cli/commands/studio/views/error.tsx +0 -20
- package/src/cli/commands/studio/views/reports/index.tsx +0 -49
- package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
- package/src/cli/commands/studio/views/skills/index.tsx +0 -87
- package/src/cli/commands/studio/views/specs/index.tsx +0 -157
- package/src/cli/commands/studio/views/styles.ts +0 -519
- package/src/cli/commands/studio/views/terminal.tsx +0 -484
- package/src/cli/commands/studio/views/vault/state.ts +0 -43
- package/src/cli/commands/studio/views/warnings.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/index.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/steps.ts +0 -337
- package/src/cli/commands/studio/views/workflow/transcript.tsx +0 -190
- package/src/lib/components/theme.ts +0 -2
- package/src/tools/setup/git-utils.ts +0 -30
- package/src/tools/setup/runtime-documents.ts +0 -291
|
@@ -2,6 +2,8 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import type { Context } from "@opencode/plugin/promise/plugin";
|
|
4
4
|
|
|
5
|
+
import { resolveArtifactTarget } from "../runtime/artifact-refusal";
|
|
6
|
+
import { checkCommitAttribution } from "../runtime/commit-attribution-guard";
|
|
5
7
|
import {
|
|
6
8
|
companionForkRefusal,
|
|
7
9
|
syncCompanionUnattended,
|
|
@@ -10,12 +12,15 @@ import {
|
|
|
10
12
|
import { hasLaunchEnvironment } from "../runtime/env";
|
|
11
13
|
import { MATE_ENV } from "../runtime/env-names";
|
|
12
14
|
import { resolveProjection } from "../runtime/projection";
|
|
15
|
+
import { checkSecretAccess, type SecretToolCall } from "../runtime/secret-guard";
|
|
16
|
+
import { routeTokensaveInput } from "../runtime/tokensave-route";
|
|
13
17
|
import { readWrapStateSync } from "../runtime/wrap-state";
|
|
14
18
|
import {
|
|
15
19
|
buildArtifactError,
|
|
20
|
+
extractPatchAdditions,
|
|
16
21
|
extractPatchPaths,
|
|
17
22
|
isArtifactPath,
|
|
18
|
-
|
|
23
|
+
isCompanionTarget,
|
|
19
24
|
shouldBlockArtifactWrite,
|
|
20
25
|
type CompanionContext,
|
|
21
26
|
} from "./companion-policy";
|
|
@@ -87,14 +92,55 @@ export async function refuseForkedCompanionWrite(
|
|
|
87
92
|
env: Record<string, string | undefined> = process.env,
|
|
88
93
|
): Promise<void> {
|
|
89
94
|
if (!filePath || !isArtifactPath(filePath)) return;
|
|
90
|
-
if (!
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
95
|
+
if (!isCompanionTarget(context, filePath)) return;
|
|
93
96
|
const refusal = await companionForkRefusal(env, context.companionPath);
|
|
94
97
|
if (refusal) throw new Error(refusal);
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
/**
|
|
100
|
+
/** OpenCode tool inputs in the shape the shared secret guard reads. */
|
|
101
|
+
function secretToolCall(
|
|
102
|
+
context: CompanionContext,
|
|
103
|
+
tool: string,
|
|
104
|
+
args: Record<string, unknown>,
|
|
105
|
+
): SecretToolCall | null {
|
|
106
|
+
const text = (value: unknown) => (typeof value === "string" ? value : "");
|
|
107
|
+
const target = (value: unknown) =>
|
|
108
|
+
text(value) ? resolveArtifactTarget(text(value), context.repositoryPath) : "";
|
|
109
|
+
switch (tool) {
|
|
110
|
+
case "read":
|
|
111
|
+
return { kind: "read", paths: [target(args.filePath)] };
|
|
112
|
+
case "write":
|
|
113
|
+
return {
|
|
114
|
+
kind: "write",
|
|
115
|
+
writes: [{ path: target(args.filePath), content: text(args.content) }],
|
|
116
|
+
};
|
|
117
|
+
case "edit":
|
|
118
|
+
return {
|
|
119
|
+
kind: "write",
|
|
120
|
+
writes: [{ path: target(args.filePath), content: text(args.newString) }],
|
|
121
|
+
};
|
|
122
|
+
case "apply_patch":
|
|
123
|
+
return {
|
|
124
|
+
kind: "write",
|
|
125
|
+
writes: extractPatchAdditions(text(args.patchText)).map((addition) => ({
|
|
126
|
+
path: target(addition.path),
|
|
127
|
+
content: addition.content,
|
|
128
|
+
})),
|
|
129
|
+
};
|
|
130
|
+
case "bash":
|
|
131
|
+
return { kind: "shell", command: text(args.command) };
|
|
132
|
+
case "grep":
|
|
133
|
+
return { kind: "search", paths: [target(args.path)], globs: [text(args.include)] };
|
|
134
|
+
default:
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Rejects when the tool call touches a secret, commits with a model co-author
|
|
141
|
+
* trailer, or would write an artifact outside the companion. Checked in that
|
|
142
|
+
* order, as in the Claude hook.
|
|
143
|
+
*/
|
|
98
144
|
export async function guardToolInput(
|
|
99
145
|
context: CompanionContext,
|
|
100
146
|
tool: string,
|
|
@@ -102,6 +148,20 @@ export async function guardToolInput(
|
|
|
102
148
|
env: Record<string, string | undefined> = process.env,
|
|
103
149
|
): Promise<void> {
|
|
104
150
|
const args = (input ?? {}) as Record<string, unknown>;
|
|
151
|
+
|
|
152
|
+
const secretCall = context.companionPath ? secretToolCall(context, tool, args) : null;
|
|
153
|
+
if (secretCall) {
|
|
154
|
+
const companionRoot = path.normalize(context.companionPath);
|
|
155
|
+
const refusal = await checkSecretAccess(secretCall, {
|
|
156
|
+
companionPath: context.companionPath,
|
|
157
|
+
isCompanionPath: (filePath) => filePath.startsWith(companionRoot),
|
|
158
|
+
});
|
|
159
|
+
if (refusal) throw new Error(refusal);
|
|
160
|
+
}
|
|
161
|
+
if (tool === "bash") {
|
|
162
|
+
const refusal = checkCommitAttribution(String(args.command ?? ""));
|
|
163
|
+
if (refusal) throw new Error(refusal);
|
|
164
|
+
}
|
|
105
165
|
const filePaths =
|
|
106
166
|
tool === "write" || tool === "edit"
|
|
107
167
|
? [String(args.filePath ?? "")]
|
|
@@ -134,7 +194,49 @@ export async function registerCompanionHooks(
|
|
|
134
194
|
*/
|
|
135
195
|
await repairCompanionGitOnce(context, env, api.location.directory).catch(() => []);
|
|
136
196
|
|
|
137
|
-
await api.tool.hook("execute.before", (event) =>
|
|
138
|
-
guardToolInput(context, event.tool, event.input, env)
|
|
197
|
+
await api.tool.hook("execute.before", async (event) => {
|
|
198
|
+
await guardToolInput(context, event.tool, event.input, env);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Registers tokensave worktree routing on an OpenCode V2 plugin context. */
|
|
203
|
+
export async function registerTokensaveRouting(api: Context): Promise<void> {
|
|
204
|
+
await api.tool.hook("execute.before", (event) => routeTokensaveCall(api, event));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** OpenCode names an MCP tool `<server>_<tool>`, also when called from inside `execute`. */
|
|
208
|
+
const TOKENSAVE_TOOL = /^tokensave_/;
|
|
209
|
+
|
|
210
|
+
interface ToolCallEvent {
|
|
211
|
+
tool: string;
|
|
212
|
+
readonly sessionID: string;
|
|
213
|
+
input: unknown;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Points a tokensave call at the linked worktree the calling session works in.
|
|
218
|
+
* The session's directory is read per call: `mate_enter_worktree` moves a
|
|
219
|
+
* session after the plugin, and `api.location`, were set up.
|
|
220
|
+
*/
|
|
221
|
+
async function routeTokensaveCall(api: Context, event: ToolCallEvent): Promise<void> {
|
|
222
|
+
if (!TOKENSAVE_TOOL.test(event.tool)) return;
|
|
223
|
+
const routed = routeTokensaveInput(
|
|
224
|
+
event.tool,
|
|
225
|
+
await sessionDirectory(api, event.sessionID),
|
|
226
|
+
event.input,
|
|
139
227
|
);
|
|
228
|
+
if (routed) event.input = routed;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The session's current directory, else the plugin's start directory: routing
|
|
233
|
+
* never blocks a call.
|
|
234
|
+
*/
|
|
235
|
+
async function sessionDirectory(api: Context, sessionID: string): Promise<string> {
|
|
236
|
+
try {
|
|
237
|
+
const session = await api.session.get({ sessionID: sessionID as never });
|
|
238
|
+
return session.location.directory;
|
|
239
|
+
} catch {
|
|
240
|
+
return api.location.directory;
|
|
241
|
+
}
|
|
140
242
|
}
|
|
@@ -2,6 +2,7 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
|
+
import { artifactRefusal, resolveArtifactTarget } from "../runtime/artifact-refusal";
|
|
5
6
|
import { persistedCompanionGitStalenessLines } from "../runtime/companion-sync";
|
|
6
7
|
import { resolveCompanionRuntime, type CompanionRuntimeContext } from "../runtime/env";
|
|
7
8
|
import { projectionFreshness, projectionStalenessLines } from "../runtime/freshness";
|
|
@@ -60,7 +61,7 @@ export function isArtifactPath(filePath: string): boolean {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
export function isProductDocumentationPath(context: CompanionContext, filePath: string): boolean {
|
|
63
|
-
const normalized =
|
|
64
|
+
const normalized = resolveArtifactTarget(filePath, context.repositoryPath);
|
|
64
65
|
const relativePath = path.relative(context.repositoryPath, normalized);
|
|
65
66
|
if (!relativePath || relativePath.startsWith("..")) {
|
|
66
67
|
return false;
|
|
@@ -86,12 +87,10 @@ export function isProductDocumentationPath(context: CompanionContext, filePath:
|
|
|
86
87
|
return false;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
export function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return path.normalize(path.join(context.repositoryPath, filePath));
|
|
90
|
+
export function isCompanionTarget(context: CompanionContext, filePath: string): boolean {
|
|
91
|
+
return resolveArtifactTarget(filePath, context.repositoryPath).startsWith(
|
|
92
|
+
path.normalize(context.companionPath),
|
|
93
|
+
);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
export function isGitignored(context: CompanionContext, filePath: string): boolean {
|
|
@@ -99,7 +98,7 @@ export function isGitignored(context: CompanionContext, filePath: string): boole
|
|
|
99
98
|
return false;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
const normalized =
|
|
101
|
+
const normalized = resolveArtifactTarget(filePath, context.repositoryPath);
|
|
103
102
|
if (!normalized.startsWith(path.normalize(context.repositoryPath))) {
|
|
104
103
|
return false;
|
|
105
104
|
}
|
|
@@ -126,7 +125,7 @@ export function shouldBlockArtifactWrite(context: CompanionContext, filePath: st
|
|
|
126
125
|
return false;
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
if (
|
|
128
|
+
if (isCompanionTarget(context, filePath)) {
|
|
130
129
|
return false;
|
|
131
130
|
}
|
|
132
131
|
|
|
@@ -155,16 +154,36 @@ export function extractPatchPaths(patchText: string): string[] {
|
|
|
155
154
|
return paths;
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
/**
|
|
158
|
+
* What a patch would add to each file it touches: the `+` lines of every
|
|
159
|
+
* section, keyed by the section's target (a move's destination when present).
|
|
160
|
+
*/
|
|
161
|
+
export function extractPatchAdditions(patchText: string): { path: string; content: string }[] {
|
|
162
|
+
const additions: { path: string; content: string[] }[] = [];
|
|
163
|
+
let current: { path: string; content: string[] } | undefined;
|
|
164
|
+
for (const line of patchText.split("\n")) {
|
|
165
|
+
const marker = /^\*\*\* (Add|Update|Delete|Move to) File:\s*(.+)$/.exec(line);
|
|
166
|
+
if (marker) {
|
|
167
|
+
if (marker[1] === "Move to" && current) {
|
|
168
|
+
current.path = marker[2].trim();
|
|
169
|
+
} else {
|
|
170
|
+
current = { path: marker[2].trim(), content: [] };
|
|
171
|
+
additions.push(current);
|
|
172
|
+
}
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (current && line.startsWith("+")) current.content.push(line.slice(1));
|
|
176
|
+
}
|
|
177
|
+
return additions.map((entry) => ({ path: entry.path, content: entry.content.join("\n") }));
|
|
178
|
+
}
|
|
161
179
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
180
|
+
export function buildArtifactError(context: CompanionContext, filePath: string): string {
|
|
181
|
+
return artifactRefusal({
|
|
182
|
+
target: filePath,
|
|
183
|
+
resolved: resolveArtifactTarget(filePath, context.repositoryPath),
|
|
184
|
+
companion: context.companionPath,
|
|
185
|
+
repoRoot: context.repositoryPath,
|
|
186
|
+
});
|
|
168
187
|
}
|
|
169
188
|
|
|
170
189
|
/**
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import type { Context } from "@opencode/plugin/promise/plugin";
|
|
4
|
+
|
|
5
|
+
import { isLinkedWorktreeOf, readGitLayout } from "../runtime/git-layout";
|
|
6
|
+
import { realPathOrNull as realPath } from "../runtime/physical-path";
|
|
7
|
+
import { companionLinkPath } from "../runtime/repo-local";
|
|
8
|
+
import type { CompanionContext } from "./companion-policy";
|
|
9
|
+
|
|
10
|
+
export const ENTER_WORKTREE_TOOL = "mate_enter_worktree";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Why the session may not move into `target`, or null when `target` is a linked worktree
|
|
14
|
+
* of the session's Working Repository whose Repository Link names the session's companion.
|
|
15
|
+
*/
|
|
16
|
+
export function enterWorktreeRefusal(context: CompanionContext, target: string): string | null {
|
|
17
|
+
if (!context.repositoryPath) return "this session has no Working Repository";
|
|
18
|
+
if (!path.isAbsolute(target)) return `${target} is not an absolute path`;
|
|
19
|
+
const worktree = realPath(target);
|
|
20
|
+
if (!worktree) return `${target} does not exist`;
|
|
21
|
+
if (!isLinkedWorktreeOf(worktree, context.repositoryPath)) {
|
|
22
|
+
// No `.git` of its own: a folder inside a checkout, not its root.
|
|
23
|
+
return readGitLayout(worktree)
|
|
24
|
+
? `${target} is not a linked worktree of ${context.repositoryPath}`
|
|
25
|
+
: `${target} is not the root of a Git worktree`;
|
|
26
|
+
}
|
|
27
|
+
const linked = realPath(companionLinkPath(worktree));
|
|
28
|
+
if (!linked || linked !== realPath(context.companionPath)) {
|
|
29
|
+
return `${target} is not linked to the companion ${context.companionPath}`;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Moves the calling session through the plugin's own client, which talks to the server that owns it. */
|
|
35
|
+
export async function registerEnterWorktree(
|
|
36
|
+
api: Context,
|
|
37
|
+
context: CompanionContext,
|
|
38
|
+
): Promise<void> {
|
|
39
|
+
await api.tool.transform((editor) => {
|
|
40
|
+
editor.add({
|
|
41
|
+
name: ENTER_WORKTREE_TOOL,
|
|
42
|
+
description: `Move this session into a linked Git worktree of the Working Repository that ${context.frameworkName} created, such as the path \`${context.frameworkName} working worktree --enter\` reports. Later tool calls run there.`,
|
|
43
|
+
input: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
path: { type: "string", description: "Absolute path of the worktree." },
|
|
47
|
+
},
|
|
48
|
+
required: ["path"],
|
|
49
|
+
additionalProperties: false,
|
|
50
|
+
},
|
|
51
|
+
async execute(input, tool) {
|
|
52
|
+
const target = (input as { path?: unknown } | undefined)?.path;
|
|
53
|
+
const refusal =
|
|
54
|
+
typeof target === "string"
|
|
55
|
+
? enterWorktreeRefusal(context, target)
|
|
56
|
+
: "the path must be a string";
|
|
57
|
+
if (refusal) {
|
|
58
|
+
return {
|
|
59
|
+
content: `Refused: ${refusal}. The session stays in ${context.repositoryPath}.`,
|
|
60
|
+
metadata: { moved: false },
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const directory = realPath(target as string)!;
|
|
64
|
+
await api.session.move({ sessionID: tool.sessionID, directory: directory as never });
|
|
65
|
+
return {
|
|
66
|
+
content: `Moved this session to ${directory}; it is now the Working Repository.`,
|
|
67
|
+
metadata: { moved: true, directory },
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -44,6 +44,9 @@ export function resolveOpenCodeGuidance(
|
|
|
44
44
|
if (!projection) return { guidance: null, errors: [] };
|
|
45
45
|
|
|
46
46
|
const policy = readCompanionPolicy(projection.companionPath);
|
|
47
|
-
const guidance = buildOpenCodeGuidance(
|
|
47
|
+
const guidance = buildOpenCodeGuidance(
|
|
48
|
+
policy.enabledCapabilities.map((name) => ({ name })),
|
|
49
|
+
{ secretGuardrails: policy.secrets.guardrails },
|
|
50
|
+
);
|
|
48
51
|
return { guidance: guidance.errors.length > 0 ? null : guidance, errors: guidance.errors };
|
|
49
52
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Cleanup, Context } from "@opencode/plugin/promise/plugin";
|
|
2
2
|
|
|
3
|
+
import { errorMessage } from "../runtime/error-message";
|
|
3
4
|
import {
|
|
4
5
|
PREPARE_TIMEOUT_MS,
|
|
5
6
|
type PrepareRun,
|
|
@@ -52,7 +53,7 @@ async function report(
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
function failedRun(error: unknown): PrepareRun {
|
|
55
|
-
return { ok: false, notes: [
|
|
56
|
+
return { ok: false, notes: [errorMessage(error)] };
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/** No remote: OpenCode holds MCP servers and skills until `setup` returns. */
|
package/src/opencode/tui.tsx
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
/** @jsxRuntime automatic */
|
|
1
2
|
/** @jsxImportSource @opentui/solid */
|
|
2
3
|
/* oxlint-disable react/no-unknown-property, react/react-in-jsx-scope, react/jsx-key, react-doctor/jsx-key */
|
|
3
4
|
/**
|
|
4
5
|
* OpenCode V2 TUI plugin module (`{ id, setup }`), OpenCode 2.x only.
|
|
5
6
|
* Solid JSX, not React: `key` is not a reconciliation prop here and `TextProps`
|
|
6
7
|
* does not accept it, so the jsx-key rules cannot be satisfied — only suppressed.
|
|
7
|
-
*
|
|
8
|
+
* The line list is a function child: Solid re-runs its `.map` whole on a store change, fine for a few lines.
|
|
8
9
|
*/
|
|
10
|
+
import type { JSX } from "@opentui/solid";
|
|
11
|
+
|
|
12
|
+
import { BRAND_ACCENT } from "../brand/palette";
|
|
9
13
|
import { mateVersion } from "../runtime/install";
|
|
10
14
|
import { readContext, readStalenessLines } from "./companion-policy";
|
|
11
15
|
|
|
@@ -47,7 +51,8 @@ export const STALENESS_POLL_MS = 5_000;
|
|
|
47
51
|
|
|
48
52
|
type SessionNotes = { lines: string[] };
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
/** The `mate v<version>` line uses the brand accent, which reads on light and dark themes alike. */
|
|
55
|
+
export const MATE_VERSION_COLOR = BRAND_ACCENT;
|
|
51
56
|
const MATE_VERSION = process.env.MATE_VERSION ?? mateVersion();
|
|
52
57
|
|
|
53
58
|
function SessionContext({
|
|
@@ -72,12 +77,14 @@ function SessionContext({
|
|
|
72
77
|
paddingBottom={sidebar ? 1 : 0}
|
|
73
78
|
flexShrink={0}
|
|
74
79
|
>
|
|
75
|
-
<text fg={
|
|
80
|
+
<text fg={MATE_VERSION_COLOR}>mate v{MATE_VERSION}</text>
|
|
76
81
|
<text fg={text.muted}>repo: {context.repositoryPath}</text>
|
|
77
82
|
<text fg={text.muted}>mate: {context.companionPath}</text>
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
{/* OpenTUI's Solid transform skips node_modules, so only a function child stays reactive; its children types omit functions. */}
|
|
84
|
+
{
|
|
85
|
+
(() =>
|
|
86
|
+
notes.lines.map((note) => <text fg={warning}>{note}</text>)) as unknown as JSX.Element
|
|
87
|
+
}
|
|
81
88
|
</box>
|
|
82
89
|
);
|
|
83
90
|
}
|
package/src/plugins.ts
CHANGED
|
@@ -14,4 +14,5 @@ export { createTokensavePlugin } from "./tools/setup/capabilities/tokensave";
|
|
|
14
14
|
export { createRtkPlugin } from "./tools/setup/capabilities/rtk";
|
|
15
15
|
export { createGraphifyPlugin } from "./tools/setup/capabilities/graphify";
|
|
16
16
|
export { createContextModePlugin } from "./tools/setup/capabilities/context-mode";
|
|
17
|
+
export { createCompanionMentionsPlugin } from "./tools/setup/capabilities/companion-mentions";
|
|
17
18
|
export { createGitignorePlugin } from "./tools/setup/plugins/gitignore";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** The artifact-write refusal both runtimes print; pure, so either guard can import it. */
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { FRAMEWORK_NAME } from "./framework";
|
|
5
|
+
|
|
6
|
+
/** Matched by consumers and tests; keep byte-identical. */
|
|
7
|
+
export const ARTIFACT_REFUSAL_HEADLINE = "artifact writes must go to the companion framework path.";
|
|
8
|
+
|
|
9
|
+
export interface ArtifactRefusalInput {
|
|
10
|
+
/** As the tool supplied it, relative or absolute. */
|
|
11
|
+
target: string;
|
|
12
|
+
/** The absolute path the guard judged. */
|
|
13
|
+
resolved: string;
|
|
14
|
+
companion: string;
|
|
15
|
+
/** The Working Repository root relative targets resolve against. */
|
|
16
|
+
repoRoot: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The absolute path both guards judge: a relative target resolves against the repo root, never a `cd`. */
|
|
20
|
+
export function resolveArtifactTarget(target: string, repoRoot: string): string {
|
|
21
|
+
if (path.isAbsolute(target)) return path.normalize(target);
|
|
22
|
+
return path.normalize(path.join(repoRoot, target));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function relativeInside(target: string, root: string): string | null {
|
|
26
|
+
const relative = path.relative(path.normalize(root), path.normalize(target));
|
|
27
|
+
if (relative === "" || relative.startsWith("..") || path.isAbsolute(relative)) return null;
|
|
28
|
+
return relative;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The refusal text, without a trailing newline. */
|
|
32
|
+
export function artifactRefusal({
|
|
33
|
+
target,
|
|
34
|
+
resolved,
|
|
35
|
+
companion,
|
|
36
|
+
repoRoot,
|
|
37
|
+
}: ArtifactRefusalInput): string {
|
|
38
|
+
const isRelative = !path.isAbsolute(target);
|
|
39
|
+
const inside = relativeInside(resolved, repoRoot);
|
|
40
|
+
const suggested = inside ? path.join(companion, inside) : null;
|
|
41
|
+
|
|
42
|
+
const lines = [
|
|
43
|
+
`${FRAMEWORK_NAME} guardrail: ${ARTIFACT_REFUSAL_HEADLINE}`,
|
|
44
|
+
` target: ${target}`,
|
|
45
|
+
];
|
|
46
|
+
if (isRelative) lines.push(` resolved: ${resolved}`);
|
|
47
|
+
lines.push(` companion: ${companion}`);
|
|
48
|
+
if (suggested) lines.push(` suggested: ${suggested}`);
|
|
49
|
+
if (isRelative) {
|
|
50
|
+
lines.push(
|
|
51
|
+
"Relative paths resolve against the working repository; a preceding `cd` is not followed.",
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
lines.push(
|
|
55
|
+
suggested
|
|
56
|
+
? "Rewrite to the suggested absolute path and retry."
|
|
57
|
+
: `Use an absolute path under ${companion}.`,
|
|
58
|
+
);
|
|
59
|
+
if (path.basename(target) === "CLAUDE.md") {
|
|
60
|
+
lines.push(`Note: CLAUDE.md already lives in the companion repo at ${companion}/CLAUDE.md.`);
|
|
61
|
+
}
|
|
62
|
+
return lines.join("\n");
|
|
63
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
1
3
|
import type { ClaudeHookGroup } from "./claude-hook-group";
|
|
4
|
+
import type { SessionKind } from "./session-kind";
|
|
2
5
|
import { NOT_WRAPPED, readWrapStateSync, type WrapState } from "./wrap-state";
|
|
3
6
|
|
|
4
7
|
/**
|
|
@@ -7,13 +10,6 @@ import { NOT_WRAPPED, readWrapStateSync, type WrapState } from "./wrap-state";
|
|
|
7
10
|
* may import it.
|
|
8
11
|
*/
|
|
9
12
|
|
|
10
|
-
/**
|
|
11
|
-
* `managed-repo`: `mate claude` with a Working Repository; its prepare just
|
|
12
|
-
* reconciled the Claude wrap, which the launcher asserts. `managed-companion`:
|
|
13
|
-
* a companion-scoped launch. `unmanaged`: a session with no launch environment.
|
|
14
|
-
*/
|
|
15
|
-
export type SessionKind = "managed-repo" | "managed-companion" | "unmanaged";
|
|
16
|
-
|
|
17
13
|
export interface ClaudeDeliveryPlan {
|
|
18
14
|
/** Capability hook groups; `launchSettingsExclude` is what `--settings` must not repeat. */
|
|
19
15
|
readonly hooks: {
|
|
@@ -28,9 +24,112 @@ export interface ClaudeDeliveryPlan {
|
|
|
28
24
|
readonly reconcile: "attended-prepare" | "prepare-hook" | "none";
|
|
29
25
|
/** Companion Git synchronization. */
|
|
30
26
|
readonly gitSync: "launch-preflight" | "prepare-hook" | "banner";
|
|
27
|
+
/**
|
|
28
|
+
* Plugin folders loaded as Claude plugins. A managed launch passes Mate's
|
|
29
|
+
* bundled plugin and every gathered Capability folder but `launchExclude`,
|
|
30
|
+
* the folders the wrap carries; a Claude-wrapped plain session gets those
|
|
31
|
+
* from the wrap alone.
|
|
32
|
+
*/
|
|
33
|
+
readonly plugins: {
|
|
34
|
+
readonly owner: "launch-flag" | "wrap" | "none";
|
|
35
|
+
readonly launchExclude: readonly string[];
|
|
36
|
+
};
|
|
37
|
+
/** Companion Instructions, per thread kind; `dirAccess` through settings loads no memory file. */
|
|
38
|
+
readonly instructions: ClaudeInstructionOwners;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ClaudeInstructionOwners {
|
|
42
|
+
/** `wrap-session-hook`: the wrap's session-prepare hook, once it has prepared, for a launch and a plain session alike. */
|
|
43
|
+
readonly main: "native-memory" | "wrap-session-hook" | "none";
|
|
44
|
+
/** `plugin-subagent-hook`: the bundled plugin's SubagentStart copy; `wrap-subagent-hook`: the wrap's. */
|
|
45
|
+
readonly subagents: "plugin-subagent-hook" | "native-memory" | "wrap-subagent-hook" | "none";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether the session's launch passes `--plugin-dir`: every managed launch does, a plain
|
|
50
|
+
* session cannot. Not whether the session loads plugin folders: a Claude-wrapped plain
|
|
51
|
+
* session gets them from the wrap.
|
|
52
|
+
*/
|
|
53
|
+
export function launchPassesClaudePluginFolders(kind: SessionKind): boolean {
|
|
54
|
+
return kind !== "unmanaged";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function planClaudeDelivery(
|
|
58
|
+
kind: SessionKind,
|
|
59
|
+
wrap: WrapState,
|
|
60
|
+
worktreePluginOverrides: readonly string[] = [],
|
|
61
|
+
): ClaudeDeliveryPlan {
|
|
62
|
+
return {
|
|
63
|
+
...planChannels(kind, wrap),
|
|
64
|
+
plugins: planPlugins(kind, wrap, worktreePluginOverrides),
|
|
65
|
+
instructions: planClaudeInstructions(kind, wrap.runtimes.has("claude")),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The instruction owners alone, for a hook that knows its wrap without reading
|
|
71
|
+
* one: a wrap-carried hook runs only because a Claude wrap installed it, maybe
|
|
72
|
+
* the main checkout's, so it must not gate on this Checkout's manifest.
|
|
73
|
+
*/
|
|
74
|
+
export function planClaudeInstructions(
|
|
75
|
+
kind: SessionKind,
|
|
76
|
+
wrappedForClaude: boolean,
|
|
77
|
+
): ClaudeInstructionOwners {
|
|
78
|
+
switch (kind) {
|
|
79
|
+
case "managed-repo":
|
|
80
|
+
return { main: "wrap-session-hook", subagents: "plugin-subagent-hook" };
|
|
81
|
+
case "managed-companion":
|
|
82
|
+
return { main: "native-memory", subagents: "native-memory" };
|
|
83
|
+
case "unmanaged":
|
|
84
|
+
return wrappedForClaude
|
|
85
|
+
? { main: "wrap-session-hook", subagents: "wrap-subagent-hook" }
|
|
86
|
+
: { main: "none", subagents: "none" };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The folders a managed launch passes with `--plugin-dir`, in order: the
|
|
92
|
+
* bundled plugin, then each gathered folder the wrap does not carry, matched
|
|
93
|
+
* by resolved path. None when the launch flag does not own plugin folders.
|
|
94
|
+
*/
|
|
95
|
+
export function launchPluginFolders(
|
|
96
|
+
plan: ClaudeDeliveryPlan,
|
|
97
|
+
gathered: readonly string[],
|
|
98
|
+
bundledPluginRoot: string,
|
|
99
|
+
): string[] {
|
|
100
|
+
if (plan.plugins.owner !== "launch-flag") return [];
|
|
101
|
+
const carried = new Set(plan.plugins.launchExclude.map((dir) => path.resolve(dir)));
|
|
102
|
+
return [bundledPluginRoot, ...gathered.filter((dir) => !carried.has(path.resolve(dir)))];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function planPlugins(
|
|
106
|
+
kind: SessionKind,
|
|
107
|
+
wrap: WrapState,
|
|
108
|
+
worktreePluginOverrides: readonly string[],
|
|
109
|
+
): ClaudeDeliveryPlan["plugins"] {
|
|
110
|
+
switch (kind) {
|
|
111
|
+
case "managed-repo": {
|
|
112
|
+
const overrides = new Set(
|
|
113
|
+
worktreePluginOverrides.map((directory) => path.resolve(directory)),
|
|
114
|
+
);
|
|
115
|
+
return {
|
|
116
|
+
owner: "launch-flag",
|
|
117
|
+
launchExclude: wrap.carriedClaudePluginDirectories.filter(
|
|
118
|
+
(directory) => !overrides.has(path.resolve(directory)),
|
|
119
|
+
),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
case "managed-companion":
|
|
123
|
+
return { owner: "launch-flag", launchExclude: [] };
|
|
124
|
+
case "unmanaged":
|
|
125
|
+
return { owner: wrap.runtimes.has("claude") ? "wrap" : "none", launchExclude: [] };
|
|
126
|
+
}
|
|
31
127
|
}
|
|
32
128
|
|
|
33
|
-
|
|
129
|
+
function planChannels(
|
|
130
|
+
kind: SessionKind,
|
|
131
|
+
wrap: WrapState,
|
|
132
|
+
): Omit<ClaudeDeliveryPlan, "plugins" | "instructions"> {
|
|
34
133
|
switch (kind) {
|
|
35
134
|
case "managed-repo":
|
|
36
135
|
return {
|