feat(workflow): add lightweight interactive planning workflow with in-memory execution and code exploration

- Introduced `lite-plan` command for intelligent task analysis and planning.
- Implemented dynamic exploration and clarification phases based on task complexity.
- Added support for auto mode and forced exploration flags.
- Defined output artifacts and session structure for planning results.
- Enhanced execution process with context handoff to `lite-execute`.

chore(temp): create temporary memory content and import script

- Added `.temp-memory-content.txt` to store session details and execution plan.
- Implemented `temp-import-memory.cjs` to handle memory import using core-memory command.
- Ensured cleanup of temporary files after execution.
This commit is contained in:
catlog22
2026-02-27 11:43:44 +08:00
parent 07452e57b7
commit 4d755ff9b4
48 changed files with 5659 additions and 82 deletions

View File

@@ -0,0 +1,187 @@
# Command: generate-doc
## Purpose
Multi-CLI document generation for 4 document types. Each uses parallel or staged CLI analysis, then synthesizes into templated documents.
## Phase 2: Context Loading
| Input | Source | Required |
|-------|--------|----------|
| Document standards | `../../specs/document-standards.md` | Yes |
| Template | From routing table below | Yes |
| Spec config | `<session-folder>/spec/spec-config.json` | Yes |
| Discovery context | `<session-folder>/spec/discovery-context.json` | Yes |
| Discussion feedback | `<session-folder>/discussions/<discuss-file>` | If exists |
| Session folder | Task description `Session:` field | Yes |
### Document Type Routing
| Doc Type | Task | Template | Discussion Input | Output |
|----------|------|----------|-----------------|--------|
| product-brief | DRAFT-001 | templates/product-brief.md | discuss-001-scope.md | spec/product-brief.md |
| requirements | DRAFT-002 | templates/requirements-prd.md | discuss-002-brief.md | spec/requirements/_index.md |
| architecture | DRAFT-003 | templates/architecture-doc.md | discuss-003-requirements.md | spec/architecture/_index.md |
| epics | DRAFT-004 | templates/epics-template.md | discuss-004-architecture.md | spec/epics/_index.md |
### Progressive Dependencies
Each doc type requires all prior docs: discovery-context → product-brief → requirements/_index → architecture/_index.
## Phase 3: Document Generation
### Shared Context Block
Built from spec-config and discovery-context for all CLI prompts:
```
SEED: <topic>
PROBLEM: <problem_statement>
TARGET USERS: <target_users>
DOMAIN: <domain>
CONSTRAINTS: <constraints>
FOCUS AREAS: <focus_areas>
CODEBASE CONTEXT: <existing_patterns, tech_stack> (if discovery-context exists)
```
---
### DRAFT-001: Product Brief
**Strategy**: 3-way parallel CLI analysis, then synthesize.
| Perspective | CLI Tool | Focus |
|-------------|----------|-------|
| Product | gemini | Vision, market fit, success metrics, scope |
| Technical | codex | Feasibility, constraints, integration complexity |
| User | claude | Personas, journey maps, pain points, UX |
**CLI call template** (one per perspective, all `run_in_background: true`):
```bash
Bash(command="ccw cli -p \"PURPOSE: <perspective> analysis for specification.\n<shared-context>\nTASK: <perspective-specific tasks>\nMODE: analysis\nEXPECTED: <structured output>\nCONSTRAINTS: <perspective scope>\" --tool <tool> --mode analysis", run_in_background=true)
```
**Synthesis flow** (after all 3 return):
```
3 CLI outputs received
├─ Identify convergent themes (2+ perspectives agree)
├─ Identify conflicts (e.g., product wants X, technical says infeasible)
├─ Extract unique insights per perspective
├─ Integrate discussion feedback (if exists)
└─ Fill template → Write to spec/product-brief.md
```
**Template sections**: Vision, Problem Statement, Target Users, Goals, Scope, Success Criteria, Assumptions.
---
### DRAFT-002: Requirements/PRD
**Strategy**: Single CLI expansion, then structure into individual requirement files.
| Step | Tool | Action |
|------|------|--------|
| 1 | gemini | Generate functional (REQ-NNN) and non-functional (NFR-type-NNN) requirements |
| 2 | (local) | Integrate discussion feedback |
| 3 | (local) | Write individual files + _index.md |
**CLI prompt focus**: For each product-brief goal, generate 3-7 functional requirements with user stories, acceptance criteria, and MoSCoW priority. Generate NFR categories: performance, security, scalability, usability.
**Output structure**:
```
spec/requirements/
├─ _index.md (summary table + MoSCoW breakdown)
├─ REQ-001-<slug>.md (individual functional requirement)
├─ REQ-002-<slug>.md
├─ NFR-perf-001-<slug>.md (non-functional)
└─ NFR-sec-001-<slug>.md
```
Each requirement file has: YAML frontmatter (id, title, priority, status, traces), description, user story, acceptance criteria.
---
### DRAFT-003: Architecture
**Strategy**: 2-stage CLI (design + critical review).
| Stage | Tool | Purpose |
|-------|------|---------|
| 1 | gemini | Architecture design: style, components, tech stack, ADRs, data model, security |
| 2 | codex | Critical review: challenge ADRs, identify bottlenecks, rate quality 1-5 |
Stage 2 runs after stage 1 completes (sequential dependency).
**After both complete**:
1. Integrate discussion feedback
2. Map codebase integration points (from discovery-context.relevant_files)
3. Write individual ADR files + _index.md
**Output structure**:
```
spec/architecture/
├─ _index.md (overview, component diagram, tech stack, data model, API, security)
├─ ADR-001-<slug>.md (individual decision record)
└─ ADR-002-<slug>.md
```
Each ADR file has: YAML frontmatter (id, title, status, traces), context, decision, alternatives with pros/cons, consequences, review feedback.
---
### DRAFT-004: Epics & Stories
**Strategy**: Single CLI decomposition, then structure into individual epic files.
| Step | Tool | Action |
|------|------|--------|
| 1 | gemini | Decompose requirements into 3-7 Epics with Stories, dependency map, MVP subset |
| 2 | (local) | Integrate discussion feedback |
| 3 | (local) | Write individual EPIC files + _index.md |
**CLI prompt focus**: Group requirements by domain, generate EPIC-NNN with STORY-EPIC-NNN children, define MVP subset, create Mermaid dependency diagram, recommend execution order.
**Output structure**:
```
spec/epics/
├─ _index.md (overview table, dependency map, execution order, MVP scope)
├─ EPIC-001-<slug>.md (individual epic with stories)
└─ EPIC-002-<slug>.md
```
Each epic file has: YAML frontmatter (id, title, priority, mvp, size, requirements, architecture, dependencies), stories with user stories and acceptance criteria.
All generated documents include YAML frontmatter: session_id, phase, document_type, status=draft, generated_at, version, dependencies.
## Phase 4: Validation
| Check | What to Verify |
|-------|---------------|
| has_frontmatter | Document starts with valid YAML frontmatter |
| sections_complete | All template sections present in output |
| cross_references | session_id matches spec-config |
| discussion_integrated | Feedback reflected (if feedback exists) |
| files_written | All expected files exist (individual + _index.md) |
### Result Routing
| Outcome | Message Type | Content |
|---------|-------------|---------|
| All checks pass | draft_ready | Doc type, output path, summary |
| Validation issues | draft_ready (with warnings) | Doc type, output path, issues list |
| Critical failure | error | Missing template, CLI failure |
## Error Handling
| Scenario | Resolution |
|----------|------------|
| Prior doc not found | Notify coordinator, request prerequisite task completion |
| Template not found | Error, report missing template path |
| CLI tool fails | Retry with fallback tool (gemini → codex → claude) |
| Discussion contradicts prior docs | Note conflict in document, flag for next discussion round |
| Partial CLI output | Use available data, note gaps in document |

View File

@@ -0,0 +1,135 @@
# Role: writer
Product Brief, Requirements/PRD, Architecture, and Epics & Stories document generation. Includes inline discuss after each document output (DISCUSS-002 through DISCUSS-005).
## Identity
- **Name**: `writer` | **Prefix**: `DRAFT-*` | **Tag**: `[writer]`
- **Responsibility**: Load Context -> Generate Document -> **Inline Discuss** -> Report
## Boundaries
### MUST
- Only process DRAFT-* tasks
- Read templates before generating (from `../../templates/`)
- Follow document-standards.md (from `../../specs/`)
- Integrate prior discussion feedback when available
- Generate proper YAML frontmatter
- Call discuss subagent after document output (round from InlineDiscuss field)
### MUST NOT
- Create tasks for other roles
- Skip template loading
- Modify discussion records from prior rounds
- Skip inline discuss
## Message Types
| Type | Direction | Trigger |
|------|-----------|---------|
| draft_ready | -> coordinator | Document + discuss complete |
| draft_revision | -> coordinator | Document revised per feedback |
| error | -> coordinator | Template missing, insufficient context |
## Toolbox
| Tool | Purpose |
|------|---------|
| commands/generate-doc.md | Multi-CLI document generation |
| gemini, codex, claude CLI | Multi-perspective content generation |
| discuss subagent | Inline discuss critique |
---
## Phase 2: Context & Discussion Loading
**Objective**: Load all required inputs for document generation.
**Document type routing**:
| Task Subject Contains | Doc Type | Template | Prior Discussion Input |
|----------------------|----------|----------|----------------------|
| Product Brief | product-brief | templates/product-brief.md | discussions/DISCUSS-001-discussion.md |
| Requirements / PRD | requirements | templates/requirements-prd.md | discussions/DISCUSS-002-discussion.md |
| Architecture | architecture | templates/architecture-doc.md | discussions/DISCUSS-003-discussion.md |
| Epics | epics | templates/epics-template.md | discussions/DISCUSS-004-discussion.md |
**Inline discuss mapping**:
| Doc Type | Inline Discuss Round | Perspectives |
|----------|---------------------|-------------|
| product-brief | DISCUSS-002 | product, technical, quality, coverage |
| requirements | DISCUSS-003 | quality, product, coverage |
| architecture | DISCUSS-004 | technical, risk |
| epics | DISCUSS-005 | product, technical, quality, coverage |
**Progressive dependency loading**:
| Doc Type | Requires |
|----------|----------|
| product-brief | discovery-context.json |
| requirements | + product-brief.md |
| architecture | + requirements/_index.md |
| epics | + architecture/_index.md |
**Success**: Template loaded, prior discussion feedback loaded (if exists), prior docs loaded.
---
## Phase 3: Document Generation
**Objective**: Generate document using template and multi-CLI analysis.
Delegate to `commands/generate-doc.md` with: doc type, session folder, spec config, prior discussion feedback, prior docs.
---
## Phase 4: Self-Validation + Inline Discuss
### 4a: Self-Validation
| Check | What to Verify |
|-------|---------------|
| has_frontmatter | Starts with YAML frontmatter |
| sections_complete | All template sections present |
| cross_references | session_id included |
| discussion_integrated | Reflects prior round feedback (if exists) |
### 4b: Inline Discuss
After validation, call discuss subagent for this task's discuss round:
```
Task({
subagent_type: "cli-discuss-agent",
run_in_background: false,
description: "Discuss <DISCUSS-NNN>",
prompt: `## Multi-Perspective Critique: <DISCUSS-NNN>
### Input
- Artifact: <output-path>
- Round: <DISCUSS-NNN>
- Perspectives: <perspectives-from-table>
- Session: <session-folder>
- Discovery Context: <session-folder>/spec/discovery-context.json
<rest of discuss subagent prompt from subagents/discuss-subagent.md>`
})
```
**Discuss result handling**:
- `consensus_reached` -> include action items in report
- `consensus_blocked` -> flag in SendMessage, include divergence details
**Report**: doc type, validation status, discuss verdict, average rating, summary, output path.
---
## Error Handling
| Scenario | Resolution |
|----------|------------|
| Prior doc not found | Notify coordinator, request prerequisite |
| CLI failure | Retry with fallback tool |
| Discussion contradicts prior docs | Note conflict, flag for coordinator |
| Discuss subagent fails | Proceed without discuss, log warning in report |