devworkspace 0.4.2 → 0.4.4
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 +51 -0
- package/README.md +299 -27
- package/dist/cli/args.d.ts +9 -0
- package/dist/cli/args.js +3 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/help.js +8 -4
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/render.js +53 -4
- package/dist/cli/render.js.map +1 -1
- package/dist/cli/run.js +42 -17
- 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/mcp/setup.d.ts +97 -2
- package/dist/mcp/setup.js +280 -67
- package/dist/mcp/setup.js.map +1 -1
- package/dist/mcp/tools.d.ts +6 -0
- package/dist/mcp/tools.js +140 -18
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/verify.d.ts +41 -0
- package/dist/mcp/verify.js +229 -0
- package/dist/mcp/verify.js.map +1 -0
- package/dist/services/doctor.js +139 -0
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/graph.d.ts +77 -3
- package/dist/services/graph.js +336 -185
- package/dist/services/graph.js.map +1 -1
- package/dist/services/init.js +5 -1
- package/dist/services/init.js.map +1 -1
- package/dist/services/setup.js +4 -0
- package/dist/services/setup.js.map +1 -1
- package/dist/services/taskContext.d.ts +24 -2
- package/dist/services/taskContext.js +72 -26
- package/dist/services/taskContext.js.map +1 -1
- package/dist/tasks/routing.js +4 -1
- package/dist/tasks/routing.js.map +1 -1
- package/docs/agents.md +18 -4
- package/docs/claude.md +13 -0
- package/docs/getting-started.md +40 -1
- package/docs/integrations.md +16 -1
- package/docs/mcp.md +46 -14
- 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,229 @@
|
|
|
1
|
+
import { exec, spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import { MCP_PROTOCOL_VERSION } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Environment policy for the server started by the live check: an explicit ALLOWLIST (names matched
|
|
5
|
+
* case-insensitively, since Windows variables are case-insensitive). Anything not listed is not inherited, so
|
|
6
|
+
* unrelated credentials (cloud keys, CI secrets, DATABASE_URL, tool-specific tokens) never reach the child
|
|
7
|
+
* regardless of what they are called. Values are never logged.
|
|
8
|
+
*
|
|
9
|
+
* Kept, and why:
|
|
10
|
+
* - Process/platform basics Node and npx need on POSIX and Windows (PATH, HOME/USERPROFILE, temp dirs, locale, SystemRoot, ...).
|
|
11
|
+
* - Network settings npx needs to download the package: proxy variables and a small set of npm_config_* options
|
|
12
|
+
* (cache, registry, scoped registries, TLS/CA). Proxy and registry URLs may embed credentials the user chose to put there.
|
|
13
|
+
* - NPM_TOKEN / NODE_AUTH_TOKEN: the standard names an .npmrc substitutes for private-registry auth.
|
|
14
|
+
* - Anything the caller names in DEVWORKSPACE_VERIFY_ENV (comma-separated), for other private-registry setups.
|
|
15
|
+
* Dropped on purpose: npm-injected variables such as npm_config_package, which would redirect a nested
|
|
16
|
+
* `npx -y devworkspace@V` when setup itself runs under `npx --package=X`.
|
|
17
|
+
*/
|
|
18
|
+
const ENV_ALLOW = new RegExp('^(?:' + [
|
|
19
|
+
'PATH', 'PATHEXT', 'HOME', 'USER', 'USERNAME', 'LOGNAME', 'SHELL', 'TERM', 'LANG', 'LANGUAGE', 'LC_[A-Z_]+', 'TZ',
|
|
20
|
+
'TMPDIR', 'TMP', 'TEMP', 'XDG_[A-Z_]+',
|
|
21
|
+
'SYSTEMROOT', 'SYSTEMDRIVE', 'WINDIR', 'COMSPEC', 'OS', 'USERDOMAIN', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH',
|
|
22
|
+
'APPDATA', 'LOCALAPPDATA', 'PROGRAMDATA', 'PROGRAMFILES', 'PROGRAMFILES\\(X86\\)', 'PROGRAMW6432',
|
|
23
|
+
'COMMONPROGRAMFILES', 'ALLUSERSPROFILE', 'PUBLIC', 'PROCESSOR_ARCHITECTURE', 'NUMBER_OF_PROCESSORS',
|
|
24
|
+
'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'ALL_PROXY', 'NODE_EXTRA_CA_CERTS', 'SSL_CERT_FILE', 'SSL_CERT_DIR',
|
|
25
|
+
'NPM_TOKEN', 'NODE_AUTH_TOKEN',
|
|
26
|
+
'NPM_CONFIG_(?:CACHE|REGISTRY|PROXY|HTTPS_PROXY|NOPROXY|USERCONFIG|GLOBALCONFIG|PREFIX|CAFILE|STRICT_SSL|OFFLINE|PREFER_OFFLINE|PREFER_ONLINE|FETCH_[A-Z_]+|LOGLEVEL)',
|
|
27
|
+
'NPM_CONFIG_@[^:]+:REGISTRY',
|
|
28
|
+
].join('|') + ')$', 'i');
|
|
29
|
+
export function cleanLauncherEnv(env) {
|
|
30
|
+
const extra = new Set((env.DEVWORKSPACE_VERIFY_ENV ?? '').split(',').map((x) => x.trim().toLowerCase()).filter(Boolean));
|
|
31
|
+
return Object.fromEntries(Object.entries(env).filter(([k]) => ENV_ALLOW.test(k) || extra.has(k.toLowerCase())));
|
|
32
|
+
}
|
|
33
|
+
/** For the agent's own CLI (`claude mcp get`): everything except variables npm injected into this process. */
|
|
34
|
+
function withoutNpmInjected(env) {
|
|
35
|
+
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;
|
|
36
|
+
return Object.fromEntries(Object.entries(env).filter(([k]) => !drop.test(k)));
|
|
37
|
+
}
|
|
38
|
+
const REQUIRED_TOOLS = ['get_project_overview', 'get_task_context', 'get_file_context', 'check_mcp_health'];
|
|
39
|
+
function adviceFor(stage, def, detail) {
|
|
40
|
+
const cmd = [def.command, ...def.args].join(' ');
|
|
41
|
+
switch (stage) {
|
|
42
|
+
case 'launch':
|
|
43
|
+
if (/ENOENT|not found|not recognized|operable program/i.test(detail)) {
|
|
44
|
+
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".`;
|
|
45
|
+
}
|
|
46
|
+
if (/timed out/i.test(detail)) {
|
|
47
|
+
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.`;
|
|
48
|
+
}
|
|
49
|
+
return `The server process could not be started with "${cmd}". Run that command by hand to see the error.`;
|
|
50
|
+
case 'initialize':
|
|
51
|
+
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.`;
|
|
52
|
+
case 'tools_list':
|
|
53
|
+
return 'The server initialized but tool discovery failed. Upgrade devworkspace so the MCP server and CLI versions match.';
|
|
54
|
+
case 'health':
|
|
55
|
+
case 'tool_call':
|
|
56
|
+
case 'context':
|
|
57
|
+
return 'The server lists its tools but a real call failed. Run "devworkspace doctor" and "devworkspace refresh", then retry.';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Start the configured MCP server and drive initialize -> tools/list -> tools/call over stdio. */
|
|
61
|
+
export async function verifyMcpServer(def, opts) {
|
|
62
|
+
const timeoutMs = opts.timeoutMs ?? 60_000;
|
|
63
|
+
const stages = [];
|
|
64
|
+
let tools = [];
|
|
65
|
+
const fail = (stage, detail) => {
|
|
66
|
+
stages.push({ stage, ok: false, detail });
|
|
67
|
+
return { ok: false, scope: 'server-in-isolation', stages, failedStage: stage, advice: adviceFor(stage, def, detail), tools };
|
|
68
|
+
};
|
|
69
|
+
// Args are fixed tokens (flags, package spec, subcommands); Windows needs a shell to run .cmd shims such as npx.
|
|
70
|
+
const win = process.platform === 'win32';
|
|
71
|
+
const child = spawn(win ? [def.command, ...def.args].join(' ') : def.command, win ? [] : def.args, {
|
|
72
|
+
cwd: opts.cwd,
|
|
73
|
+
env: cleanLauncherEnv(opts.env ?? process.env),
|
|
74
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
75
|
+
shell: win,
|
|
76
|
+
windowsHide: true,
|
|
77
|
+
// POSIX: own process group, so cleanup can end npx *and* the server it spawned.
|
|
78
|
+
detached: !win,
|
|
79
|
+
});
|
|
80
|
+
// A server that dies early closes the pipe; without a handler the resulting EPIPE would crash setup.
|
|
81
|
+
child.stdin.on('error', () => undefined);
|
|
82
|
+
let spawnError = null;
|
|
83
|
+
let stderr = '';
|
|
84
|
+
let exited = false;
|
|
85
|
+
child.on('error', (e) => { spawnError = e.message; });
|
|
86
|
+
child.on('exit', () => { exited = true; });
|
|
87
|
+
child.stderr.on('data', (d) => { stderr = (stderr + d.toString()).slice(-2000); });
|
|
88
|
+
const pending = new Map();
|
|
89
|
+
let buf = '';
|
|
90
|
+
let nonJsonLines = 0;
|
|
91
|
+
child.stdout.on('data', (d) => {
|
|
92
|
+
buf += d.toString();
|
|
93
|
+
let i;
|
|
94
|
+
while ((i = buf.indexOf('\n')) >= 0) {
|
|
95
|
+
const line = buf.slice(0, i).trim();
|
|
96
|
+
buf = buf.slice(i + 1);
|
|
97
|
+
if (!line)
|
|
98
|
+
continue;
|
|
99
|
+
try {
|
|
100
|
+
const m = JSON.parse(line);
|
|
101
|
+
if (typeof m.id === 'number')
|
|
102
|
+
pending.get(m.id)?.(m);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
nonJsonLines++; // ignored, but counted: a live process that only emits non-JSON is a protocol failure, not a launch failure
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
const deadline = Date.now() + timeoutMs;
|
|
110
|
+
const request = (id, method, params) => new Promise((resolve, reject) => {
|
|
111
|
+
const left = deadline - Date.now();
|
|
112
|
+
const t = setTimeout(() => { pending.delete(id); reject(new Error(`timed out after ${timeoutMs}ms waiting for ${method}`)); }, Math.max(left, 1));
|
|
113
|
+
pending.set(id, (m) => { clearTimeout(t); pending.delete(id); resolve(m); });
|
|
114
|
+
const poll = setInterval(() => {
|
|
115
|
+
if (spawnError || exited) {
|
|
116
|
+
clearInterval(poll);
|
|
117
|
+
clearTimeout(t);
|
|
118
|
+
pending.delete(id);
|
|
119
|
+
reject(new Error(spawnError ?? `server exited before answering ${method}${stderr ? `: ${stderr.trim().split('\n').pop()}` : ''}`));
|
|
120
|
+
}
|
|
121
|
+
else if (!pending.has(id))
|
|
122
|
+
clearInterval(poll);
|
|
123
|
+
}, 100);
|
|
124
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
|
|
125
|
+
});
|
|
126
|
+
try {
|
|
127
|
+
let init;
|
|
128
|
+
try {
|
|
129
|
+
init = await request(1, 'initialize', { protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: 'devworkspace-setup', version: '1' } });
|
|
130
|
+
}
|
|
131
|
+
catch (e) {
|
|
132
|
+
// Nothing answered: the process never came up (or died); that is a launch failure, not a protocol one.
|
|
133
|
+
if (nonJsonLines > 0)
|
|
134
|
+
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)`);
|
|
135
|
+
return fail('launch', e.message);
|
|
136
|
+
}
|
|
137
|
+
stages.push({ stage: 'launch', ok: true, detail: `started "${[def.command, ...def.args].join(' ')}"` });
|
|
138
|
+
if (init.error || !init.result?.serverInfo)
|
|
139
|
+
return fail('initialize', init.error?.message ?? 'no serverInfo in initialize result');
|
|
140
|
+
stages.push({ stage: 'initialize', ok: true, detail: `${init.result.serverInfo.name} ${init.result.serverInfo.version ?? ''}`.trim() });
|
|
141
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
|
|
142
|
+
let list;
|
|
143
|
+
try {
|
|
144
|
+
list = await request(2, 'tools/list', {});
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
return fail('tools_list', e.message);
|
|
148
|
+
}
|
|
149
|
+
tools = Array.isArray(list.result?.tools) ? list.result.tools.map((t) => t.name) : [];
|
|
150
|
+
const missing = REQUIRED_TOOLS.filter((t) => !tools.includes(t));
|
|
151
|
+
if (list.error || missing.length > 0)
|
|
152
|
+
return fail('tools_list', list.error?.message ?? `missing tools: ${missing.join(', ')}`);
|
|
153
|
+
stages.push({ stage: 'tools_list', ok: true, detail: `${tools.length} tools discovered` });
|
|
154
|
+
let health;
|
|
155
|
+
try {
|
|
156
|
+
health = await request(5, 'tools/call', { name: 'check_mcp_health', arguments: {} });
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
return fail('health', e.message);
|
|
160
|
+
}
|
|
161
|
+
if (health.error || health.result?.isError)
|
|
162
|
+
return fail('health', health.error?.message ?? String(health.result?.content?.[0]?.text ?? 'tool returned an error').slice(0, 200));
|
|
163
|
+
stages.push({ stage: 'health', ok: true, detail: 'check_mcp_health returned a result' });
|
|
164
|
+
let call;
|
|
165
|
+
try {
|
|
166
|
+
call = await request(3, 'tools/call', { name: 'get_project_overview', arguments: {} });
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
return fail('tool_call', e.message);
|
|
170
|
+
}
|
|
171
|
+
if (call.error || call.result?.isError)
|
|
172
|
+
return fail('tool_call', call.error?.message ?? String(call.result?.content?.[0]?.text ?? 'tool returned an error').slice(0, 200));
|
|
173
|
+
stages.push({ stage: 'tool_call', ok: true, detail: 'get_project_overview returned a result' });
|
|
174
|
+
let ctx;
|
|
175
|
+
try {
|
|
176
|
+
ctx = await request(4, 'tools/call', { name: 'get_task_context', arguments: { task: 'describe this project' } });
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
return fail('context', e.message);
|
|
180
|
+
}
|
|
181
|
+
const text = String(ctx.result?.content?.[0]?.text ?? '');
|
|
182
|
+
if (ctx.error || ctx.result?.isError || text.trim() === '')
|
|
183
|
+
return fail('context', ctx.error?.message ?? (text.slice(0, 200) || 'empty result'));
|
|
184
|
+
stages.push({ stage: 'context', ok: true, detail: `get_task_context returned ${text.length} characters` });
|
|
185
|
+
return { ok: true, scope: 'server-in-isolation', stages, tools, ...(init.result.serverInfo.version ? { serverVersion: String(init.result.serverInfo.version) } : {}) };
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
try {
|
|
189
|
+
child.stdin.end();
|
|
190
|
+
}
|
|
191
|
+
catch { /* already closed */ }
|
|
192
|
+
// With shell:true on Windows, kill() only ends the shell; take the whole tree so no server keeps the project dir open.
|
|
193
|
+
if (process.platform === 'win32' && child.pid)
|
|
194
|
+
spawnSync('taskkill', ['/pid', String(child.pid), '/T', '/F'], { windowsHide: true });
|
|
195
|
+
else {
|
|
196
|
+
try {
|
|
197
|
+
if (child.pid)
|
|
198
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
199
|
+
else
|
|
200
|
+
child.kill();
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
child.kill();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Ask the real Claude Code CLI how it sees the project's `devworkspace` server (`claude mcp get devworkspace`).
|
|
210
|
+
* This is the only agent-side signal available from outside: it can report registered/pending approval/connected.
|
|
211
|
+
*/
|
|
212
|
+
export async function observeClaudeCode(cwd, timeoutMs = 45_000) {
|
|
213
|
+
const out = await new Promise((resolve) => {
|
|
214
|
+
// Fixed command line with no user input; on Windows `claude` may be a .cmd shim, which needs a shell.
|
|
215
|
+
exec('claude mcp get devworkspace', { cwd, timeout: timeoutMs, windowsHide: true, env: withoutNpmInjected(process.env) }, (err, stdout, stderr) => resolve({ ok: !err, text: `${stdout}\n${stderr}` }));
|
|
216
|
+
});
|
|
217
|
+
const status = /Status:\s*(.+)/.exec(out.text)?.[1]?.trim();
|
|
218
|
+
if (!status) {
|
|
219
|
+
return { agent: 'claude-code', status: 'not-observed', detail: out.ok ? 'claude returned no status line' : 'the claude CLI is not available or did not answer' };
|
|
220
|
+
}
|
|
221
|
+
if (/pending approval/i.test(status))
|
|
222
|
+
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)' };
|
|
223
|
+
if (/connected|✔|✓/i.test(status) && !/fail/i.test(status))
|
|
224
|
+
return { agent: 'claude-code', status: 'connected', detail: status };
|
|
225
|
+
if (/fail|error|✗|✘/i.test(status))
|
|
226
|
+
return { agent: 'claude-code', status: 'failed', detail: status };
|
|
227
|
+
return { agent: 'claude-code', status: 'not-observed', detail: `unrecognized status: ${status}` };
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/mcp/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA2BlD;;;;;;;;;;;;;;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,E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AAE,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC5D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,mDAAmD,EAAE,CAAC;IACnK,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 { exec, spawn, spawnSync } from 'node:child_process';\nimport { MCP_PROTOCOL_VERSION } from './types.js';\nimport type { McpServerDef } from './setup.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 // Args are fixed tokens (flags, package spec, subcommands); Windows needs a shell to run .cmd shims such as npx.\n const win = process.platform === 'win32';\n const child = spawn(win ? [def.command, ...def.args].join(' ') : def.command, win ? [] : def.args, {\n cwd: opts.cwd,\n env: cleanLauncherEnv(opts.env ?? process.env),\n stdio: ['pipe', 'pipe', 'pipe'],\n shell: win,\n windowsHide: true,\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 out = await new Promise<{ ok: boolean; text: string }>((resolve) => {\n // Fixed command line with no user input; on Windows `claude` may be a .cmd shim, which needs a shell.\n exec('claude mcp get devworkspace', { cwd, timeout: timeoutMs, windowsHide: true, env: withoutNpmInjected(process.env) }, (err, stdout, stderr) =>\n resolve({ ok: !err, text: `${stdout}\\n${stderr}` }));\n });\n const status = /Status:\\s*(.+)/.exec(out.text)?.[1]?.trim();\n if (!status) {\n return { agent: 'claude-code', status: 'not-observed', detail: out.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';
|
|
@@ -21,6 +22,7 @@ import { findAbsolutePaths } from '../utils/paths.js';
|
|
|
21
22
|
import { detectInstalledAgents, instructionsInstalled, knowledgeWritten } from './status.js';
|
|
22
23
|
import { managerEnv } from './common.js';
|
|
23
24
|
import { withLock } from '../utils/lock.js';
|
|
25
|
+
import { which } from '../utils/proc.js';
|
|
24
26
|
export const MIN_NODE_MAJOR = 20;
|
|
25
27
|
export async function runDoctor(o) {
|
|
26
28
|
const checks = [];
|
|
@@ -232,6 +234,9 @@ export async function runDoctor(o) {
|
|
|
232
234
|
add('onboarding', 'pass', 'Architecture knowledge written');
|
|
233
235
|
else
|
|
234
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.).');
|
|
237
|
+
// MCP launcher configuration verification
|
|
238
|
+
await checkMcpLauncher(root, add);
|
|
239
|
+
await checkGraphLayout(root, add);
|
|
235
240
|
// Security and portability.
|
|
236
241
|
const wsFiles = (await listFilesRecursive(ws.dir, 3000)).filter((f) => !f.startsWith(ws.localDir) && !/\.tmp$/.test(f));
|
|
237
242
|
const secretHits = [];
|
|
@@ -350,4 +355,138 @@ async function checkDiscovery(ws, add) {
|
|
|
350
355
|
add('discovery-ecosystem', 'info', 'No source files or manifests detected');
|
|
351
356
|
}
|
|
352
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
|
+
}
|
|
398
|
+
async function checkMcpLauncher(root, add) {
|
|
399
|
+
const configs = [
|
|
400
|
+
{ file: '.mcp.json' },
|
|
401
|
+
{ file: 'mcp.json' },
|
|
402
|
+
{ file: path.join('.antigravity', 'mcp.json') },
|
|
403
|
+
];
|
|
404
|
+
const found = [];
|
|
405
|
+
for (const cfg of configs) {
|
|
406
|
+
const full = path.join(root, cfg.file);
|
|
407
|
+
if (await pathExists(full)) {
|
|
408
|
+
try {
|
|
409
|
+
const raw = await readJsonFile(full);
|
|
410
|
+
const obj = typeof raw === 'object' && raw !== null ? raw : null;
|
|
411
|
+
const servers = obj?.mcpServers && typeof obj.mcpServers === 'object' ? obj.mcpServers : null;
|
|
412
|
+
const devServer = servers?.devworkspace && typeof servers.devworkspace === 'object' ? servers.devworkspace : null;
|
|
413
|
+
if (devServer && typeof devServer.command === 'string') {
|
|
414
|
+
found.push({
|
|
415
|
+
file: cfg.file,
|
|
416
|
+
command: devServer.command,
|
|
417
|
+
args: Array.isArray(devServer.args) ? devServer.args.map(String) : [],
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
catch {
|
|
422
|
+
// syntax error
|
|
423
|
+
}
|
|
424
|
+
}
|
|
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
|
+
}
|
|
447
|
+
if (found.length === 0)
|
|
448
|
+
return;
|
|
449
|
+
const badLaunchers = [];
|
|
450
|
+
for (const item of found) {
|
|
451
|
+
if (item.command === 'devworkspace') {
|
|
452
|
+
const onPath = await which('devworkspace');
|
|
453
|
+
if (!onPath) {
|
|
454
|
+
badLaunchers.push({
|
|
455
|
+
file: item.file,
|
|
456
|
+
command: item.command,
|
|
457
|
+
reason: '"devworkspace" binary was not found on PATH',
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
else if (item.command === 'npx') {
|
|
462
|
+
const onPath = await which('npx');
|
|
463
|
+
if (!onPath) {
|
|
464
|
+
badLaunchers.push({
|
|
465
|
+
file: item.file,
|
|
466
|
+
command: item.command,
|
|
467
|
+
reason: '"npx" binary was not found on PATH',
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
const onPath = await which(item.command);
|
|
473
|
+
const isLocal = await pathExists(path.resolve(root, item.command));
|
|
474
|
+
if (!onPath && !isLocal) {
|
|
475
|
+
badLaunchers.push({
|
|
476
|
+
file: item.file,
|
|
477
|
+
command: item.command,
|
|
478
|
+
reason: `command "${item.command}" was not found on PATH or workspace root`,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (badLaunchers.length > 0) {
|
|
484
|
+
const details = badLaunchers.map((b) => `${b.file}: ${b.reason}`).join('; ');
|
|
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');
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
const launchers = [...new Set(found.map((f) => [f.command, ...f.args].join(' ')))].join('; ');
|
|
489
|
+
add('mcp-launcher', 'pass', `Configured MCP launcher is resolvable (${launchers})`);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
353
492
|
//# sourceMappingURL=doctor.js.map
|