opencode-bonfire 1.2.1 → 1.4.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.
@@ -8,14 +8,35 @@ description: End session - update context and commit changes
8
8
 
9
9
  Run `git rev-parse --show-toplevel` to locate the repository root.
10
10
 
11
- ## Step 2: Review Session Work
11
+ ## Step 2: Check for Handoff
12
+
13
+ Check if `<git-root>/.bonfire/handoff/handed-off` exists.
14
+
15
+ **If it exists**: This session was handed off to a new session. Warn the user:
16
+
17
+ > "This session was previously handed off. The new session may have already updated `index.md`.
18
+ > Running `/bonfire-end` here could cause conflicts or overwrite the new session's changes."
19
+
20
+ Ask the user:
21
+ 1. "Proceed anyway" - Continue with /bonfire-end (user takes responsibility)
22
+ 2. "Skip index.md update" - Only commit changes, don't update context
23
+ 3. "Cancel" - Abort /bonfire-end
24
+
25
+ If user chooses to proceed or skip, delete the marker file after completion:
26
+ ```bash
27
+ rm <git-root>/.bonfire/handoff/handed-off
28
+ ```
29
+
30
+ **If marker doesn't exist**: Continue normally.
31
+
32
+ ## Step 3: Review Session Work
12
33
 
13
34
  Review what was accomplished this session by examining:
14
35
  - Recent git commits
15
36
  - Files changed
16
37
  - Conversation context
17
38
 
18
- ## Step 3: Update Session Context
39
+ ## Step 4: Update Session Context
19
40
 
20
41
  Update `<git-root>/.bonfire/index.md`:
21
42
 
@@ -29,7 +50,7 @@ Update `<git-root>/.bonfire/index.md`:
29
50
 
30
51
  3. Update "Current State" to reflect new status
31
52
 
32
- ## Step 4: Update Codemap
53
+ ## Step 5: Update Codemap
33
54
 
34
55
  Update the "Codemap" section in `index.md` with files referenced this session:
35
56
 
@@ -68,7 +89,7 @@ Example:
68
89
  - `.bonfire/specs/codemap-feature.md` - Feature specification
69
90
  ```
70
91
 
71
- ## Step 5: Commit Changes (if tracked)
92
+ ## Step 6: Commit Changes (if tracked)
72
93
 
73
94
  Read `<git-root>/.bonfire/config.json` to check `gitStrategy`.
74
95
 
@@ -91,7 +112,7 @@ Read `<git-root>/.bonfire/config.json` to check `gitStrategy`.
91
112
 
92
113
  If the commit fails due to hooks, help resolve the issue (but never bypass hooks with `--no-verify`).
93
114
 
94
- ## Step 6: Confirm
115
+ ## Step 7: Confirm
95
116
 
96
117
  Summarize:
97
118
  - What was documented
@@ -0,0 +1,168 @@
1
+ ---
2
+ description: Hand off session to new Claude instance when approaching context limits
3
+ ---
4
+
5
+ # Session Handoff
6
+
7
+ Hand off the current session to a fresh Claude instance, preserving work state.
8
+
9
+ ## Step 1: Verify Environment
10
+
11
+ Check if running inside tmux:
12
+
13
+ ```bash
14
+ [ -n "$TMUX" ] && echo "tmux: yes" || echo "tmux: no"
15
+ ```
16
+
17
+ **If not in tmux**: Still generate handoff context, then provide manual instructions:
18
+
19
+ 1. Continue with Steps 2-8 (skip Step 9)
20
+ 2. Tell the user:
21
+
22
+ > "Automatic session spawning requires tmux. I've saved the handoff context.
23
+ >
24
+ > **To continue manually:**
25
+ > 1. Open a new terminal in this directory
26
+ > 2. Run: `opencode --append-system-prompt "$(cat .bonfire/handoff/context.md)"`
27
+ > 3. In the new session, run `/bonfire-start` to load full history
28
+ >
29
+ > The handoff context is saved at `.bonfire/handoff/context.md`"
30
+
31
+ ## Step 2: Find Git Root
32
+
33
+ ```bash
34
+ git rev-parse --show-toplevel
35
+ ```
36
+
37
+ ## Step 3: Verify Bonfire Exists
38
+
39
+ Check if `<git-root>/.bonfire/index.md` exists.
40
+
41
+ **If not**: Abort with message:
42
+ > "No .bonfire/ directory found. Run `/bonfire-start` first to initialize session tracking."
43
+
44
+ ## Step 4: Check for Uncommitted Changes
45
+
46
+ ```bash
47
+ git status --porcelain
48
+ ```
49
+
50
+ **If uncommitted changes exist**: Warn the user:
51
+ > "Note: You have uncommitted changes. The new session will see them. Consider committing or stashing before handoff."
52
+
53
+ Ask if they want to proceed anyway.
54
+
55
+ ## Step 5: Update index.md
56
+
57
+ Read `<git-root>/.bonfire/index.md` and update the current session entry:
58
+
59
+ 1. **Add HANDOFF marker** to session title:
60
+ ```markdown
61
+ ### Session N - DATE (HANDOFF)
62
+ ```
63
+
64
+ 2. **Add "In Progress at Handoff"** section:
65
+ ```markdown
66
+ **In Progress at Handoff**:
67
+ - [What was actively being worked on]
68
+ - [Current state of that work]
69
+ ```
70
+
71
+ 3. **Add handoff metadata**:
72
+ ```markdown
73
+ **Handoff Reason**: Approaching context limit
74
+ **Continued In**: Next session
75
+ ```
76
+
77
+ 4. **Update "Next Session Priorities"** with the immediate work that needs to continue.
78
+
79
+ 5. **Update Codemap** "This Session's Key Files" with files relevant to current work.
80
+
81
+ ## Step 6: Generate Handoff Context
82
+
83
+ Create `<git-root>/.bonfire/handoff/` directory if it doesn't exist.
84
+
85
+ Write `<git-root>/.bonfire/handoff/context.md` with minimal context (~1K tokens max):
86
+
87
+ ```markdown
88
+ # Session Handoff Context
89
+
90
+ **Date**: [CURRENT_DATE]
91
+ **Branch**: [current git branch]
92
+ **Repository**: [repo name from package.json or directory name]
93
+
94
+ ## Current Task
95
+
96
+ [1-2 sentences describing what was actively being worked on when handoff triggered]
97
+
98
+ ## Immediate Next Steps
99
+
100
+ 1. [First priority - most urgent continuation]
101
+ 2. [Second priority]
102
+ 3. [Third priority if applicable]
103
+
104
+ ## Key Context
105
+
106
+ - [Critical decision or constraint affecting the work]
107
+ - [Important file or component being modified]
108
+ - [Any blockers or considerations for new session]
109
+
110
+ ## Uncommitted Changes
111
+
112
+ [List modified files from git status, or "None" if clean]
113
+
114
+ ---
115
+
116
+ **Instructions for new session**: Run `/bonfire-start` to load full session context from `.bonfire/index.md`.
117
+ ```
118
+
119
+ **Size guidance**: Keep this file under 1000 tokens (~150 words, ~750 characters). Focus on what's needed to continue immediately, not history. If the content exceeds this, trim the "Key Context" section to essential items only.
120
+
121
+ ## Step 7: Mark Session as Handed Off
122
+
123
+ Create a marker file to prevent context corruption:
124
+
125
+ ```bash
126
+ echo "$(date -Iseconds)" > <git-root>/.bonfire/handoff/handed-off
127
+ ```
128
+
129
+ This marker tells other commands (like `/bonfire-end`) that this session has been handed off and should not update `index.md` again.
130
+
131
+ ## Step 8: Add handoff/ to .gitignore
132
+
133
+ Read `<git-root>/.bonfire/.gitignore` and add `handoff/` if not present:
134
+
135
+ ```
136
+ handoff/
137
+ ```
138
+
139
+ Handoff context is transient and should not be committed.
140
+
141
+ ## Step 9: Spawn New Session
142
+
143
+ Run the tmux command to spawn a new pane (horizontal split):
144
+
145
+ ```bash
146
+ REPO_ROOT="$(git rev-parse --show-toplevel)"
147
+ CONTEXT="$(cat "$REPO_ROOT/.bonfire/handoff/context.md")"
148
+ tmux split-window -h -c "$REPO_ROOT" \
149
+ "opencode --append-system-prompt '$CONTEXT' 'Continuing from session handoff. Please run /bonfire-start to load the full session context.'"
150
+ ```
151
+
152
+ **Verify spawn succeeded**: Check that the new pane exists. If tmux fails (e.g., terminal too small), warn the user and provide manual instructions from Step 1.
153
+
154
+ This creates a new pane to the right of the current pane, keeping both sessions visible during handoff.
155
+
156
+ ## Step 10: Confirm Handoff
157
+
158
+ Tell the user:
159
+
160
+ > **Handoff complete.**
161
+ >
162
+ > - Session state saved to `.bonfire/index.md`
163
+ > - Handoff context written to `.bonfire/handoff/context.md`
164
+ > - New session spawned in adjacent pane
165
+ >
166
+ > The new session will run `/bonfire-start` to load your full session history.
167
+ >
168
+ > You can close this pane when ready, or keep both visible during transition.
@@ -0,0 +1,229 @@
1
+ ---
2
+ description: Review a GitHub pull request and post inline comments
3
+ ---
4
+
5
+ # Review Pull Request
6
+
7
+ Review a GitHub PR in an isolated worktree, then post inline comments on findings.
8
+
9
+ ## Step 1: Parse Arguments
10
+
11
+ Extract PR number from `$ARGUMENTS`:
12
+ - `333` or `#333` → PR number 333
13
+ - Empty → Show usage and abort
14
+
15
+ **Usage**: `/bonfire-review-pr <pr-number>`
16
+
17
+ If no PR number provided:
18
+ > "Usage: `/bonfire-review-pr <pr-number>`
19
+ >
20
+ > Example: `/bonfire-review-pr 333`"
21
+
22
+ ## Step 2: Verify Environment
23
+
24
+ Check if running inside tmux:
25
+
26
+ ```bash
27
+ [ -n "$TMUX" ] && echo "tmux: yes" || echo "tmux: no"
28
+ ```
29
+
30
+ **If not in tmux**: Provide manual instructions and abort:
31
+
32
+ > "PR review with inline comments requires tmux for worktree isolation.
33
+ >
34
+ > **Manual alternative:**
35
+ > 1. Create worktree: `git worktree add ../pr-<number>-review origin/<branch>`
36
+ > 2. Open new terminal in that directory
37
+ > 3. Run: `opencode 'Review this PR and help me post comments'`
38
+ > 4. Clean up when done: `git worktree remove ../pr-<number>-review`"
39
+
40
+ ## Step 3: Fetch PR Metadata
41
+
42
+ Get PR details:
43
+
44
+ ```bash
45
+ gh pr view <number> --json number,title,headRefName,baseRefName,headRefOid,url,body,files
46
+ ```
47
+
48
+ **If PR not found**: Abort with "PR #<number> not found in this repository."
49
+
50
+ Extract and store:
51
+ - `headRefName` - PR branch name
52
+ - `baseRefName` - Target branch (usually main)
53
+ - `headRefOid` - Commit SHA for inline comments
54
+ - `title` - PR title
55
+ - `url` - PR URL
56
+ - `files` - Changed files list
57
+
58
+ ## Step 4: Find Git Root and Compute Paths
59
+
60
+ ```bash
61
+ git rev-parse --show-toplevel
62
+ ```
63
+
64
+ Compute worktree path: `<git-root>/../<repo-name>-pr-<number>-review`
65
+
66
+ Example: `/Users/vieko/dev/gtm` → `/Users/vieko/dev/gtm-pr-333-review`
67
+
68
+ ## Step 5: Create Worktree
69
+
70
+ Create isolated worktree for PR branch:
71
+
72
+ ```bash
73
+ git fetch origin <headRefName>
74
+ git worktree add <worktree-path> origin/<headRefName>
75
+ ```
76
+
77
+ **On failure** (branch conflict, dirty state, etc.):
78
+
79
+ 1. Check error message
80
+ 2. If worktree already exists: Ask user "Worktree already exists. Remove and recreate?"
81
+ - Yes: `git worktree remove <worktree-path> --force` then retry
82
+ - No: Abort
83
+ 3. If other error: Report error and abort with suggestion to check `git worktree list`
84
+
85
+ ## Step 6: Get PR Diff Summary
86
+
87
+ Get the diff for context:
88
+
89
+ ```bash
90
+ cd <worktree-path> && git diff origin/<baseRefName>...HEAD --stat
91
+ ```
92
+
93
+ Get changed files:
94
+
95
+ ```bash
96
+ cd <worktree-path> && git diff origin/<baseRefName>...HEAD --name-only
97
+ ```
98
+
99
+ ## Step 7: Generate Review Context
100
+
101
+ Create context document for spawned session.
102
+
103
+ Write to `<worktree-path>/.bonfire-pr-review-context.md`:
104
+
105
+ ```markdown
106
+ # PR Review Context
107
+
108
+ **PR**: #<number> - <title>
109
+ **URL**: <url>
110
+ **Branch**: <headRefName> → <baseRefName>
111
+ **Commit**: <headRefOid>
112
+
113
+ ## Changed Files
114
+
115
+ <list of changed files>
116
+
117
+ ## PR Description
118
+
119
+ <body from PR>
120
+
121
+ ---
122
+
123
+ ## Instructions
124
+
125
+ You are reviewing PR #<number> in an isolated worktree.
126
+
127
+ ### Step 1: Run Review
128
+
129
+ Use the task tool to invoke the **work-reviewer** subagent:
130
+
131
+ ```
132
+ Review this pull request for blindspots, gaps, and improvements.
133
+
134
+ **Scope**: PR #<number> - <title>
135
+
136
+ **Files changed**:
137
+ <list of changed files>
138
+
139
+ **PR Description**:
140
+ <body>
141
+
142
+ Return categorized findings with severity, effort, and specific file:line references.
143
+ ```
144
+
145
+ ### Step 2: Present Findings
146
+
147
+ After review completes, present findings grouped by severity.
148
+
149
+ For each finding, note:
150
+ - File and line number (if applicable)
151
+ - Severity (critical/moderate/minor)
152
+ - Description
153
+
154
+ ### Step 3: Batch Comment Selection
155
+
156
+ Ask user: "Which findings should I post as PR comments?"
157
+
158
+ Options:
159
+ 1. List findings by number, let user select (e.g., "1, 3, 5")
160
+ 2. "All" - post all findings
161
+ 3. "None" - skip commenting
162
+
163
+ ### Step 4: Post Inline Comments
164
+
165
+ For each selected finding with a file:line reference, post an inline comment:
166
+
167
+ ```bash
168
+ gh api repos/{owner}/{repo}/pulls/<number>/comments \
169
+ -f body="**Review Finding**
170
+
171
+ <finding description>
172
+
173
+ *Severity: <severity> | Effort: <effort>*" \
174
+ -f commit_id="<headRefOid>" \
175
+ -f path="<file-path>" \
176
+ -f line=<line-number>
177
+ ```
178
+
179
+ For findings without line numbers, post as general PR comment:
180
+
181
+ ```bash
182
+ gh pr comment <number> --body "**Review Finding**
183
+
184
+ <finding description>
185
+
186
+ *Severity: <severity> | Effort: <effort>*"
187
+ ```
188
+
189
+ **Note**: GitHub only allows inline comments on files that are part of the PR diff. If a finding references a file not in the diff (e.g., missing config in turbo.json when turbo.json wasn't changed), post it as a general PR comment instead.
190
+
191
+ ### Step 5: Offer Cleanup
192
+
193
+ After commenting, ask: "Review complete. Remove worktree?"
194
+
195
+ If yes:
196
+ ```bash
197
+ cd <original-git-root>
198
+ git worktree remove <worktree-path>
199
+ ```
200
+
201
+ Report: "Worktree cleaned up. PR review complete."
202
+ ```
203
+
204
+ ## Step 8: Spawn Review Session
205
+
206
+ Spawn a new OpenCode session in the worktree:
207
+
208
+ ```bash
209
+ WORKTREE_PATH="<computed-worktree-path>"
210
+ CONTEXT="$(cat "$WORKTREE_PATH/.bonfire-pr-review-context.md")"
211
+ tmux split-window -h -c "$WORKTREE_PATH" \
212
+ "opencode --append-system-prompt '$CONTEXT' 'Ready to review PR #<number>. Starting work-reviewer subagent...'"
213
+ ```
214
+
215
+ **Verify spawn succeeded**: If tmux fails (terminal too small), warn user and provide manual instructions.
216
+
217
+ ## Step 9: Confirm
218
+
219
+ Tell the user:
220
+
221
+ > **PR review session spawned.**
222
+ >
223
+ > - Worktree created at `<worktree-path>`
224
+ > - Review session opened in adjacent pane
225
+ > - The new session will run work-reviewer and help you post comments
226
+ >
227
+ > When done, the review session will offer to clean up the worktree.
228
+ >
229
+ > You can continue working here - your current branch is unchanged.
@@ -199,6 +199,28 @@ Read `.bonfire/index.md` for current project state, recent work, and priorities.
199
199
  Read `.bonfire/index.md` for current project state, recent work, and priorities.
200
200
  ```
201
201
 
202
+ ## Step 3.5: Check for Handoff Continuation
203
+
204
+ Check if `<git-root>/.bonfire/handoff/context.md` exists.
205
+
206
+ **If it exists**: This session is continuing from a handoff. Acknowledge it:
207
+
208
+ > "Detected handoff context from previous session. Loading continuation state..."
209
+
210
+ Read the handoff context file and note:
211
+ - What task was in progress
212
+ - Immediate next steps
213
+ - Key context
214
+
215
+ Then clean up the handoff files:
216
+ ```bash
217
+ rm -rf <git-root>/.bonfire/handoff/
218
+ ```
219
+
220
+ The handoff context provides quick orientation, but the full history is in `index.md` (read in Step 4).
221
+
222
+ **If handoff context doesn't exist**: Continue normally.
223
+
202
224
  ## Step 4: Read Session Context
203
225
 
204
226
  Read `<git-root>/.bonfire/index.md` and report when ready.
@@ -7,6 +7,9 @@
7
7
  },
8
8
  {
9
9
  "directory": "skill/archive-bonfire-awareness"
10
+ },
11
+ {
12
+ "directory": "skill/handoff-awareness"
10
13
  }
11
14
  ]
12
15
  }
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: Handoff Awareness
3
+ model: anthropic/claude-haiku-4-20250514
4
+ mode: task
5
+ hidden: true
6
+ tools:
7
+ - bash
8
+ - read
9
+ - glob
10
+ permission:
11
+ task:
12
+ "*": deny
13
+ ---
14
+
15
+ # Handoff Awareness
16
+
17
+ This skill detects when a session handoff may be beneficial and suggests the appropriate action.
18
+
19
+ ## When to Trigger
20
+
21
+ Activate when user mentions:
22
+ - Context concerns: "running out of context", "context limit", "context window"
23
+ - Length concerns: "conversation is getting long", "too much context", "large conversation"
24
+ - Fresh start: "should we start fresh?", "new session?", "hand off?", "start over?"
25
+ - Degraded quality: "you're losing context", "you forgot", "we already discussed this"
26
+ - Explicit ask: "can you hand off?", "transfer to new session"
27
+
28
+ ## Instructions
29
+
30
+ 1. **Check for .bonfire/ directory**:
31
+ ```bash
32
+ git rev-parse --show-toplevel
33
+ ```
34
+ Then check if `.bonfire/index.md` exists.
35
+
36
+ 2. **If .bonfire/ exists**, suggest handoff:
37
+
38
+ > "I can hand off this session to a fresh Claude instance while preserving your work.
39
+ >
40
+ > Run `/bonfire-handoff` to:
41
+ > 1. Save current progress to `.bonfire/index.md`
42
+ > 2. Generate minimal handoff context
43
+ > 3. Spawn a new Claude session in an adjacent tmux pane
44
+ >
45
+ > The new session will have access to your full session history via `/bonfire-start`."
46
+
47
+ 3. **If .bonfire/ doesn't exist**, suggest initialization:
48
+
49
+ > "To enable session handoff, first run `/bonfire-start` to initialize session tracking.
50
+ > This creates a `.bonfire/` directory that preserves context across sessions."
51
+
52
+ 4. **If not in tmux**, mention the limitation:
53
+
54
+ > "Note: Automatic session spawning requires tmux. If you're not in tmux, you can still
55
+ > run `/bonfire-handoff` to generate the handoff context, then manually start a new
56
+ > session and paste the context."
57
+
58
+ ## Important
59
+
60
+ - This skill **suggests** handoff, it does NOT trigger it automatically
61
+ - User must explicitly run `/bonfire-handoff` to perform the handoff
62
+ - Don't suggest handoff for short conversations or early in a session
63
+ - If user is mid-task, suggest completing the current atomic unit first
64
+ - Handoff is specifically for context limit concerns, not for switching topics
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-bonfire",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "OpenCode forgets everything between sessions. Bonfire remembers.",
5
5
  "type": "module",
6
6
  "bin": {