devworkspace 0.2.0 → 0.2.2

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +4 -3
  3. package/dist/agents/claude/content.js +3 -2
  4. package/dist/agents/claude/content.js.map +1 -1
  5. package/dist/cli/args.d.ts +16 -0
  6. package/dist/cli/args.js +5 -0
  7. package/dist/cli/args.js.map +1 -1
  8. package/dist/cli/help.js +30 -7
  9. package/dist/cli/help.js.map +1 -1
  10. package/dist/cli/render.d.ts +7 -1
  11. package/dist/cli/render.js +70 -13
  12. package/dist/cli/render.js.map +1 -1
  13. package/dist/cli/run.js +47 -8
  14. package/dist/cli/run.js.map +1 -1
  15. package/dist/config/schemas.d.ts +12 -1
  16. package/dist/config/schemas.js +12 -0
  17. package/dist/config/schemas.js.map +1 -1
  18. package/dist/discovery/commands.d.ts +34 -3
  19. package/dist/discovery/commands.js +109 -33
  20. package/dist/discovery/commands.js.map +1 -1
  21. package/dist/discovery/detect.d.ts +23 -0
  22. package/dist/discovery/detect.js +113 -48
  23. package/dist/discovery/detect.js.map +1 -1
  24. package/dist/discovery/docs.d.ts +10 -0
  25. package/dist/discovery/docs.js +52 -0
  26. package/dist/discovery/docs.js.map +1 -0
  27. package/dist/discovery/entrypoints.d.ts +20 -0
  28. package/dist/discovery/entrypoints.js +67 -0
  29. package/dist/discovery/entrypoints.js.map +1 -0
  30. package/dist/integrations/adapters/graphify.js +46 -8
  31. package/dist/integrations/adapters/graphify.js.map +1 -1
  32. package/dist/integrations/manager.js +14 -1
  33. package/dist/integrations/manager.js.map +1 -1
  34. package/dist/integrations/persistentPath.d.ts +20 -0
  35. package/dist/integrations/persistentPath.js +47 -0
  36. package/dist/integrations/persistentPath.js.map +1 -0
  37. package/dist/integrations/types.d.ts +6 -0
  38. package/dist/integrations/types.js.map +1 -1
  39. package/dist/knowledge/facts.d.ts +59 -2
  40. package/dist/knowledge/facts.js +115 -17
  41. package/dist/knowledge/facts.js.map +1 -1
  42. package/dist/prompts/onboarding.js +9 -6
  43. package/dist/prompts/onboarding.js.map +1 -1
  44. package/dist/services/analysis.d.ts +13 -1
  45. package/dist/services/analysis.js +23 -18
  46. package/dist/services/analysis.js.map +1 -1
  47. package/dist/services/doctor.js +92 -7
  48. package/dist/services/doctor.js.map +1 -1
  49. package/dist/services/knowledge.d.ts +17 -0
  50. package/dist/services/knowledge.js +28 -2
  51. package/dist/services/knowledge.js.map +1 -1
  52. package/dist/services/refresh.js +6 -6
  53. package/dist/services/refresh.js.map +1 -1
  54. package/dist/services/status.d.ts +12 -2
  55. package/dist/services/status.js +11 -9
  56. package/dist/services/status.js.map +1 -1
  57. package/dist/services/tasks.d.ts +2 -0
  58. package/dist/services/tasks.js +20 -12
  59. package/dist/services/tasks.js.map +1 -1
  60. package/dist/services/verify.d.ts +47 -0
  61. package/dist/services/verify.js +172 -0
  62. package/dist/services/verify.js.map +1 -0
  63. package/dist/tasks/routing.js +8 -3
  64. package/dist/tasks/routing.js.map +1 -1
  65. package/dist/tasks/task.d.ts +49 -5
  66. package/dist/tasks/task.js +68 -11
  67. package/dist/tasks/task.js.map +1 -1
  68. package/dist/verification/safety.d.ts +38 -0
  69. package/dist/verification/safety.js +120 -0
  70. package/dist/verification/safety.js.map +1 -0
  71. package/dist/verification/scope.d.ts +19 -0
  72. package/dist/verification/scope.js +119 -0
  73. package/dist/verification/scope.js.map +1 -0
  74. package/docs/integrations.md +1 -1
  75. package/docs/knowledge.md +2 -0
  76. package/docs/testing.md +29 -2
  77. package/docs/troubleshooting.md +4 -1
  78. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/tasks/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EA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CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACrF,IAAI,CAAC;gBACH,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACrG,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,KAAK,EAAG,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { DevWorkspaceError } from '../errors/index.js';\nimport { Check } from '../config/validate.js';\nimport { SCHEMA_VERSION, type CommandEntry } from '../config/schemas.js';\nimport { atomicWriteJson, ensureDir, pathExists, randomId } from '../utils/fs.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { backupIfVersionChanges, type Ws } from '../core/workspace.js';\nimport { containsSecret } from '../security/redact.js';\n\nexport const TASK_TYPES = [\n 'QUESTION',\n 'BUG',\n 'FEATURE',\n 'REFACTOR',\n 'DOCUMENTATION',\n 'TESTING',\n 'PERFORMANCE',\n 'SECURITY',\n 'ARCHITECTURE',\n 'RELEASE',\n 'MAINTENANCE',\n] as const;\nexport type TaskType = (typeof TASK_TYPES)[number];\n\nexport const TASK_STATUSES = ['IDEA', 'SPECIFIED', 'PLANNED', 'IN_PROGRESS', 'TESTING', 'REVIEW', 'BLOCKED', 'FAILED', 'COMPLETED'] as const;\nexport type TaskStatus = (typeof TASK_STATUSES)[number];\n\nexport const VERIFY_STATUSES = ['PENDING', 'PASS', 'FAIL', 'SKIPPED'] as const;\nexport type VerifyStatus = (typeof VERIFY_STATUSES)[number];\n\nexport interface VerificationItem {\n check: string;\n required: boolean;\n status: VerifyStatus;\n reason?: string;\n detail?: string;\n updatedAt?: string;\n}\n\nexport interface TestCounts {\n passed: number;\n failed: number;\n}\n\nexport interface Attestations {\n userWorkIntact: boolean;\n knowledgeReviewed: boolean;\n finalStateInspected: boolean;\n}\n\nexport interface Task {\n schemaVersion: number;\n id: string;\n title: string;\n type: TaskType;\n status: TaskStatus;\n createdAt: string;\n updatedAt: string;\n description: string;\n acceptanceCriteria: string[];\n plan: string[];\n affectedAreas: string[];\n verification: VerificationItem[];\n tests: { baseline?: TestCounts; after?: TestCounts };\n attestations: Attestations;\n decisions: string[];\n blockers: string[];\n constraints: string[];\n completionSummary?: string;\n history: { at: string; from: TaskStatus | null; to: TaskStatus; note?: string }[];\n}\n\nconst TRANSITIONS: Record<TaskStatus, TaskStatus[]> = {\n IDEA: ['SPECIFIED', 'PLANNED', 'IN_PROGRESS', 'BLOCKED', 'FAILED'],\n SPECIFIED: ['PLANNED', 'IN_PROGRESS', 'BLOCKED', 'IDEA'],\n PLANNED: ['IN_PROGRESS', 'SPECIFIED', 'BLOCKED', 'IDEA'],\n IN_PROGRESS: ['TESTING', 'REVIEW', 'COMPLETED', 'BLOCKED', 'FAILED', 'PLANNED'],\n TESTING: ['IN_PROGRESS', 'REVIEW', 'COMPLETED', 'BLOCKED', 'FAILED'],\n REVIEW: ['IN_PROGRESS', 'TESTING', 'COMPLETED', 'BLOCKED', 'FAILED'],\n BLOCKED: ['IN_PROGRESS', 'PLANNED', 'SPECIFIED', 'IDEA', 'FAILED'],\n FAILED: ['IN_PROGRESS', 'IDEA'],\n COMPLETED: ['IN_PROGRESS'],\n};\n\nexport function allowedTransitions(from: TaskStatus): TaskStatus[] {\n return TRANSITIONS[from];\n}\n\nconst CODE_CHANGING: TaskType[] = ['BUG', 'FEATURE', 'REFACTOR', 'PERFORMANCE', 'SECURITY', 'ARCHITECTURE', 'MAINTENANCE', 'TESTING', 'RELEASE'];\n\nconst CHECKS_BY_TYPE: Record<TaskType, string[]> = {\n QUESTION: [],\n DOCUMENTATION: [],\n BUG: ['unit', 'typecheck', 'lint', 'build'],\n FEATURE: ['unit', 'typecheck', 'lint', 'build', 'review'],\n REFACTOR: ['unit', 'typecheck', 'lint', 'build', 'review'],\n TESTING: ['unit', 'typecheck', 'lint'],\n PERFORMANCE: ['unit', 'build', 'review'],\n SECURITY: ['unit', 'typecheck', 'lint', 'build', 'review'],\n ARCHITECTURE: ['unit', 'typecheck', 'lint', 'build', 'review'],\n RELEASE: ['unit', 'typecheck', 'lint', 'build', 'integration', 'e2e'],\n MAINTENANCE: ['lint', 'build'],\n};\n\nexport function isCodeChanging(type: TaskType): boolean {\n return CODE_CHANGING.includes(type);\n}\n\n/** Verification a task of this type needs, given what the project actually offers. Unavailable checks are never demanded. */\nexport function requiredChecksFor(type: TaskType, contract: CommandEntry[], reviewLevel: 'off' | 'light' | 'strict' = 'light'): VerificationItem[] {\n const available = new Set(contract.filter((c) => c.available).map((c) => c.id as string));\n const items: VerificationItem[] = [];\n for (const check of CHECKS_BY_TYPE[type]) {\n if (check === 'review') {\n if (reviewLevel === 'off') continue;\n } else if (!available.has(check)) continue;\n items.push({ check, required: true, status: 'PENDING' });\n }\n return items;\n}\n\nexport function newTaskId(now: Date = new Date()): string {\n const d = now.toISOString().slice(0, 10).replace(/-/g, '');\n return `T-${d}-${randomId(2)}`;\n}\n\nexport interface NewTaskInput {\n title: string;\n type: TaskType;\n description?: string;\n verification: VerificationItem[];\n constraints?: string[];\n}\n\nexport function createTaskObject(input: NewTaskInput, now: string, id = newTaskId()): Task {\n const title = input.title.trim().slice(0, 200);\n if (!title) throw new DevWorkspaceError('USAGE', 'Task title must not be empty.');\n const task: Task = {\n schemaVersion: SCHEMA_VERSION,\n id,\n title,\n type: input.type,\n status: 'IDEA',\n createdAt: now,\n updatedAt: now,\n description: (input.description ?? '').trim().slice(0, 4000),\n acceptanceCriteria: [],\n plan: [],\n affectedAreas: [],\n verification: input.verification,\n tests: {},\n attestations: { userWorkIntact: false, knowledgeReviewed: false, finalStateInspected: false },\n decisions: [],\n blockers: [],\n constraints: input.constraints ?? [],\n history: [{ at: now, from: null, to: 'IDEA' }],\n };\n assertNoSecrets(task);\n return task;\n}\n\nexport function assertNoSecrets(task: Task): void {\n if (containsSecret(JSON.stringify(task))) {\n throw new DevWorkspaceError('SECURITY', 'Task content looks like it contains a secret; refusing to store it.', {\n hint: 'Remove credential values from titles, plans and notes.',\n });\n }\n}\n\nexport function validateTask(v: unknown, file = 'task'): Task {\n const c = new Check(file);\n const o = c.obj(v);\n c.at_('schemaVersion').int(o.schemaVersion, 1);\n c.at_('id').str(o.id, { min: 3, max: 64 });\n c.at_('title').str(o.title, { min: 1, max: 300 });\n c.at_('type').oneOf(o.type, TASK_TYPES);\n c.at_('status').oneOf(o.status, TASK_STATUSES);\n c.at_('createdAt').iso(o.createdAt);\n c.at_('updatedAt').iso(o.updatedAt);\n for (const k of ['acceptanceCriteria', 'plan', 'affectedAreas', 'decisions', 'blockers', 'constraints'] as const) c.at_(k).strArr(o[k]);\n c.at_('verification')\n .arr(o.verification, 100)\n .forEach((item, i) => {\n const ic = c.at_(`verification.${i}`);\n const io = ic.obj(item);\n ic.at_('check').str(io.check, { max: 50 });\n ic.at_('required').bool(io.required);\n ic.at_('status').oneOf(io.status, VERIFY_STATUSES);\n });\n const a = c.at_('attestations').obj(o.attestations);\n c.at_('attestations.userWorkIntact').bool(a.userWorkIntact);\n c.at_('attestations.knowledgeReviewed').bool(a.knowledgeReviewed);\n c.at_('attestations.finalStateInspected').bool(a.finalStateInspected);\n c.at_('tests').obj(o.tests);\n c.at_('history').arr(o.history, 500);\n return o as unknown as Task;\n}\n\nexport interface GateResult {\n ok: boolean;\n failures: string[];\n warnings: string[];\n}\n\n/** The completion gate. A task is only COMPLETED when every applicable requirement holds. */\nexport function evaluateGate(task: Task): GateResult {\n const failures: string[] = [];\n const warnings: string[] = [];\n for (const v of task.verification) {\n if (!v.required) continue;\n if (v.status === 'FAIL') failures.push(`${v.check}: FAIL`);\n else if (v.status === 'PENDING') failures.push(`${v.check}: not run yet`);\n else if (v.status === 'SKIPPED') {\n if (v.reason === 'user-override') warnings.push(`${v.check}: skipped at the user's request; completion is less certain`);\n else failures.push(`${v.check}: skipped without a user override`);\n }\n }\n const { baseline, after } = task.tests;\n if (baseline && !after) failures.push('baseline test results recorded, but no results after the change');\n if (baseline && after) {\n if (after.failed > baseline.failed) failures.push(`regression: failures rose from ${baseline.failed} to ${after.failed}`);\n if (after.passed < baseline.passed) failures.push(`regression: passing tests fell from ${baseline.passed} to ${after.passed}`);\n }\n if (isCodeChanging(task.type)) {\n if (!task.attestations.userWorkIntact) failures.push('not confirmed: no user work was overwritten');\n if (!task.attestations.knowledgeReviewed) failures.push('not confirmed: project knowledge was reviewed for updates');\n if (!task.attestations.finalStateInspected) failures.push('not confirmed: final repository state was inspected');\n }\n if ((isCodeChanging(task.type) || task.type === 'DOCUMENTATION') && !(task.completionSummary ?? '').trim()) {\n failures.push('completion summary is missing');\n }\n return { ok: failures.length === 0, failures, warnings };\n}\n\nexport function transitionTask(task: Task, to: TaskStatus, now: string, note?: string): GateResult | null {\n if (task.status === to) return null;\n if (!TRANSITIONS[task.status].includes(to)) {\n throw new DevWorkspaceError('GATE', `Cannot move a task from ${task.status} to ${to}.`, {\n hint: `Allowed from ${task.status}: ${TRANSITIONS[task.status].join(', ')}.`,\n });\n }\n let gate: GateResult | null = null;\n if (to === 'COMPLETED') {\n gate = evaluateGate(task);\n if (!gate.ok) {\n throw new DevWorkspaceError('GATE', `Task ${task.id} cannot be completed:\\n - ${gate.failures.join('\\n - ')}`, {\n hint: 'Resolve the items above (or mark the task BLOCKED/FAILED). A task is never complete while verification is failing.',\n });\n }\n }\n task.history.push({ at: now, from: task.status, to, ...(note ? { note: note.slice(0, 300) } : {}) });\n task.status = to;\n task.updatedAt = now;\n return gate;\n}\n\nexport function nextRequiredStep(task: Task): string {\n switch (task.status) {\n case 'COMPLETED':\n return 'None. The task is complete.';\n case 'FAILED':\n return 'Review the failure, then move the task back to IN_PROGRESS or close the idea.';\n case 'BLOCKED':\n return task.blockers.length > 0 ? `Resolve blocker: ${task.blockers[task.blockers.length - 1]}` : 'Identify and record what blocks this task.';\n case 'IDEA':\n return 'Clarify acceptance criteria, then plan.';\n case 'SPECIFIED':\n return 'Write a plan.';\n case 'PLANNED':\n return 'Start implementation (baseline verification first for meaningful changes).';\n default: {\n const pending = task.verification.filter((v) => v.required && (v.status === 'PENDING' || v.status === 'FAIL'));\n if (pending.length > 0) return `Run/fix verification: ${pending.map((p) => `${p.check} (${p.status.toLowerCase()})`).join(', ')}.`;\n const g = evaluateGate(task);\n return g.ok ? 'All gates pass. Mark the task COMPLETED.' : `Satisfy the completion gate: ${g.failures[0]}`;\n }\n }\n}\n\n// ---------- storage ----------\n\nfunction taskFile(ws: Ws, task: Pick<Task, 'id' | 'status'>): string {\n return path.join(task.status === 'COMPLETED' ? ws.tasksCompleted : ws.tasksActive, `${task.id}.json`);\n}\n\nexport async function saveTask(ws: Ws, task: Task): Promise<void> {\n validateTask(task);\n assertNoSecrets(task);\n const dest = taskFile(ws, task);\n await backupIfVersionChanges(ws, dest, task.schemaVersion);\n await ensureDir(path.dirname(dest));\n await atomicWriteJson(dest, task);\n const other = path.join(task.status === 'COMPLETED' ? ws.tasksActive : ws.tasksCompleted, `${task.id}.json`);\n await fs.rm(other, { force: true });\n}\n\nexport async function loadTask(ws: Ws, idOrPrefix: string): Promise<Task> {\n for (const dir of [ws.tasksActive, ws.tasksCompleted]) {\n if (!(await pathExists(dir))) continue;\n const names = (await fs.readdir(dir)).filter((n) => n.endsWith('.json'));\n const hits = names.filter((n) => n === `${idOrPrefix}.json` || n.startsWith(idOrPrefix));\n if (hits.length > 1) {\n const exact = hits.find((n) => n === `${idOrPrefix}.json`);\n if (!exact) throw new DevWorkspaceError('USAGE', `Task id \"${idOrPrefix}\" is ambiguous.`, { hint: 'Use more characters of the id.' });\n hits.splice(0, hits.length, exact);\n }\n if (hits.length === 1) {\n const file = path.join(dir, hits[0]!);\n return (await readVersioned(file, 'task', SCHEMA_VERSION, validateTask)).data;\n }\n }\n throw new DevWorkspaceError('NOT_FOUND', `No task matching \"${idOrPrefix}\".`, { hint: 'List tasks with \"devworkspace task list --all\".' });\n}\n\nexport interface TaskListing {\n tasks: Task[];\n corrupt: { file: string; error: string }[];\n}\n\nexport async function listTasks(ws: Ws, opts: { includeCompleted?: boolean } = {}): Promise<TaskListing> {\n const tasks: Task[] = [];\n const corrupt: { file: string; error: string }[] = [];\n const dirs = opts.includeCompleted ? [ws.tasksActive, ws.tasksCompleted] : [ws.tasksActive];\n for (const dir of dirs) {\n if (!(await pathExists(dir))) continue;\n for (const name of (await fs.readdir(dir)).filter((n) => n.endsWith('.json')).sort()) {\n try {\n tasks.push((await readVersioned(path.join(dir, name), 'task', SCHEMA_VERSION, validateTask)).data);\n } catch (e) {\n corrupt.push({ file: `${path.basename(dir)}/${name}`, error: (e as Error).message });\n }\n }\n }\n tasks.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));\n return { tasks, corrupt };\n}\n"]}
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/tasks/task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,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E,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,KAAK,EAAG,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { DevWorkspaceError } from '../errors/index.js';\nimport { Check } from '../config/validate.js';\nimport { SCHEMA_VERSION, type CommandEntry } from '../config/schemas.js';\nimport { atomicWriteJson, ensureDir, pathExists, randomId } from '../utils/fs.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { backupIfVersionChanges, type Ws } from '../core/workspace.js';\nimport { containsSecret } from '../security/redact.js';\n\nexport const TASK_TYPES = [\n 'QUESTION',\n 'BUG',\n 'FEATURE',\n 'REFACTOR',\n 'DOCUMENTATION',\n 'TESTING',\n 'PERFORMANCE',\n 'SECURITY',\n 'ARCHITECTURE',\n 'RELEASE',\n 'MAINTENANCE',\n] as const;\nexport type TaskType = (typeof TASK_TYPES)[number];\n\nexport const TASK_STATUSES = ['IDEA', 'SPECIFIED', 'PLANNED', 'IN_PROGRESS', 'TESTING', 'REVIEW', 'BLOCKED', 'FAILED', 'COMPLETED'] as const;\nexport type TaskStatus = (typeof TASK_STATUSES)[number];\n\nexport const VERIFY_STATUSES = ['PENDING', 'PASS', 'FAIL', 'SKIPPED', 'COULD_NOT_RUN'] as const;\nexport type VerifyStatus = (typeof VERIFY_STATUSES)[number];\n\n/**\n * One recorded result for one package. `executed` means DevWorkspace ran the contract command itself and saw the exit\n * code; `claimed` is somebody's report (agent or person) that DevWorkspace could not observe.\n */\nexport interface Evidence {\n kind: 'executed' | 'claimed';\n at: string;\n /** Package directory relative to the project root; \".\" for the root. */\n package: string;\n command?: string;\n exitCode?: number | null;\n durationMs?: number;\n /** Fingerprint of the task's changes inside this package when the result was recorded. */\n scope?: string;\n /** A claim the user explicitly vouched for (--reason user-override). */\n userOverride?: boolean;\n /** One-line, scrubbed explanation (failure tail or refusal reason). Never a connection string or credential. */\n note?: string;\n}\n\nexport interface VerificationItem {\n check: string;\n required: boolean;\n status: VerifyStatus;\n reason?: string;\n detail?: string;\n updatedAt?: string;\n /** Latest result per package. Absent on tasks recorded by older versions. */\n evidence?: Evidence[];\n}\n\n/** Files that were already modified when the task was created, so they are not blamed on the task. */\nexport interface TaskScope {\n capturedAt: string;\n /** Git HEAD when the task was created; null outside a repository. */\n head: string | null;\n /** Project-relative path -> content hash of files already modified at creation (\"deleted\" for removed files). */\n baseline: Record<string, string>;\n}\n\nexport interface TestCounts {\n passed: number;\n failed: number;\n}\n\nexport interface Attestations {\n userWorkIntact: boolean;\n knowledgeReviewed: boolean;\n finalStateInspected: boolean;\n}\n\nexport interface Task {\n schemaVersion: number;\n id: string;\n title: string;\n type: TaskType;\n status: TaskStatus;\n createdAt: string;\n updatedAt: string;\n description: string;\n acceptanceCriteria: string[];\n plan: string[];\n affectedAreas: string[];\n verification: VerificationItem[];\n tests: { baseline?: TestCounts; after?: TestCounts };\n attestations: Attestations;\n /** Present on tasks created by 0.2.2+: enables package-aware, evidence-based completion. */\n scope?: TaskScope;\n decisions: string[];\n blockers: string[];\n constraints: string[];\n completionSummary?: string;\n history: { at: string; from: TaskStatus | null; to: TaskStatus; note?: string }[];\n}\n\nconst TRANSITIONS: Record<TaskStatus, TaskStatus[]> = {\n IDEA: ['SPECIFIED', 'PLANNED', 'IN_PROGRESS', 'BLOCKED', 'FAILED'],\n SPECIFIED: ['PLANNED', 'IN_PROGRESS', 'BLOCKED', 'IDEA'],\n PLANNED: ['IN_PROGRESS', 'SPECIFIED', 'BLOCKED', 'IDEA'],\n IN_PROGRESS: ['TESTING', 'REVIEW', 'COMPLETED', 'BLOCKED', 'FAILED', 'PLANNED'],\n TESTING: ['IN_PROGRESS', 'REVIEW', 'COMPLETED', 'BLOCKED', 'FAILED'],\n REVIEW: ['IN_PROGRESS', 'TESTING', 'COMPLETED', 'BLOCKED', 'FAILED'],\n BLOCKED: ['IN_PROGRESS', 'PLANNED', 'SPECIFIED', 'IDEA', 'FAILED'],\n FAILED: ['IN_PROGRESS', 'IDEA'],\n COMPLETED: ['IN_PROGRESS'],\n};\n\nexport function allowedTransitions(from: TaskStatus): TaskStatus[] {\n return TRANSITIONS[from];\n}\n\nconst CODE_CHANGING: TaskType[] = ['BUG', 'FEATURE', 'REFACTOR', 'PERFORMANCE', 'SECURITY', 'ARCHITECTURE', 'MAINTENANCE', 'TESTING', 'RELEASE'];\n\nconst CHECKS_BY_TYPE: Record<TaskType, string[]> = {\n QUESTION: [],\n DOCUMENTATION: [],\n BUG: ['unit', 'typecheck', 'lint', 'build'],\n FEATURE: ['unit', 'typecheck', 'lint', 'build', 'review'],\n REFACTOR: ['unit', 'typecheck', 'lint', 'build', 'review'],\n TESTING: ['unit', 'typecheck', 'lint'],\n PERFORMANCE: ['unit', 'build', 'review'],\n SECURITY: ['unit', 'typecheck', 'lint', 'build', 'review'],\n ARCHITECTURE: ['unit', 'typecheck', 'lint', 'build', 'review'],\n RELEASE: ['unit', 'typecheck', 'lint', 'build', 'integration', 'e2e'],\n MAINTENANCE: ['lint', 'build'],\n};\n\nexport function isCodeChanging(type: TaskType): boolean {\n return CODE_CHANGING.includes(type);\n}\n\n/** Verification a task of this type needs, given what the project actually offers. Unavailable checks are never demanded. */\nexport function requiredChecksFor(type: TaskType, contract: CommandEntry[], reviewLevel: 'off' | 'light' | 'strict' = 'light'): VerificationItem[] {\n const available = new Set(contract.filter((c) => c.available).map((c) => c.id as string));\n const items: VerificationItem[] = [];\n for (const check of CHECKS_BY_TYPE[type]) {\n if (check === 'review') {\n if (reviewLevel === 'off') continue;\n } else if (!available.has(check)) continue;\n items.push({ check, required: true, status: 'PENDING' });\n }\n return items;\n}\n\nexport function newTaskId(now: Date = new Date()): string {\n const d = now.toISOString().slice(0, 10).replace(/-/g, '');\n return `T-${d}-${randomId(2)}`;\n}\n\nexport interface NewTaskInput {\n title: string;\n type: TaskType;\n description?: string;\n verification: VerificationItem[];\n constraints?: string[];\n}\n\nexport function createTaskObject(input: NewTaskInput, now: string, id = newTaskId()): Task {\n const title = input.title.trim().slice(0, 200);\n if (!title) throw new DevWorkspaceError('USAGE', 'Task title must not be empty.');\n const task: Task = {\n schemaVersion: SCHEMA_VERSION,\n id,\n title,\n type: input.type,\n status: 'IDEA',\n createdAt: now,\n updatedAt: now,\n description: (input.description ?? '').trim().slice(0, 4000),\n acceptanceCriteria: [],\n plan: [],\n affectedAreas: [],\n verification: input.verification,\n tests: {},\n attestations: { userWorkIntact: false, knowledgeReviewed: false, finalStateInspected: false },\n decisions: [],\n blockers: [],\n constraints: input.constraints ?? [],\n history: [{ at: now, from: null, to: 'IDEA' }],\n };\n assertNoSecrets(task);\n return task;\n}\n\nexport function assertNoSecrets(task: Task): void {\n if (containsSecret(JSON.stringify(task))) {\n throw new DevWorkspaceError('SECURITY', 'Task content looks like it contains a secret; refusing to store it.', {\n hint: 'Remove credential values from titles, plans and notes.',\n });\n }\n}\n\nexport function validateTask(v: unknown, file = 'task'): Task {\n const c = new Check(file);\n const o = c.obj(v);\n c.at_('schemaVersion').int(o.schemaVersion, 1);\n c.at_('id').str(o.id, { min: 3, max: 64 });\n c.at_('title').str(o.title, { min: 1, max: 300 });\n c.at_('type').oneOf(o.type, TASK_TYPES);\n c.at_('status').oneOf(o.status, TASK_STATUSES);\n c.at_('createdAt').iso(o.createdAt);\n c.at_('updatedAt').iso(o.updatedAt);\n for (const k of ['acceptanceCriteria', 'plan', 'affectedAreas', 'decisions', 'blockers', 'constraints'] as const) c.at_(k).strArr(o[k]);\n c.at_('verification')\n .arr(o.verification, 100)\n .forEach((item, i) => {\n const ic = c.at_(`verification.${i}`);\n const io = ic.obj(item);\n ic.at_('check').str(io.check, { max: 50 });\n ic.at_('required').bool(io.required);\n ic.at_('status').oneOf(io.status, VERIFY_STATUSES);\n if (io.evidence !== undefined) {\n ic.at_('evidence')\n .arr(io.evidence, 100)\n .forEach((e, j) => {\n const ec = c.at_(`verification.${i}.evidence.${j}`);\n const eo = ec.obj(e);\n ec.at_('kind').oneOf(eo.kind, ['executed', 'claimed'] as const);\n ec.at_('package').str(eo.package, { max: 240 });\n });\n }\n });\n if (o.scope !== undefined) {\n const sc = c.at_('scope').obj(o.scope);\n c.at_('scope.capturedAt').iso(sc.capturedAt);\n c.at_('scope.baseline').obj(sc.baseline);\n }\n const a = c.at_('attestations').obj(o.attestations);\n c.at_('attestations.userWorkIntact').bool(a.userWorkIntact);\n c.at_('attestations.knowledgeReviewed').bool(a.knowledgeReviewed);\n c.at_('attestations.finalStateInspected').bool(a.finalStateInspected);\n c.at_('tests').obj(o.tests);\n c.at_('history').arr(o.history, 500);\n return o as unknown as Task;\n}\n\nexport interface GateResult {\n ok: boolean;\n failures: string[];\n warnings: string[];\n}\n\n/** What the gate needs to know beyond the task itself: the contract and what the task changed, per package. */\nexport interface GateContext {\n contract: CommandEntry[];\n /**\n * Fingerprint of the task's changes inside each package (\".\" = everything). `null` means the changes could not be\n * determined (not a Git repository, or nothing changed since the task started), so every package counts as affected.\n */\n scope: Record<string, string> | null;\n}\n\nconst UNKNOWN_SCOPE = 'unknown';\n\n/** Per-package requirements of one check. Returns false when the contract has no applicable package entry. */\nfunction packageGate(v: VerificationItem, ctx: GateContext, failures: string[], warnings: string[]): boolean {\n const entries = ctx.contract.filter((c) => c.id === v.check && c.available && !c.mutates);\n if (entries.length === 0) return false;\n const known = ctx.scope !== null;\n const unknown = !known;\n let applicable = 0;\n for (const entry of entries) {\n const pkg = entry.cwd ?? '.';\n const fp = known ? ctx.scope![pkg] : UNKNOWN_SCOPE;\n if (fp === undefined) continue; // this package was not changed, so this check does not apply to it\n applicable++;\n const label = `${v.check} [${pkg}]`;\n const ev = v.evidence?.find((e) => e.package === pkg);\n if (!ev) failures.push(`${label}: not run for the current changes`);\n else if (ev.kind === 'claimed' && !ev.userOverride) failures.push(`${label}: only claimed, not executed (run: devworkspace task run <id> ${v.check} --package ${pkg})`);\n else if (ev.kind === 'claimed') warnings.push(`${label}: accepted on the user's word; DevWorkspace did not observe it run`);\n else if (ev.exitCode !== 0) failures.push(`${label}: FAIL (exit ${ev.exitCode ?? 'none'})`);\n else if (!unknown && ev.scope !== fp) failures.push(`${label}: passed, but files changed afterwards; run it again`);\n }\n if (known && applicable === 0) warnings.push(`${v.check}: no package with this check was changed`);\n return true;\n}\n\n/**\n * The completion gate. A task is only COMPLETED when every applicable requirement holds.\n * Tasks that carry a `scope` (created by 0.2.2+) are checked per changed package against executed evidence; older\n * tasks keep the original rules.\n */\nexport function evaluateGate(task: Task, ctx?: GateContext): GateResult {\n const failures: string[] = [];\n const warnings: string[] = [];\n const scoped = !!ctx && !!task.scope;\n for (const v of task.verification) {\n if (!v.required) continue;\n if (v.status === 'FAIL') failures.push(`${v.check}: FAIL`);\n else if (v.status === 'COULD_NOT_RUN') failures.push(`${v.check}: could not run${v.detail ? ` (${v.detail})` : ''}`);\n else if (v.status === 'SKIPPED') {\n if (v.reason === 'user-override') warnings.push(`${v.check}: skipped at the user's request; completion is less certain`);\n else failures.push(`${v.check}: skipped without a user override`);\n } else if (scoped && packageGate(v, ctx!, failures, warnings)) {\n // handled per package\n } else if (v.status === 'PENDING') failures.push(`${v.check}: not run yet`);\n }\n const { baseline, after } = task.tests;\n if (baseline && !after) failures.push('baseline test results recorded, but no results after the change');\n if (baseline && after) {\n if (after.failed > baseline.failed) failures.push(`regression: failures rose from ${baseline.failed} to ${after.failed}`);\n if (after.passed < baseline.passed) failures.push(`regression: passing tests fell from ${baseline.passed} to ${after.passed}`);\n }\n if (isCodeChanging(task.type)) {\n if (!task.attestations.userWorkIntact) failures.push('not confirmed: no user work was overwritten');\n if (!task.attestations.knowledgeReviewed) failures.push('not confirmed: project knowledge was reviewed for updates');\n if (!task.attestations.finalStateInspected) failures.push('not confirmed: final repository state was inspected');\n }\n if ((isCodeChanging(task.type) || task.type === 'DOCUMENTATION') && !(task.completionSummary ?? '').trim()) {\n failures.push('completion summary is missing');\n }\n return { ok: failures.length === 0, failures, warnings };\n}\n\nexport function transitionTask(task: Task, to: TaskStatus, now: string, note?: string, ctx?: GateContext): GateResult | null {\n if (task.status === to) return null;\n if (!TRANSITIONS[task.status].includes(to)) {\n throw new DevWorkspaceError('GATE', `Cannot move a task from ${task.status} to ${to}.`, {\n hint: `Allowed from ${task.status}: ${TRANSITIONS[task.status].join(', ')}.`,\n });\n }\n let gate: GateResult | null = null;\n if (to === 'COMPLETED') {\n gate = evaluateGate(task, ctx);\n if (!gate.ok) {\n throw new DevWorkspaceError('GATE', `Task ${task.id} cannot be completed:\\n - ${gate.failures.join('\\n - ')}`, {\n hint: 'Resolve the items above (or mark the task BLOCKED/FAILED). A task is never complete while verification is failing.',\n });\n }\n }\n task.history.push({ at: now, from: task.status, to, ...(note ? { note: note.slice(0, 300) } : {}) });\n task.status = to;\n task.updatedAt = now;\n return gate;\n}\n\nexport function nextRequiredStep(task: Task, ctx?: GateContext): string {\n switch (task.status) {\n case 'COMPLETED':\n return 'None. The task is complete.';\n case 'FAILED':\n return 'Review the failure, then move the task back to IN_PROGRESS or close the idea.';\n case 'BLOCKED':\n return task.blockers.length > 0 ? `Resolve blocker: ${task.blockers[task.blockers.length - 1]}` : 'Identify and record what blocks this task.';\n case 'IDEA':\n return 'Clarify acceptance criteria, then plan.';\n case 'SPECIFIED':\n return 'Write a plan.';\n case 'PLANNED':\n return 'Start implementation (baseline verification first for meaningful changes).';\n default: {\n const pending = task.verification.filter((v) => v.required && (v.status === 'PENDING' || v.status === 'FAIL' || v.status === 'COULD_NOT_RUN'));\n if (pending.length > 0) return `Run/fix verification: ${pending.map((p) => `${p.check} (${p.status.toLowerCase().replace(/_/g, ' ')})`).join(', ')}.`;\n const g = evaluateGate(task, ctx);\n return g.ok ? 'All gates pass. Mark the task COMPLETED.' : `Satisfy the completion gate: ${g.failures[0]}`;\n }\n }\n}\n\n// ---------- storage ----------\n\nfunction taskFile(ws: Ws, task: Pick<Task, 'id' | 'status'>): string {\n return path.join(task.status === 'COMPLETED' ? ws.tasksCompleted : ws.tasksActive, `${task.id}.json`);\n}\n\nexport async function saveTask(ws: Ws, task: Task): Promise<void> {\n validateTask(task);\n assertNoSecrets(task);\n const dest = taskFile(ws, task);\n await backupIfVersionChanges(ws, dest, task.schemaVersion);\n await ensureDir(path.dirname(dest));\n await atomicWriteJson(dest, task);\n const other = path.join(task.status === 'COMPLETED' ? ws.tasksActive : ws.tasksCompleted, `${task.id}.json`);\n await fs.rm(other, { force: true });\n}\n\nexport async function loadTask(ws: Ws, idOrPrefix: string): Promise<Task> {\n for (const dir of [ws.tasksActive, ws.tasksCompleted]) {\n if (!(await pathExists(dir))) continue;\n const names = (await fs.readdir(dir)).filter((n) => n.endsWith('.json'));\n const hits = names.filter((n) => n === `${idOrPrefix}.json` || n.startsWith(idOrPrefix));\n if (hits.length > 1) {\n const exact = hits.find((n) => n === `${idOrPrefix}.json`);\n if (!exact) throw new DevWorkspaceError('USAGE', `Task id \"${idOrPrefix}\" is ambiguous.`, { hint: 'Use more characters of the id.' });\n hits.splice(0, hits.length, exact);\n }\n if (hits.length === 1) {\n const file = path.join(dir, hits[0]!);\n return (await readVersioned(file, 'task', SCHEMA_VERSION, validateTask)).data;\n }\n }\n throw new DevWorkspaceError('NOT_FOUND', `No task matching \"${idOrPrefix}\".`, { hint: 'List tasks with \"devworkspace task list --all\".' });\n}\n\nexport interface TaskListing {\n tasks: Task[];\n corrupt: { file: string; error: string }[];\n}\n\nexport async function listTasks(ws: Ws, opts: { includeCompleted?: boolean } = {}): Promise<TaskListing> {\n const tasks: Task[] = [];\n const corrupt: { file: string; error: string }[] = [];\n const dirs = opts.includeCompleted ? [ws.tasksActive, ws.tasksCompleted] : [ws.tasksActive];\n for (const dir of dirs) {\n if (!(await pathExists(dir))) continue;\n for (const name of (await fs.readdir(dir)).filter((n) => n.endsWith('.json')).sort()) {\n try {\n tasks.push((await readVersioned(path.join(dir, name), 'task', SCHEMA_VERSION, validateTask)).data);\n } catch (e) {\n corrupt.push({ file: `${path.basename(dir)}/${name}`, error: (e as Error).message });\n }\n }\n }\n tasks.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));\n return { tasks, corrupt };\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import type { CommandEntry } from '../config/schemas.js';
2
+ import type { Ws } from '../core/workspace.js';
3
+ export type Safety = 'safe' | 'needs-test-environment' | 'blocked';
4
+ export interface CommandSafety {
5
+ safety: Safety;
6
+ reasons: string[];
7
+ /** Services the package is known to use (from its manifest), for the explanation only. */
8
+ services: string[];
9
+ }
10
+ export interface ManifestEvidence {
11
+ scriptBody: string | null;
12
+ services: string[];
13
+ hasCredentialFile: boolean;
14
+ }
15
+ /** Read the package manifest next to a command: the script it runs and the services the package depends on. Never reads .env files. */
16
+ export declare function readManifestEvidence(root: string, entry: CommandEntry): Promise<ManifestEvidence>;
17
+ /**
18
+ * Decide whether DevWorkspace may run a contract command by itself. Pure; no file is read here.
19
+ * - blocked: modifies project files, changes a schema/data set, or is destructive. Never run automatically.
20
+ * - needs-test-environment: exercises real services or may (a catch-all `test` in a package that uses a database).
21
+ * Runs only after the user declared a test environment for that package and check.
22
+ * - safe: typecheck, lint, build, unit tests and read-only format checks.
23
+ * A database is never judged safe from its name; DevWorkspace does not read connection settings at all.
24
+ */
25
+ export declare function classifyCommand(entry: CommandEntry, evidence: ManifestEvidence): CommandSafety;
26
+ export interface TestEnvDeclaration {
27
+ /** Package directory relative to the project root; "." for the root. */
28
+ package: string;
29
+ checks: string[];
30
+ /** Human description of the target, e.g. "docker compose test stack on this laptop". Never a connection string. */
31
+ target: string;
32
+ declaredAt: string;
33
+ }
34
+ export declare function loadTestEnv(ws: Ws): Promise<TestEnvDeclaration[]>;
35
+ export declare function assertSafeTarget(target: string): void;
36
+ export declare function saveDeclaration(ws: Ws, d: TestEnvDeclaration): Promise<void>;
37
+ export declare function removeDeclaration(ws: Ws, pkg: string): Promise<boolean>;
38
+ export declare function isDeclared(decls: TestEnvDeclaration[], pkg: string, check: string): TestEnvDeclaration | undefined;
@@ -0,0 +1,120 @@
1
+ import path from 'node:path';
2
+ import { DevWorkspaceError } from '../errors/index.js';
3
+ import { containsSecret } from '../security/redact.js';
4
+ import { safeReadText } from '../security/files.js';
5
+ import { atomicWriteJson, pathExists, readJsonFile } from '../utils/fs.js';
6
+ /** Dependencies that mean a package talks to a database or queue. */
7
+ const SERVICE_DEPS = {
8
+ pg: 'PostgreSQL',
9
+ postgres: 'PostgreSQL',
10
+ 'drizzle-orm': 'a SQL database',
11
+ prisma: 'a SQL database',
12
+ '@prisma/client': 'a SQL database',
13
+ typeorm: 'a SQL database',
14
+ sequelize: 'a SQL database',
15
+ knex: 'a SQL database',
16
+ mongoose: 'MongoDB',
17
+ mongodb: 'MongoDB',
18
+ redis: 'Redis',
19
+ ioredis: 'Redis',
20
+ bullmq: 'Redis',
21
+ bull: 'Redis',
22
+ };
23
+ /** Words that make a command destructive or schema-changing no matter which check it is filed under. */
24
+ const DESTRUCTIVE = /(?:^|[\s:/_-])(?:drop|truncate|flushall|flushdb|reset|seed|migrate)(?:$|[\s:/_.-])|db:push|--force|rm\s+-rf/i;
25
+ /** Checks whose job is to exercise real services. They need a declared test environment. */
26
+ const SERVICE_CHECKS = new Set(['integration', 'security', 'e2e']);
27
+ /** Read the package manifest next to a command: the script it runs and the services the package depends on. Never reads .env files. */
28
+ export async function readManifestEvidence(root, entry) {
29
+ const dir = entry.cwd && entry.cwd !== '.' ? entry.cwd : '';
30
+ const manifest = dir ? `${dir}/package.json` : 'package.json';
31
+ let scriptBody = null;
32
+ const services = new Set();
33
+ try {
34
+ const text = await safeReadText(root, manifest, 1024 * 1024);
35
+ const json = text ? JSON.parse(text) : null;
36
+ const script = /#scripts\.(.+)$/.exec(entry.source ?? '')?.[1];
37
+ if (json && script && typeof json.scripts?.[script] === 'string')
38
+ scriptBody = json.scripts[script];
39
+ for (const dep of Object.keys({ ...json?.dependencies, ...json?.devDependencies }))
40
+ if (SERVICE_DEPS[dep])
41
+ services.add(SERVICE_DEPS[dep]);
42
+ }
43
+ catch {
44
+ /* unreadable manifest: no evidence */
45
+ }
46
+ let hasCredentialFile = false;
47
+ for (const name of ['.env', '.env.local', '.env.test', '.env.development']) {
48
+ if (await pathExists(path.join(root, ...(dir ? [dir] : []), name)))
49
+ hasCredentialFile = true;
50
+ }
51
+ // "a SQL database" is only the fallback label for an ORM; drop it once a specific database is known.
52
+ if (services.size > 1)
53
+ services.delete('a SQL database');
54
+ return { scriptBody, services: [...services].sort(), hasCredentialFile };
55
+ }
56
+ /**
57
+ * Decide whether DevWorkspace may run a contract command by itself. Pure; no file is read here.
58
+ * - blocked: modifies project files, changes a schema/data set, or is destructive. Never run automatically.
59
+ * - needs-test-environment: exercises real services or may (a catch-all `test` in a package that uses a database).
60
+ * Runs only after the user declared a test environment for that package and check.
61
+ * - safe: typecheck, lint, build, unit tests and read-only format checks.
62
+ * A database is never judged safe from its name; DevWorkspace does not read connection settings at all.
63
+ */
64
+ export function classifyCommand(entry, evidence) {
65
+ const reasons = [];
66
+ const services = evidence.services;
67
+ const text = `${entry.command ?? ''} ${evidence.scriptBody ?? ''}`;
68
+ if (entry.mutates)
69
+ return { safety: 'blocked', reasons: ['it modifies project files; DevWorkspace never runs formatters or fixers'], services };
70
+ if (entry.id === 'migrations')
71
+ return { safety: 'blocked', reasons: ['it changes a database schema; DevWorkspace never runs migrations'], services };
72
+ if (DESTRUCTIVE.test(text))
73
+ return { safety: 'blocked', reasons: ['its definition mentions a destructive or schema-changing operation (drop/reset/seed/migrate/flush)'], services };
74
+ if (SERVICE_CHECKS.has(entry.id)) {
75
+ reasons.push(`${entry.id} tests exercise real services${services.length ? ` (the package uses ${services.join(', ')})` : ''}`);
76
+ }
77
+ else if (entry.id === 'unit' && services.length > 0 && /(?:^|\s)(?:run\s+)?test(?:\s|$)/.test(entry.command ?? '') && !/unit/.test(entry.command ?? '')) {
78
+ reasons.push(`the catch-all test script of a package that uses ${services.join(', ')} may include integration tests`);
79
+ }
80
+ if (reasons.length === 0)
81
+ return { safety: 'safe', reasons: [], services };
82
+ if (evidence.hasCredentialFile)
83
+ reasons.push('a credential file exists in the package (never read), so the database target cannot be verified');
84
+ else
85
+ reasons.push('the database target cannot be verified');
86
+ return { safety: 'needs-test-environment', reasons, services };
87
+ }
88
+ const file = (ws) => path.join(ws.localDir, 'test-environment.json');
89
+ export async function loadTestEnv(ws) {
90
+ if (!(await pathExists(file(ws))))
91
+ return [];
92
+ const raw = (await readJsonFile(file(ws)));
93
+ return Array.isArray(raw.declarations) ? raw.declarations : [];
94
+ }
95
+ export function assertSafeTarget(target) {
96
+ const t = target.trim();
97
+ if (t.length < 5 || t.length > 200)
98
+ throw new DevWorkspaceError('USAGE', '--target must be a short description (5-200 characters) of the test environment.');
99
+ if (containsSecret(t) || /[a-z][a-z0-9+.-]*:\/\/\S+/i.test(t) || /(?:password|passwd|pwd|token|secret)\s*[=:]/i.test(t)) {
100
+ throw new DevWorkspaceError('SECURITY', 'The target description looks like a connection string or credential; refusing to store it.', {
101
+ hint: 'Describe the environment in words (for example "disposable docker compose stack"), not how to connect to it.',
102
+ });
103
+ }
104
+ }
105
+ export async function saveDeclaration(ws, d) {
106
+ const all = (await loadTestEnv(ws)).filter((x) => x.package !== d.package);
107
+ await atomicWriteJson(file(ws), { schemaVersion: 1, declarations: [...all, d] });
108
+ }
109
+ export async function removeDeclaration(ws, pkg) {
110
+ const all = await loadTestEnv(ws);
111
+ const rest = all.filter((x) => x.package !== pkg);
112
+ if (rest.length === all.length)
113
+ return false;
114
+ await atomicWriteJson(file(ws), { schemaVersion: 1, declarations: rest });
115
+ return true;
116
+ }
117
+ export function isDeclared(decls, pkg, check) {
118
+ return decls.find((d) => d.package === pkg && d.checks.includes(check));
119
+ }
120
+ //# sourceMappingURL=safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safety.js","sourceRoot":"","sources":["../../src/verification/safety.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG3E,qEAAqE;AACrE,MAAM,YAAY,GAA2B;IAC3C,EAAE,EAAE,YAAY;IAChB,QAAQ,EAAE,YAAY;IACtB,aAAa,EAAE,gBAAgB;IAC/B,MAAM,EAAE,gBAAgB;IACxB,gBAAgB,EAAE,gBAAgB;IAClC,OAAO,EAAE,gBAAgB;IACzB,SAAS,EAAE,gBAAgB;IAC3B,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE,SAAS;IACnB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,OAAO;IACf,IAAI,EAAE,OAAO;CACd,CAAC;AAEF,wGAAwG;AACxG,MAAM,WAAW,GAAG,8GAA8G,CAAC;AACnI,4FAA4F;AAC5F,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AAiBnE,uIAAuI;AACvI,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAY,EAAE,KAAmB;IAC1E,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,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AClD,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC7C,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAwB,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAA2B,EAAE,GAAW,EAAE,KAAa;IAChF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["import path from 'node:path';\nimport type { CommandEntry } from '../config/schemas.js';\nimport { DevWorkspaceError } from '../errors/index.js';\nimport { containsSecret } from '../security/redact.js';\nimport { safeReadText } from '../security/files.js';\nimport { atomicWriteJson, pathExists, readJsonFile } from '../utils/fs.js';\nimport type { Ws } from '../core/workspace.js';\n\n/** Dependencies that mean a package talks to a database or queue. */\nconst SERVICE_DEPS: Record<string, string> = {\n pg: 'PostgreSQL',\n postgres: 'PostgreSQL',\n 'drizzle-orm': 'a SQL database',\n prisma: 'a SQL database',\n '@prisma/client': 'a SQL database',\n typeorm: 'a SQL database',\n sequelize: 'a SQL database',\n knex: 'a SQL database',\n mongoose: 'MongoDB',\n mongodb: 'MongoDB',\n redis: 'Redis',\n ioredis: 'Redis',\n bullmq: 'Redis',\n bull: 'Redis',\n};\n\n/** Words that make a command destructive or schema-changing no matter which check it is filed under. */\nconst DESTRUCTIVE = /(?:^|[\\s:/_-])(?:drop|truncate|flushall|flushdb|reset|seed|migrate)(?:$|[\\s:/_.-])|db:push|--force|rm\\s+-rf/i;\n/** Checks whose job is to exercise real services. They need a declared test environment. */\nconst SERVICE_CHECKS = new Set(['integration', 'security', 'e2e']);\n\nexport type Safety = 'safe' | 'needs-test-environment' | 'blocked';\n\nexport interface CommandSafety {\n safety: Safety;\n reasons: string[];\n /** Services the package is known to use (from its manifest), for the explanation only. */\n services: string[];\n}\n\nexport interface ManifestEvidence {\n scriptBody: string | null;\n services: string[];\n hasCredentialFile: boolean;\n}\n\n/** Read the package manifest next to a command: the script it runs and the services the package depends on. Never reads .env files. */\nexport async function readManifestEvidence(root: string, entry: CommandEntry): Promise<ManifestEvidence> {\n const dir = entry.cwd && entry.cwd !== '.' ? entry.cwd : '';\n const manifest = dir ? `${dir}/package.json` : 'package.json';\n let scriptBody: string | null = null;\n const services = new Set<string>();\n try {\n const text = await safeReadText(root, manifest, 1024 * 1024);\n const json = text ? (JSON.parse(text) as { scripts?: Record<string, string>; dependencies?: Record<string, string>; devDependencies?: Record<string, string> }) : null;\n const script = /#scripts\\.(.+)$/.exec(entry.source ?? '')?.[1];\n if (json && script && typeof json.scripts?.[script] === 'string') scriptBody = json.scripts[script]!;\n for (const dep of Object.keys({ ...json?.dependencies, ...json?.devDependencies })) if (SERVICE_DEPS[dep]) services.add(SERVICE_DEPS[dep]!);\n } catch {\n /* unreadable manifest: no evidence */\n }\n let hasCredentialFile = false;\n for (const name of ['.env', '.env.local', '.env.test', '.env.development']) {\n if (await pathExists(path.join(root, ...(dir ? [dir] : []), name))) hasCredentialFile = true;\n }\n // \"a SQL database\" is only the fallback label for an ORM; drop it once a specific database is known.\n if (services.size > 1) services.delete('a SQL database');\n return { scriptBody, services: [...services].sort(), hasCredentialFile };\n}\n\n/**\n * Decide whether DevWorkspace may run a contract command by itself. Pure; no file is read here.\n * - blocked: modifies project files, changes a schema/data set, or is destructive. Never run automatically.\n * - needs-test-environment: exercises real services or may (a catch-all `test` in a package that uses a database).\n * Runs only after the user declared a test environment for that package and check.\n * - safe: typecheck, lint, build, unit tests and read-only format checks.\n * A database is never judged safe from its name; DevWorkspace does not read connection settings at all.\n */\nexport function classifyCommand(entry: CommandEntry, evidence: ManifestEvidence): CommandSafety {\n const reasons: string[] = [];\n const services = evidence.services;\n const text = `${entry.command ?? ''} ${evidence.scriptBody ?? ''}`;\n if (entry.mutates) return { safety: 'blocked', reasons: ['it modifies project files; DevWorkspace never runs formatters or fixers'], services };\n if (entry.id === 'migrations') return { safety: 'blocked', reasons: ['it changes a database schema; DevWorkspace never runs migrations'], services };\n if (DESTRUCTIVE.test(text)) return { safety: 'blocked', reasons: ['its definition mentions a destructive or schema-changing operation (drop/reset/seed/migrate/flush)'], services };\n if (SERVICE_CHECKS.has(entry.id)) {\n reasons.push(`${entry.id} tests exercise real services${services.length ? ` (the package uses ${services.join(', ')})` : ''}`);\n } else if (entry.id === 'unit' && services.length > 0 && /(?:^|\\s)(?:run\\s+)?test(?:\\s|$)/.test(entry.command ?? '') && !/unit/.test(entry.command ?? '')) {\n reasons.push(`the catch-all test script of a package that uses ${services.join(', ')} may include integration tests`);\n }\n if (reasons.length === 0) return { safety: 'safe', reasons: [], services };\n if (evidence.hasCredentialFile) reasons.push('a credential file exists in the package (never read), so the database target cannot be verified');\n else reasons.push('the database target cannot be verified');\n return { safety: 'needs-test-environment', reasons, services };\n}\n\n// ---------- explicit test-environment declarations (machine-local, never committed) ----------\n\nexport interface TestEnvDeclaration {\n /** Package directory relative to the project root; \".\" for the root. */\n package: string;\n checks: string[];\n /** Human description of the target, e.g. \"docker compose test stack on this laptop\". Never a connection string. */\n target: string;\n declaredAt: string;\n}\n\ninterface TestEnvFile {\n schemaVersion: 1;\n declarations: TestEnvDeclaration[];\n}\n\nconst file = (ws: Ws): string => path.join(ws.localDir, 'test-environment.json');\n\nexport async function loadTestEnv(ws: Ws): Promise<TestEnvDeclaration[]> {\n if (!(await pathExists(file(ws)))) return [];\n const raw = (await readJsonFile(file(ws))) as Partial<TestEnvFile>;\n return Array.isArray(raw.declarations) ? raw.declarations : [];\n}\n\nexport function assertSafeTarget(target: string): void {\n const t = target.trim();\n if (t.length < 5 || t.length > 200) throw new DevWorkspaceError('USAGE', '--target must be a short description (5-200 characters) of the test environment.');\n if (containsSecret(t) || /[a-z][a-z0-9+.-]*:\\/\\/\\S+/i.test(t) || /(?:password|passwd|pwd|token|secret)\\s*[=:]/i.test(t)) {\n throw new DevWorkspaceError('SECURITY', 'The target description looks like a connection string or credential; refusing to store it.', {\n hint: 'Describe the environment in words (for example \"disposable docker compose stack\"), not how to connect to it.',\n });\n }\n}\n\nexport async function saveDeclaration(ws: Ws, d: TestEnvDeclaration): Promise<void> {\n const all = (await loadTestEnv(ws)).filter((x) => x.package !== d.package);\n await atomicWriteJson(file(ws), { schemaVersion: 1, declarations: [...all, d] } satisfies TestEnvFile);\n}\n\nexport async function removeDeclaration(ws: Ws, pkg: string): Promise<boolean> {\n const all = await loadTestEnv(ws);\n const rest = all.filter((x) => x.package !== pkg);\n if (rest.length === all.length) return false;\n await atomicWriteJson(file(ws), { schemaVersion: 1, declarations: rest } satisfies TestEnvFile);\n return true;\n}\n\nexport function isDeclared(decls: TestEnvDeclaration[], pkg: string, check: string): TestEnvDeclaration | undefined {\n return decls.find((d) => d.package === pkg && d.checks.includes(check));\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import type { CommandEntry } from '../config/schemas.js';
2
+ import type { TaskScope } from '../tasks/task.js';
3
+ export type ChangeMap = Record<string, string>;
4
+ /** Files that differ from HEAD right now (modified, staged or untracked), project-relative, with a content hash. */
5
+ export declare function dirtyFiles(root: string): Promise<{
6
+ head: string | null;
7
+ files: ChangeMap;
8
+ } | null>;
9
+ /** Snapshot taken when a task is created: what is already modified is not the task's doing. */
10
+ export declare function captureScope(root: string, now: string): Promise<TaskScope>;
11
+ /** Files that changed since the task started, with their current hashes. Null when that cannot be determined. */
12
+ export declare function changedSince(root: string, scope: TaskScope): Promise<ChangeMap | null>;
13
+ /** Directories (relative to the project root) that have their own checks in the contract, longest first. */
14
+ export declare function packageDirs(contract: CommandEntry[]): string[];
15
+ /**
16
+ * Fingerprint of the changes inside each package. A change under a package belongs to it; a change outside every package
17
+ * (root config, shared tooling) belongs to all of them. "." covers everything. Returns null when nothing is known.
18
+ */
19
+ export declare function scopeByPackage(changes: ChangeMap | null, contract: CommandEntry[]): Record<string, string> | null;
@@ -0,0 +1,119 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { gitAvailable, parsePorcelainZ } from '../git/git.js';
4
+ import { isSensitiveFile } from '../security/files.js';
5
+ import { sha256File, sha256Text } from '../utils/fs.js';
6
+ import { run } from '../utils/proc.js';
7
+ const MAX_TRACKED_FILES = 2000;
8
+ const MAX_HASH_BYTES = 8 * 1024 * 1024;
9
+ /** Documentation and tool-managed folders never decide which package's checks apply. */
10
+ const NOT_CODE = /^(?:\.devworkspace|\.claude|graphify-out)\/|\.(?:md|mdx|rst|txt)$/i;
11
+ async function git(root, args) {
12
+ const r = await run('git', args, { cwd: root, timeoutMs: 30_000 });
13
+ return r.ok ? r.stdout : null;
14
+ }
15
+ async function fileFingerprint(root, rel) {
16
+ const full = path.join(root, ...rel.split('/'));
17
+ try {
18
+ const st = await fs.lstat(full);
19
+ if (!st.isFile())
20
+ return 'not-a-file';
21
+ if (st.size > MAX_HASH_BYTES)
22
+ return `large:${st.size}:${Math.floor(st.mtimeMs)}`;
23
+ return await sha256File(full);
24
+ }
25
+ catch {
26
+ return 'deleted';
27
+ }
28
+ }
29
+ /** Files that differ from HEAD right now (modified, staged or untracked), project-relative, with a content hash. */
30
+ export async function dirtyFiles(root) {
31
+ if (!(await gitAvailable()))
32
+ return null;
33
+ if ((await git(root, ['rev-parse', '--is-inside-work-tree']))?.trim() !== 'true')
34
+ return null;
35
+ const prefix = ((await git(root, ['rev-parse', '--show-prefix'])) ?? '').trim();
36
+ const head = ((await git(root, ['rev-parse', 'HEAD'])) ?? '').trim() || null;
37
+ const status = await git(root, ['status', '--porcelain=v1', '-z', '--untracked-files=all']);
38
+ if (status === null)
39
+ return null;
40
+ const files = {};
41
+ for (const e of parsePorcelainZ(status)) {
42
+ if (e.xy === '!!' || !e.path.startsWith(prefix))
43
+ continue;
44
+ const rel = e.path.slice(prefix.length);
45
+ if (NOT_CODE.test(rel) || isSensitiveFile(rel))
46
+ continue;
47
+ if (Object.keys(files).length >= MAX_TRACKED_FILES)
48
+ break;
49
+ files[rel] = await fileFingerprint(root, rel);
50
+ }
51
+ return { head, files };
52
+ }
53
+ /** Snapshot taken when a task is created: what is already modified is not the task's doing. */
54
+ export async function captureScope(root, now) {
55
+ const d = await dirtyFiles(root);
56
+ return { capturedAt: now, head: d?.head ?? null, baseline: d?.files ?? {} };
57
+ }
58
+ /** Project-relative files committed since `head` (so committing during a task does not hide its changes). */
59
+ async function committedSince(root, head) {
60
+ const prefix = ((await git(root, ['rev-parse', '--show-prefix'])) ?? '').trim();
61
+ const out = await git(root, ['diff', '--name-only', '-z', head, 'HEAD']);
62
+ if (out === null)
63
+ return null;
64
+ return out.split('\0').filter((f) => f && f.startsWith(prefix)).map((f) => f.slice(prefix.length));
65
+ }
66
+ /** Files that changed since the task started, with their current hashes. Null when that cannot be determined. */
67
+ export async function changedSince(root, scope) {
68
+ const now = await dirtyFiles(root);
69
+ if (!now)
70
+ return null;
71
+ const changed = {};
72
+ for (const [rel, hash] of Object.entries(now.files))
73
+ if (scope.baseline[rel] !== hash)
74
+ changed[rel] = hash;
75
+ // A file that was modified at the start and has since been cleaned up (committed or reverted) also changed.
76
+ for (const rel of Object.keys(scope.baseline))
77
+ if (!(rel in now.files))
78
+ changed[rel] = await fileFingerprint(root, rel);
79
+ if (scope.head && now.head && scope.head !== now.head) {
80
+ const committed = await committedSince(root, scope.head);
81
+ if (committed === null)
82
+ return null;
83
+ for (const rel of committed)
84
+ if (!NOT_CODE.test(rel) && !isSensitiveFile(rel) && !(rel in changed))
85
+ changed[rel] = await fileFingerprint(root, rel);
86
+ }
87
+ return changed;
88
+ }
89
+ /** Directories (relative to the project root) that have their own checks in the contract, longest first. */
90
+ export function packageDirs(contract) {
91
+ const dirs = new Set();
92
+ for (const c of contract)
93
+ if (c.available && c.cwd && c.cwd !== '.')
94
+ dirs.add(c.cwd);
95
+ return [...dirs].sort((a, b) => b.length - a.length || a.localeCompare(b));
96
+ }
97
+ /**
98
+ * Fingerprint of the changes inside each package. A change under a package belongs to it; a change outside every package
99
+ * (root config, shared tooling) belongs to all of them. "." covers everything. Returns null when nothing is known.
100
+ */
101
+ export function scopeByPackage(changes, contract) {
102
+ if (!changes)
103
+ return null;
104
+ const files = Object.keys(changes).filter((f) => !NOT_CODE.test(f)).sort();
105
+ if (files.length === 0)
106
+ return null;
107
+ const dirs = packageDirs(contract);
108
+ const owner = (f) => dirs.find((d) => f === d || f.startsWith(`${d}/`)) ?? null;
109
+ const shared = files.filter((f) => owner(f) === null);
110
+ const line = (f) => `${f}:${changes[f]}`;
111
+ const out = { '.': sha256Text(files.map(line).join('\n')) };
112
+ for (const d of dirs) {
113
+ const mine = files.filter((f) => owner(f) === d);
114
+ if (mine.length > 0 || shared.length > 0)
115
+ out[d] = sha256Text([...mine, ...shared].sort().map(line).join('\n'));
116
+ }
117
+ return out;
118
+ }
119
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/verification/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACvC,wFAAwF;AACxF,MAAM,QAAQ,GAAG,oEAAoE,CAAC;AAItF,KAAK,UA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,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport type { CommandEntry } from '../config/schemas.js';\nimport { gitAvailable, parsePorcelainZ } from '../git/git.js';\nimport { isSensitiveFile } from '../security/files.js';\nimport type { TaskScope } from '../tasks/task.js';\nimport { sha256File, sha256Text } from '../utils/fs.js';\nimport { run } from '../utils/proc.js';\n\nconst MAX_TRACKED_FILES = 2000;\nconst MAX_HASH_BYTES = 8 * 1024 * 1024;\n/** Documentation and tool-managed folders never decide which package's checks apply. */\nconst NOT_CODE = /^(?:\\.devworkspace|\\.claude|graphify-out)\\/|\\.(?:md|mdx|rst|txt)$/i;\n\nexport type ChangeMap = Record<string, string>;\n\nasync function git(root: string, args: string[]): Promise<string | null> {\n const r = await run('git', args, { cwd: root, timeoutMs: 30_000 });\n return r.ok ? r.stdout : null;\n}\n\nasync function fileFingerprint(root: string, rel: string): Promise<string> {\n const full = path.join(root, ...rel.split('/'));\n try {\n const st = await fs.lstat(full);\n if (!st.isFile()) return 'not-a-file';\n if (st.size > MAX_HASH_BYTES) return `large:${st.size}:${Math.floor(st.mtimeMs)}`;\n return await sha256File(full);\n } catch {\n return 'deleted';\n }\n}\n\n/** Files that differ from HEAD right now (modified, staged or untracked), project-relative, with a content hash. */\nexport async function dirtyFiles(root: string): Promise<{ head: string | null; files: ChangeMap } | null> {\n if (!(await gitAvailable())) return null;\n if ((await git(root, ['rev-parse', '--is-inside-work-tree']))?.trim() !== 'true') return null;\n const prefix = ((await git(root, ['rev-parse', '--show-prefix'])) ?? '').trim();\n const head = ((await git(root, ['rev-parse', 'HEAD'])) ?? '').trim() || null;\n const status = await git(root, ['status', '--porcelain=v1', '-z', '--untracked-files=all']);\n if (status === null) return null;\n const files: ChangeMap = {};\n for (const e of parsePorcelainZ(status)) {\n if (e.xy === '!!' || !e.path.startsWith(prefix)) continue;\n const rel = e.path.slice(prefix.length);\n if (NOT_CODE.test(rel) || isSensitiveFile(rel)) continue;\n if (Object.keys(files).length >= MAX_TRACKED_FILES) break;\n files[rel] = await fileFingerprint(root, rel);\n }\n return { head, files };\n}\n\n/** Snapshot taken when a task is created: what is already modified is not the task's doing. */\nexport async function captureScope(root: string, now: string): Promise<TaskScope> {\n const d = await dirtyFiles(root);\n return { capturedAt: now, head: d?.head ?? null, baseline: d?.files ?? {} };\n}\n\n/** Project-relative files committed since `head` (so committing during a task does not hide its changes). */\nasync function committedSince(root: string, head: string): Promise<string[] | null> {\n const prefix = ((await git(root, ['rev-parse', '--show-prefix'])) ?? '').trim();\n const out = await git(root, ['diff', '--name-only', '-z', head, 'HEAD']);\n if (out === null) return null;\n return out.split('\\0').filter((f) => f && f.startsWith(prefix)).map((f) => f.slice(prefix.length));\n}\n\n/** Files that changed since the task started, with their current hashes. Null when that cannot be determined. */\nexport async function changedSince(root: string, scope: TaskScope): Promise<ChangeMap | null> {\n const now = await dirtyFiles(root);\n if (!now) return null;\n const changed: ChangeMap = {};\n for (const [rel, hash] of Object.entries(now.files)) if (scope.baseline[rel] !== hash) changed[rel] = hash;\n // A file that was modified at the start and has since been cleaned up (committed or reverted) also changed.\n for (const rel of Object.keys(scope.baseline)) if (!(rel in now.files)) changed[rel] = await fileFingerprint(root, rel);\n if (scope.head && now.head && scope.head !== now.head) {\n const committed = await committedSince(root, scope.head);\n if (committed === null) return null;\n for (const rel of committed) if (!NOT_CODE.test(rel) && !isSensitiveFile(rel) && !(rel in changed)) changed[rel] = await fileFingerprint(root, rel);\n }\n return changed;\n}\n\n/** Directories (relative to the project root) that have their own checks in the contract, longest first. */\nexport function packageDirs(contract: CommandEntry[]): string[] {\n const dirs = new Set<string>();\n for (const c of contract) if (c.available && c.cwd && c.cwd !== '.') dirs.add(c.cwd);\n return [...dirs].sort((a, b) => b.length - a.length || a.localeCompare(b));\n}\n\n/**\n * Fingerprint of the changes inside each package. A change under a package belongs to it; a change outside every package\n * (root config, shared tooling) belongs to all of them. \".\" covers everything. Returns null when nothing is known.\n */\nexport function scopeByPackage(changes: ChangeMap | null, contract: CommandEntry[]): Record<string, string> | null {\n if (!changes) return null;\n const files = Object.keys(changes).filter((f) => !NOT_CODE.test(f)).sort();\n if (files.length === 0) return null;\n const dirs = packageDirs(contract);\n const owner = (f: string): string | null => dirs.find((d) => f === d || f.startsWith(`${d}/`)) ?? null;\n const shared = files.filter((f) => owner(f) === null);\n const line = (f: string): string => `${f}:${changes[f]}`;\n const out: Record<string, string> = { '.': sha256Text(files.map(line).join('\\n')) };\n for (const d of dirs) {\n const mine = files.filter((f) => owner(f) === d);\n if (mine.length > 0 || shared.length > 0) out[d] = sha256Text([...mine, ...shared].sort().map(line).join('\\n'));\n }\n return out;\n}\n"]}
@@ -61,7 +61,7 @@ Setup is non-interactive. It never prompts, so it cannot hang in CI; when it nee
61
61
  1. Reuse an existing `graphify` (PATH, `~/.local/bin`, or where uv/pipx/pip put scripts) after running `graphify --version`.
62
62
  2. Otherwise pick an installer: **uv** (`uv tool install graphifyy`), else **pipx** (`pipx install graphifyy`), else the documented **`pip install --user graphifyy`** if a real Python 3.10+ exists. No separate manager is required when Python or uv is present.
63
63
  3. Run `graphify install --project` (user scope: `graphify install`).
64
- 4. Verify: executable runs, project skill exists, the skill's recorded version matches the CLI, and, because Graphify's hooks call `graphify` by name, that it is on PATH. If not on PATH the status is `DEGRADED` with the folder to add, instead of a false success.
64
+ 4. Verify: executable runs, project skill exists, the skill's recorded version matches the CLI, and, because Graphify's hooks call `graphify` by name, that it is on PATH. If it is not on this process's PATH the status is never a false success, and the advice depends on why: on **Windows**, DevWorkspace reads (never writes) the persistent user and machine PATH from the registry. If the folder is already there, the terminal or VS Code simply started before the change, so the status is `RESTART_REQUIRED` and the fix is to reopen the terminal or restart VS Code (no PATH edit). If it is missing from both, the status is `DEGRADED` with the folder to add. On macOS and Linux, or when the registry cannot be read, the persistent PATH is treated as unknown and the general advice is shown. Quick checks (`devworkspace status`) never query the registry.
65
65
 
66
66
  Python detection runs `--version` on each candidate (`py -3`, `python3`, `python`). On Windows the Microsoft Store `python` shortcut exists on PATH but is not Python, and is correctly rejected.
67
67
 
package/docs/knowledge.md CHANGED
@@ -44,6 +44,8 @@ Uncertainty is first-class: record `INFERRED`/`LOW` or `UNKNOWN` rather than gue
44
44
 
45
45
  Each fact lists the repository files that evidence it and stores their SHA-256 at the time of recording. `devworkspace refresh` re-hashes those sources: a changed or removed source marks the fact `STALE` with a reason. Only stale facts are handed to the agent in the refresh prompt (incremental, not a full re-analysis). The agent re-checks and runs `devworkspace fact verify <key>` (re-hash, mark verified), corrects the fact, or removes it. Facts without sources cannot be proven stale, so cite files.
46
46
 
47
+ Generated files are not evidence by themselves: re-running `analyze` rewrites `.devworkspace/analysis/*`, which must not invalidate unrelated facts. A fact may cite a section of the discovery report as `.devworkspace/analysis/discovery.json#ci` (fingerprint of that section only), and a bare `discovery.json` citation is narrowed to the section named by the fact's key (`ci.none` depends on `ci`). Any other generated file is ignored. `status`, `refresh --dry-run` and `doctor` all use the same read-only check, so they agree, and each stale fact says which evidence changed. A fact recorded before a dependency was tracked adopts its current fingerprint instead of going stale.
48
+
47
49
  Content hashing is deliberately conservative: *any* byte change to a cited file triggers re-validation. It over-reports rather than silently trusting old context.
48
50
 
49
51
  Deterministic (`detector`) facts are simply re-derived on every `analyze`/`refresh`; ones that no longer apply are removed (they are derived data and come back if the evidence returns), so they never produce a warning nobody can clear.
package/docs/testing.md CHANGED
@@ -15,11 +15,33 @@
15
15
 
16
16
  `required` is `yes` (always applies to code changes), `context` (only when relevant to the change) or `no`. Entries you or the agent edit by hand get `origin: "user"` and are never overwritten by later analysis.
17
17
 
18
+ Every `package.json` in the repository is read (not only the root; manifests in `fixtures/`, `examples/`, `docs/` and `node_modules` are ignored), and each package's commands are recorded **with the directory to run them in** (`cwd`, relative, POSIX), only for scripts that package actually defines. A backend `npm run test:unit` is never mixed up with a frontend `npm test`. Each package uses the package manager its own lockfile indicates. Commands are never executed by DevWorkspace.
19
+
20
+ Re-running `analyze` keeps any command with `origin: "user"` (confirmed by a person or by Claude during onboarding) exactly as written, even when a later analysis finds nothing; a user command with no `cwd` covers its whole check, one with a `cwd` covers only that directory. `discovery.json` always holds the pure detection; `commands.json` holds the merged contract.
21
+
18
22
  Sources: `package.json` scripts (matched by common names), plus conventions for Python (pytest/ruff/mypy/black/alembic), Go, Rust, Maven and Gradle. npm's default `"no test specified"` placeholder is ignored.
19
23
 
24
+ Formatters are listed too. A `format` script that rewrites files is recorded with `"mutates": true` and `required: "no"`; a `format:check` (or a `format` that only checks) is read-only. DevWorkspace never runs a command marked `mutates`.
25
+
20
26
  ### Commands are untrusted input
21
27
 
22
- Everything marked `origin: "repository-script"` comes from files in the repository. DevWorkspace **never runs these commands itself**; the agent does, and the generated instructions tell it to read what a script does before running unfamiliar ones, especially where scripts might deploy, migrate or write over the network.
28
+ Everything marked `origin: "repository-script"` comes from files in the repository. `analyze`, `status`, `doctor` and `refresh` never run any of them. Only `devworkspace task run` executes a contract command, as an argument vector (never through a shell), and only after the safety rules below. The generated instructions still tell the agent to read what an unfamiliar script does first.
29
+
30
+ ### What `task run` will and will not run
31
+
32
+ | Command | Runs? |
33
+ | --- | --- |
34
+ | typecheck, lint, build, unit tests, read-only format checks | yes |
35
+ | migrations; anything whose definition mentions drop, truncate, reset, seed, migrate, flush; any command marked `mutates` | **never** |
36
+ | integration, security and e2e checks; a catch-all `test` script in a package that depends on a database or Redis | only after you declare a test environment for that package and check |
37
+
38
+ DevWorkspace does not read `.env` files or connection settings, so it **cannot verify which database a test would use**, and it does not guess from names (a database called `test` is not treated as safe). The only way to allow such a check is an explicit, local declaration by a person:
39
+
40
+ ```bash
41
+ devworkspace testenv declare --package backend --check integration --target "disposable docker compose stack" --yes
42
+ ```
43
+
44
+ This records your assertion in `.devworkspace/local/test-environment.json` (git-ignored). Targets that look like connection strings or credentials are refused. A refused check is recorded as `COULD_NOT_RUN`, never as a pass.
23
45
 
24
46
  ## Task-specific verification
25
47
 
@@ -28,9 +50,14 @@ Questions need none; docs need only documentation checks; bugs, features and ref
28
50
  ```bash
29
51
  devworkspace task tests <id> --phase baseline --passed 214 --failed 3 # before changing code
30
52
  devworkspace task tests <id> --phase after --passed 218 --failed 3
31
- devworkspace task verify <id> unit pass
53
+ devworkspace task run <id> typecheck # executes the contract command for every package the task changed
54
+ devworkspace task verify <id> review pass # a report; recorded as a claim, not as an executed result
32
55
  ```
33
56
 
57
+ ### Package-aware completion
58
+
59
+ A task records, when it is created, which files were already modified. When you complete it, DevWorkspace works out which files changed since, assigns them to packages (the `cwd` directories of the contract; a change outside every package counts for all of them) and requires **executed** evidence for each applicable check **in each changed package**, taken after the last change. A backend-only build is not evidence for frontend changes. A pass that was only reported with `task verify` is a claim and does not satisfy the gate unless you add `--reason user-override`. Tasks created by older versions keep the original rules.
60
+
34
61
  Pre-existing failures are recorded, not blamed on new work. Regressions block completion.
35
62
 
36
63
  ## Failure reporting