opencodekit 0.14.2 → 0.14.4
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 +1 -1
- package/dist/template/.opencode/.background-tasks.json +95 -95
- package/dist/template/.opencode/.ralph-state.json +11 -11
- package/dist/template/.opencode/agent/build.md +29 -1
- package/dist/template/.opencode/agent/planner.md +93 -0
- package/dist/template/.opencode/agent/rush.md +18 -0
- package/dist/template/.opencode/command/ralph.md +41 -0
- package/dist/template/.opencode/opencode.json +8 -4
- package/dist/template/.opencode/package.json +1 -1
- package/dist/template/.opencode/plugin/compaction.ts +25 -2
- package/dist/template/.opencode/plugin/lsp.ts +9 -4
- package/dist/template/.opencode/skill/ralph/SKILL.md +300 -0
- package/dist/template/.opencode/tool/background.ts +1 -1
- package/package.json +1 -1
- 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
package/dist/index.js
CHANGED
|
@@ -750,7 +750,7 @@ var cac = (name = "") => new CAC(name);
|
|
|
750
750
|
// package.json
|
|
751
751
|
var package_default = {
|
|
752
752
|
name: "opencodekit",
|
|
753
|
-
version: "0.14.
|
|
753
|
+
version: "0.14.4",
|
|
754
754
|
description: "CLI tool for bootstrapping and managing OpenCodeKit projects",
|
|
755
755
|
type: "module",
|
|
756
756
|
repository: {
|
|
@@ -1,96 +1,96 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
2
|
+
"tasks": {
|
|
3
|
+
"bg_1767973877335_d2ihzd": {
|
|
4
|
+
"taskId": "bg_1767973877335_d2ihzd",
|
|
5
|
+
"sessionId": "ses_45c8b89a4ffeuq5BxBRQv4wrwd",
|
|
6
|
+
"agent": "explore",
|
|
7
|
+
"prompt": "Find all agent definitions in this project. List the file paths and agent names.",
|
|
8
|
+
"started": 1767973890766,
|
|
9
|
+
"status": "cancelled"
|
|
10
|
+
},
|
|
11
|
+
"bg_1767973898236_s7kyjm": {
|
|
12
|
+
"taskId": "bg_1767973898236_s7kyjm",
|
|
13
|
+
"sessionId": "ses_45c8b37ffffeIMMtZrHruaRN7A",
|
|
14
|
+
"agent": "scout",
|
|
15
|
+
"prompt": "What is the latest version of @opencode-ai/sdk and what are its main features?",
|
|
16
|
+
"started": 1767973936815,
|
|
17
|
+
"status": "completed"
|
|
18
|
+
},
|
|
19
|
+
"bg_1767974743680_ppd6p1": {
|
|
20
|
+
"taskId": "bg_1767974743680_ppd6p1",
|
|
21
|
+
"sessionId": "ses_45c7e517bffeagStJem1UDrHNf",
|
|
22
|
+
"agent": "explore",
|
|
23
|
+
"prompt": "Find all TypeScript files in the .opencode/tool directory and list them.",
|
|
24
|
+
"started": 1767974756797,
|
|
25
|
+
"status": "completed",
|
|
26
|
+
"beadId": "opencodekit-template-ag8",
|
|
27
|
+
"autoCloseBead": true
|
|
28
|
+
},
|
|
29
|
+
"bg_1767974825480_mlpk5z": {
|
|
30
|
+
"taskId": "bg_1767974825480_mlpk5z",
|
|
31
|
+
"sessionId": "ses_45c7d11efffe9LnnUp1W2C7GiI",
|
|
32
|
+
"agent": "explore",
|
|
33
|
+
"prompt": "List all files in .opencode/agent directory",
|
|
34
|
+
"started": 1767974843970,
|
|
35
|
+
"status": "completed",
|
|
36
|
+
"beadId": "opencodekit-template-3k0",
|
|
37
|
+
"autoCloseBead": true
|
|
38
|
+
},
|
|
39
|
+
"bg_1767975003390_y1pliv": {
|
|
40
|
+
"taskId": "bg_1767975003390_y1pliv",
|
|
41
|
+
"sessionId": "ses_45c7a5afffferx20SjJEy782Ap",
|
|
42
|
+
"agent": "explore",
|
|
43
|
+
"prompt": "Count the number of markdown files in .opencode/command directory",
|
|
44
|
+
"started": 1767975020306,
|
|
45
|
+
"status": "completed",
|
|
46
|
+
"beadId": "opencodekit-template-0ch",
|
|
47
|
+
"autoCloseBead": true
|
|
48
|
+
},
|
|
49
|
+
"bg_1767975064912_8nvlh7": {
|
|
50
|
+
"taskId": "bg_1767975064912_8nvlh7",
|
|
51
|
+
"sessionId": "ses_45c796aa9ffeYEhEzxybXEuOfO",
|
|
52
|
+
"agent": "explore",
|
|
53
|
+
"prompt": "List files in .opencode/agent directory",
|
|
54
|
+
"started": 1767975078449,
|
|
55
|
+
"status": "completed",
|
|
56
|
+
"beadId": "opencodekit-template-ryg",
|
|
57
|
+
"autoCloseBead": true
|
|
58
|
+
},
|
|
59
|
+
"bg_1767982850780_sdkoc4": {
|
|
60
|
+
"taskId": "bg_1767982850780_sdkoc4",
|
|
61
|
+
"sessionId": "ses_45c029d22ffe7cWSSebxdvxIgL",
|
|
62
|
+
"agent": "explore",
|
|
63
|
+
"prompt": "Find all TypeScript files in the src/commands directory and list what each command does. This is a test of agent delegation.",
|
|
64
|
+
"started": 1767982870771,
|
|
65
|
+
"status": "completed"
|
|
66
|
+
},
|
|
67
|
+
"bg_1767984165033_jyv9bd": {
|
|
68
|
+
"taskId": "bg_1767984165033_jyv9bd",
|
|
69
|
+
"sessionId": "ses_45bee8f51ffeJ6B5L7AMik624S",
|
|
70
|
+
"parentSessionId": "ses_45c0ae526ffeQlmBlscyZMZALt",
|
|
71
|
+
"agent": "explore",
|
|
72
|
+
"prompt": "List all TypeScript files in .opencode/tool/ directory and briefly describe what each tool does. This is a test of sub-session linking.",
|
|
73
|
+
"started": 1767984193526,
|
|
74
|
+
"status": "completed"
|
|
75
|
+
},
|
|
76
|
+
"bg_1767984696916_qi0xa9": {
|
|
77
|
+
"taskId": "bg_1767984696916_qi0xa9",
|
|
78
|
+
"sessionId": "ses_45be671a7ffeXRL43PHImPBtCh",
|
|
79
|
+
"parentSessionId": "ses_45c0ae526ffeQlmBlscyZMZALt",
|
|
80
|
+
"agent": "explore",
|
|
81
|
+
"prompt": "Find all files in src/commands/ and list their exports. This is a test of the updated background tool.",
|
|
82
|
+
"started": 1767984719380,
|
|
83
|
+
"status": "completed",
|
|
84
|
+
"beadId": "bd-test-123"
|
|
85
|
+
},
|
|
86
|
+
"bg_1767985457040_uo3le4": {
|
|
87
|
+
"taskId": "bg_1767985457040_uo3le4",
|
|
88
|
+
"sessionId": "ses_45bdad86bffeZNUcXDi1wrSwxb",
|
|
89
|
+
"parentSessionId": "ses_45c0ae526ffeQlmBlscyZMZALt",
|
|
90
|
+
"agent": "explore",
|
|
91
|
+
"prompt": "List files in src/ directory. Quick test.",
|
|
92
|
+
"started": 1767985471066,
|
|
93
|
+
"status": "running"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
2
|
+
"active": false,
|
|
3
|
+
"sessionID": null,
|
|
4
|
+
"iteration": 0,
|
|
5
|
+
"maxIterations": 50,
|
|
6
|
+
"completionPromise": "<promise>COMPLETE</promise>",
|
|
7
|
+
"task": "",
|
|
8
|
+
"prdFile": null,
|
|
9
|
+
"progressFile": "progress.txt",
|
|
10
|
+
"startedAt": null,
|
|
11
|
+
"mode": "hitl"
|
|
12
|
+
}
|
|
@@ -56,6 +56,23 @@ Tool results and user messages may include `<system-reminder>` tags. These conta
|
|
|
56
56
|
- Keep responses concise
|
|
57
57
|
- First output is ~70-80% right; refinement is expected, not failure
|
|
58
58
|
|
|
59
|
+
## Progress Updates (Preamble Pattern)
|
|
60
|
+
|
|
61
|
+
Before tool calls during multi-step work, send brief updates (8-12 words) to keep users informed:
|
|
62
|
+
|
|
63
|
+
**Good examples:**
|
|
64
|
+
|
|
65
|
+
- "Tests passing. Now updating the API handler."
|
|
66
|
+
- "Found the bug in auth.ts:42. Fixing now."
|
|
67
|
+
- "Linter clean. Running full test suite."
|
|
68
|
+
|
|
69
|
+
**Bad examples:**
|
|
70
|
+
|
|
71
|
+
- [radio silence for 2 minutes while working]
|
|
72
|
+
- "I am now going to use the edit tool to modify the authentication service file..." (too verbose)
|
|
73
|
+
|
|
74
|
+
Keep users in the loop without flooding them.
|
|
75
|
+
|
|
59
76
|
## Phase 0: Intent Gate
|
|
60
77
|
|
|
61
78
|
Before ANY action on a new request, do two things.
|
|
@@ -198,7 +215,18 @@ Never leave code in a broken state. Never continue hoping random changes will wo
|
|
|
198
215
|
|
|
199
216
|
## Task Management
|
|
200
217
|
|
|
201
|
-
|
|
218
|
+
Use TodoWrite to track subtasks with explicit status flow:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
pending → in_progress → completed
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Rules:**
|
|
225
|
+
|
|
226
|
+
- There should be exactly ONE `in_progress` task at a time
|
|
227
|
+
- Complete current tasks before starting new ones
|
|
228
|
+
- Mark tasks complete immediately after finishing (don't batch)
|
|
229
|
+
- Update every 10-15 minutes during long sessions
|
|
202
230
|
- Finish one subtask end-to-end before starting next
|
|
203
231
|
- Create handoff via `/handoff <bead-id>` before context limit
|
|
204
232
|
|
|
@@ -42,6 +42,43 @@ Think, read, search, and delegate @explore/@scout agents to construct a well-for
|
|
|
42
42
|
Tool results and user messages may include `<system-reminder>` tags. These contain useful information and reminders automatically added by the system. They bear no direct relation to the specific tool results or user messages in which they appear.
|
|
43
43
|
</system-reminder>
|
|
44
44
|
|
|
45
|
+
## When to Plan vs When to Execute
|
|
46
|
+
|
|
47
|
+
**Use a plan when:**
|
|
48
|
+
|
|
49
|
+
- Task is non-trivial and requires multiple actions over a long time horizon
|
|
50
|
+
- There are logical phases or dependencies where sequencing matters
|
|
51
|
+
- Work has ambiguity that benefits from outlining high-level goals
|
|
52
|
+
- User asked for more than one thing in a single prompt
|
|
53
|
+
- You need intermediate checkpoints for feedback and validation
|
|
54
|
+
|
|
55
|
+
**Skip planning for:**
|
|
56
|
+
|
|
57
|
+
- Simple single-step queries you can answer immediately
|
|
58
|
+
- Padding simple work with filler steps
|
|
59
|
+
- Trivial tasks where planning adds no value
|
|
60
|
+
|
|
61
|
+
Don't over-plan. If user asks "fix the typo in line 42", just delegate to @build. No plan needed.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Progress Updates (Preamble Pattern)
|
|
66
|
+
|
|
67
|
+
Before tool calls during research, send brief updates (8-12 words) to keep users informed:
|
|
68
|
+
|
|
69
|
+
**Good examples:**
|
|
70
|
+
|
|
71
|
+
- "Explored the repo; now checking API route definitions."
|
|
72
|
+
- "Config's looking tidy. Next up is editing helpers."
|
|
73
|
+
- "Finished reviewing auth patterns. Chasing down error handling."
|
|
74
|
+
|
|
75
|
+
**Bad examples:**
|
|
76
|
+
|
|
77
|
+
- [radio silence for 30 seconds while agents run]
|
|
78
|
+
- "I am now going to use the explore agent to search for patterns in the codebase..." (too verbose)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
45
82
|
## Enhanced Planning Workflow
|
|
46
83
|
|
|
47
84
|
### Phase 1: Initial Understanding
|
|
@@ -175,6 +212,62 @@ Final plan should include:
|
|
|
175
212
|
|
|
176
213
|
**Always end with**: "Ready to proceed with this plan?"
|
|
177
214
|
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Plan Quality Examples
|
|
218
|
+
|
|
219
|
+
**High-quality plans** (specific, actionable, verifiable):
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
1. Add CLI entry with file args
|
|
223
|
+
2. Parse Markdown via CommonMark library
|
|
224
|
+
3. Apply semantic HTML template
|
|
225
|
+
4. Handle code blocks, images, links
|
|
226
|
+
5. Add error handling for invalid files
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
1. Define CSS variables for colors
|
|
231
|
+
2. Add toggle with localStorage state
|
|
232
|
+
3. Refactor components to use variables
|
|
233
|
+
4. Verify all views for readability
|
|
234
|
+
5. Add smooth theme-change transition
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Low-quality plans** (vague, no actionable steps):
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
1. Create CLI tool
|
|
241
|
+
2. Add Markdown parser
|
|
242
|
+
3. Convert to HTML
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
1. Add dark mode toggle
|
|
247
|
+
2. Save preference
|
|
248
|
+
3. Make styles look good
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
The difference: high-quality plans have **specific implementation details** that can be verified. Low-quality plans are just restating the goal.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## TodoWrite Status Management
|
|
256
|
+
|
|
257
|
+
When creating implementation plans that @build will execute, understand the status flow:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
pending → in_progress → completed
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Rules:**
|
|
264
|
+
|
|
265
|
+
- There should be exactly ONE `in_progress` step at a time
|
|
266
|
+
- Complete current tasks before starting new ones
|
|
267
|
+
- Mark steps complete immediately after finishing (don't batch)
|
|
268
|
+
|
|
269
|
+
This helps @build track progress and helps users understand where work stands
|
|
270
|
+
|
|
178
271
|
## Specification Quality Checklist
|
|
179
272
|
|
|
180
273
|
Before presenting plan:
|
|
@@ -113,6 +113,24 @@ Delegate immediately when you hit any of these:
|
|
|
113
113
|
- First output is ~70-80% right; refinement is expected
|
|
114
114
|
- Quick sanity check after changes (linter/type-check), but don't do full verification loops
|
|
115
115
|
|
|
116
|
+
## Progress Updates (Preamble Pattern)
|
|
117
|
+
|
|
118
|
+
Even at speed, brief updates (8-12 words) help users track what's happening:
|
|
119
|
+
|
|
120
|
+
**Good examples:**
|
|
121
|
+
|
|
122
|
+
- "Found it. Fixing the typo now."
|
|
123
|
+
- "Config updated. Running quick lint check."
|
|
124
|
+
- "Done. Delegating the rest to @build."
|
|
125
|
+
|
|
126
|
+
Don't go silent during multi-file changes. One-liners are fine.
|
|
127
|
+
|
|
128
|
+
## Ambition vs Precision
|
|
129
|
+
|
|
130
|
+
**Greenfield code** (new files, new features): Be bold. Use modern patterns. Move fast.
|
|
131
|
+
|
|
132
|
+
**Existing code** (modifications, fixes): Be surgical. Match existing style exactly. Don't refactor unrelated code—that's scope creep, delegate to @build.
|
|
133
|
+
|
|
116
134
|
## Challenge Obvious Problems
|
|
117
135
|
|
|
118
136
|
Even at speed, don't blindly implement bad ideas. If you see an obvious problem with what the user is asking—something that will clearly break or contradict existing patterns—say so in one sentence and ask if they want to proceed anyway.
|
|
@@ -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`
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
},
|
|
8
8
|
"compaction": {
|
|
9
9
|
"description": "Session summarizer for context continuity across compactions",
|
|
10
|
-
"model": "
|
|
10
|
+
"model": "proxypal/gemini-2.5-flash"
|
|
11
11
|
},
|
|
12
12
|
"explore": {
|
|
13
13
|
"description": "Fast codebase search specialist",
|
|
14
|
-
"model": "
|
|
14
|
+
"model": "proxypal/gemini-3-flash-preview"
|
|
15
15
|
},
|
|
16
16
|
"looker": {
|
|
17
17
|
"description": "Media extraction specialist for images, PDFs, diagrams",
|
|
@@ -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": "`",
|
|
@@ -510,7 +514,7 @@
|
|
|
510
514
|
}
|
|
511
515
|
},
|
|
512
516
|
"share": "manual",
|
|
513
|
-
"small_model": "
|
|
517
|
+
"small_model": "proxypal/gemini-2.5-flash-lite",
|
|
514
518
|
"tui": {
|
|
515
519
|
"diff_style": "auto",
|
|
516
520
|
"scroll_acceleration": {
|
|
@@ -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
|
|
|
@@ -222,7 +222,8 @@ export const Lsp: Plugin = async () => {
|
|
|
222
222
|
* Injects LSP reminder when user mentions code files in their message
|
|
223
223
|
* This catches intent BEFORE tools are executed
|
|
224
224
|
*/
|
|
225
|
-
"chat.message": async (
|
|
225
|
+
"chat.message": async (input, output) => {
|
|
226
|
+
const { sessionID, messageID } = input;
|
|
226
227
|
const { message, parts } = output;
|
|
227
228
|
|
|
228
229
|
// Only process user messages
|
|
@@ -259,12 +260,16 @@ Do NOT skip LSP. Editing without semantic context leads to broken code.
|
|
|
259
260
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
260
261
|
`;
|
|
261
262
|
|
|
262
|
-
// Inject synthetic message part
|
|
263
|
-
|
|
263
|
+
// Inject synthetic message part with all required fields
|
|
264
|
+
const partId = `lsp-nudge-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
265
|
+
parts.push({
|
|
266
|
+
id: partId,
|
|
267
|
+
sessionID,
|
|
268
|
+
messageID: messageID || "",
|
|
264
269
|
type: "text",
|
|
265
270
|
text: nudgeText,
|
|
266
271
|
synthetic: true,
|
|
267
|
-
});
|
|
272
|
+
} as import("@opencode-ai/sdk").Part);
|
|
268
273
|
},
|
|
269
274
|
|
|
270
275
|
/**
|