// engine/universal-rules/rules/planu-workflow.ts — SPEC-779
// Universal rule: Planu Workflow (migrated from rules-generator.ts)
function buildBody() {
    return `# Planu SDD Workflow (MANDATORY)

Auto-generated by \`init_project\`. Do not edit manually.

## Spec Lifecycle

| State | Meaning |
|-------|---------|
| draft | created, not reviewed |
| review | ready for approval |
| approved | safe to implement |
| implementing | work in progress |
| done | implemented + validated |

Flow: \`facilitate → create_spec → discovery evidence → challenge_spec → check_readiness → approve → task plan → implement → traceability evidence → validate → done\`

## Evidence Gates

For non-trivial specs, Planu blocks lifecycle transitions unless evidence is present:

| Transition | Required evidence |
|------------|-------------------|
| approved | Discovery evidence: rules, examples, open questions, out-of-scope, glossary |
| implementing | Task plan mapped to acceptance criteria |
| done | Traceability matrix covering every acceptance criterion |
| done for API/UI/event/MCP work | Passing contract validation evidence |

Evidence lives in the external Planu handoff store, not under \`planu/specs/<spec>/\`. Spec folders remain \`spec.md\`-only. Trivial specs may use lightweight evidence, but \`done\` still needs at least one traceability row.

## When to use \`facilitate\`

Any new feature, bug fix, refactor, integration, or task > 5 min.

## Session Start

1. \`planu_status\` — check active specs
2. Resume any \`implementing\` spec before starting new work

## Session End

- \`session_checkpoint\` — persist context for the next session
- \`update_status(done)\` — if work is complete

## Quick Reference

| Goal | Tool |
|------|------|
| New feature | \`facilitate("what to build")\` |
| Project status | \`planu_status\` |
| Find related specs | \`semantic_search("keywords")\` |
| List approved work | \`list_specs\` with \`status: approved\` |
| Mark done | \`update_status\` → \`done\` |
| Verify | \`validate\` |
| Save session | \`session_checkpoint\` |

## Rules

- NEVER write code before spec is \`approved\`
- NEVER skip \`validate\` after implementation
- NEVER create design docs outside \`planu/specs/\`

## Model Selection (MANDATORY)

Use the cheapest/fastest model that can handle the task:

| Task type | Capability needed |
|-----------|-------------------|
| Search, explore, read, grep, summarize | smallest / fastest model |
| Implement, fix, refactor, tests, UI | mid-tier model |
| Architecture, complex debug, multi-system planning | most capable model |

**Claude Code users**: haiku (read-only) · sonnet (implement) · opus (architecture).
Set \`CLAUDE_CODE_SUBAGENT_MODEL=haiku\` in \`.env\` for automatic haiku on all read-only subagents (4–18x cheaper).

**Cursor / Windsurf / other**: use the equivalent lightweight model for search/read subagents.

## Token Optimization

- Lead with action/result — not reasoning. One sentence beats three.
- Never repeat what the user said or file contents back to them.
- Delegate to subagents: file searches, multi-file reads, independent tasks
- Stop early: task done → stop. No trailing "let me know if..." summaries.

## Output Quality

- Summarize tool results in plain language — never dump raw JSON to the user
- Keep output < 500 tokens for read operations, < 200 tokens for write confirmations
- After every tool call: explain what happened in simple terms
`;
}
export const planuWorkflowRule = {
    id: 'planu-workflow',
    name: 'Planu SDD Workflow',
    description: 'SDD spec lifecycle, session start/end, model selection, token optimization.',
    category: 'workflow',
    applicableHosts: ['all'],
    defaultEnabled: true,
    buildContent: (_host) => buildBody(),
};
//# sourceMappingURL=planu-workflow.js.map