mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
refactor(agents): deduplicate agent invocation prompts and strengthen project artifact consumption
Remove duplicated content from caller prompts that repeat agent spec definitions: - EXECUTION METHOD MAPPING, CLI EXECUTION ID strategies, Quantification Rules - MANDATORY FIRST STEPS (now internalized in cli-explore-agent) - relevant_files schema details, Phase execution flow re-specifications - plan.json/task JSON field listings (reference schemas instead) Strengthen project-tech.json and project-guidelines.json consumption: - context-search-agent: add Phase 1.1b mandatory project context loading - cli-explore-agent: add Autonomous Initialization with 4 self-contained steps - action-planning-agent: strengthen Phase 1 Step 0 with detailed usage guidance - All caller prompts: add/reinforce PROJECT CONTEXT (MANDATORY) sections Agent specs modified: action-planning-agent, cli-explore-agent, context-search-agent Caller prompts slimmed: 04-task-generation, 05-tdd-task-generation, 02-context-gathering, 01-lite-plan, collaborative-plan-with-file, 05-test-cycle-execute
This commit is contained in:
@@ -56,7 +56,23 @@ color: yellow
|
||||
**Step-by-step execution**:
|
||||
|
||||
```
|
||||
0. Load planning notes → Extract phase-level constraints (NEW)
|
||||
0. Load project context (MANDATORY - from init.md products)
|
||||
a. Read .workflow/project-tech.json (if exists)
|
||||
→ tech_stack, architecture_type, key_components, build_system, test_framework
|
||||
→ Usage: Populate plan.json shared_context, set correct build/test commands,
|
||||
align task tech choices with actual project stack
|
||||
→ If missing: Fall back to context-package.project_context fields
|
||||
|
||||
b. Read .workflow/project-guidelines.json (if exists)
|
||||
→ coding_conventions, naming_rules, forbidden_patterns, quality_gates, custom_constraints
|
||||
→ Usage: Apply as HARD CONSTRAINTS on all tasks — implementation steps,
|
||||
acceptance criteria, and convergence.verification MUST respect these rules
|
||||
→ If empty/missing: No additional constraints (proceed normally)
|
||||
|
||||
NOTE: These files provide project-level context that supplements (not replaces)
|
||||
session-specific context from planning-notes.md and context-package.json.
|
||||
|
||||
1. Load planning notes → Extract phase-level constraints (NEW)
|
||||
Commands: Read('.workflow/active/{session-id}/planning-notes.md')
|
||||
Output: Consolidated constraints from all workflow phases
|
||||
Structure:
|
||||
@@ -67,16 +83,16 @@ color: yellow
|
||||
|
||||
USAGE: This is the PRIMARY source of constraints. All task generation MUST respect these constraints.
|
||||
|
||||
1. Load session metadata → Extract user input
|
||||
2. Load session metadata → Extract user input
|
||||
- User description: Original task/feature requirements
|
||||
- Project scope: User-specified boundaries and goals
|
||||
- Technical constraints: User-provided technical requirements
|
||||
|
||||
2. Load context package → Extract structured context
|
||||
3. Load context package → Extract structured context
|
||||
Commands: Read({{context_package_path}})
|
||||
Output: Complete context package object
|
||||
|
||||
3. Check existing plan (if resuming)
|
||||
4. Check existing plan (if resuming)
|
||||
- If IMPL_PLAN.md exists: Read for continuity
|
||||
- If task JSONs exist: Load for context
|
||||
|
||||
@@ -989,7 +1005,8 @@ Use `analysis_results.complexity` or task count to determine structure:
|
||||
### 3.4 Guidelines Checklist
|
||||
|
||||
**ALWAYS:**
|
||||
- **Load planning-notes.md FIRST**: Read planning-notes.md before context-package.json. Use its Consolidated Constraints as primary constraint source for all task generation
|
||||
- **Load project context FIRST**: Read `.workflow/project-tech.json` and `.workflow/project-guidelines.json` before any session-specific files. Apply project-guidelines as hard constraints on all tasks
|
||||
- **Load planning-notes.md SECOND**: Read planning-notes.md before context-package.json. Use its Consolidated Constraints as primary constraint source for all task generation
|
||||
- **Record N+1 Context**: Update `## N+1 Context` section with key decisions and deferred items
|
||||
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
|
||||
- Apply Quantification Requirements to all requirements, acceptance criteria, and modification points
|
||||
|
||||
@@ -39,6 +39,36 @@ Phase 4: Output Generation
|
||||
|
||||
## Phase 1: Task Understanding
|
||||
|
||||
### Autonomous Initialization (execute before any analysis)
|
||||
|
||||
**These steps are MANDATORY and self-contained** -- the agent executes them regardless of caller prompt content. Callers do NOT need to repeat these instructions.
|
||||
|
||||
1. **Project Structure Discovery**:
|
||||
```bash
|
||||
ccw tool exec get_modules_by_depth '{}'
|
||||
```
|
||||
Store result as `project_structure` for module-aware file discovery in Phase 2.
|
||||
|
||||
2. **Output Schema Loading** (if output file path specified in prompt):
|
||||
- Exploration output → `cat ~/.ccw/workflows/cli-templates/schemas/explore-json-schema.json`
|
||||
- Other schemas as specified in prompt
|
||||
Read and memorize schema requirements BEFORE any analysis begins (feeds Phase 3 validation).
|
||||
|
||||
3. **Project Context Loading** (from init.md products):
|
||||
- Read `.workflow/project-tech.json` (if exists):
|
||||
- Extract: `tech_stack`, `architecture`, `key_components`, `overview`
|
||||
- Usage: Align analysis scope and patterns with actual project technology choices
|
||||
- Read `.workflow/project-guidelines.json` (if exists):
|
||||
- Extract: `conventions`, `constraints`, `quality_rules`, `learnings`
|
||||
- Usage: Apply as constraints during pattern analysis, integration point evaluation, and recommendations
|
||||
- If either file does not exist, proceed with fresh analysis (no error).
|
||||
|
||||
4. **Task Keyword Search** (initial file discovery):
|
||||
```bash
|
||||
rg -l "{extracted_keywords}" --type {detected_lang}
|
||||
```
|
||||
Extract keywords from prompt task description, detect primary language from project structure, and run targeted search. Store results as `keyword_files` for Phase 2 scoping.
|
||||
|
||||
**Extract from prompt**:
|
||||
- Analysis target and scope
|
||||
- Analysis mode (quick-scan / deep-scan / dependency-map)
|
||||
|
||||
@@ -75,6 +75,23 @@ if (file_exists(contextPackagePath)) {
|
||||
}
|
||||
```
|
||||
|
||||
**1.1b Project Context Loading** (MANDATORY):
|
||||
```javascript
|
||||
// Load project-level context (from workflow:init products)
|
||||
// These provide foundational constraints for ALL context gathering
|
||||
const projectTech = file_exists('.workflow/project-tech.json')
|
||||
? JSON.parse(Read('.workflow/project-tech.json')) // tech_stack, architecture_type, key_components, build_system, test_framework
|
||||
: null;
|
||||
const projectGuidelines = file_exists('.workflow/project-guidelines.json')
|
||||
? JSON.parse(Read('.workflow/project-guidelines.json')) // coding_conventions, naming_rules, forbidden_patterns, quality_gates
|
||||
: null;
|
||||
|
||||
// Usage:
|
||||
// - projectTech → Populate project_context fields (tech_stack, architecture_patterns)
|
||||
// - projectGuidelines → Apply as constraints during relevance scoring and conflict detection
|
||||
// - If missing: Proceed with fresh analysis (discover from codebase)
|
||||
```
|
||||
|
||||
**1.2 Foundation Setup**:
|
||||
```javascript
|
||||
// 1. Initialize CodexLens (if available)
|
||||
@@ -275,6 +292,10 @@ score = (0.4 × direct_match) + // Filename/path match
|
||||
(0.1 × dependency_link) // Connection strength
|
||||
|
||||
// Filter: Include only score > 0.5
|
||||
|
||||
// Apply projectGuidelines constraints (from 1.1b) when available:
|
||||
// - Boost files matching projectGuidelines.quality_gates patterns
|
||||
// - Penalize files matching projectGuidelines.forbidden_patterns
|
||||
```
|
||||
|
||||
**3.2 Dependency Graph**
|
||||
@@ -292,19 +313,23 @@ Merge with conflict resolution:
|
||||
|
||||
```javascript
|
||||
const context = {
|
||||
// Priority: Project docs > Existing code > Web examples
|
||||
architecture: ref_docs.patterns || code.structure,
|
||||
// Priority: projectTech/projectGuidelines (1.1b) > Project docs > Existing code > Web examples
|
||||
architecture: projectTech?.architecture_type || ref_docs.patterns || code.structure,
|
||||
|
||||
conventions: {
|
||||
naming: ref_docs.standards || code.actual_patterns,
|
||||
error_handling: ref_docs.standards || code.patterns || web.best_practices
|
||||
naming: projectGuidelines?.naming_rules || ref_docs.standards || code.actual_patterns,
|
||||
error_handling: ref_docs.standards || code.patterns || web.best_practices,
|
||||
forbidden_patterns: projectGuidelines?.forbidden_patterns || [],
|
||||
quality_gates: projectGuidelines?.quality_gates || []
|
||||
},
|
||||
|
||||
tech_stack: {
|
||||
// Actual (package.json) takes precedence
|
||||
language: code.actual.language,
|
||||
frameworks: merge_unique([ref_docs.declared, code.actual]),
|
||||
libraries: code.actual.libraries
|
||||
// projectTech provides authoritative baseline; actual (package.json) fills gaps
|
||||
language: projectTech?.tech_stack?.language || code.actual.language,
|
||||
frameworks: merge_unique([projectTech?.tech_stack?.frameworks, ref_docs.declared, code.actual]),
|
||||
libraries: merge_unique([projectTech?.tech_stack?.libraries, code.actual.libraries]),
|
||||
build_system: projectTech?.build_system || code.actual.build_system,
|
||||
test_framework: projectTech?.test_framework || code.actual.test_framework
|
||||
},
|
||||
|
||||
// Web examples fill gaps
|
||||
@@ -314,9 +339,9 @@ const context = {
|
||||
```
|
||||
|
||||
**Conflict Resolution**:
|
||||
1. Architecture: Docs > Code > Web
|
||||
2. Conventions: Declared > Actual > Industry
|
||||
3. Tech Stack: Actual (package.json) > Declared
|
||||
1. Architecture: projectTech > Docs > Code > Web
|
||||
2. Conventions: projectGuidelines > Declared > Actual > Industry
|
||||
3. Tech Stack: projectTech > Actual (package.json) > Declared
|
||||
4. Missing: Use web examples
|
||||
|
||||
**3.5 Brainstorm Artifacts Integration**
|
||||
@@ -381,6 +406,8 @@ Calculate risk level based on:
|
||||
- Existing file count (<5: low, 5-15: medium, >15: high)
|
||||
- API/architecture/data model changes
|
||||
- Breaking changes identification
|
||||
- Violations of projectGuidelines.forbidden_patterns (from 1.1b, if available)
|
||||
- Deviations from projectGuidelines.coding_conventions (from 1.1b, if available)
|
||||
|
||||
**3.7 Context Packaging & Output**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user