opencodekit 0.14.3 → 0.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -7
- package/dist/template/.opencode/.background-tasks.json +18 -0
- package/dist/template/.opencode/command/analyze-project.md +187 -358
- package/dist/template/.opencode/command/implement.md +29 -30
- package/dist/template/.opencode/command/new-feature.md +10 -10
- package/dist/template/.opencode/command/plan.md +13 -15
- package/dist/template/.opencode/command/ralph.md +41 -0
- package/dist/template/.opencode/command/start.md +11 -12
- package/dist/template/.opencode/opencode.json +5 -1
- package/dist/template/.opencode/package.json +1 -1
- package/dist/template/.opencode/plugin/compaction.ts +25 -2
- package/dist/template/.opencode/skill/ralph/SKILL.md +300 -0
- package/dist/template/.opencode/tool/background.ts +147 -99
- package/package.json +7 -7
- package/dist/template/.opencode/command/ralph-loop.md +0 -97
- package/dist/template/.opencode/plugin/handoff.ts +0 -37
- package/dist/template/.opencode/plugin/ralph-wiggum.ts +0 -182
- package/dist/template/.opencode/tool/ralph.ts +0 -203
|
@@ -61,9 +61,11 @@ bd ready --json | grep -q "$ARGUMENTS"
|
|
|
61
61
|
// Get all READY subtasks for this epic
|
|
62
62
|
// bd list --parent $ARGUMENTS --status=open --json
|
|
63
63
|
|
|
64
|
-
// Fire all READY subtasks in parallel
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
// Fire all READY subtasks in parallel using Task tool
|
|
65
|
+
// Multiple Task calls in one message run simultaneously
|
|
66
|
+
Task({
|
|
67
|
+
subagent_type: "rush",
|
|
68
|
+
description: "Execute subtask 1",
|
|
67
69
|
prompt: `Execute bd-subtask1: [Subtask description]
|
|
68
70
|
|
|
69
71
|
Context: Part of epic $ARGUMENTS
|
|
@@ -71,20 +73,20 @@ background_start({
|
|
|
71
73
|
Requirements:
|
|
72
74
|
- Complete all work items
|
|
73
75
|
- Run verification commands
|
|
74
|
-
- Commit with bead ID in message
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
title: "subtask-1"
|
|
78
|
-
}) // Fire more for each READY subtask...
|
|
76
|
+
- Commit with bead ID in message
|
|
77
|
+
- Close the bead when done: bd close bd-subtask1 --reason "Completed: ..."`,
|
|
78
|
+
});
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
Task({
|
|
81
|
+
subagent_type: "rush",
|
|
82
|
+
description: "Execute subtask 2",
|
|
83
|
+
prompt: `Execute bd-subtask2: [Subtask description]
|
|
84
|
+
...same pattern...`,
|
|
85
|
+
});
|
|
82
86
|
|
|
87
|
+
// Results available immediately after all complete
|
|
83
88
|
// Check newly unblocked subtasks
|
|
84
89
|
bd ready // → Next wave now READY
|
|
85
|
-
|
|
86
|
-
// Cleanup
|
|
87
|
-
background_cancel({ all: true })
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
## Git State Check
|
|
@@ -188,44 +190,41 @@ If memory search fails (Ollama not running), continue without it.
|
|
|
188
190
|
|
|
189
191
|
## Parallel Subagent Research (if --parallel or complex task)
|
|
190
192
|
|
|
191
|
-
**Delegation Pattern:
|
|
193
|
+
**Delegation Pattern: Parallel Task Calls**
|
|
192
194
|
|
|
193
|
-
For complex tasks, launch research subagents in
|
|
195
|
+
For complex tasks, launch research subagents in parallel before diving into code.
|
|
196
|
+
Multiple Task calls in a single message run simultaneously:
|
|
194
197
|
|
|
195
198
|
```typescript
|
|
196
199
|
// Codebase patterns - find similar implementations
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
Task({
|
|
201
|
+
subagent_type: "explore",
|
|
202
|
+
description: "Find codebase patterns",
|
|
199
203
|
prompt: `For implementing $ARGUMENTS, find:
|
|
200
204
|
1. Similar patterns in this codebase (grep/ast-grep)
|
|
201
205
|
2. Related test files and testing patterns
|
|
202
206
|
3. Configuration or setup requirements
|
|
203
207
|
Return: File paths, code patterns, test approach`,
|
|
204
|
-
|
|
205
|
-
}); // → bg_123_abc
|
|
208
|
+
});
|
|
206
209
|
|
|
207
210
|
// External best practices - library docs
|
|
208
|
-
|
|
209
|
-
|
|
211
|
+
Task({
|
|
212
|
+
subagent_type: "scout",
|
|
213
|
+
description: "Research best practices",
|
|
210
214
|
prompt: `Research best practices for $ARGUMENTS:
|
|
211
215
|
1. Official documentation for libraries involved
|
|
212
216
|
2. Common implementation patterns (Context7, GitHub)
|
|
213
217
|
3. Known pitfalls or gotchas
|
|
214
218
|
Return: Code examples, API usage, warnings`,
|
|
215
|
-
|
|
216
|
-
}); // → bg_456_def
|
|
219
|
+
});
|
|
217
220
|
|
|
218
|
-
//
|
|
219
|
-
// Collect later with: background_output({ taskId: "bg_123_abc" })
|
|
221
|
+
// Both run in parallel, results available immediately
|
|
220
222
|
```
|
|
221
223
|
|
|
222
|
-
**
|
|
224
|
+
**Subagent Tools:**
|
|
223
225
|
| Tool | Purpose |
|
|
224
226
|
| ---- | ------- |
|
|
225
|
-
| `
|
|
226
|
-
| `background_output` | Collect results from completed task |
|
|
227
|
-
| `background_list` | See all tasks and their status |
|
|
228
|
-
| `background_cancel` | Cancel running tasks (single or all) |
|
|
227
|
+
| `Task` | Delegate to subagent, runs in parallel when multiple calls in one message |
|
|
229
228
|
|
|
230
229
|
**Subagent Rules:**
|
|
231
230
|
| Agent | Use For | Can Do | Cannot Do |
|
|
@@ -54,29 +54,29 @@ Before creating anything, understand the landscape.
|
|
|
54
54
|
### Parallel Subagent Research
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
// Run both in parallel - multiple Task calls in one message
|
|
58
|
+
Task({
|
|
59
|
+
subagent_type: "explore",
|
|
60
|
+
description: "Explore codebase for feature",
|
|
60
61
|
prompt: `Research codebase for "${$ARGUMENTS}":
|
|
61
62
|
1. Find similar implementations or patterns
|
|
62
63
|
2. Identify likely affected directories
|
|
63
64
|
3. Find existing tests in related areas
|
|
64
65
|
4. Check for related beads (open or closed)
|
|
65
66
|
Return: File paths, patterns, test locations, related beads`,
|
|
66
|
-
|
|
67
|
-
}); // → bg_123_abc
|
|
67
|
+
});
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
Task({
|
|
70
|
+
subagent_type: "scout",
|
|
71
|
+
description: "Research best practices",
|
|
71
72
|
prompt: `Research best practices for "${$ARGUMENTS}":
|
|
72
73
|
1. Industry patterns for this type of feature
|
|
73
74
|
2. Library/framework recommendations
|
|
74
75
|
3. Common pitfalls to avoid
|
|
75
76
|
Return: Recommendations, code examples, warnings`,
|
|
76
|
-
|
|
77
|
-
}); // → bg_456_def
|
|
77
|
+
});
|
|
78
78
|
|
|
79
|
-
//
|
|
79
|
+
// Both run in parallel, results available immediately
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
### Check Existing Work
|
|
@@ -73,38 +73,36 @@ If memory search fails (Ollama not running), continue to subagent research.
|
|
|
73
73
|
|
|
74
74
|
## Phase 1: Parallel Subagent Research
|
|
75
75
|
|
|
76
|
-
Gather context before designing.
|
|
76
|
+
Gather context before designing. Run both in parallel:
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
|
-
// Codebase patterns
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
// Codebase patterns - run in parallel with scout
|
|
80
|
+
Task({
|
|
81
|
+
subagent_type: "explore",
|
|
82
|
+
description: "Explore codebase for planning",
|
|
82
83
|
prompt: `For planning $ARGUMENTS, research the codebase:
|
|
83
84
|
1. Find similar implementations or patterns
|
|
84
85
|
2. Identify affected files and their structure
|
|
85
86
|
3. Find related tests and testing patterns
|
|
86
87
|
4. Check for potential conflicts with in-progress work
|
|
87
88
|
Return: File paths, code patterns, test approach, conflicts`,
|
|
88
|
-
|
|
89
|
-
}); // → bg_123_abc
|
|
89
|
+
});
|
|
90
90
|
|
|
91
|
-
// External best practices
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
// External best practices - run in parallel with explore
|
|
92
|
+
Task({
|
|
93
|
+
subagent_type: "scout",
|
|
94
|
+
description: "Research implementation approaches",
|
|
94
95
|
prompt: `Research implementation approaches for $ARGUMENTS:
|
|
95
96
|
1. Best practices from official documentation
|
|
96
97
|
2. Common patterns in open source projects
|
|
97
98
|
3. Pitfalls and anti-patterns to avoid
|
|
98
99
|
Return: Recommendations, code examples, warnings`,
|
|
99
|
-
|
|
100
|
-
}); // → bg_456_def
|
|
100
|
+
});
|
|
101
101
|
|
|
102
|
-
//
|
|
103
|
-
background_output({ taskId: "bg_123_abc" });
|
|
104
|
-
background_output({ taskId: "bg_456_def" });
|
|
102
|
+
// Both run in parallel, results available immediately
|
|
105
103
|
```
|
|
106
104
|
|
|
107
|
-
**
|
|
105
|
+
**Integrate findings into your plan.**
|
|
108
106
|
|
|
109
107
|
---
|
|
110
108
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Start Ralph Wiggum autonomous loop for task completion
|
|
3
|
+
argument-hint: "<task> [--prd <file>]"
|
|
4
|
+
agent: build
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Ralph Wiggum Loop
|
|
8
|
+
|
|
9
|
+
First, load the ralph skill for complete instructions:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
skill({ name: "ralph" });
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Task
|
|
16
|
+
|
|
17
|
+
$ARGUMENTS
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
1. **Load the skill** (above) to get full workflow instructions
|
|
22
|
+
2. **Detect environment**: Check lock files to determine package manager
|
|
23
|
+
3. **Create progress.txt**: Track completed tasks and notes
|
|
24
|
+
4. **Start iterating**: Follow the loop pattern from the skill
|
|
25
|
+
|
|
26
|
+
## The Loop (Summary)
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Read PRD → Pick task → Implement ONE feature → Validate → Commit → Update progress → Repeat
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Exit when ALL tasks complete by outputting:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
<promise>COMPLETE</promise>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## See Also
|
|
39
|
+
|
|
40
|
+
- Full instructions: `skill({ name: "ralph" })`
|
|
41
|
+
- Skill location: `.opencode/skill/ralph/SKILL.md`
|
|
@@ -169,36 +169,35 @@ cd .worktrees/$ARGUMENTS
|
|
|
169
169
|
For complex tasks, gather context before diving in:
|
|
170
170
|
|
|
171
171
|
```typescript
|
|
172
|
-
//
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
// Run subagents in parallel - multiple Task calls in one message
|
|
173
|
+
Task({
|
|
174
|
+
subagent_type: "explore",
|
|
175
|
+
description: "Explore codebase patterns",
|
|
175
176
|
prompt: `Research codebase patterns for $ARGUMENTS:
|
|
176
177
|
- Find similar implementations
|
|
177
178
|
- Identify affected files
|
|
178
179
|
- Note testing patterns used
|
|
179
180
|
Return: File list, patterns found, testing approach`,
|
|
180
|
-
|
|
181
|
-
}); // → bg_123_abc
|
|
181
|
+
});
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
Task({
|
|
184
|
+
subagent_type: "scout",
|
|
185
|
+
description: "Research external docs",
|
|
185
186
|
prompt: `Research external docs for $ARGUMENTS:
|
|
186
187
|
- API documentation for libraries involved
|
|
187
188
|
- Best practices for the approach
|
|
188
189
|
- Common pitfalls to avoid
|
|
189
190
|
Return: Key findings, code examples, warnings`,
|
|
190
|
-
|
|
191
|
-
}); // → bg_456_def
|
|
191
|
+
});
|
|
192
192
|
|
|
193
|
-
//
|
|
193
|
+
// Both run in parallel, results available immediately
|
|
194
194
|
```
|
|
195
195
|
|
|
196
196
|
**Subagent delegation rules:**
|
|
197
197
|
|
|
198
198
|
- Subagents are **read-only** - they don't modify beads state
|
|
199
|
-
- Results
|
|
199
|
+
- Results returned immediately when all complete
|
|
200
200
|
- Use for research, not for implementation
|
|
201
|
-
- Cleanup at session end: `background_cancel({ all: true })`
|
|
202
201
|
|
|
203
202
|
## Existing Artifacts
|
|
204
203
|
|
|
@@ -77,7 +77,11 @@
|
|
|
77
77
|
"extensions": [".html", ".css", ".scss", ".sass", ".md", ".yaml", ".yml"]
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
-
"instructions": [
|
|
80
|
+
"instructions": [
|
|
81
|
+
".opencode/memory/user.md",
|
|
82
|
+
".opencode/memory/project/*.md",
|
|
83
|
+
".opencode/memory/observations/*.md"
|
|
84
|
+
],
|
|
81
85
|
"keybinds": {
|
|
82
86
|
"command_list": ";",
|
|
83
87
|
"leader": "`",
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* 1. Load session-context.md (CONTINUITY.md pattern)
|
|
6
6
|
* 2. Load project memory files
|
|
7
7
|
* 3. Inject beads in-progress state
|
|
8
|
-
* 4.
|
|
8
|
+
* 4. Load most recent handoff file for session resumption
|
|
9
|
+
* 5. Append workflow-specific compaction rules
|
|
9
10
|
*
|
|
10
11
|
* Session context format (agent-maintained via memory-update):
|
|
11
12
|
* - Goal: What we're trying to achieve + success criteria
|
|
@@ -20,6 +21,7 @@ import type { Plugin } from "@opencode-ai/plugin";
|
|
|
20
21
|
|
|
21
22
|
export const CompactionPlugin: Plugin = async ({ $, directory }) => {
|
|
22
23
|
const MEMORY_DIR = `${directory}/.opencode/memory`;
|
|
24
|
+
const HANDOFF_DIR = `${MEMORY_DIR}/handoffs`;
|
|
23
25
|
|
|
24
26
|
return {
|
|
25
27
|
"experimental.session.compacting": async (input, output) => {
|
|
@@ -69,8 +71,29 @@ export const CompactionPlugin: Plugin = async ({ $, directory }) => {
|
|
|
69
71
|
// Beads not available, skip
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
// 4. Load most recent handoff file (session continuity)
|
|
75
|
+
let handoffContext = "";
|
|
76
|
+
try {
|
|
77
|
+
const result =
|
|
78
|
+
await $`ls -t ${HANDOFF_DIR}/*.md 2>/dev/null | head -1`.quiet();
|
|
79
|
+
if (result.stdout) {
|
|
80
|
+
const handoffPath = result.stdout.toString().trim();
|
|
81
|
+
if (handoffPath) {
|
|
82
|
+
const handoffContent = await $`cat ${handoffPath}`.text();
|
|
83
|
+
handoffContext = `\n## Previous Session Handoff\n\n${handoffContent}\n\n**IMPORTANT**: Resume work from where previous session left off.`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
// No handoff files, skip
|
|
88
|
+
}
|
|
89
|
+
|
|
72
90
|
// Inject all context - session context FIRST (most important)
|
|
73
|
-
const allContext = [
|
|
91
|
+
const allContext = [
|
|
92
|
+
sessionContext,
|
|
93
|
+
beadsContext,
|
|
94
|
+
handoffContext,
|
|
95
|
+
memoryContext,
|
|
96
|
+
]
|
|
74
97
|
.filter(Boolean)
|
|
75
98
|
.join("\n");
|
|
76
99
|
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ralph
|
|
3
|
+
description: Use when running autonomous agent loops for extended task completion without human intervention - handles PRD-driven development, migration tasks, or batch operations
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
metadata:
|
|
7
|
+
source: https://ghuntley.com/ralph/
|
|
8
|
+
category: automation
|
|
9
|
+
updated: 2026-01-10
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Ralph Wiggum - Autonomous Agent Loop
|
|
13
|
+
|
|
14
|
+
A workflow pattern for extended autonomous work sessions where the agent iterates through tasks until completion.
|
|
15
|
+
|
|
16
|
+
## When to Use
|
|
17
|
+
|
|
18
|
+
- **PRD-driven development**: Work through a product requirements document task by task
|
|
19
|
+
- **Migration tasks**: "Migrate all Jest tests to Vitest" - agent works until done
|
|
20
|
+
- **Batch operations**: Process multiple files/components with the same pattern
|
|
21
|
+
- **Away-from-keyboard work**: Let the agent work autonomously while you're away
|
|
22
|
+
|
|
23
|
+
## When NOT to Use
|
|
24
|
+
|
|
25
|
+
- Simple single-step tasks (just do them directly)
|
|
26
|
+
- Tasks requiring frequent human decisions
|
|
27
|
+
- Exploratory work where the goal isn't clear
|
|
28
|
+
- Critical production changes (requires human oversight)
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
Invoke the workflow with:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
/ralph Migrate all Jest tests to Vitest --prd PRD.md
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or manually follow the loop pattern below.
|
|
39
|
+
|
|
40
|
+
## The Loop Pattern
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
┌─────────────────────────────────────────────────┐
|
|
44
|
+
│ 1. Read PRD/task list + progress.txt │
|
|
45
|
+
│ 2. Pick highest-priority incomplete task │
|
|
46
|
+
│ 3. Implement ONE feature only │
|
|
47
|
+
│ 4. Run feedback: test → typecheck → lint │
|
|
48
|
+
│ 5. If pass → commit + update progress.txt │
|
|
49
|
+
│ 6. If all done → output <promise>COMPLETE │
|
|
50
|
+
│ 7. Otherwise → repeat from step 1 │
|
|
51
|
+
└─────────────────────────────────────────────────┘
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Using LSP Tools (Experimental)
|
|
55
|
+
|
|
56
|
+
OpenCode provides LSP tools for code intelligence.
|
|
57
|
+
|
|
58
|
+
### Available Operations
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Understand file structure before editing
|
|
62
|
+
lsp({
|
|
63
|
+
operation: "documentSymbol",
|
|
64
|
+
filePath: "src/auth.ts",
|
|
65
|
+
line: 1,
|
|
66
|
+
character: 1,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Find where a symbol is defined
|
|
70
|
+
lsp({
|
|
71
|
+
operation: "goToDefinition",
|
|
72
|
+
filePath: "src/auth.ts",
|
|
73
|
+
line: 42,
|
|
74
|
+
character: 10,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Find all usages of a symbol (impact analysis)
|
|
78
|
+
lsp({
|
|
79
|
+
operation: "findReferences",
|
|
80
|
+
filePath: "src/auth.ts",
|
|
81
|
+
line: 42,
|
|
82
|
+
character: 10,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Get type info and documentation
|
|
86
|
+
lsp({ operation: "hover", filePath: "src/auth.ts", line: 42, character: 10 });
|
|
87
|
+
|
|
88
|
+
// Find implementations of interface/abstract
|
|
89
|
+
lsp({
|
|
90
|
+
operation: "goToImplementation",
|
|
91
|
+
filePath: "src/types.ts",
|
|
92
|
+
line: 15,
|
|
93
|
+
character: 10,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Search symbols across entire workspace
|
|
97
|
+
lsp({
|
|
98
|
+
operation: "workspaceSymbol",
|
|
99
|
+
filePath: "src/index.ts",
|
|
100
|
+
line: 1,
|
|
101
|
+
character: 1,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Call hierarchy analysis
|
|
105
|
+
lsp({
|
|
106
|
+
operation: "prepareCallHierarchy",
|
|
107
|
+
filePath: "src/api.ts",
|
|
108
|
+
line: 20,
|
|
109
|
+
character: 5,
|
|
110
|
+
});
|
|
111
|
+
lsp({
|
|
112
|
+
operation: "incomingCalls",
|
|
113
|
+
filePath: "src/api.ts",
|
|
114
|
+
line: 20,
|
|
115
|
+
character: 5,
|
|
116
|
+
});
|
|
117
|
+
lsp({
|
|
118
|
+
operation: "outgoingCalls",
|
|
119
|
+
filePath: "src/api.ts",
|
|
120
|
+
line: 20,
|
|
121
|
+
character: 5,
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### LSP-First Workflow
|
|
126
|
+
|
|
127
|
+
Before editing ANY file in the loop:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
1. Read the file
|
|
131
|
+
2. Use documentSymbol to understand structure
|
|
132
|
+
3. Use findReferences to check impact
|
|
133
|
+
4. Use hover for type info
|
|
134
|
+
5. THEN make edits
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This prevents breaking changes and ensures you understand the code before modifying it.
|
|
138
|
+
|
|
139
|
+
## Smart Language Detection
|
|
140
|
+
|
|
141
|
+
OpenCode auto-detects languages via LSP based on file extensions. Use this to determine the project type:
|
|
142
|
+
|
|
143
|
+
### Primary Detection (File Extensions)
|
|
144
|
+
|
|
145
|
+
| Language | Extensions | LSP Server |
|
|
146
|
+
| ---------- | ----------------------------- | ------------- |
|
|
147
|
+
| TypeScript | `.ts`, `.tsx`, `.mts`, `.cts` | typescript |
|
|
148
|
+
| JavaScript | `.js`, `.jsx`, `.mjs`, `.cjs` | typescript |
|
|
149
|
+
| Python | `.py`, `.pyi` | pyright |
|
|
150
|
+
| Rust | `.rs` | rust-analyzer |
|
|
151
|
+
| Go | `.go` | gopls |
|
|
152
|
+
| C/C++ | `.c`, `.cpp`, `.h`, `.hpp` | clangd |
|
|
153
|
+
| Java | `.java` | jdtls |
|
|
154
|
+
| C# | `.cs` | csharp |
|
|
155
|
+
| Ruby | `.rb`, `.rake` | ruby-lsp |
|
|
156
|
+
| PHP | `.php` | intelephense |
|
|
157
|
+
| Swift | `.swift` | sourcekit-lsp |
|
|
158
|
+
| Kotlin | `.kt`, `.kts` | kotlin-ls |
|
|
159
|
+
| Elixir | `.ex`, `.exs` | elixir-ls |
|
|
160
|
+
| Dart | `.dart` | dart |
|
|
161
|
+
| Zig | `.zig` | zls |
|
|
162
|
+
| Gleam | `.gleam` | gleam |
|
|
163
|
+
| Lua | `.lua` | lua-ls |
|
|
164
|
+
| Clojure | `.clj`, `.cljs`, `.cljc` | clojure-lsp |
|
|
165
|
+
| OCaml | `.ml`, `.mli` | ocaml-lsp |
|
|
166
|
+
| Svelte | `.svelte` | svelte |
|
|
167
|
+
| Vue | `.vue` | vue |
|
|
168
|
+
| Astro | `.astro` | astro |
|
|
169
|
+
|
|
170
|
+
### Secondary Detection (Lock Files → Package Manager)
|
|
171
|
+
|
|
172
|
+
| Lock File | Package Manager | Runtime |
|
|
173
|
+
| ------------------- | --------------- | ------- |
|
|
174
|
+
| `bun.lockb` | Bun | Bun |
|
|
175
|
+
| `yarn.lock` | Yarn | Node |
|
|
176
|
+
| `pnpm-lock.yaml` | pnpm | Node |
|
|
177
|
+
| `package-lock.json` | npm | Node |
|
|
178
|
+
| `deno.json` | Deno | Deno |
|
|
179
|
+
| `Cargo.toml` | Cargo | Rust |
|
|
180
|
+
| `go.mod` | Go Modules | Go |
|
|
181
|
+
| `pyproject.toml` | Poetry/pip | Python |
|
|
182
|
+
| `Gemfile.lock` | Bundler | Ruby |
|
|
183
|
+
| `composer.lock` | Composer | PHP |
|
|
184
|
+
| `Package.swift` | SwiftPM | Swift |
|
|
185
|
+
| `mix.lock` | Mix | Elixir |
|
|
186
|
+
| `pubspec.lock` | Pub | Dart |
|
|
187
|
+
|
|
188
|
+
### Validation Commands by Language
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# TypeScript/JavaScript (Bun)
|
|
192
|
+
bun test && bun run typecheck && bun run lint
|
|
193
|
+
|
|
194
|
+
# TypeScript/JavaScript (npm)
|
|
195
|
+
npm test && npm run typecheck && npm run lint
|
|
196
|
+
|
|
197
|
+
# TypeScript/JavaScript (Deno)
|
|
198
|
+
deno test && deno check . && deno lint
|
|
199
|
+
|
|
200
|
+
# Python
|
|
201
|
+
pytest && ruff check . && mypy .
|
|
202
|
+
|
|
203
|
+
# Rust
|
|
204
|
+
cargo test && cargo check && cargo clippy --all-targets
|
|
205
|
+
|
|
206
|
+
# Go
|
|
207
|
+
go test ./... && go vet ./... && golangci-lint run
|
|
208
|
+
|
|
209
|
+
# Ruby
|
|
210
|
+
bundle exec rspec && bundle exec rubocop
|
|
211
|
+
|
|
212
|
+
# PHP
|
|
213
|
+
composer test && composer phpstan && composer phpcs
|
|
214
|
+
|
|
215
|
+
# Swift
|
|
216
|
+
swift test && swift build
|
|
217
|
+
|
|
218
|
+
# Elixir
|
|
219
|
+
mix test && mix credo && mix dialyzer
|
|
220
|
+
|
|
221
|
+
# Dart
|
|
222
|
+
dart test && dart analyze
|
|
223
|
+
|
|
224
|
+
# Java (Maven)
|
|
225
|
+
mvn test && mvn compile && mvn checkstyle:check
|
|
226
|
+
|
|
227
|
+
# Java (Gradle)
|
|
228
|
+
./gradlew test && ./gradlew check
|
|
229
|
+
|
|
230
|
+
# C# (.NET)
|
|
231
|
+
dotnet test && dotnet build && dotnet format --verify-no-changes
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Required Files
|
|
235
|
+
|
|
236
|
+
### PRD File (Recommended)
|
|
237
|
+
|
|
238
|
+
Create a `PRD.md` with clear task list:
|
|
239
|
+
|
|
240
|
+
```markdown
|
|
241
|
+
# Migration PRD
|
|
242
|
+
|
|
243
|
+
## Tasks
|
|
244
|
+
|
|
245
|
+
- [ ] Convert test-utils.test.js
|
|
246
|
+
- [ ] Convert api.test.js
|
|
247
|
+
- [ ] Update CI config
|
|
248
|
+
- [ ] Remove Jest dependencies
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Progress File (Agent-maintained)
|
|
252
|
+
|
|
253
|
+
Agent creates/updates `progress.txt`:
|
|
254
|
+
|
|
255
|
+
```markdown
|
|
256
|
+
# Progress Log
|
|
257
|
+
|
|
258
|
+
## Session Started: 2026-01-10
|
|
259
|
+
|
|
260
|
+
### Project: TypeScript with Bun
|
|
261
|
+
|
|
262
|
+
### Commands: bun test | bun run typecheck | bun run lint
|
|
263
|
+
|
|
264
|
+
### Completed Tasks
|
|
265
|
+
|
|
266
|
+
- [x] test-utils.test.js - migrated, 12 tests passing
|
|
267
|
+
- [x] api.test.js - migrated, 8 tests passing
|
|
268
|
+
|
|
269
|
+
### Notes for Next Iteration
|
|
270
|
+
|
|
271
|
+
- CI config needs Vitest runner update
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Completion Signal
|
|
275
|
+
|
|
276
|
+
The loop ends when agent outputs:
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
<promise>COMPLETE</promise>
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Best Practices
|
|
283
|
+
|
|
284
|
+
1. **Use LSP for detection**: Check file extensions, not just lock files
|
|
285
|
+
2. **Small steps**: ONE feature per iteration (prevents context rot)
|
|
286
|
+
3. **Quality gates**: Test, typecheck, lint MUST pass before commit
|
|
287
|
+
4. **Prioritize risk**: Hard tasks first, easy wins last
|
|
288
|
+
5. **Track progress**: Update progress.txt every iteration
|
|
289
|
+
6. **Explicit scope**: Vague tasks loop forever
|
|
290
|
+
7. **Graceful fallbacks**: If a command doesn't exist, skip and note it
|
|
291
|
+
|
|
292
|
+
## Troubleshooting
|
|
293
|
+
|
|
294
|
+
| Issue | Solution |
|
|
295
|
+
| -------------------- | ------------------------------------------- |
|
|
296
|
+
| Loop not progressing | Break task into smaller pieces |
|
|
297
|
+
| Tests failing | Fix before continuing, don't skip |
|
|
298
|
+
| Context getting long | Summarize progress, restart session |
|
|
299
|
+
| Stuck on decision | Note in progress.txt, ask user next session |
|
|
300
|
+
| Unknown language | Check file extensions against LSP table |
|