@evomap/evolver-mcp 2.0.0-beta.0 → 2.0.0-beta.10
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/antigravityInstaller.d.ts +32 -0
- package/dist/antigravityInstaller.js +271 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/injection.d.ts +4 -3
- package/dist/injection.js +21 -10
- package/dist/installer.d.ts +51 -6
- package/dist/installer.js +28 -6
- package/dist/jsonMcpInstaller.d.ts +75 -0
- package/dist/jsonMcpInstaller.js +824 -0
- package/dist/kiroInstaller.d.ts +10 -0
- package/dist/kiroInstaller.js +146 -0
- package/dist/opencodeInstaller.d.ts +18 -0
- package/dist/opencodeInstaller.js +531 -0
- package/dist/proxyClient.d.ts +17 -0
- package/dist/proxyClient.js +25 -0
- package/dist/tools.js +61 -0
- package/package.json +7 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InstallOptions } from './installer.js';
|
|
2
|
+
import { type JsonMcpRuntimeResolution, type JsonMcpRuntimeSpec } from './jsonMcpInstaller.js';
|
|
3
|
+
type KiroPathOptions = Pick<InstallOptions, 'configRoot' | 'scope' | 'homeDir' | 'kiroHome'>;
|
|
4
|
+
/** Resolve only Kiro's base mcp.json contract; custom agent JSON is intentionally out of scope. */
|
|
5
|
+
export declare function resolveKiroConfig(opts: KiroPathOptions): JsonMcpRuntimeResolution;
|
|
6
|
+
export declare const KIRO_SPEC: JsonMcpRuntimeSpec;
|
|
7
|
+
export declare function kiroConfigRoot({ configRoot, scope, homeDir, kiroHome }: Pick<InstallOptions, 'configRoot' | 'scope' | 'homeDir' | 'kiroHome'>): string;
|
|
8
|
+
export declare const installKiro: (plan: import("./injection.js").InjectionPlan, opts: InstallOptions) => import("./installer.js").InstallResult;
|
|
9
|
+
export declare const uninstallKiro: (runtime: import("./injection.js").RuntimeId, opts: import("./installer.js").UninstallOptions) => import("./installer.js").InstallResult;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { installJsonMcpRuntime, McpConfigChangedError, McpConfigConflictError, McpConfigOwnershipError, McpConfigShapeError, uninstallJsonMcpRuntime, } from './jsonMcpInstaller.js';
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function valuesEqual(left, right) {
|
|
9
|
+
if (Object.is(left, right))
|
|
10
|
+
return true;
|
|
11
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
12
|
+
return Array.isArray(left) && Array.isArray(right)
|
|
13
|
+
&& left.length === right.length
|
|
14
|
+
&& left.every((value, index) => valuesEqual(value, right[index]));
|
|
15
|
+
}
|
|
16
|
+
if (!isRecord(left) || !isRecord(right))
|
|
17
|
+
return false;
|
|
18
|
+
const leftKeys = Object.keys(left).sort();
|
|
19
|
+
const rightKeys = Object.keys(right).sort();
|
|
20
|
+
return leftKeys.length === rightKeys.length
|
|
21
|
+
&& leftKeys.every((key, index) => key === rightKeys[index] && valuesEqual(left[key], right[key]));
|
|
22
|
+
}
|
|
23
|
+
function readKiroLayer(path) {
|
|
24
|
+
if (!existsSync(path))
|
|
25
|
+
return { path, raw: null };
|
|
26
|
+
const stat = lstatSync(path);
|
|
27
|
+
if (stat.isSymbolicLink()) {
|
|
28
|
+
throw new McpConfigOwnershipError('kiro', 'a layered configuration is a symbolic link');
|
|
29
|
+
}
|
|
30
|
+
if (!stat.isFile()) {
|
|
31
|
+
throw new McpConfigOwnershipError('kiro', 'a layered configuration is not a regular file');
|
|
32
|
+
}
|
|
33
|
+
return { path, raw: readFileSync(path, 'utf8') };
|
|
34
|
+
}
|
|
35
|
+
function entryFromKiroLayer(snapshot) {
|
|
36
|
+
if (snapshot.raw === null)
|
|
37
|
+
return { present: false };
|
|
38
|
+
let parsed;
|
|
39
|
+
try {
|
|
40
|
+
parsed = JSON.parse(snapshot.raw);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new McpConfigShapeError('kiro', snapshot.path, 'layered configuration is not valid JSON');
|
|
44
|
+
}
|
|
45
|
+
if (!isRecord(parsed)) {
|
|
46
|
+
throw new McpConfigShapeError('kiro', snapshot.path, 'layered configuration must be a JSON object');
|
|
47
|
+
}
|
|
48
|
+
const servers = parsed['mcpServers'];
|
|
49
|
+
if (servers === undefined)
|
|
50
|
+
return { present: false };
|
|
51
|
+
if (!isRecord(servers)) {
|
|
52
|
+
throw new McpConfigShapeError('kiro', snapshot.path, 'mcpServers must be a JSON object');
|
|
53
|
+
}
|
|
54
|
+
return Object.prototype.hasOwnProperty.call(servers, 'evolver')
|
|
55
|
+
? { present: true, value: servers['evolver'], path: snapshot.path }
|
|
56
|
+
: { present: false };
|
|
57
|
+
}
|
|
58
|
+
function kiroBaseConfigPaths(opts) {
|
|
59
|
+
const globalRoot = kiroConfigRoot({ ...opts, scope: 'user' });
|
|
60
|
+
return {
|
|
61
|
+
global: join(globalRoot, 'settings', 'mcp.json'),
|
|
62
|
+
workspace: join(opts.configRoot, '.kiro', 'settings', 'mcp.json'),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Resolve only Kiro's base mcp.json contract; custom agent JSON is intentionally out of scope. */
|
|
66
|
+
export function resolveKiroConfig(opts) {
|
|
67
|
+
const paths = kiroBaseConfigPaths(opts);
|
|
68
|
+
const configPath = (opts.scope ?? 'project') === 'user' ? paths.global : paths.workspace;
|
|
69
|
+
const safeRoot = (opts.scope ?? 'project') === 'user'
|
|
70
|
+
? kiroConfigRoot({ ...opts, scope: 'user' })
|
|
71
|
+
: opts.configRoot;
|
|
72
|
+
return {
|
|
73
|
+
configPath,
|
|
74
|
+
safeRoot,
|
|
75
|
+
conflictingPaths: [],
|
|
76
|
+
evidencePaths: [paths.global, paths.workspace],
|
|
77
|
+
topologyCandidatePaths: [configPath],
|
|
78
|
+
uninstallCandidatePaths: [configPath],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function kiroInstallPreflight(resolution, opts, expected) {
|
|
82
|
+
const paths = kiroBaseConfigPaths(opts);
|
|
83
|
+
const layerPaths = [...new Set([paths.global, paths.workspace])];
|
|
84
|
+
const snapshots = layerPaths.map(readKiroLayer);
|
|
85
|
+
let effective = { present: false };
|
|
86
|
+
for (const snapshot of snapshots) {
|
|
87
|
+
const entry = entryFromKiroLayer(snapshot);
|
|
88
|
+
if (entry.present)
|
|
89
|
+
effective = entry;
|
|
90
|
+
}
|
|
91
|
+
const effectiveMatches = effective.present && valuesEqual(effective.value, expected);
|
|
92
|
+
if (effective.present && !effectiveMatches && effective.path !== resolution.configPath) {
|
|
93
|
+
const projectCanForceWorkspaceOverride = (opts.scope ?? 'project') === 'project'
|
|
94
|
+
&& opts.force === true
|
|
95
|
+
&& effective.path === paths.global;
|
|
96
|
+
if (!projectCanForceWorkspaceOverride) {
|
|
97
|
+
throw new McpConfigConflictError('kiro', 'mcpServers.evolver', expected, effective.value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const targetIndex = layerPaths.indexOf(resolution.configPath);
|
|
101
|
+
const effectiveIndex = effective.path === undefined ? -1 : layerPaths.indexOf(effective.path);
|
|
102
|
+
const alreadyInstalled = effectiveMatches
|
|
103
|
+
&& effective.path !== resolution.configPath
|
|
104
|
+
&& effectiveIndex >= 0
|
|
105
|
+
&& targetIndex >= 0
|
|
106
|
+
&& effectiveIndex < targetIndex;
|
|
107
|
+
const guardedSnapshots = alreadyInstalled
|
|
108
|
+
? snapshots
|
|
109
|
+
: snapshots.filter((snapshot) => snapshot.path !== resolution.configPath);
|
|
110
|
+
return {
|
|
111
|
+
alreadyInstalled,
|
|
112
|
+
assertUnchanged() {
|
|
113
|
+
for (const snapshot of guardedSnapshots) {
|
|
114
|
+
const current = readKiroLayer(snapshot.path);
|
|
115
|
+
if (current.raw !== snapshot.raw)
|
|
116
|
+
throw new McpConfigChangedError('kiro', snapshot.path);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export const KIRO_SPEC = {
|
|
122
|
+
runtime: 'kiro',
|
|
123
|
+
configPath: (opts) => resolveKiroConfig(opts).configPath,
|
|
124
|
+
resolveConfig: resolveKiroConfig,
|
|
125
|
+
installPreflight: kiroInstallPreflight,
|
|
126
|
+
containerKey: 'mcpServers',
|
|
127
|
+
entry: (server) => ({
|
|
128
|
+
command: server.command,
|
|
129
|
+
args: server.args ?? [],
|
|
130
|
+
...(server.env && Object.keys(server.env).length > 0 ? { env: server.env } : {}),
|
|
131
|
+
disabled: false,
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
export function kiroConfigRoot({ configRoot, scope, homeDir, kiroHome }) {
|
|
135
|
+
if (scope !== 'user')
|
|
136
|
+
return join(configRoot, '.kiro');
|
|
137
|
+
const configured = kiroHome?.trim();
|
|
138
|
+
if (configured)
|
|
139
|
+
return resolve(configured);
|
|
140
|
+
if (homeDir !== undefined)
|
|
141
|
+
return join(homeDir, '.kiro');
|
|
142
|
+
const environmentHome = process.env['KIRO_HOME']?.trim();
|
|
143
|
+
return environmentHome ? resolve(environmentHome) : join(homedir(), '.kiro');
|
|
144
|
+
}
|
|
145
|
+
export const installKiro = installJsonMcpRuntime.bind(undefined, KIRO_SPEC);
|
|
146
|
+
export const uninstallKiro = uninstallJsonMcpRuntime.bind(undefined, KIRO_SPEC);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { InstallOptions } from './installer.js';
|
|
2
|
+
import { type JsonMcpRuntimeResolution, type JsonMcpRuntimeSpec } from './jsonMcpInstaller.js';
|
|
3
|
+
type OpenCodePathOptions = Pick<InstallOptions, 'configRoot' | 'scope' | 'homeDir' | 'xdgConfigHome' | 'opencodeConfig' | 'opencodeConfigDir'>;
|
|
4
|
+
type OpenCodeManagedPathOptions = Pick<InstallOptions, 'opencodePlatform' | 'opencodeProgramData' | 'opencodeUsername'>;
|
|
5
|
+
export declare function resolveOpenCodeManagedConfigDir(opts?: OpenCodeManagedPathOptions): string;
|
|
6
|
+
export declare function resolveOpenCodeManagedPreferencePaths(opts?: OpenCodeManagedPathOptions): string[];
|
|
7
|
+
/** Resolve the OpenCode file that is active at the requested scope.
|
|
8
|
+
* OpenCode layers project files from the worktree root down to the current directory, or from the filesystem root
|
|
9
|
+
* outside Git, then .opencode directories in reverse order. JSONC follows JSON at every location. Global,
|
|
10
|
+
* explicit, home, and managed layers retain their surrounding precedence. A JSONC path is writable only when its
|
|
11
|
+
* contents are strict JSON;
|
|
12
|
+
* comment/trailing-comma syntax is rejected by the shared strict parser so setup never rewrites it lossy.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveOpenCodeConfig(opts: OpenCodePathOptions): JsonMcpRuntimeResolution;
|
|
15
|
+
export declare const OPENCODE_SPEC: JsonMcpRuntimeSpec;
|
|
16
|
+
export declare const installOpenCode: (plan: import("./injection.js").InjectionPlan, opts: InstallOptions) => import("./installer.js").InstallResult;
|
|
17
|
+
export declare const uninstallOpenCode: (runtime: import("./injection.js").RuntimeId, opts: import("./installer.js").UninstallOptions) => import("./installer.js").InstallResult;
|
|
18
|
+
export {};
|