Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions skills/implement/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions skills/plan/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
14 changes: 8 additions & 6 deletions skills/research/SKILL.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -16,20 +16,22 @@ 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
Agent 3: Database/Storage Layer → CHUNK-R3
Agent 4: External Integrations → CHUNK-R4
Agent 5: Test Coverage Analysis → CHUNK-R5
```

Each agent receives:
- Feature name and objective
- Assigned domain
Expand All @@ -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]
Expand Down
2 changes: 0 additions & 2 deletions src/cli/repl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion templates/base/RPI_WORKFLOW_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
70 changes: 70 additions & 0 deletions templates/base/agents/rpi-engineer.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion templates/base/commands/rpi-implement.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 │
Expand Down
2 changes: 1 addition & 1 deletion templates/base/commands/rpi-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 │
Expand Down
11 changes: 9 additions & 2 deletions templates/base/commands/rpi-research.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading