diff --git a/skills/implement/SKILL.md b/skills/implement/SKILL.md index 160e2e1..0bfabe1 100644 --- a/skills/implement/SKILL.md +++ b/skills/implement/SKILL.md @@ -33,22 +33,22 @@ ONE TODO → ONE CHANGE → ONE TEST → ONE COMMIT FOR each CHUNK-Pn in dependency_order: IF dependencies_complete: 1. Load CHUNK-Pn todolist - + FOR each TODO in todolist: a. Make atomic change b. Run todo-specific test c. If PASS: commit, mark TODO ✅ d. If FAIL: STOP, investigate, fix END TODO LOOP - + 2. Update chunk documentation 3. Mark CHUNK-Pn as IMPLEMENTED 4. Update research CHUNK-Rn to IMPLEMENTED - + IF chunks_processed % 3 == 0 OR context > 35%: Context reset (save progress, reload plan) END IF - + 5. Proceed to next ready chunk END IF END CHUNK LOOP @@ -68,20 +68,20 @@ END CHUNK LOOP - Final chunks (e.g., test additions) 3. **For Each Chunk (in dependency order):** - + a. **Check dependencies complete** - + b. **Execute each todo atomically:** - Make single change - Run specified test - If pass: commit with message - If fail: STOP, investigate, fix - + c. **After all todos complete:** - Mark CHUNK-Pn as IMPLEMENTED - Update CHUNK-Rn in research to IMPLEMENTED - Commit chunk documentation updates - + d. **Context management:** - After every 3 chunks: reload plan - If >35% utilization: save, compact, continue diff --git a/skills/plan/SKILL.md b/skills/plan/SKILL.md index 2837ac4..263cb63 100644 --- a/skills/plan/SKILL.md +++ b/skills/plan/SKILL.md @@ -43,26 +43,26 @@ END LOOP - Extract per-chunk files and line numbers 2. **For Each Research Chunk (CHUNK-Rn):** - + a. **Analyze chunk content:** - Files explored with line numbers - Code flow analysis - Dependencies identified - + b. **Create CHUNK-Pn todolist:** ```markdown | # | Action | File | Lines | Risk | Test | Status | |---|--------|------|-------|------|------|--------| | 1 | [Action] | file.ext | XXX | LOW | test_x | ⏳ | ``` - + c. **Define per-todo details:** - Current code snippet - Proposed change - Test to run after - + d. **Mark research chunk as PLANNED** - + e. **Document chunk dependencies** 3. **Create Chunk Dependency Graph** diff --git a/skills/research/SKILL.md b/skills/research/SKILL.md index c59df56..944a0c8 100644 --- a/skills/research/SKILL.md +++ b/skills/research/SKILL.md @@ -1,5 +1,5 @@ --- -description: RPI Research Phase - Systematic codebase exploration with parallel agents and chunked output +description: RPI Research Phase: Manifest-Driven Parallel Execution with 5 Search Agents --- # Context Engineering: Research Phase (Enhanced) @@ -16,12 +16,14 @@ This research phase **KNOWS** how RPI-Plan will consume its output: ## Process +1. **Parallel Search:** 5 agents simultaneously search their domains.\n2. **Manifest Creation:** Results are aggregated into a table.\n3. **Sequential Deep Dive:** Sub-agents iterate through the manifest to populate details. + 1. **Initialize Research Document** - Create `.claude/research/active/[feature]_research.md` - Use template from `.claude/research/RESEARCH_TEMPLATE.md` 2. **Spawn Parallel Agents (3-5 agents)** - + ``` Agent 1: API/Route Entry Points → CHUNK-R1 Agent 2: Business Logic & Models → CHUNK-R2 @@ -29,7 +31,7 @@ This research phase **KNOWS** how RPI-Plan will consume its output: Agent 4: External Integrations → CHUNK-R4 Agent 5: Test Coverage Analysis → CHUNK-R5 ``` - + Each agent receives: - Feature name and objective - Assigned domain @@ -43,13 +45,13 @@ This research phase **KNOWS** how RPI-Plan will consume its output: **Status:** COMPLETE **Parallel Agent:** Agent N **Ready for Planning:** Yes - + ### Files Explored | File | Lines | Key Findings | - + ### Code Flow Analysis [call chain with file:line refs] - + ### Dependencies (This Chunk) - External: [APIs] - Internal: [services] diff --git a/src/cli/repl/index.ts b/src/cli/repl/index.ts index 1324a6d..a0c1551 100644 --- a/src/cli/repl/index.ts +++ b/src/cli/repl/index.ts @@ -4,8 +4,6 @@ * Interactive shell for managing k0ntext context */ -import fs from 'fs'; -import path from 'path'; import readline from 'readline'; import fs from 'fs'; import path from 'path'; diff --git a/templates/base/RPI_WORKFLOW_PLAN.md b/templates/base/RPI_WORKFLOW_PLAN.md index c034af6..e7d1930 100644 --- a/templates/base/RPI_WORKFLOW_PLAN.md +++ b/templates/base/RPI_WORKFLOW_PLAN.md @@ -37,7 +37,7 @@ Understand the system, locate relevant components, prevent context pollution ### Process 1. Load WORKFLOW_INDEX.md first (saves 100k+ tokens) -2. **Spawn 3-5 parallel Explore agents** (one per research domain) +2. **Spawn 5 parallel Explore agents (API, Logic, DB, External, Tests)** (one per research domain) 3. Each agent produces a **Research Chunk** with: - Chunk ID (e.g., `CHUNK-R1`, `CHUNK-R2`) - Explored files with line numbers diff --git a/templates/base/agents/rpi-engineer.md b/templates/base/agents/rpi-engineer.md new file mode 100644 index 0000000..ea8e692 --- /dev/null +++ b/templates/base/agents/rpi-engineer.md @@ -0,0 +1,70 @@ +--- +name: rpi-engineer +version: "1.0.0" +description: "RPI Orchestrator: Quality, Feature, and Debug Engineer using the RPI Workflow" +category: "core-agent" +--- + +# Agent Profile: RPI Engineer + +**Role:** RPI Orchestrator / Quality Engineer + +**Mission:** You are the expert orchestrator of the RPI (Research, Plan, Implement) workflow. Your goal is to solve bugs, implement features, and write tests by strictly adhering to the 3-phase RPI process. + +**Directives:** +- **Debugs:** Do NOT fix bugs directly. Start with `/rpi-research` to understand the root cause. +- **Features:** Do NOT code immediately. Start with `/rpi-research` to map the requirements. +- **Tests:** Do NOT guess tests. Start with `/rpi-research` to identify coverage gaps. + +--- + +## Capabilities & Skills + +You have full mastery of the following skills and **MUST** use them in this order: + +1. **Research (`/rpi-research`):** + - You know this command spawns **5 parallel agents** (API, Logic, DB, External, Tests). + - You expect a **Research Manifest** as output. + - You verify that all 5 domains have been explored before proceeding. + +2. **Plan (`/rpi-plan`):** + - You execute this only AFTER research is complete. + - You expect a **Plan Manifest** with specific chunks linked to research chunks. + - You verify that atomic todolists (with file:line precision) are generated. + +3. **Implement (`/rpi-implement`):** + - You execute this only AFTER the plan is approved. + - You expect this to run manifest chunks sequentially. + - You verify that statuses in both Plan and Research manifests are updated to `IMPLEMENTED`. + +--- + +## Workflow Triggers + +### Trigger: "Fix this bug" +1. **Analyze:** "I need to understand the bug first." +2. **Action:** Run `/rpi-research [bug-description]`. +3. **Outcome:** Research Manifest identifying the buggy component. +4. **Next:** Run `/rpi-plan` -> `/rpi-implement`. + +### Trigger: "Add this feature" +1. **Analyze:** "I need to map the feature requirements." +2. **Action:** Run `/rpi-research [feature-name]`. +3. **Outcome:** Research Manifest covering all 5 domains. +4. **Next:** Run `/rpi-plan` -> `/rpi-implement`. + +### Trigger: "Add tests" (Dests) +1. **Analyze:** "I need to find where tests are missing." +2. **Action:** Run `/rpi-research [test-scope]` (Agent 5 will be key here). +3. **Outcome:** Research Manifest highlighting coverage gaps. +4. **Next:** Run `/rpi-plan` -> `/rpi-implement`. + +--- + +## Inter-Phase Context Awareness +You are the guardian of the context. You ensure: +- **Research** outputs a manifest readable by **Plan**. +- **Plan** outputs a manifest readable by **Implement**. +- **Implement** updates the status of the entire chain. + +If any phase fails to produce the correct manifest format, you **STOP** and request a correction before proceeding. diff --git a/templates/base/commands/rpi-implement.md b/templates/base/commands/rpi-implement.md index a797299..69f534d 100644 --- a/templates/base/commands/rpi-implement.md +++ b/templates/base/commands/rpi-implement.md @@ -78,7 +78,7 @@ ONE TODO → ONE CHANGE → ONE TEST → ONE COMMIT │ RPI-IMPLEMENT CHUNK PROCESSING LOOP │ ├─────────────────────────────────────────────────────────┤ │ FOR each CHUNK-Pn in dependency_order: │ -│ 1. Load CHUNK-Pn todolist │ +│ 1. Load CHUNK-Pn todolist (from Plan Manifest) │ │ 2. FOR each TODO in CHUNK-Pn: │ │ a. Make atomic change │ │ b. Run specified test │ diff --git a/templates/base/commands/rpi-plan.md b/templates/base/commands/rpi-plan.md index d337e9d..62f8639 100644 --- a/templates/base/commands/rpi-plan.md +++ b/templates/base/commands/rpi-plan.md @@ -65,7 +65,7 @@ RPI-Plan **KNOWS**: │ RPI-PLAN CHUNK PROCESSING LOOP │ ├─────────────────────────────────────────────────────────┤ │ FOR each research_chunk (CHUNK-R1 to CHUNK-RN): │ -│ 1. Read research_chunk content │ +│ 1. Read research_chunk content (Sequential Sub-Agent) │ │ 2. Create corresponding CHUNK-Pn todolist: │ │ - Define atomic action items │ │ - Specify file:line for each action │ diff --git a/templates/base/commands/rpi-research.md b/templates/base/commands/rpi-research.md index e2c8422..61e11e2 100644 --- a/templates/base/commands/rpi-research.md +++ b/templates/base/commands/rpi-research.md @@ -6,7 +6,7 @@ category: "rpi-orchestration" rpi_phase: "research" context_budget_estimate: "50K tokens" typical_context_usage: "25%" -parallel_agents: "3-5" +parallel_agents: "5" chunk_output: true inter_phase_aware: true prerequisites: [] @@ -82,7 +82,7 @@ Spawn 3-5 parallel Explore agents, each focused on a specific domain: ### Step 1: Initialize Research Document Create `.ai-context/research/active/[feature]_research.md` from RESEARCH_TEMPLATE.md -### Step 2: Spawn Parallel Agents (3-5 agents) +### Step 2: Spawn 5 Parallel Search Agents Each agent receives: - Feature name and objective @@ -92,6 +92,13 @@ Each agent receives: ### Step 3: Aggregate Chunk Results +### Step 4: Sequential Deep Dive (Sub-Agents Loop) +**For each CHUNK-Rn in Manifest:** +- Start a sub-agent to "explore and append" deep details. +- Trace call chains (File:Line). +- Identify dependencies. +- Mark status as `COMPLETE` in manifest. + Collect outputs from all agents and structure into: - Chunk Manifest (table of all chunks with status) - Individual chunk sections with full details