devworkspace 0.4.4 → 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 +26 -0
- package/README.md +7 -6
- package/dist/cli/args.d.ts +7 -0
- package/dist/cli/args.js +2 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/help.js +7 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/render.d.ts +2 -1
- package/dist/cli/render.js +18 -0
- package/dist/cli/render.js.map +1 -1
- package/dist/cli/run.js +13 -3
- package/dist/cli/run.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 +21 -0
- package/dist/mcp/setup.js +107 -22
- package/dist/mcp/setup.js.map +1 -1
- package/dist/mcp/verify.js +45 -10
- package/dist/mcp/verify.js.map +1 -1
- package/dist/services/graph.d.ts +21 -0
- package/dist/services/graph.js +222 -3
- package/dist/services/graph.js.map +1 -1
- package/dist/utils/proc.js +19 -3
- package/dist/utils/proc.js.map +1 -1
- package/docs/integrations.md +2 -2
- package/docs/mcp.md +8 -3
- package/package.json +1 -1
package/dist/mcp/verify.js.map
CHANGED
|
@@ -1 +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,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CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAChJ,OAAO,CAAC,EAAE,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"]}
|
|
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,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,wBAAwB,EAAE,sBAAsB;IACnG,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,qBAAqB,EAAE,eAAe,EAAE,cAAc;IAC5G,WAAW,EAAE,iBAAiB;IAC9B,sKAAsK;IACtK,4BAA4B;CAC7B,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,EAClB,GAAG,CACJ,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,GAAsB;IACrD,MAAM,KAAK,GAAG,IAAI,GAAG,CAA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E,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/graph.d.ts
CHANGED
|
@@ -109,6 +109,27 @@ export declare function loadGraphData(root: string): Promise<{
|
|
|
109
109
|
* Reports the presence, size, and basic schema health of the Graphify graph.
|
|
110
110
|
*/
|
|
111
111
|
export declare function getGraphStatusService(o: ServiceOptions): Promise<GraphStatusResult>;
|
|
112
|
+
export interface GraphGenerateOptions {
|
|
113
|
+
force?: boolean;
|
|
114
|
+
dryRun?: boolean;
|
|
115
|
+
out?: string;
|
|
116
|
+
}
|
|
117
|
+
export interface GraphGenerateResult {
|
|
118
|
+
ok: boolean;
|
|
119
|
+
graphPath: string;
|
|
120
|
+
nodesCount: number;
|
|
121
|
+
edgesCount: number;
|
|
122
|
+
filesScanned: number;
|
|
123
|
+
nodeTypes: Record<string, number>;
|
|
124
|
+
dryRun: boolean;
|
|
125
|
+
overwritten: boolean;
|
|
126
|
+
message: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Generates an offline knowledge graph directly by scanning project source files.
|
|
130
|
+
* Extracts functions, classes, interfaces, types and dependencies without requiring Claude Code or network access.
|
|
131
|
+
*/
|
|
132
|
+
export declare function generateOfflineGraphService(o: ServiceOptions, options?: GraphGenerateOptions): Promise<GraphGenerateResult>;
|
|
112
133
|
export type MatchStrength = 'exact' | 'strong' | 'weak';
|
|
113
134
|
export interface NormalizedNode {
|
|
114
135
|
/** Workspace-relative POSIX path, or null when absent/unsafe. */
|
package/dist/services/graph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { pathExists, readTextBounded } from '../utils/fs.js';
|
|
3
|
+
import { atomicWriteFile, pathExists, readTextBounded } from '../utils/fs.js';
|
|
4
4
|
import { findSymbolInText } from '../features/validate.js';
|
|
5
5
|
import { requireWorkspace } from '../core/workspace.js';
|
|
6
6
|
import { resolveGraphifyGraph } from '../core/artifacts.js';
|
|
@@ -68,7 +68,7 @@ export async function getGraphStatusService(o) {
|
|
|
68
68
|
edgesCount: 0,
|
|
69
69
|
nodeTypes: {},
|
|
70
70
|
message: 'No Graphify knowledge graph found at graphify-out/graph.json.',
|
|
71
|
-
hint: '
|
|
71
|
+
hint: 'Run "devworkspace graph generate" for an offline graph, or in Claude Code run "/graphify ." / "graphify update ." to build with Graphify.',
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
const { nodes, edges } = loaded.data;
|
|
@@ -86,6 +86,225 @@ export async function getGraphStatusService(o) {
|
|
|
86
86
|
message: `Graphify graph loaded: ${nodes.length} nodes, ${edges.length} edges.`,
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
const SUPPORTED_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.py']);
|
|
90
|
+
const IGNORED_SCAN_DIRS = new Set([
|
|
91
|
+
'node_modules',
|
|
92
|
+
'.git',
|
|
93
|
+
'.devworkspace',
|
|
94
|
+
'dist',
|
|
95
|
+
'build',
|
|
96
|
+
'out',
|
|
97
|
+
'coverage',
|
|
98
|
+
'.claude',
|
|
99
|
+
'.cursor',
|
|
100
|
+
'graphify-out',
|
|
101
|
+
'.venv',
|
|
102
|
+
'venv',
|
|
103
|
+
'__pycache__',
|
|
104
|
+
]);
|
|
105
|
+
/**
|
|
106
|
+
* Generates an offline knowledge graph directly by scanning project source files.
|
|
107
|
+
* Extracts functions, classes, interfaces, types and dependencies without requiring Claude Code or network access.
|
|
108
|
+
*/
|
|
109
|
+
export async function generateOfflineGraphService(o, options = {}) {
|
|
110
|
+
const ws = await requireWorkspace(o.cwd);
|
|
111
|
+
const dest = options.out ? path.resolve(ws.root, options.out) : path.join(ws.root, 'graphify-out', 'graph.json');
|
|
112
|
+
let alreadyExists = false;
|
|
113
|
+
if (await pathExists(dest)) {
|
|
114
|
+
alreadyExists = true;
|
|
115
|
+
try {
|
|
116
|
+
const raw = await fs.readFile(dest, 'utf8');
|
|
117
|
+
const parsed = JSON.parse(raw);
|
|
118
|
+
if (parsed?.generator !== 'devworkspace-offline-fallback' && !options.force) {
|
|
119
|
+
throw new DevWorkspaceError('CONFLICT', `A native Graphify graph already exists at "${path.relative(ws.root, dest).replace(/\\/g, '/')}". Pass --force to overwrite.`, {
|
|
120
|
+
hint: 'Pass --force to replace the existing graph with the offline fallback graph.',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
if (e instanceof DevWorkspaceError)
|
|
126
|
+
throw e;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const files = [];
|
|
130
|
+
async function scan(dir) {
|
|
131
|
+
let entries;
|
|
132
|
+
try {
|
|
133
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
for (const ent of entries) {
|
|
139
|
+
if (ent.isDirectory()) {
|
|
140
|
+
if (!IGNORED_SCAN_DIRS.has(ent.name) && !ent.name.startsWith('.')) {
|
|
141
|
+
await scan(path.join(dir, ent.name));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (ent.isFile()) {
|
|
145
|
+
const ext = path.extname(ent.name).toLowerCase();
|
|
146
|
+
if (SUPPORTED_EXTS.has(ext)) {
|
|
147
|
+
files.push(path.join(dir, ent.name));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
await scan(ws.root);
|
|
153
|
+
files.sort();
|
|
154
|
+
const nodesMap = new Map();
|
|
155
|
+
const edges = [];
|
|
156
|
+
const nodeTypes = {};
|
|
157
|
+
const addNode = (node) => {
|
|
158
|
+
if (!nodesMap.has(node.id)) {
|
|
159
|
+
nodesMap.set(node.id, node);
|
|
160
|
+
const t = node.type || 'unknown';
|
|
161
|
+
nodeTypes[t] = (nodeTypes[t] || 0) + 1;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
for (const f of files) {
|
|
165
|
+
const rel = path.relative(ws.root, f).replace(/\\/g, '/');
|
|
166
|
+
let text;
|
|
167
|
+
try {
|
|
168
|
+
text = await fs.readFile(f, 'utf8');
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
// Add file node
|
|
174
|
+
addNode({
|
|
175
|
+
id: rel,
|
|
176
|
+
name: path.basename(rel),
|
|
177
|
+
label: path.basename(rel),
|
|
178
|
+
type: 'file',
|
|
179
|
+
path: rel,
|
|
180
|
+
source_file: rel,
|
|
181
|
+
source_location: 'L1',
|
|
182
|
+
});
|
|
183
|
+
const lines = text.split(/\r?\n/);
|
|
184
|
+
const isPy = /\.py$/i.test(rel);
|
|
185
|
+
for (let i = 0; i < lines.length; i++) {
|
|
186
|
+
const line = lines[i];
|
|
187
|
+
const lineNum = i + 1;
|
|
188
|
+
const loc = `L${lineNum}`;
|
|
189
|
+
if (isPy) {
|
|
190
|
+
const trimmed = line.replace(/#.*$/, '').trim();
|
|
191
|
+
if (!trimmed)
|
|
192
|
+
continue;
|
|
193
|
+
// Python function
|
|
194
|
+
const fnMatch = /^(?:async\s+)?def\s+([A-Za-z0-9_]+)\s*\(/.exec(trimmed);
|
|
195
|
+
if (fnMatch) {
|
|
196
|
+
const name = fnMatch[1];
|
|
197
|
+
const id = `${rel}:${name}`;
|
|
198
|
+
addNode({ id, name, label: name, type: 'function', path: rel, source_file: rel, source_location: loc });
|
|
199
|
+
edges.push({ source: rel, target: id, relation: 'defines', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
// Python class
|
|
203
|
+
const classMatch = /^class\s+([A-Za-z0-9_]+)(?:\(([^)]*)\))?:/.exec(trimmed);
|
|
204
|
+
if (classMatch) {
|
|
205
|
+
const name = classMatch[1];
|
|
206
|
+
const id = `${rel}:${name}`;
|
|
207
|
+
addNode({ id, name, label: name, type: 'class', path: rel, source_file: rel, source_location: loc });
|
|
208
|
+
edges.push({ source: rel, target: id, relation: 'defines', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
209
|
+
if (classMatch[2]) {
|
|
210
|
+
const bases = classMatch[2].split(',').map((s) => s.trim()).filter(Boolean);
|
|
211
|
+
for (const base of bases) {
|
|
212
|
+
edges.push({ source: id, target: base, relation: 'extends', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
// Python import
|
|
218
|
+
const impMatch = /^(?:from\s+([A-Za-z0-9_.]+)\s+import|import\s+([A-Za-z0-9_.,\s]+))/.exec(trimmed);
|
|
219
|
+
if (impMatch) {
|
|
220
|
+
const target = (impMatch[1] ?? impMatch[2]).split(',')[0].trim();
|
|
221
|
+
edges.push({ source: rel, target, relation: 'imports', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const trimmed = line.replace(/\/\/.*$/, '').trim();
|
|
226
|
+
if (!trimmed)
|
|
227
|
+
continue;
|
|
228
|
+
// TS/JS function
|
|
229
|
+
const fnMatch = /(?:export\s+)?(?:default\s+)?(?:async\s+)?function\s+([A-Za-z0-9_$]+)/.exec(trimmed);
|
|
230
|
+
const arrowMatch = !fnMatch ? /(?:export\s+)?const\s+([A-Za-z0-9_$]+)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[A-Za-z0-9_$]+)\s*=>/.exec(trimmed) : null;
|
|
231
|
+
if (fnMatch || arrowMatch) {
|
|
232
|
+
const name = fnMatch ? fnMatch[1] : arrowMatch[1];
|
|
233
|
+
const id = `${rel}:${name}`;
|
|
234
|
+
addNode({ id, name, label: name, type: 'function', path: rel, source_file: rel, source_location: loc });
|
|
235
|
+
edges.push({ source: rel, target: id, relation: 'defines', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
// TS/JS class
|
|
239
|
+
const classMatch = /(?:export\s+)?(?:default\s+)?(?:abstract\s+)?class\s+([A-Za-z0-9_$]+)(?:\s+extends\s+([A-Za-z0-9_$]+))?(?:\s+implements\s+([A-Za-z0-9_$,\s]+))?/.exec(trimmed);
|
|
240
|
+
if (classMatch) {
|
|
241
|
+
const name = classMatch[1];
|
|
242
|
+
const id = `${rel}:${name}`;
|
|
243
|
+
addNode({ id, name, label: name, type: 'class', path: rel, source_file: rel, source_location: loc });
|
|
244
|
+
edges.push({ source: rel, target: id, relation: 'defines', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
245
|
+
if (classMatch[2]) {
|
|
246
|
+
edges.push({ source: id, target: classMatch[2], relation: 'extends', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
247
|
+
}
|
|
248
|
+
if (classMatch[3]) {
|
|
249
|
+
for (const iface of classMatch[3].split(',').map((s) => s.trim()).filter(Boolean)) {
|
|
250
|
+
edges.push({ source: id, target: iface, relation: 'implements', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
// TS interface
|
|
256
|
+
const ifaceMatch = /(?:export\s+)?interface\s+([A-Za-z0-9_$]+)(?:\s+extends\s+([A-Za-z0-9_$,\s]+))?/.exec(trimmed);
|
|
257
|
+
if (ifaceMatch) {
|
|
258
|
+
const name = ifaceMatch[1];
|
|
259
|
+
const id = `${rel}:${name}`;
|
|
260
|
+
addNode({ id, name, label: name, type: 'interface', path: rel, source_file: rel, source_location: loc });
|
|
261
|
+
edges.push({ source: rel, target: id, relation: 'defines', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
// TS type
|
|
265
|
+
const typeMatch = /(?:export\s+)?type\s+([A-Za-z0-9_$]+)\s*=/.exec(trimmed);
|
|
266
|
+
if (typeMatch) {
|
|
267
|
+
const name = typeMatch[1];
|
|
268
|
+
const id = `${rel}:${name}`;
|
|
269
|
+
addNode({ id, name, label: name, type: 'type', path: rel, source_file: rel, source_location: loc });
|
|
270
|
+
edges.push({ source: rel, target: id, relation: 'defines', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
// TS/JS import
|
|
274
|
+
const impMatch = /(?:import\s+(?:(?:\{[^}]*\}|[\w*\s,]+)\s+from\s+)?['"]([^'"]+)['"]|require\(['"]([^'"]+)['"]\))/.exec(trimmed);
|
|
275
|
+
if (impMatch) {
|
|
276
|
+
const target = impMatch[1] ?? impMatch[2];
|
|
277
|
+
edges.push({ source: rel, target, relation: 'imports', confidence: 'EXTRACTED', provenance: 'extracted', source_file: rel, source_location: loc });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const nodes = Array.from(nodesMap.values());
|
|
283
|
+
const graphData = {
|
|
284
|
+
generator: 'devworkspace-offline-fallback',
|
|
285
|
+
generatedAt: new Date().toISOString(),
|
|
286
|
+
version: '1.0.0',
|
|
287
|
+
nodes,
|
|
288
|
+
edges,
|
|
289
|
+
};
|
|
290
|
+
if (!options.dryRun) {
|
|
291
|
+
await fs.mkdir(path.dirname(dest), { recursive: true });
|
|
292
|
+
await atomicWriteFile(dest, JSON.stringify(graphData, null, 2) + '\n');
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
ok: true,
|
|
296
|
+
graphPath: dest,
|
|
297
|
+
nodesCount: nodes.length,
|
|
298
|
+
edgesCount: edges.length,
|
|
299
|
+
filesScanned: files.length,
|
|
300
|
+
nodeTypes,
|
|
301
|
+
dryRun: Boolean(options.dryRun),
|
|
302
|
+
overwritten: alreadyExists,
|
|
303
|
+
message: options.dryRun
|
|
304
|
+
? `Dry run: would generate offline graph with ${nodes.length} nodes and ${edges.length} edges from ${files.length} files.`
|
|
305
|
+
: `Generated offline knowledge graph at "${path.relative(ws.root, dest).replace(/\\/g, '/')}": ${nodes.length} nodes, ${edges.length} edges from ${files.length} source files.`,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
89
308
|
/** Parses "L4", "L4-L9", "4" or "4:2" into a 1-based line; null for anything else. */
|
|
90
309
|
export function parseSourceLocation(loc) {
|
|
91
310
|
if (typeof loc === 'number')
|
|
@@ -376,7 +595,7 @@ export async function traceGraphService(o, query, options = {}) {
|
|
|
376
595
|
const maxNodes = Math.max(1, Math.min(options.maxNodes ?? 150, 500));
|
|
377
596
|
const empty = { depth: depthLimit, maxNodes, matchedNode: null, totalNodes: 0, verifiedNodes: 0, hypothesisNodes: 0, truncated: false, nodes: [], edges: [] };
|
|
378
597
|
if (!loaded.exists || !loaded.data) {
|
|
379
|
-
return { available: false, query, ...empty, warnings: ['No Graphify graph found at graphify-out/graph.json. Run "/graphify ." in Claude Code.'] };
|
|
598
|
+
return { available: false, query, ...empty, warnings: ['No Graphify graph found at graphify-out/graph.json. Run "devworkspace graph generate" for an offline graph, or "/graphify ." in Claude Code.'] };
|
|
380
599
|
}
|
|
381
600
|
const { nodes, edges } = loaded.data;
|
|
382
601
|
const top = rankGraphNodes(nodes, query, { limit: 1 })[0];
|