devworkspace 0.4.3 → 0.4.5
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/CHANGELOG.md +53 -0
- package/README.md +105 -26
- package/dist/cli/args.d.ts +10 -0
- package/dist/cli/args.js +3 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/help.js +15 -5
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/render.d.ts +2 -1
- package/dist/cli/render.js +71 -4
- package/dist/cli/render.js.map +1 -1
- package/dist/cli/run.js +54 -36
- package/dist/cli/run.js.map +1 -1
- package/dist/core/artifacts.d.ts +32 -0
- package/dist/core/artifacts.js +46 -0
- package/dist/core/artifacts.js.map +1 -0
- package/dist/core/version.js +3 -0
- package/dist/core/version.js.map +1 -1
- package/dist/core/workspace.js +1 -0
- package/dist/core/workspace.js.map +1 -1
- package/dist/integrations/adapters/graphify.js +2 -1
- package/dist/integrations/adapters/graphify.js.map +1 -1
- package/dist/integrations/adapters/pluginSkill.js +15 -1
- package/dist/integrations/adapters/pluginSkill.js.map +1 -1
- package/dist/mcp/setup.d.ts +98 -5
- package/dist/mcp/setup.js +332 -82
- package/dist/mcp/setup.js.map +1 -1
- package/dist/mcp/tools.d.ts +6 -0
- package/dist/mcp/tools.js +67 -13
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/verify.d.ts +41 -0
- package/dist/mcp/verify.js +264 -0
- package/dist/mcp/verify.js.map +1 -0
- package/dist/services/doctor.js +64 -1
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/graph.d.ts +92 -4
- package/dist/services/graph.js +552 -191
- package/dist/services/graph.js.map +1 -1
- package/dist/services/setup.js +3 -0
- package/dist/services/setup.js.map +1 -1
- package/dist/services/taskContext.d.ts +20 -2
- package/dist/services/taskContext.js +29 -15
- package/dist/services/taskContext.js.map +1 -1
- package/dist/utils/proc.js +19 -3
- package/dist/utils/proc.js.map +1 -1
- package/docs/agents.md +2 -2
- package/docs/claude.md +13 -0
- package/docs/getting-started.md +40 -1
- package/docs/integrations.md +16 -1
- package/docs/mcp.md +46 -10
- package/docs/troubleshooting.md +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { McpServerDef } from './setup.js';
|
|
2
|
+
/**
|
|
3
|
+
* Lifecycle stages DevWorkspace can verify on its own. Registration with, approval by, and connection to the
|
|
4
|
+
* agent (Claude Code, Codex, ...) happen inside that agent and are NOT covered here.
|
|
5
|
+
*/
|
|
6
|
+
export type McpVerifyStage = 'launch' | 'initialize' | 'tools_list' | 'health' | 'tool_call' | 'context';
|
|
7
|
+
export interface McpStageResult {
|
|
8
|
+
stage: McpVerifyStage;
|
|
9
|
+
ok: boolean;
|
|
10
|
+
detail: string;
|
|
11
|
+
}
|
|
12
|
+
export interface McpVerifyResult {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
/** Always 'server-in-isolation': this exercises the configured command directly, not a live agent connection. */
|
|
15
|
+
scope: 'server-in-isolation';
|
|
16
|
+
stages: McpStageResult[];
|
|
17
|
+
failedStage?: McpVerifyStage;
|
|
18
|
+
advice?: string;
|
|
19
|
+
tools: string[];
|
|
20
|
+
/** Version the started server reported in `initialize`; compare with the CLI you meant to launch. */
|
|
21
|
+
serverVersion?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function cleanLauncherEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
24
|
+
export interface McpVerifyOptions {
|
|
25
|
+
cwd: string;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
env?: NodeJS.ProcessEnv;
|
|
28
|
+
}
|
|
29
|
+
/** Start the configured MCP server and drive initialize -> tools/list -> tools/call over stdio. */
|
|
30
|
+
export declare function verifyMcpServer(def: McpServerDef, opts: McpVerifyOptions): Promise<McpVerifyResult>;
|
|
31
|
+
export interface AgentObservation {
|
|
32
|
+
agent: 'claude-code';
|
|
33
|
+
/** 'not-observed' = the agent CLI is not installed or gave no status; nothing is claimed in that case. */
|
|
34
|
+
status: 'connected' | 'pending-approval' | 'failed' | 'not-observed';
|
|
35
|
+
detail: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Ask the real Claude Code CLI how it sees the project's `devworkspace` server (`claude mcp get devworkspace`).
|
|
39
|
+
* This is the only agent-side signal available from outside: it can report registered/pending approval/connected.
|
|
40
|
+
*/
|
|
41
|
+
export declare function observeClaudeCode(cwd: string, timeoutMs?: number): Promise<AgentObservation>;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import { MCP_PROTOCOL_VERSION } from './types.js';
|
|
3
|
+
import { isShellShim, which } from '../utils/proc.js';
|
|
4
|
+
import { createRunner, shimInvocation } from '../integrations/exec.js';
|
|
5
|
+
/**
|
|
6
|
+
* Environment policy for the server started by the live check: an explicit ALLOWLIST (names matched
|
|
7
|
+
* case-insensitively, since Windows variables are case-insensitive). Anything not listed is not inherited, so
|
|
8
|
+
* unrelated credentials (cloud keys, CI secrets, DATABASE_URL, tool-specific tokens) never reach the child
|
|
9
|
+
* regardless of what they are called. Values are never logged.
|
|
10
|
+
*
|
|
11
|
+
* Kept, and why:
|
|
12
|
+
* - Process/platform basics Node and npx need on POSIX and Windows (PATH, HOME/USERPROFILE, temp dirs, locale, SystemRoot, ...).
|
|
13
|
+
* - Network settings npx needs to download the package: proxy variables and a small set of npm_config_* options
|
|
14
|
+
* (cache, registry, scoped registries, TLS/CA). Proxy and registry URLs may embed credentials the user chose to put there.
|
|
15
|
+
* - NPM_TOKEN / NODE_AUTH_TOKEN: the standard names an .npmrc substitutes for private-registry auth.
|
|
16
|
+
* - Anything the caller names in DEVWORKSPACE_VERIFY_ENV (comma-separated), for other private-registry setups.
|
|
17
|
+
* Dropped on purpose: npm-injected variables such as npm_config_package, which would redirect a nested
|
|
18
|
+
* `npx -y devworkspace@V` when setup itself runs under `npx --package=X`.
|
|
19
|
+
*/
|
|
20
|
+
const ENV_ALLOW = new RegExp('^(?:' + [
|
|
21
|
+
'PATH', 'PATHEXT', 'HOME', 'USER', 'USERNAME', 'LOGNAME', 'SHELL', 'TERM', 'LANG', 'LANGUAGE', 'LC_[A-Z_]+', 'TZ',
|
|
22
|
+
'TMPDIR', 'TMP', 'TEMP', 'XDG_[A-Z_]+',
|
|
23
|
+
'SYSTEMROOT', 'SYSTEMDRIVE', 'WINDIR', 'COMSPEC', 'OS', 'USERDOMAIN', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH',
|
|
24
|
+
'APPDATA', 'LOCALAPPDATA', 'PROGRAMDATA', 'PROGRAMFILES', 'PROGRAMFILES\\(X86\\)', 'PROGRAMW6432',
|
|
25
|
+
'COMMONPROGRAMFILES', 'ALLUSERSPROFILE', 'PUBLIC', 'PROCESSOR_ARCHITECTURE', 'NUMBER_OF_PROCESSORS',
|
|
26
|
+
'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'ALL_PROXY', 'NODE_EXTRA_CA_CERTS', 'SSL_CERT_FILE', 'SSL_CERT_DIR',
|
|
27
|
+
'NPM_TOKEN', 'NODE_AUTH_TOKEN',
|
|
28
|
+
'NPM_CONFIG_(?:CACHE|REGISTRY|PROXY|HTTPS_PROXY|NOPROXY|USERCONFIG|GLOBALCONFIG|PREFIX|CAFILE|STRICT_SSL|OFFLINE|PREFER_OFFLINE|PREFER_ONLINE|FETCH_[A-Z_]+|LOGLEVEL)',
|
|
29
|
+
'NPM_CONFIG_@[^:]+:REGISTRY',
|
|
30
|
+
].join('|') + ')$', 'i');
|
|
31
|
+
export function cleanLauncherEnv(env) {
|
|
32
|
+
const extra = new Set((env.DEVWORKSPACE_VERIFY_ENV ?? '').split(',').map((x) => x.trim().toLowerCase()).filter(Boolean));
|
|
33
|
+
return Object.fromEntries(Object.entries(env).filter(([k]) => ENV_ALLOW.test(k) || extra.has(k.toLowerCase())));
|
|
34
|
+
}
|
|
35
|
+
/** For the agent's own CLI (`claude mcp get`): everything except variables npm injected into this process. */
|
|
36
|
+
function withoutNpmInjected(env) {
|
|
37
|
+
const drop = /^npm_(?:command|execpath|node_execpath|lifecycle_.*|package_.*|config_(?:package|call|yes|y|workspaces?|include_workspace_root|local_prefix|global_prefix|init_module|node_gyp|user_agent|npm_version))$/i;
|
|
38
|
+
return Object.fromEntries(Object.entries(env).filter(([k]) => !drop.test(k)));
|
|
39
|
+
}
|
|
40
|
+
const REQUIRED_TOOLS = ['get_project_overview', 'get_task_context', 'get_file_context', 'check_mcp_health'];
|
|
41
|
+
function adviceFor(stage, def, detail) {
|
|
42
|
+
const cmd = [def.command, ...def.args].join(' ');
|
|
43
|
+
switch (stage) {
|
|
44
|
+
case 'launch':
|
|
45
|
+
if (/ENOENT|not found|not recognized|operable program/i.test(detail)) {
|
|
46
|
+
return `The launcher "${def.command}" is not available. Install Node.js >=20.11 (which provides npx), or re-run with --launcher direct after "npm i -g devworkspace".`;
|
|
47
|
+
}
|
|
48
|
+
if (/timed out/i.test(detail)) {
|
|
49
|
+
return `The server did not answer in time. If "${cmd}" must download the package, check network/npm registry access and retry; setup is safe to re-run.`;
|
|
50
|
+
}
|
|
51
|
+
return `The server process could not be started with "${cmd}". Run that command by hand to see the error.`;
|
|
52
|
+
case 'initialize':
|
|
53
|
+
return `The process started but did not complete MCP initialization. Run "${cmd}" by hand and check stderr; a version mismatch between the launcher and this CLI is a common cause.`;
|
|
54
|
+
case 'tools_list':
|
|
55
|
+
return 'The server initialized but tool discovery failed. Upgrade devworkspace so the MCP server and CLI versions match.';
|
|
56
|
+
case 'health':
|
|
57
|
+
case 'tool_call':
|
|
58
|
+
case 'context':
|
|
59
|
+
return 'The server lists its tools but a real call failed. Run "devworkspace doctor" and "devworkspace refresh", then retry.';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Start the configured MCP server and drive initialize -> tools/list -> tools/call over stdio. */
|
|
63
|
+
export async function verifyMcpServer(def, opts) {
|
|
64
|
+
const timeoutMs = opts.timeoutMs ?? 60_000;
|
|
65
|
+
const stages = [];
|
|
66
|
+
let tools = [];
|
|
67
|
+
const fail = (stage, detail) => {
|
|
68
|
+
stages.push({ stage, ok: false, detail });
|
|
69
|
+
return { ok: false, scope: 'server-in-isolation', stages, failedStage: stage, advice: adviceFor(stage, def, detail), tools };
|
|
70
|
+
};
|
|
71
|
+
// Windows shims (.cmd/.bat) are invoked through ComSpec with windowsVerbatimArguments: true, shell: false to eliminate DEP0190.
|
|
72
|
+
const win = process.platform === 'win32';
|
|
73
|
+
let spawnCmd = def.command;
|
|
74
|
+
let spawnArgs = def.args;
|
|
75
|
+
let verbatim = false;
|
|
76
|
+
if (win) {
|
|
77
|
+
const cmdLower = def.command.toLowerCase();
|
|
78
|
+
if (cmdLower === 'cmd' || cmdLower === 'cmd.exe') {
|
|
79
|
+
spawnCmd = def.command;
|
|
80
|
+
spawnArgs = def.args;
|
|
81
|
+
}
|
|
82
|
+
else if (isShellShim(def.command)) {
|
|
83
|
+
const inv = shimInvocation(def.command, def.args);
|
|
84
|
+
spawnCmd = inv.command;
|
|
85
|
+
spawnArgs = inv.args;
|
|
86
|
+
verbatim = true;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const resolved = await which(def.command, opts.env ?? process.env);
|
|
90
|
+
if (resolved && isShellShim(resolved)) {
|
|
91
|
+
const inv = shimInvocation(resolved, def.args);
|
|
92
|
+
spawnCmd = inv.command;
|
|
93
|
+
spawnArgs = inv.args;
|
|
94
|
+
verbatim = true;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
spawnCmd = resolved ?? def.command;
|
|
98
|
+
spawnArgs = def.args;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const child = spawn(spawnCmd, spawnArgs, {
|
|
103
|
+
cwd: opts.cwd,
|
|
104
|
+
env: cleanLauncherEnv(opts.env ?? process.env),
|
|
105
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
106
|
+
shell: false,
|
|
107
|
+
windowsHide: true,
|
|
108
|
+
windowsVerbatimArguments: verbatim,
|
|
109
|
+
// POSIX: own process group, so cleanup can end npx *and* the server it spawned.
|
|
110
|
+
detached: !win,
|
|
111
|
+
});
|
|
112
|
+
// A server that dies early closes the pipe; without a handler the resulting EPIPE would crash setup.
|
|
113
|
+
child.stdin.on('error', () => undefined);
|
|
114
|
+
let spawnError = null;
|
|
115
|
+
let stderr = '';
|
|
116
|
+
let exited = false;
|
|
117
|
+
child.on('error', (e) => { spawnError = e.message; });
|
|
118
|
+
child.on('exit', () => { exited = true; });
|
|
119
|
+
child.stderr.on('data', (d) => { stderr = (stderr + d.toString()).slice(-2000); });
|
|
120
|
+
const pending = new Map();
|
|
121
|
+
let buf = '';
|
|
122
|
+
let nonJsonLines = 0;
|
|
123
|
+
child.stdout.on('data', (d) => {
|
|
124
|
+
buf += d.toString();
|
|
125
|
+
let i;
|
|
126
|
+
while ((i = buf.indexOf('\n')) >= 0) {
|
|
127
|
+
const line = buf.slice(0, i).trim();
|
|
128
|
+
buf = buf.slice(i + 1);
|
|
129
|
+
if (!line)
|
|
130
|
+
continue;
|
|
131
|
+
try {
|
|
132
|
+
const m = JSON.parse(line);
|
|
133
|
+
if (typeof m.id === 'number')
|
|
134
|
+
pending.get(m.id)?.(m);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
nonJsonLines++; // ignored, but counted: a live process that only emits non-JSON is a protocol failure, not a launch failure
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const deadline = Date.now() + timeoutMs;
|
|
142
|
+
const request = (id, method, params) => new Promise((resolve, reject) => {
|
|
143
|
+
const left = deadline - Date.now();
|
|
144
|
+
const t = setTimeout(() => { pending.delete(id); reject(new Error(`timed out after ${timeoutMs}ms waiting for ${method}`)); }, Math.max(left, 1));
|
|
145
|
+
pending.set(id, (m) => { clearTimeout(t); pending.delete(id); resolve(m); });
|
|
146
|
+
const poll = setInterval(() => {
|
|
147
|
+
if (spawnError || exited) {
|
|
148
|
+
clearInterval(poll);
|
|
149
|
+
clearTimeout(t);
|
|
150
|
+
pending.delete(id);
|
|
151
|
+
reject(new Error(spawnError ?? `server exited before answering ${method}${stderr ? `: ${stderr.trim().split('\n').pop()}` : ''}`));
|
|
152
|
+
}
|
|
153
|
+
else if (!pending.has(id))
|
|
154
|
+
clearInterval(poll);
|
|
155
|
+
}, 100);
|
|
156
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
|
|
157
|
+
});
|
|
158
|
+
try {
|
|
159
|
+
let init;
|
|
160
|
+
try {
|
|
161
|
+
init = await request(1, 'initialize', { protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: 'devworkspace-setup', version: '1' } });
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
// Nothing answered: the process never came up (or died); that is a launch failure, not a protocol one.
|
|
165
|
+
if (nonJsonLines > 0)
|
|
166
|
+
return fail('initialize', `the process is running but sent ${nonJsonLines} non-JSON line(s) on stdout instead of MCP messages (stdout must carry only JSON-RPC)`);
|
|
167
|
+
return fail('launch', e.message);
|
|
168
|
+
}
|
|
169
|
+
stages.push({ stage: 'launch', ok: true, detail: `started "${[def.command, ...def.args].join(' ')}"` });
|
|
170
|
+
if (init.error || !init.result?.serverInfo)
|
|
171
|
+
return fail('initialize', init.error?.message ?? 'no serverInfo in initialize result');
|
|
172
|
+
stages.push({ stage: 'initialize', ok: true, detail: `${init.result.serverInfo.name} ${init.result.serverInfo.version ?? ''}`.trim() });
|
|
173
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
|
|
174
|
+
let list;
|
|
175
|
+
try {
|
|
176
|
+
list = await request(2, 'tools/list', {});
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
return fail('tools_list', e.message);
|
|
180
|
+
}
|
|
181
|
+
tools = Array.isArray(list.result?.tools) ? list.result.tools.map((t) => t.name) : [];
|
|
182
|
+
const missing = REQUIRED_TOOLS.filter((t) => !tools.includes(t));
|
|
183
|
+
if (list.error || missing.length > 0)
|
|
184
|
+
return fail('tools_list', list.error?.message ?? `missing tools: ${missing.join(', ')}`);
|
|
185
|
+
stages.push({ stage: 'tools_list', ok: true, detail: `${tools.length} tools discovered` });
|
|
186
|
+
let health;
|
|
187
|
+
try {
|
|
188
|
+
health = await request(5, 'tools/call', { name: 'check_mcp_health', arguments: {} });
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
return fail('health', e.message);
|
|
192
|
+
}
|
|
193
|
+
if (health.error || health.result?.isError)
|
|
194
|
+
return fail('health', health.error?.message ?? String(health.result?.content?.[0]?.text ?? 'tool returned an error').slice(0, 200));
|
|
195
|
+
stages.push({ stage: 'health', ok: true, detail: 'check_mcp_health returned a result' });
|
|
196
|
+
let call;
|
|
197
|
+
try {
|
|
198
|
+
call = await request(3, 'tools/call', { name: 'get_project_overview', arguments: {} });
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
return fail('tool_call', e.message);
|
|
202
|
+
}
|
|
203
|
+
if (call.error || call.result?.isError)
|
|
204
|
+
return fail('tool_call', call.error?.message ?? String(call.result?.content?.[0]?.text ?? 'tool returned an error').slice(0, 200));
|
|
205
|
+
stages.push({ stage: 'tool_call', ok: true, detail: 'get_project_overview returned a result' });
|
|
206
|
+
let ctx;
|
|
207
|
+
try {
|
|
208
|
+
ctx = await request(4, 'tools/call', { name: 'get_task_context', arguments: { task: 'describe this project' } });
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
return fail('context', e.message);
|
|
212
|
+
}
|
|
213
|
+
const text = String(ctx.result?.content?.[0]?.text ?? '');
|
|
214
|
+
if (ctx.error || ctx.result?.isError || text.trim() === '')
|
|
215
|
+
return fail('context', ctx.error?.message ?? (text.slice(0, 200) || 'empty result'));
|
|
216
|
+
stages.push({ stage: 'context', ok: true, detail: `get_task_context returned ${text.length} characters` });
|
|
217
|
+
return { ok: true, scope: 'server-in-isolation', stages, tools, ...(init.result.serverInfo.version ? { serverVersion: String(init.result.serverInfo.version) } : {}) };
|
|
218
|
+
}
|
|
219
|
+
finally {
|
|
220
|
+
try {
|
|
221
|
+
child.stdin.end();
|
|
222
|
+
}
|
|
223
|
+
catch { /* already closed */ }
|
|
224
|
+
// With shell:true on Windows, kill() only ends the shell; take the whole tree so no server keeps the project dir open.
|
|
225
|
+
if (process.platform === 'win32' && child.pid)
|
|
226
|
+
spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], { windowsHide: true });
|
|
227
|
+
else {
|
|
228
|
+
try {
|
|
229
|
+
if (child.pid)
|
|
230
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
231
|
+
else
|
|
232
|
+
child.kill();
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
child.kill();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Ask the real Claude Code CLI how it sees the project's `devworkspace` server (`claude mcp get devworkspace`).
|
|
242
|
+
* This is the only agent-side signal available from outside: it can report registered/pending approval/connected.
|
|
243
|
+
*/
|
|
244
|
+
export async function observeClaudeCode(cwd, timeoutMs = 45_000) {
|
|
245
|
+
const runner = createRunner(withoutNpmInjected(process.env));
|
|
246
|
+
const claudeExe = await runner.which('claude');
|
|
247
|
+
if (!claudeExe) {
|
|
248
|
+
return { agent: 'claude-code', status: 'not-observed', detail: 'the claude CLI is not available or did not answer' };
|
|
249
|
+
}
|
|
250
|
+
const r = await runner.run({ command: claudeExe, args: ['mcp', 'get', 'devworkspace'], cwd, timeoutMs });
|
|
251
|
+
const text = `${r.stdout}\n${r.stderr}`;
|
|
252
|
+
const status = /Status:\s*(.+)/.exec(text)?.[1]?.trim();
|
|
253
|
+
if (!status) {
|
|
254
|
+
return { agent: 'claude-code', status: 'not-observed', detail: r.ok ? 'claude returned no status line' : 'the claude CLI is not available or did not answer' };
|
|
255
|
+
}
|
|
256
|
+
if (/pending approval/i.test(status))
|
|
257
|
+
return { agent: 'claude-code', status: 'pending-approval', detail: 'Claude Code sees the server but you have not approved it yet (run `claude` in this project and approve it)' };
|
|
258
|
+
if (/connected|✔|✓/i.test(status) && !/fail/i.test(status))
|
|
259
|
+
return { agent: 'claude-code', status: 'connected', detail: status };
|
|
260
|
+
if (/fail|error|✗|✘/i.test(status))
|
|
261
|
+
return { agent: 'claude-code', status: 'failed', detail: status };
|
|
262
|
+
return { agent: 'claude-code', status: 'not-observed', detail: `unrecognized status: ${status}` };
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/mcp/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AA0BvE;;;;;;;;;;;;;;GAcG;AACH,MAAM,SAAS,GAAG,IAAI,MAAM,CAC1B,MAAM,GAAG;IACP,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI;IACjH,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa;IACtC,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU;IAC5G,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,uBAAuB,EAAE,cAAc;IACjG,o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EAAE,IAAI,EAAE,CAAC;IACxD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,mDAAmD,EAAE,CAAC;IACjK,CAAC;IACD,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,4GAA4G,EAAE,CAAC;IACxN,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjI,IAAI,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtG,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,wBAAwB,MAAM,EAAE,EAAE,CAAC;AACpG,CAAC","sourcesContent":["import { spawn, spawnSync } from 'node:child_process';\nimport { MCP_PROTOCOL_VERSION } from './types.js';\nimport type { McpServerDef } from './setup.js';\nimport { isShellShim, which } from '../utils/proc.js';\nimport { createRunner, shimInvocation } from '../integrations/exec.js';\n\n/**\n * Lifecycle stages DevWorkspace can verify on its own. Registration with, approval by, and connection to the\n * agent (Claude Code, Codex, ...) happen inside that agent and are NOT covered here.\n */\nexport type McpVerifyStage = 'launch' | 'initialize' | 'tools_list' | 'health' | 'tool_call' | 'context';\n\nexport interface McpStageResult {\n stage: McpVerifyStage;\n ok: boolean;\n detail: string;\n}\n\nexport interface McpVerifyResult {\n ok: boolean;\n /** Always 'server-in-isolation': this exercises the configured command directly, not a live agent connection. */\n scope: 'server-in-isolation';\n stages: McpStageResult[];\n failedStage?: McpVerifyStage;\n advice?: string;\n tools: string[];\n /** Version the started server reported in `initialize`; compare with the CLI you meant to launch. */\n serverVersion?: string;\n}\n\n/**\n * Environment policy for the server started by the live check: an explicit ALLOWLIST (names matched\n * case-insensitively, since Windows variables are case-insensitive). Anything not listed is not inherited, so\n * unrelated credentials (cloud keys, CI secrets, DATABASE_URL, tool-specific tokens) never reach the child\n * regardless of what they are called. Values are never logged.\n *\n * Kept, and why:\n * - Process/platform basics Node and npx need on POSIX and Windows (PATH, HOME/USERPROFILE, temp dirs, locale, SystemRoot, ...).\n * - Network settings npx needs to download the package: proxy variables and a small set of npm_config_* options\n * (cache, registry, scoped registries, TLS/CA). Proxy and registry URLs may embed credentials the user chose to put there.\n * - NPM_TOKEN / NODE_AUTH_TOKEN: the standard names an .npmrc substitutes for private-registry auth.\n * - Anything the caller names in DEVWORKSPACE_VERIFY_ENV (comma-separated), for other private-registry setups.\n * Dropped on purpose: npm-injected variables such as npm_config_package, which would redirect a nested\n * `npx -y devworkspace@V` when setup itself runs under `npx --package=X`.\n */\nconst ENV_ALLOW = new RegExp(\n '^(?:' + [\n 'PATH', 'PATHEXT', 'HOME', 'USER', 'USERNAME', 'LOGNAME', 'SHELL', 'TERM', 'LANG', 'LANGUAGE', 'LC_[A-Z_]+', 'TZ',\n 'TMPDIR', 'TMP', 'TEMP', 'XDG_[A-Z_]+',\n 'SYSTEMROOT', 'SYSTEMDRIVE', 'WINDIR', 'COMSPEC', 'OS', 'USERDOMAIN', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH',\n 'APPDATA', 'LOCALAPPDATA', 'PROGRAMDATA', 'PROGRAMFILES', 'PROGRAMFILES\\\\(X86\\\\)', 'PROGRAMW6432',\n 'COMMONPROGRAMFILES', 'ALLUSERSPROFILE', 'PUBLIC', 'PROCESSOR_ARCHITECTURE', 'NUMBER_OF_PROCESSORS',\n 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'ALL_PROXY', 'NODE_EXTRA_CA_CERTS', 'SSL_CERT_FILE', 'SSL_CERT_DIR',\n 'NPM_TOKEN', 'NODE_AUTH_TOKEN',\n 'NPM_CONFIG_(?:CACHE|REGISTRY|PROXY|HTTPS_PROXY|NOPROXY|USERCONFIG|GLOBALCONFIG|PREFIX|CAFILE|STRICT_SSL|OFFLINE|PREFER_OFFLINE|PREFER_ONLINE|FETCH_[A-Z_]+|LOGLEVEL)',\n 'NPM_CONFIG_@[^:]+:REGISTRY',\n ].join('|') + ')$',\n 'i',\n);\n\nexport function cleanLauncherEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {\n const extra = new Set((env.DEVWORKSPACE_VERIFY_ENV ?? '').split(',').map((x) => x.trim().toLowerCase()).filter(Boolean));\n return Object.fromEntries(Object.entries(env).filter(([k]) => ENV_ALLOW.test(k) || extra.has(k.toLowerCase())));\n}\n\n/** For the agent's own CLI (`claude mcp get`): everything except variables npm injected into this process. */\nfunction withoutNpmInjected(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {\n const drop = /^npm_(?:command|execpath|node_execpath|lifecycle_.*|package_.*|config_(?:package|call|yes|y|workspaces?|include_workspace_root|local_prefix|global_prefix|init_module|node_gyp|user_agent|npm_version))$/i;\n return Object.fromEntries(Object.entries(env).filter(([k]) => !drop.test(k)));\n}\n\nexport interface McpVerifyOptions {\n cwd: string;\n timeoutMs?: number;\n env?: NodeJS.ProcessEnv;\n}\n\nconst REQUIRED_TOOLS = ['get_project_overview', 'get_task_context', 'get_file_context', 'check_mcp_health'];\n\nfunction adviceFor(stage: McpVerifyStage, def: McpServerDef, detail: string): string {\n const cmd = [def.command, ...def.args].join(' ');\n switch (stage) {\n case 'launch':\n if (/ENOENT|not found|not recognized|operable program/i.test(detail)) {\n return `The launcher \"${def.command}\" is not available. Install Node.js >=20.11 (which provides npx), or re-run with --launcher direct after \"npm i -g devworkspace\".`;\n }\n if (/timed out/i.test(detail)) {\n return `The server did not answer in time. If \"${cmd}\" must download the package, check network/npm registry access and retry; setup is safe to re-run.`;\n }\n return `The server process could not be started with \"${cmd}\". Run that command by hand to see the error.`;\n case 'initialize':\n return `The process started but did not complete MCP initialization. Run \"${cmd}\" by hand and check stderr; a version mismatch between the launcher and this CLI is a common cause.`;\n case 'tools_list':\n return 'The server initialized but tool discovery failed. Upgrade devworkspace so the MCP server and CLI versions match.';\n case 'health':\n case 'tool_call':\n case 'context':\n return 'The server lists its tools but a real call failed. Run \"devworkspace doctor\" and \"devworkspace refresh\", then retry.';\n }\n}\n\n/** Start the configured MCP server and drive initialize -> tools/list -> tools/call over stdio. */\nexport async function verifyMcpServer(def: McpServerDef, opts: McpVerifyOptions): Promise<McpVerifyResult> {\n const timeoutMs = opts.timeoutMs ?? 60_000;\n const stages: McpStageResult[] = [];\n let tools: string[] = [];\n const fail = (stage: McpVerifyStage, detail: string): McpVerifyResult => {\n stages.push({ stage, ok: false, detail });\n return { ok: false, scope: 'server-in-isolation', stages, failedStage: stage, advice: adviceFor(stage, def, detail), tools };\n };\n\n // Windows shims (.cmd/.bat) are invoked through ComSpec with windowsVerbatimArguments: true, shell: false to eliminate DEP0190.\n const win = process.platform === 'win32';\n let spawnCmd = def.command;\n let spawnArgs = def.args;\n let verbatim = false;\n\n if (win) {\n const cmdLower = def.command.toLowerCase();\n if (cmdLower === 'cmd' || cmdLower === 'cmd.exe') {\n spawnCmd = def.command;\n spawnArgs = def.args;\n } else if (isShellShim(def.command)) {\n const inv = shimInvocation(def.command, def.args);\n spawnCmd = inv.command;\n spawnArgs = inv.args;\n verbatim = true;\n } else {\n const resolved = await which(def.command, opts.env ?? process.env);\n if (resolved && isShellShim(resolved)) {\n const inv = shimInvocation(resolved, def.args);\n spawnCmd = inv.command;\n spawnArgs = inv.args;\n verbatim = true;\n } else {\n spawnCmd = resolved ?? def.command;\n spawnArgs = def.args;\n }\n }\n }\n\n const child = spawn(spawnCmd, spawnArgs, {\n cwd: opts.cwd,\n env: cleanLauncherEnv(opts.env ?? process.env),\n stdio: ['pipe', 'pipe', 'pipe'],\n shell: false,\n windowsHide: true,\n windowsVerbatimArguments: verbatim,\n // POSIX: own process group, so cleanup can end npx *and* the server it spawned.\n detached: !win,\n });\n // A server that dies early closes the pipe; without a handler the resulting EPIPE would crash setup.\n child.stdin.on('error', () => undefined);\n\n let spawnError: string | null = null;\n let stderr = '';\n let exited = false;\n child.on('error', (e) => { spawnError = e.message; });\n child.on('exit', () => { exited = true; });\n child.stderr.on('data', (d: Buffer) => { stderr = (stderr + d.toString()).slice(-2000); });\n\n const pending = new Map<number, (m: Record<string, any>) => void>();\n let buf = '';\n let nonJsonLines = 0;\n child.stdout.on('data', (d: Buffer) => {\n buf += d.toString();\n let i: number;\n while ((i = buf.indexOf('\\n')) >= 0) {\n const line = buf.slice(0, i).trim();\n buf = buf.slice(i + 1);\n if (!line) continue;\n try {\n const m = JSON.parse(line) as Record<string, any>;\n if (typeof m.id === 'number') pending.get(m.id)?.(m);\n } catch {\n nonJsonLines++; // ignored, but counted: a live process that only emits non-JSON is a protocol failure, not a launch failure\n }\n }\n });\n\n const deadline = Date.now() + timeoutMs;\n const request = (id: number, method: string, params: unknown): Promise<Record<string, any>> =>\n new Promise((resolve, reject) => {\n const left = deadline - Date.now();\n const t = setTimeout(() => { pending.delete(id); reject(new Error(`timed out after ${timeoutMs}ms waiting for ${method}`)); }, Math.max(left, 1));\n pending.set(id, (m) => { clearTimeout(t); pending.delete(id); resolve(m); });\n const poll = setInterval(() => {\n if (spawnError || exited) {\n clearInterval(poll); clearTimeout(t); pending.delete(id);\n reject(new Error(spawnError ?? `server exited before answering ${method}${stderr ? `: ${stderr.trim().split('\\n').pop()}` : ''}`));\n } else if (!pending.has(id)) clearInterval(poll);\n }, 100);\n child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\\n');\n });\n\n try {\n let init: Record<string, any>;\n try {\n init = await request(1, 'initialize', { protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: 'devworkspace-setup', version: '1' } });\n } catch (e) {\n // Nothing answered: the process never came up (or died); that is a launch failure, not a protocol one.\n if (nonJsonLines > 0) return fail('initialize', `the process is running but sent ${nonJsonLines} non-JSON line(s) on stdout instead of MCP messages (stdout must carry only JSON-RPC)`);\n return fail('launch', (e as Error).message);\n }\n stages.push({ stage: 'launch', ok: true, detail: `started \"${[def.command, ...def.args].join(' ')}\"` });\n if (init.error || !init.result?.serverInfo) return fail('initialize', init.error?.message ?? 'no serverInfo in initialize result');\n stages.push({ stage: 'initialize', ok: true, detail: `${init.result.serverInfo.name} ${init.result.serverInfo.version ?? ''}`.trim() });\n child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\\n');\n\n let list: Record<string, any>;\n try { list = await request(2, 'tools/list', {}); } catch (e) { return fail('tools_list', (e as Error).message); }\n tools = Array.isArray(list.result?.tools) ? list.result.tools.map((t: { name: string }) => t.name) : [];\n const missing = REQUIRED_TOOLS.filter((t) => !tools.includes(t));\n if (list.error || missing.length > 0) return fail('tools_list', list.error?.message ?? `missing tools: ${missing.join(', ')}`);\n stages.push({ stage: 'tools_list', ok: true, detail: `${tools.length} tools discovered` });\n\n let health: Record<string, any>;\n try { health = await request(5, 'tools/call', { name: 'check_mcp_health', arguments: {} }); } catch (e) { return fail('health', (e as Error).message); }\n if (health.error || health.result?.isError) return fail('health', health.error?.message ?? String(health.result?.content?.[0]?.text ?? 'tool returned an error').slice(0, 200));\n stages.push({ stage: 'health', ok: true, detail: 'check_mcp_health returned a result' });\n\n let call: Record<string, any>;\n try { call = await request(3, 'tools/call', { name: 'get_project_overview', arguments: {} }); } catch (e) { return fail('tool_call', (e as Error).message); }\n if (call.error || call.result?.isError) return fail('tool_call', call.error?.message ?? String(call.result?.content?.[0]?.text ?? 'tool returned an error').slice(0, 200));\n stages.push({ stage: 'tool_call', ok: true, detail: 'get_project_overview returned a result' });\n\n let ctx: Record<string, any>;\n try { ctx = await request(4, 'tools/call', { name: 'get_task_context', arguments: { task: 'describe this project' } }); } catch (e) { return fail('context', (e as Error).message); }\n const text = String(ctx.result?.content?.[0]?.text ?? '');\n if (ctx.error || ctx.result?.isError || text.trim() === '') return fail('context', ctx.error?.message ?? (text.slice(0, 200) || 'empty result'));\n stages.push({ stage: 'context', ok: true, detail: `get_task_context returned ${text.length} characters` });\n\n return { ok: true, scope: 'server-in-isolation', stages, tools, ...(init.result.serverInfo.version ? { serverVersion: String(init.result.serverInfo.version) } : {}) };\n } finally {\n try { child.stdin.end(); } catch { /* already closed */ }\n // With shell:true on Windows, kill() only ends the shell; take the whole tree so no server keeps the project dir open.\n if (process.platform === 'win32' && child.pid) spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], { windowsHide: true });\n else {\n try { if (child.pid) process.kill(-child.pid, 'SIGKILL'); else child.kill(); } catch { child.kill(); }\n }\n }\n}\n\nexport interface AgentObservation {\n agent: 'claude-code';\n /** 'not-observed' = the agent CLI is not installed or gave no status; nothing is claimed in that case. */\n status: 'connected' | 'pending-approval' | 'failed' | 'not-observed';\n detail: string;\n}\n\n/**\n * Ask the real Claude Code CLI how it sees the project's `devworkspace` server (`claude mcp get devworkspace`).\n * This is the only agent-side signal available from outside: it can report registered/pending approval/connected.\n */\nexport async function observeClaudeCode(cwd: string, timeoutMs = 45_000): Promise<AgentObservation> {\n const runner = createRunner(withoutNpmInjected(process.env));\n const claudeExe = await runner.which('claude');\n if (!claudeExe) {\n return { agent: 'claude-code', status: 'not-observed', detail: 'the claude CLI is not available or did not answer' };\n }\n const r = await runner.run({ command: claudeExe, args: ['mcp', 'get', 'devworkspace'], cwd, timeoutMs });\n const text = `${r.stdout}\\n${r.stderr}`;\n const status = /Status:\\s*(.+)/.exec(text)?.[1]?.trim();\n if (!status) {\n return { agent: 'claude-code', status: 'not-observed', detail: r.ok ? 'claude returned no status line' : 'the claude CLI is not available or did not answer' };\n }\n if (/pending approval/i.test(status)) return { agent: 'claude-code', status: 'pending-approval', detail: 'Claude Code sees the server but you have not approved it yet (run `claude` in this project and approve it)' };\n if (/connected|✔|✓/i.test(status) && !/fail/i.test(status)) return { agent: 'claude-code', status: 'connected', detail: status };\n if (/fail|error|✗|✘/i.test(status)) return { agent: 'claude-code', status: 'failed', detail: status };\n return { agent: 'claude-code', status: 'not-observed', detail: `unrecognized status: ${status}` };\n}\n"]}
|
package/dist/services/doctor.js
CHANGED
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { SCHEMA_VERSION, validateAnalysisState, validateCommands } from '../config/schemas.js';
|
|
4
4
|
import { findWorkspaceRoot, LOCAL_GITIGNORE, loadProject, wsPaths } from '../core/workspace.js';
|
|
5
5
|
import { readVersioned } from '../core/versioned.js';
|
|
6
|
+
import { resolveGraphifyGraph } from '../core/artifacts.js';
|
|
6
7
|
import { getGitState, gitAvailable, gitTrackedFiles } from '../git/git.js';
|
|
7
8
|
import { inspectAll, summarize } from '../integrations/index.js';
|
|
8
9
|
import { evaluateStaleness, loadFacts } from '../knowledge/facts.js';
|
|
@@ -235,6 +236,7 @@ export async function runDoctor(o) {
|
|
|
235
236
|
add('onboarding', 'warn', 'Onboarding is not complete: .devworkspace/context/architecture.md is missing or empty', 'Paste .devworkspace/analysis/onboarding-prompt.md into your coding agent (Claude Code, Cursor, Copilot, Codex, etc.).');
|
|
236
237
|
// MCP launcher configuration verification
|
|
237
238
|
await checkMcpLauncher(root, add);
|
|
239
|
+
await checkGraphLayout(root, add);
|
|
238
240
|
// Security and portability.
|
|
239
241
|
const wsFiles = (await listFilesRecursive(ws.dir, 3000)).filter((f) => !f.startsWith(ws.localDir) && !/\.tmp$/.test(f));
|
|
240
242
|
const secretHits = [];
|
|
@@ -353,6 +355,46 @@ async function checkDiscovery(ws, add) {
|
|
|
353
355
|
add('discovery-ecosystem', 'info', 'No source files or manifests detected');
|
|
354
356
|
}
|
|
355
357
|
}
|
|
358
|
+
/** Graphify's own commands hardcode root graphify-out/, so that stays; say so, and flag a duplicate in .devworkspace/graph. */
|
|
359
|
+
async function checkGraphLayout(root, add) {
|
|
360
|
+
const g = await resolveGraphifyGraph(root);
|
|
361
|
+
if (!g.exists)
|
|
362
|
+
return;
|
|
363
|
+
const rel = path.relative(root, g.file).replace(/\\/g, '/');
|
|
364
|
+
if (g.conflict) {
|
|
365
|
+
add('graph-layout', 'warn', `Graphify graphs exist in two locations; reading ${rel} (most recent). ${path.relative(root, g.conflict.other).replace(/\\/g, '/')} is ignored.`, 'Keep one: delete the stale copy yourself, or regenerate with "graphify update ." (nothing is moved or deleted automatically).');
|
|
366
|
+
}
|
|
367
|
+
// Staleness: Graphify records the commit it was built at as the last key; compare with HEAD without parsing the whole file.
|
|
368
|
+
const built = await readGraphCommit(g.file);
|
|
369
|
+
const head = (await getGitState(root).catch(() => null))?.head ?? null;
|
|
370
|
+
if (built && head && built !== head) {
|
|
371
|
+
add('graph-stale', 'warn', `Graph was built at commit ${built.slice(0, 8)} but HEAD is ${head.slice(0, 8)}; relationships may be stale.`, 'Run "graphify update ." (no LLM cost) to refresh it. Uncommitted edits are not reflected in either case.');
|
|
372
|
+
}
|
|
373
|
+
if (!g.conflict && g.location === 'tool-owned-root') {
|
|
374
|
+
add('graph-layout', 'pass', `Graph at ${rel} (Graphify-owned location; "graphify update" and the /graphify skill require it at the project root)`);
|
|
375
|
+
}
|
|
376
|
+
else if (!g.conflict) {
|
|
377
|
+
add('graph-layout', 'pass', `Graph at ${rel} (DevWorkspace-managed location)`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
async function readGraphCommit(file) {
|
|
381
|
+
try {
|
|
382
|
+
const fh = await fs.open(file, 'r');
|
|
383
|
+
try {
|
|
384
|
+
const { size } = await fh.stat();
|
|
385
|
+
const len = Math.min(size, 512);
|
|
386
|
+
const buf = Buffer.alloc(len);
|
|
387
|
+
await fh.read(buf, 0, len, size - len);
|
|
388
|
+
return /"built_at_commit"\s*:\s*"([0-9a-f]{7,40})"/.exec(buf.toString('utf8'))?.[1] ?? null;
|
|
389
|
+
}
|
|
390
|
+
finally {
|
|
391
|
+
await fh.close();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
356
398
|
async function checkMcpLauncher(root, add) {
|
|
357
399
|
const configs = [
|
|
358
400
|
{ file: '.mcp.json' },
|
|
@@ -381,6 +423,27 @@ async function checkMcpLauncher(root, add) {
|
|
|
381
423
|
}
|
|
382
424
|
}
|
|
383
425
|
}
|
|
426
|
+
// Codex: project-scoped TOML written by `setup --agent codex` (our managed block only).
|
|
427
|
+
const toml = await readTextBounded(path.join(root, '.codex', 'config.toml'), 200_000).catch(() => null);
|
|
428
|
+
const tomlCmd = toml ? /\[mcp_servers\.devworkspace\][^[]*?command\s*=\s*"([^"]+)"[^[]*?args\s*=\s*(\[[^\]]*\])/s.exec(toml) : null;
|
|
429
|
+
if (tomlCmd) {
|
|
430
|
+
let args = [];
|
|
431
|
+
try {
|
|
432
|
+
args = JSON.parse(tomlCmd[2]).map(String);
|
|
433
|
+
}
|
|
434
|
+
catch { /* unparsable args: report the command alone */ }
|
|
435
|
+
found.push({ file: '.codex/config.toml', command: tomlCmd[1], args });
|
|
436
|
+
}
|
|
437
|
+
// Files earlier versions wrote that no supported client reads. Never deleted automatically.
|
|
438
|
+
const legacy = [];
|
|
439
|
+
for (const f of ['mcp.json', path.join('.antigravity', 'mcp.json')]) {
|
|
440
|
+
const text = await readTextBounded(path.join(root, f), 200_000).catch(() => null);
|
|
441
|
+
if (text && /"devworkspace"\s*:/.test(text))
|
|
442
|
+
legacy.push(f.split(path.sep).join('/'));
|
|
443
|
+
}
|
|
444
|
+
if (legacy.length > 0) {
|
|
445
|
+
add('mcp-legacy-config', 'warn', `${legacy.join(', ')} contain a devworkspace MCP entry, but Codex reads .codex/config.toml and Antigravity reads a user-level mcp_config.json; these files are not consumed by those agents.`, 'Run: devworkspace setup --agent codex (writes .codex/config.toml). The old file can be deleted by you; DevWorkspace will not delete it.');
|
|
446
|
+
}
|
|
384
447
|
if (found.length === 0)
|
|
385
448
|
return;
|
|
386
449
|
const badLaunchers = [];
|
|
@@ -422,7 +485,7 @@ async function checkMcpLauncher(root, add) {
|
|
|
422
485
|
add('mcp-launcher', 'warn', `Configured MCP launcher cannot be resolved: ${details}`, 'Install DevWorkspace globally (npm install -g devworkspace) or re-run: devworkspace setup --agent claude-code --launcher npx');
|
|
423
486
|
}
|
|
424
487
|
else {
|
|
425
|
-
const launchers = [...new Set(found.map((f) => f.command))].join('
|
|
488
|
+
const launchers = [...new Set(found.map((f) => [f.command, ...f.args].join(' ')))].join('; ');
|
|
426
489
|
add('mcp-launcher', 'pass', `Configured MCP launcher is resolvable (${launchers})`);
|
|
427
490
|
}
|
|
428
491
|
}
|