@evomap/evolver-mcp 2.0.0-beta.2 → 2.0.0-beta.22

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/injection.js CHANGED
@@ -3,12 +3,10 @@ export const SETUP_RUNTIMES = [
3
3
  'claude-code', 'codex', 'cursor', 'antigravity', 'opencode', 'kiro', 'openclaw', 'mcp-generic', 'http-agent', 'server',
4
4
  ];
5
5
  /** Runtimes v2 can write config/hooks for and verify. Antigravity is MCP-config-only (no lifecycle hook). */
6
- const INSTALLED_RUNTIMES = new Set(['claude-code', 'codex', 'cursor', 'antigravity']);
6
+ const INSTALLED_RUNTIMES = new Set(['claude-code', 'codex', 'cursor', 'antigravity', 'opencode', 'kiro']);
7
7
  /** Runtimes with no v2 auto-installer but a real manual path. The reason is the short, honest "do it by hand"
8
8
  * line; the precise wiring text is a separate concern (#217 slice 2), not hard-coded here. */
9
9
  const MANUAL_RUNTIMES = new Map([
10
- ['opencode', 'opencode is consumed passively today; register the evolver MCP server in its config by hand'],
11
- ['kiro', 'kiro is consumed passively today; register the evolver MCP server in its config by hand'],
12
10
  ['openclaw', 'no v2 auto-installer yet; wire the evolver MCP server (or PrivateHub HTTP/A2A) by hand'],
13
11
  ['mcp-generic', 'no config writer for a generic MCP client; register the evolver MCP server by hand'],
14
12
  ['http-agent', 'no config writer for an HTTP/API-only agent; wire it to PrivateHub HTTP/A2A by hand'],
@@ -67,12 +65,17 @@ export function planInjection(runtime, server) {
67
65
  config: { mcpServers: { evolver: { command: server.command, args: server.args ?? [], ...(server.env ? { env: server.env } : {}) } } },
68
66
  note: 'antigravity: write mcpServers.evolver in the user-level MCP config; tool discovery only (no SessionStart hook)',
69
67
  };
70
- case 'kiro':
71
68
  case 'opencode':
72
69
  return {
73
- runtime, mode: 'passive',
74
- config: {},
75
- note: `${runtime}: MVP 仅被动消费会话日志(无工具注入); 接入方式待补`,
70
+ runtime, mode: 'mcp-config',
71
+ config: { mcp: { evolver: { type: 'local', command: [server.command, ...(server.args ?? [])], ...(server.env ? { environment: server.env } : {}), enabled: true } } },
72
+ note: 'OpenCode: write opencode.json local MCP registration; no lifecycle prompt injection.',
73
+ };
74
+ case 'kiro':
75
+ return {
76
+ runtime, mode: 'mcp-config',
77
+ config: { mcpServers: { evolver: { command: server.command, args: server.args ?? [], ...(server.env ? { env: server.env } : {}), disabled: false } } },
78
+ note: 'Kiro: write .kiro/settings/mcp.json MCP registration; no lifecycle prompt injection.',
76
79
  };
77
80
  default: {
78
81
  const _exhaustive = runtime;
@@ -1,11 +1,16 @@
1
1
  import { type RuntimeId, type McpServerCmd, type InjectionPlan } from './injection.js';
2
2
  import { type CursorGene } from './cursorRulesInstaller.js';
3
+ export { EmptySharedConfigError, SymlinkRefusedError, UnparseableConfigError, } from './installerShared.js';
3
4
  /** Marks a config file as containing evolver-managed entries, so uninstall only removes what we added. */
4
5
  export declare const MANAGED_MARKER = "_evolver_managed";
6
+ /** Official command-handler metadata, also gives custom commands an ownership marker for reinstall/uninstall. */
7
+ export declare const EVOLVER_HOOK_STATUS = "Loading Evolver memory";
5
8
  /** Default command the SessionStart hook runs to render + print the memory injection. The `--hook-stdin` flag opts
6
9
  * the entrypoint into reading the runtime's SessionStart JSON from stdin (to capture session_id, #205); only the
7
10
  * installed hook sets it, so a manual `evolver inject session-start` never reads stdin. */
8
11
  export declare const DEFAULT_HOOK_COMMAND = "evolver inject session-start --hook-stdin";
12
+ /** Local-only prompt recall. The handler is default-off and reads stdin only when EVOLVER_RECALL_MODE opts in. */
13
+ export declare const DEFAULT_PROMPT_RECALL_HOOK_COMMAND = "evolver inject prompt-recall --hook-stdin";
9
14
  /**
10
15
  * Where a claude-code install registers the evolver MCP server. This is the fix for "global install doesn't
11
16
  * actually globalize" (#290): Claude Code's MCP scopes are local / user / project, and a `.mcp.json` is the
@@ -30,8 +35,12 @@ export interface InstallOptions {
30
35
  server: McpServerCmd;
31
36
  /** Command the SessionStart hook runs to inject memory. Default 'evolver inject session-start'. */
32
37
  hookCommand?: string;
38
+ /** Command the UserPromptSubmit hook runs. Default is local-only, default-off prompt recall. */
39
+ promptRecallHookCommand?: string;
33
40
  /** Reinstall even if an evolver install is already present. */
34
41
  force?: boolean;
42
+ /** Plan and validate without writing config or backup files. */
43
+ dryRun?: boolean;
35
44
  /** Cursor only: the top genes to render into .cursor/rules/evolver.mdc. The daemon refreshes these on change;
36
45
  * a one-shot `setup-hooks --runtime=cursor` install seeds the file (empty ⇒ a placeholder the daemon fills). */
37
46
  genes?: readonly CursorGene[];
@@ -40,12 +49,44 @@ export interface InstallOptions {
40
49
  /** Antigravity only: override the user home used to resolve ~/.gemini config roots. Intended for hermetic
41
50
  * embedding/tests; normal callers omit it. configRoot and scope do not affect Antigravity's user config. */
42
51
  homeDir?: string;
52
+ /** Kiro user scope only: direct replacement for ~/.kiro, matching KIRO_HOME semantics. */
53
+ kiroHome?: string;
54
+ /** OpenCode user scope only: explicit XDG_CONFIG_HOME used to resolve the global config. */
55
+ xdgConfigHome?: string;
56
+ /** OpenCode user scope only: explicit OPENCODE_CONFIG file override. */
57
+ opencodeConfig?: string;
58
+ /** OpenCode user scope only: explicit OPENCODE_CONFIG_DIR override. */
59
+ opencodeConfigDir?: string;
60
+ /** OpenCode only: inline config loaded after project/custom-directory config. */
61
+ opencodeConfigContent?: string;
62
+ /** OpenCode only: mirrors truthy OPENCODE_DISABLE_PROJECT_CONFIG handling. */
63
+ opencodeDisableProjectConfig?: boolean;
64
+ /** OpenCode only: injectable managed-config directory for hermetic tests. */
65
+ opencodeManagedConfigDir?: string;
66
+ /** OpenCode only: injectable macOS managed-preference paths for hermetic tests. */
67
+ opencodeManagedPreferencePaths?: readonly string[];
68
+ /** OpenCode only: injectable platform used to resolve system managed paths. */
69
+ opencodePlatform?: NodeJS.Platform;
70
+ /** OpenCode only: injectable ProgramData used to resolve the Windows managed path. */
71
+ opencodeProgramData?: string;
72
+ /** OpenCode only: injectable username used to resolve macOS managed preferences. */
73
+ opencodeUsername?: string;
43
74
  }
44
75
  export interface UninstallOptions {
45
76
  configRoot: string;
46
77
  scope?: InstallScope;
47
78
  /** Antigravity only: override the user home used to resolve ~/.gemini config roots. */
48
79
  homeDir?: string;
80
+ /** Kiro user scope only: direct replacement for ~/.kiro, matching KIRO_HOME semantics. */
81
+ kiroHome?: string;
82
+ /** Validate and report the uninstall without changing config or backup files. */
83
+ dryRun?: boolean;
84
+ /** OpenCode user scope only: explicit XDG_CONFIG_HOME used to resolve the global config. */
85
+ xdgConfigHome?: string;
86
+ /** OpenCode user scope only: explicit OPENCODE_CONFIG file override. */
87
+ opencodeConfig?: string;
88
+ /** OpenCode user scope only: explicit OPENCODE_CONFIG_DIR override. */
89
+ opencodeConfigDir?: string;
49
90
  }
50
91
  export interface InstallResult {
51
92
  ok: boolean;
@@ -54,33 +95,21 @@ export interface InstallResult {
54
95
  /** Absolute paths written (install) or cleaned (uninstall). */
55
96
  files: string[];
56
97
  alreadyInstalled?: boolean;
98
+ dryRun?: boolean;
99
+ verified?: boolean;
100
+ backups?: string[];
57
101
  error?: string;
58
102
  }
59
- export declare class SymlinkRefusedError extends Error {
60
- constructor(label: string, path: string);
61
- }
62
- /**
63
- * Thrown when a SHARED user config (~/.claude.json or ~/.claude/settings.json) exists but does not parse as JSON.
64
- * These files are Claude Code's own state (projects/oauthAccount/userID/history/settings),
65
- * and user-scope install merges into them via a full-file atomic replace. The lenient readJson() returns {} on
66
- * a parse failure, which would make the merge emit ONLY evolver's entry and silently WIPE the whole file — a
67
- * realistic data-loss path because Claude Code writes these files non-atomically (a concurrent session can leave
68
- * one truncated). For the shared-config read we therefore refuse instead of clobbering. Project-scoped
69
- * .mcp.json/.claude/settings.json are evolver-owned, so their lenient fresh-start behavior stays unchanged.
70
- */
71
- export declare class UnparseableConfigError extends Error {
72
- constructor(label: string, path: string, owner?: string);
73
- }
74
- /**
75
- * Thrown when a SHARED user config exists but is empty or whitespace-only. Claude Code writes these files with a
76
- * truncating write, so present-empty can be a concurrent-write window rather than a fresh config.
77
- */
78
- export declare class EmptySharedConfigError extends Error {
79
- constructor(label: string, path: string, owner?: string);
80
- }
81
103
  type SharedConfigRaceHook = (path: string, attempt: number) => void;
82
104
  export declare function _setSharedConfigRaceHookForTest(hook?: SharedConfigRaceHook): void;
83
105
  export declare function deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown>;
106
+ /** Bind custom-command ownership to that exact command without adding undocumented hook-schema fields. */
107
+ export declare function evolverManagedHookStatus(command: string): string;
108
+ /** Remove only Evolver-owned handlers, retaining user handlers that share the same matcher group. */
109
+ export declare function stripEvolverHookEntries(entries: readonly unknown[], trustManagedStatus?: boolean, managedCommands?: ReadonlySet<string>): {
110
+ changed: boolean;
111
+ entries: unknown[];
112
+ };
84
113
  /**
85
114
  * deepMerge, but for `hooks.<event>` arrays keep the user's existing entries and only replace evolver-owned
86
115
  * ones — so reinstalling refreshes evolver's hook without clobbering a user's own SessionStart/Stop hooks.
@@ -110,5 +139,4 @@ export declare function installInjection(plan: InjectionPlan, opts: InstallOptio
110
139
  * the mcpServers.evolver entry (and any evolver-owned hooks/marker), so it is safe on the shared ~/.claude.json. */
111
140
  export declare function uninstallInjection(runtime: RuntimeId, opts: UninstallOptions): InstallResult;
112
141
  /** Convenience: plan + install in one call for a runtime. */
113
- export declare function setupRuntime(runtime: RuntimeId, opts: InstallOptions): InstallResult;
114
- export {};
142
+ export declare function setupRuntime(runtime: RuntimeId, opts: InstallOptions): InstallResult;