devworkspace 0.2.1 → 0.3.0

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 +35 -0
  2. package/README.md +4 -3
  3. package/dist/agents/claude/content.js +4 -3
  4. package/dist/agents/claude/content.js.map +1 -1
  5. package/dist/cli/args.d.ts +19 -0
  6. package/dist/cli/args.js +6 -0
  7. package/dist/cli/args.js.map +1 -1
  8. package/dist/cli/help.js +32 -9
  9. package/dist/cli/help.js.map +1 -1
  10. package/dist/cli/render.d.ts +9 -1
  11. package/dist/cli/render.js +89 -11
  12. package/dist/cli/render.js.map +1 -1
  13. package/dist/cli/run.js +54 -8
  14. package/dist/cli/run.js.map +1 -1
  15. package/dist/config/schemas.d.ts +5 -0
  16. package/dist/config/schemas.js +2 -0
  17. package/dist/config/schemas.js.map +1 -1
  18. package/dist/discovery/cache.d.ts +19 -0
  19. package/dist/discovery/cache.js +50 -0
  20. package/dist/discovery/cache.js.map +1 -0
  21. package/dist/discovery/commands.js +17 -3
  22. package/dist/discovery/commands.js.map +1 -1
  23. package/dist/discovery/detect.d.ts +6 -0
  24. package/dist/discovery/detect.js +12 -6
  25. package/dist/discovery/detect.js.map +1 -1
  26. package/dist/discovery/docs.d.ts +10 -0
  27. package/dist/discovery/docs.js +52 -0
  28. package/dist/discovery/docs.js.map +1 -0
  29. package/dist/discovery/entrypoints.d.ts +20 -0
  30. package/dist/discovery/entrypoints.js +67 -0
  31. package/dist/discovery/entrypoints.js.map +1 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +1 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/integrations/adapters/claudePlugin.js +12 -3
  36. package/dist/integrations/adapters/claudePlugin.js.map +1 -1
  37. package/dist/knowledge/facts.d.ts +59 -2
  38. package/dist/knowledge/facts.js +115 -17
  39. package/dist/knowledge/facts.js.map +1 -1
  40. package/dist/prompts/onboarding.js +6 -3
  41. package/dist/prompts/onboarding.js.map +1 -1
  42. package/dist/services/analysis.d.ts +7 -1
  43. package/dist/services/analysis.js +17 -4
  44. package/dist/services/analysis.js.map +1 -1
  45. package/dist/services/doctor.js +14 -3
  46. package/dist/services/doctor.js.map +1 -1
  47. package/dist/services/knowledge.d.ts +17 -0
  48. package/dist/services/knowledge.js +28 -2
  49. package/dist/services/knowledge.js.map +1 -1
  50. package/dist/services/refresh.js +6 -6
  51. package/dist/services/refresh.js.map +1 -1
  52. package/dist/services/status.d.ts +11 -2
  53. package/dist/services/status.js +11 -9
  54. package/dist/services/status.js.map +1 -1
  55. package/dist/services/taskContext.d.ts +59 -0
  56. package/dist/services/taskContext.js +164 -0
  57. package/dist/services/taskContext.js.map +1 -0
  58. package/dist/services/tasks.d.ts +2 -0
  59. package/dist/services/tasks.js +20 -12
  60. package/dist/services/tasks.js.map +1 -1
  61. package/dist/services/verify.d.ts +47 -0
  62. package/dist/services/verify.js +172 -0
  63. package/dist/services/verify.js.map +1 -0
  64. package/dist/tasks/routing.js +10 -3
  65. package/dist/tasks/routing.js.map +1 -1
  66. package/dist/tasks/task.d.ts +49 -5
  67. package/dist/tasks/task.js +68 -11
  68. package/dist/tasks/task.js.map +1 -1
  69. package/dist/verification/safety.d.ts +38 -0
  70. package/dist/verification/safety.js +120 -0
  71. package/dist/verification/safety.js.map +1 -0
  72. package/dist/verification/scope.d.ts +19 -0
  73. package/dist/verification/scope.js +119 -0
  74. package/dist/verification/scope.js.map +1 -0
  75. package/docs/benchmarking.md +19 -0
  76. package/docs/knowledge.md +19 -0
  77. package/docs/testing.md +25 -2
  78. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/services/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAqB,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAA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AC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC;QAC9H,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { SCHEMA_VERSION, validateCommands, type CommandEntry } from '../config/schemas.js';\nimport { DevWorkspaceError } from '../errors/index.js';\nimport { loadProject, requireWorkspace, type Ws } from '../core/workspace.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { classifyRequest, WORKFLOWS, type Classification, type WorkflowSpec } from '../tasks/routing.js';\nimport {\n assertNoSecrets,\n createTaskObject,\n evaluateGate,\n listTasks,\n loadTask,\n requiredChecksFor,\n saveTask,\n transitionTask,\n type GateResult,\n type Task,\n type TaskStatus,\n type TaskType,\n type VerifyStatus,\n TASK_STATUSES,\n TASK_TYPES,\n VERIFY_STATUSES,\n} from '../tasks/task.js';\nimport { pathExists } from '../utils/fs.js';\nimport { isoNow, mutate, type ServiceOptions } from './common.js';\n\nasync function loadContract(ws: Ws): Promise<CommandEntry[]> {\n if (!(await pathExists(ws.commands))) return [];\n return (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;\n}\n\nexport interface CreateTaskResult {\n task: Task;\n classification: Classification;\n workflow: WorkflowSpec;\n}\n\nexport async function createTask(o: ServiceOptions, input: { text: string; type?: string; title?: string }): Promise<CreateTaskResult> {\n return mutate(o, async (ws) => {\n const project = await loadProject(ws);\n const classification = classifyRequest(input.text);\n let type: TaskType = classification.type;\n if (input.type) {\n const up = input.type.toUpperCase();\n if (!(TASK_TYPES as readonly string[]).includes(up)) {\n throw new DevWorkspaceError('USAGE', `Unknown task type \"${input.type}\".`, { hint: `Use one of: ${TASK_TYPES.join(', ')}.` });\n }\n type = up as TaskType;\n }\n const contract = await loadContract(ws);\n let verification = requiredChecksFor(type, contract, project.settings.review);\n // Explicit user constraints stay visible: the check is kept but recorded as skipped at the user's request.\n const skipChecks = new Set<string>();\n if (classification.constraints.includes('no-e2e')) skipChecks.add('e2e');\n if (classification.constraints.includes('no-tests')) skipChecks.add('unit').add('integration').add('e2e');\n verification = verification.map((v) => (skipChecks.has(v.check) ? { ...v, status: 'SKIPPED' as const, reason: 'user-override' } : v));\n const title = (input.title ?? input.text).replace(/\\s+/g, ' ').trim().slice(0, 100);\n const task = createTaskObject({ title, type, description: input.text, verification, constraints: classification.constraints }, isoNow(o));\n await saveTask(ws, task);\n return { task, classification: { ...classification, type }, workflow: WORKFLOWS[type] };\n });\n}\n\nexport async function showTask(o: ServiceOptions, id: string): Promise<{ task: Task; gate: GateResult }> {\n const ws = await requireWorkspace(o.cwd);\n const task = await loadTask(ws, id);\n return { task, gate: evaluateGate(task) };\n}\n\nexport async function listTasksService(o: ServiceOptions, includeCompleted = false): ReturnType<typeof listTasks> {\n const ws = await requireWorkspace(o.cwd);\n return listTasks(ws, { includeCompleted });\n}\n\nexport interface TaskPatch {\n title?: string;\n summary?: string;\n criteria?: string[];\n plan?: string[];\n areas?: string[];\n decisions?: string[];\n blockers?: string[];\n clearBlockers?: boolean;\n require?: string[];\n}\n\nexport async function updateTask(o: ServiceOptions, id: string, patch: TaskPatch): Promise<Task> {\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n if (patch.title) task.title = patch.title.trim().slice(0, 200);\n if (patch.summary !== undefined) task.completionSummary = patch.summary.trim().slice(0, 4000);\n task.acceptanceCriteria.push(...(patch.criteria ?? []));\n task.plan.push(...(patch.plan ?? []));\n task.affectedAreas.push(...(patch.areas ?? []).filter((a) => !task.affectedAreas.includes(a)));\n task.decisions.push(...(patch.decisions ?? []));\n if (patch.clearBlockers) task.blockers = [];\n task.blockers.push(...(patch.blockers ?? []));\n for (const check of patch.require ?? []) {\n if (!task.verification.some((v) => v.check === check)) task.verification.push({ check, required: true, status: 'PENDING' });\n }\n task.updatedAt = isoNow(o);\n assertNoSecrets(task);\n await saveTask(ws, task);\n return task;\n });\n}\n\nexport async function setTaskStatus(o: ServiceOptions, id: string, status: string, note?: string): Promise<{ task: Task; gate: GateResult | null }> {\n const up = status.toUpperCase();\n if (!(TASK_STATUSES as readonly string[]).includes(up)) {\n throw new DevWorkspaceError('USAGE', `Unknown task status \"${status}\".`, { hint: `Use one of: ${TASK_STATUSES.join(', ')}.` });\n }\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n const gate = transitionTask(task, up as TaskStatus, isoNow(o), note);\n if (up === 'BLOCKED' && note) task.blockers.push(note.slice(0, 300));\n await saveTask(ws, task);\n return { task, gate };\n });\n}\n\nexport async function recordVerification(\n o: ServiceOptions,\n id: string,\n check: string,\n result: string,\n extra: { reason?: string; detail?: string } = {},\n): Promise<Task> {\n const status = result.toUpperCase();\n const normalized = status === 'SKIP' ? 'SKIPPED' : status;\n if (!(VERIFY_STATUSES as readonly string[]).includes(normalized)) {\n throw new DevWorkspaceError('USAGE', `Unknown result \"${result}\".`, { hint: 'Use pass, fail, skip or pending.' });\n }\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n let item = task.verification.find((v) => v.check === check);\n if (!item) {\n item = { check, required: false, status: 'PENDING' };\n task.verification.push(item);\n }\n item.status = normalized as VerifyStatus;\n item.updatedAt = isoNow(o);\n if (extra.reason) item.reason = extra.reason;\n else delete item.reason;\n if (extra.detail) item.detail = extra.detail.slice(0, 500);\n task.updatedAt = item.updatedAt;\n assertNoSecrets(task);\n await saveTask(ws, task);\n return task;\n });\n}\n\nexport async function recordTests(o: ServiceOptions, id: string, phase: 'baseline' | 'after', passed: number, failed: number): Promise<Task> {\n if (!Number.isInteger(passed) || !Number.isInteger(failed) || passed < 0 || failed < 0) {\n throw new DevWorkspaceError('USAGE', '--passed and --failed must be non-negative integers.');\n }\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n task.tests[phase] = { passed, failed };\n task.updatedAt = isoNow(o);\n await saveTask(ws, task);\n return task;\n });\n}\n\nexport async function attestTask(\n o: ServiceOptions,\n id: string,\n flags: { userWorkIntact?: boolean; knowledgeReviewed?: boolean; finalStateInspected?: boolean },\n): Promise<Task> {\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n task.attestations = { ...task.attestations, ...Object.fromEntries(Object.entries(flags).filter(([, v]) => v !== undefined)) };\n task.updatedAt = isoNow(o);\n await saveTask(ws, task);\n return task;\n });\n}\n"]}
1
+ {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/services/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAA0C,MAAM,qBAAqB,CAAC;AACzG,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,cAAc,EAOd,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAuB,MAAM,aAAa,CAAC;AAQlE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,CAAiB,EAAE,KAAsD;IACxG,OAAO,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC5B,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,cAAc,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,IAAI,GAAa,cAAc,CAAC,IAAI,CAAC;QACzC,IAAI,K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C;QACzB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,CAAiB,EACjB,EAAU,EACV,KAA+F;IAE/F,OAAO,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC5B,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC;QAC9H,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { DevWorkspaceError } from '../errors/index.js';\nimport { loadProject, requireWorkspace } from '../core/workspace.js';\nimport { captureScope } from '../verification/scope.js';\nimport { gateContext, loadContract } from './verify.js';\nimport { classifyRequest, WORKFLOWS, type Classification, type WorkflowSpec } from '../tasks/routing.js';\nimport {\n assertNoSecrets,\n createTaskObject,\n evaluateGate,\n nextRequiredStep,\n listTasks,\n loadTask,\n requiredChecksFor,\n saveTask,\n transitionTask,\n type Evidence,\n type GateResult,\n type Task,\n type TaskStatus,\n type TaskType,\n type VerifyStatus,\n TASK_STATUSES,\n TASK_TYPES,\n VERIFY_STATUSES,\n} from '../tasks/task.js';\nimport { isoNow, mutate, type ServiceOptions } from './common.js';\n\nexport interface CreateTaskResult {\n task: Task;\n classification: Classification;\n workflow: WorkflowSpec;\n}\n\nexport async function createTask(o: ServiceOptions, input: { text: string; type?: string; title?: string }): Promise<CreateTaskResult> {\n return mutate(o, async (ws) => {\n const project = await loadProject(ws);\n const classification = classifyRequest(input.text);\n let type: TaskType = classification.type;\n if (input.type) {\n const up = input.type.toUpperCase();\n if (!(TASK_TYPES as readonly string[]).includes(up)) {\n throw new DevWorkspaceError('USAGE', `Unknown task type \"${input.type}\".`, { hint: `Use one of: ${TASK_TYPES.join(', ')}.` });\n }\n type = up as TaskType;\n }\n const contract = await loadContract(ws);\n let verification = requiredChecksFor(type, contract, project.settings.review);\n // Explicit user constraints stay visible: the check is kept but recorded as skipped at the user's request.\n const skipChecks = new Set<string>();\n if (classification.constraints.includes('no-e2e')) skipChecks.add('e2e');\n if (classification.constraints.includes('no-tests')) skipChecks.add('unit').add('integration').add('e2e');\n verification = verification.map((v) => (skipChecks.has(v.check) ? { ...v, status: 'SKIPPED' as const, reason: 'user-override' } : v));\n const title = (input.title ?? input.text).replace(/\\s+/g, ' ').trim().slice(0, 100);\n const task = createTaskObject({ title, type, description: input.text, verification, constraints: classification.constraints }, isoNow(o));\n task.scope = await captureScope(ws.root, isoNow(o));\n await saveTask(ws, task);\n return { task, classification: { ...classification, type }, workflow: WORKFLOWS[type] };\n });\n}\n\nexport async function showTask(o: ServiceOptions, id: string): Promise<{ task: Task; gate: GateResult; next: string }> {\n const ws = await requireWorkspace(o.cwd);\n const task = await loadTask(ws, id);\n const ctx = await gateContext(ws, task);\n return { task, gate: evaluateGate(task, ctx), next: nextRequiredStep(task, ctx) };\n}\n\nexport async function listTasksService(o: ServiceOptions, includeCompleted = false): ReturnType<typeof listTasks> {\n const ws = await requireWorkspace(o.cwd);\n return listTasks(ws, { includeCompleted });\n}\n\nexport interface TaskPatch {\n title?: string;\n summary?: string;\n criteria?: string[];\n plan?: string[];\n areas?: string[];\n decisions?: string[];\n blockers?: string[];\n clearBlockers?: boolean;\n require?: string[];\n}\n\nexport async function updateTask(o: ServiceOptions, id: string, patch: TaskPatch): Promise<Task> {\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n if (patch.title) task.title = patch.title.trim().slice(0, 200);\n if (patch.summary !== undefined) task.completionSummary = patch.summary.trim().slice(0, 4000);\n task.acceptanceCriteria.push(...(patch.criteria ?? []));\n task.plan.push(...(patch.plan ?? []));\n task.affectedAreas.push(...(patch.areas ?? []).filter((a) => !task.affectedAreas.includes(a)));\n task.decisions.push(...(patch.decisions ?? []));\n if (patch.clearBlockers) task.blockers = [];\n task.blockers.push(...(patch.blockers ?? []));\n for (const check of patch.require ?? []) {\n const existing = task.verification.find((v) => v.check === check);\n if (existing) existing.required = true;\n else task.verification.push({ check, required: true, status: 'PENDING' });\n }\n task.updatedAt = isoNow(o);\n assertNoSecrets(task);\n await saveTask(ws, task);\n return task;\n });\n}\n\nexport async function setTaskStatus(o: ServiceOptions, id: string, status: string, note?: string): Promise<{ task: Task; gate: GateResult | null }> {\n const up = status.toUpperCase();\n if (!(TASK_STATUSES as readonly string[]).includes(up)) {\n throw new DevWorkspaceError('USAGE', `Unknown task status \"${status}\".`, { hint: `Use one of: ${TASK_STATUSES.join(', ')}.` });\n }\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n const gate = transitionTask(task, up as TaskStatus, isoNow(o), note, up === 'COMPLETED' ? await gateContext(ws, task) : undefined);\n if (up === 'BLOCKED' && note) task.blockers.push(note.slice(0, 300));\n await saveTask(ws, task);\n return { task, gate };\n });\n}\n\nexport async function recordVerification(\n o: ServiceOptions,\n id: string,\n check: string,\n result: string,\n extra: { reason?: string; detail?: string; package?: string } = {},\n): Promise<Task> {\n const status = result.toUpperCase();\n const normalized = status === 'SKIP' ? 'SKIPPED' : status;\n if (!(VERIFY_STATUSES as readonly string[]).includes(normalized)) {\n throw new DevWorkspaceError('USAGE', `Unknown result \"${result}\".`, { hint: 'Use pass, fail, skip or pending.' });\n }\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n let item = task.verification.find((v) => v.check === check);\n if (!item) {\n item = { check, required: false, status: 'PENDING' };\n task.verification.push(item);\n }\n item.status = normalized as VerifyStatus;\n item.updatedAt = isoNow(o);\n // A reported pass is a claim: DevWorkspace did not see the command run. It is kept as such, per package, and the\n // completion gate of a scoped task only accepts it with an explicit user override.\n if (normalized === 'PASS') {\n const pkg = !extra.package || extra.package === '' ? '.' : extra.package.replace(/\\/+$/, '');\n const claim: Evidence = { kind: 'claimed', at: item.updatedAt, package: pkg, ...(extra.reason === 'user-override' ? { userOverride: true } : {}), ...(extra.detail ? { note: extra.detail.slice(0, 200) } : {}) };\n // Never replace something DevWorkspace observed with somebody's say-so.\n if (!item.evidence?.some((e) => e.package === pkg && e.kind === 'executed')) item.evidence = [...(item.evidence ?? []).filter((e) => e.package !== pkg), claim];\n }\n if (extra.reason) item.reason = extra.reason;\n else delete item.reason;\n if (extra.detail) item.detail = extra.detail.slice(0, 500);\n task.updatedAt = item.updatedAt;\n assertNoSecrets(task);\n await saveTask(ws, task);\n return task;\n });\n}\n\nexport async function recordTests(o: ServiceOptions, id: string, phase: 'baseline' | 'after', passed: number, failed: number): Promise<Task> {\n if (!Number.isInteger(passed) || !Number.isInteger(failed) || passed < 0 || failed < 0) {\n throw new DevWorkspaceError('USAGE', '--passed and --failed must be non-negative integers.');\n }\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n task.tests[phase] = { passed, failed };\n task.updatedAt = isoNow(o);\n await saveTask(ws, task);\n return task;\n });\n}\n\nexport async function attestTask(\n o: ServiceOptions,\n id: string,\n flags: { userWorkIntact?: boolean; knowledgeReviewed?: boolean; finalStateInspected?: boolean },\n): Promise<Task> {\n return mutate(o, async (ws) => {\n const task = await loadTask(ws, id);\n task.attestations = { ...task.attestations, ...Object.fromEntries(Object.entries(flags).filter(([, v]) => v !== undefined)) };\n task.updatedAt = isoNow(o);\n await saveTask(ws, task);\n return task;\n });\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import { type CommandEntry } from '../config/schemas.js';
2
+ import { type Ws } from '../core/workspace.js';
3
+ import { type GateContext, type Task } from '../tasks/task.js';
4
+ import { type CommandSafety, type TestEnvDeclaration } from '../verification/safety.js';
5
+ import { type ServiceOptions } from './common.js';
6
+ export declare function loadContract(ws: Ws): Promise<CommandEntry[]>;
7
+ /** Contract plus what the task has changed per package: everything the completion gate needs to judge it. */
8
+ export declare function gateContext(ws: Ws, task: Task, contract?: CommandEntry[]): Promise<GateContext>;
9
+ export type RunOutcome = 'passed' | 'failed' | 'refused' | 'not-affected';
10
+ export interface PackageRun {
11
+ package: string;
12
+ command: string | null;
13
+ outcome: RunOutcome;
14
+ exitCode?: number | null;
15
+ durationMs?: number;
16
+ /** Why DevWorkspace did not run it, or the scrubbed tail of a failure. */
17
+ reason?: string;
18
+ safety: CommandSafety['safety'];
19
+ }
20
+ export interface RunCheckResult {
21
+ task: Task;
22
+ check: string;
23
+ runs: PackageRun[];
24
+ }
25
+ export declare function splitCommand(command: string): string[] | null;
26
+ /**
27
+ * PATH lookup on Windows finds the extensionless Unix shell script (`npm`) before `npm.cmd`, and that cannot be
28
+ * spawned. Prefer the Windows launcher next to it. Elsewhere the lookup result is used as is.
29
+ */
30
+ export declare function resolveExecutable(found: string | null, name: string, platform: NodeJS.Platform, exists: (p: string) => Promise<boolean>): Promise<string>;
31
+ /**
32
+ * Run one contract check for the packages the task changed, and record what really happened. DevWorkspace only runs
33
+ * read-only, non-destructive commands; anything that may touch a database runs only after the user declared a test
34
+ * environment for that package and check. Refusals are recorded as "could not run", never as a pass.
35
+ */
36
+ export declare function runTaskCheck(o: ServiceOptions, id: string, check: string, opts?: {
37
+ package?: string;
38
+ timeoutMs?: number;
39
+ }): Promise<RunCheckResult>;
40
+ export declare function declareTestEnv(o: ServiceOptions, input: {
41
+ package: string;
42
+ checks: string[];
43
+ target: string;
44
+ yes: boolean;
45
+ }): Promise<TestEnvDeclaration>;
46
+ export declare function listTestEnv(o: ServiceOptions): Promise<TestEnvDeclaration[]>;
47
+ export declare function revokeTestEnv(o: ServiceOptions, pkg: string): Promise<boolean>;
@@ -0,0 +1,172 @@
1
+ import path from 'node:path';
2
+ import { SCHEMA_VERSION, validateCommands } from '../config/schemas.js';
3
+ import { requireWorkspace } from '../core/workspace.js';
4
+ import { readVersioned } from '../core/versioned.js';
5
+ import { DevWorkspaceError } from '../errors/index.js';
6
+ import { createRunner } from '../integrations/exec.js';
7
+ import { scrub } from '../integrations/manager.js';
8
+ import { loadTask, saveTask, assertNoSecrets } from '../tasks/task.js';
9
+ import { pathExists } from '../utils/fs.js';
10
+ import { classifyCommand, isDeclared, loadTestEnv, readManifestEvidence, assertSafeTarget, removeDeclaration, saveDeclaration } from '../verification/safety.js';
11
+ import { changedSince, scopeByPackage } from '../verification/scope.js';
12
+ import { isoNow, mutate } from './common.js';
13
+ export async function loadContract(ws) {
14
+ if (!(await pathExists(ws.commands)))
15
+ return [];
16
+ return (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;
17
+ }
18
+ /** Contract plus what the task has changed per package: everything the completion gate needs to judge it. */
19
+ export async function gateContext(ws, task, contract) {
20
+ const checks = contract ?? (await loadContract(ws));
21
+ const scope = task.scope ? scopeByPackage(await changedSince(ws.root, task.scope), checks) : null;
22
+ return { contract: checks, scope };
23
+ }
24
+ /** Anything a shell would interpret. Contract commands are run as an argument vector, never through a shell. */
25
+ const SHELL_SYNTAX = /[&|;<>$`(){}"'\\*?!%^\r\n]/;
26
+ export function splitCommand(command) {
27
+ if (SHELL_SYNTAX.test(command))
28
+ return null;
29
+ const parts = command.trim().split(/\s+/);
30
+ return parts[0] ? parts : null;
31
+ }
32
+ const DEFAULT_TIMEOUT_MS = 10 * 60_000;
33
+ /**
34
+ * PATH lookup on Windows finds the extensionless Unix shell script (`npm`) before `npm.cmd`, and that cannot be
35
+ * spawned. Prefer the Windows launcher next to it. Elsewhere the lookup result is used as is.
36
+ */
37
+ export async function resolveExecutable(found, name, platform, exists) {
38
+ if (!found)
39
+ return name;
40
+ if (platform !== 'win32' || /\.(?:exe|cmd|bat|com)$/i.test(found))
41
+ return found;
42
+ for (const ext of ['.cmd', '.exe', '.bat'])
43
+ if (await exists(found + ext))
44
+ return found + ext;
45
+ return found;
46
+ }
47
+ /**
48
+ * Run one contract check for the packages the task changed, and record what really happened. DevWorkspace only runs
49
+ * read-only, non-destructive commands; anything that may touch a database runs only after the user declared a test
50
+ * environment for that package and check. Refusals are recorded as "could not run", never as a pass.
51
+ */
52
+ export async function runTaskCheck(o, id, check, opts = {}) {
53
+ const ws = await requireWorkspace(o.cwd);
54
+ const task = await loadTask(ws, id);
55
+ const contract = await loadContract(ws);
56
+ const wanted = opts.package ? (opts.package === '.' || opts.package === '' ? '.' : opts.package.replace(/\/+$/, '')) : undefined;
57
+ const entries = contract.filter((c) => c.id === check && c.available && (wanted === undefined || (c.cwd ?? '.') === wanted));
58
+ if (entries.length === 0) {
59
+ throw new DevWorkspaceError('NOT_FOUND', `The testing contract has no "${check}" command${wanted ? ` for package "${wanted}"` : ''}.`, {
60
+ hint: 'See the contract with "devworkspace context", or add the command to .devworkspace/context/commands.json.',
61
+ });
62
+ }
63
+ const scope = (await gateContext(ws, task, contract)).scope;
64
+ const decls = await loadTestEnv(ws);
65
+ const runner = o.runner ?? createRunner(o.env ?? process.env, o.platform);
66
+ const runs = [];
67
+ const evidence = [];
68
+ for (const entry of entries) {
69
+ const pkg = entry.cwd ?? '.';
70
+ const base = { package: pkg, command: entry.command };
71
+ const fingerprint = scope === null ? 'unknown' : scope[pkg];
72
+ if (wanted === undefined && fingerprint === undefined) {
73
+ runs.push({ ...base, outcome: 'not-affected', safety: 'safe', reason: 'the task changed nothing in this package' });
74
+ continue;
75
+ }
76
+ const manifest = await readManifestEvidence(ws.root, entry);
77
+ const cls = classifyCommand(entry, manifest);
78
+ if (cls.safety === 'blocked') {
79
+ runs.push({ ...base, outcome: 'refused', safety: cls.safety, reason: `refused: ${cls.reasons.join('; ')}` });
80
+ continue;
81
+ }
82
+ if (cls.safety === 'needs-test-environment' && !isDeclared(decls, pkg, check)) {
83
+ runs.push({
84
+ ...base,
85
+ outcome: 'refused',
86
+ safety: cls.safety,
87
+ reason: `refused: ${cls.reasons.join('; ')}. Run it yourself against a test environment you control, then declare it with: devworkspace testenv declare --package ${pkg} --check ${check} --target "<description>" --yes`,
88
+ });
89
+ continue;
90
+ }
91
+ const argv = splitCommand(entry.command ?? '');
92
+ if (!argv) {
93
+ runs.push({ ...base, outcome: 'refused', safety: cls.safety, reason: 'refused: the command uses shell syntax, and DevWorkspace never runs a shell' });
94
+ continue;
95
+ }
96
+ const exe = await resolveExecutable(await runner.which(argv[0]), argv[0], o.platform ?? process.platform, pathExists);
97
+ const started = Date.now();
98
+ const r = await runner.run({ command: exe, args: argv.slice(1), cwd: pkg === '.' ? ws.root : path.join(ws.root, ...pkg.split('/')), timeoutMs: opts.timeoutMs ?? DEFAULT_TIMEOUT_MS });
99
+ const durationMs = Date.now() - started;
100
+ if (r.code === null && !r.timedOut && r.error) {
101
+ // The command never started (missing executable, bad cwd): that is "could not run", not a test failure.
102
+ runs.push({ ...base, outcome: 'refused', safety: cls.safety, reason: `could not start: ${scrub(r.error)}` });
103
+ continue;
104
+ }
105
+ const passed = r.ok && r.code === 0;
106
+ const tail = passed ? undefined : scrub((r.error ?? '') || (r.timedOut ? 'timed out' : '') || r.stderr.slice(-300) || r.stdout.slice(-300) || `exit ${r.code}`);
107
+ runs.push({ ...base, outcome: passed ? 'passed' : 'failed', safety: cls.safety, exitCode: r.code, durationMs, ...(tail ? { reason: tail } : {}) });
108
+ evidence.push({ kind: 'executed', at: isoNow(o), package: pkg, command: entry.command ?? undefined, exitCode: r.code, durationMs, scope: fingerprint ?? 'unknown', ...(tail ? { note: tail } : {}) });
109
+ }
110
+ const updated = await mutate(o, async (w) => {
111
+ const t = await loadTask(w, id);
112
+ let item = t.verification.find((v) => v.check === check);
113
+ if (!item) {
114
+ item = { check, required: false, status: 'PENDING' };
115
+ t.verification.push(item);
116
+ }
117
+ for (const e of evidence)
118
+ item.evidence = [...(item.evidence ?? []).filter((x) => x.package !== e.package), e];
119
+ item.status = summarize(item, runs);
120
+ const refused = runs.filter((r) => r.outcome === 'refused');
121
+ if (item.status === 'COULD_NOT_RUN')
122
+ item.detail = refused.map((r) => `${r.package}: ${r.reason}`).join(' | ').slice(0, 500);
123
+ else
124
+ delete item.detail;
125
+ delete item.reason;
126
+ item.updatedAt = isoNow(o);
127
+ t.updatedAt = item.updatedAt;
128
+ assertNoSecrets(t);
129
+ await saveTask(w, t);
130
+ return t;
131
+ });
132
+ return { task: updated, check, runs };
133
+ }
134
+ function summarize(item, runs) {
135
+ if (runs.some((r) => r.outcome === 'failed'))
136
+ return 'FAIL';
137
+ if (runs.some((r) => r.outcome === 'refused'))
138
+ return 'COULD_NOT_RUN';
139
+ if (runs.some((r) => r.outcome === 'passed'))
140
+ return 'PASS';
141
+ return item.status;
142
+ }
143
+ // ---------- declared test environments ----------
144
+ export async function declareTestEnv(o, input) {
145
+ if (!input.yes) {
146
+ throw new DevWorkspaceError('USAGE', 'Declaring a test environment is a statement that running these checks there is safe; confirm with --yes.', {
147
+ hint: 'DevWorkspace cannot verify a database target (it never reads connection settings). This records your assertion, locally, and nothing else.',
148
+ });
149
+ }
150
+ assertSafeTarget(input.target);
151
+ const ws = await requireWorkspace(o.cwd);
152
+ const pkg = input.package === '' ? '.' : input.package.replace(/\/+$/, '');
153
+ const contract = await loadContract(ws);
154
+ if (!contract.some((c) => c.available && (c.cwd ?? '.') === pkg)) {
155
+ throw new DevWorkspaceError('NOT_FOUND', `The testing contract has no commands for package "${pkg}".`, { hint: 'Use a package directory shown by "devworkspace context".' });
156
+ }
157
+ const allowed = new Set(['unit', 'integration', 'e2e', 'security']);
158
+ const bad = input.checks.filter((c) => !allowed.has(c));
159
+ if (input.checks.length === 0 || bad.length > 0) {
160
+ throw new DevWorkspaceError('USAGE', `--check must be one or more of: ${[...allowed].join(', ')}.`, { hint: 'Migrations, seeds and resets are never run by DevWorkspace.' });
161
+ }
162
+ const decl = { package: pkg, checks: [...new Set(input.checks)].sort(), target: input.target.trim(), declaredAt: isoNow(o) };
163
+ await mutate(o, async (w) => saveDeclaration(w, decl));
164
+ return decl;
165
+ }
166
+ export async function listTestEnv(o) {
167
+ return loadTestEnv(await requireWorkspace(o.cwd));
168
+ }
169
+ export async function revokeTestEnv(o, pkg) {
170
+ return mutate(o, async (w) => removeDeclaration(w, pkg === '' ? '.' : pkg.replace(/\/+$/, '')));
171
+ }
172
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/services/verify.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAqB,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAW,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAwF,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC7J,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAA+C,MAAM,2BAA2B,CAAC;AAC9M,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAuB,MAAM,aAAa,CAAC;AAElE,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EAAM;IACvC,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,EAAE,CAAC,QAAQ,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,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC","sourcesContent":["import path from 'node:path';\nimport { SCHEMA_VERSION, validateCommands, type CommandEntry } from '../config/schemas.js';\nimport { requireWorkspace, type Ws } from '../core/workspace.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { DevWorkspaceError } from '../errors/index.js';\nimport { createRunner } from '../integrations/exec.js';\nimport { scrub } from '../integrations/manager.js';\nimport { loadTask, saveTask, type Evidence, type GateContext, type Task, type VerificationItem, type VerifyStatus, assertNoSecrets } from '../tasks/task.js';\nimport { pathExists } from '../utils/fs.js';\nimport { classifyCommand, isDeclared, loadTestEnv, readManifestEvidence, assertSafeTarget, removeDeclaration, saveDeclaration, type CommandSafety, type TestEnvDeclaration } from '../verification/safety.js';\nimport { changedSince, scopeByPackage } from '../verification/scope.js';\nimport { isoNow, mutate, type ServiceOptions } from './common.js';\n\nexport async function loadContract(ws: Ws): Promise<CommandEntry[]> {\n if (!(await pathExists(ws.commands))) return [];\n return (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;\n}\n\n/** Contract plus what the task has changed per package: everything the completion gate needs to judge it. */\nexport async function gateContext(ws: Ws, task: Task, contract?: CommandEntry[]): Promise<GateContext> {\n const checks = contract ?? (await loadContract(ws));\n const scope = task.scope ? scopeByPackage(await changedSince(ws.root, task.scope), checks) : null;\n return { contract: checks, scope };\n}\n\nexport type RunOutcome = 'passed' | 'failed' | 'refused' | 'not-affected';\n\nexport interface PackageRun {\n package: string;\n command: string | null;\n outcome: RunOutcome;\n exitCode?: number | null;\n durationMs?: number;\n /** Why DevWorkspace did not run it, or the scrubbed tail of a failure. */\n reason?: string;\n safety: CommandSafety['safety'];\n}\n\nexport interface RunCheckResult {\n task: Task;\n check: string;\n runs: PackageRun[];\n}\n\n/** Anything a shell would interpret. Contract commands are run as an argument vector, never through a shell. */\nconst SHELL_SYNTAX = /[&|;<>$`(){}\"'\\\\*?!%^\\r\\n]/;\n\nexport function splitCommand(command: string): string[] | null {\n if (SHELL_SYNTAX.test(command)) return null;\n const parts = command.trim().split(/\\s+/);\n return parts[0] ? parts : null;\n}\n\nconst DEFAULT_TIMEOUT_MS = 10 * 60_000;\n\n/**\n * PATH lookup on Windows finds the extensionless Unix shell script (`npm`) before `npm.cmd`, and that cannot be\n * spawned. Prefer the Windows launcher next to it. Elsewhere the lookup result is used as is.\n */\nexport async function resolveExecutable(found: string | null, name: string, platform: NodeJS.Platform, exists: (p: string) => Promise<boolean>): Promise<string> {\n if (!found) return name;\n if (platform !== 'win32' || /\\.(?:exe|cmd|bat|com)$/i.test(found)) return found;\n for (const ext of ['.cmd', '.exe', '.bat']) if (await exists(found + ext)) return found + ext;\n return found;\n}\n\n/**\n * Run one contract check for the packages the task changed, and record what really happened. DevWorkspace only runs\n * read-only, non-destructive commands; anything that may touch a database runs only after the user declared a test\n * environment for that package and check. Refusals are recorded as \"could not run\", never as a pass.\n */\nexport async function runTaskCheck(o: ServiceOptions, id: string, check: string, opts: { package?: string; timeoutMs?: number } = {}): Promise<RunCheckResult> {\n const ws = await requireWorkspace(o.cwd);\n const task = await loadTask(ws, id);\n const contract = await loadContract(ws);\n const wanted = opts.package ? (opts.package === '.' || opts.package === '' ? '.' : opts.package.replace(/\\/+$/, '')) : undefined;\n const entries = contract.filter((c) => c.id === check && c.available && (wanted === undefined || (c.cwd ?? '.') === wanted));\n if (entries.length === 0) {\n throw new DevWorkspaceError('NOT_FOUND', `The testing contract has no \"${check}\" command${wanted ? ` for package \"${wanted}\"` : ''}.`, {\n hint: 'See the contract with \"devworkspace context\", or add the command to .devworkspace/context/commands.json.',\n });\n }\n const scope = (await gateContext(ws, task, contract)).scope;\n const decls = await loadTestEnv(ws);\n const runner = o.runner ?? createRunner(o.env ?? process.env, o.platform);\n const runs: PackageRun[] = [];\n const evidence: Evidence[] = [];\n\n for (const entry of entries) {\n const pkg = entry.cwd ?? '.';\n const base = { package: pkg, command: entry.command };\n const fingerprint = scope === null ? 'unknown' : scope[pkg];\n if (wanted === undefined && fingerprint === undefined) {\n runs.push({ ...base, outcome: 'not-affected', safety: 'safe', reason: 'the task changed nothing in this package' });\n continue;\n }\n const manifest = await readManifestEvidence(ws.root, entry);\n const cls = classifyCommand(entry, manifest);\n if (cls.safety === 'blocked') {\n runs.push({ ...base, outcome: 'refused', safety: cls.safety, reason: `refused: ${cls.reasons.join('; ')}` });\n continue;\n }\n if (cls.safety === 'needs-test-environment' && !isDeclared(decls, pkg, check)) {\n runs.push({\n ...base,\n outcome: 'refused',\n safety: cls.safety,\n reason: `refused: ${cls.reasons.join('; ')}. Run it yourself against a test environment you control, then declare it with: devworkspace testenv declare --package ${pkg} --check ${check} --target \"<description>\" --yes`,\n });\n continue;\n }\n const argv = splitCommand(entry.command ?? '');\n if (!argv) {\n runs.push({ ...base, outcome: 'refused', safety: cls.safety, reason: 'refused: the command uses shell syntax, and DevWorkspace never runs a shell' });\n continue;\n }\n const exe = await resolveExecutable(await runner.which(argv[0]!), argv[0]!, o.platform ?? process.platform, pathExists);\n const started = Date.now();\n const r = await runner.run({ command: exe, args: argv.slice(1), cwd: pkg === '.' ? ws.root : path.join(ws.root, ...pkg.split('/')), timeoutMs: opts.timeoutMs ?? DEFAULT_TIMEOUT_MS });\n const durationMs = Date.now() - started;\n if (r.code === null && !r.timedOut && r.error) {\n // The command never started (missing executable, bad cwd): that is \"could not run\", not a test failure.\n runs.push({ ...base, outcome: 'refused', safety: cls.safety, reason: `could not start: ${scrub(r.error)}` });\n continue;\n }\n const passed = r.ok && r.code === 0;\n const tail = passed ? undefined : scrub((r.error ?? '') || (r.timedOut ? 'timed out' : '') || r.stderr.slice(-300) || r.stdout.slice(-300) || `exit ${r.code}`);\n runs.push({ ...base, outcome: passed ? 'passed' : 'failed', safety: cls.safety, exitCode: r.code, durationMs, ...(tail ? { reason: tail } : {}) });\n evidence.push({ kind: 'executed', at: isoNow(o), package: pkg, command: entry.command ?? undefined, exitCode: r.code, durationMs, scope: fingerprint ?? 'unknown', ...(tail ? { note: tail } : {}) });\n }\n\n const updated = await mutate(o, async (w) => {\n const t = await loadTask(w, id);\n let item = t.verification.find((v) => v.check === check);\n if (!item) {\n item = { check, required: false, status: 'PENDING' };\n t.verification.push(item);\n }\n for (const e of evidence) item.evidence = [...(item.evidence ?? []).filter((x) => x.package !== e.package), e];\n item.status = summarize(item, runs);\n const refused = runs.filter((r) => r.outcome === 'refused');\n if (item.status === 'COULD_NOT_RUN') item.detail = refused.map((r) => `${r.package}: ${r.reason}`).join(' | ').slice(0, 500);\n else delete item.detail;\n delete item.reason;\n item.updatedAt = isoNow(o);\n t.updatedAt = item.updatedAt;\n assertNoSecrets(t);\n await saveTask(w, t);\n return t;\n });\n return { task: updated, check, runs };\n}\n\nfunction summarize(item: VerificationItem, runs: PackageRun[]): VerifyStatus {\n if (runs.some((r) => r.outcome === 'failed')) return 'FAIL';\n if (runs.some((r) => r.outcome === 'refused')) return 'COULD_NOT_RUN';\n if (runs.some((r) => r.outcome === 'passed')) return 'PASS';\n return item.status;\n}\n\n// ---------- declared test environments ----------\n\nexport async function declareTestEnv(o: ServiceOptions, input: { package: string; checks: string[]; target: string; yes: boolean }): Promise<TestEnvDeclaration> {\n if (!input.yes) {\n throw new DevWorkspaceError('USAGE', 'Declaring a test environment is a statement that running these checks there is safe; confirm with --yes.', {\n hint: 'DevWorkspace cannot verify a database target (it never reads connection settings). This records your assertion, locally, and nothing else.',\n });\n }\n assertSafeTarget(input.target);\n const ws = await requireWorkspace(o.cwd);\n const pkg = input.package === '' ? '.' : input.package.replace(/\\/+$/, '');\n const contract = await loadContract(ws);\n if (!contract.some((c) => c.available && (c.cwd ?? '.') === pkg)) {\n throw new DevWorkspaceError('NOT_FOUND', `The testing contract has no commands for package \"${pkg}\".`, { hint: 'Use a package directory shown by \"devworkspace context\".' });\n }\n const allowed = new Set(['unit', 'integration', 'e2e', 'security']);\n const bad = input.checks.filter((c) => !allowed.has(c));\n if (input.checks.length === 0 || bad.length > 0) {\n throw new DevWorkspaceError('USAGE', `--check must be one or more of: ${[...allowed].join(', ')}.`, { hint: 'Migrations, seeds and resets are never run by DevWorkspace.' });\n }\n const decl: TestEnvDeclaration = { package: pkg, checks: [...new Set(input.checks)].sort(), target: input.target.trim(), declaredAt: isoNow(o) };\n await mutate(o, async (w) => saveDeclaration(w, decl));\n return decl;\n}\n\nexport async function listTestEnv(o: ServiceOptions): Promise<TestEnvDeclaration[]> {\n return loadTestEnv(await requireWorkspace(o.cwd));\n}\n\nexport async function revokeTestEnv(o: ServiceOptions, pkg: string): Promise<boolean> {\n return mutate(o, async (w) => removeDeclaration(w, pkg === '' ? '.' : pkg.replace(/\\/+$/, '')));\n}\n"]}
@@ -158,7 +158,9 @@ export function detectConstraints(text) {
158
158
  return OVERRIDE_PATTERNS.filter(([, re]) => re.test(text)).map(([c]) => c);
159
159
  }
160
160
  const QUESTION_START = /^\s*(?:where|what|which|who|when|how\s+(?:does|do|is|are|can|should)|why|explain|describe|show\s+me|walk\s+me|is\s+there|are\s+there|can\s+you\s+(?:explain|tell|show)|tell\s+me|list|find)\b/i;
161
- const IMPERATIVE_START = /^\s*(?:fix|add|implement|create|build|refactor|remove|delete|update|change|rename|write|make|migrate|upgrade|optimi[sz]e|release|publish)\b/i;
161
+ const IMPERATIVE_START = /^\s*(?:fix|add|implement|create|build|refactor|remove|delete|update|change|rename|write|make|migrate|upgrade|optimi[sz]e|release|publish|validate|ensure|prevent|enforce|guard|reject|restrict|handle|resolve|patch|repair|address|correct|replace|move|extract|rewrite|convert|improve|enable|disable|support|introduce|apply|configure|install|harden|secure|scope|isolate)\b/i;
162
+ /** A direct yes/no or open question: it ends in a question mark and does not start like an instruction. */
163
+ const DIRECT_QUESTION = /\?\s*$/;
162
164
  /** Heuristic classifier used to propose a task type. The agent may override it; ambiguous input defaults to the safest (read-only) type. */
163
165
  export function classifyRequest(text) {
164
166
  const constraints = detectConstraints(text);
@@ -170,17 +172,19 @@ export function classifyRequest(text) {
170
172
  constraints,
171
173
  readOnly: WORKFLOWS[type].readOnly || constraints.includes('no-modify') || constraints.includes('plan-only'),
172
174
  });
173
- if (QUESTION_START.test(t) && !IMPERATIVE_START.test(t))
175
+ if ((QUESTION_START.test(t) || DIRECT_QUESTION.test(t)) && !IMPERATIVE_START.test(t))
174
176
  return make('QUESTION', 'high');
175
177
  if (/\b(?:add|write|improve|increase)\s+(?:\w+\s+)?(?:unit\s+|e2e\s+|integration\s+)?tests?\b|\btest coverage\b|^\s*run\s+(?:the\s+|all\s+)?(?:\w+\s+)?tests?\b/i.test(t))
176
178
  return make('TESTING', 'high');
177
179
  if (/\b(?:upgrade|bump|update\s+dependenc\w*)\b/i.test(t))
178
180
  return make('MAINTENANCE', 'high');
181
+ if (/\b(?:vulnerab\w*|csrf|xss|sql injection|cve-\d+|cross-?tenant|tenant isolation|privilege escalation|idor)\b/i.test(t))
182
+ return make('SECURITY', 'high');
179
183
  if (/\b(?:fix|bug|broken|crash(?:es|ing)?|regression|not working|fails?|failing|exception|error)\b/i.test(t))
180
184
  return make('BUG', 'high');
181
185
  if (/\b(?:refactor|restructure|reorgani[sz]e|clean\s?up|simplify|de-?duplicate)\b/i.test(t))
182
186
  return make('REFACTOR', 'high');
183
- if (/\b(?:vulnerab\w*|security|csrf|xss|sql injection|sanitiz\w*|harden\w*|cve-\d+)\b/i.test(t))
187
+ if (/\b(?:vulnerab\w*|security|csrf|xss|sql injection|sanitiz\w*|harden\w*|cve-\d+|cross-?tenant|tenant isolation|ownership|authori[sz]ation|privilege escalation|idor)\b/i.test(t))
184
188
  return make('SECURITY', 'high');
185
189
  if (/\b(?:performance|slow|latency|speed up|optimi[sz]e|throughput)\b/i.test(t))
186
190
  return make('PERFORMANCE', 'high');
@@ -194,6 +198,9 @@ export function classifyRequest(text) {
194
198
  return make('ARCHITECTURE', 'high');
195
199
  if (/\b(?:add|implement|create|build|support|introduce|enable|new)\b/i.test(t))
196
200
  return make('FEATURE', 'high');
201
+ // An instruction we cannot place is still a request to change something. Never default it to a read-only question.
202
+ if (IMPERATIVE_START.test(t))
203
+ return make('FEATURE', 'low');
197
204
  return make('QUESTION', 'low');
198
205
  }
199
206
  export function renderRoutingTable() {
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/tasks/routing.ts"],"names":[],"mappings":"AAiBA,uHAAuH;AACvH,MAAM,CAAC,MAAM,SAAS,GAAmC;IACvD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE,CAAC;QACf,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE;YACL,+FAA+F;YAC/F,4FAA4F;YAC5F,4DAA4D;SAC7D;QACD,YAAY,EAAE,yCAAyC;QACvD,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE,WAAW;QACrB,eAAe,EAAE,gGAAgG;KAClH;IACD,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,YAAY,EAAE,CAAC;QACf,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,IAAI;QACf,KAAK,EAAE;YACL,qDAAqD;YACrD,4CAA4C;YAC5C,+CAA+C;YAC/C,yCAAyC;YACzC,qGAAqG;YACrG,kEAAkE;SACnE;QACD,YAAY,EAAE,2GAA2G;QACzH,WAAW,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;QACjC,QAAQ,EAAE,0DAA0D;QACpE,eAAe,EAAE,iEAAiE;KACnF;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,CAAC;QACf,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,IAAI;QACf,KAAK,EAAE;YACL,sDAAsD;YACtD,2DAA2D;YAC3D,+CAA+C;YAC/C,iEAAiE;YACjE,kBAAkB;YAClB,mFAAmF;SACpF;QACD,YAAY,EAAE,6DAA6D;QAC3E,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAA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O,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAChG,IAAI,gFAAgF,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACjI,IAAI,8DAA8D,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAChH,IAAI,kEAAkE,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/G,OAAO,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,IAAI,GAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAClE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrH,OAAO,KAAK,CAAC,CAAC,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,YAAY,MAAM,CAAC,CAAC,YAAY,IAAI,CAAC;IAC7E,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,gDAAgD,EAAE,2BAA2B,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7G,CAAC","sourcesContent":["import type { TaskType } from './task.js';\n\nexport type Constraint = 'no-modify' | 'plan-only' | 'no-commit' | 'no-e2e' | 'no-tests' | 'no-fix';\n\nexport interface WorkflowSpec {\n type: TaskType;\n /** Highest context level normally needed (1 instructions … 6 tests/implementation). */\n contextDepth: 1 | 2 | 3 | 4 | 5 | 6;\n readOnly: boolean;\n trackTask: boolean;\n steps: string[];\n verification: string;\n agentSkills: string[];\n ponytail: string;\n knowledgeUpdate: string;\n}\n\n/** Single source of truth for routing. The generated Claude skill and docs/routing.md are rendered from this table. */\nexport const WORKFLOWS: Record<TaskType, WorkflowSpec> = {\n QUESTION: {\n type: 'QUESTION',\n contextDepth: 5,\n readOnly: true,\n trackTask: false,\n steps: [\n 'Read .devworkspace/context facts relevant to the topic (devworkspace context --topic <area>).',\n 'Use Graphify (if ready) or targeted search to locate the code; read only the files needed.',\n 'Answer with file references. State uncertainty explicitly.',\n ],\n verification: 'None. Do not modify files or run tests.',\n agentSkills: [],\n ponytail: 'Not used.',\n knowledgeUpdate: 'Only if you discovered a durable fact that is missing; record it with \"devworkspace fact add\".',\n },\n BUG: {\n type: 'BUG',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: [\n 'Check git status; protect uncommitted user changes.',\n 'Investigate and reproduce where practical.',\n 'Write a regression test and confirm it fails.',\n 'Fix the cause, confirm the test passes.',\n 'Run the applicable regression suite, then typecheck/lint/build as required by the testing contract.',\n 'Review the diff; record results with \"devworkspace task verify\".',\n ],\n verification: 'Regression test, applicable suite, typecheck, lint, build (whatever the testing contract marks required).',\n agentSkills: ['/test', '/review'],\n ponytail: 'Light review of the diff when review level is not \"off\".',\n knowledgeUpdate: 'Only if the bug revealed a persistent constraint or convention.',\n },\n FEATURE: {\n type: 'FEATURE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: [\n 'Check git status. Read relevant facts and decisions.',\n 'Write acceptance criteria and a short plan (task update).',\n 'Write tests for the criteria, then implement.',\n 'Run targeted tests, then regression, then typecheck/lint/build.',\n 'Review the diff.',\n 'Update project knowledge for architecture, conventions or decisions that changed.',\n ],\n verification: 'Targeted tests, regression, typecheck, lint, build, review.',\n agentSkills: ['/spec', '/plan', '/build', '/test', '/review'],\n ponytail: 'Review for unnecessary complexity before completion.',\n knowledgeUpdate: 'Yes when the feature adds a module, integration, business rule or decision.',\n },\n REFACTOR: {\n type: 'REFACTOR',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: [\n 'Check git status. Analyse architecture, decisions and dependents (Graphify).',\n 'Record a baseline test result (devworkspace task tests --phase baseline).',\n 'Plan, then refactor in small verified steps.',\n 'Run targeted verification and the full regression suite; compare against the baseline.',\n 'Review the diff.',\n ],\n verification: 'Baseline vs after (no regressions), typecheck, lint, build, review.',\n agentSkills: ['/plan', '/code-simplify', '/review'],\n ponytail: 'Use for simplification review.',\n knowledgeUpdate: 'Yes if structure or conventions changed.',\n },\n DOCUMENTATION: {\n type: 'DOCUMENTATION',\n contextDepth: 4,\n readOnly: false,\n trackTask: false,\n steps: ['Read the code or facts being documented.', 'Edit documentation only.', 'Run documentation checks if the project has them (link or lint checks).'],\n verification: 'Only checks that apply to documentation.',\n agentSkills: [],\n ponytail: 'Not used.',\n knowledgeUpdate: 'Rarely.',\n },\n TESTING: {\n type: 'TESTING',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status.', 'Find existing test conventions.', 'Add tests; confirm they fail for the right reason where applicable.', 'Run the affected suite plus typecheck and lint.'],\n verification: 'Affected tests, typecheck, lint.',\n agentSkills: ['/test'],\n ponytail: 'Optional.',\n knowledgeUpdate: 'If the testing strategy or commands changed.',\n },\n PERFORMANCE: {\n type: 'PERFORMANCE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Measure first; record the baseline.', 'Change one thing at a time.', 'Re-measure and run the regression suite and build.', 'Review.'],\n verification: 'Before/after measurement, regression suite, build.',\n agentSkills: ['/webperf', '/review'],\n ponytail: 'Review for added complexity.',\n knowledgeUpdate: 'If a persistent constraint or decision emerged.',\n },\n SECURITY: {\n type: 'SECURITY',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status.', 'Understand the threat and the affected paths.', 'Test that demonstrates the issue, then fix.', 'Regression suite, typecheck, lint, build.', 'Security-focused review. Never print secret values.'],\n verification: 'Regression and exploit test, typecheck, lint, build, review.',\n agentSkills: ['/test', '/review'],\n ponytail: 'Use for bug and security review of the diff.',\n knowledgeUpdate: 'Yes for new security conventions or decisions.',\n },\n ARCHITECTURE: {\n type: 'ARCHITECTURE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Read facts, decisions and architecture notes; map structure with Graphify.', 'Present options and record the chosen one with \"devworkspace decision add\".', 'Plan and implement in verified steps.', 'Full verification and review.'],\n verification: 'Baseline vs after, typecheck, lint, build, review.',\n agentSkills: ['/spec', '/plan', '/build', '/review'],\n ponytail: 'Review for unnecessary abstraction.',\n knowledgeUpdate: 'Always: architecture notes and the decision record.',\n },\n RELEASE: {\n type: 'RELEASE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status and branch.', 'Run the full testing contract including integration/e2e where available.', 'Update changelog and version per project convention.', 'Do not publish or push without explicit user authorisation.'],\n verification: 'Everything in the testing contract.',\n agentSkills: ['/ship'],\n ponytail: 'Optional final review.',\n knowledgeUpdate: 'If release process facts changed.',\n },\n MAINTENANCE: {\n type: 'MAINTENANCE',\n contextDepth: 4,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status.', 'Make the change.', 'Run lint and build; run tests when behaviour could change.'],\n verification: 'Lint, build, tests if behaviour could change.',\n agentSkills: [],\n ponytail: 'Optional.',\n knowledgeUpdate: 'Only for changed commands or tooling.',\n },\n};\n\nconst OVERRIDE_PATTERNS: [Constraint, RegExp][] = [\n ['no-modify', /\\b(?:only|just)\\s+(?:explain|describe|investigate|look|read|review)\\b|\\b(?:do\\s*n[o']t|don'?t|never)\\s+(?:modify|change|edit|touch)\\b|\\bread[- ]only\\b|\\bno\\s+changes\\b/i],\n ['plan-only', /\\b(?:only|just)\\s+(?:make\\s+|write\\s+|give\\s+me\\s+)?a\\s+plan\\b|\\bplan\\s+only\\b/i],\n ['no-commit', /\\b(?:do\\s*n[o']t|don'?t|never)\\s+commit\\b|\\bno\\s+commits?\\b/i],\n ['no-e2e', /\\b(?:do\\s*n[o']t|don'?t|skip|no)\\s+(?:run\\s+)?(?:the\\s+)?(?:e2e|end[- ]to[- ]end)\\b/i],\n ['no-tests', /\\b(?:do\\s*n[o']t|don'?t|skip)\\s+(?:run\\s+)?(?:any\\s+|the\\s+)?tests\\b(?!\\s+but)/i],\n ['no-fix', /\\b(?:do\\s*n[o']t|don'?t)\\s+fix\\b|\\bwithout\\s+fixing\\b/i],\n];\n\nexport function detectConstraints(text: string): Constraint[] {\n return OVERRIDE_PATTERNS.filter(([, re]) => re.test(text)).map(([c]) => c);\n}\n\nexport interface Classification {\n type: TaskType;\n confidence: 'high' | 'low';\n constraints: Constraint[];\n /** True when the request must not change files (question type, or an explicit user override). */\n readOnly: boolean;\n}\n\nconst QUESTION_START = /^\\s*(?:where|what|which|who|when|how\\s+(?:does|do|is|are|can|should)|why|explain|describe|show\\s+me|walk\\s+me|is\\s+there|are\\s+there|can\\s+you\\s+(?:explain|tell|show)|tell\\s+me|list|find)\\b/i;\nconst IMPERATIVE_START = /^\\s*(?:fix|add|implement|create|build|refactor|remove|delete|update|change|rename|write|make|migrate|upgrade|optimi[sz]e|release|publish)\\b/i;\n\n/** Heuristic classifier used to propose a task type. The agent may override it; ambiguous input defaults to the safest (read-only) type. */\nexport function classifyRequest(text: string): Classification {\n const constraints = detectConstraints(text);\n // Negated phrases (\"don't fix anything\") describe limits, not the task itself.\n const t = OVERRIDE_PATTERNS.reduce((acc, [, re]) => acc.replace(new RegExp(re.source, re.flags + 'g'), ' '), text).trim();\n const make = (type: TaskType, confidence: 'high' | 'low'): Classification => ({\n type,\n confidence,\n constraints,\n readOnly: WORKFLOWS[type].readOnly || constraints.includes('no-modify') || constraints.includes('plan-only'),\n });\n if (QUESTION_START.test(t) && !IMPERATIVE_START.test(t)) return make('QUESTION', 'high');\n if (/\\b(?:add|write|improve|increase)\\s+(?:\\w+\\s+)?(?:unit\\s+|e2e\\s+|integration\\s+)?tests?\\b|\\btest coverage\\b|^\\s*run\\s+(?:the\\s+|all\\s+)?(?:\\w+\\s+)?tests?\\b/i.test(t)) return make('TESTING', 'high');\n if (/\\b(?:upgrade|bump|update\\s+dependenc\\w*)\\b/i.test(t)) return make('MAINTENANCE', 'high');\n if (/\\b(?:fix|bug|broken|crash(?:es|ing)?|regression|not working|fails?|failing|exception|error)\\b/i.test(t)) return make('BUG', 'high');\n if (/\\b(?:refactor|restructure|reorgani[sz]e|clean\\s?up|simplify|de-?duplicate)\\b/i.test(t)) return make('REFACTOR', 'high');\n if (/\\b(?:vulnerab\\w*|security|csrf|xss|sql injection|sanitiz\\w*|harden\\w*|cve-\\d+)\\b/i.test(t)) return make('SECURITY', 'high');\n if (/\\b(?:performance|slow|latency|speed up|optimi[sz]e|throughput)\\b/i.test(t)) return make('PERFORMANCE', 'high');\n if (/\\b(?:document|readme|docs|changelog|jsdoc|docstring)\\b/i.test(t)) return make('DOCUMENTATION', 'high');\n if (/\\b(?:release|publish|deploy|ship|version bump)\\b/i.test(t)) return make('RELEASE', 'high');\n if (/\\b(?:upgrade|bump|update\\s+dependenc\\w*|chore|lint(?:ing)?|format(?:ting)?)\\b/i.test(t)) return make('MAINTENANCE', 'high');\n if (/\\b(?:redesign|re-?architect\\w*|migrate\\s+to|architecture)\\b/i.test(t)) return make('ARCHITECTURE', 'high');\n if (/\\b(?:add|implement|create|build|support|introduce|enable|new)\\b/i.test(t)) return make('FEATURE', 'high');\n return make('QUESTION', 'low');\n}\n\nexport function renderRoutingTable(): string {\n const rows = (Object.values(WORKFLOWS) as WorkflowSpec[]).map((w) => {\n const flags = [w.readOnly ? 'read-only' : 'modifies code', w.trackTask ? 'tracked task' : 'no task file'].join(', ');\n return `| ${w.type} | ${flags} | L${w.contextDepth} | ${w.verification} |`;\n });\n return ['| Type | Nature | Max context | Verification |', '| --- | --- | --- | --- |', ...rows].join('\\n');\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/tasks/routing.ts"],"names":[],"mappings":"AAiBA,uHAAuH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IAChG,IAAI,gFAAgF,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACjI,IAAI,8DAA8D,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAChH,IAAI,kEAAkE,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/G,mHAAmH;IACnH,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,IAAI,GAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAClE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrH,OAAO,KAAK,CAAC,CAAC,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,YAAY,MAAM,CAAC,CAAC,YAAY,IAAI,CAAC;IAC7E,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,gDAAgD,EAAE,2BAA2B,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7G,CAAC","sourcesContent":["import type { TaskType } from './task.js';\n\nexport type Constraint = 'no-modify' | 'plan-only' | 'no-commit' | 'no-e2e' | 'no-tests' | 'no-fix';\n\nexport interface WorkflowSpec {\n type: TaskType;\n /** Highest context level normally needed (1 instructions … 6 tests/implementation). */\n contextDepth: 1 | 2 | 3 | 4 | 5 | 6;\n readOnly: boolean;\n trackTask: boolean;\n steps: string[];\n verification: string;\n agentSkills: string[];\n ponytail: string;\n knowledgeUpdate: string;\n}\n\n/** Single source of truth for routing. The generated Claude skill and docs/routing.md are rendered from this table. */\nexport const WORKFLOWS: Record<TaskType, WorkflowSpec> = {\n QUESTION: {\n type: 'QUESTION',\n contextDepth: 5,\n readOnly: true,\n trackTask: false,\n steps: [\n 'Read .devworkspace/context facts relevant to the topic (devworkspace context --topic <area>).',\n 'Use Graphify (if ready) or targeted search to locate the code; read only the files needed.',\n 'Answer with file references. State uncertainty explicitly.',\n ],\n verification: 'None. Do not modify files or run tests.',\n agentSkills: [],\n ponytail: 'Not used.',\n knowledgeUpdate: 'Only if you discovered a durable fact that is missing; record it with \"devworkspace fact add\".',\n },\n BUG: {\n type: 'BUG',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: [\n 'Check git status; protect uncommitted user changes.',\n 'Investigate and reproduce where practical.',\n 'Write a regression test and confirm it fails.',\n 'Fix the cause, confirm the test passes.',\n 'Run the applicable regression suite, then typecheck/lint/build as required by the testing contract.',\n 'Review the diff; record results with \"devworkspace task verify\".',\n ],\n verification: 'Regression test, applicable suite, typecheck, lint, build (whatever the testing contract marks required).',\n agentSkills: ['/test', '/review'],\n ponytail: 'Light review of the diff when review level is not \"off\".',\n knowledgeUpdate: 'Only if the bug revealed a persistent constraint or convention.',\n },\n FEATURE: {\n type: 'FEATURE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: [\n 'Check git status. Read relevant facts and decisions.',\n 'Write acceptance criteria and a short plan (task update).',\n 'Write tests for the criteria, then implement.',\n 'Run targeted tests, then regression, then typecheck/lint/build.',\n 'Review the diff.',\n 'Update project knowledge for architecture, conventions or decisions that changed.',\n ],\n verification: 'Targeted tests, regression, typecheck, lint, build, review.',\n agentSkills: ['/spec', '/plan', '/build', '/test', '/review'],\n ponytail: 'Review for unnecessary complexity before completion.',\n knowledgeUpdate: 'Yes when the feature adds a module, integration, business rule or decision.',\n },\n REFACTOR: {\n type: 'REFACTOR',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: [\n 'Check git status. Analyse architecture, decisions and dependents (Graphify).',\n 'Record a baseline test result (devworkspace task tests --phase baseline).',\n 'Plan, then refactor in small verified steps.',\n 'Run targeted verification and the full regression suite; compare against the baseline.',\n 'Review the diff.',\n ],\n verification: 'Baseline vs after (no regressions), typecheck, lint, build, review.',\n agentSkills: ['/plan', '/code-simplify', '/review'],\n ponytail: 'Use for simplification review.',\n knowledgeUpdate: 'Yes if structure or conventions changed.',\n },\n DOCUMENTATION: {\n type: 'DOCUMENTATION',\n contextDepth: 4,\n readOnly: false,\n trackTask: false,\n steps: ['Read the code or facts being documented.', 'Edit documentation only.', 'Run documentation checks if the project has them (link or lint checks).'],\n verification: 'Only checks that apply to documentation.',\n agentSkills: [],\n ponytail: 'Not used.',\n knowledgeUpdate: 'Rarely.',\n },\n TESTING: {\n type: 'TESTING',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status.', 'Find existing test conventions.', 'Add tests; confirm they fail for the right reason where applicable.', 'Run the affected suite plus typecheck and lint.'],\n verification: 'Affected tests, typecheck, lint.',\n agentSkills: ['/test'],\n ponytail: 'Optional.',\n knowledgeUpdate: 'If the testing strategy or commands changed.',\n },\n PERFORMANCE: {\n type: 'PERFORMANCE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Measure first; record the baseline.', 'Change one thing at a time.', 'Re-measure and run the regression suite and build.', 'Review.'],\n verification: 'Before/after measurement, regression suite, build.',\n agentSkills: ['/webperf', '/review'],\n ponytail: 'Review for added complexity.',\n knowledgeUpdate: 'If a persistent constraint or decision emerged.',\n },\n SECURITY: {\n type: 'SECURITY',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status.', 'Understand the threat and the affected paths.', 'Test that demonstrates the issue, then fix.', 'Regression suite, typecheck, lint, build.', 'Security-focused review. Never print secret values.'],\n verification: 'Regression and exploit test, typecheck, lint, build, review.',\n agentSkills: ['/test', '/review'],\n ponytail: 'Use for bug and security review of the diff.',\n knowledgeUpdate: 'Yes for new security conventions or decisions.',\n },\n ARCHITECTURE: {\n type: 'ARCHITECTURE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Read facts, decisions and architecture notes; map structure with Graphify.', 'Present options and record the chosen one with \"devworkspace decision add\".', 'Plan and implement in verified steps.', 'Full verification and review.'],\n verification: 'Baseline vs after, typecheck, lint, build, review.',\n agentSkills: ['/spec', '/plan', '/build', '/review'],\n ponytail: 'Review for unnecessary abstraction.',\n knowledgeUpdate: 'Always: architecture notes and the decision record.',\n },\n RELEASE: {\n type: 'RELEASE',\n contextDepth: 6,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status and branch.', 'Run the full testing contract including integration/e2e where available.', 'Update changelog and version per project convention.', 'Do not publish or push without explicit user authorisation.'],\n verification: 'Everything in the testing contract.',\n agentSkills: ['/ship'],\n ponytail: 'Optional final review.',\n knowledgeUpdate: 'If release process facts changed.',\n },\n MAINTENANCE: {\n type: 'MAINTENANCE',\n contextDepth: 4,\n readOnly: false,\n trackTask: true,\n steps: ['Check git status.', 'Make the change.', 'Run lint and build; run tests when behaviour could change.'],\n verification: 'Lint, build, tests if behaviour could change.',\n agentSkills: [],\n ponytail: 'Optional.',\n knowledgeUpdate: 'Only for changed commands or tooling.',\n },\n};\n\nconst OVERRIDE_PATTERNS: [Constraint, RegExp][] = [\n ['no-modify', /\\b(?:only|just)\\s+(?:explain|describe|investigate|look|read|review)\\b|\\b(?:do\\s*n[o']t|don'?t|never)\\s+(?:modify|change|edit|touch)\\b|\\bread[- ]only\\b|\\bno\\s+changes\\b/i],\n ['plan-only', /\\b(?:only|just)\\s+(?:make\\s+|write\\s+|give\\s+me\\s+)?a\\s+plan\\b|\\bplan\\s+only\\b/i],\n ['no-commit', /\\b(?:do\\s*n[o']t|don'?t|never)\\s+commit\\b|\\bno\\s+commits?\\b/i],\n ['no-e2e', /\\b(?:do\\s*n[o']t|don'?t|skip|no)\\s+(?:run\\s+)?(?:the\\s+)?(?:e2e|end[- ]to[- ]end)\\b/i],\n ['no-tests', /\\b(?:do\\s*n[o']t|don'?t|skip)\\s+(?:run\\s+)?(?:any\\s+|the\\s+)?tests\\b(?!\\s+but)/i],\n ['no-fix', /\\b(?:do\\s*n[o']t|don'?t)\\s+fix\\b|\\bwithout\\s+fixing\\b/i],\n];\n\nexport function detectConstraints(text: string): Constraint[] {\n return OVERRIDE_PATTERNS.filter(([, re]) => re.test(text)).map(([c]) => c);\n}\n\nexport interface Classification {\n type: TaskType;\n confidence: 'high' | 'low';\n constraints: Constraint[];\n /** True when the request must not change files (question type, or an explicit user override). */\n readOnly: boolean;\n}\n\nconst QUESTION_START = /^\\s*(?:where|what|which|who|when|how\\s+(?:does|do|is|are|can|should)|why|explain|describe|show\\s+me|walk\\s+me|is\\s+there|are\\s+there|can\\s+you\\s+(?:explain|tell|show)|tell\\s+me|list|find)\\b/i;\nconst IMPERATIVE_START =\n /^\\s*(?:fix|add|implement|create|build|refactor|remove|delete|update|change|rename|write|make|migrate|upgrade|optimi[sz]e|release|publish|validate|ensure|prevent|enforce|guard|reject|restrict|handle|resolve|patch|repair|address|correct|replace|move|extract|rewrite|convert|improve|enable|disable|support|introduce|apply|configure|install|harden|secure|scope|isolate)\\b/i;\n/** A direct yes/no or open question: it ends in a question mark and does not start like an instruction. */\nconst DIRECT_QUESTION = /\\?\\s*$/;\n\n/** Heuristic classifier used to propose a task type. The agent may override it; ambiguous input defaults to the safest (read-only) type. */\nexport function classifyRequest(text: string): Classification {\n const constraints = detectConstraints(text);\n // Negated phrases (\"don't fix anything\") describe limits, not the task itself.\n const t = OVERRIDE_PATTERNS.reduce((acc, [, re]) => acc.replace(new RegExp(re.source, re.flags + 'g'), ' '), text).trim();\n const make = (type: TaskType, confidence: 'high' | 'low'): Classification => ({\n type,\n confidence,\n constraints,\n readOnly: WORKFLOWS[type].readOnly || constraints.includes('no-modify') || constraints.includes('plan-only'),\n });\n if ((QUESTION_START.test(t) || DIRECT_QUESTION.test(t)) && !IMPERATIVE_START.test(t)) return make('QUESTION', 'high');\n if (/\\b(?:add|write|improve|increase)\\s+(?:\\w+\\s+)?(?:unit\\s+|e2e\\s+|integration\\s+)?tests?\\b|\\btest coverage\\b|^\\s*run\\s+(?:the\\s+|all\\s+)?(?:\\w+\\s+)?tests?\\b/i.test(t)) return make('TESTING', 'high');\n if (/\\b(?:upgrade|bump|update\\s+dependenc\\w*)\\b/i.test(t)) return make('MAINTENANCE', 'high');\n if (/\\b(?:vulnerab\\w*|csrf|xss|sql injection|cve-\\d+|cross-?tenant|tenant isolation|privilege escalation|idor)\\b/i.test(t)) return make('SECURITY', 'high');\n if (/\\b(?:fix|bug|broken|crash(?:es|ing)?|regression|not working|fails?|failing|exception|error)\\b/i.test(t)) return make('BUG', 'high');\n if (/\\b(?:refactor|restructure|reorgani[sz]e|clean\\s?up|simplify|de-?duplicate)\\b/i.test(t)) return make('REFACTOR', 'high');\n if (/\\b(?:vulnerab\\w*|security|csrf|xss|sql injection|sanitiz\\w*|harden\\w*|cve-\\d+|cross-?tenant|tenant isolation|ownership|authori[sz]ation|privilege escalation|idor)\\b/i.test(t)) return make('SECURITY', 'high');\n if (/\\b(?:performance|slow|latency|speed up|optimi[sz]e|throughput)\\b/i.test(t)) return make('PERFORMANCE', 'high');\n if (/\\b(?:document|readme|docs|changelog|jsdoc|docstring)\\b/i.test(t)) return make('DOCUMENTATION', 'high');\n if (/\\b(?:release|publish|deploy|ship|version bump)\\b/i.test(t)) return make('RELEASE', 'high');\n if (/\\b(?:upgrade|bump|update\\s+dependenc\\w*|chore|lint(?:ing)?|format(?:ting)?)\\b/i.test(t)) return make('MAINTENANCE', 'high');\n if (/\\b(?:redesign|re-?architect\\w*|migrate\\s+to|architecture)\\b/i.test(t)) return make('ARCHITECTURE', 'high');\n if (/\\b(?:add|implement|create|build|support|introduce|enable|new)\\b/i.test(t)) return make('FEATURE', 'high');\n // An instruction we cannot place is still a request to change something. Never default it to a read-only question.\n if (IMPERATIVE_START.test(t)) return make('FEATURE', 'low');\n return make('QUESTION', 'low');\n}\n\nexport function renderRoutingTable(): string {\n const rows = (Object.values(WORKFLOWS) as WorkflowSpec[]).map((w) => {\n const flags = [w.readOnly ? 'read-only' : 'modifies code', w.trackTask ? 'tracked task' : 'no task file'].join(', ');\n return `| ${w.type} | ${flags} | L${w.contextDepth} | ${w.verification} |`;\n });\n return ['| Type | Nature | Max context | Verification |', '| --- | --- | --- | --- |', ...rows].join('\\n');\n}\n"]}
@@ -4,8 +4,27 @@ export declare const TASK_TYPES: readonly ["QUESTION", "BUG", "FEATURE", "REFACT
4
4
  export type TaskType = (typeof TASK_TYPES)[number];
5
5
  export declare const TASK_STATUSES: readonly ["IDEA", "SPECIFIED", "PLANNED", "IN_PROGRESS", "TESTING", "REVIEW", "BLOCKED", "FAILED", "COMPLETED"];
6
6
  export type TaskStatus = (typeof TASK_STATUSES)[number];
7
- export declare const VERIFY_STATUSES: readonly ["PENDING", "PASS", "FAIL", "SKIPPED"];
7
+ export declare const VERIFY_STATUSES: readonly ["PENDING", "PASS", "FAIL", "SKIPPED", "COULD_NOT_RUN"];
8
8
  export type VerifyStatus = (typeof VERIFY_STATUSES)[number];
9
+ /**
10
+ * One recorded result for one package. `executed` means DevWorkspace ran the contract command itself and saw the exit
11
+ * code; `claimed` is somebody's report (agent or person) that DevWorkspace could not observe.
12
+ */
13
+ export interface Evidence {
14
+ kind: 'executed' | 'claimed';
15
+ at: string;
16
+ /** Package directory relative to the project root; "." for the root. */
17
+ package: string;
18
+ command?: string;
19
+ exitCode?: number | null;
20
+ durationMs?: number;
21
+ /** Fingerprint of the task's changes inside this package when the result was recorded. */
22
+ scope?: string;
23
+ /** A claim the user explicitly vouched for (--reason user-override). */
24
+ userOverride?: boolean;
25
+ /** One-line, scrubbed explanation (failure tail or refusal reason). Never a connection string or credential. */
26
+ note?: string;
27
+ }
9
28
  export interface VerificationItem {
10
29
  check: string;
11
30
  required: boolean;
@@ -13,6 +32,16 @@ export interface VerificationItem {
13
32
  reason?: string;
14
33
  detail?: string;
15
34
  updatedAt?: string;
35
+ /** Latest result per package. Absent on tasks recorded by older versions. */
36
+ evidence?: Evidence[];
37
+ }
38
+ /** Files that were already modified when the task was created, so they are not blamed on the task. */
39
+ export interface TaskScope {
40
+ capturedAt: string;
41
+ /** Git HEAD when the task was created; null outside a repository. */
42
+ head: string | null;
43
+ /** Project-relative path -> content hash of files already modified at creation ("deleted" for removed files). */
44
+ baseline: Record<string, string>;
16
45
  }
17
46
  export interface TestCounts {
18
47
  passed: number;
@@ -41,6 +70,8 @@ export interface Task {
41
70
  after?: TestCounts;
42
71
  };
43
72
  attestations: Attestations;
73
+ /** Present on tasks created by 0.2.2+: enables package-aware, evidence-based completion. */
74
+ scope?: TaskScope;
44
75
  decisions: string[];
45
76
  blockers: string[];
46
77
  constraints: string[];
@@ -72,10 +103,23 @@ export interface GateResult {
72
103
  failures: string[];
73
104
  warnings: string[];
74
105
  }
75
- /** The completion gate. A task is only COMPLETED when every applicable requirement holds. */
76
- export declare function evaluateGate(task: Task): GateResult;
77
- export declare function transitionTask(task: Task, to: TaskStatus, now: string, note?: string): GateResult | null;
78
- export declare function nextRequiredStep(task: Task): string;
106
+ /** What the gate needs to know beyond the task itself: the contract and what the task changed, per package. */
107
+ export interface GateContext {
108
+ contract: CommandEntry[];
109
+ /**
110
+ * Fingerprint of the task's changes inside each package ("." = everything). `null` means the changes could not be
111
+ * determined (not a Git repository, or nothing changed since the task started), so every package counts as affected.
112
+ */
113
+ scope: Record<string, string> | null;
114
+ }
115
+ /**
116
+ * The completion gate. A task is only COMPLETED when every applicable requirement holds.
117
+ * Tasks that carry a `scope` (created by 0.2.2+) are checked per changed package against executed evidence; older
118
+ * tasks keep the original rules.
119
+ */
120
+ export declare function evaluateGate(task: Task, ctx?: GateContext): GateResult;
121
+ export declare function transitionTask(task: Task, to: TaskStatus, now: string, note?: string, ctx?: GateContext): GateResult | null;
122
+ export declare function nextRequiredStep(task: Task, ctx?: GateContext): string;
79
123
  export declare function saveTask(ws: Ws, task: Task): Promise<void>;
80
124
  export declare function loadTask(ws: Ws, idOrPrefix: string): Promise<Task>;
81
125
  export interface TaskListing {