feat: unified task.json schema migration and multi-module updates

- Create task-schema.json (JSON Schema draft-07) with 10 field blocks fusing
  Unified JSONL, 6-field Task JSON, and Solution Schema advantages
- Migrate unified-execute-with-file from JSONL to .task/*.json directory scanning
- Migrate 3 producers (lite-plan, plan-converter, collaborative-plan) to
  .task/*.json multi-file output
- Add review-cycle Phase 7.5 export-to-tasks (FIX-*.json) and issue-resolve
  --export-tasks option
- Add schema compatibility annotations to action-planning-agent, workflow-plan,
  and tdd-plan
- Add spec-generator skill phases and templates
- Add memory v2 pipeline (consolidation, extraction, job scheduler, embedder)
- Add secret-redactor utility and core-memory enhancements
- Add codex-lens accuracy benchmarks and staged env config overrides
This commit is contained in:
catlog22
2026-02-11 17:40:56 +08:00
parent 7aa1038951
commit 99ee4e7d36
36 changed files with 7823 additions and 315 deletions

View File

@@ -0,0 +1,242 @@
# Phase 1: Discovery
Parse input, analyze the seed idea, optionally explore codebase, establish session configuration.
## Objective
- Generate session ID and create output directory
- Parse user input (text description or file reference)
- Analyze seed via Gemini CLI to extract problem space dimensions
- Conditionally explore codebase for existing patterns and constraints
- Gather user preferences (depth, focus areas) via interactive confirmation
- Write `spec-config.json` as the session state file
## Input
- Dependency: `$ARGUMENTS` (user input from command)
- Flags: `-y` (auto mode), `-c` (continue mode)
## Execution Steps
### Step 1: Session Initialization
```javascript
// Parse arguments
const args = $ARGUMENTS;
const autoMode = args.includes('-y') || args.includes('--yes');
const continueMode = args.includes('-c') || args.includes('--continue');
// Extract the idea/topic (remove flags)
const idea = args.replace(/(-y|--yes|-c|--continue)\s*/g, '').trim();
// Generate session ID
const slug = idea.toLowerCase()
.replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-')
.replace(/^-|-$/g, '')
.slice(0, 40);
const date = new Date().toISOString().slice(0, 10);
const sessionId = `SPEC-${slug}-${date}`;
const workDir = `.workflow/.spec/${sessionId}`;
// Check for continue mode
if (continueMode) {
// Find existing session
const existingSessions = Glob('.workflow/.spec/SPEC-*/spec-config.json');
// If slug matches an existing session, load it and resume
// Read spec-config.json, find first incomplete phase, jump to that phase
return; // Resume logic handled by orchestrator
}
// Create output directory
Bash(`mkdir -p "${workDir}"`);
```
### Step 2: Input Parsing
```javascript
// Determine input type
if (idea.startsWith('@') || idea.endsWith('.md') || idea.endsWith('.txt')) {
// File reference - read and extract content
const filePath = idea.replace(/^@/, '');
const fileContent = Read(filePath);
// Use file content as the seed
inputType = 'file';
seedInput = fileContent;
} else {
// Direct text description
inputType = 'text';
seedInput = idea;
}
```
### Step 3: Seed Analysis via Gemini CLI
```javascript
Bash({
command: `ccw cli -p "PURPOSE: Analyze this seed idea/requirement to extract structured problem space dimensions.
Success: Clear problem statement, target users, domain identification, 3-5 exploration dimensions.
SEED INPUT:
${seedInput}
TASK:
- Extract a clear problem statement (what problem does this solve?)
- Identify target users (who benefits?)
- Determine the domain (technical, business, consumer, etc.)
- List constraints (budget, time, technical, regulatory)
- Generate 3-5 exploration dimensions (key areas to investigate)
- Assess complexity: simple (1-2 components), moderate (3-5 components), complex (6+ components)
MODE: analysis
EXPECTED: JSON output with fields: problem_statement, target_users[], domain, constraints[], dimensions[], complexity
CONSTRAINTS: Be specific and actionable, not vague
" --tool gemini --mode analysis`,
run_in_background: true
});
// Wait for CLI result before continuing
```
Parse the CLI output into structured `seedAnalysis`:
```javascript
const seedAnalysis = {
problem_statement: "...",
target_users: ["..."],
domain: "...",
constraints: ["..."],
dimensions: ["..."]
};
const complexity = "moderate"; // from CLI output
```
### Step 4: Codebase Exploration (Conditional)
```javascript
// Detect if running inside a project with code
const hasCodebase = Glob('**/*.{ts,js,py,java,go,rs}').length > 0
|| Glob('package.json').length > 0
|| Glob('Cargo.toml').length > 0;
if (hasCodebase) {
Task({
subagent_type: "cli-explore-agent",
run_in_background: false,
description: `Explore codebase for spec: ${slug}`,
prompt: `
## Spec Generator Context
Topic: ${seedInput}
Dimensions: ${seedAnalysis.dimensions.join(', ')}
Session: ${workDir}
## MANDATORY FIRST STEPS
1. Search for code related to topic keywords
2. Read project config files (package.json, pyproject.toml, etc.) if they exist
## Exploration Focus
- Identify existing implementations related to the topic
- Find patterns that could inform architecture decisions
- Map current architecture constraints
- Locate integration points and dependencies
## Output
Write findings to: ${workDir}/discovery-context.json
Schema:
{
"relevant_files": [{"path": "...", "relevance": "high|medium|low", "rationale": "..."}],
"existing_patterns": ["pattern descriptions"],
"architecture_constraints": ["constraint descriptions"],
"integration_points": ["integration point descriptions"],
"tech_stack": {"languages": [], "frameworks": [], "databases": []},
"_metadata": { "exploration_type": "spec-discovery", "timestamp": "ISO8601" }
}
`
});
}
```
### Step 5: User Confirmation (Interactive)
```javascript
if (!autoMode) {
// Confirm problem statement and select depth
AskUserQuestion({
questions: [
{
question: `Problem statement: "${seedAnalysis.problem_statement}" - Is this accurate?`,
header: "Problem",
multiSelect: false,
options: [
{ label: "Accurate", description: "Proceed with this problem statement" },
{ label: "Needs adjustment", description: "I'll refine the problem statement" }
]
},
{
question: "What specification depth do you need?",
header: "Depth",
multiSelect: false,
options: [
{ label: "Light", description: "Quick overview - key decisions only" },
{ label: "Standard (Recommended)", description: "Balanced detail for most projects" },
{ label: "Comprehensive", description: "Maximum detail for complex/critical projects" }
]
},
{
question: "Which areas should we focus on?",
header: "Focus",
multiSelect: true,
options: seedAnalysis.dimensions.map(d => ({ label: d, description: `Explore ${d} in depth` }))
}
]
});
} else {
// Auto mode defaults
depth = "standard";
focusAreas = seedAnalysis.dimensions;
}
```
### Step 6: Write spec-config.json
```javascript
const specConfig = {
session_id: sessionId,
seed_input: seedInput,
input_type: inputType,
timestamp: new Date().toISOString(),
mode: autoMode ? "auto" : "interactive",
complexity: complexity,
depth: depth,
focus_areas: focusAreas,
seed_analysis: seedAnalysis,
has_codebase: hasCodebase,
phasesCompleted: [
{
phase: 1,
name: "discovery",
output_file: "spec-config.json",
completed_at: new Date().toISOString()
}
]
};
Write(`${workDir}/spec-config.json`, JSON.stringify(specConfig, null, 2));
```
## Output
- **File**: `spec-config.json`
- **File**: `discovery-context.json` (optional, if codebase detected)
- **Format**: JSON
## Quality Checklist
- [ ] Session ID matches `SPEC-{slug}-{date}` format
- [ ] Problem statement exists and is >= 20 characters
- [ ] Target users identified (>= 1)
- [ ] 3-5 exploration dimensions generated
- [ ] spec-config.json written with all required fields
- [ ] Output directory created
## Next Phase
Proceed to [Phase 2: Product Brief](02-product-brief.md) with the generated spec-config.json.

View File

@@ -0,0 +1,226 @@
# Phase 2: Product Brief
Generate a product brief through multi-perspective CLI analysis, establishing "what" and "why".
## Objective
- Read Phase 1 outputs (spec-config.json, discovery-context.json)
- Launch 3 parallel CLI analyses from product, technical, and user perspectives
- Synthesize convergent themes and conflicting views
- Optionally refine with user input
- Generate product-brief.md using template
## Input
- Dependency: `{workDir}/spec-config.json`
- Optional: `{workDir}/discovery-context.json`
- Config: `{workDir}/spec-config.json`
- Template: `templates/product-brief.md`
## Execution Steps
### Step 1: Load Phase 1 Context
```javascript
const specConfig = JSON.parse(Read(`${workDir}/spec-config.json`));
const { seed_analysis, seed_input, has_codebase, depth, focus_areas } = specConfig;
let discoveryContext = null;
if (has_codebase) {
try {
discoveryContext = JSON.parse(Read(`${workDir}/discovery-context.json`));
} catch (e) {
// No discovery context available, proceed without
}
}
// Build shared context string for CLI prompts
const sharedContext = `
SEED: ${seed_input}
PROBLEM: ${seed_analysis.problem_statement}
TARGET USERS: ${seed_analysis.target_users.join(', ')}
DOMAIN: ${seed_analysis.domain}
CONSTRAINTS: ${seed_analysis.constraints.join(', ')}
FOCUS AREAS: ${focus_areas.join(', ')}
${discoveryContext ? `
CODEBASE CONTEXT:
- Existing patterns: ${discoveryContext.existing_patterns?.slice(0,5).join(', ') || 'none'}
- Architecture constraints: ${discoveryContext.architecture_constraints?.slice(0,3).join(', ') || 'none'}
- Tech stack: ${JSON.stringify(discoveryContext.tech_stack || {})}
` : ''}`;
```
### Step 2: Multi-CLI Parallel Analysis (3 perspectives)
Launch 3 CLI calls in parallel:
**Product Perspective (Gemini)**:
```javascript
Bash({
command: `ccw cli -p "PURPOSE: Product analysis for specification - identify market fit, user value, and success criteria.
Success: Clear vision, measurable goals, competitive positioning.
${sharedContext}
TASK:
- Define product vision (1-3 sentences, aspirational)
- Analyze market/competitive landscape
- Define 3-5 measurable success metrics
- Identify scope boundaries (in-scope vs out-of-scope)
- Assess user value proposition
- List assumptions that need validation
MODE: analysis
EXPECTED: Structured product analysis with: vision, goals with metrics, scope, competitive positioning, assumptions
CONSTRAINTS: Focus on 'what' and 'why', not 'how'
" --tool gemini --mode analysis`,
run_in_background: true
});
```
**Technical Perspective (Codex)**:
```javascript
Bash({
command: `ccw cli -p "PURPOSE: Technical feasibility analysis for specification - assess implementation viability and constraints.
Success: Clear technical constraints, integration complexity, technology recommendations.
${sharedContext}
TASK:
- Assess technical feasibility of the core concept
- Identify technical constraints and blockers
- Evaluate integration complexity with existing systems
- Recommend technology approach (high-level)
- Identify technical risks and dependencies
- Estimate complexity: simple/moderate/complex
MODE: analysis
EXPECTED: Technical analysis with: feasibility assessment, constraints, integration complexity, tech recommendations, risks
CONSTRAINTS: Focus on feasibility and constraints, not detailed architecture
" --tool codex --mode analysis`,
run_in_background: true
});
```
**User Perspective (Claude)**:
```javascript
Bash({
command: `ccw cli -p "PURPOSE: User experience analysis for specification - understand user journeys, pain points, and UX considerations.
Success: Clear user personas, journey maps, UX requirements.
${sharedContext}
TASK:
- Elaborate user personas with goals and frustrations
- Map primary user journey (happy path)
- Identify key pain points in current experience
- Define UX success criteria
- List accessibility and usability considerations
- Suggest interaction patterns
MODE: analysis
EXPECTED: User analysis with: personas, journey map, pain points, UX criteria, interaction recommendations
CONSTRAINTS: Focus on user needs and experience, not implementation
" --tool claude --mode analysis`,
run_in_background: true
});
// STOP: Wait for all 3 CLI results before continuing
```
### Step 3: Synthesize Perspectives
```javascript
// After receiving all 3 CLI results:
// Extract convergent themes (all agree)
// Identify conflicting views (need resolution)
// Note unique contributions from each perspective
const synthesis = {
convergent_themes: [], // themes all 3 perspectives agree on
conflicts: [], // areas where perspectives differ
product_insights: [], // unique from product perspective
technical_insights: [], // unique from technical perspective
user_insights: [] // unique from user perspective
};
```
### Step 4: Interactive Refinement (Optional)
```javascript
if (!autoMode) {
// Present synthesis summary to user
// AskUserQuestion with:
// - Confirm vision statement
// - Resolve any conflicts between perspectives
// - Adjust scope if needed
AskUserQuestion({
questions: [
{
question: "Review the synthesized product brief. Any adjustments needed?",
header: "Review",
multiSelect: false,
options: [
{ label: "Looks good", description: "Proceed to PRD generation" },
{ label: "Adjust scope", description: "Narrow or expand the scope" },
{ label: "Revise vision", description: "Refine the vision statement" }
]
}
]
});
}
```
### Step 5: Generate product-brief.md
```javascript
// Read template
const template = Read('templates/product-brief.md');
// Fill template with synthesized content
// Apply document-standards.md formatting rules
// Write with YAML frontmatter
const frontmatter = `---
session_id: ${specConfig.session_id}
phase: 2
document_type: product-brief
status: ${autoMode ? 'complete' : 'draft'}
generated_at: ${new Date().toISOString()}
stepsCompleted: ["load-context", "multi-cli-analysis", "synthesis", "generation"]
version: 1
dependencies:
- spec-config.json
---`;
// Combine frontmatter + filled template content
Write(`${workDir}/product-brief.md`, `${frontmatter}\n\n${filledContent}`);
// Update spec-config.json
specConfig.phasesCompleted.push({
phase: 2,
name: "product-brief",
output_file: "product-brief.md",
completed_at: new Date().toISOString()
});
Write(`${workDir}/spec-config.json`, JSON.stringify(specConfig, null, 2));
```
## Output
- **File**: `product-brief.md`
- **Format**: Markdown with YAML frontmatter
## Quality Checklist
- [ ] Vision statement: clear, 1-3 sentences
- [ ] Problem statement: specific and measurable
- [ ] Target users: >= 1 persona with needs
- [ ] Goals: >= 2 with measurable metrics
- [ ] Scope: in-scope and out-of-scope defined
- [ ] Multi-perspective synthesis included
- [ ] YAML frontmatter valid
## Next Phase
Proceed to [Phase 3: Requirements](03-requirements.md) with the generated product-brief.md.