@evomap/evolver-cli 2.0.51 → 2.0.53

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/dist/lifecycle.js CHANGED
@@ -3766,6 +3766,18 @@ function recoverBootstrapTransaction(stateDir, run, uid, now, deadlineMs, assert
3766
3766
  return { status: 'none' };
3767
3767
  }
3768
3768
  const marker = readBootstrapMarker(stateDir);
3769
+ if (marker && journal.stage === 'rollback_pending') {
3770
+ assertBootstrapMarkerMatchesJournal(marker, journal);
3771
+ rollbackBootstrapTransaction(stateDir, journal, run, uid, now, deadlineMs, true, true, assertOwner);
3772
+ assertOwner();
3773
+ restoreBootstrapCanonicalQuarantine(stateDir, journal, {
3774
+ beforeMove: () => assertOwner(),
3775
+ afterMove: () => assertOwner(),
3776
+ });
3777
+ assertOwner();
3778
+ removeBootstrapJournal(stateDir);
3779
+ return { status: 'none' };
3780
+ }
3769
3781
  if (marker) {
3770
3782
  assertBootstrapMarkerMatchesJournal(marker, journal);
3771
3783
  assertOwner();
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type PluginRuntime } from './pluginRuntime.js';
2
- export declare const PLUGIN_USAGE = "Usage: evolver plugin list [--json]\n evolver plugin install [--host <host>] [--scope user|project] [--root <dir>]\n [--profile <dsh-profile>] [--trust] [--dry-run] [--json]\n\nHosts: claude-code, codex, grok, qoder, antigravity, opencode, dsh,\n cursor, workbuddy, mcp-generic\nDefault scope: user. dsh default profile: dsh-tui.\n--trust says you trust the plugin's hooks; only hosts that require it (grok) accept it.\nWith no host, only a single discovered native host is selected; otherwise choose --host.\nCursor, WorkBuddy and generic MCP return manual_required without writing client config.\nDry-run performs no download, host command or config write and proves no installed state.\nInstallation uses EvoMap/evolver-agent-plugin and does not replace setup-hooks.\nExit codes: 0 verified install/already-installed/list/preview; 2 action required\n(including trust_required and profile_store_mismatch); 1 conflict or failure.\n";
2
+ export declare const PLUGIN_USAGE = "Usage: evolver plugin list [--json]\n evolver plugin install [--host <host>] [--scope user|project] [--root <dir>]\n [--profile <dsh-profile>] [--trust] [--dry-run] [--json]\n\nHosts: claude-code, codex, grok, qoder, antigravity, opencode, dsh, zcode,\n kimi, stepcode, minimax, cursor, workbuddy, mcp-generic\nDefault scope: user. dsh default profile: dsh-tui.\n--trust says you trust the plugin's hooks; only hosts that require it (grok) accept it.\nWith no host, only a single discovered native host is selected; otherwise choose --host.\nCursor, WorkBuddy and generic MCP return manual_required without writing client config.\nKimi Code, Step Code and ZCode install on Windows and macOS.\nZCode installs evolver-plugin@evomap from the evolver-agent-plugin ZCode marketplace\nURL, after uninstalling an evolver-plugin@evolver-zcode-local install (data kept).\nDry-run performs no download, host command or config write and proves no installed state.\nInstallation uses EvoMap/evolver-agent-plugin and does not replace setup-hooks.\nExit codes: 0 verified install/already-installed/list/preview; 2 action required\n(including trust_required and profile_store_mismatch); 1 conflict or failure.\n";
3
3
  export interface PluginCommandDeps {
4
4
  runtime?: PluginRuntime;
5
5
  stdout?: (text: string) => void;
package/dist/plugin.js CHANGED
@@ -2,17 +2,21 @@ import { realpathSync, statSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { PLUGIN_HOSTS, pluginHostNamed } from './pluginHosts.js';
4
4
  import { installAgentPlugin } from './pluginInstall.js';
5
+ import { expectedHostLauncher, hostLauncher } from './pluginLauncher.js';
5
6
  import { createPluginRuntime, PluginInstallError } from './pluginRuntime.js';
6
7
  export const PLUGIN_USAGE = `Usage: evolver plugin list [--json]
7
8
  evolver plugin install [--host <host>] [--scope user|project] [--root <dir>]
8
9
  [--profile <dsh-profile>] [--trust] [--dry-run] [--json]
9
10
 
10
- Hosts: claude-code, codex, grok, qoder, antigravity, opencode, dsh,
11
- cursor, workbuddy, mcp-generic
11
+ Hosts: claude-code, codex, grok, qoder, antigravity, opencode, dsh, zcode,
12
+ kimi, stepcode, minimax, cursor, workbuddy, mcp-generic
12
13
  Default scope: user. dsh default profile: dsh-tui.
13
14
  --trust says you trust the plugin's hooks; only hosts that require it (grok) accept it.
14
15
  With no host, only a single discovered native host is selected; otherwise choose --host.
15
16
  Cursor, WorkBuddy and generic MCP return manual_required without writing client config.
17
+ Kimi Code, Step Code and ZCode install on Windows and macOS.
18
+ ZCode installs evolver-plugin@evomap from the evolver-agent-plugin ZCode marketplace
19
+ URL, after uninstalling an evolver-plugin@evolver-zcode-local install (data kept).
16
20
  Dry-run performs no download, host command or config write and proves no installed state.
17
21
  Installation uses EvoMap/evolver-agent-plugin and does not replace setup-hooks.
18
22
  Exit codes: 0 verified install/already-installed/list/preview; 2 action required
@@ -68,7 +72,7 @@ function installOptions(flags, runtime) {
68
72
  if (flags.host && !host)
69
73
  throw new PluginInstallError('invalid_arguments', 'Unknown plugin host. Use evolver plugin list to see supported entries.');
70
74
  if (!host) {
71
- const found = PLUGIN_HOSTS.filter(candidate => candidate.kind !== 'manual' && candidate.command && runtime.available(candidate.command));
75
+ const found = PLUGIN_HOSTS.filter(candidate => candidate.kind !== 'manual' && supportsPlatform(candidate, runtime) && hostLauncher(runtime, candidate));
72
76
  if (found.length !== 1)
73
77
  throw new PluginInstallError('selection_required', found.length === 0
74
78
  ? 'No native plugin host was found on PATH. Choose --host explicitly; plugin list includes manual entries.'
@@ -89,6 +93,8 @@ function installOptions(flags, runtime) {
89
93
  const profile = flags.profile ?? 'dsh-tui';
90
94
  if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(profile))
91
95
  throw new PluginInstallError('invalid_arguments', '--profile must be a simple dsh profile name, not a path or command.');
96
+ if (!supportsPlatform(host, runtime))
97
+ throw new PluginInstallError('unsupported_capability', `${host.label} plugin installation is supported on ${host.platforms.map(platformName).join(' and ')} only; this machine runs ${platformName(runtime.platform)}.`);
92
98
  let root = resolve(runtime.cwd, flags.root ?? '.');
93
99
  if (!flags.dryRun && host.kind !== 'manual') {
94
100
  try {
@@ -100,7 +106,13 @@ function installOptions(flags, runtime) {
100
106
  throw new PluginInstallError('invalid_arguments', '--root must identify an existing project/working directory.');
101
107
  }
102
108
  }
103
- return { host, scope: scope, root, profile, dryRun: flags.dryRun, trust: flags.trust };
109
+ const launcher = hostLauncher(runtime, host) ?? expectedHostLauncher(runtime, host);
110
+ return { host, scope: scope, root, profile, dryRun: flags.dryRun, trust: flags.trust, launcher };
111
+ }
112
+ const PLATFORM_NAMES = { win32: 'Windows', darwin: 'macOS', linux: 'Linux' };
113
+ const platformName = (platform) => PLATFORM_NAMES[platform] ?? platform;
114
+ function supportsPlatform(host, runtime) {
115
+ return !host.platforms || host.platforms.includes(runtime.platform);
104
116
  }
105
117
  export async function runPluginCommand(argv, deps = {}) {
106
118
  const stdout = deps.stdout ?? (text => { process.stdout.write(text); });
@@ -115,7 +127,7 @@ export async function runPluginCommand(argv, deps = {}) {
115
127
  return 0;
116
128
  }
117
129
  if (flags.action === 'list') {
118
- const hosts = PLUGIN_HOSTS.map(host => ({ id: host.id, label: host.label, mode: host.kind === 'manual' ? 'manual' : 'native', cli: host.command ?? null, cliFound: Boolean(host.command && runtime.available(host.command)), minimumVersion: host.minimumVersion ?? null, requiresTrust: Boolean(host.requiresTrust), scopes: host.scopes, instructions: host.instructions }));
130
+ const hosts = PLUGIN_HOSTS.map(host => ({ id: host.id, label: host.label, mode: host.kind === 'manual' ? 'manual' : 'native', cli: host.command ?? null, cliFound: Boolean(hostLauncher(runtime, host)), minimumVersion: host.minimumVersion ?? null, requiresTrust: Boolean(host.requiresTrust), scopes: host.scopes, platforms: host.platforms ?? null, instructions: host.instructions }));
119
131
  stdout(json ? `${JSON.stringify({ ok: true, action: 'list', hosts })}\n` : `${hosts.map(host => `${host.id.padEnd(14)} ${host.mode.padEnd(7)} ${host.cliFound ? 'CLI found' : 'CLI not found / not required'}; scopes=${host.scopes.join('|')}`).join('\n')}\nCLI detection is not installation or version verification.\n`);
120
132
  return 0;
121
133
  }
@@ -1,4 +1,6 @@
1
1
  import { type PluginHost } from './pluginHosts.js';
2
2
  import { type PluginRuntime } from './pluginRuntime.js';
3
3
  export declare function validatePackedBundle(bundle: string, host: PluginHost): void;
4
+ /** A host-registered folder is trusted only as a valid packed bundle inside a release checkout this installer owns. */
5
+ export declare function isManagedPackedBundle(runtime: PluginRuntime, host: PluginHost, folder: string): boolean;
4
6
  export declare function ensureAgentPluginBundle(runtime: PluginRuntime, host: PluginHost): Promise<string>;
@@ -1,8 +1,7 @@
1
1
  import { withOwnedPluginLock } from './pluginLock.js';
2
2
  import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { AGENT_PLUGIN_GIT_URL, AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY, AGENT_PLUGIN_RELEASE } from './pluginHosts.js';
5
- import { agentPluginRepositoryMatches } from './pluginInspection.js';
3
+ import { join, relative, sep } from 'node:path';
4
+ import { AGENT_PLUGIN_GIT_URL, AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY, AGENT_PLUGIN_RELEASE, agentPluginRepositoryMatches } from './pluginHosts.js';
6
5
  import { assertPluginManagedPath, checkedPluginCommand, pluginHome, PluginInstallError, readPluginJson, readPluginText } from './pluginRuntime.js';
7
6
  const RECEIPT = '.evolver-plugin-checkout.json';
8
7
  export function validatePackedBundle(bundle, host) {
@@ -10,15 +9,14 @@ export function validatePackedBundle(bundle, host) {
10
9
  if (root.isSymbolicLink() || !root.isDirectory())
11
10
  throw new PluginInstallError('failed', 'The plugin bundle root is not an ordinary owned directory.');
12
11
  const manifest = readPluginJson(join(bundle, host.manifest));
13
- const expectedName = host.id === 'opencode' ? '@evomap/evolver-opencode' : AGENT_PLUGIN_NAME;
12
+ const expectedName = host.packageName ?? AGENT_PLUGIN_NAME;
14
13
  if (readPluginText(join(bundle, '.evolver-packed'))?.trim() !== host.id || manifest?.['name'] !== expectedName || typeof manifest['version'] !== 'string') {
15
14
  throw new PluginInstallError('failed', `The release branch has no valid packed ${host.label} plugin. No host installation was attempted.`);
16
15
  }
17
16
  const repository = typeof manifest['repository'] === 'string' ? manifest['repository'] : manifest['repository']?.url;
18
17
  if (!agentPluginRepositoryMatches(repository))
19
18
  throw new PluginInstallError('failed', 'The packed plugin manifest identifies another repository.');
20
- const entries = host.id === 'opencode' ? ['server.mjs', 'tui.mjs'] : ['bin/hook.mjs', `hosts/${host.id}/profile.js`];
21
- if (entries.some(entry => readPluginText(join(bundle, entry)) === undefined))
19
+ if (host.entries.some(entry => readPluginText(join(bundle, entry)) === undefined))
22
20
  throw new PluginInstallError('failed', 'The packed plugin is missing an entry module.');
23
21
  const queue = [bundle];
24
22
  let count = 0;
@@ -34,8 +32,37 @@ export function validatePackedBundle(bundle, host) {
34
32
  }
35
33
  }
36
34
  }
35
+ function agentPluginCacheBase(runtime) {
36
+ return join(realpathSync(pluginHome(runtime)), '.evolver', 'plugins', 'evolver-agent-plugin');
37
+ }
38
+ /** A host-registered folder is trusted only as a valid packed bundle inside a release checkout this installer owns. */
39
+ export function isManagedPackedBundle(runtime, host, folder) {
40
+ try {
41
+ const parts = relative(agentPluginCacheBase(runtime), realpathSync(folder)).split(sep);
42
+ if (parts.length !== 4 || !/^[a-f0-9]{40}$/.test(parts[0]) || parts[1] !== host.id || parts[2] !== 'dist' || parts[3] !== host.id)
43
+ return false;
44
+ validatePackedBundle(folder, host);
45
+ return true;
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ /** `git status` must not run a command configured inside the cached checkout, so fsmonitor is forced off. */
52
+ async function assertPristineCheckout(runtime, checkout, commit) {
53
+ const git = ['-C', checkout, '-c', 'core.fsmonitor=false'];
54
+ const head = await checkedPluginCommand(runtime, 'git', [...git, 'rev-parse', 'HEAD']);
55
+ const changes = await checkedPluginCommand(runtime, 'git', [...git, 'status', '--porcelain', '--untracked-files=all', '--', '.', `:(exclude)${RECEIPT}`]);
56
+ if (head.stdout.trim() !== commit || changes.stdout.trim() !== '') {
57
+ throw new PluginInstallError('conflict', `The cached release checkout ${checkout} was modified after download; remove it and retry.`);
58
+ }
59
+ }
60
+ /** A script host's installer imports the checkout's scripts, shared lib and host adapters next to its packed folder. */
61
+ function checkoutPaths(host) {
62
+ return host.kind === 'script' ? [`dist/${host.id}`, 'scripts', 'lib', 'hosts'] : [`dist/${host.id}`];
63
+ }
37
64
  export async function ensureAgentPluginBundle(runtime, host) {
38
- if (host.kind !== 'bundle')
65
+ if (host.kind !== 'bundle' && host.kind !== 'script')
39
66
  throw new PluginInstallError('unsupported_capability', 'This host uses its native source installer, not the packed-checkout download path.');
40
67
  if (!runtime.available('git'))
41
68
  throw new PluginInstallError('host_missing', 'Git is required to fetch the packed plugin release.');
@@ -44,7 +71,7 @@ export async function ensureAgentPluginBundle(runtime, host) {
44
71
  if (matches.length !== 1)
45
72
  throw new PluginInstallError('failed', 'The plugin release branch did not resolve to one commit.');
46
73
  const commit = matches[0][1];
47
- const base = join(realpathSync(pluginHome(runtime)), '.evolver', 'plugins', 'evolver-agent-plugin');
74
+ const base = agentPluginCacheBase(runtime);
48
75
  assertPluginManagedPath(base);
49
76
  mkdirSync(base, { recursive: true, mode: 0o700 });
50
77
  const lockPath = join(base, `${host.id}.lock`);
@@ -60,6 +87,7 @@ export async function ensureAgentPluginBundle(runtime, host) {
60
87
  throw new PluginInstallError('conflict', 'The plugin cache directory is not an owned, matching release checkout.');
61
88
  }
62
89
  validatePackedBundle(join(checkout, 'dist', host.id), host);
90
+ await assertPristineCheckout(runtime, checkout, commit);
63
91
  return join(checkout, 'dist');
64
92
  }
65
93
  stage = mkdtempSync(join(base, `.${host.id}-`));
@@ -69,7 +97,7 @@ export async function ensureAgentPluginBundle(runtime, host) {
69
97
  const noHooks = join(stage, 'no-hooks');
70
98
  mkdirSync(noHooks, { mode: 0o700 });
71
99
  await checkedPluginCommand(runtime, 'git', ['-c', `core.hooksPath=${noHooks}`, 'clone', '--depth', '1', '--branch', AGENT_PLUGIN_RELEASE, '--filter=blob:none', '--sparse', AGENT_PLUGIN_GIT_URL, source], runtime.cwd, 120_000);
72
- await checkedPluginCommand(runtime, 'git', ['-C', source, '-c', `core.hooksPath=${noHooks}`, 'sparse-checkout', 'set', `dist/${host.id}`], runtime.cwd, 120_000);
100
+ await checkedPluginCommand(runtime, 'git', ['-C', source, '-c', `core.hooksPath=${noHooks}`, 'sparse-checkout', 'set', ...checkoutPaths(host)], runtime.cwd, 120_000);
73
101
  const head = await checkedPluginCommand(runtime, 'git', ['-C', source, 'rev-parse', 'HEAD']);
74
102
  if (head.stdout.trim() !== commit)
75
103
  throw new PluginInstallError('failed', 'The plugin release changed while downloading. Retry to use a consistent release.');
@@ -3,18 +3,30 @@ export declare const AGENT_PLUGIN_GIT_URL = "https://github.com/EvoMap/evolver-a
3
3
  export declare const AGENT_PLUGIN_NAME = "evolver-plugin";
4
4
  export declare const AGENT_PLUGIN_RELEASE = "release";
5
5
  export declare const DSH_PLUGIN_SOURCE = "github:EvoMap/evolver-agent-plugin#release&path:dist/dsh";
6
+ export declare const ZCODE_LOCAL_MARKETPLACE = "evolver-zcode-local";
7
+ export declare function agentPluginRepositoryMatches(value: unknown): boolean;
6
8
  export type PluginScope = 'user' | 'project';
7
- type PluginHostId = 'claude-code' | 'codex' | 'grok' | 'qoder' | 'antigravity' | 'opencode' | 'dsh' | 'cursor' | 'workbuddy' | 'mcp-generic';
9
+ type PluginHostId = 'claude-code' | 'codex' | 'grok' | 'qoder' | 'antigravity' | 'opencode' | 'dsh' | 'zcode' | 'kimi' | 'stepcode' | 'minimax' | 'cursor' | 'workbuddy' | 'mcp-generic';
8
10
  export interface PluginHost {
9
11
  id: PluginHostId;
10
12
  label: string;
11
13
  command?: string;
12
14
  minimumVersion?: string;
13
- kind: 'marketplace' | 'bundle' | 'profile' | 'manual';
15
+ /** `script` runs the release checkout's own installer for the host. */
16
+ kind: 'marketplace' | 'bundle' | 'script' | 'profile' | 'manual';
14
17
  scopes: readonly PluginScope[];
18
+ /** Hosts whose adapter is accepted only on these platforms. */
19
+ platforms?: readonly NodeJS.Platform[];
15
20
  management?: 'plugin' | 'plugins';
16
21
  marketplace?: string;
22
+ /** What `marketplace add` registers when it is not the plugin repository itself. */
23
+ marketplaceSource?: string;
17
24
  manifest?: string;
25
+ packageName?: string;
26
+ /** Files an installed (and packed) plugin must contain besides its manifest. */
27
+ entries: readonly string[];
28
+ /** The release checkout's installer, for `script` hosts. */
29
+ installer?: string;
18
30
  /** Where the packed plugin sits inside the checkout path the host's inventory reports. */
19
31
  packedSubdir?: string;
20
32
  /** The host's installer refuses to install hooks/MCP/skills until the user passes its trust flag. */
@@ -31,6 +43,8 @@ export interface PluginInstallOptions {
31
43
  profile: string;
32
44
  dryRun: boolean;
33
45
  trust: boolean;
46
+ /** The host CLI's argv prefix: its command, or node plus a CLI script for hosts that ship one. */
47
+ launcher: readonly string[];
34
48
  }
35
49
  export interface PluginCommandStep {
36
50
  name: string;
@@ -1,49 +1,91 @@
1
+ import { dirname, join } from 'node:path';
1
2
  export const AGENT_PLUGIN_REPOSITORY = 'EvoMap/evolver-agent-plugin';
2
3
  export const AGENT_PLUGIN_GIT_URL = `https://github.com/${AGENT_PLUGIN_REPOSITORY}.git`;
3
4
  export const AGENT_PLUGIN_NAME = 'evolver-plugin';
4
5
  export const AGENT_PLUGIN_RELEASE = 'release';
5
6
  export const DSH_PLUGIN_SOURCE = `github:${AGENT_PLUGIN_REPOSITORY}#${AGENT_PLUGIN_RELEASE}&path:dist/dsh`;
7
+ /** ZCode resolves a repository marketplace from `.claude-plugin/marketplace.json` first, so it gets its own manifest by URL. */
8
+ const ZCODE_MARKETPLACE_URL = `https://raw.githubusercontent.com/${AGENT_PLUGIN_REPOSITORY}/main/.zcode-plugin/marketplace.json`;
9
+ export const ZCODE_LOCAL_MARKETPLACE = 'evolver-zcode-local';
10
+ export function agentPluginRepositoryMatches(value) {
11
+ if (typeof value !== 'string')
12
+ return false;
13
+ const source = value.trim().toLowerCase().replace(/^git\+/, '').replace(/^git@github\.com:/, 'https://github.com/').replace(/^ssh:\/\/git@github\.com\//, 'https://github.com/').replace(/\/$/, '').replace(/\.git$/, '');
14
+ return source === AGENT_PLUGIN_GIT_URL.toLowerCase().replace(/\.git$/, '') || source === AGENT_PLUGIN_REPOSITORY.toLowerCase();
15
+ }
6
16
  export const PLUGIN_HOSTS = [
7
17
  {
8
18
  id: 'claude-code', label: 'Claude Code', command: 'claude', minimumVersion: '2.1.286',
9
19
  kind: 'marketplace', management: 'plugin', marketplace: 'evolver-agent-plugin',
10
- scopes: ['user', 'project'], manifest: '.claude-plugin/plugin.json',
20
+ scopes: ['user', 'project'], manifest: '.claude-plugin/plugin.json', entries: ['hooks/hooks.json', 'hooks/register.ts', 'bin/relay.mjs'],
11
21
  legacyNames: ['evolver', 'evolver-mods', 'evolver-agent-plugin'],
12
22
  instructions: ['Restart Claude Code. Installed hooks modules also require the host rollout flag; an installed plugin is not proof that recall is active.'],
13
23
  },
14
24
  {
15
25
  id: 'codex', label: 'Codex', command: 'codex', minimumVersion: '0.164.0', kind: 'marketplace', management: 'plugin', marketplace: 'evomap',
16
- scopes: ['user'], manifest: '.codex-plugin/plugin.json', legacyNames: ['evolver'],
26
+ scopes: ['user'], manifest: '.codex-plugin/plugin.json', entries: ['hooks/hooks.json', 'bin/hook.mjs'], legacyNames: ['evolver'],
17
27
  instructions: ['Open /hooks in Codex, review and trust the Evolver hooks, then start a new thread.'],
18
28
  },
19
29
  {
20
30
  id: 'grok', label: 'Grok CLI', command: 'grok', minimumVersion: '1.0.70',
21
- kind: 'marketplace', management: 'plugin', marketplace: 'evolver-agent-plugin', scopes: ['user'], manifest: '.grok-plugin/plugin.json',
31
+ kind: 'marketplace', management: 'plugin', marketplace: 'evolver-agent-plugin', scopes: ['user'], manifest: '.grok-plugin/plugin.json', entries: ['hooks/hooks.json', 'bin/hook.mjs'],
22
32
  packedSubdir: 'dist/grok', requiresTrust: true, legacyNames: ['evolver', 'evolver-grok-plugin'],
23
33
  instructions: ['Restart Grok and review its hook trust settings. Recall reaches the first tool result; a turn without tools receives no strategy.'],
24
34
  },
25
35
  {
26
36
  id: 'qoder', label: 'Qoder CLI', command: 'qodercli', minimumVersion: '1.1.79',
27
- kind: 'marketplace', management: 'plugins', marketplace: 'evomap', scopes: ['user'], manifest: '.qoder-plugin/plugin.json',
37
+ kind: 'marketplace', management: 'plugins', marketplace: 'evomap', scopes: ['user'], manifest: '.qoder-plugin/plugin.json', entries: ['hooks/hooks.json', 'bin/hook.mjs'],
28
38
  legacyNames: ['evolver', 'evolver-qoder-plugin'], instructions: ['Start a new Qoder session or run /plugins reload.'],
29
39
  },
30
40
  {
31
41
  id: 'antigravity', label: 'Antigravity', command: 'agy', kind: 'bundle', management: 'plugin',
32
- scopes: ['user'], manifest: 'plugin.json', legacyNames: ['evolver-antigravity-plugin'],
42
+ scopes: ['user'], manifest: 'plugin.json', entries: ['hooks.json', 'bin/hook.mjs'], legacyNames: ['evolver-antigravity-plugin'],
33
43
  instructions: ['Restart Antigravity. Its commands run from the installed plugin with node bin/command.mjs antigravity <command>.'],
34
44
  },
35
45
  {
36
46
  id: 'opencode', label: 'OpenCode', command: 'opencode', minimumVersion: '1.19.4', kind: 'bundle',
37
- scopes: ['user', 'project'], manifest: 'package.json', legacyNames: ['evolver-opencode-plugin'],
47
+ scopes: ['user', 'project'], manifest: 'package.json', packageName: '@evomap/evolver-opencode', entries: ['server.mjs', 'tui.mjs'],
48
+ legacyNames: ['evolver-opencode-plugin'],
38
49
  instructions: ['Restart OpenCode. Both the server entry in opencode.json and the TUI entry in tui.json must be registered.'],
39
50
  },
40
51
  {
41
52
  id: 'dsh', label: 'DeepSeek Harness', command: 'dsh', minimumVersion: '0.1.5', kind: 'profile',
42
- scopes: ['user'], manifest: 'package.json', legacyNames: ['@evomap/dsh-evolver'],
53
+ scopes: ['user'], manifest: 'package.json', packageName: '@evomap/dsh-evolver', entries: ['plugin.mjs'], legacyNames: ['@evomap/dsh-evolver'],
43
54
  instructions: ['Restart dsh. Installation applies only to the selected profile; repeat for other profiles. DSH Desktop requires its own bundled CLI/profile.'],
44
55
  },
45
56
  {
46
- id: 'cursor', label: 'Cursor', command: 'cursor-agent', kind: 'manual', scopes: ['user'],
57
+ id: 'zcode', label: 'ZCode', command: 'zcode', kind: 'marketplace', management: 'plugins', marketplace: 'evomap', marketplaceSource: ZCODE_MARKETPLACE_URL,
58
+ scopes: ['user'], platforms: ['win32', 'darwin'], manifest: '.zcode-plugin/plugin.json', entries: ['hooks/hooks.json', 'bin/hook.mjs'], legacyNames: [],
59
+ instructions: [
60
+ 'Start a new ZCode session. ZCode CLI and Desktop share this installation; plugins and hooks must be enabled in ZCode.',
61
+ 'Evolver runs the CLI shipped with ZCode Desktop, or the standalone zcode.cjs named by ZCODE_CLI_PATH.',
62
+ `The evomap marketplace is ${ZCODE_MARKETPLACE_URL}; plugins update evolver-plugin@evomap follows each release.`,
63
+ `An evolver-plugin@${ZCODE_LOCAL_MARKETPLACE} install is uninstalled first, keeping its data, so hooks do not run twice; its marketplace is removed only when it points into Evolver's release cache.`,
64
+ ],
65
+ },
66
+ {
67
+ id: 'kimi', label: 'Kimi Code', command: 'kimi', kind: 'script', installer: 'scripts/install-kimi.mjs',
68
+ scopes: ['user'], platforms: ['win32', 'darwin'], manifest: 'kimi.plugin.json', entries: ['bin/hook.mjs'], legacyNames: [],
69
+ instructions: [
70
+ 'Close Kimi Code before installing or updating, then start a new CLI or Desktop session.',
71
+ 'KIMI_CODE_HOME selects the profile root; start Kimi with the same value.',
72
+ ],
73
+ },
74
+ {
75
+ id: 'stepcode', label: 'Step Code', command: 'step', kind: 'bundle', scopes: ['user'], platforms: ['win32', 'darwin'],
76
+ manifest: 'package.json', packageName: '@evomap/stepcode-evolver', entries: ['plugin.mjs'], legacyNames: [],
77
+ instructions: ['Start a new Step Code session. The adapter is verified with Step Code CLI 0.1.7 on Windows and macOS; STEP_CODING_AGENT_DIR selects the profile.'],
78
+ },
79
+ {
80
+ id: 'minimax', label: 'MiniMax Code', command: 'mcode', kind: 'script', installer: 'scripts/install-minimax.mjs',
81
+ scopes: ['user'], manifest: '.minimax-plugin/plugin.json', entries: ['hooks/hooks.json', 'bin/hook.mjs'], legacyNames: [],
82
+ instructions: [
83
+ 'Start a new MiniMax task. MINIMAX_DATA_DIR selects the data root; keep it the same for mcode.',
84
+ 'To pause the plugin: mcode plugin disable evolver-plugin@local --json',
85
+ ],
86
+ },
87
+ {
88
+ id: 'cursor', label: 'Cursor', command: 'cursor-agent', kind: 'manual', scopes: ['user'], entries: [],
47
89
  legacyNames: ['evolver-cursor-plugin'],
48
90
  instructions: [
49
91
  `In Cursor's plugin marketplace, add ${AGENT_PLUGIN_REPOSITORY} and install evolver-plugin.`,
@@ -52,7 +94,7 @@ export const PLUGIN_HOSTS = [
52
94
  ],
53
95
  },
54
96
  {
55
- id: 'workbuddy', label: 'WorkBuddy / CodeBuddy', command: 'codebuddy', kind: 'manual', scopes: ['user', 'project'],
97
+ id: 'workbuddy', label: 'WorkBuddy / CodeBuddy', command: 'codebuddy', kind: 'manual', scopes: ['user', 'project'], entries: [],
56
98
  legacyNames: ['evolver'],
57
99
  instructions: [
58
100
  'In WorkBuddy, if the standalone plugin is installed: /plugin uninstall evolver@evomap-workbuddy --keep-data (repeat with --scope project where applicable).',
@@ -63,7 +105,7 @@ export const PLUGIN_HOSTS = [
63
105
  ],
64
106
  },
65
107
  {
66
- id: 'mcp-generic', label: 'Generic MCP client', kind: 'manual', scopes: ['user'], legacyNames: [],
108
+ id: 'mcp-generic', label: 'Generic MCP client', kind: 'manual', scopes: ['user'], entries: [], legacyNames: [],
67
109
  instructions: [
68
110
  `git clone --depth 1 --branch release ${AGENT_PLUGIN_GIT_URL}`,
69
111
  'In that checkout, run npm ci; the stdio server requires the MCP SDK.',
@@ -73,36 +115,45 @@ export const PLUGIN_HOSTS = [
73
115
  },
74
116
  ];
75
117
  export function pluginHostNamed(name) {
76
- const aliases = { claude: 'claude-code', codebuddy: 'workbuddy', 'deepseek-harness': 'dsh', mcp: 'mcp-generic' };
118
+ const aliases = {
119
+ claude: 'claude-code', codebuddy: 'workbuddy', 'deepseek-harness': 'dsh', mcp: 'mcp-generic', 'kimi-code': 'kimi', step: 'stepcode', mcode: 'minimax',
120
+ };
77
121
  return PLUGIN_HOSTS.find(host => host.id === (aliases[name] ?? name));
78
122
  }
123
+ function marketplaceInstallSteps({ host, scope, trust }, step) {
124
+ const management = host.management;
125
+ const selector = host.id === 'grok' ? AGENT_PLUGIN_NAME : `${AGENT_PLUGIN_NAME}@${host.marketplace}`;
126
+ const scoped = host.id === 'claude-code' || host.id === 'zcode';
127
+ const install = host.id === 'codex'
128
+ ? [management, 'add', selector, '--json']
129
+ : [management, 'install', selector, ...(scoped ? ['--scope', scope, '--json'] : []), ...(host.requiresTrust && trust ? ['--trust'] : [])];
130
+ return [step('marketplace', [management, 'marketplace', 'add', host.marketplaceSource ?? AGENT_PLUGIN_REPOSITORY]), step('install', install)];
131
+ }
132
+ function scriptInstallSteps(host, bundle, step) {
133
+ const installer = { name: 'install', command: 'node', args: [join(dirname(bundle), host.installer), 'install'] };
134
+ return host.id === 'minimax' ? [installer, step('enable', ['plugin', 'enable', `${AGENT_PLUGIN_NAME}@local`, '--json'])] : [installer];
135
+ }
79
136
  export function pluginInstallSteps(options, bundle = '<release-checkout>/dist') {
80
- const { host, scope, profile, trust } = options;
81
- const command = host.command ?? '';
82
- if (host.kind === 'marketplace') {
83
- const management = host.management;
84
- const selector = host.id === 'grok' ? AGENT_PLUGIN_NAME : `${AGENT_PLUGIN_NAME}@${host.marketplace}`;
85
- const add = [management, 'marketplace', 'add', AGENT_PLUGIN_REPOSITORY];
86
- const install = host.id === 'codex'
87
- ? [management, 'add', selector, '--json']
88
- : [management, 'install', selector, ...(host.id === 'claude-code' ? ['--scope', scope, '--json'] : []), ...(host.requiresTrust && trust ? ['--trust'] : [])];
89
- return [
90
- { name: 'marketplace', command, args: add },
91
- { name: 'install', command, args: install },
92
- ];
93
- }
137
+ const { host, scope, profile } = options;
138
+ const [command = '', ...prefix] = options.launcher;
139
+ const step = (name, args) => ({ name, command, args: [...prefix, ...args] });
140
+ if (host.kind === 'marketplace')
141
+ return marketplaceInstallSteps(options, step);
142
+ if (host.kind === 'script')
143
+ return scriptInstallSteps(host, bundle, step);
94
144
  if (host.id === 'antigravity')
95
- return [{ name: 'install', command, args: ['plugin', 'install', `${bundle}/antigravity`] }];
145
+ return [step('install', ['plugin', 'install', `${bundle}/antigravity`])];
96
146
  if (host.id === 'opencode')
97
- return [{ name: 'install', command, args: ['plugin', `${bundle}/opencode`, ...(scope === 'user' ? ['-g'] : [])] }];
147
+ return [step('install', ['plugin', `${bundle}/opencode`, ...(scope === 'user' ? ['-g'] : [])])];
148
+ if (host.id === 'stepcode')
149
+ return [step('install', ['install', join(bundle, 'stepcode')])];
98
150
  if (host.id === 'dsh')
99
- return [{
100
- name: 'install', command, args: ['plugin', '--profile', profile, 'add', '-w', DSH_PLUGIN_SOURCE],
101
- }];
151
+ return [step('install', ['plugin', '--profile', profile, 'add', '-w', DSH_PLUGIN_SOURCE])];
102
152
  return [];
103
153
  }
104
- export function pluginRollbackInstructions(options, bundle) {
154
+ export function pluginRollbackInstructions(options, bundle = '<release-checkout>/dist') {
105
155
  const { host, scope, profile } = options;
156
+ const cli = options.launcher.map(part => (/\s/.test(part) ? JSON.stringify(part) : part)).join(' ');
106
157
  if (host.id === 'claude-code')
107
158
  return [`claude plugin uninstall ${AGENT_PLUGIN_NAME}@${host.marketplace} --scope ${scope} --keep-data`];
108
159
  if (host.id === 'codex')
@@ -116,7 +167,15 @@ export function pluginRollbackInstructions(options, bundle) {
116
167
  if (host.id === 'dsh')
117
168
  return [`dsh plugin --profile ${profile} remove @evomap/dsh-evolver`];
118
169
  if (host.id === 'opencode')
119
- return [`Remove only this plugin's ${bundle ?? '<installed-bundle>'}/opencode/server.mjs and tui.mjs entries from opencode.json and tui.json; preserve neighboring configuration.`];
170
+ return [`Remove only this plugin's ${bundle}/opencode/server.mjs and tui.mjs entries from opencode.json and tui.json; preserve neighboring configuration.`];
171
+ if (host.id === 'zcode')
172
+ return [`${cli} plugins uninstall ${AGENT_PLUGIN_NAME}@${host.marketplace} --scope ${scope} --keep-data`, `${cli} plugins marketplace remove ${host.marketplace}`];
173
+ if (host.id === 'kimi')
174
+ return [`node ${join(dirname(bundle), host.installer)} remove`];
175
+ if (host.id === 'stepcode')
176
+ return [`step remove ${join(bundle, 'stepcode')}`];
177
+ if (host.id === 'minimax')
178
+ return [`mcode plugin remove ${AGENT_PLUGIN_NAME}@local --json`];
120
179
  return [];
121
180
  }
122
181
  const SHELL_SAFE_ARGUMENT = /^[A-Za-z0-9@._/][A-Za-z0-9@._/-]*$/;
@@ -1,4 +1,5 @@
1
1
  import { type PluginInstallOptions, type PluginHost } from './pluginHosts.js';
2
+ import { type ZcodeLocalInstall } from './pluginZcodeMigration.js';
2
3
  import { type PluginRuntime } from './pluginRuntime.js';
3
4
  export interface InstalledAgentPlugin {
4
5
  id: string;
@@ -16,9 +17,10 @@ export interface PluginInspection {
16
17
  conflicts: string[];
17
18
  /** Native commands the user can run to remove a conflicting standalone plugin; never run automatically. */
18
19
  migrations: string[];
20
+ zcodeLocal?: ZcodeLocalInstall;
19
21
  }
20
22
  export declare function installedPluginsFromJson(value: unknown, host: PluginHost): InstalledAgentPlugin[];
21
- export declare function agentPluginRepositoryMatches(value: unknown): boolean;
22
23
  export declare function verifyPluginManifest(runtime: PluginRuntime, options: PluginInstallOptions, plugin: InstalledAgentPlugin, installAnswer?: unknown): string;
23
24
  export declare function inspectOpenCodePlugin(runtime: PluginRuntime, options: PluginInstallOptions): PluginInspection;
24
- export declare function inspectAgentPlugin(runtime: PluginRuntime, options: PluginInstallOptions): Promise<PluginInspection>;
25
+ /** `bundle` is the release checkout's dist folder, which a `script` host's own status command needs. */
26
+ export declare function inspectAgentPlugin(runtime: PluginRuntime, options: PluginInstallOptions, bundle?: string): Promise<PluginInspection>;
@@ -2,7 +2,9 @@ import { resolveOpenCodeConfig } from '@evomap/evolver-mcp';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { dirname, join, resolve } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
- import { AGENT_PLUGIN_GIT_URL, AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY, standalonePluginRemoval } from './pluginHosts.js';
5
+ import { agentPluginRepositoryMatches, AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY, standalonePluginRemoval } from './pluginHosts.js';
6
+ import { inspectScriptPlugin, inspectStepCodePlugin } from './pluginLocalInspection.js';
7
+ import { zcodeLocalInstall } from './pluginZcodeMigration.js';
6
8
  import { checkedPluginCommand, objectOf, pluginHome, pluginJson, pluginVersionAtLeast, PluginInstallError, readPluginJson, readPluginText } from './pluginRuntime.js';
7
9
  function listRecords(value, key, label) {
8
10
  const list = Array.isArray(value) ? value : objectOf(value)?.[key];
@@ -21,16 +23,10 @@ export function installedPluginsFromJson(value, host) {
21
23
  throw new PluginInstallError('unsupported_capability', `${host.label} plugin list has an unnamed entry.`);
22
24
  return {
23
25
  id, name, version: stringOf(raw['version']) ?? '', enabled: raw['enabled'] !== false,
24
- scope: stringOf(raw['scope']), path: stringOf(raw['installPath']) ?? stringOf(raw['installedPath']) ?? stringOf(raw['path']), raw,
26
+ scope: stringOf(raw['scope']), path: stringOf(raw['installPath']) ?? stringOf(raw['installedPath']) ?? stringOf(raw['rootPath']) ?? stringOf(raw['path']), raw,
25
27
  };
26
28
  });
27
29
  }
28
- export function agentPluginRepositoryMatches(value) {
29
- if (typeof value !== 'string')
30
- return false;
31
- const source = value.trim().toLowerCase().replace(/^git\+/, '').replace(/^git@github\.com:/, 'https://github.com/').replace(/^ssh:\/\/git@github\.com\//, 'https://github.com/').replace(/\/$/, '').replace(/\.git$/, '');
32
- return source === AGENT_PLUGIN_GIT_URL.toLowerCase().replace(/\.git$/, '') || source === AGENT_PLUGIN_REPOSITORY.toLowerCase();
33
- }
34
30
  function packageRepositoryOf(value) {
35
31
  return typeof value === 'string' ? value : objectOf(value)?.['url'];
36
32
  }
@@ -38,7 +34,9 @@ function repositoryOf(record) {
38
34
  return record['repo'] ?? objectOf(record['marketplaceSource'])?.['source']
39
35
  ?? objectOf(record['source'])?.['url'] ?? (typeof record['source'] === 'string' ? record['source'] : undefined);
40
36
  }
41
- async function marketplaceMatches(runtime, record) {
37
+ async function marketplaceMatches(runtime, host, record) {
38
+ if (host.marketplaceSource)
39
+ return objectOf(record['source'])?.['url'] === host.marketplaceSource;
42
40
  if (agentPluginRepositoryMatches(repositoryOf(record)))
43
41
  return true;
44
42
  const root = stringOf(record['root']) ?? stringOf(record['installLocation']);
@@ -85,21 +83,23 @@ function hasForeignInstalledScope(plugin, scope) {
85
83
  async function inspectMarketplacePlugin(runtime, options) {
86
84
  const { host, scope } = options;
87
85
  const management = host.management;
88
- const pluginResult = await checkedPluginCommand(runtime, host.command, [management, 'list', '--json'], options.root);
86
+ const [command, ...prefix] = options.launcher;
87
+ const pluginResult = await checkedPluginCommand(runtime, command, [...prefix, management, 'list', '--json'], options.root);
89
88
  const plugins = installedPluginsFromJson(pluginJson(pluginResult.stdout, `${host.label} plugin list`), host);
90
- const marketResult = await checkedPluginCommand(runtime, host.command, [management, 'marketplace', 'list', '--json'], options.root);
89
+ const marketResult = await checkedPluginCommand(runtime, command, [...prefix, management, 'marketplace', 'list', '--json'], options.root);
91
90
  const markets = listRecords(pluginJson(marketResult.stdout, `${host.label} marketplace list`), 'marketplaces', `${host.label} marketplace list`);
92
91
  const market = markets.find(record => record['name'] === host.marketplace);
93
92
  const conflicts = oldHookConflicts(runtime, options);
94
93
  const migrations = [];
95
- if (market && !await marketplaceMatches(runtime, market))
96
- conflicts.push(`Marketplace ${host.marketplace} belongs to another source. Review its plugins before replacing it with ${AGENT_PLUGIN_REPOSITORY}.`);
94
+ const zcodeLocal = host.id === 'zcode' ? zcodeLocalInstall(runtime, host, plugins.map(plugin => plugin.id), markets) : undefined;
95
+ if (market && !await marketplaceMatches(runtime, host, market))
96
+ conflicts.push(`Marketplace ${host.marketplace} belongs to another source. Review its plugins before replacing it with ${host.marketplaceSource ?? AGENT_PLUGIN_REPOSITORY}.`);
97
97
  for (const plugin of plugins) {
98
98
  if (host.legacyNames.includes(plugin.name) && plugin.enabled) {
99
99
  conflicts.push(`The standalone ${plugin.name} plugin is enabled. Disable/remove it using ${host.label}, keeping its data, before installing ${AGENT_PLUGIN_NAME}.`);
100
100
  migrations.push(standalonePluginRemoval(options, plugin));
101
101
  }
102
- if (plugin.name === AGENT_PLUGIN_NAME && plugin.id !== `${AGENT_PLUGIN_NAME}@${host.marketplace}` && !(host.id === 'grok' && plugin.id === AGENT_PLUGIN_NAME))
102
+ if (plugin.name === AGENT_PLUGIN_NAME && plugin.id !== `${AGENT_PLUGIN_NAME}@${host.marketplace}` && plugin.id !== zcodeLocal?.uninstall && !(host.id === 'grok' && plugin.id === AGENT_PLUGIN_NAME))
103
103
  conflicts.push('An Evolver plugin from another marketplace is registered; review that installation before continuing.');
104
104
  }
105
105
  const installed = plugins.find(plugin => (plugin.id === `${AGENT_PLUGIN_NAME}@${host.marketplace}` || (host.id === 'grok' && plugin.id === AGENT_PLUGIN_NAME)) && (host.id !== 'claude-code' || plugin.scope === scope));
@@ -109,7 +109,7 @@ async function inspectMarketplacePlugin(runtime, options) {
109
109
  conflicts.push('The plugin is installed but disabled. Enable it explicitly in the host rather than installing another copy.');
110
110
  if (installed && host.id === 'codex' && !agentPluginRepositoryMatches(repositoryOf(installed.raw)))
111
111
  conflicts.push('The installed plugin source does not match the unified Evolver plugin repository.');
112
- return { installed, marketplacePresent: Boolean(market), conflicts, migrations };
112
+ return { installed, marketplacePresent: Boolean(market), conflicts, migrations, zcodeLocal };
113
113
  }
114
114
  export function verifyPluginManifest(runtime, options, plugin, installAnswer) {
115
115
  const { host } = options;
@@ -122,8 +122,7 @@ export function verifyPluginManifest(runtime, options, plugin, installAnswer) {
122
122
  if (!path || !host.manifest)
123
123
  throw new PluginInstallError('failed', 'The host did not identify a verifiable installed plugin directory.');
124
124
  const manifest = readPluginJson(join(path, host.manifest));
125
- const expectedName = host.id === 'opencode' ? '@evomap/evolver-opencode' : host.id === 'dsh' ? '@evomap/dsh-evolver' : AGENT_PLUGIN_NAME;
126
- if (!manifest || manifest['name'] !== expectedName || manifest['version'] !== plugin.version) {
125
+ if (!manifest || manifest['name'] !== (host.packageName ?? AGENT_PLUGIN_NAME) || manifest['version'] !== plugin.version) {
127
126
  throw new PluginInstallError('failed', 'The host registration and installed plugin manifest do not agree; installation was not confirmed.');
128
127
  }
129
128
  const repository = packageRepositoryOf(manifest?.['repository']);
@@ -131,8 +130,7 @@ export function verifyPluginManifest(runtime, options, plugin, installAnswer) {
131
130
  throw new PluginInstallError('conflict', 'The installed plugin manifest does not identify the unified Evolver plugin source.');
132
131
  if (readPluginText(join(path, '.evolver-packed'))?.trim() !== host.id)
133
132
  throw new PluginInstallError('failed', 'The installed plugin is not the packed artifact for the selected host.');
134
- const entries = host.id === 'opencode' ? ['server.mjs', 'tui.mjs'] : host.id === 'dsh' ? ['plugin.mjs'] : host.id === 'antigravity' ? ['hooks.json', 'bin/hook.mjs'] : host.id === 'claude-code' ? ['hooks/hooks.json', 'hooks/register.ts', 'bin/relay.mjs'] : ['hooks/hooks.json', 'bin/hook.mjs'];
135
- if (entries.some(entry => !existsSync(join(path, entry))))
133
+ if (host.entries.some(entry => !existsSync(join(path, entry))))
136
134
  throw new PluginInstallError('failed', 'The installed plugin is missing its hook/plugin entry files.');
137
135
  return path;
138
136
  }
@@ -227,14 +225,20 @@ function inspectDshPlugin(runtime, options) {
227
225
  ? { id: AGENT_PLUGIN_NAME, name: AGENT_PLUGIN_NAME, version: manifest['version'], enabled: true, path, raw: manifest } : undefined;
228
226
  return { installed, marketplacePresent: false, conflicts, migrations };
229
227
  }
230
- export async function inspectAgentPlugin(runtime, options) {
231
- if (options.host.kind === 'marketplace')
228
+ /** `bundle` is the release checkout's dist folder, which a `script` host's own status command needs. */
229
+ export async function inspectAgentPlugin(runtime, options, bundle) {
230
+ if (options.host.marketplace)
232
231
  return inspectMarketplacePlugin(runtime, options);
232
+ if (options.host.kind === 'script')
233
+ return inspectScriptPlugin(runtime, options, bundle);
234
+ if (options.host.id === 'stepcode')
235
+ return inspectStepCodePlugin(runtime, options);
233
236
  if (options.host.id === 'opencode')
234
237
  return inspectOpenCodePlugin(runtime, options);
235
238
  if (options.host.id === 'dsh')
236
239
  return inspectDshPlugin(runtime, options);
237
- const result = await checkedPluginCommand(runtime, options.host.command, ['plugin', 'list', '--json'], options.root);
240
+ const [command, ...prefix] = options.launcher;
241
+ const result = await checkedPluginCommand(runtime, command, [...prefix, 'plugin', 'list', '--json'], options.root);
238
242
  const plugins = installedPluginsFromJson(pluginJson(result.stdout, 'Antigravity plugin list'), options.host);
239
243
  const installed = plugins.find(plugin => plugin.name === AGENT_PLUGIN_NAME);
240
244
  const standalone = plugins.filter(plugin => options.host.legacyNames.includes(plugin.name) && plugin.enabled);
@@ -1,5 +1,6 @@
1
1
  import { type PluginCommandStep, type PluginInstallOptions } from './pluginHosts.js';
2
2
  import { type PluginInstallStatus, type PluginRuntime } from './pluginRuntime.js';
3
+ import { type ZcodeMigrationReport } from './pluginZcodeMigration.js';
3
4
  export interface AgentPluginInstallResult {
4
5
  ok: boolean;
5
6
  status: PluginInstallStatus;
@@ -16,5 +17,7 @@ export interface AgentPluginInstallResult {
16
17
  installedPath?: string;
17
18
  error?: string;
18
19
  profile?: string;
20
+ migrated?: ZcodeMigrationReport;
21
+ warnings?: string[];
19
22
  }
20
23
  export declare function installAgentPlugin(runtime: PluginRuntime, options: PluginInstallOptions): Promise<AgentPluginInstallResult>;
@@ -2,15 +2,74 @@ import { ensureAgentPluginBundle } from './pluginBundle.js';
2
2
  import { assertDshProfileStoreMatches } from './pluginDshStore.js';
3
3
  import { AGENT_PLUGIN_NAME, AGENT_PLUGIN_REPOSITORY, pluginInstallSteps, pluginRollbackInstructions } from './pluginHosts.js';
4
4
  import { inspectAgentPlugin, verifyPluginManifest } from './pluginInspection.js';
5
+ import { hostLauncher } from './pluginLauncher.js';
5
6
  import { withPluginInstallLock } from './pluginLock.js';
6
7
  import { checkedPluginCommand, checkPluginHostVersion, PluginInstallError } from './pluginRuntime.js';
8
+ import { ZCODE_LOCAL_PLUGIN, ZCODE_MIGRATION_PREVIEW, ZCODE_MIGRATION_PREVIEW_NOTE, zcodeKeptMarketplaceWarning, zcodeMigrationPending, zcodeMigrationReport, zcodeMigrationSteps } from './pluginZcodeMigration.js';
7
9
  function trustInstruction(host) {
8
10
  return `${host.label} asks you to trust a plugin before it installs. Review ${AGENT_PLUGIN_REPOSITORY}, then rerun with --trust: evolver plugin install --host ${host.id} --trust`;
9
11
  }
12
+ async function useReleaseCheckout(runtime, options, result) {
13
+ const bundle = await ensureAgentPluginBundle(runtime, options.host);
14
+ result.completed.push('download');
15
+ result.commands = pluginInstallSteps(options, bundle);
16
+ result.rollback = pluginRollbackInstructions(options, bundle);
17
+ return bundle;
18
+ }
10
19
  function assertNoConflicts(inspection) {
11
20
  if (inspection.conflicts.length > 0)
12
21
  throw new PluginInstallError('conflict', inspection.conflicts.join('\n'), inspection.migrations);
13
22
  }
23
+ function dryRunResult(options, result, trustMissing) {
24
+ const { host } = options;
25
+ const zcode = host.id === 'zcode';
26
+ const commands = zcode ? [...zcodeMigrationSteps(options, ZCODE_MIGRATION_PREVIEW), ...result.commands] : result.commands;
27
+ const notes = [...(zcode ? [ZCODE_MIGRATION_PREVIEW_NOTE] : []), ...(trustMissing ? [trustInstruction(host)] : [])];
28
+ return { ...result, ok: true, status: 'dry_run', commands, instructions: [...result.instructions, ...notes, 'Preview only: host version, registration, download and installation have not been executed.'] };
29
+ }
30
+ function alreadyInstalled(runtime, options, result, inspection) {
31
+ if (!inspection.installed || zcodeMigrationPending(inspection.zcodeLocal))
32
+ return undefined;
33
+ const installedPath = verifyPluginManifest(runtime, options, inspection.installed);
34
+ const warnings = zcodeKeptMarketplaceWarning(inspection.zcodeLocal);
35
+ return { ...result, ok: true, status: 'already_installed', verified: true, version: inspection.installed.version, installedPath, commands: [], ...(warnings.length > 0 && { warnings }) };
36
+ }
37
+ function plannedCommands(options, inspection, install) {
38
+ if (!zcodeMigrationPending(inspection.zcodeLocal))
39
+ return install;
40
+ return [...zcodeMigrationSteps(options, inspection.zcodeLocal), ...(inspection.installed ? [] : install)];
41
+ }
42
+ async function runPlannedCommands(runtime, options, result, inspection, bundle) {
43
+ let installAnswer;
44
+ for (const step of result.commands) {
45
+ if (step.name === 'marketplace' && inspection.marketplacePresent)
46
+ continue;
47
+ const executed = await checkedPluginCommand(runtime, step.command, step.args, options.root, 120_000);
48
+ result.completed.push(step.name);
49
+ if (step.name === 'marketplace') {
50
+ const registered = await inspectAgentPlugin(runtime, options, bundle);
51
+ if (!registered.marketplacePresent || registered.conflicts.length > 0) {
52
+ throw new PluginInstallError('conflict', 'The registered marketplace could not be confirmed as the unified plugin source. No plugin install was attempted.');
53
+ }
54
+ }
55
+ else if (step.name === 'install') {
56
+ try {
57
+ installAnswer = JSON.parse(executed.stdout);
58
+ }
59
+ catch { /* Some native installers report human-readable progress; the final inventory is authoritative. */ }
60
+ }
61
+ }
62
+ return installAnswer;
63
+ }
64
+ function failureNotes(completed) {
65
+ if (completed.length === 0)
66
+ return [];
67
+ const removed = completed.includes('uninstall-local') ? `Only the ${ZCODE_LOCAL_PLUGIN} steps in completed removed anything; no other` : 'No existing';
68
+ return [
69
+ `Commands already completed: ${completed.join(', ')}. Inspect the selected host before retrying.`,
70
+ `${removed} plugin, user data or marketplace was automatically removed. Use the rollback instructions only after checking the current host registration.`,
71
+ ];
72
+ }
14
73
  function migrationInstructions(error) {
15
74
  if (!(error instanceof PluginInstallError) || error.instructions.length === 0)
16
75
  return [];
@@ -32,61 +91,42 @@ export async function installAgentPlugin(runtime, options) {
32
91
  return { ...result, status: 'manual_required', instructions: [...instructions, `Requested scope: ${options.scope}. No client configuration was changed.`] };
33
92
  }
34
93
  const trustMissing = host.requiresTrust && !options.trust;
35
- if (options.dryRun) {
36
- return { ...result, ok: true, status: 'dry_run', instructions: [...result.instructions, ...(trustMissing ? [trustInstruction(host)] : []), 'Preview only: host version, registration, download and installation have not been executed.'] };
37
- }
94
+ if (options.dryRun)
95
+ return dryRunResult(options, result, trustMissing);
38
96
  if (trustMissing) {
39
97
  return { ...result, status: 'trust_required', error: `${host.label} installs plugin hooks, MCP servers and skills only after you trust the plugin. No host command was run.`, instructions: [trustInstruction(host)] };
40
98
  }
41
99
  try {
42
- await checkPluginHostVersion(runtime, host);
43
- let inspection = await inspectAgentPlugin(runtime, options);
100
+ await checkPluginHostVersion(runtime, host, hostLauncher(runtime, host));
101
+ let bundle = host.kind === 'script' ? await useReleaseCheckout(runtime, options, result) : undefined;
102
+ let inspection = await inspectAgentPlugin(runtime, options, bundle);
44
103
  assertNoConflicts(inspection);
45
- if (inspection.installed) {
46
- const installedPath = verifyPluginManifest(runtime, options, inspection.installed);
47
- return { ...result, ok: true, status: 'already_installed', verified: true, version: inspection.installed.version, installedPath, commands: [] };
48
- }
104
+ const settled = alreadyInstalled(runtime, options, result, inspection);
105
+ if (settled)
106
+ return settled;
49
107
  return await withPluginInstallLock(runtime, options, async () => {
50
- inspection = await inspectAgentPlugin(runtime, options);
108
+ inspection = await inspectAgentPlugin(runtime, options, bundle);
51
109
  assertNoConflicts(inspection);
52
- if (inspection.installed) {
53
- const installedPath = verifyPluginManifest(runtime, options, inspection.installed);
54
- return { ...result, ok: true, status: 'already_installed', verified: true, version: inspection.installed.version, installedPath, commands: [] };
55
- }
110
+ const settledInLock = alreadyInstalled(runtime, options, result, inspection);
111
+ if (settledInLock)
112
+ return settledInLock;
56
113
  if (host.id === 'dsh')
57
114
  await assertDshProfileStoreMatches(runtime, options);
58
- let bundle;
59
- if (host.kind === 'bundle') {
60
- bundle = await ensureAgentPluginBundle(runtime, host);
61
- result.completed.push('download');
62
- result.commands = pluginInstallSteps(options, bundle);
63
- result.rollback = pluginRollbackInstructions(options, bundle);
64
- }
65
- let installAnswer;
66
- for (const step of result.commands) {
67
- if (step.name === 'marketplace' && inspection.marketplacePresent)
68
- continue;
69
- const executed = await checkedPluginCommand(runtime, step.command, step.args, options.root, 120_000);
70
- result.completed.push(step.name);
71
- if (step.name === 'marketplace') {
72
- inspection = await inspectAgentPlugin(runtime, options);
73
- if (!inspection.marketplacePresent || inspection.conflicts.length > 0) {
74
- throw new PluginInstallError('conflict', 'The registered marketplace could not be confirmed as the unified plugin source. No plugin install was attempted.');
75
- }
76
- }
77
- else {
78
- try {
79
- installAnswer = JSON.parse(executed.stdout);
80
- }
81
- catch { /* Some native installers report human-readable progress; the final inventory is authoritative. */ }
82
- }
83
- }
84
- inspection = await inspectAgentPlugin(runtime, options);
115
+ if (host.kind === 'bundle')
116
+ bundle = await useReleaseCheckout(runtime, options, result);
117
+ const local = inspection.zcodeLocal;
118
+ result.commands = plannedCommands(options, inspection, result.commands);
119
+ const installAnswer = await runPlannedCommands(runtime, options, result, inspection, bundle);
120
+ inspection = await inspectAgentPlugin(runtime, options, bundle);
85
121
  assertNoConflicts(inspection);
86
122
  if (!inspection.installed)
87
123
  throw new PluginInstallError('failed', `The ${AGENT_PLUGIN_NAME} command completed, but the selected host/scope did not register it. Installation was not confirmed.`);
88
124
  const installedPath = verifyPluginManifest(runtime, options, inspection.installed, installAnswer);
89
- return { ...result, ok: true, status: 'installed', verified: true, version: inspection.installed.version, installedPath };
125
+ const warnings = zcodeKeptMarketplaceWarning(local);
126
+ return {
127
+ ...result, ok: true, status: result.completed.includes('install') ? 'installed' : 'already_installed', verified: true, version: inspection.installed.version, installedPath,
128
+ ...zcodeMigrationReport(local, result.completed), ...(warnings.length > 0 && { warnings }),
129
+ };
90
130
  });
91
131
  }
92
132
  catch (error) {
@@ -94,10 +134,7 @@ export async function installAgentPlugin(runtime, options) {
94
134
  ...result,
95
135
  status: error instanceof PluginInstallError ? error.status : 'failed',
96
136
  error: error instanceof PluginInstallError ? error.message : 'The plugin operation failed; no verified installation was reported.',
97
- instructions: [...result.instructions, ...migrationInstructions(error), ...(result.completed.length > 0 ? [
98
- `Commands already completed: ${result.completed.join(', ')}. Inspect the selected host before retrying.`,
99
- 'No existing plugin, user data or marketplace was automatically removed. Use the rollback instructions only after checking the current host registration.',
100
- ] : [])],
137
+ instructions: [...result.instructions, ...migrationInstructions(error), ...failureNotes(result.completed)],
101
138
  };
102
139
  }
103
140
  }
@@ -0,0 +1,7 @@
1
+ import type { PluginHost } from './pluginHosts.js';
2
+ import { type PluginRuntime } from './pluginRuntime.js';
3
+ /** The argv prefix that runs the host's own CLI, or undefined when it is not present on this machine. ZCode's CLI is
4
+ * a Node script, never a `zcode` executable on PATH. */
5
+ export declare function hostLauncher(runtime: PluginRuntime, host: PluginHost): string[] | undefined;
6
+ /** What a preview shows when the host CLI is absent: the command a real install would run. */
7
+ export declare function expectedHostLauncher(runtime: PluginRuntime, host: PluginHost): string[];
@@ -0,0 +1,40 @@
1
+ import { statSync } from 'node:fs';
2
+ import { isAbsolute, join } from 'node:path';
3
+ import { pluginHome } from './pluginRuntime.js';
4
+ const ZCODE_DESKTOP_CLI = ['resources', 'glm', 'zcode.cjs'];
5
+ const ZCODE_MAC_CLI = ['ZCode.app', 'Contents', 'Resources', 'glm', 'zcode.cjs'];
6
+ const isFile = (path) => {
7
+ try {
8
+ return statSync(path).isFile();
9
+ }
10
+ catch {
11
+ return false;
12
+ }
13
+ };
14
+ /** ZCode ships its CLI as a Node script inside Desktop; ZCODE_CLI_PATH names another copy of that zcode.cjs script. */
15
+ function zcodeCliCandidates(runtime) {
16
+ const explicit = runtime.env['ZCODE_CLI_PATH']?.trim();
17
+ if (explicit)
18
+ return isAbsolute(explicit) ? [explicit] : [];
19
+ const home = pluginHome(runtime);
20
+ if (runtime.platform === 'win32')
21
+ return [join(runtime.env['LOCALAPPDATA'] || join(home, 'AppData', 'Local'), 'Programs', 'ZCode', ...ZCODE_DESKTOP_CLI)];
22
+ if (runtime.platform === 'darwin')
23
+ return [join(home, 'Applications', ...ZCODE_MAC_CLI), join('/Applications', ...ZCODE_MAC_CLI)];
24
+ return [];
25
+ }
26
+ /** The argv prefix that runs the host's own CLI, or undefined when it is not present on this machine. ZCode's CLI is
27
+ * a Node script, never a `zcode` executable on PATH. */
28
+ export function hostLauncher(runtime, host) {
29
+ if (host.id === 'zcode') {
30
+ const cli = zcodeCliCandidates(runtime).find(isFile);
31
+ return cli && runtime.available('node') ? ['node', cli] : undefined;
32
+ }
33
+ return host.command && runtime.available(host.command) ? [host.command] : undefined;
34
+ }
35
+ /** What a preview shows when the host CLI is absent: the command a real install would run. */
36
+ export function expectedHostLauncher(runtime, host) {
37
+ if (host.id === 'zcode')
38
+ return ['node', zcodeCliCandidates(runtime)[0] ?? '<ZCode Desktop>/resources/glm/zcode.cjs'];
39
+ return host.command ? [host.command] : [];
40
+ }
@@ -0,0 +1,7 @@
1
+ import { type PluginInstallOptions } from './pluginHosts.js';
2
+ import type { PluginInspection } from './pluginInspection.js';
3
+ import { type PluginRuntime } from './pluginRuntime.js';
4
+ /** Kimi and MiniMax are installed by the release checkout's own installer, whose `status` is the registration record. */
5
+ export declare function inspectScriptPlugin(runtime: PluginRuntime, options: PluginInstallOptions, bundle: string): Promise<PluginInspection>;
6
+ /** Step Code lists installed extension packages in its agent settings; local sources are folder paths. */
7
+ export declare function inspectStepCodePlugin(runtime: PluginRuntime, options: PluginInstallOptions): PluginInspection;
@@ -0,0 +1,46 @@
1
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
2
+ import { AGENT_PLUGIN_NAME } from './pluginHosts.js';
3
+ import { checkedPluginCommand, objectOf, pluginHome, pluginJson, PluginInstallError, readPluginJson } from './pluginRuntime.js';
4
+ const DISABLED = 'The plugin is installed but disabled. Enable it explicitly in the host rather than installing another copy.';
5
+ function installedRecord(version, path, enabled, raw) {
6
+ if (typeof version !== 'string' || typeof path !== 'string' || !isAbsolute(path))
7
+ return undefined;
8
+ return { id: AGENT_PLUGIN_NAME, name: AGENT_PLUGIN_NAME, version, enabled, path, raw };
9
+ }
10
+ /** Kimi and MiniMax are installed by the release checkout's own installer, whose `status` is the registration record. */
11
+ export async function inspectScriptPlugin(runtime, options, bundle) {
12
+ const { host } = options;
13
+ const { stdout } = await checkedPluginCommand(runtime, 'node', [join(dirname(bundle), host.installer), 'status'], options.root);
14
+ const status = objectOf(pluginJson(stdout, `${host.label} installer status`));
15
+ if (typeof status?.['installed'] !== 'boolean')
16
+ throw new PluginInstallError('unsupported_capability', `${host.label} installer status has an unsupported shape; no installed state can be inferred.`);
17
+ const installed = status['installed'] ? installedRecord(status['version'], status['path'], status['enabled'] !== false, status) : undefined;
18
+ if (status['installed'] && !installed)
19
+ throw new PluginInstallError('unsupported_capability', `${host.label} installer status reports an installation without its version and path.`);
20
+ return { installed, marketplacePresent: false, conflicts: installed && !installed.enabled ? [DISABLED] : [], migrations: [] };
21
+ }
22
+ function stepAgentDir(runtime) {
23
+ const configured = runtime.env['STEP_CODING_AGENT_DIR'];
24
+ if (configured === undefined)
25
+ return join(pluginHome(runtime), '.stepcode', 'agent');
26
+ if (!isAbsolute(configured))
27
+ throw new PluginInstallError('invalid_arguments', 'STEP_CODING_AGENT_DIR must be an absolute directory, as Step Code requires.');
28
+ return configured;
29
+ }
30
+ /** Step Code lists installed extension packages in its agent settings; local sources are folder paths. */
31
+ export function inspectStepCodePlugin(runtime, options) {
32
+ const agentDir = stepAgentDir(runtime);
33
+ const packages = readPluginJson(join(agentDir, 'settings.json'))?.['packages'] ?? [];
34
+ if (!Array.isArray(packages))
35
+ throw new PluginInstallError('unsupported_capability', 'Step Code settings list packages in an unsupported shape; no installed state can be inferred.');
36
+ const ours = packages.flatMap(entry => {
37
+ const source = typeof entry === 'string' ? entry : objectOf(entry)?.['source'];
38
+ if (typeof source !== 'string' || /^(?:npm|git|https?):/.test(source))
39
+ return [];
40
+ const path = resolve(agentDir, source);
41
+ const manifest = readPluginJson(join(path, 'package.json'));
42
+ return manifest && manifest['name'] === options.host.packageName ? [installedRecord(manifest['version'], path, true, manifest)] : [];
43
+ }).filter(plugin => plugin !== undefined);
44
+ const conflicts = ours.length > 1 ? ['Multiple Step Code Evolver packages are installed; remove all but one with step remove <path>.'] : [];
45
+ return { installed: ours[0], marketplacePresent: false, conflicts, migrations: [] };
46
+ }
@@ -27,6 +27,7 @@ export declare function objectOf(value: unknown): Record<string, unknown> | unde
27
27
  export declare function readPluginText(path: string, maxBytes?: number): string | undefined;
28
28
  export declare function readPluginJson(path: string): Record<string, unknown> | undefined;
29
29
  export declare function pluginVersionAtLeast(current: string, minimum: string): boolean;
30
- export declare function checkPluginHostVersion(runtime: PluginRuntime, host: PluginHost): Promise<void>;
30
+ /** `launcher` is the host CLI found on this machine (see hostLauncher), or undefined when it is missing. */
31
+ export declare function checkPluginHostVersion(runtime: PluginRuntime, host: PluginHost, launcher: readonly string[] | undefined): Promise<void>;
31
32
  /** Only installer-owned descendants are written; a symlink may not redirect the cache or lock. */
32
33
  export declare function assertPluginManagedPath(path: string): void;
@@ -157,12 +157,18 @@ export function pluginVersionAtLeast(current, minimum) {
157
157
  }
158
158
  return true;
159
159
  }
160
- export async function checkPluginHostVersion(runtime, host) {
161
- if (!host.command || !runtime.available(host.command))
162
- throw new PluginInstallError('host_missing', `${host.label} CLI (${host.command ?? 'none'}) was not found on PATH.`);
160
+ /** `launcher` is the host CLI found on this machine (see hostLauncher), or undefined when it is missing. */
161
+ export async function checkPluginHostVersion(runtime, host, launcher) {
162
+ if (!launcher)
163
+ throw new PluginInstallError('host_missing', host.id === 'zcode'
164
+ ? 'ZCode CLI was not found: install ZCode Desktop, or set ZCODE_CLI_PATH to an absolute standalone zcode.cjs, with node on PATH.'
165
+ : `${host.label} CLI (${host.command ?? 'none'}) was not found on PATH.`);
166
+ if (host.kind === 'script' && !runtime.available('node'))
167
+ throw new PluginInstallError('host_missing', `${host.label} is installed by a Node.js script; node was not found on PATH.`);
163
168
  if (!host.minimumVersion)
164
169
  return;
165
- const { stdout } = await checkedPluginCommand(runtime, host.command, ['--version']);
170
+ const [command, ...prefix] = launcher;
171
+ const { stdout } = await checkedPluginCommand(runtime, command, [...prefix, '--version']);
166
172
  const version = /(?:^|\s)v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)(?:\s|$)/.exec(stdout.trim())?.[1];
167
173
  if (!version || !pluginVersionAtLeast(version, host.minimumVersion)) {
168
174
  throw new PluginInstallError('unsupported_version', `${host.label} requires ${host.minimumVersion}+; ${version ?? 'an unknown version'} was observed. Upgrade the host CLI before installing.`);
@@ -0,0 +1,22 @@
1
+ import { type PluginCommandStep, type PluginHost, type PluginInstallOptions } from './pluginHosts.js';
2
+ import { type PluginRuntime } from './pluginRuntime.js';
3
+ export declare const ZCODE_LOCAL_PLUGIN = "evolver-plugin@evolver-zcode-local";
4
+ /** A ZCode local-folder install of this plugin, which would run the same hooks as the evomap install. */
5
+ export interface ZcodeLocalInstall {
6
+ uninstall?: string;
7
+ removeMarketplace?: string;
8
+ keptMarketplace?: string;
9
+ }
10
+ export interface ZcodeMigrationReport {
11
+ uninstalled?: string;
12
+ removedMarketplace?: string;
13
+ }
14
+ export declare function zcodeLocalInstall(runtime: PluginRuntime, host: PluginHost, pluginIds: readonly string[], markets: readonly Record<string, unknown>[]): ZcodeLocalInstall | undefined;
15
+ export declare const zcodeMigrationPending: (local: ZcodeLocalInstall | undefined) => boolean;
16
+ export declare function zcodeMigrationSteps(options: PluginInstallOptions, local: ZcodeLocalInstall): PluginCommandStep[];
17
+ export declare const ZCODE_MIGRATION_PREVIEW: ZcodeLocalInstall;
18
+ export declare const ZCODE_MIGRATION_PREVIEW_NOTE = "uninstall-local and remove-local-marketplace run only when evolver-plugin@evolver-zcode-local is installed or its marketplace points into Evolver's release cache.";
19
+ export declare function zcodeMigrationReport(local: ZcodeLocalInstall | undefined, completed: readonly string[]): {
20
+ migrated?: ZcodeMigrationReport;
21
+ };
22
+ export declare function zcodeKeptMarketplaceWarning(local: ZcodeLocalInstall | undefined): string[];
@@ -0,0 +1,40 @@
1
+ import { isManagedPackedBundle } from './pluginBundle.js';
2
+ import { AGENT_PLUGIN_NAME, ZCODE_LOCAL_MARKETPLACE } from './pluginHosts.js';
3
+ import { objectOf } from './pluginRuntime.js';
4
+ export const ZCODE_LOCAL_PLUGIN = `${AGENT_PLUGIN_NAME}@${ZCODE_LOCAL_MARKETPLACE}`;
5
+ function ownsLocalMarketplace(runtime, host, record) {
6
+ const source = objectOf(record['source']);
7
+ const folder = source?.['source'] === 'directory' ? source['path'] : undefined;
8
+ return typeof folder === 'string' && isManagedPackedBundle(runtime, host, folder);
9
+ }
10
+ export function zcodeLocalInstall(runtime, host, pluginIds, markets) {
11
+ const installed = pluginIds.includes(ZCODE_LOCAL_PLUGIN);
12
+ const market = markets.find(record => record['name'] === ZCODE_LOCAL_MARKETPLACE);
13
+ if (!installed && !market)
14
+ return undefined;
15
+ const marketplace = market && (ownsLocalMarketplace(runtime, host, market) ? { removeMarketplace: ZCODE_LOCAL_MARKETPLACE } : { keptMarketplace: ZCODE_LOCAL_MARKETPLACE });
16
+ return { ...(installed && { uninstall: ZCODE_LOCAL_PLUGIN }), ...marketplace };
17
+ }
18
+ export const zcodeMigrationPending = (local) => Boolean(local?.uninstall || local?.removeMarketplace);
19
+ export function zcodeMigrationSteps(options, local) {
20
+ const [command = '', ...prefix] = options.launcher;
21
+ const step = (name, args) => ({ name, command, args: [...prefix, ...args] });
22
+ return [
23
+ ...(local.uninstall ? [step('uninstall-local', ['plugins', 'uninstall', local.uninstall, '--scope', options.scope, '--keep-data', '--force', '--json'])] : []),
24
+ ...(local.removeMarketplace ? [step('remove-local-marketplace', ['plugins', 'marketplace', 'remove', local.removeMarketplace, '--json'])] : []),
25
+ ];
26
+ }
27
+ export const ZCODE_MIGRATION_PREVIEW = { uninstall: ZCODE_LOCAL_PLUGIN, removeMarketplace: ZCODE_LOCAL_MARKETPLACE };
28
+ export const ZCODE_MIGRATION_PREVIEW_NOTE = `uninstall-local and remove-local-marketplace run only when ${ZCODE_LOCAL_PLUGIN} is installed or its marketplace points into Evolver's release cache.`;
29
+ export function zcodeMigrationReport(local, completed) {
30
+ const migrated = {
31
+ ...(completed.includes('uninstall-local') && { uninstalled: local?.uninstall }),
32
+ ...(completed.includes('remove-local-marketplace') && { removedMarketplace: local?.removeMarketplace }),
33
+ };
34
+ return Object.keys(migrated).length > 0 ? { migrated } : {};
35
+ }
36
+ export function zcodeKeptMarketplaceWarning(local) {
37
+ if (!local?.keptMarketplace)
38
+ return [];
39
+ return [`Marketplace ${local.keptMarketplace} points at a folder Evolver does not manage, so it stays registered. Do not install ${AGENT_PLUGIN_NAME} from it as well: both copies would run the same hooks.`];
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-cli",
3
- "version": "2.0.51",
3
+ "version": "2.0.53",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -27,12 +27,12 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@evomap/evolver-core": "2.0.51",
31
- "@evomap/evolver-adapter-public": "2.0.51",
32
- "@evomap/evolver-mcp": "2.0.51",
33
- "@evomap/evolver-proxy": "2.0.51",
34
- "@evomap/evolver-runtime-adapters": "2.0.51",
35
- "@evomap/evolver-webui": "2.0.51"
30
+ "@evomap/evolver-core": "2.0.53",
31
+ "@evomap/evolver-adapter-public": "2.0.53",
32
+ "@evomap/evolver-mcp": "2.0.53",
33
+ "@evomap/evolver-proxy": "2.0.53",
34
+ "@evomap/evolver-runtime-adapters": "2.0.53",
35
+ "@evomap/evolver-webui": "2.0.53"
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",