@uniqbit/mate-core 1.0.0-canary.0 → 1.0.0-canary.3
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/hooks.json +10 -1
- package/claude-plugin/hooks/tokensave-route.mjs +52 -0
- package/opencode-plugin/src/server.ts +4 -0
- package/opencode-plugin/src/tui.tsx +3 -1
- package/opencode-plugin/tui.tsx +4 -1
- package/package.json +45 -16
- package/src/brand/terminal.ts +5 -0
- package/src/cli/commands/artifact/apply-context.ts +275 -0
- package/src/cli/commands/artifact/artifact.ts +4 -0
- package/src/cli/commands/artifact/delivery/archive.ts +13 -5
- package/src/cli/commands/artifact/delivery/environment.ts +36 -13
- package/src/cli/commands/artifact/delivery/link.ts +35 -15
- package/src/cli/commands/artifact/delivery/output.ts +31 -0
- package/src/cli/commands/artifact/finish/command.ts +50 -5
- package/src/cli/commands/artifact/finish/engine.ts +44 -11
- package/src/cli/commands/artifact/finish/git.ts +132 -19
- package/src/cli/commands/artifact/finish/openspec.ts +6 -1
- package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
- package/src/cli/commands/cap/index-cmd.ts +64 -15
- 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 +16 -11
- 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 +74 -12
- package/src/cli/commands/doctor.ts +20 -5
- 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/report/index.ts +20 -1
- package/src/cli/commands/session/context.ts +102 -0
- package/src/cli/commands/setup.ts +44 -10
- package/src/cli/commands/studio/factory-credential.ts +49 -0
- package/src/cli/commands/studio/index.ts +29 -2
- package/src/cli/commands/studio/payload.ts +249 -15
- package/src/cli/commands/studio/routes.ts +41 -8
- package/src/cli/commands/studio/selection.ts +142 -16
- package/src/cli/commands/studio/server.ts +403 -364
- 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/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 +18 -0
- package/src/cli/parse-flags.ts +9 -1
- package/src/cli/repo-list-table.tsx +2 -0
- package/src/cli/setup-selector.tsx +79 -20
- package/src/cli/usage.ts +11 -1
- package/src/create-mate.ts +5 -4
- package/src/hooks/tokensave-route.ts +26 -0
- package/src/lib/apply-context/fingerprint.ts +174 -0
- package/src/lib/apply-context/protocol.ts +193 -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 +13 -11
- package/src/lib/delivery/archive-change.ts +14 -2
- package/src/lib/delivery/branches.ts +29 -5
- package/src/lib/delivery/environment.ts +7 -1
- package/src/lib/delivery/forge.ts +2 -2
- package/src/lib/delivery/merge-git.ts +261 -0
- package/src/lib/delivery/overlap.ts +11 -4
- package/src/lib/delivery/record-delivery.ts +97 -10
- package/src/lib/delivery/record.ts +67 -7
- package/src/lib/delivery/refresh.ts +104 -10
- package/src/lib/delivery/repository-access.ts +46 -2
- package/src/lib/delivery/resolve-branch.ts +162 -0
- package/src/lib/delivery/token.ts +7 -41
- 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/install.ts +66 -14
- package/src/lib/live-progress.ts +36 -0
- package/src/lib/member-choices.ts +67 -0
- package/src/lib/orchestrator/adapters/base.ts +55 -22
- package/src/lib/orchestrator/adapters/claude.ts +6 -1
- package/src/lib/orchestrator/config-store.ts +3 -2
- package/src/lib/orchestrator/editor.ts +29 -23
- package/src/lib/orchestrator/projection-entries.ts +56 -21
- 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-types.ts +33 -1
- package/src/lib/orchestrator/session-context-link.ts +67 -0
- package/src/lib/orchestrator/setup-compatibilities.ts +55 -12
- package/src/lib/orchestrator/types.ts +5 -0
- package/src/lib/orchestrator/working-repo-projection.ts +50 -7
- package/src/lib/orchestrator/workspace-document.ts +105 -0
- package/src/lib/package-paths.ts +29 -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 +45 -2
- package/src/opencode/enter-worktree.ts +72 -0
- package/src/opencode/tui.tsx +21 -26
- package/src/plugins.ts +1 -0
- package/src/runtime/claude-delivery-plan.ts +22 -5
- package/src/runtime/companion-git.ts +52 -10
- package/src/runtime/companion-guidance.ts +7 -7
- package/src/runtime/companion-lock.ts +30 -7
- package/src/runtime/env.ts +48 -3
- package/src/runtime/git-layout.ts +219 -0
- package/src/runtime/index.ts +24 -0
- package/src/runtime/physical-path.ts +111 -0
- package/src/runtime/policy.ts +36 -2
- package/src/runtime/runtime-directory.ts +5 -0
- package/src/runtime/secret-guard.ts +19 -5
- package/src/runtime/secret-patterns.ts +267 -34
- package/src/runtime/session-context.ts +98 -0
- package/src/runtime/tokensave-route.ts +152 -0
- package/src/runtime/wrap-state.ts +24 -16
- package/src/studio.ts +124 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +10 -8
- package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +16 -98
- package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +10 -2
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +76 -18
- 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 +2 -0
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +32 -5
- package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +8 -1
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +16 -1
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +22 -6
- package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +2 -0
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +8 -1
- 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 +7 -0
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +55 -50
- 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 +2 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +2 -0
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +29 -10
- package/src/templates/mate-skills/agents/mate-publish-artifact/references/openspec.md +4 -2
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +21 -0
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +13 -0
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +76 -18
- 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 +2 -0
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +32 -5
- package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +8 -1
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +16 -1
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +22 -6
- package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +2 -0
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +8 -1
- 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 +7 -0
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +55 -50
- 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 +2 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +2 -0
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +29 -10
- package/src/templates/mate-skills/claude/mate-publish-artifact/references/openspec.md +4 -2
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +21 -0
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +13 -0
- package/src/templates/mate-skills/openspec-references.ts +2 -0
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +364 -224
- package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
- package/src/tools/setup/capabilities/context-mode.ts +34 -5
- package/src/tools/setup/capabilities/graphify-secrets.ts +2 -14
- package/src/tools/setup/capabilities/graphify.ts +34 -7
- package/src/tools/setup/capabilities/openspec.ts +12 -2
- 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 +77 -68
- package/src/tools/setup/engine.ts +3 -2
- package/src/tools/setup/install-contract.ts +8 -0
- package/src/tools/setup/mate-skill-copies.ts +51 -0
- package/src/tools/setup/package-managers/uv.ts +73 -11
- package/src/tools/setup/plugin.ts +5 -0
- package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
- package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
- package/src/tools/setup/providers/claude.ts +11 -5
- package/src/tools/setup/utils.ts +4 -0
- 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 +57 -16
- 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/src/cli/commands/studio/client-asset.ts +0 -16
- package/src/cli/commands/studio/views/client.ts +0 -44
- 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 -102
- package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
- package/src/cli/commands/studio/views/document.tsx +0 -910
- package/src/cli/commands/studio/views/error.tsx +0 -20
- package/src/cli/commands/studio/views/markdown.tsx +0 -250
- package/src/cli/commands/studio/views/palette.ts +0 -134
- package/src/cli/commands/studio/views/reports/index.tsx +0 -44
- package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
- package/src/cli/commands/studio/views/skills/index.tsx +0 -68
- package/src/cli/commands/studio/views/specs/index.tsx +0 -149
- package/src/cli/commands/studio/views/studio-client/actions.ts +0 -51
- package/src/cli/commands/studio/views/studio-client/companion.ts +0 -13
- package/src/cli/commands/studio/views/studio-client/index.ts +0 -32
- package/src/cli/commands/studio/views/studio-client/keys.ts +0 -3
- package/src/cli/commands/studio/views/studio-client/main.ts +0 -3
- package/src/cli/commands/studio/views/studio-client/page.ts +0 -146
- package/src/cli/commands/studio/views/studio-client/panels.ts +0 -57
- package/src/cli/commands/studio/views/studio-client/reports.ts +0 -122
- package/src/cli/commands/studio/views/studio-client/theme.ts +0 -63
- package/src/cli/commands/studio/views/studio-client/vault-editor.ts +0 -166
- package/src/cli/commands/studio/views/studio-client/vault-pane.ts +0 -202
- package/src/cli/commands/studio/views/studio-client/vault-tree.ts +0 -258
- package/src/cli/commands/studio/views/studio-client.generated.ts +0 -2
- package/src/cli/commands/studio/views/styles.ts +0 -530
- package/src/cli/commands/studio/views/terminal.tsx +0 -484
- package/src/cli/commands/studio/views/vault/state.ts +0 -41
- package/src/cli/commands/studio/views/warnings.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/delivery-path.tsx +0 -370
- package/src/cli/commands/studio/views/workflow/graph.ts +0 -220
- package/src/cli/commands/studio/views/workflow/index.tsx +0 -20
- package/src/cli/commands/studio/views/workflow/steps.ts +0 -278
- package/src/lib/components/theme.ts +0 -2
- package/src/tools/setup/git-utils.ts +0 -30
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { runtimeClaudeCapabilityPluginsRoot } from "../../../runtime/runtime-directory";
|
|
4
|
+
import type { CapabilityPlugin, RuntimeContributionsByRuntime } from "../plugin";
|
|
5
|
+
|
|
6
|
+
const ID = "companion-mentions";
|
|
7
|
+
|
|
8
|
+
export function createCompanionMentionsPlugin(): CapabilityPlugin {
|
|
9
|
+
return {
|
|
10
|
+
id: ID,
|
|
11
|
+
kind: "capability",
|
|
12
|
+
label: "Companion Mentions",
|
|
13
|
+
description: "Find and attach companion files from Claude Code's @ menu as @mate:<path>.",
|
|
14
|
+
defaultSelected: false,
|
|
15
|
+
isEnabled: (config) => (config.capabilities ?? []).some((c) => c.name === ID),
|
|
16
|
+
// The wrap writes this path into settings.local.json, so it names the runtime link, never the install.
|
|
17
|
+
getRuntimeContributions(): RuntimeContributionsByRuntime {
|
|
18
|
+
return {
|
|
19
|
+
claude: {
|
|
20
|
+
pluginDirectories: [{ path: path.join(runtimeClaudeCapabilityPluginsRoot(), ID) }],
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
async apply() {},
|
|
25
|
+
async teardown() {},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -11,6 +11,10 @@ import {
|
|
|
11
11
|
isContextModePackageReference,
|
|
12
12
|
validateContextModePackage,
|
|
13
13
|
} from "../../../lib/context-mode-package";
|
|
14
|
+
import {
|
|
15
|
+
readMemberChoices as readStoredMemberChoices,
|
|
16
|
+
type MemberChoices,
|
|
17
|
+
} from "../../../lib/member-choices";
|
|
14
18
|
import { warmOpenCodePackageCache } from "../../../lib/opencode-plugin-package";
|
|
15
19
|
import { installedVersionAt, isPreinstalledPluginPath } from "../../../lib/preinstalled-plugins";
|
|
16
20
|
import { launchPassesClaudePluginFolders } from "../../../runtime/claude-delivery-plan";
|
|
@@ -29,6 +33,14 @@ interface ContextModePluginDeps {
|
|
|
29
33
|
installPackage?: typeof installContextModePackage;
|
|
30
34
|
validatePackage?: typeof validateContextModePackage;
|
|
31
35
|
warmOpenCodePackage?: typeof warmOpenCodePackageCache;
|
|
36
|
+
readMemberChoices?: (companionPath: string) => Promise<MemberChoices>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function isPackagePresent(companionPath: string): Promise<boolean> {
|
|
40
|
+
return fs.access(getContextModePackageRoot(companionPath)).then(
|
|
41
|
+
() => true,
|
|
42
|
+
() => false,
|
|
43
|
+
);
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
export const CONTEXT_MODE_OPENCODE_GUIDANCE = `## Context Mode
|
|
@@ -130,6 +142,16 @@ export function createContextModePlugin(deps: ContextModePluginDeps = {}): Capab
|
|
|
130
142
|
const installPackage = deps.installPackage ?? installContextModePackage;
|
|
131
143
|
const validatePackage = deps.validatePackage ?? validateContextModePackage;
|
|
132
144
|
const warmOpenCodePackage = deps.warmOpenCodePackage ?? warmOpenCodePackageCache;
|
|
145
|
+
const readMemberChoices = deps.readMemberChoices ?? readStoredMemberChoices;
|
|
146
|
+
/**
|
|
147
|
+
* The companion recommends Context Mode; the member decides whether its
|
|
148
|
+
* package is installed for them (`mate install`). Without the package and
|
|
149
|
+
* without the member having asked for it, this machine's sessions run
|
|
150
|
+
* without the Claude plugin rather than failing the launch.
|
|
151
|
+
*/
|
|
152
|
+
const isWiredForMember = async (companionPath: string): Promise<boolean> =>
|
|
153
|
+
(await isPackagePresent(companionPath)) ||
|
|
154
|
+
(await readMemberChoices(companionPath))["context-mode"] === "accepted";
|
|
133
155
|
return {
|
|
134
156
|
id: "context-mode",
|
|
135
157
|
kind: "capability",
|
|
@@ -142,7 +164,8 @@ export function createContextModePlugin(deps: ContextModePluginDeps = {}): Capab
|
|
|
142
164
|
* Every context-mode reference is Mate-managed; the installed package also
|
|
143
165
|
* supplies Claude's launch-only plugin.
|
|
144
166
|
*/
|
|
145
|
-
getRuntimeContributions(ctx): RuntimeContributionsByRuntime {
|
|
167
|
+
async getRuntimeContributions(ctx): Promise<RuntimeContributionsByRuntime> {
|
|
168
|
+
const wired = await isWiredForMember(ctx.companionPath);
|
|
146
169
|
return {
|
|
147
170
|
claude: {
|
|
148
171
|
// The context-mode Claude plugin exposes its skill and MCP tools
|
|
@@ -152,7 +175,7 @@ export function createContextModePlugin(deps: ContextModePluginDeps = {}): Capab
|
|
|
152
175
|
"Skill(context-mode:context-mode)",
|
|
153
176
|
"mcp__plugin_context-mode_context-mode__*",
|
|
154
177
|
],
|
|
155
|
-
pluginDirectories: [{ path: getContextModePackageRoot(ctx.companionPath) }],
|
|
178
|
+
pluginDirectories: wired ? [{ path: getContextModePackageRoot(ctx.companionPath) }] : [],
|
|
156
179
|
},
|
|
157
180
|
opencode: {
|
|
158
181
|
pluginReferences: [
|
|
@@ -182,6 +205,7 @@ export function createContextModePlugin(deps: ContextModePluginDeps = {}): Capab
|
|
|
182
205
|
label: "Context Mode package",
|
|
183
206
|
group: "companion",
|
|
184
207
|
source: "Context Mode capability",
|
|
208
|
+
recommendedBy: ["context-mode"],
|
|
185
209
|
command,
|
|
186
210
|
fingerprint: `context-mode:${command}`,
|
|
187
211
|
detect: () =>
|
|
@@ -197,9 +221,11 @@ export function createContextModePlugin(deps: ContextModePluginDeps = {}): Capab
|
|
|
197
221
|
const legacyInstallDir = getLegacyInstallDir(ctx.companionPath);
|
|
198
222
|
await fs.rm(legacyInstallDir, { recursive: true, force: true });
|
|
199
223
|
await pruneEmptyAncestors(path.dirname(legacyInstallDir), ctx.companionPath);
|
|
200
|
-
|
|
224
|
+
// Setup installs unless the member declined; then it behaves like sync.
|
|
225
|
+
const declined = (await readMemberChoices(ctx.companionPath))["context-mode"] === "declined";
|
|
226
|
+
if (ctx.mode === "setup" && !declined) {
|
|
201
227
|
await installPackage(ctx.companionPath);
|
|
202
|
-
} else {
|
|
228
|
+
} else if (await isWiredForMember(ctx.companionPath)) {
|
|
203
229
|
await validatePackage(ctx.companionPath);
|
|
204
230
|
}
|
|
205
231
|
await ctx.instructions?.append(CONTEXT_MODE_OPENCODE_GUIDANCE, {
|
|
@@ -214,7 +240,10 @@ export function createContextModePlugin(deps: ContextModePluginDeps = {}): Capab
|
|
|
214
240
|
},
|
|
215
241
|
forProvider: {
|
|
216
242
|
claude: {
|
|
217
|
-
preflight: (ctx) =>
|
|
243
|
+
preflight: async (ctx) =>
|
|
244
|
+
(await isWiredForMember(ctx.companionPath))
|
|
245
|
+
? validateClaudePackage(ctx, validatePackage)
|
|
246
|
+
: [],
|
|
218
247
|
async apply(ctx) {
|
|
219
248
|
await assertNoMcpConflict(ctx, "claude");
|
|
220
249
|
},
|
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
|
|
4
4
|
import { isSecretFile, type SecretPolicy } from "../../../runtime/secret-patterns";
|
|
5
5
|
import { scanContent, scanFiles } from "../../../runtime/secret-scan";
|
|
6
|
-
import {
|
|
6
|
+
import { addExcludeLine } from "../working-repo-local-state";
|
|
7
7
|
|
|
8
8
|
export const GRAPHIFY_IGNORE_FILE = ".graphifyignore";
|
|
9
9
|
const REGION_BEGIN = "# mate:secrets begin (managed by Mate; edits are overwritten)";
|
|
@@ -47,19 +47,7 @@ function endsWithRegion(content: string, region: string[]): boolean {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function excludeFromGit(repoPath: string): Promise<void> {
|
|
50
|
-
|
|
51
|
-
if (!excludePath) return;
|
|
52
|
-
let existing = "";
|
|
53
|
-
try {
|
|
54
|
-
existing = await fs.readFile(excludePath, "utf8");
|
|
55
|
-
} catch {
|
|
56
|
-
// Fresh repos may not have created info/exclude yet.
|
|
57
|
-
}
|
|
58
|
-
const entry = `/${GRAPHIFY_IGNORE_FILE}`;
|
|
59
|
-
if (existing.split(/\r?\n/).some((line) => line.trim() === entry)) return;
|
|
60
|
-
await fs.mkdir(path.dirname(excludePath), { recursive: true });
|
|
61
|
-
const separator = existing === "" || existing.endsWith("\n") ? "" : "\n";
|
|
62
|
-
await fs.writeFile(excludePath, `${existing}${separator}${entry}\n`, "utf8");
|
|
50
|
+
await addExcludeLine(repoPath, `/${GRAPHIFY_IGNORE_FILE}`);
|
|
63
51
|
}
|
|
64
52
|
|
|
65
53
|
/**
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
} from "../utils";
|
|
12
12
|
import { confirm } from "../../../cli/confirm";
|
|
13
13
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
14
|
-
import {
|
|
14
|
+
import { isDeclinedByMember, type ReadMemberChoices } from "../../../lib/member-choices";
|
|
15
|
+
import { getWrapperBinPath, withoutMateWrapperDirs } from "../../../lib/package-paths";
|
|
15
16
|
import { resolveSecretPolicy } from "../../../runtime/policy";
|
|
16
17
|
import { isInstalledViaUvTool } from "../package-managers/uv";
|
|
17
18
|
import { stripSectionFromFile } from "../providers/agent-file-sections";
|
|
@@ -119,7 +120,19 @@ function isMateManagedClaudeHookCommand(command: string): boolean {
|
|
|
119
120
|
return false;
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
// `graphify hook-guard read`, `"/abs/bin/graphify" hook-check`: the CLI hooks
|
|
124
|
+
// current graphifyy writes, by bare name or absolute path.
|
|
125
|
+
const GRAPHIFY_CLI_HOOK_COMMAND = /(?:^|[\s/\\"'])graphify(?:\.exe)?["']?\s+hook-/;
|
|
126
|
+
|
|
127
|
+
function isGraphifyCliHookGroup(entry: ClaudeHookGroup): boolean {
|
|
128
|
+
return (entry.hooks ?? []).some((hook) =>
|
|
129
|
+
GRAPHIFY_CLI_HOOK_COMMAND.test(hook.command?.trim() ?? ""),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Graphify's CLI hooks plus the script hooks older graphifyy wrote to `.claude/hooks/`. */
|
|
122
134
|
function isGraphifyClaudeHookGroup(entry: ClaudeHookGroup): boolean {
|
|
135
|
+
if (isGraphifyCliHookGroup(entry)) return true;
|
|
123
136
|
return (entry.hooks ?? []).some((hook) => {
|
|
124
137
|
const command = hook.command?.trim();
|
|
125
138
|
return command
|
|
@@ -141,6 +154,7 @@ export interface GraphifyPluginDeps {
|
|
|
141
154
|
isInstalledViaUvTool?: (pkgName: string) => boolean;
|
|
142
155
|
runCommand?: GraphifyRunCommand;
|
|
143
156
|
runProviderInstall?: GraphifyProviderInstall;
|
|
157
|
+
readMemberChoices?: ReadMemberChoices;
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
export function createGraphifyPlugin(deps: GraphifyPluginDeps = {}): CapabilityPlugin {
|
|
@@ -149,6 +163,10 @@ export function createGraphifyPlugin(deps: GraphifyPluginDeps = {}): CapabilityP
|
|
|
149
163
|
const checkUvTool = deps.isInstalledViaUvTool ?? isInstalledViaUvTool;
|
|
150
164
|
const runCommand = deps.runCommand ?? runShellCommand;
|
|
151
165
|
const runProviderInstall = deps.runProviderInstall ?? runCommandSilently;
|
|
166
|
+
// The real CLI only: Mate's own `graphify` wrapper is on a launch's PATH
|
|
167
|
+
// and fails without it.
|
|
168
|
+
const graphifyOnPath = () =>
|
|
169
|
+
checkPath("graphify", withoutMateWrapperDirs(process.env.PATH ?? ""));
|
|
152
170
|
|
|
153
171
|
return {
|
|
154
172
|
id: "graphify",
|
|
@@ -182,19 +200,24 @@ export function createGraphifyPlugin(deps: GraphifyPluginDeps = {}): CapabilityP
|
|
|
182
200
|
label: "Graphify CLI",
|
|
183
201
|
group: "companion",
|
|
184
202
|
source: "Graphify capability",
|
|
203
|
+
recommendedBy: ["graphify"],
|
|
185
204
|
command: GRAPHIFY_INSTALL_CMD,
|
|
186
205
|
fingerprint: `graphify:${GRAPHIFY_INSTALL_CMD}`,
|
|
187
|
-
detect: () =>
|
|
206
|
+
detect: () => graphifyOnPath() || checkUvTool("graphifyy"),
|
|
188
207
|
install: () => runCommand(GRAPHIFY_INSTALL_CMD),
|
|
189
|
-
verify: () =>
|
|
208
|
+
verify: () => graphifyOnPath() || checkUvTool("graphifyy"),
|
|
190
209
|
},
|
|
191
210
|
],
|
|
192
211
|
|
|
193
212
|
async apply(ctx: SetupContext) {
|
|
194
213
|
// binary: graphify (single y); package: graphifyy (double y)
|
|
195
|
-
const isInstalled =
|
|
214
|
+
const isInstalled = graphifyOnPath() || checkUvTool("graphifyy");
|
|
196
215
|
|
|
197
|
-
if (
|
|
216
|
+
if (
|
|
217
|
+
!isInstalled &&
|
|
218
|
+
ctx.mode === "setup" &&
|
|
219
|
+
!(await isDeclinedByMember(ctx.companionPath, ["graphify"], deps.readMemberChoices))
|
|
220
|
+
) {
|
|
198
221
|
process.stdout.write(`graphify binary not found. To install:\n ${GRAPHIFY_INSTALL_CMD}\n`);
|
|
199
222
|
const ok = await askConfirm("Run this install command now?");
|
|
200
223
|
if (ok) {
|
|
@@ -235,8 +258,7 @@ export function createGraphifyPlugin(deps: GraphifyPluginDeps = {}): CapabilityP
|
|
|
235
258
|
{
|
|
236
259
|
async apply(ctx: SetupContext) {
|
|
237
260
|
// Reconcile Graphify-managed provider assets from the companion root
|
|
238
|
-
const isInstalled =
|
|
239
|
-
checkPath("graphify", process.env.PATH ?? "") || checkUvTool("graphifyy");
|
|
261
|
+
const isInstalled = graphifyOnPath() || checkUvTool("graphifyy");
|
|
240
262
|
if (isInstalled) {
|
|
241
263
|
await runProviderInstall(
|
|
242
264
|
"graphify",
|
|
@@ -275,6 +297,11 @@ export function createGraphifyPlugin(deps: GraphifyPluginDeps = {}): CapabilityP
|
|
|
275
297
|
isGraphifyPluginReference,
|
|
276
298
|
);
|
|
277
299
|
}
|
|
300
|
+
} else if (providerId === "claude") {
|
|
301
|
+
// Hooks live in machine-local settings; without the CLI (never
|
|
302
|
+
// installed, declined, or removed) they would fail every tool call.
|
|
303
|
+
// Only graphify's own CLI hooks: unrelated `.claude/hooks/` scripts stay.
|
|
304
|
+
await removeClaudeHookGroupsWhere(ctx.companionPath, isGraphifyCliHookGroup);
|
|
278
305
|
}
|
|
279
306
|
|
|
280
307
|
// Redirect the freshly-installed skill's cwd-relative graphify-out/
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "../../../lib/openspec-cli";
|
|
12
12
|
import { getWrapperBinPath } from "../../../lib/package-paths";
|
|
13
13
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
14
|
+
import type { FrameworkConfig } from "../../../lib/orchestrator/types";
|
|
14
15
|
import { removeRecorded } from "../managed-output";
|
|
15
16
|
import type {
|
|
16
17
|
CapabilityPlugin,
|
|
@@ -21,6 +22,7 @@ import type {
|
|
|
21
22
|
import { mergeDir, pruneEmptyAncestors } from "../utils";
|
|
22
23
|
import { applyMateSkills, MATE_SKILLS, readSkillAuthor, teardownMateSkills } from "../mate";
|
|
23
24
|
import { getSharedSkillsDir, isSharedSkillRootActive } from "../providers/agents-skill-root";
|
|
25
|
+
import { skillIgnoreEntries } from "../mate-skill-copies";
|
|
24
26
|
|
|
25
27
|
export { MATE_SKILLS } from "../mate";
|
|
26
28
|
|
|
@@ -384,6 +386,10 @@ async function reconcileOpenSpecSchema(ctx: SetupContext): Promise<void> {
|
|
|
384
386
|
await ensureManagedOpenSpecConfig(ctx.companionPath);
|
|
385
387
|
}
|
|
386
388
|
|
|
389
|
+
function isOpenSpecEnabled(config: FrameworkConfig): boolean {
|
|
390
|
+
return (config.capabilities ?? []).some((c) => c.name === "openspec");
|
|
391
|
+
}
|
|
392
|
+
|
|
387
393
|
export function createOpenspecPlugin(deps: OpenSpecPluginDeps = {}): CapabilityPlugin {
|
|
388
394
|
const depsWithDefaults = {
|
|
389
395
|
runOpenSpec: deps.runOpenSpec ?? runOpenSpec,
|
|
@@ -397,7 +403,7 @@ export function createOpenspecPlugin(deps: OpenSpecPluginDeps = {}): CapabilityP
|
|
|
397
403
|
label: "OpenSpec",
|
|
398
404
|
description: "Route OpenSpec commands to the companion root and enable planning workflows.",
|
|
399
405
|
defaultSelected: true,
|
|
400
|
-
isEnabled:
|
|
406
|
+
isEnabled: isOpenSpecEnabled,
|
|
401
407
|
// Permission pre-seeds are declared and reconciled by the Claude Runtime
|
|
402
408
|
// Surface. Skill trees stay imperative on purpose: the workflow skills are
|
|
403
409
|
// written by the external `openspec` CLI (foreign trees), and the
|
|
@@ -416,7 +422,11 @@ export function createOpenspecPlugin(deps: OpenSpecPluginDeps = {}): CapabilityP
|
|
|
416
422
|
},
|
|
417
423
|
};
|
|
418
424
|
},
|
|
419
|
-
|
|
425
|
+
// Mate skill copies are regenerated on every sync, so only an enabled capability ignores them.
|
|
426
|
+
gitignoreEntries: (ctx) => [
|
|
427
|
+
...OPENSPEC_GITIGNORE_ENTRIES,
|
|
428
|
+
...(isOpenSpecEnabled(ctx.config) ? skillIgnoreEntries(MATE_SKILLS) : []),
|
|
429
|
+
],
|
|
420
430
|
persistGitignoreEntries: true,
|
|
421
431
|
async apply(ctx) {
|
|
422
432
|
// OpenSpec output is committed in the companion, so only setup and
|
|
@@ -3,8 +3,9 @@ import path from "node:path";
|
|
|
3
3
|
|
|
4
4
|
import { getReactDoctorBinPath } from "../../../lib/package-paths";
|
|
5
5
|
import type { CapabilityPlugin, RuntimeContributionsByRuntime, SetupContext } from "../plugin";
|
|
6
|
+
import { skillIgnoreEntries } from "../mate-skill-copies";
|
|
6
7
|
import { removeLegacyOpenCodeSkills, removeSharedSkills } from "../providers/agents-skill-root";
|
|
7
|
-
import { pruneEmptyAncestors } from "../utils";
|
|
8
|
+
import { mergeDir, pruneEmptyAncestors } from "../utils";
|
|
8
9
|
|
|
9
10
|
const SKILL_NAME = "mate-react-doctor";
|
|
10
11
|
// The upstream skill earlier releases installed under its own name.
|
|
@@ -15,6 +16,11 @@ const SKILL_SRC = path.join(
|
|
|
15
16
|
"../../../templates/capabilities/react-doctor/mate-react-doctor",
|
|
16
17
|
);
|
|
17
18
|
|
|
19
|
+
/** Writes the skill copy into `skillsDir`, as a provider sync does. */
|
|
20
|
+
export async function deployReactDoctorSkill(skillsDir: string): Promise<void> {
|
|
21
|
+
await mergeDir(SKILL_SRC, path.join(skillsDir, SKILL_NAME));
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
/** Removes the skill copies earlier releases installed under the upstream name. */
|
|
19
25
|
async function removeLegacySkills(companionPath: string): Promise<void> {
|
|
20
26
|
const claudeSkillsDir = path.join(companionPath, ".claude", "skills");
|
|
@@ -52,6 +58,7 @@ export function createReactDoctorPlugin(): CapabilityPlugin {
|
|
|
52
58
|
opencode: { skillTrees },
|
|
53
59
|
};
|
|
54
60
|
},
|
|
61
|
+
gitignoreEntries: () => skillIgnoreEntries([SKILL_NAME]),
|
|
55
62
|
async apply(ctx: SetupContext) {
|
|
56
63
|
await removeLegacySkills(ctx.companionPath);
|
|
57
64
|
},
|
|
@@ -2,6 +2,7 @@ import type { CapabilityPlugin, RuntimeContributionsByRuntime, SetupContext } fr
|
|
|
2
2
|
import type { InstallRequirement } from "../install-contract";
|
|
3
3
|
import { isCommandOnPath, runShellCommand, runShellCommandSilently } from "../utils";
|
|
4
4
|
import { confirm } from "../../../cli/confirm";
|
|
5
|
+
import { isDeclinedByMember, type ReadMemberChoices } from "../../../lib/member-choices";
|
|
5
6
|
|
|
6
7
|
const RTK_INSTALL_CMD_BREW = "brew install rtk-ai/tap/rtk";
|
|
7
8
|
const RTK_INSTALL_CMD_FALLBACK =
|
|
@@ -31,6 +32,7 @@ export type RtkDeps = {
|
|
|
31
32
|
isBrewAvailable?: () => boolean;
|
|
32
33
|
runRtkInstallCmd?: (cmd: string) => Promise<void>;
|
|
33
34
|
runRtkCommandSilently?: (cmd: string) => Promise<void>;
|
|
35
|
+
readMemberChoices?: ReadMemberChoices;
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
export function createRtkPlugin(deps: RtkDeps = {}): CapabilityPlugin {
|
|
@@ -63,6 +65,7 @@ export function createRtkPlugin(deps: RtkDeps = {}): CapabilityPlugin {
|
|
|
63
65
|
label: "RTK CLI",
|
|
64
66
|
group: "companion",
|
|
65
67
|
source: "RTK capability",
|
|
68
|
+
recommendedBy: ["rtk"],
|
|
66
69
|
command,
|
|
67
70
|
fingerprint: `rtk:${command}`,
|
|
68
71
|
detect: checkRtkPath,
|
|
@@ -73,6 +76,7 @@ export function createRtkPlugin(deps: RtkDeps = {}): CapabilityPlugin {
|
|
|
73
76
|
},
|
|
74
77
|
async apply(ctx) {
|
|
75
78
|
if (checkRtkPath() || ctx.mode !== "setup") return;
|
|
79
|
+
if (await isDeclinedByMember(ctx.companionPath, ["rtk"], deps.readMemberChoices)) return;
|
|
76
80
|
|
|
77
81
|
const command = checkBrew() ? RTK_INSTALL_CMD_BREW : RTK_INSTALL_CMD_FALLBACK;
|
|
78
82
|
process.stdout.write(`rtk binary not found. To install:\n ${command}\n`);
|
|
@@ -4,12 +4,15 @@ import fs from "node:fs/promises";
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
|
|
7
|
+
import { parse as parseJsonc } from "jsonc-parser";
|
|
8
|
+
|
|
9
|
+
import { isDeclinedByMember, readMemberChoices } from "../../../lib/member-choices";
|
|
7
10
|
import { resolveSecretPolicy } from "../../../runtime/policy";
|
|
8
11
|
import { DEFAULT_SECRET_DENY_PATTERNS, type SecretPolicy } from "../../../runtime/secret-patterns";
|
|
9
|
-
import { resolveGitInfoExcludePath } from "../git-utils";
|
|
10
12
|
import type { InstallRequirement } from "../install-contract";
|
|
11
13
|
import type { CapabilityPlugin, RuntimeContributionsByRuntime } from "../plugin";
|
|
12
14
|
import { isCommandOnPath, resolveCommandOnPath, runCommand, runShellCommand } from "../utils";
|
|
15
|
+
import { addExcludeLine } from "../working-repo-local-state";
|
|
13
16
|
import { TOKENSAVE_CLAUDE_MD_MARKER } from "./tokensave-shared";
|
|
14
17
|
export { TOKENSAVE_WORKING_REPO_EXCLUDE_ENTRIES } from "./tokensave-shared";
|
|
15
18
|
|
|
@@ -82,6 +85,10 @@ export const tokensaveDeps = {
|
|
|
82
85
|
homeDir(): string {
|
|
83
86
|
return os.homedir();
|
|
84
87
|
},
|
|
88
|
+
env(name: string): string | undefined {
|
|
89
|
+
return process.env[name];
|
|
90
|
+
},
|
|
91
|
+
readMemberChoices,
|
|
85
92
|
};
|
|
86
93
|
|
|
87
94
|
async function cleanupRepoLocalTokensaveArtifacts(repoPath: string): Promise<void> {
|
|
@@ -157,9 +164,12 @@ function installTokensaveAgentIntegrations(providers: string[], cwd: string): vo
|
|
|
157
164
|
}
|
|
158
165
|
}
|
|
159
166
|
|
|
167
|
+
/** JSONC-tolerant: agent configs may carry comments and trailing commas. */
|
|
160
168
|
async function readJsonObject(filePath: string): Promise<Record<string, unknown> | undefined> {
|
|
161
169
|
try {
|
|
162
|
-
const parsed: unknown =
|
|
170
|
+
const parsed: unknown = parseJsonc(await fs.readFile(filePath, "utf8"), [], {
|
|
171
|
+
allowTrailingComma: true,
|
|
172
|
+
});
|
|
163
173
|
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
|
|
164
174
|
? (parsed as Record<string, unknown>)
|
|
165
175
|
: undefined;
|
|
@@ -177,24 +187,35 @@ async function fileExists(filePath: string): Promise<boolean> {
|
|
|
177
187
|
}
|
|
178
188
|
}
|
|
179
189
|
|
|
190
|
+
/** Claude's global config dir, as tokensave resolves it. */
|
|
191
|
+
function claudeConfigDir(): string {
|
|
192
|
+
return tokensaveDeps.env("CLAUDE_CONFIG_DIR") || path.join(tokensaveDeps.homeDir(), ".claude");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** OpenCode's global config dir, as tokensave resolves it. */
|
|
196
|
+
function opencodeConfigDir(): string {
|
|
197
|
+
const xdg = tokensaveDeps.env("XDG_CONFIG_HOME");
|
|
198
|
+
return path.join(xdg || path.join(tokensaveDeps.homeDir(), ".config"), "opencode");
|
|
199
|
+
}
|
|
200
|
+
|
|
180
201
|
/**
|
|
181
202
|
* Read-only probe of the global files `tokensave install --agent <agent>` writes.
|
|
182
203
|
* tokensave's own permission check reads only these global files, never the
|
|
183
204
|
* companion-scoped settings Mate loads via `--settings`.
|
|
184
205
|
*/
|
|
185
206
|
export async function isTokensaveAgentIntegrated(agent: string): Promise<boolean> {
|
|
186
|
-
const home = tokensaveDeps.homeDir();
|
|
187
207
|
if (agent === "claude") {
|
|
188
|
-
const
|
|
208
|
+
const configDir = claudeConfigDir();
|
|
209
|
+
const settings = await readJsonObject(path.join(configDir, "settings.json"));
|
|
189
210
|
const allow = (settings?.permissions as { allow?: unknown } | undefined)?.allow;
|
|
190
211
|
return (
|
|
191
212
|
Array.isArray(allow) &&
|
|
192
213
|
allow.includes("mcp__tokensave__*") &&
|
|
193
|
-
(await fileExists(path.join(
|
|
214
|
+
(await fileExists(path.join(configDir, "rules", "tokensave.md")))
|
|
194
215
|
);
|
|
195
216
|
}
|
|
196
217
|
if (agent === "opencode") {
|
|
197
|
-
const configDir =
|
|
218
|
+
const configDir = opencodeConfigDir();
|
|
198
219
|
const config = await readJsonObject(path.join(configDir, "opencode.json"));
|
|
199
220
|
/**
|
|
200
221
|
* `tokensave install` writes the flat `mcp.<name>` entry, which OpenCode 2.x
|
|
@@ -298,30 +319,7 @@ export async function ensureTokensaveInstalled(
|
|
|
298
319
|
}
|
|
299
320
|
|
|
300
321
|
export async function ensureTokensaveStoreExcluded(repoPath: string): Promise<void> {
|
|
301
|
-
|
|
302
|
-
if (!excludePath) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
let existing = "";
|
|
307
|
-
try {
|
|
308
|
-
existing = await fs.readFile(excludePath, "utf8");
|
|
309
|
-
} catch {
|
|
310
|
-
// Fresh repos may not have created info/exclude yet.
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const lines = existing
|
|
314
|
-
.split(/\r?\n/)
|
|
315
|
-
.map((line) => line.trim())
|
|
316
|
-
.filter(Boolean);
|
|
317
|
-
|
|
318
|
-
if (lines.includes(TOKENSAVE_STORE_EXCLUDE_ENTRY)) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
lines.push(TOKENSAVE_STORE_EXCLUDE_ENTRY);
|
|
323
|
-
await fs.mkdir(path.dirname(excludePath), { recursive: true });
|
|
324
|
-
await fs.writeFile(excludePath, lines.join("\n") + "\n", "utf8");
|
|
322
|
+
await addExcludeLine(repoPath, TOKENSAVE_STORE_EXCLUDE_ENTRY);
|
|
325
323
|
}
|
|
326
324
|
|
|
327
325
|
/**
|
|
@@ -478,6 +476,7 @@ export function createTokensavePlugin(): CapabilityPlugin {
|
|
|
478
476
|
label: "TokenSave CLI",
|
|
479
477
|
group: "companion",
|
|
480
478
|
source: "TokenSave capability",
|
|
479
|
+
recommendedBy: ["tokensave"],
|
|
481
480
|
command: plan?.command ?? "cargo install tokensave",
|
|
482
481
|
fingerprint: `tokensave:${plan?.command ?? "manual"}`,
|
|
483
482
|
detect: () => tokensaveDeps.run(["--version"], process.cwd()).ok,
|
|
@@ -500,6 +499,7 @@ export function createTokensavePlugin(): CapabilityPlugin {
|
|
|
500
499
|
label: `TokenSave ${agent} integration`,
|
|
501
500
|
group: "companion",
|
|
502
501
|
source: "TokenSave capability",
|
|
502
|
+
recommendedBy: ["tokensave"],
|
|
503
503
|
command: `tokensave install --agent ${agent} --git-hook no --wildcard-permissions`,
|
|
504
504
|
fingerprint: `tokensave-agent:${agent}`,
|
|
505
505
|
detect: () => isTokensaveAgentIntegrated(agent),
|
|
@@ -522,37 +522,40 @@ export function createTokensavePlugin(): CapabilityPlugin {
|
|
|
522
522
|
getRuntimeContributions(): RuntimeContributionsByRuntime {
|
|
523
523
|
const mcpServers = [{ name: "tokensave", command: "tokensave", args: ["serve"] }];
|
|
524
524
|
// Hook commands pin the resolved binary path (hooks run without the
|
|
525
|
-
// launch environment's PATH guarantees).
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
525
|
+
// launch environment's PATH guarantees). Hooks live in the machine-local
|
|
526
|
+
// settings, so a member who has not installed TokenSave gets none rather
|
|
527
|
+
// than a failing hook on every tool call.
|
|
528
|
+
const tokensaveCommandPath = resolveCommandOnPath("tokensave", process.env.PATH ?? "");
|
|
529
|
+
const hookGroups = !tokensaveCommandPath
|
|
530
|
+
? []
|
|
531
|
+
: [
|
|
532
|
+
{
|
|
533
|
+
event: "PreToolUse",
|
|
534
|
+
marker: "tokensave",
|
|
535
|
+
group: {
|
|
536
|
+
matcher: "Agent|Grep|Bash",
|
|
537
|
+
hooks: [
|
|
538
|
+
{ type: "command", command: tokensaveCommandPath, args: ["hook-pre-tool-use"] },
|
|
539
|
+
],
|
|
540
|
+
},
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
event: "UserPromptSubmit",
|
|
544
|
+
marker: "tokensave",
|
|
545
|
+
group: {
|
|
546
|
+
hooks: [
|
|
547
|
+
{ type: "command", command: tokensaveCommandPath, args: ["hook-prompt-submit"] },
|
|
548
|
+
],
|
|
549
|
+
},
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
event: "Stop",
|
|
553
|
+
marker: "tokensave",
|
|
554
|
+
group: {
|
|
555
|
+
hooks: [{ type: "command", command: tokensaveCommandPath, args: ["hook-stop"] }],
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
];
|
|
556
559
|
return {
|
|
557
560
|
claude: { mcpServers, hookGroups, permissionEntries: ["mcp__tokensave__*"] },
|
|
558
561
|
opencode: { mcpServers },
|
|
@@ -565,13 +568,19 @@ export function createTokensavePlugin(): CapabilityPlugin {
|
|
|
565
568
|
if (ctx.activeProviders.filter((p) => TOKENSAVE_SUPPORTED_AGENTS.has(p)).length === 0) return;
|
|
566
569
|
|
|
567
570
|
const targetPath = ctx.repoPath ?? ctx.companionPath;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
571
|
+
// Installing is the member's choice (`mate install`); neither a launch
|
|
572
|
+
// sync nor setup for a member who declined installs TokenSave.
|
|
573
|
+
const mayInstall =
|
|
574
|
+
ctx.mode === "setup" &&
|
|
575
|
+
!(await isDeclinedByMember(
|
|
576
|
+
ctx.companionPath,
|
|
577
|
+
["tokensave"],
|
|
578
|
+
tokensaveDeps.readMemberChoices,
|
|
579
|
+
));
|
|
580
|
+
const installed = mayInstall
|
|
581
|
+
? await ensureTokensaveInstalled(targetPath, { upgrade: true })
|
|
582
|
+
: await tokensaveInstalled(targetPath);
|
|
583
|
+
if (!installed) return;
|
|
575
584
|
await ensureTokensaveBranchingPosture(targetPath, resolveSecretPolicy(ctx.companionPath));
|
|
576
585
|
if (ctx.mode === "setup") {
|
|
577
586
|
installTokensaveAgentIntegrations(ctx.activeProviders, targetPath);
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
} from "./providers/opencode";
|
|
26
26
|
import { normalizeRegistration, type NormalizedRegistration } from "./registry";
|
|
27
27
|
import { projectionRepoRoot } from "./surface-target";
|
|
28
|
+
import { emitWarning } from "../../lib/live-progress";
|
|
28
29
|
|
|
29
30
|
export interface SetupInstallationPlanAction {
|
|
30
31
|
phase: Plugin["kind"];
|
|
@@ -138,7 +139,7 @@ export async function executeSetupInstallationPlan(
|
|
|
138
139
|
assetOverrideRoots: distribution.config.assetRoots,
|
|
139
140
|
warn: (message) => {
|
|
140
141
|
warnings.push(message);
|
|
141
|
-
|
|
142
|
+
emitWarning(message);
|
|
142
143
|
},
|
|
143
144
|
});
|
|
144
145
|
|
|
@@ -166,7 +167,7 @@ export async function executeSetupInstallationPlan(
|
|
|
166
167
|
skippedActions.push(action);
|
|
167
168
|
const warning = `${action.pluginId} capability disabled: ${action.skipReason}`;
|
|
168
169
|
warnings.push(warning);
|
|
169
|
-
|
|
170
|
+
emitWarning(warning);
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
// Track every planned plugin so bookkeeping reconciles entries the plugin
|
|
@@ -14,6 +14,14 @@ export interface InstallRequirement {
|
|
|
14
14
|
source: string;
|
|
15
15
|
command: string;
|
|
16
16
|
fingerprint?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Capabilities that recommend this requirement instead of mandating it: the
|
|
19
|
+
* companion selects them for the team, each member decides whether the tool
|
|
20
|
+
* is installed for them. Active once the member accepts any of them (or the
|
|
21
|
+
* tool is already there); never installed by `--yes` alone. Absent means
|
|
22
|
+
* the requirement is mandatory.
|
|
23
|
+
*/
|
|
24
|
+
recommendedBy?: string[];
|
|
17
25
|
detect(): boolean | Promise<boolean>;
|
|
18
26
|
install(): Promise<void>;
|
|
19
27
|
verify?(): boolean | Promise<boolean>;
|