@uniqbit/mate-core 1.0.0-canary.6 → 1.0.0-canary.8
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/plugin.json +1 -1
- package/package.json +6 -3
- package/src/cli/commands/artifact/delivery/submit.ts +6 -4
- package/src/cli/commands/artifact/finish/command.ts +28 -11
- package/src/cli/commands/artifact/pending/command.ts +71 -7
- package/src/cli/commands/cap/tokensave.ts +2 -2
- package/src/cli/commands/companion/update.ts +2 -3
- package/src/cli/commands/doctor.ts +67 -4
- package/src/cli/commands/friction.ts +558 -0
- package/src/cli/commands/install.ts +8 -4
- package/src/cli/commands/plugin/install.ts +82 -35
- package/src/cli/commands/studio/connection.ts +53 -0
- package/src/cli/commands/studio/routes.ts +3 -0
- package/src/cli/commands/studio/selection.ts +10 -1
- package/src/cli/commands/studio/server.ts +31 -0
- package/src/cli/commands/studio/service-host.ts +3 -0
- package/src/cli/commands/studio/services.ts +25 -0
- package/src/cli/commands/triage.ts +172 -0
- package/src/cli/commands/vscode/release-vsix.json +2 -2
- package/src/cli/install-plan.tsx +3 -0
- package/src/cli/main.ts +85 -19
- package/src/cli/plugin-commands.ts +6 -1
- package/src/cli/usage.ts +12 -2
- package/src/create-mate.ts +11 -5
- package/src/distribution.ts +2 -0
- package/src/factory-host.ts +6 -0
- package/src/hooks/validate-artifact-path.ts +64 -14
- package/src/index.ts +1 -0
- package/src/lib/delivery/merge-git.ts +31 -7
- package/src/lib/delivery/overlap.ts +14 -1
- package/src/lib/delivery/repository-access.ts +11 -6
- package/src/lib/delivery/staging/apply-chain.ts +25 -7
- package/src/lib/delivery/staging/linked-merges.ts +175 -0
- package/src/lib/delivery/staging/naming.ts +3 -0
- package/src/lib/delivery/staging/openspec-type.ts +38 -7
- package/src/lib/delivery/staging/pending.ts +153 -11
- package/src/lib/delivery/staging/preflight.ts +239 -0
- package/src/lib/delivery/staging/project.ts +243 -104
- package/src/lib/delivery/staging/replay.ts +5 -3
- package/src/lib/delivery/staging/settle-linked.ts +5 -119
- package/src/lib/delivery/staging/submit.ts +139 -18
- package/src/lib/delivery/submit-change.ts +163 -37
- package/src/lib/friction/describe.ts +42 -0
- package/src/lib/friction/fields.ts +60 -0
- package/src/lib/friction/mark.ts +194 -0
- package/src/lib/friction/view/model.ts +67 -0
- package/src/lib/friction/view/read.ts +145 -0
- package/src/lib/friction/view/select.ts +54 -0
- package/src/lib/openspec-cli.ts +10 -5
- package/src/lib/orchestrator/adapters/claude.ts +5 -4
- package/src/lib/orchestrator/adapters/opencode.ts +2 -0
- package/src/lib/orchestrator/root-context.ts +23 -6
- package/src/lib/package-paths.ts +23 -15
- package/src/lib/session-attribution.ts +3 -7
- package/src/lib/skills-cli.ts +38 -0
- package/src/lib/tool-manifest.ts +73 -0
- package/src/lib/triage/context.ts +312 -0
- package/src/lib/triage/launch.ts +52 -0
- package/src/lib/triage/prepare.ts +112 -0
- package/src/lib/triage/session.ts +126 -0
- package/src/opencode/companion-hooks.ts +53 -5
- package/src/opencode/projected-guidance.ts +2 -0
- package/src/playbooks/companion-guidance.ts +2 -2
- package/src/plugin-api.ts +6 -0
- package/src/runtime/command-arg.ts +15 -0
- package/src/runtime/command-friction.ts +97 -0
- package/src/runtime/companion-guidance.ts +33 -16
- package/src/runtime/friction-fingerprint.ts +35 -0
- package/src/runtime/friction-log.ts +376 -0
- package/src/runtime/friction-recorder.ts +212 -0
- package/src/runtime/friction-retention.ts +1 -0
- package/src/runtime/friction-state.ts +110 -0
- package/src/runtime/friction-switch.ts +26 -0
- package/src/runtime/friction-vocabulary.ts +42 -0
- package/src/runtime/git-tracked.ts +13 -2
- package/src/runtime/projected-guidance.ts +2 -1
- package/src/runtime/secret-values.ts +16 -0
- package/src/runtime/session-id.ts +24 -0
- package/src/runtime/session-prepare-runner.ts +3 -0
- package/src/runtime/workflow/next-handoff-process.ts +2 -1
- package/src/studio.ts +47 -1
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +5 -1
- package/src/templates/capabilities/react-doctor/mate-react-doctor/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +42 -4
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +27 -2
- package/src/templates/mate-skills/agents/mate-backfill-spec/SKILL.md +23 -1
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +26 -1
- package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +28 -3
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +25 -0
- package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +28 -3
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +28 -6
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +27 -2
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +28 -0
- package/src/templates/mate-skills/agents/mate-submit-change/SKILL.md +24 -2
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +42 -4
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +27 -2
- package/src/templates/mate-skills/claude/mate-backfill-spec/SKILL.md +23 -1
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +26 -1
- package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +28 -3
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +25 -0
- package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +28 -3
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +28 -6
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +27 -2
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +28 -0
- package/src/templates/mate-skills/claude/mate-submit-change/SKILL.md +24 -2
- package/src/templates/triage/PLAYBOOK.md +120 -0
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +108 -108
- package/src/tools/setup/capabilities/graphify.ts +23 -1
- package/src/tools/setup/capabilities/rtk.ts +46 -94
- package/src/tools/setup/capabilities/tokensave.ts +76 -54
- package/src/tools/setup/dynamic-plugins/audiences.ts +28 -14
- package/src/tools/setup/dynamic-plugins/hydrate.ts +32 -14
- package/src/tools/setup/dynamic-plugins/install.ts +2 -0
- package/src/tools/setup/dynamic-plugins/installed.ts +73 -0
- package/src/tools/setup/dynamic-plugins/loader.ts +12 -10
- package/src/tools/setup/dynamic-plugins/local.ts +492 -0
- package/src/tools/setup/dynamic-plugins/paths.ts +34 -6
- package/src/tools/setup/dynamic-plugins/verify.ts +34 -14
- package/src/tools/setup/dynamic-plugins/workspaces.ts +17 -8
- package/src/tools/setup/mate.ts +26 -1
- package/src/tools/setup/plugin.ts +5 -0
- package/src/tools/setup/plugins/gitignore.ts +45 -12
- package/src/tools/setup/service.ts +12 -0
- package/src/tools/setup/utils.ts +10 -1
- package/src/tools/setup.ts +16 -2
- package/studio-dist/client/assets/app-ggXJ_QVh.css +2 -0
- package/studio-dist/client/assets/button-amJ3g5oD.js +1 -0
- package/studio-dist/client/assets/cn-BQPKiwI4.js +1 -0
- package/studio-dist/client/assets/combobox-CJ7aGFid.js +1 -0
- package/studio-dist/client/assets/{companion-view-BVaZNtiI.js → companion-view-C_N237bf.js} +1 -1
- package/studio-dist/client/assets/fields-BAiGkJ5N.js +1 -0
- package/studio-dist/client/assets/friction-DqOU59v7.js +1 -0
- package/studio-dist/client/assets/getting-started-djaQeWlu.js +1 -0
- package/studio-dist/client/assets/getting-started-yp42dj5S.js +1 -0
- package/studio-dist/client/assets/getting-started._topic-C9zVXz_m.js +1 -0
- package/studio-dist/client/assets/getting-started.index-DWbDKICP.js +1 -0
- package/studio-dist/client/assets/graph-BYaD_5Bq.js +2 -0
- package/studio-dist/client/assets/{graph-canvas-DDuzsNSx.js → graph-canvas-ySGKMhmk.js} +1 -1
- package/studio-dist/client/assets/guides-D6T6W_jV.js +1 -0
- package/studio-dist/client/assets/index-Qx7reRPD.js +40 -0
- package/studio-dist/client/assets/markdown-view-jMiaBTSO.js +1 -0
- package/studio-dist/client/assets/panel-C4bf_h2W.js +1 -0
- package/studio-dist/client/assets/plugins._service._view-y6f2FDAB.js +1 -0
- package/studio-dist/client/assets/prepaint-CKsXyJOR.js +27 -0
- package/studio-dist/client/assets/{queries-axYk2u9L.js → queries-Dfp5deWj.js} +1 -1
- package/studio-dist/client/assets/react-BYUSgtBs.js +1 -0
- package/studio-dist/client/assets/reports-JFSwSueq.js +1 -0
- package/studio-dist/client/assets/routes-BdOWSgzK.js +1 -0
- package/studio-dist/client/assets/search-CXosfvYh.js +1 -0
- package/studio-dist/client/assets/select-BHYYWPhK.js +1 -0
- package/studio-dist/client/assets/skills-Bo9FLsBd.js +1 -0
- package/studio-dist/client/assets/{specs-DU1kqcp5.js → specs-BrCOjOch.js} +1 -1
- package/studio-dist/client/assets/specs-view-CdE2rlli.js +1 -0
- package/studio-dist/client/assets/{steps-DhIFuAZy.js → steps-CKUno4lh.js} +1 -1
- package/studio-dist/client/assets/store-C3vJq8Wj.js +1 -0
- package/studio-dist/client/assets/{studio-BR9j15J0.js → studio-0ueISxwP.js} +8 -8
- package/studio-dist/client/assets/{studio-queries-CFP_yTpr.js → studio-queries-BflKt9va.js} +2 -2
- package/studio-dist/client/assets/{usage-CHmwtkoM.js → usage-BLsLy0nN.js} +16 -16
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-DC7f8GOp.js +1 -0
- package/studio-dist/client/assets/useMutation-uJUrejsi.js +1 -0
- package/studio-dist/client/assets/vault-BB1B_OhR.js +1 -0
- package/studio-dist/client/assets/warnings-CqOOGlPD.js +1 -0
- package/studio-dist/client/assets/workflow-BFzmI-06.js +1 -0
- package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-DAbZ6fzY.js → __23tanstack-start-server-fn-resolver-gVfW5vIV.js} +30 -14
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +66 -50
- package/studio-dist/server/assets/{button-BfoNadNR.js → button-D6bvrFmm.js} +226 -3478
- package/studio-dist/server/assets/cn-FXJAM0KO.js +5528 -0
- package/studio-dist/server/assets/combobox-D2MbYV1O.js +484 -0
- package/studio-dist/server/assets/{companion-view-DHUjPpA0.js → companion-view-Mf1ANbMb.js} +2 -2
- package/studio-dist/server/assets/{companions-kBrJZAd6.js → companions-Dr6IpNAb.js} +1 -1
- package/studio-dist/server/assets/{fields-BD_c65T1.js → fields-B4mAPETz.js} +2 -1
- package/studio-dist/server/assets/friction-9a5S1m7U.js +943 -0
- package/studio-dist/server/assets/friction-CWOTjpCV.js +62 -0
- package/studio-dist/server/assets/{getting-started-7P0oyWaM.js → getting-started-RU6tYU2Q.js} +2 -2
- package/studio-dist/server/assets/{getting-started._topic-B1mV0kGz.js → getting-started._topic-C02HGrC6.js} +2 -2
- package/studio-dist/server/assets/{getting-started.index-CeGtvUsm.js → getting-started.index-EzLRosbb.js} +2 -2
- package/studio-dist/server/assets/{graph-BWtmJOH2.js → graph-B11ITte0.js} +1 -1
- package/studio-dist/server/assets/{graph-DSDVEELZ.js → graph-CZ2H9Fzr.js} +8 -8
- package/studio-dist/server/assets/{graph-canvas-CID9Nksc.js → graph-canvas-rP5TT14Z.js} +2 -2
- package/studio-dist/server/assets/{guides-Bm3RbUB-.js → guides-B8HdeK_C.js} +1 -1
- package/studio-dist/server/assets/{guides-BLJenHwQ.js → guides-BGftp4wf.js} +1 -1
- package/studio-dist/server/assets/{guides.server-rHHqRuzV.js → guides.server-DqFQAStf.js} +1 -1
- package/studio-dist/server/assets/{markdown-view-D3v9x-cM.js → markdown-view-CArpV-CS.js} +1 -1
- package/studio-dist/server/assets/{panel-yqOl5GMU.js → panel-DR0iq46J.js} +4 -3
- package/studio-dist/server/assets/{plugins._service._view-DwqJX7s9.js → plugins._service._view-n7u2k5dF.js} +11 -6
- package/studio-dist/server/assets/prepaint-B28ClcPN.js +45 -0
- package/studio-dist/server/assets/{queries-DYmGrhNO.js → queries-D-yVP9i0.js} +1 -1
- package/studio-dist/server/assets/react-CiBZPDs8.js +45 -0
- package/studio-dist/server/assets/{reports-C4Y_Jd-x.js → reports-B9k98oE6.js} +1 -1
- package/studio-dist/server/assets/{reports-7yaPz7aP.js → reports-C2SmTgqh.js} +7 -7
- package/studio-dist/server/assets/{router-Dnoq5auE.js → router-CPt0TAk_.js} +654 -1565
- package/studio-dist/server/assets/{routes-Cok4p3mK.js → routes-CwH8LEy2.js} +8 -8
- package/studio-dist/server/assets/{search-DUK7Jl6f.js → search-b-yQesv3.js} +25 -2
- package/studio-dist/server/assets/{combobox-oxUI6r4V.js → select-C3i6TTX-.js} +35 -514
- package/studio-dist/server/assets/{shell-DNVXedgE.js → shell-CagqZZMZ.js} +4 -3
- package/studio-dist/server/assets/{skills-D8qdXSku.js → skills-C21Mg_8-.js} +8 -8
- package/studio-dist/server/assets/{skills-pKmuAs0F.js → skills-DGg0mWDM.js} +1 -1
- package/studio-dist/server/assets/{specs-DeHYUNFp.js → specs-DetoMiaB.js} +4 -4
- package/studio-dist/server/assets/{specs-view-BGn-5Ik_.js → specs-view-CmbfLDwN.js} +10 -9
- package/studio-dist/server/assets/{steps-CV7Yk7L7.js → steps-D1tYAyWZ.js} +1 -1
- package/studio-dist/server/assets/store-aC-I6f6o.js +93 -0
- package/studio-dist/server/assets/{studio-CB94np48.js → studio-qRvQjRpz.js} +47 -2
- package/studio-dist/server/assets/{studio-queries-BqZGBE70.js → studio-queries-Dqf-3nzj.js} +66 -8
- package/studio-dist/server/assets/{usage-M6Gi6Km7.js → usage-CS4CBK9D.js} +13 -44
- package/studio-dist/server/assets/{usage-j5jR9gX9.js → usage-Cwle9-xY.js} +1 -1
- package/studio-dist/server/assets/useAnchoredPopupScrollLock-BjMNgXv9.js +756 -0
- package/studio-dist/server/assets/useMutation-DpBIuWXt.js +690 -0
- package/studio-dist/server/assets/{vault-lBlvSyD4.js → vault-CEBBRLMb.js} +1 -1
- package/studio-dist/server/assets/{vault-PqVmssmW.js → vault-DVQidlId.js} +6 -6
- package/studio-dist/server/assets/{views-CsFp1i1G.js → views-UgO0Qz_g.js} +2 -2
- package/studio-dist/server/assets/{warnings-BDs34j_m.js → warnings-C7hgXpdk.js} +2 -2
- package/studio-dist/server/assets/{workflow-T0eEldsa.js → workflow-6dZZ1ofw.js} +9 -9
- package/studio-dist/server/server.js +2 -2
- package/tool-manifest.yaml +85 -0
- package/studio-dist/client/assets/app-BFVyWHGo.css +0 -2
- package/studio-dist/client/assets/button-D6LrRkOG.js +0 -1
- package/studio-dist/client/assets/combobox-Dk2MMZWE.js +0 -1
- package/studio-dist/client/assets/fields-D_FYhxQr.js +0 -1
- package/studio-dist/client/assets/getting-started-ByWRg7hC.js +0 -1
- package/studio-dist/client/assets/getting-started-DZSjYC-b.js +0 -1
- package/studio-dist/client/assets/getting-started._topic-C6OyQ4G6.js +0 -1
- package/studio-dist/client/assets/getting-started.index-BkmPHdEm.js +0 -1
- package/studio-dist/client/assets/graph-7jm2XzyL.js +0 -2
- package/studio-dist/client/assets/guides-D9VTjWXP.js +0 -1
- package/studio-dist/client/assets/index-BBmFpG4y.js +0 -40
- package/studio-dist/client/assets/markdown-view-RL5YvfZg.js +0 -1
- package/studio-dist/client/assets/panel-B8F8sOKQ.js +0 -1
- package/studio-dist/client/assets/plugins._service._view-CynxTbMx.js +0 -1
- package/studio-dist/client/assets/react-r45OnJCw.js +0 -27
- package/studio-dist/client/assets/reports-BCAyXh6p.js +0 -1
- package/studio-dist/client/assets/routes-BFPqq89E.js +0 -1
- package/studio-dist/client/assets/skills-DTks_uBx.js +0 -1
- package/studio-dist/client/assets/specs-view-omrd_5P3.js +0 -1
- package/studio-dist/client/assets/store-DJ5cncKA.js +0 -1
- package/studio-dist/client/assets/useBaseQuery-BlC-AZ35.js +0 -1
- package/studio-dist/client/assets/vault-DRg8MScm.js +0 -1
- package/studio-dist/client/assets/warnings-UHFy6HAp.js +0 -1
- package/studio-dist/client/assets/workflow-Bv9vSfVV.js +0 -1
- package/studio-dist/server/assets/react-BO0uMhpm.js +0 -89
- package/studio-dist/server/assets/store-CWDGIp6x.js +0 -280
- package/studio-dist/server/assets/useBaseQuery-Tv_QJt9r.js +0 -2051
|
@@ -5,7 +5,7 @@ import { resolveInstallContext } from "../../../lib/install";
|
|
|
5
5
|
import { backfillHubAllowedAgents } from "../../../lib/orchestrator/companion-hub";
|
|
6
6
|
import { ConfigStore } from "../../../lib/orchestrator/config-store";
|
|
7
7
|
import type { FrameworkConfig, PluginDeclaration } from "../../../lib/orchestrator/types";
|
|
8
|
-
import { applySetupCompatibilities } from "../../../tools/setup";
|
|
8
|
+
import { applySetupCompatibilities, syncCompanionFiles } from "../../../tools/setup";
|
|
9
9
|
import {
|
|
10
10
|
describeUnknownAudience,
|
|
11
11
|
readAudienceSelection,
|
|
@@ -13,6 +13,10 @@ import {
|
|
|
13
13
|
} from "../../../tools/setup/dynamic-plugins/audiences";
|
|
14
14
|
import { hydrateDynamicPlugins } from "../../../tools/setup/dynamic-plugins/hydrate";
|
|
15
15
|
import type { PluginInstallDeps } from "../../../tools/setup/dynamic-plugins/install";
|
|
16
|
+
import {
|
|
17
|
+
committedDeclarationProblems,
|
|
18
|
+
declareLocalPlugin,
|
|
19
|
+
} from "../../../tools/setup/dynamic-plugins/local";
|
|
16
20
|
import { installPluginWorkspaces } from "../../../tools/setup/dynamic-plugins/workspaces";
|
|
17
21
|
import { reportPluginInstallResults, reportPluginWorkspaces } from "../install";
|
|
18
22
|
|
|
@@ -35,77 +39,114 @@ function withDeclaration(
|
|
|
35
39
|
);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
/** The local file sits in another directory, so a relative `file:` path is taken from `cwd` now. */
|
|
43
|
+
function absoluteFileSpec(version: string, cwd: string): string {
|
|
44
|
+
if (!version.startsWith("file:") || version.startsWith("file://")) return version;
|
|
45
|
+
const target = version.slice("file:".length);
|
|
46
|
+
if (target.startsWith("~/") || path.isAbsolute(target)) return version;
|
|
47
|
+
return `file:${path.resolve(cwd, target)}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const INSTALL_USAGE = `usage: ${FRAMEWORK_NAME} plugin install [--local] <package>[@version]`;
|
|
39
51
|
|
|
40
52
|
export interface PluginInstallCommandDeps {
|
|
41
53
|
cwd?: string;
|
|
42
54
|
installDeps?: PluginInstallDeps;
|
|
43
55
|
setupHub?: (companionPath: string, config: FrameworkConfig) => Promise<void>;
|
|
56
|
+
syncCompanion?: (companionPath: string, config: FrameworkConfig) => Promise<unknown>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function refuse(message: string): false {
|
|
60
|
+
process.stderr.write(`${FRAMEWORK_NAME}: ${message}\n`);
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
return false;
|
|
44
63
|
}
|
|
45
64
|
|
|
46
65
|
/**
|
|
47
|
-
* @command mate plugin install <package>[@version]
|
|
66
|
+
* @command mate plugin install [--local] <package>[@version]
|
|
48
67
|
* @description Declares `<package>` in the companion's (or hub's) `framework.yaml`
|
|
49
68
|
* `plugins:` list (adding it, or updating its version if already declared)
|
|
50
69
|
* and installs it immediately into the shared workspace, the same way
|
|
51
70
|
* `mate install` would on its next run: with the selected audience's
|
|
52
|
-
* plugins, and without any other audience's.
|
|
71
|
+
* plugins, and without any other audience's. A successful install in a
|
|
72
|
+
* companion then syncs the companion's agent runtime settings, as
|
|
73
|
+
* `mate install` does.
|
|
74
|
+
* @flags
|
|
75
|
+
* - `--local` — declare the package in the untracked `.mate/config/framework.local.yaml` and install it into the ignored `.mate/local-plugins/`, for this machine only. No tracked file names it. A relative `file:` path is resolved from the current directory and written as an absolute path. Refused in a hub and for a package `framework.yaml` declares.
|
|
53
76
|
*/
|
|
54
77
|
export async function runPluginInstallCommand(
|
|
55
78
|
argv: string[],
|
|
56
79
|
deps: PluginInstallCommandDeps = {},
|
|
57
80
|
): Promise<boolean> {
|
|
58
|
-
|
|
59
|
-
if (spec === "-h" || spec === "--help") {
|
|
81
|
+
if (argv.includes("-h") || argv.includes("--help")) {
|
|
60
82
|
process.stdout.write(`${INSTALL_USAGE}\n`);
|
|
61
83
|
return true;
|
|
62
84
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
const local = argv.includes("--local");
|
|
86
|
+
const unknownOption = argv.find((arg) => arg.startsWith("-") && arg !== "--local");
|
|
87
|
+
const spec = argv.find((arg) => !arg.startsWith("-"));
|
|
88
|
+
if (unknownOption || !spec) {
|
|
89
|
+
const problem = unknownOption ? `unknown option ${unknownOption}; ` : "";
|
|
90
|
+
return refuse(`${problem}${INSTALL_USAGE}`);
|
|
68
91
|
}
|
|
69
|
-
const
|
|
92
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
93
|
+
const parsed = parsePackageSpec(spec);
|
|
94
|
+
const packageName = parsed.package;
|
|
95
|
+
const version = local ? absoluteFileSpec(parsed.version, cwd) : parsed.version;
|
|
70
96
|
|
|
71
|
-
const context = await resolveInstallContext(
|
|
97
|
+
const context = await resolveInstallContext(cwd);
|
|
72
98
|
if (context.kind === "ambiguous") {
|
|
73
99
|
process.stderr.write(`${context.message}\n`);
|
|
74
100
|
process.exitCode = 1;
|
|
75
101
|
return false;
|
|
76
102
|
}
|
|
77
103
|
if ((context.kind !== "companion" && context.kind !== "hub") || !context.companionPath) {
|
|
78
|
-
|
|
79
|
-
|
|
104
|
+
return refuse(
|
|
105
|
+
"`plugin install` requires a companion or hub context; run it from inside a linked working repository or a hub root.",
|
|
80
106
|
);
|
|
81
|
-
process.exitCode = 1;
|
|
82
|
-
return false;
|
|
83
107
|
}
|
|
84
108
|
|
|
85
109
|
// A hub declares no audiences; the selection only applies to a companion.
|
|
86
110
|
let audience: string | null = null;
|
|
87
111
|
if (context.kind === "companion") {
|
|
88
112
|
const resolved = resolveAudience(context.config, readAudienceSelection(process.env));
|
|
89
|
-
if (!resolved.ok)
|
|
90
|
-
process.stderr.write(`${FRAMEWORK_NAME}: ${describeUnknownAudience(resolved)}\n`);
|
|
91
|
-
process.exitCode = 1;
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
113
|
+
if (!resolved.ok) return refuse(describeUnknownAudience(resolved));
|
|
94
114
|
audience = resolved.active;
|
|
95
115
|
}
|
|
96
116
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
let nextConfig = context.config;
|
|
118
|
+
if (local) {
|
|
119
|
+
const problems = await declareLocalPlugin(
|
|
120
|
+
context.companionPath,
|
|
121
|
+
context.config,
|
|
122
|
+
packageName,
|
|
123
|
+
version,
|
|
124
|
+
);
|
|
125
|
+
if (problems.length > 0) {
|
|
126
|
+
return refuse(problems.map((problem) => problem.message).join("\n"));
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
const problems = await committedDeclarationProblems(
|
|
130
|
+
context.companionPath,
|
|
131
|
+
context.config,
|
|
132
|
+
packageName,
|
|
133
|
+
);
|
|
134
|
+
if (problems.length > 0) {
|
|
135
|
+
return refuse(problems.map((problem) => problem.message).join("\n"));
|
|
136
|
+
}
|
|
137
|
+
const configPath = path.join(
|
|
138
|
+
context.companionPath,
|
|
139
|
+
`.${FRAMEWORK_NAME}`,
|
|
140
|
+
"config",
|
|
141
|
+
"framework.yaml",
|
|
142
|
+
);
|
|
143
|
+
const store = new ConfigStore(configPath);
|
|
144
|
+
const nextPlugins = withDeclaration(context.config.plugins ?? [], packageName, version);
|
|
145
|
+
nextConfig = { ...context.config, plugins: nextPlugins };
|
|
146
|
+
const agentsBackfilled = context.kind === "hub" && backfillHubAllowedAgents(nextConfig);
|
|
147
|
+
if (nextPlugins !== context.config.plugins || agentsBackfilled) {
|
|
148
|
+
await store.save(nextConfig);
|
|
149
|
+
}
|
|
109
150
|
}
|
|
110
151
|
|
|
111
152
|
const outcome = await installPluginWorkspaces(context.companionPath, nextConfig, audience, {
|
|
@@ -114,6 +155,9 @@ export async function runPluginInstallCommand(
|
|
|
114
155
|
const { results } = outcome;
|
|
115
156
|
reportPluginWorkspaces(outcome);
|
|
116
157
|
reportPluginInstallResults(results);
|
|
158
|
+
const succeeded =
|
|
159
|
+
results.find((result) => result.package === packageName)?.status !== "failed" &&
|
|
160
|
+
!results.some((result) => result.refused);
|
|
117
161
|
await hydrateDynamicPlugins({ companionPath: context.companionPath });
|
|
118
162
|
if (context.kind === "hub") {
|
|
119
163
|
await (
|
|
@@ -122,6 +166,9 @@ export async function runPluginInstallCommand(
|
|
|
122
166
|
applySetupCompatibilities(companionPath, config, "sync", undefined, undefined, "hub"))
|
|
123
167
|
)(context.companionPath, nextConfig);
|
|
124
168
|
}
|
|
169
|
+
if (context.kind === "companion" && succeeded) {
|
|
170
|
+
await (deps.syncCompanion ?? syncCompanionFiles)(context.companionPath, nextConfig);
|
|
171
|
+
}
|
|
125
172
|
|
|
126
|
-
return
|
|
173
|
+
return succeeded;
|
|
127
174
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page's connection to Studio's server. Browser-safe: plugin view bundles import it,
|
|
3
|
+
* so it imports nothing from Node.
|
|
4
|
+
*/
|
|
5
|
+
import { STUDIO_PING_ROUTE } from "./routes";
|
|
6
|
+
|
|
7
|
+
export type StudioConnectionState =
|
|
8
|
+
| "online"
|
|
9
|
+
| "offline"
|
|
10
|
+
| "signed-out"
|
|
11
|
+
| "expired"
|
|
12
|
+
| "host-refused";
|
|
13
|
+
|
|
14
|
+
/** A connection problem; any other state of a request is an answer of Studio's. */
|
|
15
|
+
export type StudioConnectionProblem = Exclude<StudioConnectionState, "online">;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The connection problem a request's outcome (its response, or what it threw) shows.
|
|
19
|
+
* `null` for any answer Studio itself gave, a refusal included, and for an abort.
|
|
20
|
+
*/
|
|
21
|
+
export function connectionStateOf(outcome: unknown): StudioConnectionProblem | null {
|
|
22
|
+
if (outcome instanceof TypeError) return "offline";
|
|
23
|
+
if (!(outcome instanceof Response)) return null;
|
|
24
|
+
// A redirect `redirect: "manual"` stopped: an auth proxy in front of Studio.
|
|
25
|
+
if (outcome.type === "opaqueredirect") return "signed-out";
|
|
26
|
+
if (outcome.status === 401) return "expired";
|
|
27
|
+
if (outcome.status === 421) return "host-refused";
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Pings Studio. Never carries the token, so the token exchange's 303 cannot answer it. */
|
|
32
|
+
export async function probeStudio(fetchImpl: typeof fetch = fetch): Promise<StudioConnectionState> {
|
|
33
|
+
let outcome: unknown;
|
|
34
|
+
try {
|
|
35
|
+
outcome = await fetchImpl(STUDIO_PING_ROUTE, {
|
|
36
|
+
redirect: "manual",
|
|
37
|
+
credentials: "same-origin",
|
|
38
|
+
cache: "no-store",
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
outcome = error;
|
|
42
|
+
}
|
|
43
|
+
return connectionStateOf(outcome) ?? "online";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Studio's connection state, shared with the plugin views it mounts. */
|
|
47
|
+
export interface StudioConnection {
|
|
48
|
+
state(): StudioConnectionState;
|
|
49
|
+
/** A request failed; Studio probes unless a probe is running. Only the probe changes the state. */
|
|
50
|
+
suspect(): void;
|
|
51
|
+
/** Calls `listener` with each new state; returns the unsubscribe. */
|
|
52
|
+
subscribe(listener: (state: StudioConnectionState) => void): () => void;
|
|
53
|
+
}
|
|
@@ -15,6 +15,9 @@ export const SERVICE_ROUTE_PREFIX = "/api/plugins/";
|
|
|
15
15
|
/** A service plugin's view modules: `/studio/plugins/<service id>/<view id>/<file>`. */
|
|
16
16
|
export const SERVICE_ASSET_PREFIX = "/studio/plugins/";
|
|
17
17
|
|
|
18
|
+
/** Answers 204 to any reader; the page probes its connection here. */
|
|
19
|
+
export const STUDIO_PING_ROUTE = "/api/ping";
|
|
20
|
+
|
|
18
21
|
/** One event stream per page: board, reports and markdown tree changes for a companion. */
|
|
19
22
|
export const STUDIO_EVENTS_ROUTE = "/api/events";
|
|
20
23
|
|
|
@@ -11,6 +11,7 @@ export type StudioView =
|
|
|
11
11
|
| "vault"
|
|
12
12
|
| "reports"
|
|
13
13
|
| "usage"
|
|
14
|
+
| "friction"
|
|
14
15
|
| "graph";
|
|
15
16
|
|
|
16
17
|
export const STUDIO_VIEWS: readonly StudioView[] = [
|
|
@@ -22,6 +23,7 @@ export const STUDIO_VIEWS: readonly StudioView[] = [
|
|
|
22
23
|
"vault",
|
|
23
24
|
"reports",
|
|
24
25
|
"usage",
|
|
26
|
+
"friction",
|
|
25
27
|
"graph",
|
|
26
28
|
];
|
|
27
29
|
|
|
@@ -38,7 +40,14 @@ export const MODE_VIEWS: Readonly<Record<StudioMode, readonly StudioView[]>> = {
|
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
/** Views every mode is offered, in navigation order. */
|
|
41
|
-
export const SHARED_VIEWS: readonly StudioView[] = [
|
|
43
|
+
export const SHARED_VIEWS: readonly StudioView[] = [
|
|
44
|
+
"vault",
|
|
45
|
+
"specs",
|
|
46
|
+
"reports",
|
|
47
|
+
"graph",
|
|
48
|
+
"usage",
|
|
49
|
+
"friction",
|
|
50
|
+
];
|
|
42
51
|
|
|
43
52
|
/** Where a mode lands when its URL names no view, or one it is not offered. */
|
|
44
53
|
export const LANDING_VIEW: Readonly<Record<StudioMode, StudioView>> = {
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
SERVICE_ROUTE_PREFIX,
|
|
39
39
|
STUDIO_EVENTS_ROUTE,
|
|
40
40
|
STUDIO_HOSTNAME,
|
|
41
|
+
STUDIO_PING_ROUTE,
|
|
41
42
|
type StudioEvent,
|
|
42
43
|
TERMINAL_ASSET_PREFIX,
|
|
43
44
|
TERMINAL_SESSIONS_END_ROUTE,
|
|
@@ -141,6 +142,8 @@ export interface StudioServerDeps {
|
|
|
141
142
|
vault?: VaultManager;
|
|
142
143
|
reports?: ReportStore;
|
|
143
144
|
usage?: UsageCache;
|
|
145
|
+
/** Where the Friction Log and Switch live; the user's home when absent. */
|
|
146
|
+
homeDir?: string;
|
|
144
147
|
terminal?: Partial<TerminalRegistryOptions>;
|
|
145
148
|
launchableAgents?: typeof launchableAgents;
|
|
146
149
|
/** The plugin services Studio mounts; the registered plugins' when absent. */
|
|
@@ -611,6 +614,30 @@ export function createStudioFetch(
|
|
|
611
614
|
});
|
|
612
615
|
return (await usage).read(companionPath, request);
|
|
613
616
|
},
|
|
617
|
+
friction: async (digest, { days }) => {
|
|
618
|
+
const companionPath = await companionPathOf(digest);
|
|
619
|
+
const { readFrictionView } = await import("../../../lib/friction/view/read");
|
|
620
|
+
return readFrictionView({ companion: companionPath }, { days, homeDir: deps.homeDir });
|
|
621
|
+
},
|
|
622
|
+
frictionRecording: async () => {
|
|
623
|
+
const { readFrictionSwitch } = await import("../../../runtime/friction-switch");
|
|
624
|
+
return { recording: readFrictionSwitch(deps.homeDir) };
|
|
625
|
+
},
|
|
626
|
+
setFrictionRecording: async (recording) => {
|
|
627
|
+
const { writeFrictionSwitch } = await import("../../../runtime/friction-switch");
|
|
628
|
+
writeFrictionSwitch(recording, deps.homeDir);
|
|
629
|
+
return { recording };
|
|
630
|
+
},
|
|
631
|
+
markFriction: async (target, state, { note, link }) => {
|
|
632
|
+
const { markFriction } = await import("../../../lib/friction/mark");
|
|
633
|
+
const marked = await markFriction(
|
|
634
|
+
target,
|
|
635
|
+
state,
|
|
636
|
+
{ note, link, by: "studio" },
|
|
637
|
+
{ homeDir: deps.homeDir },
|
|
638
|
+
);
|
|
639
|
+
return marked.ok ? { ok: true, state: marked.state } : { ok: false, reason: marked.reason };
|
|
640
|
+
},
|
|
614
641
|
skillPreview: async (digest, agent, name, file) => {
|
|
615
642
|
const { readSkillPreview } = await import("./skill-files");
|
|
616
643
|
return readSkillPreview(await companionPathOf(digest), agent, name, file);
|
|
@@ -718,6 +745,10 @@ export function createStudioFetch(
|
|
|
718
745
|
const refusal = refusalFor(route, request, url, acceptedOrigin);
|
|
719
746
|
if (refusal) return respond(refusal);
|
|
720
747
|
|
|
748
|
+
if (url.pathname === STUDIO_PING_ROUTE) {
|
|
749
|
+
return respond(new Response(null, { status: 204, headers: { "cache-control": "no-store" } }));
|
|
750
|
+
}
|
|
751
|
+
|
|
721
752
|
if (url.pathname === REPORTS_ROUTE) {
|
|
722
753
|
const digest = url.searchParams.get(COMPANION_PARAM) ?? "";
|
|
723
754
|
if (!COMPANION_DIGEST_PATTERN.test(digest)) {
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
StudioServiceHost,
|
|
14
14
|
StudioSocketHandler,
|
|
15
15
|
StudioSocketPeer,
|
|
16
|
+
StudioViewLayout,
|
|
16
17
|
StudioWorksetSessions,
|
|
17
18
|
} from "../../../tools/setup/service";
|
|
18
19
|
import { SERVICE_ASSET_PREFIX, SERVICE_ROUTE_PREFIX } from "./routes";
|
|
@@ -26,6 +27,7 @@ export interface StudioServiceViewSummary {
|
|
|
26
27
|
moduleUrl?: string;
|
|
27
28
|
/** The service route answering the view's attention count, when it declares one. */
|
|
28
29
|
attentionUrl?: string;
|
|
30
|
+
layout?: StudioViewLayout;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/** A mounted service as Studio's application sees it. */
|
|
@@ -218,6 +220,7 @@ function mountedServices(mounted: MountedService[]): MountedServices {
|
|
|
218
220
|
...(view.attention
|
|
219
221
|
? { attentionUrl: `${SERVICE_ROUTE_PREFIX}${service.id}${view.attention}` }
|
|
220
222
|
: {}),
|
|
223
|
+
...(view.layout ? { layout: view.layout } : {}),
|
|
221
224
|
})),
|
|
222
225
|
})),
|
|
223
226
|
match(pathname, method) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { FrictionView, FrictionViewDays } from "../../../lib/friction/view/model";
|
|
2
|
+
import type { FrictionState, MarkState } from "../../../runtime/friction-vocabulary";
|
|
1
3
|
import type { UsageRequest } from "../../../lib/usage/cache";
|
|
2
4
|
import type { UsageResponse } from "../../../lib/usage/types";
|
|
3
5
|
import type { StudioSpecGraph } from "./graph";
|
|
@@ -63,6 +65,25 @@ export interface StudioServices {
|
|
|
63
65
|
reports(companionDigest: string): Promise<StoredReport[]>;
|
|
64
66
|
/** Read-only, explicitly refreshed usage; never collected for unrelated views. */
|
|
65
67
|
usage(companionDigest: string, request: UsageRequest): Promise<UsageResponse>;
|
|
68
|
+
/** The friction recorded for a registered companion on this machine; read-only. */
|
|
69
|
+
friction(companionDigest: string, request: { days: FrictionViewDays }): Promise<FrictionView>;
|
|
70
|
+
/** This machine's Friction Switch alone: reads no Friction Log and writes nothing. */
|
|
71
|
+
frictionRecording(): Promise<{ recording: boolean }>;
|
|
72
|
+
/**
|
|
73
|
+
* Sets this machine's Friction Switch. Needs no `writable`: it writes only the switch's
|
|
74
|
+
* settings file, never a companion, repository, registry or log.
|
|
75
|
+
*/
|
|
76
|
+
setFrictionRecording(recording: boolean): Promise<{ recording: boolean }>;
|
|
77
|
+
/**
|
|
78
|
+
* Sets or, with `open`, clears a fingerprint's or Free Report's Friction State, as
|
|
79
|
+
* `mate friction mark` does, by `studio`. Needs no `writable`: it writes only the state file.
|
|
80
|
+
* A refusal is an answer, not an error.
|
|
81
|
+
*/
|
|
82
|
+
markFriction(
|
|
83
|
+
target: string,
|
|
84
|
+
state: MarkState,
|
|
85
|
+
input: { note?: string; link?: string },
|
|
86
|
+
): Promise<FrictionMarkResult>;
|
|
66
87
|
/** One installed skill's files and one of them rendered (SKILL.md by default); read-only. */
|
|
67
88
|
skillPreview(
|
|
68
89
|
companionDigest: string,
|
|
@@ -86,6 +107,10 @@ export interface StudioServices {
|
|
|
86
107
|
addCompanion(input: CompanionAddInput): Promise<CompanionAddResult>;
|
|
87
108
|
}
|
|
88
109
|
|
|
110
|
+
export type FrictionMarkResult =
|
|
111
|
+
| { ok: true; state: FrictionState | null }
|
|
112
|
+
| { ok: false; reason: string };
|
|
113
|
+
|
|
89
114
|
export type CompanionAddInput = { kind: "url"; url: string } | { kind: "path"; path: string };
|
|
90
115
|
|
|
91
116
|
export type CompanionAddResult =
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import readline from "node:readline/promises";
|
|
2
|
+
|
|
3
|
+
import { FRAMEWORK_NAME } from "../../framework";
|
|
4
|
+
import { FrictionRefusal } from "../../lib/friction/fields";
|
|
5
|
+
import { formatCommand } from "../../runtime/command-arg";
|
|
6
|
+
import {
|
|
7
|
+
launchAgent,
|
|
8
|
+
TRIAGE_AGENT_NAMES,
|
|
9
|
+
TRIAGE_AGENTS,
|
|
10
|
+
type FoundAgent,
|
|
11
|
+
type TriageAgent,
|
|
12
|
+
} from "../../lib/triage/launch";
|
|
13
|
+
import {
|
|
14
|
+
prepareTriageSession,
|
|
15
|
+
seedPrompt,
|
|
16
|
+
type TriageSessionFiles,
|
|
17
|
+
} from "../../lib/triage/prepare";
|
|
18
|
+
import { recordTriageLauncher } from "../../lib/triage/session";
|
|
19
|
+
import { currentSession } from "../../runtime/session-id";
|
|
20
|
+
import { collectDoctorReport } from "./doctor";
|
|
21
|
+
|
|
22
|
+
interface TriageArgs {
|
|
23
|
+
target?: string;
|
|
24
|
+
agent: TriageAgent | null;
|
|
25
|
+
launch: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const TRIAGE_USAGE = `Usage: ${FRAMEWORK_NAME} triage ["<fingerprint|report-id>"] [--agent <${TRIAGE_AGENTS.join("|")}>] [--no-launch]`;
|
|
29
|
+
|
|
30
|
+
function parseTriageArgs(argv: string[]): TriageArgs | { error: string } {
|
|
31
|
+
const args: TriageArgs = { agent: null, launch: true };
|
|
32
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
33
|
+
const arg = argv[index]!;
|
|
34
|
+
const [flag, inline] = arg.startsWith("--") && arg.includes("=") ? arg.split(/=(.*)/s) : [arg];
|
|
35
|
+
if (flag === "--no-launch" && inline === undefined) {
|
|
36
|
+
args.launch = false;
|
|
37
|
+
} else if (flag === "--agent") {
|
|
38
|
+
const value = inline ?? argv[++index];
|
|
39
|
+
if (!TRIAGE_AGENTS.includes(value as TriageAgent)) {
|
|
40
|
+
return { error: `--agent must be one of: ${TRIAGE_AGENTS.join(", ")}` };
|
|
41
|
+
}
|
|
42
|
+
args.agent = value as TriageAgent;
|
|
43
|
+
} else if (!arg.startsWith("-")) {
|
|
44
|
+
if (arg.trim() === "") return { error: "the Triage Target is empty" };
|
|
45
|
+
if (args.target !== undefined) {
|
|
46
|
+
return { error: `triage takes one Triage Target; got a second: ${arg}` };
|
|
47
|
+
}
|
|
48
|
+
args.target = arg;
|
|
49
|
+
} else {
|
|
50
|
+
return { error: `unknown triage option: ${arg}` };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return args;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TriageDeps {
|
|
57
|
+
cwd?: string;
|
|
58
|
+
env?: Record<string, string | undefined>;
|
|
59
|
+
now?: Date;
|
|
60
|
+
/** Asks which agent to start; null when no terminal can ask. Defaults to a prompt on a TTY stdin. */
|
|
61
|
+
ask?: AskAgent | null;
|
|
62
|
+
collectDoctor?: (cwd: string) => Promise<unknown>;
|
|
63
|
+
launch?: typeof launchAgent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type AskAgent = (choices: TriageAgent[]) => Promise<TriageAgent | null>;
|
|
67
|
+
|
|
68
|
+
const askAgent: AskAgent = async (choices) => {
|
|
69
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
70
|
+
try {
|
|
71
|
+
const answer = await rl.question(`Start which agent? (${choices.join("/")}) `);
|
|
72
|
+
const picked = answer.trim().toLowerCase();
|
|
73
|
+
return choices.find((choice) => choice === picked) ?? null;
|
|
74
|
+
} finally {
|
|
75
|
+
rl.close();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
async function chooseAgent(
|
|
80
|
+
requested: TriageAgent | null,
|
|
81
|
+
agents: FoundAgent[],
|
|
82
|
+
ask: AskAgent | null,
|
|
83
|
+
): Promise<{ found: FoundAgent } | { error: string }> {
|
|
84
|
+
const pick = (id: TriageAgent | null, error: string) => {
|
|
85
|
+
const found = agents.find((agent) => agent.agent === id);
|
|
86
|
+
return found ? { found } : { error };
|
|
87
|
+
};
|
|
88
|
+
if (requested) return pick(requested, `${TRIAGE_AGENT_NAMES[requested]} was not found on PATH.`);
|
|
89
|
+
if (agents.length === 0) {
|
|
90
|
+
return {
|
|
91
|
+
error: `No agent was found: install ${TRIAGE_AGENTS.map((id) => TRIAGE_AGENT_NAMES[id]).join(" or ")}, or start your own agent with the prompt in prompt.md.`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (agents.length === 1) return { found: agents[0]! };
|
|
95
|
+
const flags = agents.map((agent) => `--agent ${agent.agent}`).join(" or ");
|
|
96
|
+
if (!ask) return { error: `Several agents are installed; choose one with ${flags}.` };
|
|
97
|
+
const picked = await ask(agents.map((agent) => agent.agent));
|
|
98
|
+
return pick(picked, `No agent chosen; choose one with ${flags}.`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function printPaths(files: TriageSessionFiles): void {
|
|
102
|
+
console.log(`Triage session: ${files.dir}`);
|
|
103
|
+
console.log(` context: ${files.context}`);
|
|
104
|
+
console.log(` playbook: ${files.playbook}`);
|
|
105
|
+
console.log(` prompt: ${files.prompt}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @command mate triage
|
|
110
|
+
* @description Writes a triage session under Mate's home (machine facts, the
|
|
111
|
+
* shipped playbook, a seed prompt and a 30-day friction snapshot) and starts
|
|
112
|
+
* Claude Code or OpenCode in it, directly and not through a Mate launch.
|
|
113
|
+
* Runs before every gate, so it works when Mate itself does not.
|
|
114
|
+
* An optional Triage Target (a fingerprint or Free Report id) focuses the
|
|
115
|
+
* session on that item and chooses the snapshot's companion.
|
|
116
|
+
* `--no-launch` only prints the session paths.
|
|
117
|
+
*/
|
|
118
|
+
export async function runTriageCommand(argv: string[] = [], deps: TriageDeps = {}): Promise<void> {
|
|
119
|
+
const args = parseTriageArgs(argv);
|
|
120
|
+
if ("error" in args) {
|
|
121
|
+
console.error(`${FRAMEWORK_NAME}: ${args.error}`);
|
|
122
|
+
console.error(TRIAGE_USAGE);
|
|
123
|
+
process.exitCode = 1;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const env = deps.env ?? process.env;
|
|
127
|
+
let prepared: Awaited<ReturnType<typeof prepareTriageSession>>;
|
|
128
|
+
try {
|
|
129
|
+
prepared = await prepareTriageSession({
|
|
130
|
+
argv,
|
|
131
|
+
cwd: deps.cwd ?? process.cwd(),
|
|
132
|
+
homeDir: env.HOME,
|
|
133
|
+
now: deps.now ?? new Date(),
|
|
134
|
+
pathValue: env.PATH ?? "",
|
|
135
|
+
env,
|
|
136
|
+
collectDoctor: deps.collectDoctor ?? ((cwd) => collectDoctorReport({ cwd, write: false })),
|
|
137
|
+
target: args.target,
|
|
138
|
+
});
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (!(error instanceof FrictionRefusal)) throw error;
|
|
141
|
+
console.error(`${FRAMEWORK_NAME}: ${error.message}`);
|
|
142
|
+
process.exitCode = 1;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const { files, agents } = prepared;
|
|
146
|
+
printPaths(files);
|
|
147
|
+
if (!args.launch) return;
|
|
148
|
+
if (currentSession(env)) {
|
|
149
|
+
console.log(
|
|
150
|
+
`No agent started: this is an agent session. Run \`${formatCommand([FRAMEWORK_NAME, "triage", ...argv])}\` in your own terminal.`,
|
|
151
|
+
);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const ask = deps.ask === undefined ? (process.stdin.isTTY ? askAgent : null) : deps.ask;
|
|
156
|
+
const choice = await chooseAgent(args.agent, agents, ask);
|
|
157
|
+
if ("error" in choice) {
|
|
158
|
+
console.error(`${FRAMEWORK_NAME}: ${choice.error}`);
|
|
159
|
+
process.exitCode = 1;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const release = recordTriageLauncher(files.dir);
|
|
163
|
+
try {
|
|
164
|
+
process.exitCode = await (deps.launch ?? launchAgent)({
|
|
165
|
+
...choice.found,
|
|
166
|
+
sessionDir: files.dir,
|
|
167
|
+
prompt: seedPrompt(),
|
|
168
|
+
});
|
|
169
|
+
} finally {
|
|
170
|
+
release();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-canary.
|
|
3
|
-
"sha512": "sha512-
|
|
2
|
+
"version": "1.0.0-canary.8",
|
|
3
|
+
"sha512": "sha512-eOxXhwtswLDZvHJJYI86S91PNqhNhKaGbbDbL4/TH5j2pxuyyHyOtBaYZGrH/0Hy6eGLSfJE1VMlCDJFfDcPjw=="
|
|
4
4
|
}
|
package/src/cli/install-plan.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { BRAND_ACCENT } from "../brand/palette";
|
|
|
7
7
|
import { useSpinnerFrame } from "../lib/components/spinner";
|
|
8
8
|
import type { InstallPlan, InstallPlanItem, InstallRequirementResult } from "../lib/install";
|
|
9
9
|
import { runInstallPlan } from "../lib/install";
|
|
10
|
+
import { holdToolNotices } from "../lib/tool-manifest";
|
|
10
11
|
|
|
11
12
|
type Execution = { ok: boolean; results: InstallRequirementResult[] };
|
|
12
13
|
|
|
@@ -178,8 +179,10 @@ export function InstallExecutionView({
|
|
|
178
179
|
export async function renderInstallExecution(plan: InstallPlan): Promise<Execution> {
|
|
179
180
|
return new Promise((resolve) => {
|
|
180
181
|
let app: ReturnType<typeof render> | undefined;
|
|
182
|
+
const releaseNotices = holdToolNotices();
|
|
181
183
|
const finish = (execution: Execution) => {
|
|
182
184
|
app?.unmount();
|
|
185
|
+
releaseNotices();
|
|
183
186
|
resolve(execution);
|
|
184
187
|
};
|
|
185
188
|
app = render(<InstallExecutionView plan={plan} onDone={finish} />);
|