@uniqbit/mate-core 0.18.1-canary.0 → 0.18.1-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-plugin/hooks/session-banner.mjs +1 -1
- package/opencode-plugin/server.ts +5 -0
- package/opencode-plugin/src/add-dir.ts +118 -0
- package/opencode-plugin/src/companion.ts +180 -0
- package/opencode-plugin/src/server.ts +26 -0
- package/opencode-plugin/src/tui.tsx +1 -0
- package/opencode-plugin/tui.tsx +2 -0
- package/package.json +13 -6
- package/src/cli/commands/artifact/finish/engine.ts +1 -1
- package/src/cli/commands/artifact/finish/git.ts +75 -51
- package/src/cli/commands/companion/hub.ts +1 -1
- package/src/cli/commands/companion/link.ts +13 -59
- package/src/cli/commands/doctor.ts +30 -4
- package/src/cli/commands/install.ts +17 -1
- package/src/cli/commands/plugin/plugin.ts +0 -4
- package/src/cli/commands/report/formatter.ts +0 -4
- package/src/cli/commands/studio/selection.ts +3 -0
- package/src/cli/commands/studio/terminal-launch.ts +1 -51
- package/src/cli/commands/studio/terminal.ts +2 -13
- package/src/cli/commands/studio/vault.ts +5 -3
- package/src/cli/commands/studio/views/workflow/steps.ts +5 -4
- package/src/cli/commands/update.ts +4 -20
- package/src/cli/commands/working/cleanup.ts +4 -1
- package/src/cli/launch-selector.tsx +0 -318
- package/src/cli/main.ts +0 -29
- package/src/cli/setup-selector.tsx +1 -1
- package/src/cli/usage.ts +0 -1
- package/src/hooks/session-banner.ts +7 -5
- package/src/hooks/validate-artifact-path.ts +17 -6
- package/src/lib/opencode-plugin-package.ts +7 -28
- package/src/lib/orchestrator/adapters/opencode.ts +28 -67
- package/src/lib/orchestrator/companion-git-sync.ts +29 -93
- package/src/lib/orchestrator/companion-hub.ts +71 -110
- package/src/lib/orchestrator/repo-local-registry.ts +0 -21
- package/src/lib/orchestrator/types.ts +0 -6
- package/src/lib/orchestrator/working-repo-projection.ts +13 -9
- package/src/lib/package-paths.ts +32 -0
- package/src/lib/prebuilt-workspace.ts +0 -3
- package/src/opencode/companion-hooks.ts +15 -10
- package/src/runtime/companion-git.ts +327 -84
- package/src/runtime/companion-sync.ts +34 -43
- package/src/runtime/index.ts +7 -5
- package/src/templates/mate-skills/agents/mate-domain-modeling/SKILL.md +2 -2
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +25 -0
- package/src/templates/mate-skills/agents/mate-grilling/SKILL.md +9 -7
- package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +34 -4
- package/src/templates/mate-skills/claude/mate-domain-modeling/SKILL.md +2 -2
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +25 -0
- package/src/templates/mate-skills/claude/mate-grilling/SKILL.md +9 -7
- package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +34 -4
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +68 -77
- package/src/tools/setup/capabilities/graphify.ts +0 -4
- package/src/tools/setup/dynamic-plugins/frozen.ts +24 -3
- package/src/tools/setup/dynamic-plugins/loader.ts +16 -0
- package/src/tools/setup/dynamic-plugins/policy.ts +55 -0
- package/src/tools/setup/dynamic-plugins/staging.ts +55 -0
- package/src/tools/setup/dynamic-plugins/verify.ts +22 -18
- package/src/tools/setup/providers/opencode-format.ts +4 -0
- package/src/tools/setup/providers/opencode.ts +9 -65
- package/src/tools/setup/runtime-documents.ts +8 -9
- package/src/cli/commands/plugin/verify.ts +0 -29
|
@@ -5,37 +5,38 @@ import type { PluginDeclaration } from "../../../lib/orchestrator/types";
|
|
|
5
5
|
import { readDeclarations, validateDeclaration } from "./declarations";
|
|
6
6
|
import { loadDynamicPlugin, type DynamicPluginLoadDeps } from "./loader";
|
|
7
7
|
import { pluginPackageRoot } from "./paths";
|
|
8
|
+
import {
|
|
9
|
+
disallowedPluginMessage,
|
|
10
|
+
isPluginAllowed,
|
|
11
|
+
PluginPolicyError,
|
|
12
|
+
readPluginPolicy,
|
|
13
|
+
} from "./policy";
|
|
8
14
|
|
|
9
15
|
export interface PluginVerificationFailure {
|
|
10
16
|
package: string;
|
|
11
17
|
reason: string;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
export interface PluginInspection {
|
|
15
|
-
failures: PluginVerificationFailure[];
|
|
16
|
-
/** IDs of the capabilities the loaded plugins provide. */
|
|
17
|
-
capabilities: string[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
20
|
/**
|
|
21
|
-
* Strict, installation-free check of every declared plugin: installed
|
|
21
|
+
* Strict, installation-free check of every declared plugin: allowed, installed
|
|
22
22
|
* and loadable with the effective environment. Unlike hydration it fails
|
|
23
|
-
* closed on the first-class problems ordinary commands only warn about.
|
|
23
|
+
* closed on the first-class problems ordinary commands only warn about. Only
|
|
24
|
+
* allowlisted packages are imported.
|
|
24
25
|
*/
|
|
25
26
|
export async function verifyDeclaredPlugins(
|
|
26
27
|
companionPath: string,
|
|
27
28
|
deps: DynamicPluginLoadDeps = {},
|
|
28
29
|
): Promise<PluginVerificationFailure[]> {
|
|
29
|
-
return (await inspectDeclaredPlugins(companionPath, deps)).failures;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function inspectDeclaredPlugins(
|
|
33
|
-
companionPath: string,
|
|
34
|
-
deps: DynamicPluginLoadDeps = {},
|
|
35
|
-
): Promise<PluginInspection> {
|
|
36
30
|
const env = deps.env ?? process.env;
|
|
37
31
|
const failures: PluginVerificationFailure[] = [];
|
|
38
|
-
|
|
32
|
+
let policy: ReturnType<typeof readPluginPolicy>;
|
|
33
|
+
try {
|
|
34
|
+
policy = readPluginPolicy(env);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (!(error instanceof PluginPolicyError)) throw error;
|
|
37
|
+
return [{ package: "(allowlist)", reason: error.message }];
|
|
38
|
+
}
|
|
39
|
+
|
|
39
40
|
const declarations: PluginDeclaration[] = [];
|
|
40
41
|
for (const entry of await readDeclarations(companionPath)) {
|
|
41
42
|
const { declaration, error } = validateDeclaration(entry);
|
|
@@ -45,6 +46,10 @@ export async function inspectDeclaredPlugins(
|
|
|
45
46
|
|
|
46
47
|
for (const declaration of declarations) {
|
|
47
48
|
const name = declaration.package;
|
|
49
|
+
if (!isPluginAllowed(policy, name)) {
|
|
50
|
+
failures.push({ package: name, reason: disallowedPluginMessage(name) });
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
48
53
|
// oxlint-disable-next-line no-await-in-loop -- declared order is part of the contract
|
|
49
54
|
const installed = await fs
|
|
50
55
|
.access(pluginPackageRoot(companionPath, name))
|
|
@@ -60,7 +65,6 @@ export async function inspectDeclaredPlugins(
|
|
|
60
65
|
// oxlint-disable-next-line no-await-in-loop -- declared order is part of the contract
|
|
61
66
|
const result = await loadDynamicPlugin(companionPath, declaration, { ...deps, env });
|
|
62
67
|
if (!result.ok) failures.push({ package: name, reason: result.warning });
|
|
63
|
-
else if (result.plugin.kind === "capability") capabilities.push(result.plugin.id);
|
|
64
68
|
}
|
|
65
|
-
return
|
|
69
|
+
return failures;
|
|
66
70
|
}
|
|
@@ -245,6 +245,10 @@ function mergeConfig(target: Record<string, unknown>, source: Record<string, unk
|
|
|
245
245
|
target[key] = [...targetValue, ...sourceValue];
|
|
246
246
|
continue;
|
|
247
247
|
}
|
|
248
|
+
if (key === "plugins" && Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
249
|
+
target[key] = [...new Set([...targetValue, ...sourceValue])];
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
248
252
|
if (isRecord(targetValue) && isRecord(sourceValue)) {
|
|
249
253
|
mergeConfig(targetValue, sourceValue);
|
|
250
254
|
continue;
|
|
@@ -3,12 +3,7 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
import { FRAMEWORK_NAME } from "../../../framework";
|
|
6
|
-
import {
|
|
7
|
-
OPENCODE_PLUGIN_PACKAGE_NAME,
|
|
8
|
-
getOpenCodePluginPackageReference,
|
|
9
|
-
isMateOpenCodePluginReference,
|
|
10
|
-
warmOpenCodePluginCache,
|
|
11
|
-
} from "../../../lib/opencode-plugin-package";
|
|
6
|
+
import { isLegacyMateOpenCodePluginReference } from "../../../lib/opencode-plugin-package";
|
|
12
7
|
import { refreshFromTemplate, stripGuidanceBlock } from "../plugins/guidance";
|
|
13
8
|
import { stripSectionFromFile, type RemoveHeadingSectionOptions } from "./agent-file-sections";
|
|
14
9
|
import { reconcileSharedSkillTree } from "./agents-skill-root";
|
|
@@ -21,7 +16,6 @@ import {
|
|
|
21
16
|
import type { CapabilityContributionInput, ProviderPlugin, SetupContext } from "../plugin";
|
|
22
17
|
import { surfaceRoot } from "../surface-target";
|
|
23
18
|
import { resolvePreinstalledPluginReference } from "../../../lib/preinstalled-plugins";
|
|
24
|
-
import { getCurrentVersion } from "../../../lib/update-checker";
|
|
25
19
|
import { pruneEmptyAncestors } from "../utils";
|
|
26
20
|
import {
|
|
27
21
|
getOpenCodePluginReferences,
|
|
@@ -115,23 +109,15 @@ function isLegacyMatePluginConfigEntry(entry: unknown): boolean {
|
|
|
115
109
|
return typeof entry === "string" && LEGACY_PLUGIN_CONFIG_ENTRY_PATTERN.test(entry);
|
|
116
110
|
}
|
|
117
111
|
|
|
118
|
-
/**
|
|
112
|
+
/** Legacy package references (published or path-bound) and copied-file references alike. */
|
|
119
113
|
function isMatePluginEntry(entry: unknown): boolean {
|
|
120
|
-
return
|
|
114
|
+
return isLegacyMateOpenCodePluginReference(entry) || isLegacyMatePluginConfigEntry(entry);
|
|
121
115
|
}
|
|
122
116
|
|
|
123
117
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* every unrelated plugin entry.
|
|
118
|
+
* The committed config carries no Mate entry: the bundled plugin root is
|
|
119
|
+
* machine-local and reaches OpenCode through the launch overlay instead.
|
|
127
120
|
*/
|
|
128
|
-
function ensureMatePluginReference(config: OpenCodeConfig, pluginReference: string): void {
|
|
129
|
-
const preserved = getOpenCodePluginReferences(config).filter(
|
|
130
|
-
(entry) => !isMatePluginEntry(entry),
|
|
131
|
-
);
|
|
132
|
-
setOpenCodePluginReferences(config, [...preserved, pluginReference]);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
121
|
function stripMatePluginReference(config: OpenCodeConfig): void {
|
|
136
122
|
if (!Array.isArray(config.plugin) && !Array.isArray(config.plugins)) return;
|
|
137
123
|
|
|
@@ -141,11 +127,7 @@ function stripMatePluginReference(config: OpenCodeConfig): void {
|
|
|
141
127
|
setOpenCodePluginReferences(config, preserved);
|
|
142
128
|
}
|
|
143
129
|
|
|
144
|
-
async function syncOpenCodeConfigFile(
|
|
145
|
-
srcPath: string,
|
|
146
|
-
destPath: string,
|
|
147
|
-
pluginReference: string,
|
|
148
|
-
): Promise<void> {
|
|
130
|
+
async function syncOpenCodeConfigFile(srcPath: string, destPath: string): Promise<void> {
|
|
149
131
|
const defaults = normalizeOpenCodeConfig(
|
|
150
132
|
JSON.parse(await fs.readFile(srcPath, "utf8")) as Record<string, unknown>,
|
|
151
133
|
);
|
|
@@ -163,7 +145,7 @@ async function syncOpenCodeConfigFile(
|
|
|
163
145
|
}
|
|
164
146
|
|
|
165
147
|
mergeConfigDefaults(existing, defaults);
|
|
166
|
-
|
|
148
|
+
stripMatePluginReference(existing);
|
|
167
149
|
await writeOpenCodeConfig(destPath, existing);
|
|
168
150
|
}
|
|
169
151
|
|
|
@@ -293,51 +275,14 @@ async function removeLegacyRuntimeFiles(dest: string): Promise<void> {
|
|
|
293
275
|
}
|
|
294
276
|
}
|
|
295
277
|
|
|
296
|
-
async function
|
|
297
|
-
const warmed = await warmOpenCodePluginCache();
|
|
298
|
-
if (warmed.ok) return;
|
|
299
|
-
|
|
300
|
-
process.stderr.write(
|
|
301
|
-
[
|
|
302
|
-
`${FRAMEWORK_NAME}: could not pre-fetch ${pluginReference} into OpenCode's plugin environment.`,
|
|
303
|
-
"The first managed OpenCode launch will download it, which requires registry access.",
|
|
304
|
-
`Re-run \`${FRAMEWORK_NAME} companion setup\` with network access to warm the cache ahead of time.`,
|
|
305
|
-
...(warmed.detail ? [`Details: ${warmed.detail}`] : []),
|
|
306
|
-
].join("\n") + "\n",
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async function syncOpenCodeRuntimeFiles(
|
|
311
|
-
src: string,
|
|
312
|
-
companionPath: string,
|
|
313
|
-
mode: SetupContext["mode"],
|
|
314
|
-
): Promise<void> {
|
|
278
|
+
async function syncOpenCodeRuntimeFiles(src: string, companionPath: string): Promise<void> {
|
|
315
279
|
const dest = path.join(companionPath, ".opencode");
|
|
316
280
|
await fs.mkdir(dest, { recursive: true });
|
|
317
281
|
|
|
318
|
-
|
|
319
|
-
// does: the Runtime Surface writes the reference, so it is what changes it.
|
|
320
|
-
const pluginReference =
|
|
321
|
-
(await resolvePreinstalledPluginReference(
|
|
322
|
-
companionPath,
|
|
323
|
-
OPENCODE_PLUGIN_PACKAGE_NAME,
|
|
324
|
-
getCurrentVersion(),
|
|
325
|
-
)) ?? getOpenCodePluginPackageReference();
|
|
326
|
-
|
|
327
|
-
await syncOpenCodeConfigFile(
|
|
328
|
-
path.join(src, "opencode.json"),
|
|
329
|
-
path.join(dest, "opencode.json"),
|
|
330
|
-
pluginReference,
|
|
331
|
-
);
|
|
282
|
+
await syncOpenCodeConfigFile(path.join(src, "opencode.json"), path.join(dest, "opencode.json"));
|
|
332
283
|
await removeMatePluginFromLegacyTuiConfig(dest);
|
|
333
284
|
await removeLegacyRuntimeFiles(dest);
|
|
334
285
|
await removeLegacyTuiDependencies(dest);
|
|
335
|
-
|
|
336
|
-
// Warm OpenCode's plugin package cache only during interactive setup; the
|
|
337
|
-
// lightweight launch-time sync path must not install dependencies.
|
|
338
|
-
if (mode === "setup") {
|
|
339
|
-
await warmPluginCacheForSetup(pluginReference);
|
|
340
|
-
}
|
|
341
286
|
}
|
|
342
287
|
|
|
343
288
|
async function configureOpenCodeGuidance(companionPath: string): Promise<void> {
|
|
@@ -644,7 +589,6 @@ export function createOpenCodePlugin(): ProviderPlugin {
|
|
|
644
589
|
await syncOpenCodeRuntimeFiles(
|
|
645
590
|
path.join(getSetupProvidersRoot(), "opencode"),
|
|
646
591
|
ctx.companionPath,
|
|
647
|
-
ctx.mode,
|
|
648
592
|
);
|
|
649
593
|
await configureOpenCodeGuidance(ctx.companionPath);
|
|
650
594
|
},
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
ManagedRegion,
|
|
8
8
|
RenderedRuntimeDocument,
|
|
9
9
|
} from "../../lib/orchestrator/projection-types";
|
|
10
|
-
import {
|
|
10
|
+
import { getOpenCodePluginRoot } from "../../lib/package-paths";
|
|
11
11
|
import type { CapabilityContributionInput, SetupContext } from "./plugin";
|
|
12
12
|
import {
|
|
13
13
|
mateBannerHookGroups,
|
|
@@ -45,15 +45,14 @@ function document(documentPath: string, regions: ManagedRegion[]): RenderedRunti
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* The Mate plugin
|
|
49
|
-
*
|
|
48
|
+
* The Mate plugin root is what makes an Unmanaged OpenCode session load the
|
|
49
|
+
* companion guidance at all: OpenCode has no config channel for a generated
|
|
50
50
|
* system prompt, so the plugin is the only injection point, and a bare session
|
|
51
|
-
*
|
|
51
|
+
* has no launch overlay to find it in. The root is machine-local, which this
|
|
52
|
+
* git-excluded document tolerates and a committed config would not.
|
|
52
53
|
*
|
|
53
|
-
* A managed launch
|
|
54
|
-
*
|
|
55
|
-
* than doubled: the plugin skips its own emission when the companion-policy
|
|
56
|
-
* marker is already in the prompt.
|
|
54
|
+
* A managed launch lists the same root in its `OPENCODE_CONFIG_CONTENT`
|
|
55
|
+
* overlay; OpenCode dedupes identical plugin paths across config sources.
|
|
57
56
|
*/
|
|
58
57
|
|
|
59
58
|
/**
|
|
@@ -153,7 +152,7 @@ export function renderDocumentsForTarget(
|
|
|
153
152
|
{
|
|
154
153
|
at: ["plugins"],
|
|
155
154
|
kind: "list",
|
|
156
|
-
values: [
|
|
155
|
+
values: [getOpenCodePluginRoot()],
|
|
157
156
|
},
|
|
158
157
|
{
|
|
159
158
|
at: ["mcp", "servers"],
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { FRAMEWORK_NAME } from "../../../framework";
|
|
2
|
-
import { resolveInstallContext } from "../../../lib/install";
|
|
3
|
-
import { inspectDeclaredPlugins } from "../../../tools/setup/dynamic-plugins/verify";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @command mate plugin verify
|
|
7
|
-
* @description Strict, installation-free check that every plugin declared by the companion is installed, and loadable with the current environment. Exits non-zero naming each failing package. With `--json`, prints `{"capabilities": [...]}` listing the capability IDs the verified plugins provide.
|
|
8
|
-
*/
|
|
9
|
-
export async function runPluginVerifyCommand(
|
|
10
|
-
argv: string[] = [],
|
|
11
|
-
cwd = process.cwd(),
|
|
12
|
-
): Promise<boolean> {
|
|
13
|
-
const context = await resolveInstallContext(cwd);
|
|
14
|
-
if ((context.kind !== "companion" && context.kind !== "hub") || !context.companionPath) {
|
|
15
|
-
process.stderr.write(`${FRAMEWORK_NAME}: \`plugin verify\` requires a companion context.\n`);
|
|
16
|
-
process.exitCode = 1;
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const { failures, capabilities } = await inspectDeclaredPlugins(context.companionPath);
|
|
20
|
-
for (const failure of failures) {
|
|
21
|
-
process.stderr.write(`${FRAMEWORK_NAME}: plugin ${failure.package}: ${failure.reason}\n`);
|
|
22
|
-
}
|
|
23
|
-
if (failures.length > 0) {
|
|
24
|
-
process.exitCode = 1;
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (argv.includes("--json")) process.stdout.write(`${JSON.stringify({ capabilities })}\n`);
|
|
28
|
-
return true;
|
|
29
|
-
}
|