@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
import { PROJECTED_BANNER_FLAG } from "../../../hooks/session-banner";
|
|
5
4
|
import { getClaudePluginRoot } from "../../../lib/package-paths";
|
|
5
|
+
import { PROJECTED_FLAG } from "../../../runtime/projected-flag";
|
|
6
6
|
import { runtimeClaudePluginRoot } from "../../../runtime/runtime-directory";
|
|
7
7
|
import { hookGroupKey, type ClaudeHookGroup } from "./claude-format";
|
|
8
8
|
|
|
@@ -12,12 +12,11 @@ import { hookGroupKey, type ClaudeHookGroup } from "./claude-format";
|
|
|
12
12
|
* all, so the working-target settings document has to carry it instead.
|
|
13
13
|
*
|
|
14
14
|
* A managed session loads the Working Repository's settings as its `local`
|
|
15
|
-
* source *alongside* the plugin, so every group carried over runs twice there
|
|
16
|
-
*
|
|
17
|
-
* input
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* launch's.
|
|
15
|
+
* source *alongside* the plugin, so every group carried over runs twice there;
|
|
16
|
+
* a plain session may load both too, through `--plugin-dir`. The guard is
|
|
17
|
+
* input-pure, the guidance hook yields under a launch environment, and the
|
|
18
|
+
* banner, prepare and SubagentStart instruction copies carried here hold
|
|
19
|
+
* `PROJECTED_FLAG`, so one copy of each acts.
|
|
21
20
|
*
|
|
22
21
|
* The wiring is read from the installed plugin, but every command names
|
|
23
22
|
* `<mate home>/runtime/claude-plugin`, so a reinstall or Node switch does not
|
|
@@ -25,9 +24,11 @@ import { hookGroupKey, type ClaudeHookGroup } from "./claude-format";
|
|
|
25
24
|
*/
|
|
26
25
|
|
|
27
26
|
const GUARD_HOOK_SHIM = "validate-artifact-path.mjs";
|
|
27
|
+
const TOKENSAVE_ROUTE_HOOK_SHIM = "tokensave-route.mjs";
|
|
28
28
|
const GUIDANCE_HOOK_SHIM = "session-guidance.mjs";
|
|
29
29
|
const BANNER_HOOK_SHIM = "session-banner.mjs";
|
|
30
30
|
const PREPARE_HOOK_SHIM = "session-prepare.mjs";
|
|
31
|
+
const INSTRUCTIONS_HOOK_SHIM = "companion-instructions.mjs";
|
|
31
32
|
const PLUGIN_ROOT_TOKEN = "${CLAUDE_PLUGIN_ROOT}";
|
|
32
33
|
|
|
33
34
|
interface PluginHookWiring {
|
|
@@ -46,16 +47,23 @@ function readPluginHookWiring(pluginRoot: string): PluginHookWiring {
|
|
|
46
47
|
return {};
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
function
|
|
50
|
+
function mapCommands(
|
|
51
|
+
group: ClaudeHookGroup,
|
|
52
|
+
rewrite: (command: string) => string,
|
|
53
|
+
): ClaudeHookGroup {
|
|
50
54
|
return {
|
|
51
55
|
...group,
|
|
52
56
|
hooks: (group.hooks ?? []).map((hook) => ({
|
|
53
57
|
...hook,
|
|
54
|
-
...(hook.command ? { command: hook.command
|
|
58
|
+
...(hook.command ? { command: rewrite(hook.command) } : {}),
|
|
55
59
|
})),
|
|
56
60
|
};
|
|
57
61
|
}
|
|
58
62
|
|
|
63
|
+
function resolveCommands(group: ClaudeHookGroup, pluginRoot: string): ClaudeHookGroup {
|
|
64
|
+
return mapCommands(group, (command) => command.split(PLUGIN_ROOT_TOKEN).join(pluginRoot));
|
|
65
|
+
}
|
|
66
|
+
|
|
59
67
|
function runsShim(group: ClaudeHookGroup, shim: string): boolean {
|
|
60
68
|
return (group.hooks ?? []).some((hook) => (hook.command ?? "").includes(shim));
|
|
61
69
|
}
|
|
@@ -76,6 +84,16 @@ export function mateGuardHookGroups(
|
|
|
76
84
|
return groupsFor("PreToolUse", GUARD_HOOK_SHIM, commandRoot);
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
/**
|
|
88
|
+
* The tokensave routing `PreToolUse` group, resolved the same way. Input-pure
|
|
89
|
+
* like the guard, so a session loading both copies routes each call once.
|
|
90
|
+
*/
|
|
91
|
+
export function mateTokensaveRouteHookGroups(
|
|
92
|
+
commandRoot: string = runtimeClaudePluginRoot(),
|
|
93
|
+
): ClaudeHookGroup[] {
|
|
94
|
+
return groupsFor("PreToolUse", TOKENSAVE_ROUTE_HOOK_SHIM, commandRoot);
|
|
95
|
+
}
|
|
96
|
+
|
|
79
97
|
/**
|
|
80
98
|
* The guidance hook's `SessionStart` groups, resolved the same way. This is the
|
|
81
99
|
* channel that replaces `--append-system-prompt` where no launch supplies one:
|
|
@@ -90,39 +108,53 @@ export function mateGuidanceHookGroups(
|
|
|
90
108
|
|
|
91
109
|
/**
|
|
92
110
|
* The banner's `SessionStart` group, resolved the same way and carrying
|
|
93
|
-
* `
|
|
111
|
+
* `PROJECTED_FLAG`. Without the marker the carried command would be
|
|
94
112
|
* byte-identical to the plugin's, and a managed session — which loads both —
|
|
95
113
|
* would print the banner twice.
|
|
96
114
|
*/
|
|
97
115
|
export function mateBannerHookGroups(
|
|
98
116
|
commandRoot: string = runtimeClaudePluginRoot(),
|
|
99
117
|
): ClaudeHookGroup[] {
|
|
100
|
-
return groupsFor("SessionStart", BANNER_HOOK_SHIM, commandRoot)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
118
|
+
return withProjectedFlag(groupsFor("SessionStart", BANNER_HOOK_SHIM, commandRoot));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function withProjectedFlag(groups: ClaudeHookGroup[]): ClaudeHookGroup[] {
|
|
122
|
+
return groups.map((group) => mapCommands(group, (command) => `${command} ${PROJECTED_FLAG}`));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The `SubagentStart` instruction group, resolved the same way and carrying
|
|
127
|
+
* `PROJECTED_FLAG`: a session that loads both this copy and the plugin's,
|
|
128
|
+
* through a launch or `--plugin-dir`, would otherwise deliver the instructions
|
|
129
|
+
* twice.
|
|
130
|
+
*/
|
|
131
|
+
export function mateInstructionHookGroups(
|
|
132
|
+
commandRoot: string = runtimeClaudePluginRoot(),
|
|
133
|
+
): ClaudeHookGroup[] {
|
|
134
|
+
return withProjectedFlag(groupsFor("SubagentStart", INSTRUCTIONS_HOOK_SHIM, commandRoot));
|
|
107
135
|
}
|
|
108
136
|
|
|
109
137
|
/**
|
|
110
138
|
* The session-prepare `SessionStart` group, resolved the same way. Its declared
|
|
111
139
|
* `timeout` sits above the shim's own bound, so Claude Code never kills a
|
|
112
|
-
* prepare the shim has not given up on.
|
|
140
|
+
* prepare the shim has not given up on. It carries `PROJECTED_FLAG`: this copy
|
|
141
|
+
* alone prepares, which it skips under a launch environment, and then delivers
|
|
142
|
+
* the main thread's instructions; the plugin's copy stays inert.
|
|
113
143
|
*/
|
|
114
144
|
export function mateSessionPrepareHookGroups(
|
|
115
145
|
commandRoot: string = runtimeClaudePluginRoot(),
|
|
116
146
|
): ClaudeHookGroup[] {
|
|
117
|
-
return groupsFor("SessionStart", PREPARE_HOOK_SHIM, commandRoot);
|
|
147
|
+
return withProjectedFlag(groupsFor("SessionStart", PREPARE_HOOK_SHIM, commandRoot));
|
|
118
148
|
}
|
|
119
149
|
|
|
120
150
|
function mateOwnHookGroups(commandRoot: string): ClaudeHookGroup[] {
|
|
121
151
|
return [
|
|
122
152
|
...mateGuardHookGroups(commandRoot),
|
|
153
|
+
...mateTokensaveRouteHookGroups(commandRoot),
|
|
123
154
|
...mateGuidanceHookGroups(commandRoot),
|
|
124
155
|
...mateBannerHookGroups(commandRoot),
|
|
125
156
|
...mateSessionPrepareHookGroups(commandRoot),
|
|
157
|
+
...mateInstructionHookGroups(commandRoot),
|
|
126
158
|
];
|
|
127
159
|
}
|
|
128
160
|
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
|
|
6
|
+
import { gitEnvironment } from "../../../runtime/companion-git";
|
|
7
|
+
import { CLAUDE_SETTINGS_DOCUMENT } from "../../../runtime/runtime-document-manifest";
|
|
8
|
+
import type { WrappedClaudePlugin } from "../../../runtime/wrap-state";
|
|
9
|
+
|
|
10
|
+
const execFileAsync = promisify(execFile);
|
|
11
|
+
|
|
12
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
13
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Git lists the original Checkout first when it can identify it. */
|
|
17
|
+
async function originalCheckout(repoPath: string): Promise<string | undefined> {
|
|
18
|
+
try {
|
|
19
|
+
const { stdout } = await execFileAsync("git", ["worktree", "list", "--porcelain", "-z"], {
|
|
20
|
+
cwd: repoPath,
|
|
21
|
+
env: gitEnvironment(),
|
|
22
|
+
timeout: 3000,
|
|
23
|
+
maxBuffer: 1024 * 1024,
|
|
24
|
+
});
|
|
25
|
+
const first = stdout.split("\0\0", 1)[0]?.split("\0") ?? [];
|
|
26
|
+
if (!first[0]?.startsWith("worktree ") || first.includes("bare")) return undefined;
|
|
27
|
+
const original = first[0].slice("worktree ".length);
|
|
28
|
+
const dotGit = await fs.stat(path.join(original, ".git")).catch(() => undefined);
|
|
29
|
+
if (!dotGit || (!dotGit.isFile() && !dotGit.isDirectory())) return undefined;
|
|
30
|
+
return (await sameDirectory(original, repoPath)) ? undefined : original;
|
|
31
|
+
} catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function readSettings(repoPath: string): Promise<Record<string, unknown> | undefined> {
|
|
37
|
+
try {
|
|
38
|
+
const value = JSON.parse(
|
|
39
|
+
await fs.readFile(path.join(repoPath, CLAUDE_SETTINGS_DOCUMENT), "utf8"),
|
|
40
|
+
) as unknown;
|
|
41
|
+
return isRecord(value) ? value : undefined;
|
|
42
|
+
} catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function sameDirectory(first: string, second: string): Promise<boolean> {
|
|
48
|
+
if (path.resolve(first) === path.resolve(second)) return true;
|
|
49
|
+
try {
|
|
50
|
+
const [firstReal, secondReal] = await Promise.all([fs.realpath(first), fs.realpath(second)]);
|
|
51
|
+
return firstReal === secondReal;
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function marketplaceSource(settings: Record<string, unknown>, name: string): unknown {
|
|
58
|
+
const marketplaces = settings.extraKnownMarketplaces;
|
|
59
|
+
const entry = isRecord(marketplaces) ? marketplaces[name] : undefined;
|
|
60
|
+
return isRecord(entry) ? entry.source : undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The absolute folder of a `directory` marketplace source; any other source has none. */
|
|
64
|
+
function directoryPath(source: unknown): string | undefined {
|
|
65
|
+
return isRecord(source) &&
|
|
66
|
+
source.source === "directory" &&
|
|
67
|
+
typeof source.path === "string" &&
|
|
68
|
+
path.isAbsolute(source.path)
|
|
69
|
+
? source.path
|
|
70
|
+
: undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Only a recorded plugin enabled in both Checkouts can be redirected. A missing,
|
|
75
|
+
* unreadable or ambiguous setting keeps the Wrap's existing delivery decision.
|
|
76
|
+
*/
|
|
77
|
+
export async function worktreePluginSourceConflicts(
|
|
78
|
+
repoPath: string,
|
|
79
|
+
carried: readonly WrappedClaudePlugin[],
|
|
80
|
+
): Promise<string[]> {
|
|
81
|
+
if (carried.length === 0) return [];
|
|
82
|
+
const original = await originalCheckout(repoPath);
|
|
83
|
+
if (!original) return [];
|
|
84
|
+
const [mainSettings, worktreeSettings] = await Promise.all([
|
|
85
|
+
readSettings(original),
|
|
86
|
+
readSettings(repoPath),
|
|
87
|
+
]);
|
|
88
|
+
if (!mainSettings || !worktreeSettings) return [];
|
|
89
|
+
const mainEnabled = mainSettings.enabledPlugins;
|
|
90
|
+
const worktreeEnabled = worktreeSettings.enabledPlugins;
|
|
91
|
+
if (!isRecord(mainEnabled) || !isRecord(worktreeEnabled)) return [];
|
|
92
|
+
|
|
93
|
+
const disabled = new Set(
|
|
94
|
+
carried
|
|
95
|
+
.filter(({ id }) => mainEnabled[id] === false || worktreeEnabled[id] === false)
|
|
96
|
+
.map(({ directory }) => path.resolve(directory)),
|
|
97
|
+
);
|
|
98
|
+
const conflicts = await Promise.all(
|
|
99
|
+
carried.map(async (plugin) => {
|
|
100
|
+
const enabledInBoth = mainEnabled[plugin.id] === true && worktreeEnabled[plugin.id] === true;
|
|
101
|
+
if (!enabledInBoth || disabled.has(path.resolve(plugin.directory))) return undefined;
|
|
102
|
+
|
|
103
|
+
const worktreeDirectory = directoryPath(
|
|
104
|
+
marketplaceSource(worktreeSettings, plugin.marketplace),
|
|
105
|
+
);
|
|
106
|
+
if (!worktreeDirectory || !(await sameDirectory(worktreeDirectory, plugin.directory))) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const mainSource = marketplaceSource(mainSettings, plugin.marketplace);
|
|
111
|
+
if (!isRecord(mainSource) || typeof mainSource.source !== "string") return undefined;
|
|
112
|
+
if (mainSource.source !== "directory") return plugin.directory;
|
|
113
|
+
const mainDirectory = directoryPath(mainSource);
|
|
114
|
+
return mainDirectory && !(await sameDirectory(mainDirectory, worktreeDirectory))
|
|
115
|
+
? plugin.directory
|
|
116
|
+
: undefined;
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
119
|
+
return [
|
|
120
|
+
...new Set(conflicts.filter((directory): directory is string => directory !== undefined)),
|
|
121
|
+
];
|
|
122
|
+
}
|
|
@@ -4,6 +4,17 @@ import path from "node:path";
|
|
|
4
4
|
|
|
5
5
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
6
6
|
import type { FrameworkConfig } from "../../../lib/orchestrator/types";
|
|
7
|
+
import { getClaudePluginRoot } from "../../../lib/package-paths";
|
|
8
|
+
import { writeAtomicThroughLink } from "../../../runtime/write-atomic";
|
|
9
|
+
import { resolveSecretPolicy } from "../../../runtime/policy";
|
|
10
|
+
import {
|
|
11
|
+
CLAUDE_LOCAL_CONFIG_DOCUMENT,
|
|
12
|
+
CLAUDE_SETTINGS_DOCUMENT,
|
|
13
|
+
renderedDocument,
|
|
14
|
+
type ManagedRegion,
|
|
15
|
+
type RenderedRuntimeDocuments,
|
|
16
|
+
} from "../../../runtime/runtime-document-manifest";
|
|
17
|
+
import { projectableSecretDenyPatterns } from "../../../runtime/secret-patterns";
|
|
7
18
|
import { refreshFromTemplate, stripGuidanceBlock } from "../plugins/guidance";
|
|
8
19
|
import {
|
|
9
20
|
instructionBlockKey,
|
|
@@ -11,9 +22,19 @@ import {
|
|
|
11
22
|
upsertManagedBlock,
|
|
12
23
|
} from "../context-services";
|
|
13
24
|
import type { CapabilityContributionInput, ProviderPlugin, SetupContext } from "../plugin";
|
|
14
|
-
import { surfaceRoot } from "../surface-target";
|
|
25
|
+
import { projectionRepoRoot, surfaceRoot } from "../surface-target";
|
|
15
26
|
import { mergeDir, pruneEmptyAncestors } from "../utils";
|
|
16
27
|
import { stripSectionFromFile, type RemoveHeadingSectionOptions } from "./agent-file-sections";
|
|
28
|
+
import {
|
|
29
|
+
claudeUserConfigDir,
|
|
30
|
+
definesUserClaudeAttribution,
|
|
31
|
+
isManagedClaudeAttribution,
|
|
32
|
+
MANAGED_CLAUDE_ATTRIBUTION,
|
|
33
|
+
} from "./claude-attribution";
|
|
34
|
+
import {
|
|
35
|
+
inspectClaudePluginFolders,
|
|
36
|
+
type PublishedClaudePluginFolder,
|
|
37
|
+
} from "./claude-plugin-folders";
|
|
17
38
|
import { patchSkillTreeMarkdownFiles } from "./skill-tree";
|
|
18
39
|
import {
|
|
19
40
|
filterClaudeHookGroups,
|
|
@@ -28,6 +49,14 @@ import {
|
|
|
28
49
|
type ClaudeHookGroup,
|
|
29
50
|
type ClaudeSettings,
|
|
30
51
|
} from "./claude-format";
|
|
52
|
+
import {
|
|
53
|
+
mateBannerHookGroups,
|
|
54
|
+
mateGuardHookGroups,
|
|
55
|
+
mateGuidanceHookGroups,
|
|
56
|
+
mateInstructionHookGroups,
|
|
57
|
+
mateSessionPrepareHookGroups,
|
|
58
|
+
mateTokensaveRouteHookGroups,
|
|
59
|
+
} from "./claude-plugin-hooks";
|
|
31
60
|
import { getSetupRootTemplates } from "./utils";
|
|
32
61
|
|
|
33
62
|
async function configureClaudeGuidance(companionPath: string): Promise<void> {
|
|
@@ -106,6 +135,59 @@ function getAllManagedPermissionEntries(companionPath: string): Set<string> {
|
|
|
106
135
|
]);
|
|
107
136
|
}
|
|
108
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Claude Code features Mate turns off because they compete with its own
|
|
140
|
+
* workflow: plan mode writes plans outside the Companion Repository, the
|
|
141
|
+
* Artifact tool competes with `mate report`, DesignSync has no role in a
|
|
142
|
+
* Mate session, and SendFeedback drafts reports about Claude Code, not the
|
|
143
|
+
* session's work. `ExitPlanMode` stays allowed so a user who enters plan mode
|
|
144
|
+
* by hand can still leave it. Fixed, not configurable.
|
|
145
|
+
*/
|
|
146
|
+
export const MANAGED_CLAUDE_DENY_ENTRIES: readonly string[] = [
|
|
147
|
+
"EnterPlanMode",
|
|
148
|
+
"DesignSync",
|
|
149
|
+
"SendFeedback",
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
const SECRET_DENY_TOOLS = ["Read", "Edit"] as const;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Claude deny rules for the default secret files, at any depth. Claude checks
|
|
156
|
+
* deny before allow, so only patterns that can't match an allow-listed file are
|
|
157
|
+
* rendered; the hook enforces the rest of the pattern set. Claude applies
|
|
158
|
+
* `Edit(...)` rules to every built-in file-editing tool, `Write` included, so
|
|
159
|
+
* no `Write(...)` rule is rendered: Claude never matches one and warns about it.
|
|
160
|
+
*/
|
|
161
|
+
export function renderSecretDenyEntries(): string[] {
|
|
162
|
+
return projectableSecretDenyPatterns().flatMap((pattern) =>
|
|
163
|
+
SECRET_DENY_TOOLS.map((tool) => `${tool}(**/${pattern})`),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** The managed `permissions.deny` list: fixed tool denies, plus secret files while guardrails are on. */
|
|
168
|
+
function renderManagedClaudeDenyEntries(companionPath: string): string[] {
|
|
169
|
+
return [
|
|
170
|
+
...MANAGED_CLAUDE_DENY_ENTRIES,
|
|
171
|
+
...(resolveSecretPolicy(companionPath).guardrails ? renderSecretDenyEntries() : []),
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Every deny entry Mate may have written, whatever the current config says, so
|
|
177
|
+
* an opt-out strips the secret entries instead of keeping them as user entries.
|
|
178
|
+
*/
|
|
179
|
+
function getAllManagedDenyEntries(): Set<string> {
|
|
180
|
+
return new Set([
|
|
181
|
+
...MANAGED_CLAUDE_DENY_ENTRIES,
|
|
182
|
+
...renderSecretDenyEntries(),
|
|
183
|
+
// Legacy secret entries: Claude Code never matched Write() rules for file
|
|
184
|
+
// permission checks and warns about them, so setup no longer emits them.
|
|
185
|
+
// Keep them managed so re-running setup strips them from existing installs.
|
|
186
|
+
...projectableSecretDenyPatterns().map((pattern) => `Write(**/${pattern})`),
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
const MANAGED_CLAUDE_FORCED_SETTINGS = { enableArtifact: false } as const;
|
|
190
|
+
|
|
109
191
|
/** Companion-owned Claude settings: sole source of Mate-managed hooks, permissions and MCP servers. */
|
|
110
192
|
export function getCompanionClaudeSettingsPath(companionPath: string): string {
|
|
111
193
|
return path.join(companionPath, ".claude", "settings.local.json");
|
|
@@ -121,7 +203,7 @@ export function getCompanionClaudeMcpConfigPath(companionPath: string): string {
|
|
|
121
203
|
* Rendered separately from the settings document so a working-target pass can
|
|
122
204
|
* obtain them without a write.
|
|
123
205
|
*/
|
|
124
|
-
|
|
206
|
+
function renderManagedClaudePermissionEntries(
|
|
125
207
|
companionPath: string,
|
|
126
208
|
contributions: CapabilityContributionInput[] = [],
|
|
127
209
|
): string[] {
|
|
@@ -134,7 +216,7 @@ export function renderManagedClaudePermissionEntries(
|
|
|
134
216
|
}
|
|
135
217
|
|
|
136
218
|
/** The Mate-managed `.mcp.json` server map of one pass, as a value. */
|
|
137
|
-
|
|
219
|
+
function renderManagedClaudeMcpServers(
|
|
138
220
|
contributions: CapabilityContributionInput[] = [],
|
|
139
221
|
): Record<string, unknown> {
|
|
140
222
|
const servers: Record<string, unknown> = {};
|
|
@@ -151,7 +233,7 @@ export function renderManagedClaudeMcpServers(
|
|
|
151
233
|
* Enabled Capabilities' Claude hook groups per event, in declared order, as a
|
|
152
234
|
* value: what a Claude wrap carries into the Working Repository.
|
|
153
235
|
*/
|
|
154
|
-
|
|
236
|
+
function renderManagedClaudeHookGroups(
|
|
155
237
|
contributions: CapabilityContributionInput[] = [],
|
|
156
238
|
): Record<string, ClaudeHookGroup[]> {
|
|
157
239
|
const hooks: Record<string, ClaudeHookGroup[]> = {};
|
|
@@ -173,6 +255,7 @@ function renderManagedClaudeSettings(
|
|
|
173
255
|
companionPath: string,
|
|
174
256
|
config: FrameworkConfig,
|
|
175
257
|
contributions: CapabilityContributionInput[] = [],
|
|
258
|
+
userDefinesAttribution: boolean,
|
|
176
259
|
): ClaudeSettings {
|
|
177
260
|
// Declared markers and permission entries widen the managed strip set for
|
|
178
261
|
// every registered Capability, enabled or not, so deselection tears down.
|
|
@@ -221,6 +304,13 @@ function renderManagedClaudeSettings(
|
|
|
221
304
|
} else {
|
|
222
305
|
delete permissions.allow;
|
|
223
306
|
}
|
|
307
|
+
// permissions.deny: same reconciliation as allow, against the fixed set.
|
|
308
|
+
const managedDeny = getAllManagedDenyEntries();
|
|
309
|
+
const existingDeny = Array.isArray(existingPermissions.deny) ? existingPermissions.deny : [];
|
|
310
|
+
permissions.deny = [
|
|
311
|
+
...existingDeny.filter((entry) => !managedDeny.has(entry)),
|
|
312
|
+
...renderManagedClaudeDenyEntries(companionPath),
|
|
313
|
+
];
|
|
224
314
|
|
|
225
315
|
const mcpServers = { ...existing.mcpServers };
|
|
226
316
|
// tokensave (and any future Mate-managed MCP server) now lives in the
|
|
@@ -228,7 +318,12 @@ function renderManagedClaudeSettings(
|
|
|
228
318
|
// entry is removed so it cannot shadow the `.mcp.json` definition.
|
|
229
319
|
delete mcpServers.tokensave;
|
|
230
320
|
|
|
231
|
-
const settings: ClaudeSettings = {
|
|
321
|
+
const settings: ClaudeSettings = {
|
|
322
|
+
...existing,
|
|
323
|
+
hooks,
|
|
324
|
+
autoMemoryEnabled: false,
|
|
325
|
+
...MANAGED_CLAUDE_FORCED_SETTINGS,
|
|
326
|
+
};
|
|
232
327
|
if (Object.keys(hooks).length === 0) {
|
|
233
328
|
delete settings.hooks;
|
|
234
329
|
}
|
|
@@ -242,10 +337,190 @@ function renderManagedClaudeSettings(
|
|
|
242
337
|
} else {
|
|
243
338
|
delete settings.mcpServers;
|
|
244
339
|
}
|
|
340
|
+
/** The document's own value is kept; Mate's yields to one the user scope sets. */
|
|
341
|
+
if (!("attribution" in existing) || isManagedClaudeAttribution(existing.attribution)) {
|
|
342
|
+
if (userDefinesAttribution) delete settings.attribution;
|
|
343
|
+
else settings.attribution = { ...MANAGED_CLAUDE_ATTRIBUTION };
|
|
344
|
+
}
|
|
245
345
|
|
|
246
346
|
return settings;
|
|
247
347
|
}
|
|
248
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Loaded by a managed session beside the launch's plugin, so each Mate hook
|
|
351
|
+
* here runs twice there: the guard and tokensave routing are input-pure, guidance yields under a
|
|
352
|
+
* launch env, and the banner, prepare and instruction copies carry
|
|
353
|
+
* `--projected`, so one copy of each acts. Capability groups run once: the
|
|
354
|
+
* launch omits them from `--settings`.
|
|
355
|
+
*
|
|
356
|
+
* `permissions.additionalDirectories` grants companion file access only; it
|
|
357
|
+
* loads no `CLAUDE.md`.
|
|
358
|
+
*
|
|
359
|
+
* Unlike {@link renderManagedClaudeSettings}, this carries no
|
|
360
|
+
* `autoMemoryEnabled: false`. Whether a Wrap should leave the user's choice
|
|
361
|
+
* alone there is an open question, not settled policy.
|
|
362
|
+
*/
|
|
363
|
+
function claudeSettingsRegions(
|
|
364
|
+
ctx: SetupContext,
|
|
365
|
+
inputs: CapabilityContributionInput[],
|
|
366
|
+
repoRoot: string,
|
|
367
|
+
pluginFolders: readonly PublishedClaudePluginFolder[],
|
|
368
|
+
): ManagedRegion[] {
|
|
369
|
+
const capabilityHooks = renderManagedClaudeHookGroups(inputs);
|
|
370
|
+
const mateHooks: Record<string, unknown[]> = {
|
|
371
|
+
PreToolUse: [...mateGuardHookGroups(), ...mateTokensaveRouteHookGroups()],
|
|
372
|
+
SessionStart: [
|
|
373
|
+
...mateBannerHookGroups(),
|
|
374
|
+
...mateGuidanceHookGroups(),
|
|
375
|
+
...mateSessionPrepareHookGroups(),
|
|
376
|
+
],
|
|
377
|
+
SubagentStart: mateInstructionHookGroups(),
|
|
378
|
+
};
|
|
379
|
+
const events = [...new Set([...Object.keys(mateHooks), ...Object.keys(capabilityHooks)])];
|
|
380
|
+
return [
|
|
381
|
+
...events.map((event): ManagedRegion => ({
|
|
382
|
+
at: ["hooks", event],
|
|
383
|
+
kind: "list",
|
|
384
|
+
values: [...(mateHooks[event] ?? []), ...(capabilityHooks[event] ?? [])],
|
|
385
|
+
})),
|
|
386
|
+
/**
|
|
387
|
+
* `stripPrefix` heals a repository an older Mate wrapped. That version wrote
|
|
388
|
+
* the whole launch environment here, and Claude Code applies `env` to the
|
|
389
|
+
* session, so every hook in a bare session inherited `MATE_*` and read the
|
|
390
|
+
* repository as a Managed Session — silently, since looking managed is
|
|
391
|
+
* exactly what makes the guidance hook emit nothing. Guidance must be the
|
|
392
|
+
* projection's to give in an Unmanaged Session, so no `MATE_*` key may
|
|
393
|
+
* survive here. It sets no entry of its own: the
|
|
394
|
+
* `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD` an earlier wrap set is
|
|
395
|
+
* reverted from the manifest, so a user's own value stays.
|
|
396
|
+
*/
|
|
397
|
+
{
|
|
398
|
+
at: ["env"],
|
|
399
|
+
kind: "map",
|
|
400
|
+
entries: {},
|
|
401
|
+
stripPrefix: "MATE_",
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
at: ["permissions", "allow"],
|
|
405
|
+
kind: "list",
|
|
406
|
+
values: renderManagedClaudePermissionEntries(ctx.companionPath, inputs),
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
at: ["permissions", "deny"],
|
|
410
|
+
kind: "list",
|
|
411
|
+
values: renderManagedClaudeDenyEntries(ctx.companionPath),
|
|
412
|
+
},
|
|
413
|
+
...claudePluginRegions(pluginFolders),
|
|
414
|
+
/**
|
|
415
|
+
* Yields: the document is the user's, so their own `enableArtifact` wins,
|
|
416
|
+
* and unwrapping restores it instead of deleting a key Mate overwrote.
|
|
417
|
+
*/
|
|
418
|
+
...Object.entries(MANAGED_CLAUDE_FORCED_SETTINGS).map(([key, value]): ManagedRegion => ({
|
|
419
|
+
at: [key],
|
|
420
|
+
kind: "value",
|
|
421
|
+
value,
|
|
422
|
+
yields: true,
|
|
423
|
+
})),
|
|
424
|
+
/**
|
|
425
|
+
* Placed only while no scope sets attribution: a project-scope value would
|
|
426
|
+
* lose to this local one, yielding or not. Mate's own earlier value does
|
|
427
|
+
* not count as the user's.
|
|
428
|
+
*/
|
|
429
|
+
...(definesUserClaudeAttribution({ repoRoot })
|
|
430
|
+
? []
|
|
431
|
+
: [
|
|
432
|
+
{
|
|
433
|
+
at: ["attribution"],
|
|
434
|
+
kind: "value",
|
|
435
|
+
value: { ...MANAGED_CLAUDE_ATTRIBUTION },
|
|
436
|
+
yields: true,
|
|
437
|
+
} satisfies ManagedRegion,
|
|
438
|
+
]),
|
|
439
|
+
];
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Each published plugin folder as a local `directory` marketplace and its one
|
|
444
|
+
* enabled plugin, so a plain session in a trusted folder loads it in place. The
|
|
445
|
+
* path is the folder as the launch passes it, so the wrap state can name what
|
|
446
|
+
* the launch must leave to the wrap.
|
|
447
|
+
*/
|
|
448
|
+
function claudePluginRegions(published: readonly PublishedClaudePluginFolder[]): ManagedRegion[] {
|
|
449
|
+
return [
|
|
450
|
+
{
|
|
451
|
+
at: ["extraKnownMarketplaces"],
|
|
452
|
+
kind: "map",
|
|
453
|
+
entries: Object.fromEntries(
|
|
454
|
+
published.map(({ path: folder, marketplace }) => [
|
|
455
|
+
marketplace,
|
|
456
|
+
{ source: { source: "directory", path: folder } },
|
|
457
|
+
]),
|
|
458
|
+
),
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
at: ["enabledPlugins"],
|
|
462
|
+
kind: "map",
|
|
463
|
+
entries: Object.fromEntries(
|
|
464
|
+
published.map(({ plugin, marketplace }) => [`${plugin}@${marketplace}`, true]),
|
|
465
|
+
),
|
|
466
|
+
},
|
|
467
|
+
];
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* The working target's Claude documents, rendered as values. Each is a document
|
|
472
|
+
* the runtime finds by walking up from the current directory, and every path
|
|
473
|
+
* inside one still names the Companion Repository — only where the document is
|
|
474
|
+
* placed differs from the companion target.
|
|
475
|
+
*/
|
|
476
|
+
export async function renderClaudeWorkingDocuments(
|
|
477
|
+
ctx: SetupContext,
|
|
478
|
+
inputs: CapabilityContributionInput[],
|
|
479
|
+
): Promise<RenderedRuntimeDocuments> {
|
|
480
|
+
const repoRoot = projectionRepoRoot(ctx);
|
|
481
|
+
/** Reads the folders only; the pass published them before this render. */
|
|
482
|
+
const pluginFolders = (
|
|
483
|
+
await inspectClaudePluginFolders(inputs, { bundledPluginRoot: getClaudePluginRoot() })
|
|
484
|
+
).published;
|
|
485
|
+
return {
|
|
486
|
+
documents: [
|
|
487
|
+
...renderedDocument(
|
|
488
|
+
CLAUDE_SETTINGS_DOCUMENT,
|
|
489
|
+
claudeSettingsRegions(ctx, inputs, repoRoot, pluginFolders),
|
|
490
|
+
),
|
|
491
|
+
/**
|
|
492
|
+
* Local scope, not `.mcp.json`: a project-scoped server is inert until a
|
|
493
|
+
* human approves it in a session, which an Unmanaged Session is exactly the
|
|
494
|
+
* case that cannot rely on. The repo path is the key Claude Code files a
|
|
495
|
+
* project under, resolved so a symlinked working directory still matches.
|
|
496
|
+
*
|
|
497
|
+
* Confirmed against a real `~/.claude.json`: the keys there are the
|
|
498
|
+
* directories sessions started in, not repository roots — sibling
|
|
499
|
+
* directories of one checkout each hold their own entry, as do temporary
|
|
500
|
+
* directories. So this reaches exactly one session: the one started at the
|
|
501
|
+
* repository root. A session started in a subdirectory of a wrapped
|
|
502
|
+
* repository has its own key, finds no `mcpServers` under it, and sees none
|
|
503
|
+
* of these servers — the Unmanaged Session case this document exists for,
|
|
504
|
+
* missed. That limit is deliberate. The directories a session might start
|
|
505
|
+
* in are unbounded, and every one of them would be a fresh entry in the
|
|
506
|
+
* user's global configuration that nothing later reclaims; keying the
|
|
507
|
+
* repository root only keeps the projection's footprint there to a single
|
|
508
|
+
* key. A subdirectory session still gets the rest of the projection — the
|
|
509
|
+
* documents inside the repository are found by the runtime's own upward
|
|
510
|
+
* walk — it loses only the MCP servers.
|
|
511
|
+
*/
|
|
512
|
+
...renderedDocument(CLAUDE_LOCAL_CONFIG_DOCUMENT, [
|
|
513
|
+
{
|
|
514
|
+
at: ["projects", repoRoot, "mcpServers"],
|
|
515
|
+
kind: "map",
|
|
516
|
+
entries: renderManagedClaudeMcpServers(inputs),
|
|
517
|
+
},
|
|
518
|
+
]),
|
|
519
|
+
],
|
|
520
|
+
warnings: [],
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
249
524
|
// Write the Mate-managed Claude settings into the companion repo. This is the
|
|
250
525
|
// config surface Mate owns and loads at launch via `--settings`, so hooks,
|
|
251
526
|
// permissions, and MCP servers no longer need to live in the working repo.
|
|
@@ -253,10 +528,17 @@ export async function syncCompanionClaudeSettings(
|
|
|
253
528
|
companionPath: string,
|
|
254
529
|
config: FrameworkConfig,
|
|
255
530
|
contributions: CapabilityContributionInput[] = [],
|
|
531
|
+
env: Record<string, string | undefined> = process.env,
|
|
256
532
|
): Promise<void> {
|
|
257
533
|
const settingsPath = getCompanionClaudeSettingsPath(companionPath);
|
|
258
534
|
const existing = await readClaudeSettings(settingsPath);
|
|
259
|
-
const settings = renderManagedClaudeSettings(
|
|
535
|
+
const settings = renderManagedClaudeSettings(
|
|
536
|
+
existing,
|
|
537
|
+
companionPath,
|
|
538
|
+
config,
|
|
539
|
+
contributions,
|
|
540
|
+
definesUserClaudeAttribution({ userConfigDir: claudeUserConfigDir(env) }),
|
|
541
|
+
);
|
|
260
542
|
|
|
261
543
|
await writeClaudeSettings(settingsPath, settings);
|
|
262
544
|
|
|
@@ -395,7 +677,7 @@ async function configureClaude(companionPath: string): Promise<void> {
|
|
|
395
677
|
try {
|
|
396
678
|
await fs.access(agentsMdDest);
|
|
397
679
|
} catch {
|
|
398
|
-
await fs.
|
|
680
|
+
await writeAtomicThroughLink(agentsMdDest, await fs.readFile(agentsMdSrc));
|
|
399
681
|
}
|
|
400
682
|
|
|
401
683
|
const claudeMdSrc = path.join(getSetupRootTemplates(), "TEMPLATE_CLAUDE.md");
|
|
@@ -403,7 +685,7 @@ async function configureClaude(companionPath: string): Promise<void> {
|
|
|
403
685
|
try {
|
|
404
686
|
await fs.access(claudeMdDest);
|
|
405
687
|
} catch {
|
|
406
|
-
await fs.
|
|
688
|
+
await writeAtomicThroughLink(claudeMdDest, await fs.readFile(claudeMdSrc));
|
|
407
689
|
}
|
|
408
690
|
}
|
|
409
691
|
|