feat: enhance spec loading capabilities and add new categories

- Added support for loading specs from new categories: debug, test, review, and validation.
- Updated various agents and skills to include instructions for loading project context from the new spec categories.
- Introduced new spec documents for test conventions, review standards, and validation rules to improve project guidelines.
- Enhanced the frontend to support new watcher settings and display auto-watch status.
- Improved the spec index builder to accommodate new categories and ensure proper loading of specifications.
This commit is contained in:
catlog22
2026-03-20 15:06:57 +08:00
parent 2b43b6be7b
commit d843112094
39 changed files with 356 additions and 29 deletions

View File

@@ -31,6 +31,9 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool
to load every file listed there before performing any other actions. This is your
primary context.
**Load Project Context** (from spec system):
- Run: `ccw spec load --category test` for test framework context, coverage targets, and conventions
**Core responsibilities:**
- **FIRST: Execute CLI analysis** with appropriate templates and context
- Parse structured results (fix strategies, root causes, modification points)

View File

@@ -36,6 +36,7 @@ Phase 5: Fix & Verification
## Phase 1: Bug Analysis
**Load Project Context** (from spec system):
- Load debug specs using: `ccw spec load --category debug` for known issues, workarounds, and root-cause notes
- Load exploration specs using: `ccw spec load --category exploration` for tech stack context and coding constraints
**Session Setup**:

View File

@@ -383,6 +383,7 @@ Bash(
### Context Loading (Inherited from code-developer)
**Standard Context Sources**:
- Test specs: Run `ccw spec load --category test` for test framework context, conventions, and coverage targets
- Task JSON: `description`, `convergence.criteria`, `focus_paths`
- Context Package: `context_package_path` → brainstorm artifacts, exploration results
- Tech Stack: `meta.shared_context.tech_stack` (skip auto-detection if present)

View File

@@ -52,6 +52,9 @@ Read("d:\Claude_dms3\.claude\agents\action-planning-agent.md")
```
<!-- TODO: verify mandatory read path -->
**Load Project Context** (from spec system):
- Run: `ccw spec load --category test` for test framework, coverage targets, and conventions
</role>
<test_specification_reference>

View File

@@ -25,6 +25,7 @@ You are a test context discovery specialist focused on gathering test coverage i
**Mandatory Initial Read:**
- Project `CLAUDE.md` for coding standards and conventions
- Test session metadata (`workflow-session.json`) for session context
- Run: `ccw spec load --category test` for test framework, coverage targets, and conventions
**Core Responsibilities:**
- Coverage-first analysis of existing tests

View File

@@ -34,6 +34,9 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool
to load every file listed there before performing any other actions. This is your
primary context.
**Load Project Context** (from spec system):
- Run: `ccw spec load --category test` for test framework, coverage targets, and conventions
## Core Philosophy
**"Tests Are the Review"** - When all tests pass across all layers, the code is approved and ready. No separate review process is needed.

View File

@@ -40,6 +40,8 @@ Multi-dimensional code review skill that analyzes code across 6 key dimensions a
└─────────────────────────────────────────────────────────────────┘
```
**Project Context**: Run `ccw spec load --category review` for review standards, checklists, and approval gates.
## Key Design Principles
1. **多维度审查**: 覆盖正确性、可读性、性能、安全性、测试覆盖、架构一致性六大维度

View File

@@ -98,6 +98,10 @@ Skill(skill="review-cycle", args="-y src/auth/**")
| module | [phases/review-module.md](phases/review-module.md) | review-module-cycle.md | Module-based review: path patterns → 7-dimension parallel analysis → aggregation → deep-dive → completion |
| fix | [phases/review-fix.md](phases/review-fix.md) | review-cycle-fix.md | Automated fix: export file → intelligent batching → parallel planning → execution → completion |
## Project Context
Run `ccw spec load --category review` for review standards, checklists, and approval gates.
## Core Rules
1. **Mode Detection First**: Parse input to determine session/module/fix mode before anything else

View File

@@ -9,6 +9,10 @@ Apply simplification rules from analysisResult to produce optimized content. Wri
- Fix pseudo-code format issues
- Write optimized content back to target file
## Pre-Step: Load Context
Run `ccw spec load --category validation` for verification rules and acceptance criteria to validate optimization preserves functional integrity.
## Execution
### Step 2.1: Apply Operations in Order

View File

@@ -19,6 +19,10 @@ Decompose the specification into executable Epics and Stories with dependency ma
## Execution Steps
### Step 0: Load Validation Context
Run `ccw spec load --category validation` for verification rules and acceptance criteria to validate epic decomposition.
### Step 1: Load Phase 2-4 Context
```javascript

View File

@@ -31,8 +31,9 @@ Root cause analysis from debug evidence.
## Phase 2: Load Evidence
1. Read upstream artifacts via team_msg(operation="get_state", role="reproducer")
2. Extract evidence paths from reproducer's state_update ref
1. Load debug specs: Run `ccw spec load --category debug` for known issues, workarounds, and root-cause notes
2. Read upstream artifacts via team_msg(operation="get_state", role="reproducer")
3. Extract evidence paths from reproducer's state_update ref
3. Load evidence-summary.json from session evidence/
4. Load all evidence files:
- Read screenshot files (visual inspection)

View File

@@ -26,7 +26,8 @@ Run test suites, collect coverage data, and perform automatic fix cycles when te
| Target layer | task description `layer: L1/L2/L3` | Yes |
1. Extract session path and target layer from task description
2. Read .msg/meta.json for strategy and generated test file list
2. Load validation specs: Run `ccw spec load --category validation` for verification rules and acceptance criteria
3. Read .msg/meta.json for strategy and generated test file list
3. Detect test command by framework:
| Framework | Command |

View File

@@ -21,7 +21,8 @@ Deep analysis on scan findings: triage, root cause / impact / optimization enric
| .msg/meta.json | <session>/.msg/meta.json | No |
1. Extract session path, input path, dimensions from task description
2. Load scan results. If missing or empty -> report clean, complete immediately
2. Load review specs: Run `ccw spec load --category review` for review standards, checklists, and approval gates
3. Load scan results. If missing or empty -> report clean, complete immediately
3. Load wisdom files from `<session>/wisdom/`
4. Triage findings into two buckets:

View File

@@ -18,7 +18,8 @@ Multi-dimension tech debt scanner. Scan codebase across 5 dimensions (code, arch
| .msg/meta.json | <session>/.msg/meta.json | Yes |
1. Extract session path and scan scope from task description
2. Read .msg/meta.json for team context
2. Load debug specs: Run `ccw spec load --category debug` for known issues, workarounds, and root-cause notes
3. Read .msg/meta.json for team context
3. Detect project type and framework:
| Signal File | Project Type |

View File

@@ -24,7 +24,8 @@ Execute tests, collect coverage, attempt auto-fix for failures. Acts as the Crit
| .msg/meta.json | <session>/wisdom/.msg/meta.json | No |
1. Extract session path and test directory from task description
2. Extract coverage target (default: 80%)
2. Load test specs: Run `ccw spec load --category test` for test framework conventions and coverage targets
3. Extract coverage target (default: 80%)
3. Read .msg/meta.json for framework info (from strategist namespace)
4. Determine test framework:

View File

@@ -22,7 +22,8 @@ Generate test code by layer (L1 unit / L2 integration / L3 E2E). Acts as the Gen
| .msg/meta.json | <session>/wisdom/.msg/meta.json | No |
1. Extract session path and layer from task description
2. Read test strategy:
2. Load test specs: Run `ccw spec load --category test` for test framework conventions and coverage targets
3. Read test strategy:
```
Read("<session>/strategy/test-strategy.md")

View File

@@ -18,7 +18,8 @@ Explore codebase structure through cli-explore-agent, collecting structured cont
| Task description | From task subject/description | Yes |
| Session path | Extracted from task description | Yes |
1. Extract session path, topic, perspective, dimensions from task description:
1. Load debug specs: Run `ccw spec load --category debug` for known issues and root-cause notes
2. Extract session path, topic, perspective, dimensions from task description:
| Field | Pattern | Default |
|-------|---------|---------|

View File

@@ -93,7 +93,7 @@ rg "password|token|secret|auth" -g "*.{ts,js,py}"
rg "eval|exec|innerHTML|dangerouslySetInnerHTML" -g "*.{ts,js,tsx}"
# Gemini security analysis
ccw spec load --category execution
ccw spec load --category review
ccw cli -p "
PURPOSE: Security audit of completed implementation
TASK: Review code for security vulnerabilities, insecure patterns, auth/authz issues
@@ -105,7 +105,7 @@ RULES: Focus on OWASP Top 10, authentication, authorization, data validation, in
**Architecture Review** (`architecture`):
```bash
ccw spec load --category execution
ccw spec load --category review
ccw cli -p "
PURPOSE: Architecture compliance review
TASK: Evaluate adherence to architectural patterns, identify technical debt, review design decisions
@@ -117,7 +117,7 @@ RULES: Check for patterns, separation of concerns, modularity, scalability
**Quality Review** (`quality`):
```bash
ccw spec load --category execution
ccw spec load --category review
ccw cli -p "
PURPOSE: Code quality and best practices review
TASK: Assess code readability, maintainability, adherence to best practices
@@ -139,7 +139,7 @@ for task_file in ${sessionPath}/.task/*.json; do
done
# Cross-check implementation against requirements
ccw spec load --category execution
ccw spec load --category review
ccw cli -p "
PURPOSE: Verify all requirements and acceptance criteria are met
TASK: Cross-check implementation summaries against original requirements

View File

@@ -8,6 +8,8 @@ allowed-tools: Skill, Agent, AskUserQuestion, TodoWrite, Read, Write, Edit, Bash
Test review and fix engine for lite-execute chain or standalone invocation.
**Project Context**: Run `ccw spec load --category test` for test framework conventions, coverage targets, and fixtures.
---
## Usage

View File

@@ -34,6 +34,10 @@ You **MUST** consider the user input before proceeding (if not empty).
## Execution
### Step 5.0: Load Validation Context
Run `ccw spec load --category validation` for verification rules and acceptance criteria.
### Step 5.1: Initialize Analysis Context
```bash

View File

@@ -222,6 +222,7 @@ Execute complete context-search-agent workflow for TDD implementation planning:
### Phase 1: Initialization & Pre-Analysis
1. **Project State Loading**:
- Run: \`ccw spec load --category execution\` to load project context, tech stack, and guidelines.
- Run: \`ccw spec load --category test\` to load test framework conventions, coverage targets, and fixtures.
- If files don't exist, proceed with fresh analysis.
2. **Detection**: Check for existing context-package (early exit if valid)
3. **Foundation**: Initialize CodexLens, get project structure, load docs

View File

@@ -237,13 +237,14 @@ MCP Capabilities: {exa_code, exa_web, code_index}
These files provide project-level constraints that apply to ALL tasks:
1. **ccw spec load --category execution** (project specs and tech analysis)
2. **ccw spec load --category test** (test framework, coverage targets, conventions)
- Contains: tech_stack, architecture_type, key_components, build_system, test_framework, coding_conventions, naming_rules, forbidden_patterns, quality_gates, custom_constraints
- Usage: Populate plan.json shared_context, align task tech choices, set correct test commands
- Apply as HARD CONSTRAINTS on all generated tasks — task implementation steps,
acceptance criteria, and convergence.verification MUST respect these guidelines
- If empty/missing: No additional constraints (proceed normally)
Loading order: \`ccw spec load --category execution\` → planning-notes.md → context-package.json
Loading order: \`ccw spec load --category execution\` → \`ccw spec load --category test\` → planning-notes.md → context-package.json
## USER CONFIGURATION (from Phase 0)
Execution Method: ${userConfig.executionMethod} // agent|hybrid|cli

View File

@@ -346,6 +346,7 @@ Execute complete context-search-agent workflow for implementation planning:
### Phase 1: Initialization & Pre-Analysis
1. **Project State Loading**:
- Run: \`ccw spec load --category execution\` to load project context, tech stack, and guidelines.
- Run: \`ccw spec load --category test\` to load test framework conventions, coverage targets, and fixtures.
- If files don't exist, proceed with fresh analysis.
2. **Detection**: Check for existing context-package (early exit if valid)
3. **Foundation**: Initialize CodexLens, get project structure, load docs

View File

@@ -249,7 +249,8 @@ Task(
${selectedStrategy} - ${strategyDescription}
## PROJECT CONTEXT (MANDATORY)
1. Run: \`ccw spec load --category execution\` (tech stack, test framework, build system, constraints)
1. Run: \`ccw spec load --category execution\` (tech stack, build system, constraints)
2. Run: \`ccw spec load --category test\` (test framework, coverage targets, conventions)
## MANDATORY FIRST STEPS
1. Read test results: ${session.test_results_path}

View File

@@ -377,6 +377,99 @@ if (invalidSteps.length > 0) {
}
```
### Step 1.2b: Generate Test Requirements (Acceptance Criteria)
> 调优的前提:为每一步生成跟任务匹配的验收标准。没有预期基准,就无法判断命令执行是否达标。
用 Gemini 根据 step command + workflow context + 上下游关系,自动推断每步的验收标准。
```javascript
// Build step chain description for context
const stepChainDesc = steps.map((s, i) =>
`Step ${i + 1}: ${s.name} (${s.type}) — ${s.command}`
).join('\n');
const reqGenPrompt = `PURPOSE: Generate concrete acceptance criteria (test requirements) for each step in a workflow pipeline. These criteria will be used to objectively judge whether each step's execution succeeded or failed.
WORKFLOW:
Name: ${workflowName}
Goal: ${workflowContext}
STEP CHAIN:
${stepChainDesc}
TASK:
For each step, generate:
1. **expected_outputs** — what files/artifacts should be produced (specific filenames or patterns)
2. **content_signals** — what content patterns indicate success (keywords, structures, data shapes)
3. **quality_thresholds** — minimum quality bar (e.g., "no empty files", "JSON must be parseable", "must contain at least N items")
4. **pass_criteria** — 1-2 sentence description of what "pass" looks like for this step
5. **fail_signals** — what patterns indicate failure (error messages, empty output, wrong format)
6. **handoff_contract** — what this step must provide for the next step to work (data format, required fields)
CONTEXT RULES:
- Infer from the command what the step is supposed to do
- Consider workflow goal when judging what "good enough" means
- Each step's handoff_contract should match what the next step needs as input
- Be specific: "report.md with ## Summary section" not "a report file"
EXPECTED OUTPUT (strict JSON, no markdown):
{
"step_requirements": [
{
"step_index": 0,
"step_name": "<name>",
"expected_outputs": ["<file or pattern>"],
"content_signals": ["<keyword or pattern that indicates success>"],
"quality_thresholds": ["<minimum bar>"],
"pass_criteria": "<what pass looks like>",
"fail_signals": ["<pattern that indicates failure>"],
"handoff_contract": "<what next step needs from this step>"
}
]
}
CONSTRAINTS: Be specific to each command, output ONLY JSON`;
Bash({
command: `ccw cli -p "${escapeForShell(reqGenPrompt)}" --tool gemini --mode analysis --rule universal-rigorous-style`,
run_in_background: true,
timeout: 300000
});
// STOP — wait for hook callback
// After callback: parse JSON, attach requirements to each step
const reqOutput = /* CLI output from callback */;
const reqJsonMatch = reqOutput.match(/\{[\s\S]*\}/);
if (reqJsonMatch) {
try {
const reqData = JSON.parse(reqJsonMatch[0]);
(reqData.step_requirements || []).forEach(req => {
const idx = req.step_index;
if (idx >= 0 && idx < steps.length) {
steps[idx].test_requirements = {
expected_outputs: req.expected_outputs || [],
content_signals: req.content_signals || [],
quality_thresholds: req.quality_thresholds || [],
pass_criteria: req.pass_criteria || '',
fail_signals: req.fail_signals || [],
handoff_contract: req.handoff_contract || ''
};
}
});
} catch (e) {
// Fallback: proceed without generated requirements
// Steps will use any manually provided success_criteria
}
}
// Capture session ID for resume chain start
const reqSessionMatch = reqOutput.match(/\[CCW_EXEC_ID=([^\]]+)\]/);
const reqSessionId = reqSessionMatch ? reqSessionMatch[1] : null;
```
### Step 1.3: Create Workspace
```javascript
@@ -414,9 +507,10 @@ const initialState = {
index: i,
status: 'pending',
execution: null,
analysis: null
analysis: null,
test_requirements: s.test_requirements || null // from Step 1.2b
})),
analysis_session_id: null, // ccw cli resume chain
analysis_session_id: reqSessionId || null, // resume chain starts from requirements generation
process_log_entries: [],
synthesis: null,
errors: [],