feat: Implement Architect role & design_task tool (#189)

Adds the Architect role for design/architecture investigations with
persistent sessions and structured design proposals.

## New Features

- **Architect role** with opus (complex) and sonnet (standard) levels
- **design_task tool** — Creates To Design issues and dispatches architect
- **Workflow states:** To Design → Designing → Planning
- **Completion rules:** architect:done → Planning, architect:blocked → Refining
- **Auto-level selection** based on complexity keywords

## Files Changed (22 files, 546 additions)

### New Files
- lib/tools/design-task.ts — design_task tool implementation
- lib/tools/design-task.test.ts — 16 tests for architect functionality

### Core Changes
- lib/tiers.ts — ARCHITECT_LEVELS, WorkerRole type, models, emoji
- lib/workflow.ts — toDesign/designing states, completion rules
- lib/projects.ts — architect WorkerState on Project type
- lib/dispatch.ts — architect role support in dispatch pipeline
- lib/services/pipeline.ts — architect completion rules
- lib/model-selector.ts — architect level selection heuristic

### Integration
- index.ts — Register design_task tool, architect config schema
- lib/notify.ts — architect role in notifications
- lib/bootstrap-hook.ts — architect session key parsing
- lib/services/tick.ts — architect in queue processing
- lib/services/heartbeat.ts — architect in health checks
- lib/tools/health.ts — architect in health scans
- lib/tools/status.ts — architect in status dashboard
- lib/tools/work-start.ts — architect role option
- lib/tools/work-finish.ts — architect validation
- lib/tools/project-register.ts — architect labels + role scaffolding
- lib/templates.ts — architect instructions + AGENTS.md updates
- lib/setup/workspace.ts — architect role file scaffolding
- lib/setup/smart-model-selector.ts — architect in model assignment
- lib/setup/llm-model-selector.ts — architect in LLM prompt
This commit is contained in:
Lauren ten Hoor
2026-02-14 17:08:17 +08:00
parent 310230772b
commit 57c78f3656
22 changed files with 546 additions and 56 deletions

View File

@@ -15,6 +15,10 @@ export type ModelAssignment = {
reviewer: string;
tester: string;
};
architect: {
opus: string;
sonnet: string;
};
};
/**
@@ -34,6 +38,7 @@ export async function selectModelsWithLLM(
return {
dev: { junior: model, medior: model, senior: model },
qa: { reviewer: model, tester: model },
architect: { opus: model, sonnet: model },
};
}
@@ -70,6 +75,10 @@ Return ONLY a JSON object in this exact format (no markdown, no explanation):
"qa": {
"reviewer": "provider/model-name",
"tester": "provider/model-name"
},
"architect": {
"opus": "provider/model-name",
"sonnet": "provider/model-name"
}
}`;
@@ -119,6 +128,14 @@ Return ONLY a JSON object in this exact format (no markdown, no explanation):
console.log("LLM returned:", JSON.stringify(assignment, null, 2));
// Validate the structure
// Backfill architect if LLM didn't return it (graceful upgrade)
if (!assignment.architect) {
assignment.architect = {
opus: assignment.dev?.senior ?? availableModels[0].model,
sonnet: assignment.dev?.medior ?? availableModels[0].model,
};
}
if (
!assignment.dev?.junior ||
!assignment.dev?.medior ||

View File

@@ -14,6 +14,10 @@ export type ModelAssignment = {
reviewer: string;
tester: string;
};
architect: {
opus: string;
sonnet: string;
};
};
/**
@@ -41,6 +45,7 @@ export async function assignModels(
return {
dev: { junior: model, medior: model, senior: model },
qa: { reviewer: model, tester: model },
architect: { opus: model, sonnet: model },
};
}
@@ -67,6 +72,8 @@ export function formatAssignment(assignment: ModelAssignment): string {
`| DEV | junior | ${assignment.dev.junior.padEnd(24)} |`,
`| QA | reviewer | ${assignment.qa.reviewer.padEnd(24)} |`,
`| QA | tester | ${assignment.qa.tester.padEnd(24)} |`,
`| ARCH | opus | ${assignment.architect.opus.padEnd(24)} |`,
`| ARCH | sonnet | ${assignment.architect.sonnet.padEnd(24)} |`,
];
return lines.join("\n");
}

View File

@@ -10,6 +10,7 @@ import {
HEARTBEAT_MD_TEMPLATE,
DEFAULT_DEV_INSTRUCTIONS,
DEFAULT_QA_INSTRUCTIONS,
DEFAULT_ARCHITECT_INSTRUCTIONS,
} from "../templates.js";
/**
@@ -49,6 +50,11 @@ export async function scaffoldWorkspace(workspacePath: string): Promise<string[]
await fs.writeFile(qaRolePath, DEFAULT_QA_INSTRUCTIONS, "utf-8");
filesWritten.push("projects/roles/default/qa.md");
}
const architectRolePath = path.join(defaultRolesDir, "architect.md");
if (!await fileExists(architectRolePath)) {
await fs.writeFile(architectRolePath, DEFAULT_ARCHITECT_INSTRUCTIONS, "utf-8");
filesWritten.push("projects/roles/default/architect.md");
}
// log/ directory (audit.log created on first write)
const logDir = path.join(workspacePath, "log");