devworkspace 0.4.1 → 0.4.3
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 +48 -0
- package/README.md +218 -21
- package/dist/cli/args.d.ts +6 -0
- package/dist/cli/args.js +2 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/run.js +17 -0
- package/dist/cli/run.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +13 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/setup.d.ts +24 -1
- package/dist/mcp/setup.js +55 -4
- package/dist/mcp/setup.js.map +1 -1
- package/dist/mcp/tools.d.ts +6 -0
- package/dist/mcp/tools.js +1066 -34
- package/dist/mcp/tools.js.map +1 -1
- package/dist/services/doctor.js +76 -0
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/graph.d.ts +7 -0
- package/dist/services/graph.js +18 -9
- 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 +1 -0
- package/dist/services/setup.js.map +1 -1
- package/dist/services/taskContext.d.ts +21 -0
- package/dist/services/taskContext.js +53 -21
- 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 +16 -2
- package/docs/mcp.md +97 -11
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/services/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,eAAe,E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AM,IAAI,CAAC,CAAC;QAC5C,GAAG,CAAC,qBAAqB,EAAE,MAAM,EAAE,YAAY,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzH,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,qBAAqB,EAAE,MAAM,EAAE,uCAAuC,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { SCHEMA_VERSION, validateAnalysisState, validateCommands } from '../config/schemas.js';\nimport { findWorkspaceRoot, LOCAL_GITIGNORE, loadProject, wsPaths, type Ws } from '../core/workspace.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { getGitState, gitAvailable, gitTrackedFiles } from '../git/git.js';\nimport { inspectAll, summarize, type IntegrationReport } from '../integrations/index.js';\nimport { evaluateStaleness, loadFacts } from '../knowledge/facts.js';\nimport { ONBOARDING_REQUIREMENTS, validatePrompt } from '../prompts/requirements.js';\nimport { isSensitiveFile } from '../security/files.js';\nimport { findSecrets } from '../security/redact.js';\nimport { listDecisions } from '../decisions/decision.js';\nimport { listTasks } from '../tasks/task.js';\nimport { ensureDir, listFilesRecursive, pathExists, readJsonFile, readTextBounded, atomicWriteFile } from '../utils/fs.js';\nimport { ALWAYS_SKIP_DIRS } from '../discovery/scan.js';\nimport { isAuxPath } from '../discovery/detect.js';\nimport { detectContractDrift } from '../discovery/commands.js';\nimport { loadFeatures } from './features.js';\nimport { validateFeatureMap } from '../features/validate.js';\nimport { findAbsolutePaths } from '../utils/paths.js';\nimport { detectInstalledAgents, instructionsInstalled, knowledgeWritten } from './status.js';\nimport { managerEnv, type ServiceOptions } from './common.js';\nimport { withLock } from '../utils/lock.js';\nimport type { AgentAdapter } from '../agents/types.js';\n\nexport type CheckStatus = 'pass' | 'warn' | 'fail' | 'info';\n\nexport interface DoctorCheck {\n id: string;\n status: CheckStatus;\n message: string;\n remediation?: string;\n}\n\nexport interface DoctorResult {\n root: string | null;\n checks: DoctorCheck[];\n counts: { pass: number; warn: number; fail: number; info: number };\n /** Core workspace has no failing checks. */\n healthy: boolean;\n /** Core workspace is onboarded: instructions installed and architecture knowledge written. */\n ready: boolean;\n fixed: string[];\n /** Observed integration state, kept separate from core readiness. */\n integrations: IntegrationReport[];\n integrationSummary: { complete: boolean; required: number; verified: number };\n}\n\nexport interface DoctorOptions extends ServiceOptions {\n fix?: boolean;\n minNodeMajor?: number;\n}\n\nexport const MIN_NODE_MAJOR = 20;\n\nexport async function runDoctor(o: DoctorOptions): Promise<DoctorResult> {\n const checks: DoctorCheck[] = [];\n const fixed: string[] = [];\n const add = (id: string, status: CheckStatus, message: string, remediation?: string): void => {\n checks.push({ id, status, message, ...(remediation ? { remediation } : {}) });\n };\n\n const major = Number(process.versions.node.split('.')[0]);\n const minNode = o.minNodeMajor ?? MIN_NODE_MAJOR;\n if (major >= minNode) add('node', 'pass', `Node.js ${process.versions.node}`);\n else add('node', 'fail', `Node.js ${process.versions.node} is older than the required ${minNode}`, `Install Node.js ${minNode} or newer (https://nodejs.org).`);\n\n const hasGit = await gitAvailable();\n if (hasGit) add('git', 'pass', 'Git is available');\n else add('git', 'warn', 'Git was not found on PATH', 'Install Git; DevWorkspace works without it but cannot protect uncommitted changes.');\n\n const root = await findWorkspaceRoot(o.cwd);\n if (!root) {\n if (await pathExists(path.join(o.cwd, '.devworkspace'))) {\n add('workspace', 'fail', 'Partial initialization: .devworkspace/ exists but project.json is missing', 'Restore project.json from Git, or run \"devworkspace init\" to complete the setup (existing files are kept).');\n } else {\n add('workspace', 'fail', 'No DevWorkspace found in this directory or any parent', 'Run: devworkspace init');\n }\n return finish(null, checks, fixed, undefined, o);\n }\n const ws = wsPaths(root);\n add('workspace', 'pass', 'Workspace found');\n\n // Project config and schema compatibility.\n let projectOk = false;\n let acknowledgedNoVerification = false;\n try {\n const p = await loadProject(ws);\n projectOk = true;\n acknowledgedNoVerification = p.settings.acknowledgeNoVerification === true;\n add('project', 'pass', `project.json valid (schema v${p.schemaVersion}, id ${p.projectId.slice(0, 8)})`);\n } catch (e) {\n const code = (e as { code?: string }).code;\n add('project', 'fail', (e as Error).message.split('\\n')[0]!, code === 'SCHEMA_TOO_NEW' ? 'Upgrade DevWorkspace: npm install -g devworkspace@latest' : 'Restore .devworkspace/project.json from Git, or re-run \"devworkspace init\" after moving the broken file away.');\n }\n\n // Layout.\n const dirs = [ws.contextDir, ws.decisionsDir, ws.tasksActive, ws.tasksCompleted, ws.sessionsDir, ws.analysisDir, ws.stateDir];\n const missingDirs: string[] = [];\n for (const d of dirs) if (!(await pathExists(d))) missingDirs.push(d);\n if (missingDirs.length === 0) add('layout', 'pass', 'Workspace folders present');\n else if (o.fix && projectOk) {\n await withLock(ws.dir, async () => {\n for (const d of missingDirs) await ensureDir(d);\n });\n fixed.push(`created ${missingDirs.length} missing folder(s)`);\n add('layout', 'pass', `Recreated ${missingDirs.length} missing folder(s)`);\n } else {\n add('layout', 'warn', `Missing folders: ${missingDirs.map((d) => path.basename(d)).join(', ')}`, 'Run: devworkspace doctor --fix');\n }\n\n // Ignore rules.\n const giOk = await fs.readFile(ws.gitignore, 'utf8').then(\n (gi) => gi.split(/\\r?\\n/).some((l) => l.trim() === 'local/'),\n () => false,\n );\n if (giOk) add('ignore-local', 'pass', 'Machine-local state is git-ignored');\n else if (o.fix && projectOk) {\n await atomicWriteFile(ws.gitignore, LOCAL_GITIGNORE);\n fixed.push('wrote .devworkspace/.gitignore');\n add('ignore-local', 'pass', 'Wrote .devworkspace/.gitignore');\n } else add('ignore-local', 'fail', '.devworkspace/.gitignore does not ignore local/', 'Run: devworkspace doctor --fix');\n\n try {\n const rootGi = await fs.readFile(path.join(root, '.gitignore'), 'utf8');\n if (rootGi.split(/\\r?\\n/).some((l) => /^\\/?\\.devworkspace\\/?\\*?$/.test(l.trim()))) {\n add('ignore-root', 'warn', 'The root .gitignore ignores all of .devworkspace/, so project knowledge will not be shared', 'Remove that rule; .devworkspace/.gitignore already excludes machine-local files.');\n }\n } catch {\n /* no root .gitignore */\n }\n\n // Knowledge and contract.\n try {\n const facts = await loadFacts(ws);\n const view = await evaluateStaleness(ws.root, facts, new Date().toISOString());\n const stale = [...view.recorded, ...view.detected];\n add('facts', 'pass', `${facts.facts.length} fact(s) stored`);\n if (stale.length > 0) add('staleness', 'warn', `${stale.length} stale fact(s): ${stale.slice(0, 5).map((f) => `${f.key} (${f.reason})`).join('; ')}`, 'Run: devworkspace refresh, then re-check the listed facts against the repository.');\n else if (facts.facts.length > 0) add('staleness', 'pass', 'No stale facts recorded');\n } catch (e) {\n add('facts', 'fail', (e as Error).message.split('\\n')[0]!, 'Restore .devworkspace/context/facts.json from Git or a backup under .devworkspace/local/backups.');\n }\n\n if (await pathExists(ws.commands)) {\n try {\n const c = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data;\n add('contract', 'pass', 'Testing contract present');\n if (!c.checks.some((x) => x.id === 'unit' && x.available)) add('tests-available', 'warn', 'No unit-test command detected', 'Add a test script or edit .devworkspace/context/commands.json; tasks will not be able to demand tests.');\n if (!c.checks.some((x) => x.id === 'build' && x.available)) add('build-available', 'info', 'No build command detected');\n const configured = c.checks.filter((x) => x.available);\n if (configured.length > 0) {\n const ids = [...new Set(configured.map((x) => x.id))];\n const dirs = [...new Set(configured.map((x) => x.cwd).filter((d): d is string => !!d))];\n add('verification-commands', 'pass', `${ids.length} verification check(s) configured: ${ids.join(', ')}${dirs.length ? ` (in ${dirs.join(', ')})` : ''}`);\n\n const drift = await detectContractDrift(ws.root, c.checks);\n if (drift.hasDrift) {\n const summary = drift.issues.slice(0, 3).map((i) => `${i.id}${i.cwd ? ` [${i.cwd}]` : ''}: ${i.message}`).join('; ');\n const more = drift.issues.length > 3 ? ` (+${drift.issues.length - 3} more)` : '';\n add(\n 'contract-drift',\n 'warn',\n `Verification contract has drifted from actual repository scripts (${drift.issues.length} issue(s): ${summary}${more})`,\n 'Run \"devworkspace refresh\" to resynchronize with package manifests, or edit .devworkspace/context/commands.json.',\n );\n } else {\n add('contract-drift', 'pass', 'Verification commands match repository manifests and directories');\n }\n } else if (acknowledgedNoVerification) {\n add('verification-commands', 'info', 'No verification commands; acknowledged in project.json (settings.acknowledgeNoVerification)');\n } else {\n add(\n 'verification-commands',\n 'warn',\n 'No verification commands (tests, lint, typecheck, build) are configured, so tasks cannot require any verification',\n 'Run: devworkspace analyze. If the project intentionally has none, set \"acknowledgeNoVerification\": true under settings in .devworkspace/project.json.',\n );\n }\n } catch (e) {\n add('contract', 'fail', (e as Error).message.split('\\n')[0]!, 'Fix commands.json or re-run: devworkspace analyze');\n }\n } else add('contract', 'warn', 'Testing contract not generated yet', 'Run: devworkspace analyze');\n\n if (await pathExists(ws.features)) {\n try {\n const f = await loadFeatures(ws);\n const rep = await validateFeatureMap(ws.root, f.features);\n if (rep.total === 0) {\n add('features', 'info', 'Feature map present but contains no features (.devworkspace/context/features.json)');\n } else if (rep.unknown > 0 || rep.features.some((x) => !x.valid)) {\n const broken = rep.features.filter((x) => !x.valid).map((x) => `${x.featureId}: ${x.issues[0]}`).slice(0, 3).join('; ');\n add(\n 'features',\n 'warn',\n `${rep.total} feature(s) mapped, but some contain missing files or broken symbols (${broken})`,\n 'Run \"devworkspace feature validate\" or update .devworkspace/context/features.json.',\n );\n } else {\n add('features', 'pass', `${rep.total} feature(s) mapped: ${rep.verified} verified, ${rep.inferred} inferred`);\n }\n } catch (e) {\n add('features', 'fail', (e as Error).message.split('\\n')[0]!, 'Fix .devworkspace/context/features.json');\n }\n } else {\n add('features', 'info', 'No feature map defined (.devworkspace/context/features.json is optional)');\n }\n\n await checkDiscovery(ws, add);\n\n if (await pathExists(ws.analysisState)) {\n try {\n const a = (await readVersioned(ws.analysisState, 'analysis', SCHEMA_VERSION, validateAnalysisState)).data;\n add('analysis', 'pass', `Last analysis ${a.analyzedAt}${a.truncated ? ' (partial: size limits hit)' : ''}`);\n } catch (e) {\n add('analysis', 'fail', (e as Error).message.split('\\n')[0]!, 'Re-run: devworkspace analyze');\n }\n } else add('analysis', 'warn', 'Repository has not been analyzed', 'Run: devworkspace analyze');\n\n // Prompt quality (when present).\n if (await pathExists(ws.onboardingPrompt)) {\n const text = (await readTextBounded(ws.onboardingPrompt, 1024 * 1024)) ?? '';\n const missing = validatePrompt(text, ONBOARDING_REQUIREMENTS);\n if (missing.length === 0) add('onboarding-prompt', 'pass', 'Onboarding prompt satisfies all behavioural requirements');\n else add('onboarding-prompt', 'fail', `Onboarding prompt is missing: ${missing.join(', ')}`, 'Re-run: devworkspace analyze');\n }\n\n // Agent wiring.\n const installedAgents = await detectInstalledAgents(ws);\n if (installedAgents.length > 0) {\n const names = installedAgents.map((a) => a.displayName).join(', ');\n const msg = installedAgents.length === 1 && installedAgents[0]!.id === 'claude'\n ? 'Claude instructions and skill installed'\n : `${names} instructions installed`;\n add('agent-instructions', 'pass', msg);\n\n // Read-only: plan() only computes what an install would write; nothing is touched here.\n const projectName = (await loadProject(ws).catch(() => null))?.name ?? path.basename(root);\n const outdatedByAgent: { agent: AgentAdapter; paths: string[] }[] = [];\n for (const adapter of installedAgents) {\n const planned = await adapter.plan({ root, projectName });\n const outdated = planned.filter((c) => c.kind === 'update').map((c) => c.path);\n if (outdated.length > 0) {\n outdatedByAgent.push({ agent: adapter, paths: outdated });\n }\n }\n if (outdatedByAgent.length > 0) {\n const allPaths = outdatedByAgent.flatMap((x) => x.paths);\n const namesStale = outdatedByAgent.map((x) => x.agent.displayName).join(', ');\n add(\n 'agent-freshness',\n 'warn',\n `Installed ${namesStale} instructions are older than this DevWorkspace version (${allPaths.join(', ')})`,\n 'Run: devworkspace agent install (add --dry-run to preview; only the managed block and the devworkspace skill change).',\n );\n } else {\n add(\n 'agent-freshness',\n 'pass',\n installedAgents.length === 1 && installedAgents[0]!.id === 'claude'\n ? 'Installed Claude instructions and skill match this DevWorkspace version'\n : `Installed ${names} instructions match this DevWorkspace version`,\n );\n }\n } else {\n add(\n 'agent-instructions',\n 'warn',\n 'Agent instructions are not installed (or the managed section is missing)',\n 'Run: devworkspace agent install',\n );\n }\n if (await knowledgeWritten(ws)) add('onboarding', 'pass', 'Architecture knowledge written');\n else 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.).');\n\n // Security and portability.\n const wsFiles = (await listFilesRecursive(ws.dir, 3000)).filter((f) => !f.startsWith(ws.localDir) && !/\\.tmp$/.test(f));\n const secretHits: string[] = [];\n const absHits: string[] = [];\n for (const f of wsFiles) {\n if (!/\\.(json|md)$/.test(f)) continue;\n const rel = path.relative(ws.dir, f).replace(/\\\\/g, '/');\n const text = await readTextBounded(f, 1024 * 1024);\n if (!text) continue;\n if (findSecrets(text).length > 0) secretHits.push(rel);\n if (rel !== 'analysis/onboarding-prompt.md' && rel !== 'analysis/refresh-prompt.md' && findAbsolutePaths(text).length > 0) absHits.push(rel);\n }\n if (secretHits.length === 0) add('secrets', 'pass', 'No secret-like values in .devworkspace');\n else add('secrets', 'fail', `Secret-like values found in: ${secretHits.join(', ')}`, 'Remove the values, rotate the credential if it was real, and re-run doctor.');\n if (absHits.length === 0) add('portability', 'pass', 'No machine-specific absolute paths in portable knowledge');\n else add('portability', 'warn', `Absolute paths found in: ${absHits.join(', ')}`, 'Replace them with project-relative paths so the workspace works after the project moves.');\n\n const git = await getGitState(root);\n if (git.isRepo) {\n const tracked = await gitTrackedFiles(root);\n const bad = (tracked ?? []).filter((f) => isSensitiveFile(f));\n if (bad.length > 0) add('tracked-secrets', 'warn', `Credential-like files are tracked by Git: ${bad.slice(0, 5).join(', ')}`, 'Remove them from Git history if they hold real secrets (git rm --cached, then rotate).');\n else add('tracked-secrets', 'pass', 'No credential-like files tracked by Git');\n }\n\n const leftovers = wsFiles.filter((f) => f.endsWith('.tmp'));\n const allTmp = (await listFilesRecursive(ws.dir, 3000)).filter((f) => f.endsWith('.tmp'));\n if (allTmp.length > 0 || leftovers.length > 0) add('tmp-files', 'warn', `${allTmp.length} leftover temporary file(s) from an interrupted write`, 'They are safe to delete: ' + allTmp.slice(0, 3).map((f) => path.relative(root, f).replace(/\\\\/g, '/')).join(', '));\n\n // Tasks and decisions.\n const { tasks, corrupt } = await listTasks(ws, { includeCompleted: true });\n if (corrupt.length > 0) add('tasks', 'fail', `${corrupt.length} unreadable task file(s): ${corrupt.map((c) => c.file).join(', ')}`, 'Restore them from Git or delete the broken file.');\n else add('tasks', 'pass', `${tasks.length} task(s) readable`);\n const dec = await listDecisions(ws);\n if (dec.unreadable.length > 0) add('decisions', 'warn', `Unreadable decision file(s): ${dec.unreadable.join(', ')}`, 'Check their front matter.');\n\n return finish(root, checks, fixed, ws, o);\n}\n\nasync function finish(root: string | null, checks: DoctorCheck[], fixed: string[], ws: Ws | undefined, o: DoctorOptions): Promise<DoctorResult> {\n const counts = { pass: 0, warn: 0, fail: 0, info: 0 };\n for (const c of checks) counts[c.status]++;\n let ready = false;\n const discoveryOk = !checks.some((c) => DISCOVERY_CHECKS.has(c.id) && c.status === 'warn');\n if (ws) ready = counts.fail === 0 && discoveryOk && (await instructionsInstalled(ws)) && (await knowledgeWritten(ws));\n // Integrations are observed (tools are run), and reported separately: a missing optional tool never makes the core workspace unhealthy.\n const integrations = root && ws ? await inspectAll(ws, managerEnv(o, root), { deep: true }) : [];\n const s = summarize(integrations);\n return { root, checks, counts, healthy: counts.fail === 0, ready, fixed, integrations, integrationSummary: { complete: integrations.length > 0 && s.complete, required: s.required, verified: s.verified } };\n}\n\n/** Doctor checks that say whether the repository was actually understood, as opposed to the folder merely existing. */\nconst DISCOVERY_CHECKS = new Set(['discovery-incomplete', 'discovery-ecosystem', 'verification-commands']);\n\n/** package.json files near the top of the tree (two levels), found without a full scan. */\nasync function findNearbyManifests(root: string): Promise<string[]> {\n const found: string[] = [];\n const skip = (name: string, rel: string): boolean => name.startsWith('.') || ALWAYS_SKIP_DIRS.has(name) || isAuxPath(`${rel}/x`);\n async function dirs(rel: string): Promise<string[]> {\n try {\n return (await fs.readdir(path.join(root, rel), { withFileTypes: true })).filter((e) => e.isDirectory() && !skip(e.name, rel ? `${rel}/${e.name}` : e.name)).map((e) => (rel ? `${rel}/${e.name}` : e.name));\n } catch {\n return [];\n }\n }\n for (const d1 of await dirs('')) {\n if (await pathExists(path.join(root, d1, 'package.json'))) found.push(`${d1}/package.json`);\n for (const d2 of (await dirs(d1)).slice(0, 100)) if (await pathExists(path.join(root, d2, 'package.json'))) found.push(`${d2}/package.json`);\n }\n return found.sort();\n}\n\nasync function checkDiscovery(ws: Ws, add: (id: string, status: CheckStatus, message: string, remediation?: string) => void): Promise<void> {\n if (!(await pathExists(ws.discovery))) return; // \"not analyzed yet\" is reported by the analysis check\n let d: { ecosystems?: string[]; languages?: { name: string; files: number }[]; manifests?: string[]; monorepo?: { packages?: { path: string }[] }; scan?: { fileCount?: number } };\n try {\n d = (await readJsonFile(ws.discovery)) as typeof d;\n } catch (e) {\n add('discovery-ecosystem', 'fail', (e as Error).message.split('\\n')[0]!, 'Re-run: devworkspace analyze');\n return;\n }\n const eco = d.ecosystems ?? [];\n const languages = (d.languages ?? []).map((l) => l.name);\n // Manifests the analysis recorded. Older reports lack the list, so reconstruct it from the packages they did record.\n const known = new Set<string>(d.manifests ?? []);\n for (const p of d.monorepo?.packages ?? []) known.add(`${p.path}/package.json`);\n if (eco.includes('node')) known.add('package.json');\n const missed = (await findNearbyManifests(ws.root)).filter((m) => !known.has(m));\n if (missed.length > 0) {\n add(\n 'discovery-incomplete',\n 'warn',\n `The repository has package manifest(s) the last analysis did not record: ${missed.slice(0, 4).join(', ')}${missed.length > 4 ? ', ...' : ''}`,\n 'Run: devworkspace analyze (current versions detect nested packages). Commands you confirmed earlier are kept.',\n );\n } else if (eco.length === 0 && languages.length > 0) {\n add(\n 'discovery-ecosystem',\n 'warn',\n `No ecosystem was detected although ${d.scan?.fileCount ?? 'several'} files were scanned (${languages.slice(0, 3).join(', ')}), so build and test tooling is unknown`,\n 'Run: devworkspace analyze. If the project has no package manifest, record its commands by hand in .devworkspace/context/commands.json.',\n );\n } else if (eco.length > 0) {\n const n = d.monorepo?.packages?.length ?? 0;\n add('discovery-ecosystem', 'pass', `Detected ${eco.join(', ')}${n > 0 ? ` (${n} package${n === 1 ? '' : 's'})` : ''}`);\n } else {\n add('discovery-ecosystem', 'info', 'No source files or manifests detected');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/services/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAW,MAAM,sBAAsB,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,SAAS,EAA0B,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OA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C;gBACxB,YAAY,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,MAAM,EAAE,YAAY,IAAI,CAAC,OAAO,2CAA2C;iBAC5E,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7E,GAAG,CACD,cAAc,EACd,MAAM,EACN,+CAA+C,OAAO,EAAE,EACxD,8HAA8H,CAC/H,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvE,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,0CAA0C,SAAS,GAAG,CAAC,CAAC;IACtF,CAAC;AACH,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { SCHEMA_VERSION, validateAnalysisState, validateCommands } from '../config/schemas.js';\nimport { findWorkspaceRoot, LOCAL_GITIGNORE, loadProject, wsPaths, type Ws } from '../core/workspace.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { getGitState, gitAvailable, gitTrackedFiles } from '../git/git.js';\nimport { inspectAll, summarize, type IntegrationReport } from '../integrations/index.js';\nimport { evaluateStaleness, loadFacts } from '../knowledge/facts.js';\nimport { ONBOARDING_REQUIREMENTS, validatePrompt } from '../prompts/requirements.js';\nimport { isSensitiveFile } from '../security/files.js';\nimport { findSecrets } from '../security/redact.js';\nimport { listDecisions } from '../decisions/decision.js';\nimport { listTasks } from '../tasks/task.js';\nimport { ensureDir, listFilesRecursive, pathExists, readJsonFile, readTextBounded, atomicWriteFile } from '../utils/fs.js';\nimport { ALWAYS_SKIP_DIRS } from '../discovery/scan.js';\nimport { isAuxPath } from '../discovery/detect.js';\nimport { detectContractDrift } from '../discovery/commands.js';\nimport { loadFeatures } from './features.js';\nimport { validateFeatureMap } from '../features/validate.js';\nimport { findAbsolutePaths } from '../utils/paths.js';\nimport { detectInstalledAgents, instructionsInstalled, knowledgeWritten } from './status.js';\nimport { managerEnv, type ServiceOptions } from './common.js';\nimport { withLock } from '../utils/lock.js';\nimport type { AgentAdapter } from '../agents/types.js';\nimport { which } from '../utils/proc.js';\n\nexport type CheckStatus = 'pass' | 'warn' | 'fail' | 'info';\n\nexport interface DoctorCheck {\n id: string;\n status: CheckStatus;\n message: string;\n remediation?: string;\n}\n\nexport interface DoctorResult {\n root: string | null;\n checks: DoctorCheck[];\n counts: { pass: number; warn: number; fail: number; info: number };\n /** Core workspace has no failing checks. */\n healthy: boolean;\n /** Core workspace is onboarded: instructions installed and architecture knowledge written. */\n ready: boolean;\n fixed: string[];\n /** Observed integration state, kept separate from core readiness. */\n integrations: IntegrationReport[];\n integrationSummary: { complete: boolean; required: number; verified: number };\n}\n\nexport interface DoctorOptions extends ServiceOptions {\n fix?: boolean;\n minNodeMajor?: number;\n}\n\nexport const MIN_NODE_MAJOR = 20;\n\nexport async function runDoctor(o: DoctorOptions): Promise<DoctorResult> {\n const checks: DoctorCheck[] = [];\n const fixed: string[] = [];\n const add = (id: string, status: CheckStatus, message: string, remediation?: string): void => {\n checks.push({ id, status, message, ...(remediation ? { remediation } : {}) });\n };\n\n const major = Number(process.versions.node.split('.')[0]);\n const minNode = o.minNodeMajor ?? MIN_NODE_MAJOR;\n if (major >= minNode) add('node', 'pass', `Node.js ${process.versions.node}`);\n else add('node', 'fail', `Node.js ${process.versions.node} is older than the required ${minNode}`, `Install Node.js ${minNode} or newer (https://nodejs.org).`);\n\n const hasGit = await gitAvailable();\n if (hasGit) add('git', 'pass', 'Git is available');\n else add('git', 'warn', 'Git was not found on PATH', 'Install Git; DevWorkspace works without it but cannot protect uncommitted changes.');\n\n const root = await findWorkspaceRoot(o.cwd);\n if (!root) {\n if (await pathExists(path.join(o.cwd, '.devworkspace'))) {\n add('workspace', 'fail', 'Partial initialization: .devworkspace/ exists but project.json is missing', 'Restore project.json from Git, or run \"devworkspace init\" to complete the setup (existing files are kept).');\n } else {\n add('workspace', 'fail', 'No DevWorkspace found in this directory or any parent', 'Run: devworkspace init');\n }\n return finish(null, checks, fixed, undefined, o);\n }\n const ws = wsPaths(root);\n add('workspace', 'pass', 'Workspace found');\n\n // Project config and schema compatibility.\n let projectOk = false;\n let acknowledgedNoVerification = false;\n try {\n const p = await loadProject(ws);\n projectOk = true;\n acknowledgedNoVerification = p.settings.acknowledgeNoVerification === true;\n add('project', 'pass', `project.json valid (schema v${p.schemaVersion}, id ${p.projectId.slice(0, 8)})`);\n } catch (e) {\n const code = (e as { code?: string }).code;\n add('project', 'fail', (e as Error).message.split('\\n')[0]!, code === 'SCHEMA_TOO_NEW' ? 'Upgrade DevWorkspace: npm install -g devworkspace@latest' : 'Restore .devworkspace/project.json from Git, or re-run \"devworkspace init\" after moving the broken file away.');\n }\n\n // Layout.\n const dirs = [ws.contextDir, ws.decisionsDir, ws.tasksActive, ws.tasksCompleted, ws.sessionsDir, ws.analysisDir, ws.stateDir];\n const missingDirs: string[] = [];\n for (const d of dirs) if (!(await pathExists(d))) missingDirs.push(d);\n if (missingDirs.length === 0) add('layout', 'pass', 'Workspace folders present');\n else if (o.fix && projectOk) {\n await withLock(ws.dir, async () => {\n for (const d of missingDirs) await ensureDir(d);\n });\n fixed.push(`created ${missingDirs.length} missing folder(s)`);\n add('layout', 'pass', `Recreated ${missingDirs.length} missing folder(s)`);\n } else {\n add('layout', 'warn', `Missing folders: ${missingDirs.map((d) => path.basename(d)).join(', ')}`, 'Run: devworkspace doctor --fix');\n }\n\n // Ignore rules.\n const giOk = await fs.readFile(ws.gitignore, 'utf8').then(\n (gi) => gi.split(/\\r?\\n/).some((l) => l.trim() === 'local/'),\n () => false,\n );\n if (giOk) add('ignore-local', 'pass', 'Machine-local state is git-ignored');\n else if (o.fix && projectOk) {\n await atomicWriteFile(ws.gitignore, LOCAL_GITIGNORE);\n fixed.push('wrote .devworkspace/.gitignore');\n add('ignore-local', 'pass', 'Wrote .devworkspace/.gitignore');\n } else add('ignore-local', 'fail', '.devworkspace/.gitignore does not ignore local/', 'Run: devworkspace doctor --fix');\n\n try {\n const rootGi = await fs.readFile(path.join(root, '.gitignore'), 'utf8');\n if (rootGi.split(/\\r?\\n/).some((l) => /^\\/?\\.devworkspace\\/?\\*?$/.test(l.trim()))) {\n add('ignore-root', 'warn', 'The root .gitignore ignores all of .devworkspace/, so project knowledge will not be shared', 'Remove that rule; .devworkspace/.gitignore already excludes machine-local files.');\n }\n } catch {\n /* no root .gitignore */\n }\n\n // Knowledge and contract.\n try {\n const facts = await loadFacts(ws);\n const view = await evaluateStaleness(ws.root, facts, new Date().toISOString());\n const stale = [...view.recorded, ...view.detected];\n add('facts', 'pass', `${facts.facts.length} fact(s) stored`);\n if (stale.length > 0) add('staleness', 'warn', `${stale.length} stale fact(s): ${stale.slice(0, 5).map((f) => `${f.key} (${f.reason})`).join('; ')}`, 'Run: devworkspace refresh, then re-check the listed facts against the repository.');\n else if (facts.facts.length > 0) add('staleness', 'pass', 'No stale facts recorded');\n } catch (e) {\n add('facts', 'fail', (e as Error).message.split('\\n')[0]!, 'Restore .devworkspace/context/facts.json from Git or a backup under .devworkspace/local/backups.');\n }\n\n if (await pathExists(ws.commands)) {\n try {\n const c = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data;\n add('contract', 'pass', 'Testing contract present');\n if (!c.checks.some((x) => x.id === 'unit' && x.available)) add('tests-available', 'warn', 'No unit-test command detected', 'Add a test script or edit .devworkspace/context/commands.json; tasks will not be able to demand tests.');\n if (!c.checks.some((x) => x.id === 'build' && x.available)) add('build-available', 'info', 'No build command detected');\n const configured = c.checks.filter((x) => x.available);\n if (configured.length > 0) {\n const ids = [...new Set(configured.map((x) => x.id))];\n const dirs = [...new Set(configured.map((x) => x.cwd).filter((d): d is string => !!d))];\n add('verification-commands', 'pass', `${ids.length} verification check(s) configured: ${ids.join(', ')}${dirs.length ? ` (in ${dirs.join(', ')})` : ''}`);\n\n const drift = await detectContractDrift(ws.root, c.checks);\n if (drift.hasDrift) {\n const summary = drift.issues.slice(0, 3).map((i) => `${i.id}${i.cwd ? ` [${i.cwd}]` : ''}: ${i.message}`).join('; ');\n const more = drift.issues.length > 3 ? ` (+${drift.issues.length - 3} more)` : '';\n add(\n 'contract-drift',\n 'warn',\n `Verification contract has drifted from actual repository scripts (${drift.issues.length} issue(s): ${summary}${more})`,\n 'Run \"devworkspace refresh\" to resynchronize with package manifests, or edit .devworkspace/context/commands.json.',\n );\n } else {\n add('contract-drift', 'pass', 'Verification commands match repository manifests and directories');\n }\n } else if (acknowledgedNoVerification) {\n add('verification-commands', 'info', 'No verification commands; acknowledged in project.json (settings.acknowledgeNoVerification)');\n } else {\n add(\n 'verification-commands',\n 'warn',\n 'No verification commands (tests, lint, typecheck, build) are configured, so tasks cannot require any verification',\n 'Run: devworkspace analyze. If the project intentionally has none, set \"acknowledgeNoVerification\": true under settings in .devworkspace/project.json.',\n );\n }\n } catch (e) {\n add('contract', 'fail', (e as Error).message.split('\\n')[0]!, 'Fix commands.json or re-run: devworkspace analyze');\n }\n } else add('contract', 'warn', 'Testing contract not generated yet', 'Run: devworkspace analyze');\n\n if (await pathExists(ws.features)) {\n try {\n const f = await loadFeatures(ws);\n const rep = await validateFeatureMap(ws.root, f.features);\n if (rep.total === 0) {\n add('features', 'info', 'Feature map present but contains no features (.devworkspace/context/features.json)');\n } else if (rep.unknown > 0 || rep.features.some((x) => !x.valid)) {\n const broken = rep.features.filter((x) => !x.valid).map((x) => `${x.featureId}: ${x.issues[0]}`).slice(0, 3).join('; ');\n add(\n 'features',\n 'warn',\n `${rep.total} feature(s) mapped, but some contain missing files or broken symbols (${broken})`,\n 'Run \"devworkspace feature validate\" or update .devworkspace/context/features.json.',\n );\n } else {\n add('features', 'pass', `${rep.total} feature(s) mapped: ${rep.verified} verified, ${rep.inferred} inferred`);\n }\n } catch (e) {\n add('features', 'fail', (e as Error).message.split('\\n')[0]!, 'Fix .devworkspace/context/features.json');\n }\n } else {\n add('features', 'info', 'No feature map defined (.devworkspace/context/features.json is optional)');\n }\n\n await checkDiscovery(ws, add);\n\n if (await pathExists(ws.analysisState)) {\n try {\n const a = (await readVersioned(ws.analysisState, 'analysis', SCHEMA_VERSION, validateAnalysisState)).data;\n add('analysis', 'pass', `Last analysis ${a.analyzedAt}${a.truncated ? ' (partial: size limits hit)' : ''}`);\n } catch (e) {\n add('analysis', 'fail', (e as Error).message.split('\\n')[0]!, 'Re-run: devworkspace analyze');\n }\n } else add('analysis', 'warn', 'Repository has not been analyzed', 'Run: devworkspace analyze');\n\n // Prompt quality (when present).\n if (await pathExists(ws.onboardingPrompt)) {\n const text = (await readTextBounded(ws.onboardingPrompt, 1024 * 1024)) ?? '';\n const missing = validatePrompt(text, ONBOARDING_REQUIREMENTS);\n if (missing.length === 0) add('onboarding-prompt', 'pass', 'Onboarding prompt satisfies all behavioural requirements');\n else add('onboarding-prompt', 'fail', `Onboarding prompt is missing: ${missing.join(', ')}`, 'Re-run: devworkspace analyze');\n }\n\n // Agent wiring.\n const installedAgents = await detectInstalledAgents(ws);\n if (installedAgents.length > 0) {\n const names = installedAgents.map((a) => a.displayName).join(', ');\n const msg = installedAgents.length === 1 && installedAgents[0]!.id === 'claude'\n ? 'Claude instructions and skill installed'\n : `${names} instructions installed`;\n add('agent-instructions', 'pass', msg);\n\n // Read-only: plan() only computes what an install would write; nothing is touched here.\n const projectName = (await loadProject(ws).catch(() => null))?.name ?? path.basename(root);\n const outdatedByAgent: { agent: AgentAdapter; paths: string[] }[] = [];\n for (const adapter of installedAgents) {\n const planned = await adapter.plan({ root, projectName });\n const outdated = planned.filter((c) => c.kind === 'update').map((c) => c.path);\n if (outdated.length > 0) {\n outdatedByAgent.push({ agent: adapter, paths: outdated });\n }\n }\n if (outdatedByAgent.length > 0) {\n const allPaths = outdatedByAgent.flatMap((x) => x.paths);\n const namesStale = outdatedByAgent.map((x) => x.agent.displayName).join(', ');\n add(\n 'agent-freshness',\n 'warn',\n `Installed ${namesStale} instructions are older than this DevWorkspace version (${allPaths.join(', ')})`,\n 'Run: devworkspace agent install (add --dry-run to preview; only the managed block and the devworkspace skill change).',\n );\n } else {\n add(\n 'agent-freshness',\n 'pass',\n installedAgents.length === 1 && installedAgents[0]!.id === 'claude'\n ? 'Installed Claude instructions and skill match this DevWorkspace version'\n : `Installed ${names} instructions match this DevWorkspace version`,\n );\n }\n } else {\n add(\n 'agent-instructions',\n 'warn',\n 'Agent instructions are not installed (or the managed section is missing)',\n 'Run: devworkspace agent install',\n );\n }\n if (await knowledgeWritten(ws)) add('onboarding', 'pass', 'Architecture knowledge written');\n else 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.).');\n\n // MCP launcher configuration verification\n await checkMcpLauncher(root, add);\n\n // Security and portability.\n const wsFiles = (await listFilesRecursive(ws.dir, 3000)).filter((f) => !f.startsWith(ws.localDir) && !/\\.tmp$/.test(f));\n const secretHits: string[] = [];\n const absHits: string[] = [];\n for (const f of wsFiles) {\n if (!/\\.(json|md)$/.test(f)) continue;\n const rel = path.relative(ws.dir, f).replace(/\\\\/g, '/');\n const text = await readTextBounded(f, 1024 * 1024);\n if (!text) continue;\n if (findSecrets(text).length > 0) secretHits.push(rel);\n if (rel !== 'analysis/onboarding-prompt.md' && rel !== 'analysis/refresh-prompt.md' && findAbsolutePaths(text).length > 0) absHits.push(rel);\n }\n if (secretHits.length === 0) add('secrets', 'pass', 'No secret-like values in .devworkspace');\n else add('secrets', 'fail', `Secret-like values found in: ${secretHits.join(', ')}`, 'Remove the values, rotate the credential if it was real, and re-run doctor.');\n if (absHits.length === 0) add('portability', 'pass', 'No machine-specific absolute paths in portable knowledge');\n else add('portability', 'warn', `Absolute paths found in: ${absHits.join(', ')}`, 'Replace them with project-relative paths so the workspace works after the project moves.');\n\n const git = await getGitState(root);\n if (git.isRepo) {\n const tracked = await gitTrackedFiles(root);\n const bad = (tracked ?? []).filter((f) => isSensitiveFile(f));\n if (bad.length > 0) add('tracked-secrets', 'warn', `Credential-like files are tracked by Git: ${bad.slice(0, 5).join(', ')}`, 'Remove them from Git history if they hold real secrets (git rm --cached, then rotate).');\n else add('tracked-secrets', 'pass', 'No credential-like files tracked by Git');\n }\n\n const leftovers = wsFiles.filter((f) => f.endsWith('.tmp'));\n const allTmp = (await listFilesRecursive(ws.dir, 3000)).filter((f) => f.endsWith('.tmp'));\n if (allTmp.length > 0 || leftovers.length > 0) add('tmp-files', 'warn', `${allTmp.length} leftover temporary file(s) from an interrupted write`, 'They are safe to delete: ' + allTmp.slice(0, 3).map((f) => path.relative(root, f).replace(/\\\\/g, '/')).join(', '));\n\n // Tasks and decisions.\n const { tasks, corrupt } = await listTasks(ws, { includeCompleted: true });\n if (corrupt.length > 0) add('tasks', 'fail', `${corrupt.length} unreadable task file(s): ${corrupt.map((c) => c.file).join(', ')}`, 'Restore them from Git or delete the broken file.');\n else add('tasks', 'pass', `${tasks.length} task(s) readable`);\n const dec = await listDecisions(ws);\n if (dec.unreadable.length > 0) add('decisions', 'warn', `Unreadable decision file(s): ${dec.unreadable.join(', ')}`, 'Check their front matter.');\n\n return finish(root, checks, fixed, ws, o);\n}\n\nasync function finish(root: string | null, checks: DoctorCheck[], fixed: string[], ws: Ws | undefined, o: DoctorOptions): Promise<DoctorResult> {\n const counts = { pass: 0, warn: 0, fail: 0, info: 0 };\n for (const c of checks) counts[c.status]++;\n let ready = false;\n const discoveryOk = !checks.some((c) => DISCOVERY_CHECKS.has(c.id) && c.status === 'warn');\n if (ws) ready = counts.fail === 0 && discoveryOk && (await instructionsInstalled(ws)) && (await knowledgeWritten(ws));\n // Integrations are observed (tools are run), and reported separately: a missing optional tool never makes the core workspace unhealthy.\n const integrations = root && ws ? await inspectAll(ws, managerEnv(o, root), { deep: true }) : [];\n const s = summarize(integrations);\n return { root, checks, counts, healthy: counts.fail === 0, ready, fixed, integrations, integrationSummary: { complete: integrations.length > 0 && s.complete, required: s.required, verified: s.verified } };\n}\n\n/** Doctor checks that say whether the repository was actually understood, as opposed to the folder merely existing. */\nconst DISCOVERY_CHECKS = new Set(['discovery-incomplete', 'discovery-ecosystem', 'verification-commands']);\n\n/** package.json files near the top of the tree (two levels), found without a full scan. */\nasync function findNearbyManifests(root: string): Promise<string[]> {\n const found: string[] = [];\n const skip = (name: string, rel: string): boolean => name.startsWith('.') || ALWAYS_SKIP_DIRS.has(name) || isAuxPath(`${rel}/x`);\n async function dirs(rel: string): Promise<string[]> {\n try {\n return (await fs.readdir(path.join(root, rel), { withFileTypes: true })).filter((e) => e.isDirectory() && !skip(e.name, rel ? `${rel}/${e.name}` : e.name)).map((e) => (rel ? `${rel}/${e.name}` : e.name));\n } catch {\n return [];\n }\n }\n for (const d1 of await dirs('')) {\n if (await pathExists(path.join(root, d1, 'package.json'))) found.push(`${d1}/package.json`);\n for (const d2 of (await dirs(d1)).slice(0, 100)) if (await pathExists(path.join(root, d2, 'package.json'))) found.push(`${d2}/package.json`);\n }\n return found.sort();\n}\n\nasync function checkDiscovery(ws: Ws, add: (id: string, status: CheckStatus, message: string, remediation?: string) => void): Promise<void> {\n if (!(await pathExists(ws.discovery))) return; // \"not analyzed yet\" is reported by the analysis check\n let d: { ecosystems?: string[]; languages?: { name: string; files: number }[]; manifests?: string[]; monorepo?: { packages?: { path: string }[] }; scan?: { fileCount?: number } };\n try {\n d = (await readJsonFile(ws.discovery)) as typeof d;\n } catch (e) {\n add('discovery-ecosystem', 'fail', (e as Error).message.split('\\n')[0]!, 'Re-run: devworkspace analyze');\n return;\n }\n const eco = d.ecosystems ?? [];\n const languages = (d.languages ?? []).map((l) => l.name);\n // Manifests the analysis recorded. Older reports lack the list, so reconstruct it from the packages they did record.\n const known = new Set<string>(d.manifests ?? []);\n for (const p of d.monorepo?.packages ?? []) known.add(`${p.path}/package.json`);\n if (eco.includes('node')) known.add('package.json');\n const missed = (await findNearbyManifests(ws.root)).filter((m) => !known.has(m));\n if (missed.length > 0) {\n add(\n 'discovery-incomplete',\n 'warn',\n `The repository has package manifest(s) the last analysis did not record: ${missed.slice(0, 4).join(', ')}${missed.length > 4 ? ', ...' : ''}`,\n 'Run: devworkspace analyze (current versions detect nested packages). Commands you confirmed earlier are kept.',\n );\n } else if (eco.length === 0 && languages.length > 0) {\n add(\n 'discovery-ecosystem',\n 'warn',\n `No ecosystem was detected although ${d.scan?.fileCount ?? 'several'} files were scanned (${languages.slice(0, 3).join(', ')}), so build and test tooling is unknown`,\n 'Run: devworkspace analyze. If the project has no package manifest, record its commands by hand in .devworkspace/context/commands.json.',\n );\n } else if (eco.length > 0) {\n const n = d.monorepo?.packages?.length ?? 0;\n add('discovery-ecosystem', 'pass', `Detected ${eco.join(', ')}${n > 0 ? ` (${n} package${n === 1 ? '' : 's'})` : ''}`);\n } else {\n add('discovery-ecosystem', 'info', 'No source files or manifests detected');\n }\n}\n\nasync function checkMcpLauncher(\n root: string,\n add: (id: string, status: CheckStatus, message: string, remediation?: string) => void,\n): Promise<void> {\n const configs = [\n { file: '.mcp.json' },\n { file: 'mcp.json' },\n { file: path.join('.antigravity', 'mcp.json') },\n ];\n\n const found: { file: string; command: string; args: string[] }[] = [];\n for (const cfg of configs) {\n const full = path.join(root, cfg.file);\n if (await pathExists(full)) {\n try {\n const raw = await readJsonFile(full);\n const obj = typeof raw === 'object' && raw !== null ? (raw as Record<string, unknown>) : null;\n const servers = obj?.mcpServers && typeof obj.mcpServers === 'object' ? (obj.mcpServers as Record<string, unknown>) : null;\n const devServer = servers?.devworkspace && typeof servers.devworkspace === 'object' ? (servers.devworkspace as Record<string, unknown>) : null;\n if (devServer && typeof devServer.command === 'string') {\n found.push({\n file: cfg.file,\n command: devServer.command,\n args: Array.isArray(devServer.args) ? devServer.args.map(String) : [],\n });\n }\n } catch {\n // syntax error\n }\n }\n }\n\n if (found.length === 0) return;\n\n const badLaunchers: { file: string; command: string; reason: string }[] = [];\n for (const item of found) {\n if (item.command === 'devworkspace') {\n const onPath = await which('devworkspace');\n if (!onPath) {\n badLaunchers.push({\n file: item.file,\n command: item.command,\n reason: '\"devworkspace\" binary was not found on PATH',\n });\n }\n } else if (item.command === 'npx') {\n const onPath = await which('npx');\n if (!onPath) {\n badLaunchers.push({\n file: item.file,\n command: item.command,\n reason: '\"npx\" binary was not found on PATH',\n });\n }\n } else {\n const onPath = await which(item.command);\n const isLocal = await pathExists(path.resolve(root, item.command));\n if (!onPath && !isLocal) {\n badLaunchers.push({\n file: item.file,\n command: item.command,\n reason: `command \"${item.command}\" was not found on PATH or workspace root`,\n });\n }\n }\n }\n\n if (badLaunchers.length > 0) {\n const details = badLaunchers.map((b) => `${b.file}: ${b.reason}`).join('; ');\n add(\n 'mcp-launcher',\n 'warn',\n `Configured MCP launcher cannot be resolved: ${details}`,\n 'Install DevWorkspace globally (npm install -g devworkspace) or re-run: devworkspace setup --agent claude-code --launcher npx',\n );\n } else {\n const launchers = [...new Set(found.map((f) => f.command))].join(', ');\n add('mcp-launcher', 'pass', `Configured MCP launcher is resolvable (${launchers})`);\n }\n}\n"]}
|
package/dist/services/graph.d.ts
CHANGED
|
@@ -82,6 +82,13 @@ export declare function loadGraphData(root: string): Promise<{
|
|
|
82
82
|
* Reports the presence, size, and basic schema health of the Graphify graph.
|
|
83
83
|
*/
|
|
84
84
|
export declare function getGraphStatusService(o: ServiceOptions): Promise<GraphStatusResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Extracts a candidate file path and symbol from a node definition.
|
|
87
|
+
*/
|
|
88
|
+
export declare function extractPathAndSymbol(node: RawGraphNode): {
|
|
89
|
+
relPath: string | null;
|
|
90
|
+
symbol: string | null;
|
|
91
|
+
};
|
|
85
92
|
/**
|
|
86
93
|
* Finds the starting node in a graph that matches the user's query.
|
|
87
94
|
*/
|
package/dist/services/graph.js
CHANGED
|
@@ -85,7 +85,7 @@ export async function getGraphStatusService(o) {
|
|
|
85
85
|
/**
|
|
86
86
|
* Extracts a candidate file path and symbol from a node definition.
|
|
87
87
|
*/
|
|
88
|
-
function extractPathAndSymbol(node) {
|
|
88
|
+
export function extractPathAndSymbol(node) {
|
|
89
89
|
// If explicitly declared:
|
|
90
90
|
const rawPath = typeof node.path === 'string' ? node.path : typeof node.file === 'string' ? node.file : null;
|
|
91
91
|
let relPath = rawPath ? rawPath.replace(/\\/g, '/').replace(/^\/+/, '') : null;
|
|
@@ -174,12 +174,19 @@ async function verifyNode(root, node, depth) {
|
|
|
174
174
|
...(reason ? { reason } : {}),
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
+
const GRAPH_STOP_WORDS = new Set([
|
|
178
|
+
'the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'does', 'how',
|
|
179
|
+
'what', 'where', 'why', 'when', 'which', 'to', 'in', 'of', 'at', 'by', 'on',
|
|
180
|
+
'as', 'an', 'a', 'or', 'is', 'it', 'be', 'so', 'db'
|
|
181
|
+
]);
|
|
177
182
|
/**
|
|
178
183
|
* Finds the starting node in a graph that matches the user's query.
|
|
179
184
|
*/
|
|
180
185
|
export function findMatchingStartNode(nodes, query) {
|
|
181
186
|
const q = query.trim().toLowerCase();
|
|
182
187
|
const qNorm = q.replace(/\\/g, '/');
|
|
188
|
+
if (q.length === 0 || GRAPH_STOP_WORDS.has(q))
|
|
189
|
+
return null;
|
|
183
190
|
// 1. Exact match on ID
|
|
184
191
|
const exactId = nodes.find((n) => n.id.toLowerCase() === q || n.id.toLowerCase().replace(/\\/g, '/') === qNorm);
|
|
185
192
|
if (exactId)
|
|
@@ -198,14 +205,16 @@ export function findMatchingStartNode(nodes, query) {
|
|
|
198
205
|
});
|
|
199
206
|
if (exactName)
|
|
200
207
|
return exactName;
|
|
201
|
-
// 4. Substring match on ID or path
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
// 4. Substring match on ID or path only for meaningful terms of at least 3 characters
|
|
209
|
+
if (q.length >= 3 && !GRAPH_STOP_WORDS.has(qNorm)) {
|
|
210
|
+
const subMatch = nodes.find((n) => {
|
|
211
|
+
const id = n.id.toLowerCase().replace(/\\/g, '/');
|
|
212
|
+
const p = (n.path || n.file || '').toLowerCase().replace(/\\/g, '/');
|
|
213
|
+
return id.includes(qNorm) || p.includes(qNorm);
|
|
214
|
+
});
|
|
215
|
+
if (subMatch)
|
|
216
|
+
return subMatch;
|
|
217
|
+
}
|
|
209
218
|
return null;
|
|
210
219
|
}
|
|
211
220
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/services/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AA0EvD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,C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,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhG,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;IACvE,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC;IAChF,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,MAAM,CAAC;IAEpF,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,GAAG,eAAe,kGAAkG,CAAC,CAAC;IACtI,CAAC;IAED,OAAO;QACL,SAAS,EAAE,IAAI;QACf,KAAK;QACL,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,OAAO;QACpB,UAAU,EAAE,WAAW,CAAC,MAAM;QAC9B,aAAa,EAAE,aAAa;QAC5B,eAAe,EAAE,eAAe;QAChC,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,WAAW;QAClB,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { pathExists, readTextBounded } from '../utils/fs.js';\nimport { findSymbolInText } from '../features/validate.js';\nimport { requireWorkspace } from '../core/workspace.js';\nimport type { ServiceOptions } from './common.js';\nimport { DevWorkspaceError } from '../errors/index.js';\n\nexport type NodeVerificationStatus = 'verified' | 'hypothesis';\n\nexport interface RawGraphNode {\n id: string;\n name?: string;\n label?: string;\n type?: string;\n path?: string;\n file?: string;\n [key: string]: unknown;\n}\n\nexport interface RawGraphEdge {\n source: string;\n target: string;\n relation?: string;\n type?: string;\n label?: string;\n weight?: number;\n [key: string]: unknown;\n}\n\nexport interface RawGraphData {\n nodes?: RawGraphNode[];\n edges?: RawGraphEdge[];\n links?: RawGraphEdge[];\n [key: string]: unknown;\n}\n\nexport interface TracedNode {\n id: string;\n name: string;\n type: string;\n path: string | null;\n symbol: string | null;\n depth: number;\n status: NodeVerificationStatus;\n fileExists: boolean;\n symbolFound: boolean | null;\n reason?: string;\n}\n\nexport interface TracedEdge {\n source: string;\n target: string;\n relation: string;\n status: NodeVerificationStatus;\n}\n\nexport interface GraphStatusResult {\n available: boolean;\n graphPath: string;\n nodesCount: number;\n edgesCount: number;\n nodeTypes: Record<string, number>;\n message: string;\n hint?: string;\n}\n\nexport interface GraphTraceResult {\n available: boolean;\n query: string;\n depth: number;\n matchedNode: TracedNode | null;\n totalNodes: number;\n verifiedNodes: number;\n hypothesisNodes: number;\n nodes: TracedNode[];\n edges: TracedEdge[];\n warnings: string[];\n}\n\n/**\n * Resolves the location of Graphify's output graph in the repository.\n */\nexport function getGraphPath(root: string): string {\n return path.join(root, 'graphify-out', 'graph.json');\n}\n\n/**\n * Loads and validates Graphify graph JSON data safely.\n */\nexport async function loadGraphData(root: string): Promise<{ exists: boolean; path: string; data?: { nodes: RawGraphNode[]; edges: RawGraphEdge[] } }> {\n const gPath = getGraphPath(root);\n if (!(await pathExists(gPath))) {\n return { exists: false, path: gPath };\n }\n\n let raw: string;\n try {\n raw = await fs.readFile(gPath, 'utf8');\n } catch (e) {\n throw new DevWorkspaceError('IO', `Failed to read Graphify output at \"${gPath}\": ${(e as Error).message}`, {\n hint: 'Ensure graphify-out/graph.json is readable or regenerate with \"graphify update .\".',\n });\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n throw new DevWorkspaceError('SCHEMA', `Graphify output at \"${gPath}\" is not valid JSON.`, {\n hint: 'Regenerate the graph using \"graphify update .\" or \"/graphify .\" in Claude Code.',\n });\n }\n\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new DevWorkspaceError('SCHEMA', `Graphify output at \"${gPath}\" must be a JSON object with nodes and edges.`, {\n hint: 'Regenerate the graph using \"graphify update .\".',\n });\n }\n\n const obj = parsed as RawGraphData;\n const nodes = Array.isArray(obj.nodes) ? obj.nodes : [];\n const edges = Array.isArray(obj.edges) ? obj.edges : Array.isArray(obj.links) ? obj.links : [];\n\n return {\n exists: true,\n path: gPath,\n data: { nodes, edges },\n };\n}\n\n/**\n * Reports the presence, size, and basic schema health of the Graphify graph.\n */\nexport async function getGraphStatusService(o: ServiceOptions): Promise<GraphStatusResult> {\n const ws = await requireWorkspace(o.cwd);\n const loaded = await loadGraphData(ws.root);\n\n if (!loaded.exists || !loaded.data) {\n return {\n available: false,\n graphPath: loaded.path,\n nodesCount: 0,\n edgesCount: 0,\n nodeTypes: {},\n message: 'No Graphify knowledge graph found at graphify-out/graph.json.',\n hint: 'In Claude Code run \"/graphify .\" to build the graph, or run \"graphify update .\" if already initialized.',\n };\n }\n\n const { nodes, edges } = loaded.data;\n const nodeTypes: Record<string, number> = {};\n for (const n of nodes) {\n const t = n.type || 'unknown';\n nodeTypes[t] = (nodeTypes[t] || 0) + 1;\n }\n\n return {\n available: true,\n graphPath: loaded.path,\n nodesCount: nodes.length,\n edgesCount: edges.length,\n nodeTypes,\n message: `Graphify graph loaded: ${nodes.length} nodes, ${edges.length} edges.`,\n };\n}\n\n/**\n * Extracts a candidate file path and symbol from a node definition.\n */\nfunction extractPathAndSymbol(node: RawGraphNode): { relPath: string | null; symbol: string | null } {\n // If explicitly declared:\n const rawPath = typeof node.path === 'string' ? node.path : typeof node.file === 'string' ? node.file : null;\n let relPath = rawPath ? rawPath.replace(/\\\\/g, '/').replace(/^\\/+/, '') : null;\n let symbol: string | null = null;\n\n if (node.id.includes('::')) {\n const parts = node.id.split('::');\n if (!relPath && parts[0] && (parts[0].includes('/') || parts[0].includes('.'))) {\n relPath = parts[0].replace(/\\\\/g, '/').replace(/^\\/+/, '');\n }\n symbol = parts[1] || null;\n } else if (!relPath && (node.id.includes('/') || node.id.includes('.'))) {\n relPath = node.id.replace(/\\\\/g, '/').replace(/^\\/+/, '');\n }\n\n if (!symbol && typeof node.name === 'string' && node.name !== relPath) {\n symbol = node.name;\n }\n\n return { relPath, symbol };\n}\n\n/**\n * Verifies whether a node's physical path and symbol exist on disk.\n */\nasync function verifyNode(root: string, node: RawGraphNode, depth: number): Promise<TracedNode> {\n const { relPath, symbol } = extractPathAndSymbol(node);\n const name = typeof node.name === 'string' ? node.name : typeof node.label === 'string' ? node.label : node.id;\n const type = typeof node.type === 'string' ? node.type : 'symbol';\n\n if (!relPath) {\n return {\n id: node.id,\n name,\n type,\n path: null,\n symbol,\n depth,\n status: 'hypothesis',\n fileExists: false,\n symbolFound: null,\n reason: 'No source file associated with node',\n };\n }\n\n const fullPath = path.join(root, ...relPath.split('/'));\n const exists = await pathExists(fullPath);\n\n if (!exists) {\n return {\n id: node.id,\n name,\n type,\n path: relPath,\n symbol,\n depth,\n status: 'hypothesis',\n fileExists: false,\n symbolFound: null,\n reason: `File \"${relPath}\" not found on disk`,\n };\n }\n\n let symbolFound: boolean | null = null;\n let status: NodeVerificationStatus = 'verified';\n let reason: string | undefined;\n\n if (symbol) {\n try {\n const text = await readTextBounded(fullPath, 500_000);\n if (text) {\n symbolFound = findSymbolInText(text, symbol);\n if (!symbolFound) {\n status = 'hypothesis';\n reason = `Symbol \"${symbol}\" not found in \"${relPath}\"`;\n }\n }\n } catch {\n status = 'hypothesis';\n reason = `Could not inspect symbols in \"${relPath}\"`;\n }\n }\n\n return {\n id: node.id,\n name,\n type,\n path: relPath,\n symbol,\n depth,\n status,\n fileExists: true,\n symbolFound,\n ...(reason ? { reason } : {}),\n };\n}\n\n/**\n * Finds the starting node in a graph that matches the user's query.\n */\nexport function findMatchingStartNode(nodes: RawGraphNode[], query: string): RawGraphNode | null {\n const q = query.trim().toLowerCase();\n const qNorm = q.replace(/\\\\/g, '/');\n\n // 1. Exact match on ID\n const exactId = nodes.find((n) => n.id.toLowerCase() === q || n.id.toLowerCase().replace(/\\\\/g, '/') === qNorm);\n if (exactId) return exactId;\n\n // 2. Exact match on path or file\n const exactPath = nodes.find((n) => {\n const p = (n.path || n.file || '').toLowerCase().replace(/\\\\/g, '/');\n return p === qNorm;\n });\n if (exactPath) return exactPath;\n\n // 3. Exact match on name or symbol\n const exactName = nodes.find((n) => {\n const name = (n.name || n.label || '').toLowerCase();\n return name === q;\n });\n if (exactName) return exactName;\n\n // 4. Substring match on ID or path\n const subMatch = nodes.find((n) => {\n const id = n.id.toLowerCase().replace(/\\\\/g, '/');\n const p = (n.path || n.file || '').toLowerCase().replace(/\\\\/g, '/');\n return id.includes(qNorm) || p.includes(qNorm);\n });\n if (subMatch) return subMatch;\n\n return null;\n}\n\n/**\n * Performs a bounded graph trace starting from a specified file or symbol node up to maxDepth.\n * Verifies every traversed node against the repository filesystem, marking unverified nodes\n * and edges as hypotheses.\n */\nexport async function traceGraphService(\n o: ServiceOptions,\n query: string,\n options: { depth?: number; maxNodes?: number } = {},\n): Promise<GraphTraceResult> {\n const ws = await requireWorkspace(o.cwd);\n const loaded = await loadGraphData(ws.root);\n\n const depthLimit = Math.min(Math.max(options.depth ?? 2, 1), 10);\n const maxNodes = Math.min(options.maxNodes ?? 150, 500);\n\n if (!loaded.exists || !loaded.data) {\n return {\n available: false,\n query,\n depth: depthLimit,\n matchedNode: null,\n totalNodes: 0,\n verifiedNodes: 0,\n hypothesisNodes: 0,\n nodes: [],\n edges: [],\n warnings: ['No Graphify graph found at graphify-out/graph.json. Run \"/graphify .\" in Claude Code.'],\n };\n }\n\n const { nodes, edges } = loaded.data;\n const startNode = findMatchingStartNode(nodes, query);\n\n if (!startNode) {\n return {\n available: true,\n query,\n depth: depthLimit,\n matchedNode: null,\n totalNodes: 0,\n verifiedNodes: 0,\n hypothesisNodes: 0,\n nodes: [],\n edges: [],\n warnings: [`No graph node found matching \"${query}\". Check node IDs with \"devworkspace graph status\".`],\n };\n }\n\n // Build adjacency index\n const outgoing = new Map<string, RawGraphEdge[]>();\n const incoming = new Map<string, RawGraphEdge[]>();\n\n for (const e of edges) {\n if (!outgoing.has(e.source)) outgoing.set(e.source, []);\n outgoing.get(e.source)!.push(e);\n\n if (!incoming.has(e.target)) incoming.set(e.target, []);\n incoming.get(e.target)!.push(e);\n }\n\n const nodeMap = new Map<string, RawGraphNode>(nodes.map((n) => [n.id, n]));\n\n // Breadth-first search bounded by depthLimit\n const visitedDepths = new Map<string, number>();\n const queue: { id: string; depth: number }[] = [{ id: startNode.id, depth: 0 }];\n visitedDepths.set(startNode.id, 0);\n\n const collectedEdges: RawGraphEdge[] = [];\n\n while (queue.length > 0 && visitedDepths.size < maxNodes) {\n const current = queue.shift()!;\n if (current.depth >= depthLimit) continue;\n\n // Explore outgoing edges\n const outEdges = outgoing.get(current.id) || [];\n for (const edge of outEdges) {\n collectedEdges.push(edge);\n if (!visitedDepths.has(edge.target)) {\n visitedDepths.set(edge.target, current.depth + 1);\n queue.push({ id: edge.target, depth: current.depth + 1 });\n }\n }\n\n // Explore incoming edges\n const inEdges = incoming.get(current.id) || [];\n for (const edge of inEdges) {\n collectedEdges.push(edge);\n if (!visitedDepths.has(edge.source)) {\n visitedDepths.set(edge.source, current.depth + 1);\n queue.push({ id: edge.source, depth: current.depth + 1 });\n }\n }\n }\n\n // Verify all traversed nodes against disk\n const tracedNodes: TracedNode[] = [];\n const nodeStatusMap = new Map<string, NodeVerificationStatus>();\n\n for (const [nodeId, depth] of visitedDepths.entries()) {\n const rawNode = nodeMap.get(nodeId) || { id: nodeId };\n const verified = await verifyNode(ws.root, rawNode, depth);\n tracedNodes.push(verified);\n nodeStatusMap.set(nodeId, verified.status);\n }\n\n // Deduplicate and verify collected edges\n const edgeKeys = new Set<string>();\n const tracedEdges: TracedEdge[] = [];\n\n for (const e of collectedEdges) {\n if (!visitedDepths.has(e.source) || !visitedDepths.has(e.target)) continue;\n const key = `${e.source}->${e.target}::${e.relation || e.type || ''}`;\n if (edgeKeys.has(key)) continue;\n edgeKeys.add(key);\n\n const srcStatus = nodeStatusMap.get(e.source);\n const tgtStatus = nodeStatusMap.get(e.target);\n const edgeStatus: NodeVerificationStatus = srcStatus === 'verified' && tgtStatus === 'verified' ? 'verified' : 'hypothesis';\n\n tracedEdges.push({\n source: e.source,\n target: e.target,\n relation: typeof e.relation === 'string' ? e.relation : typeof e.type === 'string' ? e.type : 'relates_to',\n status: edgeStatus,\n });\n }\n\n // Sort nodes by depth, then by path/name\n tracedNodes.sort((a, b) => a.depth - b.depth || (a.path || a.id).localeCompare(b.path || b.id));\n\n const matched = tracedNodes.find((n) => n.id === startNode.id) || null;\n const verifiedCount = tracedNodes.filter((n) => n.status === 'verified').length;\n const hypothesisCount = tracedNodes.filter((n) => n.status === 'hypothesis').length;\n\n const warnings: string[] = [];\n if (hypothesisCount > 0) {\n warnings.push(`${hypothesisCount} node(s) or connected dependencies are unverified hypotheses (files or symbols missing on disk).`);\n }\n\n return {\n available: true,\n query,\n depth: depthLimit,\n matchedNode: matched,\n totalNodes: tracedNodes.length,\n verifiedNodes: verifiedCount,\n hypothesisNodes: hypothesisCount,\n nodes: tracedNodes,\n edges: tracedEdges,\n warnings,\n };\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/services/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,E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I,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;IACvE,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC;IAChF,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,MAAM,CAAC;IAEpF,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,GAAG,eAAe,kGAAkG,CAAC,CAAC;IACtI,CAAC;IAED,OAAO;QACL,SAAS,EAAE,IAAI;QACf,KAAK;QACL,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,OAAO;QACpB,UAAU,EAAE,WAAW,CAAC,MAAM;QAC9B,aAAa,EAAE,aAAa;QAC5B,eAAe,EAAE,eAAe;QAChC,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,WAAW;QAClB,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { pathExists, readTextBounded } from '../utils/fs.js';\nimport { findSymbolInText } from '../features/validate.js';\nimport { requireWorkspace } from '../core/workspace.js';\nimport type { ServiceOptions } from './common.js';\nimport { DevWorkspaceError } from '../errors/index.js';\n\nexport type NodeVerificationStatus = 'verified' | 'hypothesis';\n\nexport interface RawGraphNode {\n id: string;\n name?: string;\n label?: string;\n type?: string;\n path?: string;\n file?: string;\n [key: string]: unknown;\n}\n\nexport interface RawGraphEdge {\n source: string;\n target: string;\n relation?: string;\n type?: string;\n label?: string;\n weight?: number;\n [key: string]: unknown;\n}\n\nexport interface RawGraphData {\n nodes?: RawGraphNode[];\n edges?: RawGraphEdge[];\n links?: RawGraphEdge[];\n [key: string]: unknown;\n}\n\nexport interface TracedNode {\n id: string;\n name: string;\n type: string;\n path: string | null;\n symbol: string | null;\n depth: number;\n status: NodeVerificationStatus;\n fileExists: boolean;\n symbolFound: boolean | null;\n reason?: string;\n}\n\nexport interface TracedEdge {\n source: string;\n target: string;\n relation: string;\n status: NodeVerificationStatus;\n}\n\nexport interface GraphStatusResult {\n available: boolean;\n graphPath: string;\n nodesCount: number;\n edgesCount: number;\n nodeTypes: Record<string, number>;\n message: string;\n hint?: string;\n}\n\nexport interface GraphTraceResult {\n available: boolean;\n query: string;\n depth: number;\n matchedNode: TracedNode | null;\n totalNodes: number;\n verifiedNodes: number;\n hypothesisNodes: number;\n nodes: TracedNode[];\n edges: TracedEdge[];\n warnings: string[];\n}\n\n/**\n * Resolves the location of Graphify's output graph in the repository.\n */\nexport function getGraphPath(root: string): string {\n return path.join(root, 'graphify-out', 'graph.json');\n}\n\n/**\n * Loads and validates Graphify graph JSON data safely.\n */\nexport async function loadGraphData(root: string): Promise<{ exists: boolean; path: string; data?: { nodes: RawGraphNode[]; edges: RawGraphEdge[] } }> {\n const gPath = getGraphPath(root);\n if (!(await pathExists(gPath))) {\n return { exists: false, path: gPath };\n }\n\n let raw: string;\n try {\n raw = await fs.readFile(gPath, 'utf8');\n } catch (e) {\n throw new DevWorkspaceError('IO', `Failed to read Graphify output at \"${gPath}\": ${(e as Error).message}`, {\n hint: 'Ensure graphify-out/graph.json is readable or regenerate with \"graphify update .\".',\n });\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n throw new DevWorkspaceError('SCHEMA', `Graphify output at \"${gPath}\" is not valid JSON.`, {\n hint: 'Regenerate the graph using \"graphify update .\" or \"/graphify .\" in Claude Code.',\n });\n }\n\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new DevWorkspaceError('SCHEMA', `Graphify output at \"${gPath}\" must be a JSON object with nodes and edges.`, {\n hint: 'Regenerate the graph using \"graphify update .\".',\n });\n }\n\n const obj = parsed as RawGraphData;\n const nodes = Array.isArray(obj.nodes) ? obj.nodes : [];\n const edges = Array.isArray(obj.edges) ? obj.edges : Array.isArray(obj.links) ? obj.links : [];\n\n return {\n exists: true,\n path: gPath,\n data: { nodes, edges },\n };\n}\n\n/**\n * Reports the presence, size, and basic schema health of the Graphify graph.\n */\nexport async function getGraphStatusService(o: ServiceOptions): Promise<GraphStatusResult> {\n const ws = await requireWorkspace(o.cwd);\n const loaded = await loadGraphData(ws.root);\n\n if (!loaded.exists || !loaded.data) {\n return {\n available: false,\n graphPath: loaded.path,\n nodesCount: 0,\n edgesCount: 0,\n nodeTypes: {},\n message: 'No Graphify knowledge graph found at graphify-out/graph.json.',\n hint: 'In Claude Code run \"/graphify .\" to build the graph, or run \"graphify update .\" if already initialized.',\n };\n }\n\n const { nodes, edges } = loaded.data;\n const nodeTypes: Record<string, number> = {};\n for (const n of nodes) {\n const t = n.type || 'unknown';\n nodeTypes[t] = (nodeTypes[t] || 0) + 1;\n }\n\n return {\n available: true,\n graphPath: loaded.path,\n nodesCount: nodes.length,\n edgesCount: edges.length,\n nodeTypes,\n message: `Graphify graph loaded: ${nodes.length} nodes, ${edges.length} edges.`,\n };\n}\n\n/**\n * Extracts a candidate file path and symbol from a node definition.\n */\nexport function extractPathAndSymbol(node: RawGraphNode): { relPath: string | null; symbol: string | null } {\n // If explicitly declared:\n const rawPath = typeof node.path === 'string' ? node.path : typeof node.file === 'string' ? node.file : null;\n let relPath = rawPath ? rawPath.replace(/\\\\/g, '/').replace(/^\\/+/, '') : null;\n let symbol: string | null = null;\n\n if (node.id.includes('::')) {\n const parts = node.id.split('::');\n if (!relPath && parts[0] && (parts[0].includes('/') || parts[0].includes('.'))) {\n relPath = parts[0].replace(/\\\\/g, '/').replace(/^\\/+/, '');\n }\n symbol = parts[1] || null;\n } else if (!relPath && (node.id.includes('/') || node.id.includes('.'))) {\n relPath = node.id.replace(/\\\\/g, '/').replace(/^\\/+/, '');\n }\n\n if (!symbol && typeof node.name === 'string' && node.name !== relPath) {\n symbol = node.name;\n }\n\n return { relPath, symbol };\n}\n\n/**\n * Verifies whether a node's physical path and symbol exist on disk.\n */\nasync function verifyNode(root: string, node: RawGraphNode, depth: number): Promise<TracedNode> {\n const { relPath, symbol } = extractPathAndSymbol(node);\n const name = typeof node.name === 'string' ? node.name : typeof node.label === 'string' ? node.label : node.id;\n const type = typeof node.type === 'string' ? node.type : 'symbol';\n\n if (!relPath) {\n return {\n id: node.id,\n name,\n type,\n path: null,\n symbol,\n depth,\n status: 'hypothesis',\n fileExists: false,\n symbolFound: null,\n reason: 'No source file associated with node',\n };\n }\n\n const fullPath = path.join(root, ...relPath.split('/'));\n const exists = await pathExists(fullPath);\n\n if (!exists) {\n return {\n id: node.id,\n name,\n type,\n path: relPath,\n symbol,\n depth,\n status: 'hypothesis',\n fileExists: false,\n symbolFound: null,\n reason: `File \"${relPath}\" not found on disk`,\n };\n }\n\n let symbolFound: boolean | null = null;\n let status: NodeVerificationStatus = 'verified';\n let reason: string | undefined;\n\n if (symbol) {\n try {\n const text = await readTextBounded(fullPath, 500_000);\n if (text) {\n symbolFound = findSymbolInText(text, symbol);\n if (!symbolFound) {\n status = 'hypothesis';\n reason = `Symbol \"${symbol}\" not found in \"${relPath}\"`;\n }\n }\n } catch {\n status = 'hypothesis';\n reason = `Could not inspect symbols in \"${relPath}\"`;\n }\n }\n\n return {\n id: node.id,\n name,\n type,\n path: relPath,\n symbol,\n depth,\n status,\n fileExists: true,\n symbolFound,\n ...(reason ? { reason } : {}),\n };\n}\n\nconst GRAPH_STOP_WORDS = new Set([\n 'the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'does', 'how',\n 'what', 'where', 'why', 'when', 'which', 'to', 'in', 'of', 'at', 'by', 'on',\n 'as', 'an', 'a', 'or', 'is', 'it', 'be', 'so', 'db'\n]);\n\n/**\n * Finds the starting node in a graph that matches the user's query.\n */\nexport function findMatchingStartNode(nodes: RawGraphNode[], query: string): RawGraphNode | null {\n const q = query.trim().toLowerCase();\n const qNorm = q.replace(/\\\\/g, '/');\n\n if (q.length === 0 || GRAPH_STOP_WORDS.has(q)) return null;\n\n // 1. Exact match on ID\n const exactId = nodes.find((n) => n.id.toLowerCase() === q || n.id.toLowerCase().replace(/\\\\/g, '/') === qNorm);\n if (exactId) return exactId;\n\n // 2. Exact match on path or file\n const exactPath = nodes.find((n) => {\n const p = (n.path || n.file || '').toLowerCase().replace(/\\\\/g, '/');\n return p === qNorm;\n });\n if (exactPath) return exactPath;\n\n // 3. Exact match on name or symbol\n const exactName = nodes.find((n) => {\n const name = (n.name || n.label || '').toLowerCase();\n return name === q;\n });\n if (exactName) return exactName;\n\n // 4. Substring match on ID or path only for meaningful terms of at least 3 characters\n if (q.length >= 3 && !GRAPH_STOP_WORDS.has(qNorm)) {\n const subMatch = nodes.find((n) => {\n const id = n.id.toLowerCase().replace(/\\\\/g, '/');\n const p = (n.path || n.file || '').toLowerCase().replace(/\\\\/g, '/');\n return id.includes(qNorm) || p.includes(qNorm);\n });\n if (subMatch) return subMatch;\n }\n\n return null;\n}\n\n/**\n * Performs a bounded graph trace starting from a specified file or symbol node up to maxDepth.\n * Verifies every traversed node against the repository filesystem, marking unverified nodes\n * and edges as hypotheses.\n */\nexport async function traceGraphService(\n o: ServiceOptions,\n query: string,\n options: { depth?: number; maxNodes?: number } = {},\n): Promise<GraphTraceResult> {\n const ws = await requireWorkspace(o.cwd);\n const loaded = await loadGraphData(ws.root);\n\n const depthLimit = Math.min(Math.max(options.depth ?? 2, 1), 10);\n const maxNodes = Math.min(options.maxNodes ?? 150, 500);\n\n if (!loaded.exists || !loaded.data) {\n return {\n available: false,\n query,\n depth: depthLimit,\n matchedNode: null,\n totalNodes: 0,\n verifiedNodes: 0,\n hypothesisNodes: 0,\n nodes: [],\n edges: [],\n warnings: ['No Graphify graph found at graphify-out/graph.json. Run \"/graphify .\" in Claude Code.'],\n };\n }\n\n const { nodes, edges } = loaded.data;\n const startNode = findMatchingStartNode(nodes, query);\n\n if (!startNode) {\n return {\n available: true,\n query,\n depth: depthLimit,\n matchedNode: null,\n totalNodes: 0,\n verifiedNodes: 0,\n hypothesisNodes: 0,\n nodes: [],\n edges: [],\n warnings: [`No graph node found matching \"${query}\". Check node IDs with \"devworkspace graph status\".`],\n };\n }\n\n // Build adjacency index\n const outgoing = new Map<string, RawGraphEdge[]>();\n const incoming = new Map<string, RawGraphEdge[]>();\n\n for (const e of edges) {\n if (!outgoing.has(e.source)) outgoing.set(e.source, []);\n outgoing.get(e.source)!.push(e);\n\n if (!incoming.has(e.target)) incoming.set(e.target, []);\n incoming.get(e.target)!.push(e);\n }\n\n const nodeMap = new Map<string, RawGraphNode>(nodes.map((n) => [n.id, n]));\n\n // Breadth-first search bounded by depthLimit\n const visitedDepths = new Map<string, number>();\n const queue: { id: string; depth: number }[] = [{ id: startNode.id, depth: 0 }];\n visitedDepths.set(startNode.id, 0);\n\n const collectedEdges: RawGraphEdge[] = [];\n\n while (queue.length > 0 && visitedDepths.size < maxNodes) {\n const current = queue.shift()!;\n if (current.depth >= depthLimit) continue;\n\n // Explore outgoing edges\n const outEdges = outgoing.get(current.id) || [];\n for (const edge of outEdges) {\n collectedEdges.push(edge);\n if (!visitedDepths.has(edge.target)) {\n visitedDepths.set(edge.target, current.depth + 1);\n queue.push({ id: edge.target, depth: current.depth + 1 });\n }\n }\n\n // Explore incoming edges\n const inEdges = incoming.get(current.id) || [];\n for (const edge of inEdges) {\n collectedEdges.push(edge);\n if (!visitedDepths.has(edge.source)) {\n visitedDepths.set(edge.source, current.depth + 1);\n queue.push({ id: edge.source, depth: current.depth + 1 });\n }\n }\n }\n\n // Verify all traversed nodes against disk\n const tracedNodes: TracedNode[] = [];\n const nodeStatusMap = new Map<string, NodeVerificationStatus>();\n\n for (const [nodeId, depth] of visitedDepths.entries()) {\n const rawNode = nodeMap.get(nodeId) || { id: nodeId };\n const verified = await verifyNode(ws.root, rawNode, depth);\n tracedNodes.push(verified);\n nodeStatusMap.set(nodeId, verified.status);\n }\n\n // Deduplicate and verify collected edges\n const edgeKeys = new Set<string>();\n const tracedEdges: TracedEdge[] = [];\n\n for (const e of collectedEdges) {\n if (!visitedDepths.has(e.source) || !visitedDepths.has(e.target)) continue;\n const key = `${e.source}->${e.target}::${e.relation || e.type || ''}`;\n if (edgeKeys.has(key)) continue;\n edgeKeys.add(key);\n\n const srcStatus = nodeStatusMap.get(e.source);\n const tgtStatus = nodeStatusMap.get(e.target);\n const edgeStatus: NodeVerificationStatus = srcStatus === 'verified' && tgtStatus === 'verified' ? 'verified' : 'hypothesis';\n\n tracedEdges.push({\n source: e.source,\n target: e.target,\n relation: typeof e.relation === 'string' ? e.relation : typeof e.type === 'string' ? e.type : 'relates_to',\n status: edgeStatus,\n });\n }\n\n // Sort nodes by depth, then by path/name\n tracedNodes.sort((a, b) => a.depth - b.depth || (a.path || a.id).localeCompare(b.path || b.id));\n\n const matched = tracedNodes.find((n) => n.id === startNode.id) || null;\n const verifiedCount = tracedNodes.filter((n) => n.status === 'verified').length;\n const hypothesisCount = tracedNodes.filter((n) => n.status === 'hypothesis').length;\n\n const warnings: string[] = [];\n if (hypothesisCount > 0) {\n warnings.push(`${hypothesisCount} node(s) or connected dependencies are unverified hypotheses (files or symbols missing on disk).`);\n }\n\n return {\n available: true,\n query,\n depth: depthLimit,\n matchedNode: matched,\n totalNodes: tracedNodes.length,\n verifiedNodes: verifiedCount,\n hypothesisNodes: hypothesisCount,\n nodes: tracedNodes,\n edges: tracedEdges,\n warnings,\n };\n}\n\n"]}
|
package/dist/services/init.js
CHANGED
|
@@ -67,7 +67,11 @@ export async function initWorkspace(o) {
|
|
|
67
67
|
gitignoreUpdated: false,
|
|
68
68
|
notes,
|
|
69
69
|
integrations: [],
|
|
70
|
-
nextSteps: [
|
|
70
|
+
nextSteps: [
|
|
71
|
+
'Run: devworkspace analyze',
|
|
72
|
+
'Connect an AI coding agent via MCP: run "devworkspace setup --agent claude-code" (or codex, antigravity, all)',
|
|
73
|
+
'Then paste .devworkspace/analysis/onboarding-prompt.md into Claude Code',
|
|
74
|
+
],
|
|
71
75
|
...extra,
|
|
72
76
|
});
|
|
73
77
|
const shallow = async () => inspectAll(ws, managerEnv(o, root), { deep: false });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/services/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAsB,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA4C,MAAM,0BAA0B,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAW,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAuBtE,KAAK,UAAU,WAAW,CAAC,CAAc,EAAE,KAAe;IACxD,IAAI,CAAC,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IA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} from 'node:fs';\nimport path from 'node:path';\nimport { SCHEMA_VERSION, validateProject, type ProjectConfig } from '../config/schemas.js';\nimport { DevWorkspaceError } from '../errors/index.js';\nimport { gitTopLevel } from '../git/git.js';\nimport { inspectAll, runSetup, type IntegrationReport, type SetupResult } from '../integrations/index.js';\nimport { atomicWriteFile, atomicWriteJson, ensureDir, pathExists } from '../utils/fs.js';\nimport { findWorkspaceRoot, LOCAL_GITIGNORE, loadProject, wsPaths, WORKSPACE_DIR, type Ws } from '../core/workspace.js';\nimport { packageVersion } from '../core/version.js';\nimport { withLock } from '../utils/lock.js';\nimport { readPackageJson } from '../discovery/detect.js';\nimport { newProjectId } from './analysis.js';\nimport { isoNow, managerEnv, type ServiceOptions } from './common.js';\n\nexport interface InitOptions extends ServiceOptions {\n /** Explicit project root; defaults to the Git top-level or the current directory. */\n root?: string;\n /** Also run the integration manager (same code path as `devworkspace setup --integrations`). */\n withIntegrations?: { yes: boolean; scope: 'project' | 'user' };\n}\n\nexport interface InitResult {\n root: string;\n dryRun: boolean;\n alreadyInitialized: boolean;\n created: string[];\n unchanged: string[];\n gitignoreUpdated: boolean;\n notes: string[];\n integrations: IntegrationReport[];\n /** Present when withIntegrations was requested. */\n setup?: SetupResult;\n nextSteps: string[];\n}\n\nasync function resolveRoot(o: InitOptions, notes: string[]): Promise<string> {\n if (o.root) return path.resolve(o.cwd, o.root);\n const existing = await findWorkspaceRoot(o.cwd);\n if (existing) {\n if (path.resolve(existing) !== path.resolve(o.cwd)) notes.push(`Using the existing workspace root (${path.relative(o.cwd, existing) || '.'}).`);\n return existing;\n }\n const top = await gitTopLevel(o.cwd);\n if (top && path.resolve(top).toLowerCase() !== path.resolve(o.cwd).toLowerCase()) {\n notes.push('Current directory is inside a Git repository; using the repository root. Pass --root to choose a different directory.');\n return path.resolve(top);\n }\n return path.resolve(o.cwd);\n}\n\n/** Make sure each required line is present in .devworkspace/.gitignore without removing anything the user added. */\nasync function ensureGitignore(ws: Ws): Promise<'created' | 'updated' | 'unchanged'> {\n if (!(await pathExists(ws.gitignore))) {\n await atomicWriteFile(ws.gitignore, LOCAL_GITIGNORE);\n return 'created';\n }\n const text = await fs.readFile(ws.gitignore, 'utf8');\n const have = new Set(text.split(/\\r?\\n/).map((l) => l.trim()));\n const missing = LOCAL_GITIGNORE.split('\\n').filter((l) => l && !l.startsWith('#') && !have.has(l));\n if (missing.length === 0) return 'unchanged';\n const eol = text.includes('\\r\\n') ? '\\r\\n' : '\\n';\n await atomicWriteFile(ws.gitignore, text + (text.endsWith('\\n') ? '' : eol) + missing.join(eol) + eol);\n return 'updated';\n}\n\nexport async function initWorkspace(o: InitOptions): Promise<InitResult> {\n const notes: string[] = [];\n const root = await resolveRoot(o, notes);\n const st = await fs.stat(root).catch(() => null);\n if (!st?.isDirectory()) {\n throw new DevWorkspaceError('NOT_FOUND', `Project root does not exist: ${root}`, { hint: 'Run the command inside your project, or pass --root <dir>.' });\n }\n const ws = wsPaths(root);\n const created: string[] = [];\n const unchanged: string[] = [];\n const rel = (p: string): string => path.relative(root, p).replace(/\\\\/g, '/');\n const alreadyInitialized = await pathExists(ws.projectJson);\n\n const dirs = [ws.contextDir, ws.decisionsDir, ws.tasksActive, ws.tasksCompleted, ws.sessionsDir, ws.analysisDir, ws.stateDir];\n const pkg = (await pathExists(path.join(root, 'package.json'))) ? await readPackageJson(root, 'package.json').catch(() => null) : null;\n const name = pkg?.name ?? path.basename(root);\n const now = isoNow(o);\n\n\n const result = (extra: Partial<InitResult>): InitResult => ({\n root,\n dryRun: !!o.dryRun,\n alreadyInitialized,\n created,\n unchanged,\n gitignoreUpdated: false,\n notes,\n integrations: [],\n nextSteps: ['Run: devworkspace analyze', 'Then paste .devworkspace/analysis/onboarding-prompt.md into Claude Code'],\n ...extra,\n });\n const shallow = async (): Promise<IntegrationReport[]> => inspectAll(ws, managerEnv(o, root), { deep: false });\n\n if (o.dryRun) {\n for (const d of dirs) if (!(await pathExists(d))) created.push(rel(d) + '/');\n if (!alreadyInitialized) created.push(rel(ws.projectJson));\n if (!(await pathExists(ws.gitignore))) created.push(rel(ws.gitignore));\n return result({ integrations: await shallow() });\n }\n\n await ensureDir(ws.dir);\n return withLock(ws.dir, async () => {\n for (const d of dirs) {\n if (await pathExists(d)) unchanged.push(rel(d) + '/');\n else {\n await ensureDir(d);\n created.push(rel(d) + '/');\n }\n }\n // Empty directories do not survive Git, so keep portable folders alive.\n for (const d of [ws.decisionsDir, ws.tasksActive, ws.tasksCompleted, ws.sessionsDir]) {\n const keep = path.join(d, '.gitkeep');\n if (!(await pathExists(keep))) await fs.writeFile(keep, '');\n }\n\n let project: ProjectConfig;\n if (alreadyInitialized) {\n project = await loadProject(ws);\n unchanged.push(rel(ws.projectJson));\n if (project.devworkspaceVersion !== packageVersion()) {\n project = { ...project, devworkspaceVersion: packageVersion(), updatedAt: now };\n await atomicWriteJson(ws.projectJson, validateProject(project));\n notes.push(`Recorded DevWorkspace ${packageVersion()} in project.json.`);\n }\n } else {\n project = {\n schemaVersion: SCHEMA_VERSION,\n projectId: newProjectId(),\n name,\n createdAt: now,\n updatedAt: now,\n devworkspaceVersion: packageVersion(),\n settings: { review: 'light', maxFiles: 50_000 },\n managedFiles: [{ path: `${WORKSPACE_DIR}/.gitignore`, mode: 'owned' }],\n };\n await atomicWriteJson(ws.projectJson, validateProject(project));\n created.push(rel(ws.projectJson));\n }\n\n const gi = await ensureGitignore(ws);\n if (gi === 'created') created.push(rel(ws.gitignore));\n else if (gi === 'updated') notes.push('Added missing ignore rules to .devworkspace/.gitignore.');\n else unchanged.push(rel(ws.gitignore));\n\n let setup: SetupResult | undefined;\n if (o.withIntegrations) {\n setup = await runSetup(ws, managerEnv(o, root), { scope: o.withIntegrations.scope, yes: o.withIntegrations.yes, dryRun: false, repair: false });\n }\n return result({ gitignoreUpdated: gi === 'updated', integrations: setup ? setup.outcomes.map((x) => x.report) : await shallow(), ...(setup ? { setup } : {}) });\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"init.js","source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C,CAAC;QACrC,IAAI,EAAE,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;aACjD,IAAI,EAAE,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;;YAC5F,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QAEvC,IAAI,KAA8B,CAAC;QACnC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;YACvB,KAAK,GAAG,MAAM,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAClJ,CAAC;QACD,OAAO,MAAM,CAAC,EAAE,gBAAgB,EAAE,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClK,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { SCHEMA_VERSION, validateProject, type ProjectConfig } from '../config/schemas.js';\nimport { DevWorkspaceError } from '../errors/index.js';\nimport { gitTopLevel } from '../git/git.js';\nimport { inspectAll, runSetup, type IntegrationReport, type SetupResult } from '../integrations/index.js';\nimport { atomicWriteFile, atomicWriteJson, ensureDir, pathExists } from '../utils/fs.js';\nimport { findWorkspaceRoot, LOCAL_GITIGNORE, loadProject, wsPaths, WORKSPACE_DIR, type Ws } from '../core/workspace.js';\nimport { packageVersion } from '../core/version.js';\nimport { withLock } from '../utils/lock.js';\nimport { readPackageJson } from '../discovery/detect.js';\nimport { newProjectId } from './analysis.js';\nimport { isoNow, managerEnv, type ServiceOptions } from './common.js';\n\nexport interface InitOptions extends ServiceOptions {\n /** Explicit project root; defaults to the Git top-level or the current directory. */\n root?: string;\n /** Also run the integration manager (same code path as `devworkspace setup --integrations`). */\n withIntegrations?: { yes: boolean; scope: 'project' | 'user' };\n}\n\nexport interface InitResult {\n root: string;\n dryRun: boolean;\n alreadyInitialized: boolean;\n created: string[];\n unchanged: string[];\n gitignoreUpdated: boolean;\n notes: string[];\n integrations: IntegrationReport[];\n /** Present when withIntegrations was requested. */\n setup?: SetupResult;\n nextSteps: string[];\n}\n\nasync function resolveRoot(o: InitOptions, notes: string[]): Promise<string> {\n if (o.root) return path.resolve(o.cwd, o.root);\n const existing = await findWorkspaceRoot(o.cwd);\n if (existing) {\n if (path.resolve(existing) !== path.resolve(o.cwd)) notes.push(`Using the existing workspace root (${path.relative(o.cwd, existing) || '.'}).`);\n return existing;\n }\n const top = await gitTopLevel(o.cwd);\n if (top && path.resolve(top).toLowerCase() !== path.resolve(o.cwd).toLowerCase()) {\n notes.push('Current directory is inside a Git repository; using the repository root. Pass --root to choose a different directory.');\n return path.resolve(top);\n }\n return path.resolve(o.cwd);\n}\n\n/** Make sure each required line is present in .devworkspace/.gitignore without removing anything the user added. */\nasync function ensureGitignore(ws: Ws): Promise<'created' | 'updated' | 'unchanged'> {\n if (!(await pathExists(ws.gitignore))) {\n await atomicWriteFile(ws.gitignore, LOCAL_GITIGNORE);\n return 'created';\n }\n const text = await fs.readFile(ws.gitignore, 'utf8');\n const have = new Set(text.split(/\\r?\\n/).map((l) => l.trim()));\n const missing = LOCAL_GITIGNORE.split('\\n').filter((l) => l && !l.startsWith('#') && !have.has(l));\n if (missing.length === 0) return 'unchanged';\n const eol = text.includes('\\r\\n') ? '\\r\\n' : '\\n';\n await atomicWriteFile(ws.gitignore, text + (text.endsWith('\\n') ? '' : eol) + missing.join(eol) + eol);\n return 'updated';\n}\n\nexport async function initWorkspace(o: InitOptions): Promise<InitResult> {\n const notes: string[] = [];\n const root = await resolveRoot(o, notes);\n const st = await fs.stat(root).catch(() => null);\n if (!st?.isDirectory()) {\n throw new DevWorkspaceError('NOT_FOUND', `Project root does not exist: ${root}`, { hint: 'Run the command inside your project, or pass --root <dir>.' });\n }\n const ws = wsPaths(root);\n const created: string[] = [];\n const unchanged: string[] = [];\n const rel = (p: string): string => path.relative(root, p).replace(/\\\\/g, '/');\n const alreadyInitialized = await pathExists(ws.projectJson);\n\n const dirs = [ws.contextDir, ws.decisionsDir, ws.tasksActive, ws.tasksCompleted, ws.sessionsDir, ws.analysisDir, ws.stateDir];\n const pkg = (await pathExists(path.join(root, 'package.json'))) ? await readPackageJson(root, 'package.json').catch(() => null) : null;\n const name = pkg?.name ?? path.basename(root);\n const now = isoNow(o);\n\n\n const result = (extra: Partial<InitResult>): InitResult => ({\n root,\n dryRun: !!o.dryRun,\n alreadyInitialized,\n created,\n unchanged,\n gitignoreUpdated: false,\n notes,\n integrations: [],\n nextSteps: [\n 'Run: devworkspace analyze',\n 'Connect an AI coding agent via MCP: run \"devworkspace setup --agent claude-code\" (or codex, antigravity, all)',\n 'Then paste .devworkspace/analysis/onboarding-prompt.md into Claude Code',\n ],\n ...extra,\n });\n const shallow = async (): Promise<IntegrationReport[]> => inspectAll(ws, managerEnv(o, root), { deep: false });\n\n if (o.dryRun) {\n for (const d of dirs) if (!(await pathExists(d))) created.push(rel(d) + '/');\n if (!alreadyInitialized) created.push(rel(ws.projectJson));\n if (!(await pathExists(ws.gitignore))) created.push(rel(ws.gitignore));\n return result({ integrations: await shallow() });\n }\n\n await ensureDir(ws.dir);\n return withLock(ws.dir, async () => {\n for (const d of dirs) {\n if (await pathExists(d)) unchanged.push(rel(d) + '/');\n else {\n await ensureDir(d);\n created.push(rel(d) + '/');\n }\n }\n // Empty directories do not survive Git, so keep portable folders alive.\n for (const d of [ws.decisionsDir, ws.tasksActive, ws.tasksCompleted, ws.sessionsDir]) {\n const keep = path.join(d, '.gitkeep');\n if (!(await pathExists(keep))) await fs.writeFile(keep, '');\n }\n\n let project: ProjectConfig;\n if (alreadyInitialized) {\n project = await loadProject(ws);\n unchanged.push(rel(ws.projectJson));\n if (project.devworkspaceVersion !== packageVersion()) {\n project = { ...project, devworkspaceVersion: packageVersion(), updatedAt: now };\n await atomicWriteJson(ws.projectJson, validateProject(project));\n notes.push(`Recorded DevWorkspace ${packageVersion()} in project.json.`);\n }\n } else {\n project = {\n schemaVersion: SCHEMA_VERSION,\n projectId: newProjectId(),\n name,\n createdAt: now,\n updatedAt: now,\n devworkspaceVersion: packageVersion(),\n settings: { review: 'light', maxFiles: 50_000 },\n managedFiles: [{ path: `${WORKSPACE_DIR}/.gitignore`, mode: 'owned' }],\n };\n await atomicWriteJson(ws.projectJson, validateProject(project));\n created.push(rel(ws.projectJson));\n }\n\n const gi = await ensureGitignore(ws);\n if (gi === 'created') created.push(rel(ws.gitignore));\n else if (gi === 'updated') notes.push('Added missing ignore rules to .devworkspace/.gitignore.');\n else unchanged.push(rel(ws.gitignore));\n\n let setup: SetupResult | undefined;\n if (o.withIntegrations) {\n setup = await runSetup(ws, managerEnv(o, root), { scope: o.withIntegrations.scope, yes: o.withIntegrations.yes, dryRun: false, repair: false });\n }\n return result({ gitignoreUpdated: gi === 'updated', integrations: setup ? setup.outcomes.map((x) => x.report) : await shallow(), ...(setup ? { setup } : {}) });\n });\n}\n"]}
|
package/dist/services/setup.js
CHANGED
|
@@ -79,6 +79,7 @@ export async function setupProject(o) {
|
|
|
79
79
|
if (missingRequired.length > 0) {
|
|
80
80
|
nextSteps.push(`Optional integrations: run "devworkspace setup --integrations --yes" to install ${missingRequired.map((m) => m.name).join(', ')}.`);
|
|
81
81
|
}
|
|
82
|
+
nextSteps.push('Connect an AI coding agent via MCP: run "devworkspace setup --agent claude-code" (or codex, antigravity, all).');
|
|
82
83
|
nextSteps.push('Check overall workspace health: run "devworkspace status".');
|
|
83
84
|
nextSteps.push('Start your first engineering task: run "devworkspace task new <request>".');
|
|
84
85
|
const project = await loadProject(ws);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/services/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAW7D,MAAM,UAAU,mBAAmB;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE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AAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACzD,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,cAAc,EAAE,CAAC,CAAC,cAAc;SACjC,CAAC,CAAC;QACH,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5D,YAAY,EAAE;YACZ,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM;YACzC,SAAS,EAAE,eAAe,CAAC,MAAM;YACjC,MAAM,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,KAAK,EAAE,WAAW,CAAC,MAAM;SAC1B;QACD,QAAQ,EAAE,eAAe;QACzB,YAAY;QACZ,MAAM,EAAE;YACN,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI;YAChC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI;YAClC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI;SACnC;QACD,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport { packageVersion } from '../core/version.js';\nimport { findWorkspaceRoot, loadProject, wsPaths } from '../core/workspace.js';\nimport { detectContractDrift } from '../discovery/commands.js';\nimport { inspectAll } from '../integrations/index.js';\nimport { pathExists } from '../utils/fs.js';\nimport { analyzeWorkspace } from './analysis.js';\nimport { managerEnv, type ServiceOptions } from './common.js';\nimport { runDoctor } from './doctor.js';\nimport { loadFeatures } from './features.js';\nimport { initWorkspace } from './init.js';\nimport { validateFeatureMap } from '../features/validate.js';\nimport type { ContractDriftItem } from '../discovery/commands.js';\n\nexport type CliExecutionMode = 'source-checkout' | 'installed-package' | 'npx-cache';\n\nexport interface CliProvenance {\n version: string;\n path: string;\n mode: CliExecutionMode;\n}\n\nexport function detectCliProvenance(): CliProvenance {\n const cliPath = process.argv[1] ? path.resolve(process.argv[1]) : 'unknown';\n const norm = cliPath.replace(/\\\\/g, '/');\n let mode: CliExecutionMode = 'installed-package';\n if (norm.includes('/_npx/') || norm.includes('\\\\_npx\\\\')) {\n mode = 'npx-cache';\n } else if (norm.includes('/devworkspace/dist/') || norm.endsWith('/dist/cli/main.js') || norm.endsWith('/src/cli/main.ts')) {\n mode = 'source-checkout';\n }\n return { version: packageVersion(), path: cliPath, mode };\n}\n\nexport interface ProjectSetupResult {\n root: string;\n os: string;\n nodeVersion: string;\n cli: CliProvenance;\n initialized: boolean;\n isFirstRun: boolean;\n projectName: string;\n packages: { path: string; ecosystem: string; packageManager?: string }[];\n frameworks: string[];\n verification: {\n total: number;\n available: number;\n checks: string[];\n drift: ContractDriftItem[];\n };\n features: {\n present: boolean;\n total: number;\n verified: number;\n unknown: number;\n } | null;\n integrations: {\n id: string;\n name: string;\n status: string;\n required: boolean;\n }[];\n doctor: {\n healthy: boolean;\n passed: number;\n warnings: number;\n failures: number;\n };\n nextSteps: string[];\n}\n\n/**\n * Single-command setup workflow.\n * Idempotently inspects repository, initializes or safely updates .devworkspace/,\n * discovers packages & commands, checks for drift, validates feature map if present,\n * observes optional integrations, and runs safe diagnostics.\n */\nexport async function setupProject(o: ServiceOptions): Promise<ProjectSetupResult> {\n const startDir = o.cwd ? path.resolve(o.cwd) : process.cwd();\n const existingRoot = await findWorkspaceRoot(startDir);\n const root = existingRoot ?? startDir;\n const isFirstRun = !existingRoot;\n const cli = detectCliProvenance();\n\n // 1. Initialize workspace non-destructively\n await initWorkspace({ ...o, cwd: root, root });\n\n // 2. Discover packages, commands, frameworks, entrypoints, and derive detector facts\n const ws = wsPaths(root);\n const analysis = await analyzeWorkspace(ws, { ...o, cwd: root });\n\n // 3. Inspect configured verification commands and detect contract drift\n const driftReport = await detectContractDrift(ws.root, analysis.discovery.commands);\n const availableChecks = analysis.discovery.commands.filter((c) => c.available);\n\n // 4. Validate feature map if present\n let featuresSummary: ProjectSetupResult['features'] = null;\n if (await pathExists(ws.features)) {\n try {\n const f = await loadFeatures(ws);\n const rep = await validateFeatureMap(ws.root, f.features);\n featuresSummary = {\n present: true,\n total: rep.total,\n verified: rep.verified,\n unknown: rep.unknown,\n };\n } catch {\n featuresSummary = { present: true, total: 0, verified: 0, unknown: 0 };\n }\n }\n\n // 5. Shallowly observe optional integrations (Graphify, Agent Skills, Ponytail, OmniRoute)\n const integrationsReports = await inspectAll(ws, managerEnv(o, root), { deep: false });\n const integrations = integrationsReports.map((r) => ({\n id: r.id,\n name: r.name,\n status: r.status,\n required: r.required,\n }));\n\n // 6. Run doctor diagnostics\n const doctorResult = await runDoctor({ ...o, cwd: root });\n\n // 7. Compile next steps\n const nextSteps: string[] = [];\n if (driftReport.hasDrift) {\n nextSteps.push('Review verification contract drift: run \"devworkspace refresh\" or edit .devworkspace/context/commands.json.');\n }\n const missingRequired = integrationsReports.filter((r) => r.required && r.status === 'NOT_INSTALLED');\n if (missingRequired.length > 0) {\n nextSteps.push(`Optional integrations: run \"devworkspace setup --integrations --yes\" to install ${missingRequired.map((m) => m.name).join(', ')}.`);\n }\n nextSteps.push('Check overall workspace health: run \"devworkspace status\".');\n nextSteps.push('Start your first engineering task: run \"devworkspace task new <request>\".');\n\n const project = await loadProject(ws);\n\n return {\n root,\n os: `${os.type()} ${os.release()} (${process.platform})`,\n nodeVersion: process.versions.node,\n cli,\n initialized: true,\n isFirstRun,\n projectName: project.name,\n packages: analysis.discovery.monorepo.packages.map((p) => ({\n path: p.path,\n ecosystem: p.ecosystem,\n packageManager: p.packageManager,\n })),\n frameworks: analysis.discovery.frameworks.map((f) => f.name),\n verification: {\n total: analysis.discovery.commands.length,\n available: availableChecks.length,\n checks: [...new Set(availableChecks.map((c) => c.id))],\n drift: driftReport.issues,\n },\n features: featuresSummary,\n integrations,\n doctor: {\n healthy: doctorResult.healthy,\n passed: doctorResult.counts.pass,\n warnings: doctorResult.counts.warn,\n failures: doctorResult.counts.fail,\n },\n nextSteps,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/services/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAW7D,MAAM,UAAU,mBAAmB;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACzC,IAAI,IAAI,GAAqB,mBAAmB,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C,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACzD,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,cAAc,EAAE,CAAC,CAAC,cAAc;SACjC,CAAC,CAAC;QACH,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5D,YAAY,EAAE;YACZ,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM;YACzC,SAAS,EAAE,eAAe,CAAC,MAAM;YACjC,MAAM,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACtD,KAAK,EAAE,WAAW,CAAC,MAAM;SAC1B;QACD,QAAQ,EAAE,eAAe;QACzB,YAAY;QACZ,MAAM,EAAE;YACN,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI;YAChC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI;YAClC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI;SACnC;QACD,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport { packageVersion } from '../core/version.js';\nimport { findWorkspaceRoot, loadProject, wsPaths } from '../core/workspace.js';\nimport { detectContractDrift } from '../discovery/commands.js';\nimport { inspectAll } from '../integrations/index.js';\nimport { pathExists } from '../utils/fs.js';\nimport { analyzeWorkspace } from './analysis.js';\nimport { managerEnv, type ServiceOptions } from './common.js';\nimport { runDoctor } from './doctor.js';\nimport { loadFeatures } from './features.js';\nimport { initWorkspace } from './init.js';\nimport { validateFeatureMap } from '../features/validate.js';\nimport type { ContractDriftItem } from '../discovery/commands.js';\n\nexport type CliExecutionMode = 'source-checkout' | 'installed-package' | 'npx-cache';\n\nexport interface CliProvenance {\n version: string;\n path: string;\n mode: CliExecutionMode;\n}\n\nexport function detectCliProvenance(): CliProvenance {\n const cliPath = process.argv[1] ? path.resolve(process.argv[1]) : 'unknown';\n const norm = cliPath.replace(/\\\\/g, '/');\n let mode: CliExecutionMode = 'installed-package';\n if (norm.includes('/_npx/') || norm.includes('\\\\_npx\\\\')) {\n mode = 'npx-cache';\n } else if (norm.includes('/devworkspace/dist/') || norm.endsWith('/dist/cli/main.js') || norm.endsWith('/src/cli/main.ts')) {\n mode = 'source-checkout';\n }\n return { version: packageVersion(), path: cliPath, mode };\n}\n\nexport interface ProjectSetupResult {\n root: string;\n os: string;\n nodeVersion: string;\n cli: CliProvenance;\n initialized: boolean;\n isFirstRun: boolean;\n projectName: string;\n packages: { path: string; ecosystem: string; packageManager?: string }[];\n frameworks: string[];\n verification: {\n total: number;\n available: number;\n checks: string[];\n drift: ContractDriftItem[];\n };\n features: {\n present: boolean;\n total: number;\n verified: number;\n unknown: number;\n } | null;\n integrations: {\n id: string;\n name: string;\n status: string;\n required: boolean;\n }[];\n doctor: {\n healthy: boolean;\n passed: number;\n warnings: number;\n failures: number;\n };\n nextSteps: string[];\n}\n\n/**\n * Single-command setup workflow.\n * Idempotently inspects repository, initializes or safely updates .devworkspace/,\n * discovers packages & commands, checks for drift, validates feature map if present,\n * observes optional integrations, and runs safe diagnostics.\n */\nexport async function setupProject(o: ServiceOptions): Promise<ProjectSetupResult> {\n const startDir = o.cwd ? path.resolve(o.cwd) : process.cwd();\n const existingRoot = await findWorkspaceRoot(startDir);\n const root = existingRoot ?? startDir;\n const isFirstRun = !existingRoot;\n const cli = detectCliProvenance();\n\n // 1. Initialize workspace non-destructively\n await initWorkspace({ ...o, cwd: root, root });\n\n // 2. Discover packages, commands, frameworks, entrypoints, and derive detector facts\n const ws = wsPaths(root);\n const analysis = await analyzeWorkspace(ws, { ...o, cwd: root });\n\n // 3. Inspect configured verification commands and detect contract drift\n const driftReport = await detectContractDrift(ws.root, analysis.discovery.commands);\n const availableChecks = analysis.discovery.commands.filter((c) => c.available);\n\n // 4. Validate feature map if present\n let featuresSummary: ProjectSetupResult['features'] = null;\n if (await pathExists(ws.features)) {\n try {\n const f = await loadFeatures(ws);\n const rep = await validateFeatureMap(ws.root, f.features);\n featuresSummary = {\n present: true,\n total: rep.total,\n verified: rep.verified,\n unknown: rep.unknown,\n };\n } catch {\n featuresSummary = { present: true, total: 0, verified: 0, unknown: 0 };\n }\n }\n\n // 5. Shallowly observe optional integrations (Graphify, Agent Skills, Ponytail, OmniRoute)\n const integrationsReports = await inspectAll(ws, managerEnv(o, root), { deep: false });\n const integrations = integrationsReports.map((r) => ({\n id: r.id,\n name: r.name,\n status: r.status,\n required: r.required,\n }));\n\n // 6. Run doctor diagnostics\n const doctorResult = await runDoctor({ ...o, cwd: root });\n\n // 7. Compile next steps\n const nextSteps: string[] = [];\n if (driftReport.hasDrift) {\n nextSteps.push('Review verification contract drift: run \"devworkspace refresh\" or edit .devworkspace/context/commands.json.');\n }\n const missingRequired = integrationsReports.filter((r) => r.required && r.status === 'NOT_INSTALLED');\n if (missingRequired.length > 0) {\n nextSteps.push(`Optional integrations: run \"devworkspace setup --integrations --yes\" to install ${missingRequired.map((m) => m.name).join(', ')}.`);\n }\n nextSteps.push('Connect an AI coding agent via MCP: run \"devworkspace setup --agent claude-code\" (or codex, antigravity, all).');\n nextSteps.push('Check overall workspace health: run \"devworkspace status\".');\n nextSteps.push('Start your first engineering task: run \"devworkspace task new <request>\".');\n\n const project = await loadProject(ws);\n\n return {\n root,\n os: `${os.type()} ${os.release()} (${process.platform})`,\n nodeVersion: process.versions.node,\n cli,\n initialized: true,\n isFirstRun,\n projectName: project.name,\n packages: analysis.discovery.monorepo.packages.map((p) => ({\n path: p.path,\n ecosystem: p.ecosystem,\n packageManager: p.packageManager,\n })),\n frameworks: analysis.discovery.frameworks.map((f) => f.name),\n verification: {\n total: analysis.discovery.commands.length,\n available: availableChecks.length,\n checks: [...new Set(availableChecks.map((c) => c.id))],\n drift: driftReport.issues,\n },\n features: featuresSummary,\n integrations,\n doctor: {\n healthy: doctorResult.healthy,\n passed: doctorResult.counts.pass,\n warnings: doctorResult.counts.warn,\n failures: doctorResult.counts.fail,\n },\n nextSteps,\n };\n}\n"]}
|