opencode-handoff 0.1.0
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/LICENSE +9 -0
- package/README.md +81 -0
- package/package.json +36 -0
- package/src/plugin.ts +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Josh Thomas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# opencode-handoff
|
|
2
|
+
|
|
3
|
+
Create focused handoff prompts for continuing work in new sessions.
|
|
4
|
+
|
|
5
|
+
Inspired by Amp's handoff command - see their [post](https://ampcode.com/news/handoff) and [manual](https://ampcode.com/manual#handoff) about it.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- `/handoff <goal>` command that analyzes the conversation and generates a continuation prompt
|
|
10
|
+
- Guides the AI to include relevant `@file` references so the next session starts with context loaded
|
|
11
|
+
- Opens a new session with the prompt as an editable draft
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- [OpenCode](https://opencode.ai/) v1.0.143 or later
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Add to your OpenCode config (`~/.config/opencode/config.json`):
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"plugin": ["opencode-handoff@0.1.0"]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Restart OpenCode and you're ready to go.
|
|
28
|
+
|
|
29
|
+
Pin to a specific version to ensure updates work correctly - OpenCode's lockfile won't re-resolve unpinned versions. To upgrade, change the version and restart.
|
|
30
|
+
|
|
31
|
+
### Local Development
|
|
32
|
+
|
|
33
|
+
If you want to customize or contribute:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/joshuadavidthomas/opencode-handoff ~/.config/opencode/opencode-handoff
|
|
37
|
+
mkdir -p ~/.config/opencode/plugin
|
|
38
|
+
ln -sf ~/.config/opencode/opencode-handoff/src/plugin.ts ~/.config/opencode/plugin/handoff.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
1. Have a conversation in OpenCode with some context
|
|
44
|
+
2. When ready to continue in a fresh session, type `/handoff <your goal>`
|
|
45
|
+
3. A new session opens with the handoff prompt as an editable draft
|
|
46
|
+
4. Review and edit the draft if needed, then send
|
|
47
|
+
|
|
48
|
+
**Example:**
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
/handoff implement the user authentication feature we discussed
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The AI analyzes the conversation, extracts key decisions and relevant files, generates a focused prompt, and creates a new session with that prompt ready to edit.
|
|
55
|
+
|
|
56
|
+
## Contributing
|
|
57
|
+
|
|
58
|
+
Contributions are welcome! Here's how to set up for development:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/joshuadavidthomas/opencode-handoff
|
|
62
|
+
cd opencode-handoff
|
|
63
|
+
bun install
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then symlink the plugin to your OpenCode config:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
mkdir -p ~/.config/opencode/plugin
|
|
70
|
+
ln -sf "$(pwd)/src/plugin.ts" ~/.config/opencode/plugin/handoff.ts
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
opencode-handoff is licensed under the MIT license. See the [`LICENSE`](LICENSE) file for more information.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
opencode-handoff is not built by, or affiliated with, the OpenCode team.
|
|
80
|
+
|
|
81
|
+
OpenCode is ©2025 Anomaly.
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-handoff",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Create focused handoff prompts for continuing work in new OpenCode sessions",
|
|
6
|
+
"author": "Josh Thomas <josh@joshthomas.dev>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/joshuadavidthomas/opencode-handoff"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"opencode",
|
|
14
|
+
"plugin",
|
|
15
|
+
"agent",
|
|
16
|
+
"ai"
|
|
17
|
+
],
|
|
18
|
+
"main": "src/plugin.ts",
|
|
19
|
+
"files": ["src", "README.md"],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@opencode-ai/plugin": "^1.0.143",
|
|
25
|
+
"@opencode-ai/sdk": "^1.0.143",
|
|
26
|
+
"zod": "^4.1.13"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/bun": "latest",
|
|
30
|
+
"@types/node": "^22.0.0",
|
|
31
|
+
"typescript": "~5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"bun": ">=1.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Plugin } from "@opencode-ai/plugin"
|
|
2
|
+
import { tool } from "@opencode-ai/plugin"
|
|
3
|
+
|
|
4
|
+
export const HandoffPlugin: Plugin = async (ctx) => ({
|
|
5
|
+
config: async (config) => {
|
|
6
|
+
config.command = config.command || {}
|
|
7
|
+
config.command["handoff"] = {
|
|
8
|
+
description: "Create a focused handoff prompt for a new session",
|
|
9
|
+
template: `You are creating a handoff message to continue work in a new session.
|
|
10
|
+
|
|
11
|
+
User's goal: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
When an AI assistant starts a fresh session, it spends significant time exploring the codebase—grepping, reading files, searching—before it can begin actual work. This "file archaeology" is wasteful when the previous session already discovered what matters.
|
|
14
|
+
|
|
15
|
+
A good handoff frontloads everything the next session needs so it can start implementing immediately.
|
|
16
|
+
|
|
17
|
+
Analyze this conversation and extract what matters for continuing the work.
|
|
18
|
+
|
|
19
|
+
1. FILE REFERENCES (Required)
|
|
20
|
+
|
|
21
|
+
Include all relevant @file references on a SINGLE LINE, space-separated.
|
|
22
|
+
|
|
23
|
+
Why: Every @file gets loaded into context automatically. The next session won't need to search—the files are already there. This eliminates exploration entirely.
|
|
24
|
+
|
|
25
|
+
Include files that will be edited, dependencies being touched, relevant tests, configs, and key reference docs. Be generous—the cost of an extra file is low; missing a critical one means another archaeology dig. Target 8-15 files, up to 20 for complex work.
|
|
26
|
+
|
|
27
|
+
2. CONTEXT AND GOAL
|
|
28
|
+
|
|
29
|
+
After the files, describe what we're working on and provide whatever context helps continue the work. Structure it based on what fits the conversation—could be tasks, findings, a simple paragraph, or detailed steps.
|
|
30
|
+
|
|
31
|
+
Preserve: decisions, constraints, user preferences, technical patterns.
|
|
32
|
+
|
|
33
|
+
Exclude: conversation back-and-forth, dead ends, meta-commentary.
|
|
34
|
+
|
|
35
|
+
The user controls what context matters. If they mentioned something to preserve, include it—trust their judgment about their workflow.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
After generating the handoff message, IMMEDIATELY call handoff_prepare with the full message as a handoff prompt:
|
|
40
|
+
\`handoff_prepare(prompt="...")\``,
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
tool: {
|
|
45
|
+
handoff_prepare: tool({
|
|
46
|
+
description: "Prepare handoff by creating new session with generated prompt as draft",
|
|
47
|
+
args: {
|
|
48
|
+
prompt: tool.schema.string().describe("The generated handoff prompt"),
|
|
49
|
+
},
|
|
50
|
+
async execute(args, context) {
|
|
51
|
+
await ctx.client.tui.clearPrompt()
|
|
52
|
+
await ctx.client.tui.executeCommand({ body: { command: "session_new" } })
|
|
53
|
+
await new Promise(r => setTimeout(r, 200))
|
|
54
|
+
await ctx.client.tui.appendPrompt({ body: { text: args.prompt } })
|
|
55
|
+
|
|
56
|
+
await ctx.client.tui.showToast({
|
|
57
|
+
body: {
|
|
58
|
+
title: "Handoff Ready",
|
|
59
|
+
message: "Review and edit the draft, then send",
|
|
60
|
+
variant: "success",
|
|
61
|
+
duration: 4000,
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return "Handoff prompt created in new session. Review and edit before sending."
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
})
|