opencodekit 0.16.2 → 0.16.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 +7683 -2224
- package/dist/template/.opencode/AGENTS.md +7 -7
- package/dist/template/.opencode/agent/build.md +1 -2
- package/dist/template/.opencode/agent/plan.md +0 -1
- package/dist/template/.opencode/agent/scout.md +52 -6
- package/dist/template/.opencode/command/create.md +2 -2
- package/dist/template/.opencode/command/design.md +1 -1
- package/dist/template/.opencode/command/handoff.md +2 -2
- package/dist/template/.opencode/command/plan.md +19 -19
- package/dist/template/.opencode/command/pr.md +2 -2
- package/dist/template/.opencode/command/research.md +9 -5
- package/dist/template/.opencode/command/resume.md +3 -3
- package/dist/template/.opencode/command/review-codebase.md +2 -2
- package/dist/template/.opencode/command/ship.md +4 -4
- package/dist/template/.opencode/command/start.md +7 -7
- package/dist/template/.opencode/command/status.md +3 -3
- package/dist/template/.opencode/command/ui-review.md +2 -2
- package/dist/template/.opencode/command/verify.md +1 -1
- package/dist/template/.opencode/memory/beads-workflow.md +65 -65
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/plans/1770013678126-witty-planet.md +1 -1
- package/dist/template/.opencode/plans/1770112267595-shiny-rocket.md +258 -0
- package/dist/template/.opencode/plans/swarm-protocol.md +8 -8
- package/dist/template/.opencode/plugin/README.md +2 -2
- package/dist/template/.opencode/plugin/compaction.ts +1 -1
- package/dist/template/.opencode/plugin/swarm-enforcer.ts +6 -6
- package/dist/template/.opencode/skill/beads/SKILL.md +7 -7
- package/dist/template/.opencode/skill/beads-bridge/SKILL.md +3 -3
- package/dist/template/.opencode/skill/session-management/SKILL.md +2 -2
- package/dist/template/.opencode/skill/swarm-coordination/SKILL.md +4 -4
- package/dist/template/.opencode/skill/v1-run/SKILL.md +165 -0
- package/dist/template/.opencode/skill/v1-run/mcp.json +6 -0
- package/dist/template/.opencode/tool/beads-sync.ts +5 -5
- package/dist/template/.opencode/tool/observation.ts +1 -1
- package/package.json +4 -5
|
@@ -11,11 +11,11 @@ Based on Steve Yegge's best practices and official beads documentation.
|
|
|
11
11
|
|
|
12
12
|
| Principle | Why | How |
|
|
13
13
|
| ------------------------ | -------------------------------- | ------------------------------------ |
|
|
14
|
-
| One task per session | Fresh context prevents confusion | Restart after `
|
|
14
|
+
| One task per session | Fresh context prevents confusion | Restart after `br close` |
|
|
15
15
|
| Plan outside beads first | Better planning tools exist | Use `/brainstorm` → `/plan` → import |
|
|
16
|
-
| File lots of issues | Track any work >2 minutes | `
|
|
17
|
-
| "Land the plane" = PUSH | `
|
|
18
|
-
| Keep DB small | Performance degrades >500 issues | `
|
|
16
|
+
| File lots of issues | Track any work >2 minutes | `br create` liberally |
|
|
17
|
+
| "Land the plane" = PUSH | `br sync --flush-only` means git push | Always verify push succeeded |
|
|
18
|
+
| Keep DB small | Performance degrades >500 issues | `br cleanup --days 7` weekly |
|
|
19
19
|
|
|
20
20
|
## Hierarchy Model: Epic → Task → Subtask
|
|
21
21
|
|
|
@@ -50,27 +50,27 @@ Epic (feature-level)
|
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
# Create epic
|
|
53
|
-
|
|
53
|
+
br create "User Authentication" -t epic -p 2
|
|
54
54
|
# Returns: bd-epic
|
|
55
55
|
|
|
56
56
|
# Create tasks with dependencies
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
br create "Setup database schema" -t task -p 2
|
|
58
|
+
br dep add bd-xxx1 bd-epic
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
br create "Implement API endpoints" -t task -p 2
|
|
61
|
+
br dep add bd-xxx2 bd-epic
|
|
62
|
+
br dep add bd-xxx2 bd-xxx1 --type blocks # Sequential
|
|
63
63
|
|
|
64
64
|
# Create subtasks for complex tasks
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
br create "POST /api/users endpoint" -t subtask -p 2
|
|
66
|
+
br dep add bd-xxx2.1 bd-xxx2
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
br create "GET /api/users/:id endpoint" -t subtask -p 2
|
|
69
|
+
br dep add bd-xxx2.2 bd-xxx2
|
|
70
|
+
br dep add bd-xxx2.2 bd-xxx2.1 --type blocks # Sequential subtasks
|
|
71
71
|
|
|
72
72
|
# Verify hierarchy
|
|
73
|
-
|
|
73
|
+
br dep tree bd-epic
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
## Git Worktree Integration
|
|
@@ -122,9 +122,9 @@ main-repo/
|
|
|
122
122
|
| Mode | Configuration | Use When |
|
|
123
123
|
| ----------- | -------------------------------------- | ------------------------ |
|
|
124
124
|
| Default | Daemon auto-disabled in worktrees | Most cases |
|
|
125
|
-
| Sync branch | `
|
|
125
|
+
| Sync branch | `br config set sync-branch beads-sync` | Full daemon in worktrees |
|
|
126
126
|
| External DB | `export BEADS_DIR=~/project/.beads` | Complete separation |
|
|
127
|
-
| Sandbox | `
|
|
127
|
+
| Sandbox | `br --sandbox` or `BEADS_NO_DAEMON=1` | Claude Code, containers |
|
|
128
128
|
|
|
129
129
|
### Worktree Cleanup
|
|
130
130
|
|
|
@@ -161,13 +161,13 @@ Subagents (read-only, stateless workers)
|
|
|
161
161
|
|
|
162
162
|
| Agent | Can Do | Cannot Do |
|
|
163
163
|
| --------- | ------------------------ | ---------------------- |
|
|
164
|
-
| `build` | All beads ops, `
|
|
165
|
-
| `plan` | All beads ops, `
|
|
166
|
-
| `general` | Read, small edits | `
|
|
167
|
-
| `explore` | Read, grep, glob | Edit, write, `
|
|
168
|
-
| `scout` | Fetch, search, Context7 | Edit, write, `
|
|
169
|
-
| `plan` | Read, create artifacts | Edit files, `
|
|
170
|
-
| `review` | Read, analyze, suggest | Edit files, `
|
|
164
|
+
| `build` | All beads ops, `br sync --flush-only` | - |
|
|
165
|
+
| `plan` | All beads ops, `br sync --flush-only` | - |
|
|
166
|
+
| `general` | Read, small edits | `br sync --flush-only`, beads write |
|
|
167
|
+
| `explore` | Read, grep, glob | Edit, write, `br sync --flush-only` |
|
|
168
|
+
| `scout` | Fetch, search, Context7 | Edit, write, `br sync --flush-only` |
|
|
169
|
+
| `plan` | Read, create artifacts | Edit files, `br sync --flush-only` |
|
|
170
|
+
| `review` | Read, analyze, suggest | Edit files, `br sync --flush-only` |
|
|
171
171
|
| `vision` | Analyze images, mockups | All beads operations |
|
|
172
172
|
|
|
173
173
|
### Parallel Research Pattern
|
|
@@ -215,10 +215,10 @@ Task({
|
|
|
215
215
|
|
|
216
216
|
| Task | Frequency | Command | Why |
|
|
217
217
|
| ------------ | -------------- | --------------------- | -------------------------------------- |
|
|
218
|
-
| Health check | Weekly | `
|
|
219
|
-
| Cleanup | Every few days | `
|
|
220
|
-
| Upgrade | Weekly | `
|
|
221
|
-
| Git hooks | Once per repo | `
|
|
218
|
+
| Health check | Weekly | `br doctor --fix` | Repairs orphaned issues, sync problems |
|
|
219
|
+
| Cleanup | Every few days | `br cleanup --days 7` | Keep DB under 200-500 issues |
|
|
220
|
+
| Upgrade | Weekly | `br upgrade` | Latest features and fixes |
|
|
221
|
+
| Git hooks | Once per repo | `br hooks install` | Auto-sync on commit/merge/checkout |
|
|
222
222
|
|
|
223
223
|
## Command Configuration Best Practices
|
|
224
224
|
|
|
@@ -297,32 +297,32 @@ model: gemini-2.5-pro # Override default model
|
|
|
297
297
|
|
|
298
298
|
| Command | Agent | Beads Operations | When to Use |
|
|
299
299
|
| ---------------------------- | ------- | ------------------------------------------------------ | --------------------------- |
|
|
300
|
-
| `/triage` | build | `
|
|
301
|
-
| `/triage --quick` | build | `
|
|
302
|
-
| `/start <id>` | build | `
|
|
300
|
+
| `/triage` | build | `br doctor`, `br list`, `br ready`, `br cleanup` | Start of day, find work |
|
|
301
|
+
| `/triage --quick` | build | `br ready`, `br list --status=in_progress` | Fast check, what's next |
|
|
302
|
+
| `/start <id>` | build | `br update --status in_progress`, `br hooks install` | Claim a task |
|
|
303
303
|
| `/start <id> --worktree` | build | + Create git worktree | Isolated feature work |
|
|
304
304
|
| `/start <id> --research` | build | + Parallel subagent research | Complex task preparation |
|
|
305
|
-
| `/create` | build | `
|
|
306
|
-
| `/new-feature` | plan | `
|
|
305
|
+
| `/create` | build | `br create`, `br sync --flush-only` | Create new tracked task |
|
|
306
|
+
| `/new-feature` | plan | `br create` (epic + subtasks), `br dep add`, `br sync --flush-only` | Complex feature with phases |
|
|
307
307
|
| `/new-feature --worktree` | plan | + Create git worktree for epic | Isolated feature branch |
|
|
308
|
-
| `/issue <num>` | build | `
|
|
309
|
-
| `/plan <id>` | plan | `
|
|
308
|
+
| `/issue <num>` | build | `br create`, `br sync --flush-only`, `gh issue comment` | Import GitHub issue |
|
|
309
|
+
| `/plan <id>` | plan | `br create` (subtasks), `br dep add`, `br sync --flush-only` | Break down task |
|
|
310
310
|
| `/plan <id> --create-beads` | plan | Create child beads after planning | Auto-hierarchy creation |
|
|
311
|
-
| `/implement <id>` | build | `
|
|
311
|
+
| `/implement <id>` | build | `br update --status in_progress`, `br sync --flush-only` | Do the work |
|
|
312
312
|
| `/implement <id> --parallel` | build | + Aggressive subagent research | Complex implementation |
|
|
313
|
-
| `/commit [id]` | build | `
|
|
314
|
-
| `/finish <id>` | build | `
|
|
315
|
-
| `/handoff <id>` | build | `
|
|
316
|
-
| `/resume <id>` | build | `
|
|
317
|
-
| `/pr <id>` | build | `
|
|
318
|
-
| `/fix` | build | `
|
|
319
|
-
| `/status` | explore | `
|
|
313
|
+
| `/commit [id]` | build | `br sync --flush-only` (if bead-id provided) | Commit with traceability |
|
|
314
|
+
| `/finish <id>` | build | `br close`, `br sync --flush-only` | Complete task (asks first) |
|
|
315
|
+
| `/handoff <id>` | build | `br sync --flush-only` | Pause work, save context |
|
|
316
|
+
| `/resume <id>` | build | `br update --status in_progress` | Continue previous work |
|
|
317
|
+
| `/pr <id>` | build | `br-msg`, `br sync --flush-only` | Create pull request |
|
|
318
|
+
| `/fix` | build | `br sync --flush-only` (after user confirms commit) | Fix bugs with tracking |
|
|
319
|
+
| `/status` | explore | `br status`, `br list`, `br-inbox`, `br-release` | Dashboard view |
|
|
320
320
|
|
|
321
321
|
### Research Commands (Read-Only Beads)
|
|
322
322
|
|
|
323
323
|
| Command | Agent | Beads Operations | Notes |
|
|
324
324
|
| ------------------ | ------- | --------------------- | -------------------------- |
|
|
325
|
-
| `/research <id>` | scout | `
|
|
325
|
+
| `/research <id>` | scout | `br show` (read-only) | NO `br sync --flush-only` - subagent |
|
|
326
326
|
| `/brainstorm` | plan | None | Pure planning, no tracking |
|
|
327
327
|
| `/analyze-project` | explore | None | Codebase exploration |
|
|
328
328
|
| `/summarize` | explore | None | Session/code summary |
|
|
@@ -460,7 +460,7 @@ For tasks that can run autonomously until completion. The agent loops until it o
|
|
|
460
460
|
|
|
461
461
|
```bash
|
|
462
462
|
# Create PRD from beads
|
|
463
|
-
|
|
463
|
+
br list --status=open --json > PRD.json
|
|
464
464
|
|
|
465
465
|
# Start Ralph loop
|
|
466
466
|
/ralph-loop "Complete all open tasks" --prd PRD.json
|
|
@@ -470,7 +470,7 @@ ralph-status # Check progress
|
|
|
470
470
|
ralph-stop # Stop gracefully
|
|
471
471
|
|
|
472
472
|
# After completion, sync beads
|
|
473
|
-
|
|
473
|
+
br sync --flush-only
|
|
474
474
|
```
|
|
475
475
|
|
|
476
476
|
**Key constraints:**
|
|
@@ -486,17 +486,17 @@ bd sync
|
|
|
486
486
|
|
|
487
487
|
| Agent | Can Do | Cannot Do |
|
|
488
488
|
| ------- | ------------------------------- | --------- |
|
|
489
|
-
| `build` | All beads operations, `
|
|
490
|
-
| `plan` | All beads operations, `
|
|
489
|
+
| `build` | All beads operations, `br sync --flush-only` | - |
|
|
490
|
+
| `plan` | All beads operations, `br sync --flush-only` | - |
|
|
491
491
|
|
|
492
492
|
### Subagents (Read-Only Beads)
|
|
493
493
|
|
|
494
494
|
| Agent | Can Do | Cannot Do |
|
|
495
495
|
| --------- | -------------------------------------- | --------------------- |
|
|
496
|
-
| `plan` | `
|
|
497
|
-
| `scout` | `
|
|
498
|
-
| `explore` | `
|
|
499
|
-
| `review` | `
|
|
496
|
+
| `plan` | `br show`, `br list`, create artifacts | `br sync --flush-only`, `br close` |
|
|
497
|
+
| `scout` | `br show` (read context) | Any writes |
|
|
498
|
+
| `explore` | `br show`, `br list` | Any writes |
|
|
499
|
+
| `review` | `br show` | Any writes |
|
|
500
500
|
| `vision` | None | All beads operations |
|
|
501
501
|
|
|
502
502
|
## File Locking (Multi-Agent)
|
|
@@ -529,10 +529,10 @@ Closes: bd-a1b2c3
|
|
|
529
529
|
## Session End Checklist
|
|
530
530
|
|
|
531
531
|
1. [ ] All work committed
|
|
532
|
-
2. [ ] `
|
|
532
|
+
2. [ ] `br sync --flush-only` run (pushes to git)
|
|
533
533
|
3. [ ] If incomplete: `/handoff <id>` created
|
|
534
534
|
4. [ ] If complete: `/finish <id>` run
|
|
535
|
-
5. [ ] No stale file locks (`
|
|
535
|
+
5. [ ] No stale file locks (`br-release({ _: true })`)
|
|
536
536
|
6. [ ] Worktrees cleaned up (if used)
|
|
537
537
|
|
|
538
538
|
## Troubleshooting
|
|
@@ -540,25 +540,25 @@ Closes: bd-a1b2c3
|
|
|
540
540
|
| Problem | Solution |
|
|
541
541
|
| ---------------------------- | --------------------------------------------------- |
|
|
542
542
|
| "bd command not found" | `npm install -g beads-village` |
|
|
543
|
-
| Orphaned issues | `
|
|
544
|
-
| DB too large | `
|
|
545
|
-
| Sync conflicts | `
|
|
543
|
+
| Orphaned issues | `br doctor --fix` |
|
|
544
|
+
| DB too large | `br cleanup --days 3` |
|
|
545
|
+
| Sync conflicts | `br sync --force` (careful!) |
|
|
546
546
|
| Stale handoff | Check if rebase needed before `/resume` |
|
|
547
|
-
| Task not in `
|
|
547
|
+
| Task not in `br ready` | Check blockers: `br show <id>` |
|
|
548
548
|
| "Branch already checked out" | `rm -rf .git/beads-worktrees && git worktree prune` |
|
|
549
|
-
| Daemon issues in worktree | `
|
|
550
|
-
| Sandbox environment | `
|
|
549
|
+
| Daemon issues in worktree | `br config set sync-branch beads-sync` |
|
|
550
|
+
| Sandbox environment | `br --sandbox` or `BEADS_NO_DAEMON=1` |
|
|
551
551
|
|
|
552
552
|
## Anti-Patterns
|
|
553
553
|
|
|
554
554
|
| Don't | Why | Do Instead |
|
|
555
555
|
| -------------------------------------- | --------------------- | -------------------------------- |
|
|
556
|
-
| Skip `
|
|
556
|
+
| Skip `br sync --flush-only` at session end | Changes won't persist | Always sync before stopping |
|
|
557
557
|
| Create beads for trivial fixes | DB bloat | Use `/quick-build` |
|
|
558
|
-
| Work on blocked tasks | Wastes time | Use `
|
|
559
|
-
| Subagents running `
|
|
558
|
+
| Work on blocked tasks | Wastes time | Use `br ready` to find unblocked |
|
|
559
|
+
| Subagents running `br sync --flush-only` | Coordination issues | Only leader agents sync |
|
|
560
560
|
| Force through complex with quick-build | Technical debt | Proper `/create` workflow |
|
|
561
|
-
| Ignore `
|
|
561
|
+
| Ignore `br doctor` warnings | Corruption risk | Fix issues promptly |
|
|
562
562
|
| Skip worktree for XL features | Merge conflicts | Use `--worktree` flag |
|
|
563
563
|
| Implement epic directly | Too large | Work on subtasks instead |
|
|
564
564
|
| Wait for subagent results | Blocks progress | Fire parallel, continue working |
|
|
Binary file
|
|
Binary file
|
|
@@ -144,7 +144,7 @@ Implement the `/init` slash command that provides one-command project onboarding
|
|
|
144
144
|
**Implementation Details**:
|
|
145
145
|
|
|
146
146
|
1. If user says yes to beads:
|
|
147
|
-
- Run `
|
|
147
|
+
- Run `br init` if available
|
|
148
148
|
- Or create basic structure manually:
|
|
149
149
|
- `.beads/config.yaml`
|
|
150
150
|
- `.beads/issues.jsonl`
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Plan: Patch-Package Style Feature for Template File Modifications
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Add a patch system that preserves user modifications to template files across upgrades. When users edit built-in skills, commands, agents, or tools, their changes are saved as patches and automatically reapplied after template updates.
|
|
6
|
+
|
|
7
|
+
## Problem
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
User edits .opencode/skill/beads/skill.md (built-in template file)
|
|
11
|
+
User runs `ock upgrade`
|
|
12
|
+
→ Current behavior: Template file overwrites OR user version preserved forever (never gets template updates)
|
|
13
|
+
→ User loses customizations OR misses template improvements
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Solution
|
|
17
|
+
|
|
18
|
+
Save user modifications as unified diff patches. On upgrade:
|
|
19
|
+
|
|
20
|
+
1. Apply new template files
|
|
21
|
+
2. Automatically reapply user patches
|
|
22
|
+
3. Handle conflicts gracefully
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## File Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
.opencode/
|
|
30
|
+
├── patches/
|
|
31
|
+
│ ├── .patches.json # Metadata index (hashes, versions)
|
|
32
|
+
│ ├── skill-beads-skill.md.patch # Unified diff patches
|
|
33
|
+
│ ├── command-ship.md.patch
|
|
34
|
+
│ └── *.patch.rej # Failed patches (conflicts)
|
|
35
|
+
├── .version # Already exists
|
|
36
|
+
└── ... (other template files)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## New Commands
|
|
42
|
+
|
|
43
|
+
### `ock patch save <file>`
|
|
44
|
+
|
|
45
|
+
Save current modifications as a patch.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
$ ock patch save .opencode/skill/beads/skill.md
|
|
49
|
+
|
|
50
|
+
✓ Saved patch: .opencode/patches/skill-beads-skill.md.patch
|
|
51
|
+
Original: a1b2c3d4 → Current: e5f6g7h8
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### `ock patch list`
|
|
55
|
+
|
|
56
|
+
List all saved patches with status.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
$ ock patch list
|
|
60
|
+
|
|
61
|
+
Active Patches (3):
|
|
62
|
+
skill/beads/skill.md ✓ Clean
|
|
63
|
+
command/ship.md ⚠ Stale (template changed)
|
|
64
|
+
agent/build.md ✗ Conflict
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `ock patch apply` (automatic during upgrade)
|
|
68
|
+
|
|
69
|
+
Reapply patches after template update.
|
|
70
|
+
|
|
71
|
+
### `ock patch remove <file>`
|
|
72
|
+
|
|
73
|
+
Remove a saved patch.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## `.patches.json` Schema
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"version": "1.0.0",
|
|
82
|
+
"patches": {
|
|
83
|
+
"skill/beads/skill.md": {
|
|
84
|
+
"originalHash": "sha256:a1b2c3d4...",
|
|
85
|
+
"currentHash": "sha256:e5f6g7h8...",
|
|
86
|
+
"patchFile": "skill-beads-skill.md.patch",
|
|
87
|
+
"createdAt": "2026-02-03T10:00:00Z",
|
|
88
|
+
"templateVersion": "1.2.3"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Upgrade Flow (Modified)
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
1. User runs: ock upgrade
|
|
100
|
+
2. Check version (existing logic)
|
|
101
|
+
3. For PRESERVE_DIRS files that exist in template:
|
|
102
|
+
- Copy template file (overwrite user's version)
|
|
103
|
+
- Check if patch exists in .patches.json
|
|
104
|
+
- If patch exists, apply it
|
|
105
|
+
- If patch fails, save conflict to .patch.rej
|
|
106
|
+
4. Report: "✓ Updated X files, reapplied Y patches, Z conflicts"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Conflict Resolution
|
|
112
|
+
|
|
113
|
+
| Scenario | Action |
|
|
114
|
+
| ------------------------------- | ----------------------------------------- |
|
|
115
|
+
| Template unchanged | Auto-apply patch |
|
|
116
|
+
| Template changed, patch applies | Auto-apply with info message |
|
|
117
|
+
| Template changed, patch fails | Save `.patch.rej`, skip file, notify user |
|
|
118
|
+
|
|
119
|
+
**Conflict UI:**
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
⚠ CONFLICT: skill/beads/skill.md
|
|
123
|
+
|
|
124
|
+
Template changed in v1.3.0 and your patch no longer applies.
|
|
125
|
+
|
|
126
|
+
Options:
|
|
127
|
+
[1] View diff between versions
|
|
128
|
+
[2] Keep new template (discard patch)
|
|
129
|
+
[3] Keep your version (skip update)
|
|
130
|
+
[4] Manually merge (edit patch.rej)
|
|
131
|
+
|
|
132
|
+
Saved: .opencode/patches/skill-beads-skill.md.patch.rej
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Implementation Phases
|
|
138
|
+
|
|
139
|
+
### Phase 1: Core Patch Infrastructure
|
|
140
|
+
|
|
141
|
+
**Files to create:**
|
|
142
|
+
|
|
143
|
+
- `src/commands/patch.ts` - Patch save/list/apply/remove commands
|
|
144
|
+
- `src/utils/patch.ts` - Diff generation, hash calculation, patch application
|
|
145
|
+
|
|
146
|
+
**Files to modify:**
|
|
147
|
+
|
|
148
|
+
- `src/index.ts` - Register `patch` command
|
|
149
|
+
|
|
150
|
+
**Key functions:**
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
// src/utils/patch.ts
|
|
154
|
+
export function generatePatch(templatePath: string, userPath: string): string;
|
|
155
|
+
export function applyPatch(filePath: string, patchContent: string): boolean;
|
|
156
|
+
export function calculateHash(content: string): string;
|
|
157
|
+
export function loadPatchMetadata(opencodeDir: string): PatchMetadata;
|
|
158
|
+
export function savePatchMetadata(opencodeDir: string, metadata: PatchMetadata): void;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Phase 2: Upgrade Integration
|
|
162
|
+
|
|
163
|
+
**Files to modify:**
|
|
164
|
+
|
|
165
|
+
- `src/commands/upgrade.ts` - Integrate patch apply after template copy
|
|
166
|
+
|
|
167
|
+
**Changes:**
|
|
168
|
+
|
|
169
|
+
1. After `copyDirWithPreserve()`, call `applyPatches()`
|
|
170
|
+
2. Modify `PRESERVE_DIRS` logic: still preserve, but ALSO check for patches
|
|
171
|
+
3. Add patch status to upgrade summary
|
|
172
|
+
|
|
173
|
+
### Phase 3: CLI Polish
|
|
174
|
+
|
|
175
|
+
- Interactive conflict resolution
|
|
176
|
+
- `--dry-run` flag for patch apply
|
|
177
|
+
- Pretty diff viewer for conflicts
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Dependencies
|
|
182
|
+
|
|
183
|
+
Use existing Node.js capabilities:
|
|
184
|
+
|
|
185
|
+
- `crypto.createHash('sha256')` - Hash calculation
|
|
186
|
+
- **diff** library (`npm:diff`) - Generate unified diffs
|
|
187
|
+
- **patch-package** or custom parser - Apply patches
|
|
188
|
+
|
|
189
|
+
Alternative: Shell out to `git diff` and `git apply` (simpler, but requires git).
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Critical Files
|
|
194
|
+
|
|
195
|
+
| File | Purpose |
|
|
196
|
+
| ------------------------- | -------------------------- |
|
|
197
|
+
| `src/commands/patch.ts` | New - Patch commands |
|
|
198
|
+
| `src/utils/patch.ts` | New - Patch utilities |
|
|
199
|
+
| `src/commands/upgrade.ts` | Modify - Integrate patches |
|
|
200
|
+
| `src/index.ts` | Modify - Register command |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Verification
|
|
205
|
+
|
|
206
|
+
1. **Unit tests**: `src/commands/patch.test.ts`
|
|
207
|
+
- Test patch generation from diff
|
|
208
|
+
- Test patch application
|
|
209
|
+
- Test conflict detection
|
|
210
|
+
|
|
211
|
+
2. **Integration test**:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Setup
|
|
215
|
+
ock init
|
|
216
|
+
echo "# Custom section" >> .opencode/skill/beads/skill.md
|
|
217
|
+
ock patch save .opencode/skill/beads/skill.md
|
|
218
|
+
|
|
219
|
+
# Simulate upgrade
|
|
220
|
+
ock upgrade --force
|
|
221
|
+
|
|
222
|
+
# Verify
|
|
223
|
+
grep "Custom section" .opencode/skill/beads/skill.md # Should exist
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
3. **Conflict test**:
|
|
227
|
+
- Modify template file in dist/template
|
|
228
|
+
- Run upgrade
|
|
229
|
+
- Verify conflict detection and `.patch.rej` creation
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Complexity Estimate
|
|
234
|
+
|
|
235
|
+
| Component | Effort | Notes |
|
|
236
|
+
| ------------------- | ------ | ------------------------------ |
|
|
237
|
+
| Hash/diff utilities | 2h | Use `diff` library |
|
|
238
|
+
| Patch save command | 2h | Generate + store patch |
|
|
239
|
+
| Patch list command | 1h | Read metadata, show status |
|
|
240
|
+
| Patch apply logic | 3h | Apply patches, handle failures |
|
|
241
|
+
| Upgrade integration | 2h | Hook into existing flow |
|
|
242
|
+
| Conflict UI | 2h | Interactive resolution |
|
|
243
|
+
| Tests | 2h | Unit + integration |
|
|
244
|
+
|
|
245
|
+
**Total: ~14 hours (2 days)**
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Open Questions
|
|
250
|
+
|
|
251
|
+
1. **Git dependency?** Should we require git for `git diff`/`git apply` or use pure JS?
|
|
252
|
+
- Recommendation: Pure JS (`diff` library) for portability
|
|
253
|
+
|
|
254
|
+
2. **Auto-save patches?** Should we auto-detect modifications on upgrade?
|
|
255
|
+
- Recommendation: Manual `ock patch save` for now (explicit is better)
|
|
256
|
+
|
|
257
|
+
3. **Nested directories?** How to handle `skill/beads/skill.md` path → filename conversion?
|
|
258
|
+
- Recommendation: Replace `/` with `-` → `skill-beads-skill.md.patch`
|
|
@@ -15,11 +15,11 @@ Use `.beads/` as the single source of truth for task state + dependencies, while
|
|
|
15
15
|
|
|
16
16
|
Canonical state lives in `.beads/issues.jsonl` (tasks) and `.beads/artifacts/<id>/` (task artifacts).
|
|
17
17
|
|
|
18
|
-
- Create tasks: `
|
|
19
|
-
- See unblocked work: `
|
|
20
|
-
- Inspect context: `
|
|
21
|
-
- Claim work: `
|
|
22
|
-
- Close work: `
|
|
18
|
+
- Create tasks: `br create "Title" -p <1-3>`
|
|
19
|
+
- See unblocked work: `br ready`
|
|
20
|
+
- Inspect context: `br show <id>`
|
|
21
|
+
- Claim work: `br update <id> --status=in_progress`
|
|
22
|
+
- Close work: `br close <id> --reason="..."` then `br sync --flush-only`
|
|
23
23
|
|
|
24
24
|
## Task Artifact Contract
|
|
25
25
|
|
|
@@ -115,9 +115,9 @@ Immediately stop execution and return to planning if:
|
|
|
115
115
|
|
|
116
116
|
## Lead Checklist
|
|
117
117
|
|
|
118
|
-
1. `
|
|
118
|
+
1. `br ready` -> pick task -> `br show <id>`
|
|
119
119
|
2. Ensure `.beads/artifacts/<id>/spec.md` has acceptance checks
|
|
120
|
-
3. `
|
|
120
|
+
3. `br update <id> --status=in_progress`
|
|
121
121
|
4. Delegate with the packet format
|
|
122
122
|
5. Require worker report + evidence
|
|
123
|
-
6. `
|
|
123
|
+
6. `br close <id> --reason="..."` + `br sync --flush-only`
|
|
@@ -85,10 +85,10 @@ Session 3: read_session("previous") → Tests (90k) → close
|
|
|
85
85
|
**Swarm protocol guardrails (Beads-as-board)** - nudges agents to follow the Beads-first workflow.
|
|
86
86
|
|
|
87
87
|
- Treats `.beads/` as the single source of truth for the swarm task board
|
|
88
|
-
- If user expresses implementation intent and no task is `in_progress`, injects a nudge to use `
|
|
88
|
+
- If user expresses implementation intent and no task is `in_progress`, injects a nudge to use `br ready/show/update`
|
|
89
89
|
- If there are `in_progress` tasks but `.beads/artifacts/<id>/spec.md` is missing, nudges to create it before implementation
|
|
90
90
|
- On `file.edited`, warns if code is being changed without a claimed task or with missing `spec.md`
|
|
91
|
-
- On `session.idle`, reminds to `
|
|
91
|
+
- On `session.idle`, reminds to `br close` + `br sync` when work is done
|
|
92
92
|
|
|
93
93
|
### notification.ts
|
|
94
94
|
|
|
@@ -60,7 +60,7 @@ export const CompactionPlugin: Plugin = async ({ $, directory }) => {
|
|
|
60
60
|
let beadsContext = "";
|
|
61
61
|
try {
|
|
62
62
|
const result =
|
|
63
|
-
await $`cd ${directory} &&
|
|
63
|
+
await $`cd ${directory} && br list --status in_progress --json 2>/dev/null`.quiet();
|
|
64
64
|
if (result.stdout) {
|
|
65
65
|
const inProgress = JSON.parse(result.stdout.toString());
|
|
66
66
|
if (inProgress.length > 0) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Ensure `spec.md` exists for in-progress tasks
|
|
8
8
|
* - Close/sync in-progress work at session end
|
|
9
9
|
*
|
|
10
|
-
* This plugin is intentionally non-destructive: it never runs `
|
|
10
|
+
* This plugin is intentionally non-destructive: it never runs `br update/close/sync`.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import fsPromises from "node:fs/promises";
|
|
@@ -132,9 +132,9 @@ function buildNudge(params: {
|
|
|
132
132
|
|
|
133
133
|
Pick a task before code changes:
|
|
134
134
|
|
|
135
|
-
1) \`
|
|
136
|
-
2) \`
|
|
137
|
-
3) \`
|
|
135
|
+
1) \`br ready\` → find unblocked work
|
|
136
|
+
2) \`br show <id>\` → inspect task
|
|
137
|
+
3) \`br update <id> --status in_progress\` → claim it
|
|
138
138
|
|
|
139
139
|
For parallel work, use the Task tool to spawn subagents.
|
|
140
140
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
@@ -253,7 +253,7 @@ export const SwarmEnforcer: Plugin = async ({ client, directory }) => {
|
|
|
253
253
|
if (cachedInProgress.length === 0) {
|
|
254
254
|
await showToast(
|
|
255
255
|
"Beads: No task claimed",
|
|
256
|
-
"Run
|
|
256
|
+
"Run br ready/show/update to claim a task before edits.",
|
|
257
257
|
"warning",
|
|
258
258
|
);
|
|
259
259
|
return;
|
|
@@ -282,7 +282,7 @@ export const SwarmEnforcer: Plugin = async ({ client, directory }) => {
|
|
|
282
282
|
.join(", ");
|
|
283
283
|
await showToast(
|
|
284
284
|
"Beads: Work still in progress",
|
|
285
|
-
`In-progress: ${list}. Close with
|
|
285
|
+
`In-progress: ${list}. Close with br close + br sync when done.`,
|
|
286
286
|
"info",
|
|
287
287
|
);
|
|
288
288
|
},
|
|
@@ -553,25 +553,25 @@ beads_sync({ operation: "pull" });
|
|
|
553
553
|
|
|
554
554
|
| Task | Frequency | Command | Why |
|
|
555
555
|
| ------------ | -------------- | --------------------- | ---------------------------------------------- |
|
|
556
|
-
| Health check | Weekly | `
|
|
557
|
-
| Cleanup | Every few days | `
|
|
558
|
-
| Upgrade | Weekly | `
|
|
559
|
-
| Git hooks | Once per repo | `
|
|
556
|
+
| Health check | Weekly | `br doctor` | Repairs database issues, detects orphaned work |
|
|
557
|
+
| Cleanup | Every few days | `br cleanup --days 7` | Keep DB under 200-500 issues for performance |
|
|
558
|
+
| Upgrade | Weekly | `br upgrade` | Get latest features and fixes |
|
|
559
|
+
| Git hooks | Once per repo | `br hooks install` | Auto-sync on commit/merge/checkout |
|
|
560
560
|
|
|
561
561
|
### Key Principles
|
|
562
562
|
|
|
563
563
|
1. **Plan outside Beads first** - Use planning tools, then import tasks to beads
|
|
564
564
|
2. **One task per session, then restart** - Fresh context prevents confusion
|
|
565
565
|
3. **File lots of issues** - Any work >2 minutes should be tracked
|
|
566
|
-
4. **Use short prefixes** - `
|
|
567
|
-
5. **"Land the plane" = PUSH** - `
|
|
566
|
+
4. **Use short prefixes** - `br-`, `vc-`, `wy-` etc.
|
|
567
|
+
5. **"Land the plane" = PUSH** - `br sync --flush-only` means git push, not "ready when you are"
|
|
568
568
|
6. **Include issue ID in commits** - `git commit -m "Fix bug (bd-abc)"`
|
|
569
569
|
|
|
570
570
|
### Database Health
|
|
571
571
|
|
|
572
572
|
```bash
|
|
573
573
|
# Check database size
|
|
574
|
-
|
|
574
|
+
br list --status=all --json | wc -l
|
|
575
575
|
|
|
576
576
|
# Target: under 200-500 issues
|
|
577
577
|
# If over, run cleanup more aggressively:
|