* feat(ideas): upload-plan knop — short-circuit van Make-Plan AI-flow Voegt een 'Upload plan' knop toe in idea-row-actions (verschijnt in zowel list als idea-detail). Klik → file picker → kies .md → server-side parse + opslaan; idea-status springt naar PLAN_READY. Vandaaruit de bestaande 'Maak PBI' knop voor materialize. Server (uploadPlanMdAction): - Toegestaan vanuit DRAFT, GRILLED, PLAN_FAILED, PLAN_READY - DRAFT → skip-grill: status gaat direct naar PLAN_READY - PLAN_READY overschrijft het bestaande plan (consistent met updatePlanMdAction, geen confirmation) - Geblokkeerd in GRILLING/PLANNING (job loopt), PLANNED (al gematerialiseerd) - Parse-failure → 422 + details (NIET opslaan, zodat een onparseerbaar plan nooit in de DB belandt) - Empty / >100k chars → 422 - Schrijft IdeaLog NOTE met from_status + length - Rate-limit + demo-guard + ownership-check via loadOwnedIdea (zelfde patroon als updatePlanMdAction) UI (idea-row-actions.tsx): - Hidden <input type=file accept=".md,.markdown,text/markdown,text/plain"> - FileReader → text → action - Toast bij success + router.refresh() - Blocked-tooltip in andere statussen Tests: 10 nieuwe in __tests__/actions/ideas-crud.test.ts dekkend voor: happy paths (DRAFT/GRILLED/PLAN_READY-overwrite/PLAN_FAILED), blocks (PLANNED/GRILLING), validation (empty/oversized/parse-fail), 404. Full suite groen: 849/849. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add reviews for Bootstrap-wizard plans v3.2 to v3.4 - Review v3.2: Addressed executor model, fire-and-forget issues, and PAT handling. - Review v3.3: Improved transaction handling, stale recovery, and ID generation. - Review v3.4: Finalized GitHub permissions, catalog versioning, and E2E verification queries. - Updated recommendations for each version to enhance implementation readiness. * docs(plans): M8 bootstrap-wizard upload-variant v1.4 — backtick-paden Upload-variant van het volledige technische plan (docs/plans/M8-bootstrap-wizard.md), bedoeld voor de "Upload plan"-functie. Genereert 1 PBI + 4 Stories + 22 Tasks via materializeIdeaPlanAction. v1.4-aanpassingen tov eerdere generatie-iteratie: - Alle bestandspaden in implementation_plan in backticks (path-extractor matchen) - Expliciete "Bestanden:" blok per task vóór de stappen - Alle tasks op verify_required: ALIGNED_OR_PARTIAL (was deels ALIGNED — te strict voor ADR-stubs en multi-file edits) Fixt forward-only: T-963 cancelled_by_self door DIVERGENT verifier-verdict. Re-upload van dit bestand produceert tasks die door verify_task_against_plan als ALIGNED of PARTIAL geclassificeerd kunnen worden. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * PBI-67: Add review-plan support to Idea model and job config - Add plan_review_log and reviewed_at fields to Idea model - Add REVIEWING_PLAN, PLAN_REVIEW_FAILED, PLAN_REVIEWED to IdeaStatus enum - Add IDEA_REVIEW_PLAN to ClaudeJobKind enum - Add IDEA_REVIEW_PLAN config to job-config.ts with model=opus, thinking_budget=6000 - Create migration record for schema changes (applied via db push) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * PBI-67 Phase 2: Add update-idea-plan-reviewed MCP tool - Create src/tools/update-idea-plan-reviewed.ts: saves review-log and transitions idea status to PLAN_REVIEWED - Add PLAN_REVIEW_RESULT to IdeaLogType enum (both repos) - Register tool in src/index.ts - Update Prisma schemas (both repos): add plan_review_log and reviewed_at fields to Idea model - Add REVIEWING_PLAN, PLAN_REVIEW_FAILED, PLAN_REVIEWED to IdeaStatus enum (MCP schema) - Add IDEA_REVIEW_PLAN to ClaudeJobKind enum (MCP schema) - Tool includes transaction safety and convergence metrics logging Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * feat(PBI-67): IDEA_REVIEW_PLAN Phases 3-6 — server actions, UI components, prompt & tests - Phase 3: startReviewPlanJobAction, cancelIdeaJobAction, status transitions (REVIEWING_PLAN / PLAN_REVIEWED / PLAN_REVIEW_FAILED), status colors, job-card/jobs-column filters, idea-list status tabs - Phase 4: review-plan-job.md prompt (multi-model orchestration with codex injection + active plan revision via update_idea_plan_md after each round), runbook, 13 unit tests - Phase 5: ReviewLogViewer component (rounds, convergence, approval, issues), idea-detail integration, proper ReviewLog TypeScript types exported from component - Phase 6.1: wait-for-job discriminator wired (IDEA_REVIEW_PLAN), plan-revision step made mandatory in prompt (was previously optional/missing) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
224 lines
7.1 KiB
TypeScript
224 lines
7.1 KiB
TypeScript
// PBI-67: model + mode-selectie per ClaudeJob-kind.
|
|
//
|
|
// Sync with scrum4me-mcp/src/lib/job-config.ts — als je hier een veld
|
|
// aanpast, doe hetzelfde aan de MCP-kant. Dit is bewust een duplicate
|
|
// (geen gedeeld package) om de MCP-server eigenstandig te houden.
|
|
//
|
|
// Override-cascade (eerste match wint):
|
|
// 1. task.requires_opus === true → forceer Opus
|
|
// 2. job.requested_* (snapshot bij enqueue, ingevuld door deze module)
|
|
// 3. product.preferred_*
|
|
// 4. KIND_DEFAULTS hieronder
|
|
//
|
|
// CLI-flag-mapping (Claude CLI 2.1.x):
|
|
// - thinking_budget (number) → mapBudgetToEffort() → --effort {low,medium,high,xhigh,max}
|
|
// (de CLI heeft geen --thinking-budget flag — alleen --effort)
|
|
// - max_turns blijft audit-only: de CLI heeft géén --max-turns flag.
|
|
// De waarde wordt gesnapshot voor cost-attribution maar niet doorgegeven.
|
|
// - allowed_tools → --allowedTools (komma-gescheiden lijst)
|
|
|
|
export type ClaudeModel =
|
|
| 'claude-opus-4-7'
|
|
| 'claude-sonnet-4-6'
|
|
| 'claude-haiku-4-5-20251001'
|
|
|
|
export type PermissionMode = 'plan' | 'default' | 'acceptEdits' | 'bypassPermissions'
|
|
|
|
export type JobConfig = {
|
|
model: ClaudeModel
|
|
thinking_budget: number
|
|
permission_mode: PermissionMode
|
|
max_turns: number | null
|
|
allowed_tools: string[] | null
|
|
}
|
|
|
|
export type JobInput = {
|
|
kind: string
|
|
requested_model?: string | null
|
|
requested_thinking_budget?: number | null
|
|
requested_permission_mode?: string | null
|
|
}
|
|
|
|
export type ProductInput = {
|
|
preferred_model?: string | null
|
|
thinking_budget_default?: number | null
|
|
preferred_permission_mode?: string | null
|
|
}
|
|
|
|
export type TaskInput = {
|
|
requires_opus?: boolean | null
|
|
}
|
|
|
|
// Tool-allowlists per kind. Bewust géén `wait_for_job`, `check_queue_empty`
|
|
// of `get_idea_context` — de runner (scrum4me-docker/bin/run-one-job.ts)
|
|
// claimt voor Claude. Vangrail tegen recursieve claims binnen één invocation.
|
|
const TASK_TOOLS = [
|
|
'Read', 'Edit', 'Write', 'Bash', 'Grep', 'Glob',
|
|
'mcp__scrum4me__get_claude_context',
|
|
'mcp__scrum4me__update_task_status',
|
|
'mcp__scrum4me__update_task_plan',
|
|
'mcp__scrum4me__log_implementation',
|
|
'mcp__scrum4me__log_test_result',
|
|
'mcp__scrum4me__log_commit',
|
|
'mcp__scrum4me__verify_task_against_plan',
|
|
'mcp__scrum4me__update_job_status',
|
|
'mcp__scrum4me__ask_user_question',
|
|
'mcp__scrum4me__get_question_answer',
|
|
'mcp__scrum4me__list_open_questions',
|
|
'mcp__scrum4me__cancel_question',
|
|
'mcp__scrum4me__worker_heartbeat',
|
|
]
|
|
|
|
const KIND_DEFAULTS: Record<string, JobConfig> = {
|
|
// Idea-kinds en PLAN_CHAT draaien in `acceptEdits` (niet `plan`):
|
|
// `plan`-mode wacht op human-approval na elke planning-fase, wat in een
|
|
// autonome runner-context betekent dat Claude geen `update_job_status`
|
|
// aanroept en de job na lease-expiry FAILED'd. De `allowed_tools`-lijst
|
|
// doet de echte sandboxing (geen Bash, geen Edit, alleen Read/Grep/etc).
|
|
IDEA_GRILL: {
|
|
model: 'claude-sonnet-4-6',
|
|
thinking_budget: 12000,
|
|
permission_mode: 'acceptEdits',
|
|
max_turns: 15,
|
|
allowed_tools: [
|
|
'Read', 'Grep', 'Glob', 'WebSearch', 'AskUserQuestion',
|
|
'mcp__scrum4me__update_idea_grill_md',
|
|
'mcp__scrum4me__log_idea_decision',
|
|
'mcp__scrum4me__update_job_status',
|
|
'mcp__scrum4me__ask_user_question',
|
|
'mcp__scrum4me__get_question_answer',
|
|
],
|
|
},
|
|
IDEA_MAKE_PLAN: {
|
|
model: 'claude-opus-4-7',
|
|
thinking_budget: 24000,
|
|
permission_mode: 'acceptEdits',
|
|
max_turns: 20,
|
|
allowed_tools: [
|
|
'Read', 'Grep', 'Glob', 'WebSearch', 'AskUserQuestion', 'Write',
|
|
'mcp__scrum4me__update_idea_plan_md',
|
|
'mcp__scrum4me__log_idea_decision',
|
|
'mcp__scrum4me__update_job_status',
|
|
],
|
|
},
|
|
IDEA_REVIEW_PLAN: {
|
|
model: 'claude-opus-4-7',
|
|
thinking_budget: 6000,
|
|
permission_mode: 'acceptEdits',
|
|
max_turns: 1,
|
|
allowed_tools: [
|
|
'Read', 'Write', 'Grep', 'Glob',
|
|
'mcp__scrum4me__update_idea_plan_reviewed',
|
|
'mcp__scrum4me__log_idea_decision',
|
|
'mcp__scrum4me__update_job_status',
|
|
'mcp__scrum4me__ask_user_question',
|
|
],
|
|
},
|
|
PLAN_CHAT: {
|
|
model: 'claude-sonnet-4-6',
|
|
thinking_budget: 6000,
|
|
permission_mode: 'acceptEdits',
|
|
max_turns: 5,
|
|
allowed_tools: [
|
|
'Read', 'Grep', 'AskUserQuestion',
|
|
'mcp__scrum4me__update_job_status',
|
|
],
|
|
},
|
|
TASK_IMPLEMENTATION: {
|
|
model: 'claude-sonnet-4-6',
|
|
thinking_budget: 6000,
|
|
permission_mode: 'bypassPermissions',
|
|
max_turns: 50,
|
|
allowed_tools: TASK_TOOLS,
|
|
},
|
|
SPRINT_IMPLEMENTATION: {
|
|
model: 'claude-sonnet-4-6',
|
|
thinking_budget: 6000,
|
|
permission_mode: 'bypassPermissions',
|
|
max_turns: null,
|
|
// Geen `mcp__scrum4me__job_heartbeat` — de runner verlengt de lease
|
|
// automatisch via setInterval (zie scrum4me-docker/bin/run-one-job.ts).
|
|
allowed_tools: [
|
|
...TASK_TOOLS,
|
|
'mcp__scrum4me__update_task_execution',
|
|
'mcp__scrum4me__verify_sprint_task',
|
|
],
|
|
},
|
|
}
|
|
|
|
const FALLBACK: JobConfig = {
|
|
model: 'claude-sonnet-4-6',
|
|
thinking_budget: 6000,
|
|
permission_mode: 'default',
|
|
max_turns: 50,
|
|
allowed_tools: null,
|
|
}
|
|
|
|
export function getKindDefault(kind: string): JobConfig {
|
|
return KIND_DEFAULTS[kind] ?? FALLBACK
|
|
}
|
|
|
|
// max_turns en allowed_tools blijven kind-default (geen product/task override
|
|
// in V1 — als de behoefte ontstaat, voeg analoge velden toe aan Product/Task).
|
|
export function resolveJobConfig(
|
|
job: JobInput,
|
|
product: ProductInput,
|
|
task?: TaskInput,
|
|
): JobConfig {
|
|
const base = getKindDefault(job.kind)
|
|
|
|
const model = (
|
|
task?.requires_opus
|
|
? 'claude-opus-4-7'
|
|
: job.requested_model ?? product.preferred_model ?? base.model
|
|
) as ClaudeModel
|
|
|
|
const thinking_budget =
|
|
job.requested_thinking_budget ?? product.thinking_budget_default ?? base.thinking_budget
|
|
|
|
const permission_mode = (job.requested_permission_mode ??
|
|
product.preferred_permission_mode ??
|
|
base.permission_mode) as PermissionMode
|
|
|
|
return {
|
|
model,
|
|
thinking_budget,
|
|
permission_mode,
|
|
max_turns: base.max_turns,
|
|
allowed_tools: base.allowed_tools,
|
|
}
|
|
}
|
|
|
|
// Map numeriek thinking_budget naar de Claude CLI 2.1.x --effort flag.
|
|
// Returns null als de flag niet meegegeven moet worden (budget = 0).
|
|
//
|
|
// Mapping (sync met scrum4me-mcp/src/lib/job-config.ts):
|
|
// 0 → null (geen --effort flag)
|
|
// 1..6000 → "medium"
|
|
// 6001..12000 → "high"
|
|
// 12001..24000→ "xhigh"
|
|
// >24000 → "max"
|
|
export function mapBudgetToEffort(budget: number): string | null {
|
|
if (budget <= 0) return null
|
|
if (budget <= 6000) return 'medium'
|
|
if (budget <= 12000) return 'high'
|
|
if (budget <= 24000) return 'xhigh'
|
|
return 'max'
|
|
}
|
|
|
|
// Snapshot-velden voor ClaudeJob.requested_*. Bij elke enqueue laden we
|
|
// product (voor preferred_*) en optioneel task (voor requires_opus), draaien
|
|
// de resolver, en schrijven het resultaat als auditspoor in de job-rij.
|
|
export type ClaudeJobSnapshotFields = {
|
|
requested_model: string
|
|
requested_thinking_budget: number
|
|
requested_permission_mode: string
|
|
}
|
|
|
|
export function snapshotFromConfig(cfg: JobConfig): ClaudeJobSnapshotFields {
|
|
return {
|
|
requested_model: cfg.model,
|
|
requested_thinking_budget: cfg.thinking_budget,
|
|
requested_permission_mode: cfg.permission_mode,
|
|
}
|
|
}
|