refactor(enhance-prompt): update description and streamline enhancement pipeline by removing codebase analysis references

This commit is contained in:
catlog22
2025-11-15 16:19:36 +08:00
parent 763c51cb28
commit e76e5bbf5c
2 changed files with 46 additions and 64 deletions

View File

@@ -1,37 +1,22 @@
--- ---
name: enhance-prompt name: enhance-prompt
description: Enhanced prompt transformation using session memory and codebase analysis with --enhance flag detection description: Enhanced prompt transformation using session memory and intent analysis with --enhance flag detection
argument-hint: "user input to enhance" argument-hint: "user input to enhance"
--- ---
## Overview ## Overview
Systematically enhances user prompts by combining session memory context with codebase patterns, translating ambiguous requests into actionable specifications. Systematically enhances user prompts by leveraging session memory context and intent analysis, translating ambiguous requests into actionable specifications.
## Core Protocol ## Core Protocol
**Enhancement Pipeline:** **Enhancement Pipeline:**
`Intent Translation``Context Integration` `Gemini Analysis (if needed)` `Structured Output` `Intent Translation``Context Integration``Structured Output`
**Context Sources:** **Context Sources:**
- Session memory (conversation history, previous analysis) - Session memory (conversation history, previous analysis)
- Codebase patterns (via Gemini when triggered)
- Implicit technical requirements - Implicit technical requirements
- User intent patterns
## Gemini Trigger Logic
```pseudo
FUNCTION should_use_gemini(user_prompt):
critical_keywords = ["refactor", "migrate", "redesign", "auth", "payment", "security"]
RETURN (
prompt_affects_multiple_modules(user_prompt, threshold=3) OR
any_keyword_in_prompt(critical_keywords, user_prompt)
)
END
```
**Gemini Integration:** ~/.claude/workflows/intelligent-tools-strategy.md
## Enhancement Rules ## Enhancement Rules
@@ -47,22 +32,18 @@ END
### Context Integration Strategy ### Context Integration Strategy
**Session Memory First:** **Session Memory:**
- Reference recent conversation context - Reference recent conversation context
- Reuse previously identified patterns - Reuse previously identified patterns
- Build on established understanding - Build on established understanding
- Infer technical requirements from discussion
**Codebase Analysis (via Gemini):**
- Only when complexity requires it
- Focus on integration points
- Identify existing patterns
**Example:** **Example:**
```bash ```bash
# User: "add login" # User: "add login"
# Session Memory: Previous auth discussion, JWT mentioned # Session Memory: Previous auth discussion, JWT mentioned
# Inferred: JWT-based auth, integrate with existing session management # Inferred: JWT-based auth, integrate with existing session management
# Gemini (if multi-module): Analyze AuthService patterns, middleware structure # Action: Implement JWT authentication with session persistence
``` ```
## Output Structure ## Output Structure
@@ -76,7 +57,7 @@ ATTENTION: [Critical constraints]
### Output Examples ### Output Examples
**Simple (no Gemini):** **Example 1:**
```bash ```bash
# Input: "fix login button" # Input: "fix login button"
INTENT: Debug non-functional login button INTENT: Debug non-functional login button
@@ -85,28 +66,28 @@ ACTION: Check event binding → verify state updates → test auth flow
ATTENTION: Preserve existing OAuth integration ATTENTION: Preserve existing OAuth integration
``` ```
**Complex (with Gemini):** **Example 2:**
```bash ```bash
# Input: "refactor payment code" # Input: "refactor payment code"
INTENT: Restructure payment module for maintainability INTENT: Restructure payment module for maintainability
CONTEXT: Session memory - PCI compliance requirements CONTEXT: Session memory - PCI compliance requirements, Stripe integration patterns
Gemini - PaymentServiceStripeAdapter pattern identified ACTION: Extract reusable validators → isolate payment gateway logic → maintain adapter pattern
ACTION: Extract reusable validators → isolate payment gateway logic
ATTENTION: Zero behavior change, maintain PCI compliance, full test coverage ATTENTION: Zero behavior change, maintain PCI compliance, full test coverage
``` ```
## Automatic Triggers ## Enhancement Triggers
- Ambiguous language: "fix", "improve", "clean up" - Ambiguous language: "fix", "improve", "clean up"
- Multi-module impact (>3 modules) - Vague requests requiring clarification
- Complex technical requirements
- Architecture changes - Architecture changes
- Critical systems: auth, payment, security - Critical systems: auth, payment, security
- Complex refactoring - Multi-step refactoring
## Key Principles ## Key Principles
1. **Memory First**: Leverage session context before analysis 1. **Session Memory First**: Leverage conversation context and established understanding
2. **Minimal Gemini**: Only when complexity demands it 2. **Context Reuse**: Build on previous discussions and decisions
3. **Context Reuse**: Build on previous understanding 3. **Clear Output**: Structured, actionable specifications
4. **Clear Output**: Structured, actionable specifications 4. **Intent Clarification**: Transform vague requests into specific technical goals
5. **Avoid Duplication**: Reference existing context, don't repeat 5. **Avoid Duplication**: Reference existing context, don't repeat

View File

@@ -236,35 +236,31 @@ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]
- `.workflow/[sessionId]/.task/IMPL-*.json` exists (at least one) - `.workflow/[sessionId]/.task/IMPL-*.json` exists (at least one)
- `.workflow/[sessionId]/TODO_LIST.md` exists - `.workflow/[sessionId]/TODO_LIST.md` exists
<!-- TodoWrite: When task-generate-agent invoked, INSERT 3 task-generate-agent tasks --> <!-- TodoWrite: When task-generate-agent invoked, ATTACH 1 agent task -->
**TodoWrite Update (Phase 4 SlashCommand invoked - tasks attached)**: **TodoWrite Update (Phase 4 SlashCommand invoked - agent task attached)**:
```json ```json
[ [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"}, {"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"}, {"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Phase 4.1: Discovery - analyze requirements (task-generate-agent)", "status": "in_progress", "activeForm": "Analyzing requirements"}, {"content": "Execute task-generate-agent", "status": "in_progress", "activeForm": "Executing task-generate-agent"}
{"content": "Phase 4.2: Planning - design tasks (task-generate-agent)", "status": "pending", "activeForm": "Designing tasks"},
{"content": "Phase 4.3: Output - generate JSONs (task-generate-agent)", "status": "pending", "activeForm": "Generating task JSONs"}
] ]
``` ```
**Note**: SlashCommand invocation **attaches** task-generate-agent's 3 tasks. Orchestrator **executes** these tasks. **Note**: Single agent task attached. Agent autonomously completes discovery, planning, and output generation internally.
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially <!-- TodoWrite: After agent completes, mark task as completed -->
<!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view --> **TodoWrite Update (Phase 4 completed)**:
**TodoWrite Update (Phase 4 completed - tasks collapsed)**:
```json ```json
[ [
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"}, {"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"}, {"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
{"content": "Execute task generation", "status": "completed", "activeForm": "Executing task generation"} {"content": "Execute task-generate-agent", "status": "completed", "activeForm": "Executing task-generate-agent"}
] ]
``` ```
**Note**: Phase 4 tasks completed and collapsed to summary. **Note**: Agent task completed. No collapse needed (single task).
**Return to User**: **Return to User**:
``` ```
@@ -288,31 +284,35 @@ Quality Gate: Consider running /workflow:action-plan-verify to catch issues earl
1. **Task Attachment** (when SlashCommand invoked): 1. **Task Attachment** (when SlashCommand invoked):
- Sub-command's internal tasks are **attached** to orchestrator's TodoWrite - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
- Example: `/workflow:tools:context-gather` attaches 3 sub-tasks (Phase 2.1, 2.2, 2.3) - **Phase 2, 3**: Multiple sub-tasks attached (e.g., Phase 2.1, 2.2, 2.3)
- **Phase 4**: Single agent task attached (e.g., "Execute task-generate-agent")
- First attached task marked as `in_progress`, others as `pending` - First attached task marked as `in_progress`, others as `pending`
- Orchestrator **executes** these attached tasks sequentially - Orchestrator **executes** these attached tasks sequentially
2. **Task Collapse** (after sub-tasks complete): 2. **Task Collapse** (after sub-tasks complete):
- Remove detailed sub-tasks from TodoWrite - **Applies to Phase 2, 3**: Remove detailed sub-tasks from TodoWrite
- **Collapse** to high-level phase summary - **Collapse** to high-level phase summary
- Example: Phase 2.1-2.3 collapse to "Execute context gathering: completed" - Example: Phase 2.1-2.3 collapse to "Execute context gathering: completed"
- **Phase 4**: No collapse needed (single task, just mark completed)
- Maintains clean orchestrator-level view - Maintains clean orchestrator-level view
3. **Continuous Execution**: 3. **Continuous Execution**:
- After collapse, automatically proceed to next pending phase - After completion, automatically proceed to next pending phase
- No user intervention required between phases - No user intervention required between phases
- TodoWrite dynamically reflects current execution state - TodoWrite dynamically reflects current execution state
**Lifecycle Summary**: Initial pending tasks → Phase invoked (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins → Repeat until all phases complete. **Lifecycle Summary**: Initial pending tasks → Phase invoked (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary for Phase 2/3, or marked completed for Phase 4) → Next phase begins → Repeat until all phases complete.
### Benefits ### Benefits
- ✓ Real-time visibility into sub-task execution - ✓ Real-time visibility into sub-task execution
- ✓ Clear mental model: SlashCommand = attach → execute → collapse - ✓ Clear mental model: SlashCommand = attach → execute → collapse (Phase 2/3) or complete (Phase 4)
- ✓ Clean summary after completion - ✓ Clean summary after completion
- ✓ Easy to track workflow progress - ✓ Easy to track workflow progress
**Note**: See individual Phase descriptions (Phase 2, 3, 4) for detailed TodoWrite Update examples with full JSON structures. **Note**: See individual Phase descriptions for detailed TodoWrite Update examples:
- **Phase 2, 3**: Multiple sub-tasks with attach/collapse pattern
- **Phase 4**: Single agent task (no collapse needed)
## Input Processing ## Input Processing
@@ -425,20 +425,21 @@ Conditional Branch: Check conflict_risk
└─ ELSE: Skip Phase 3, proceed to Phase 4 └─ ELSE: Skip Phase 3, proceed to Phase 4
Phase 4: Task Generation (SlashCommand invoked) Phase 4: Task Generation (SlashCommand invoked)
→ ATTACH 3 tasks: ← ATTACHED → ATTACH 1 agent task: ← ATTACHED
- Phase 4.1: Discovery - analyze requirements - Execute task-generate-agent
- Phase 4.2: Planning - design tasks → Agent autonomously completes internally:
- Phase 4.3: Output - generate JSONs (discovery → planning → output)
→ Execute Phase 4.1-4.3
→ COLLAPSE tasks ← COLLAPSED
→ Outputs: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md → Outputs: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
Return summary to user Return summary to user
``` ```
**Key Points**: **Key Points**:
- **← ATTACHED**: Sub-tasks attached to TodoWrite when SlashCommand invoked - **← ATTACHED**: Tasks attached to TodoWrite when SlashCommand invoked
- **← COLLAPSED**: Sub-tasks collapsed to summary after completion - Phase 2, 3: Multiple sub-tasks
- Phase 4: Single agent task
- **← COLLAPSED**: Sub-tasks collapsed to summary after completion (Phase 2, 3 only)
- **Phase 4**: Single agent task, no collapse (just mark completed)
- **Conditional Branch**: Phase 3 only executes if conflict_risk ≥ medium - **Conditional Branch**: Phase 3 only executes if conflict_risk ≥ medium
- **Continuous Flow**: No user intervention between phases - **Continuous Flow**: No user intervention between phases