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:
catlog22
2026-02-25 18:44:51 +08:00
parent 5c51315a7e
commit db5797faa3
9 changed files with 213 additions and 330 deletions

View File

@@ -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)