@bybrawe/opencode-loop 0.5.24 → 0.5.25

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/README.md CHANGED
@@ -1,1041 +1,363 @@
1
1
  # OpenCode Loop
2
2
 
3
- **Claude Code style auto-continue for OpenCode.**
3
+ **Claude Code-style auto-continue, scheduled OpenCode work, and background loops.**
4
4
 
5
- OpenCode Loop adds a practical `/loop` command and `opencode-loopd` daemon to OpenCode so an agent can keep working after each idle turn instead of waiting for you to type “continue” again.
5
+ OpenCode Loop adds `/loop`, scheduled prompt/command/shell jobs, compact scheduling, safe long-running continuation helpers, and the `opencode-loopd` background daemon.
6
6
 
7
- It is useful for long coding sessions, `progress.md` workflows, TODO automation, test-fix loops, periodic `/compact`, checkpoints, safe autonomous development, and background OpenCode continuation jobs.
7
+ > **Current release: `0.5.25`.** Loop also contains an older experimental `/loop-goal` mode, but for strong persistent Goal contracts and host-verified completion, use the separate **OpenCode Goals** plugin described below.
8
8
 
9
- Repository: **ByBrawe/opencode-loop**
10
- NPM package name: **@bybrawe/opencode-loop**
9
+ ## Install or update
11
10
 
12
- ### Scheduler heartbeat note
13
-
14
- v0.5.11 includes a referenced heartbeat scheduler. This is important in OpenCode TUI because local command hooks are event-driven: a normal `/loop-status` command can wake the plugin, but a timer-only loop should not depend on a user typing another command. The heartbeat periodically checks active loop jobs, clears stale completed runs, and starts due work only when the session appears idle.
15
-
16
-
17
- ## Current status
18
-
19
- **v0.5.24 uses OpenCode's native compaction lifecycle, serializes compact-before-run work, fixes current headless summarize payloads, and validates stale `busy` recovery against a genuinely completed assistant tail.** **v0.5.23 adds immediate, token-safe recovery when a scheduler prompt/shell dispatch is rejected, without automatically replaying the prompt.** **v0.5.22 adds forward-compatible OpenCode command handling plus Bun and peer-range compatibility CI.** **v0.5.21 targets current OpenCode 1.18.x compatibility and safer releases.** Server-plugin control commands keep their locked-down acknowledgement prompt instead of creating an empty command message, `/compact` prefers the current `session.compact` TUI command, and CI now covers Ubuntu and Windows before publishing. **v0.5.20 fixes Windows TUI state writes.** Session job state is written through the OS temp directory with rename plus copy/unlink fallback and short retries, so antivirus locks and OpenCode snapshots no longer drop `/loop` jobs with `EPERM` on rename. **v0.5.19** hardens Goal Mode, package updates, and the background daemon: package installs are pinned to the installed version so OpenCode cannot keep loading an older cached release, scheduler-created goal messages no longer self-interrupt on delayed updates, finite daemon failures return nonzero, model/agent selection is supported, Windows scheduled tasks use a short launcher that stays below the `/TR` limit, and asynchronous release verification is reliable under load.
20
-
21
- The known update-related symptoms from older builds are fixed:
22
-
23
- - `/loop` looks queued but the job stays at `runs=0`
24
- - a loop job is replaced but does not fire after OpenCode becomes idle
25
- - repeated `/loop` commands create confusing queued turns
26
- - prompt, shell, or toast calls silently fail after OpenCode SDK changes
27
- - `/compact` accidentally being treated as a normal agent prompt
28
- - intermittent `Tool execution aborted` behavior caused by triggering a new turn too early
29
- - experimental `/loop-goal` support for goal-driven work that continues until complete, blocked, paused, cleared, or paused by no-progress/user-interrupt guards
30
- - `--no-now` interval jobs not waking until another OpenCode event happens
31
- - `/loop-ask`, `/loop-command`, and `/loop-shell` being configured but not reliably firing on their own
32
-
33
- The TUI loop is still intentionally session-bound: it runs while OpenCode is open and the current session emits status/idle events. For long-running background work after closing the terminal or OpenCode, use `opencode-loopd`.
34
-
35
- ## v0.5.19 quick behavior guide
36
-
37
- OpenCode Loop has two triggers now:
38
-
39
- 1. **Idle/status events** from OpenCode. These are used when OpenCode finishes a turn.
40
- 2. **A real due timer** inside the plugin. This wakes delayed jobs even when no new OpenCode event happens.
41
-
42
- All TUI jobs are still idle-safe. If the timer expires while OpenCode is busy, or while a tool/background child session is still executing, the job does not interrupt the active turn. It waits and retries until that work finishes and the parent session becomes idle.
43
-
44
- Simple examples:
45
-
46
- ```text
47
- /loop 0s continue the project
48
- ```
49
-
50
- Run every time OpenCode becomes idle.
51
-
52
- ```text
53
- /loop 1m --no-now continue the project
54
- ```
55
-
56
- Wait 1 minute first, then run when OpenCode is idle.
57
-
58
- ```text
59
- /loop-command 200m /compact
60
- ```
61
-
62
- Run OpenCode compact about every 200 minutes, but only when OpenCode is idle.
63
-
64
- ```text
65
- /loop-ask 1h did you run tests, tsc --noEmit, and build? If not, run them and fix errors.
66
- ```
67
-
68
- Ask a recurring quality-control question every hour.
69
-
70
- ```text
71
- /loop-shell 10m npm test
72
- ```
73
-
74
- Run a shell command every 10 minutes when idle.
75
-
76
- ```text
77
- /loop-goal --max-turns 5 --check "npm run build" --complete-when-checks-pass make the project build cleanly
78
- ```
79
-
80
- Experimental persistent goal mode: keep working until the goal is complete, blocked, paused, cleared, or a safety limit is reached.
81
-
82
- > Note: OpenCode custom command markdown still creates an assistant turn for slash commands. v0.5.17 routes that acknowledgement through the installed `opencode-loop-local` agent, which denies tools and subagents. The real scheduled iteration explicitly restores the normal coding agent/model, so a status or control command cannot launch background exploration or leave later loop work tool-disabled.
83
-
84
- ## Why this exists
85
-
86
- Claude Code users often rely on a loop-like workflow where the agent finishes one step, then immediately continues with the next step.
87
-
88
- OpenCode is powerful, but long-running autonomous workflows usually need extra control around:
89
-
90
- - auto-continue after idle
91
- - compact / summarize scheduling
92
- - `progress.md` and TODO-driven development
93
- - test verification after each turn
94
- - patch checkpoints
95
- - maximum runtime limits
96
- - failure limits
97
- - background daemon execution
98
- - Windows Task Scheduler support
99
- - safety prompts and destructive command guards
100
-
101
- OpenCode Loop is designed for developers searching for:
102
-
103
- - OpenCode loop
104
- - OpenCode Claude Code loop
105
- - OpenCode auto continue
106
- - OpenCode continue automatically
107
- - OpenCode `/loop` command
108
- - OpenCode compact scheduler
109
- - OpenCode Ralph loop alternative
110
- - Claude Code style loop for OpenCode
111
- - autonomous coding loop for OpenCode
112
- - progress.md TODO automation for OpenCode
113
- - OpenCode background daemon
114
- - OpenCode loop daemon
115
- - OpenCode Windows Task Scheduler loop
116
-
117
- ## Features
118
-
119
- > The TUI `/loop` command is session-bound. It runs while OpenCode is open and the session receives idle/status events. If the terminal closes, the machine sleeps, the process is killed, or the provider connection is lost for a long time, the TUI loop cannot continue in the background. For long-running loops, use `opencode-loopd` daemon mode.
120
-
121
- - **Claude Code style auto-continue** with `/loop 0s ...`.
122
- - **TUI loop mode** with `/loop`, active while OpenCode is open.
123
- - **Background daemon mode** with `opencode-loopd` for long-running loops outside the OpenCode TUI.
124
- - **Windows Task Scheduler helper** with `opencode-loopd install-task`.
125
- - **One-shot scheduled runs** for periodic continuation jobs.
126
- - **Interval loops** for prompts, slash commands, and shell commands.
127
- - **Prompt-file support** with `--prompt-file loop-prompt.md` for long reusable instructions.
128
- - **Prompt-file daemon support** with `opencode-loopd --prompt-file loop-prompt.md`.
129
- - **Include extra context files** with `--include-file`.
130
- - **progress.md workflow** with `--progress-file progress.md`.
131
- - **Large TODO support** with `--batch`.
132
- - **Compact scheduling** with `/loop 200m /compact` or `--compact-every`.
133
- - **Verification loops** with `--verify "npm test"`.
134
- - **Preflight checks** with `--preflight "npm install"`.
135
- - **Post-run commands** with `--postrun`.
136
- - **Failure control** with `--max-failures` and `--pause-on-verify-fail`.
137
- - **Runtime control** with `--max-runtime 6h`.
138
- - **Run limit support** with `--max-runs`.
139
- - **Wait-before-first-run support** with `--no-now` for TUI loops and `--sleep-first` for daemon mode.
140
- - **Checkpoints** with `--checkpoint-only` or `--git-checkpoint`.
141
- - **Safe mode** with `--safe` and prompt-level destructive command warnings.
142
- - **Branch setup** with `--branch ai-loop`.
143
- - **Stop controls** with `--stop-file STOP_LOOP`, `--until`, `/loop-stop`, `/loop-pause`, `/loop-resume`, and `/loop-remove`.
144
- - **Watch mode** with `--watch progress.md`.
145
- - **Experimental Goal Mode** with `/loop-goal`, goal status, goal tools, acceptance criteria, and verification checks.
146
- - **Diagnostics** with `/loop-doctor`.
147
- - **Starter progress file** with `/loop-init`.
148
- - **State export** with `/loop-export`.
149
-
150
- ## Installation
151
-
152
- ### Recommended: install from npm
153
-
154
- Use the npm installer from any shell: Windows PowerShell, Windows CMD, macOS, or Linux.
11
+ Recommended installation from any shell on Windows, macOS, or Linux:
155
12
 
156
13
  ```bash
157
14
  npx -y @bybrawe/opencode-loop@latest
158
15
  ```
159
16
 
160
- The installer copies the slash command files and the tool-denied local command agent into your OpenCode config directory. If `@bybrawe/opencode-loop` is already present in the OpenCode `plugin` array, that package entry remains authoritative, is pinned to the installer's exact version to bypass stale OpenCode package caches, and duplicate local plugin copies are removed. Otherwise it installs `opencode-loop.ts` locally and ensures the config directory has the `@opencode-ai/plugin` dependency required by `tool()`.
161
-
162
- Windows target paths:
163
-
164
- ```text
165
- %USERPROFILE%\.config\opencode\plugins\opencode-loop.ts
166
- %USERPROFILE%\.config\opencode\commands\loop*.md
167
- %USERPROFILE%\.config\opencode\agents\opencode-loop-local.md
168
- ```
169
-
170
- macOS / Linux target paths:
171
-
172
- ```text
173
- ~/.config/opencode/plugins/opencode-loop.ts
174
- ~/.config/opencode/commands/loop*.md
175
- ~/.config/opencode/agents/opencode-loop-local.md
176
- ```
177
-
178
- Then fully restart OpenCode and run:
179
-
180
- ```text
181
- /loop-help
182
- /loop-doctor
183
- ```
184
-
185
- The npm package also installs the `opencode-loopd` CLI for background loops:
186
-
187
- ```bash
188
- opencode-loopd --help
189
- ```
190
-
191
- ### Why `npx` is the recommended npm install
17
+ The installer:
192
18
 
193
- OpenCode can load npm plugins from the `plugin` array in `opencode.json`, but OpenCode slash commands are discovered from command definitions such as markdown files in a `commands/` directory or command entries in config.
19
+ - installs/updates the OpenCode Loop plugin;
20
+ - installs the `/loop-*` slash-command definitions;
21
+ - installs the tool-denied `opencode-loop-local` command agent;
22
+ - keeps an existing npm plugin entry pinned to the installer’s exact version to avoid stale OpenCode package-cache resolution;
23
+ - removes duplicate old local Loop plugin copies when the package entry is authoritative.
194
24
 
195
- The `npx` installer installs both parts:
196
-
197
- - the OpenCode plugin file
198
- - the `/loop-*` command markdown files
199
- - the tool-denied `opencode-loop-local` acknowledgement agent
200
-
201
- The installer automatically avoids loading both the package entry and a local plugin copy. It can therefore be rerun safely after switching installation styles.
202
-
203
- ### Optional: OpenCode config package entry
204
-
205
- If you want OpenCode to load the npm plugin package directly, add the scoped package name to your OpenCode config:
206
-
207
- ```json
208
- {
209
- "$schema": "https://opencode.ai/config.json",
210
- "plugin": ["@bybrawe/opencode-loop"]
211
- }
212
- ```
213
-
214
- Use the scoped package name exactly as shown.
215
-
216
- `opencode-loop` without `@bybrawe/` is a different npm package name.
217
-
218
- If `/loop` does not appear after using only the config method, run the installer once:
219
-
220
- ```bash
221
- npx -y @bybrawe/opencode-loop
222
- ```
223
-
224
- If you later remove `@bybrawe/opencode-loop` from the `plugin` array, rerun the installer so it restores the local plugin copy.
225
-
226
- ### Install from GitHub
227
-
228
- Use this if you want to install from source instead of npm.
229
-
230
- Windows PowerShell:
231
-
232
- ```powershell
233
- git clone https://github.com/ByBrawe/opencode-loop.git
234
- cd opencode-loop
235
- powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1
236
- ```
237
-
238
- macOS / Linux / Git Bash:
239
-
240
- ```bash
241
- git clone https://github.com/ByBrawe/opencode-loop.git
242
- cd opencode-loop
243
- chmod +x ./scripts/install.sh
244
- ./scripts/install.sh
245
- ```
246
-
247
- Then restart OpenCode and run:
25
+ Then **fully restart OpenCode** and verify:
248
26
 
249
27
  ```text
250
28
  /loop-help
251
29
  /loop-doctor
252
30
  ```
253
31
 
254
- ### Manual global install
255
-
256
- Windows PowerShell:
257
-
258
- ```powershell
259
- mkdir "$env:USERPROFILE\.config\opencode\plugins" -Force
260
- mkdir "$env:USERPROFILE\.config\opencode\commands" -Force
261
- mkdir "$env:USERPROFILE\.config\opencode\agents" -Force
262
- copy .\src\index.js "$env:USERPROFILE\.config\opencode\plugins\opencode-loop.ts"
263
- copy .\commands\*.md "$env:USERPROFILE\.config\opencode\commands\"
264
- copy .\agents\*.md "$env:USERPROFILE\.config\opencode\agents\"
265
- ```
266
-
267
- macOS / Linux:
32
+ Run the same command again whenever you want to update:
268
33
 
269
34
  ```bash
270
- mkdir -p ~/.config/opencode/plugins ~/.config/opencode/commands ~/.config/opencode/agents
271
- cp ./src/index.js ~/.config/opencode/plugins/opencode-loop.ts
272
- cp ./commands/*.md ~/.config/opencode/commands/
273
- cp ./agents/*.md ~/.config/opencode/agents/
35
+ npx -y @bybrawe/opencode-loop@latest
274
36
  ```
275
37
 
276
- ### Project-local install
277
-
278
- Use this when you want the plugin to be available only inside one repository.
38
+ ### Uninstall
279
39
 
280
40
  ```bash
281
- mkdir -p .opencode/plugins .opencode/commands .opencode/agents
282
- cp ./src/index.js .opencode/plugins/opencode-loop.ts
283
- cp ./commands/*.md .opencode/commands/
284
- cp ./agents/*.md .opencode/agents/
41
+ npx -y @bybrawe/opencode-loop@latest --uninstall
285
42
  ```
286
43
 
287
- On Windows PowerShell:
44
+ Uninstall removes known OpenCode Loop package registrations, local plugin files, `/loop-*` command markdown files, and the Loop local command agent while preserving unrelated OpenCode configuration.
288
45
 
289
- ```powershell
290
- mkdir .opencode\plugins -Force
291
- mkdir .opencode\commands -Force
292
- mkdir .opencode\agents -Force
293
- copy .\src\index.js .opencode\plugins\opencode-loop.ts
294
- copy .\commands\*.md .opencode\commands\
295
- copy .\agents\*.md .opencode\agents\
296
- ```
297
-
298
- ### Verify installation
299
-
300
- After restarting OpenCode, run:
46
+ Project Loop state is intentionally preserved under:
301
47
 
302
48
  ```text
303
- /loop-help
304
- /loop-doctor
49
+ .opencode/opencode-loop/
305
50
  ```
306
51
 
307
- If the commands do not appear:
308
-
309
- 1. Make sure OpenCode was fully restarted.
310
- 2. Check that `opencode-loop.ts` exists in the OpenCode plugin directory.
311
- 3. Check that `loop.md`, `loop-help.md`, and the other command files exist in the OpenCode commands directory.
312
- 4. Check that `opencode-loop-local.md` exists in the OpenCode agents directory.
313
- 5. Run `npx -y @bybrawe/opencode-loop` again to reinstall the command and agent files.
52
+ Delete that directory yourself only when you intentionally want to erase saved Loop jobs, logs, checkpoints, or related local state. Restart OpenCode after uninstalling.
314
53
 
315
54
  ## Quick start
316
55
 
317
- ### The 6 examples most people need
318
-
319
- Auto-continue every time OpenCode finishes a turn:
56
+ Auto-continue whenever OpenCode becomes idle:
320
57
 
321
58
  ```text
322
59
  /loop 0s continue from progress.md and implement the next unfinished TODO
323
60
  ```
324
61
 
325
- Run now, then continue every 1 minute when OpenCode is idle:
326
-
327
- ```text
328
- /loop 1m continue the project
329
- ```
330
-
331
- Wait 1 minute before the first run, then continue every 1 minute when idle:
332
-
333
- ```text
334
- /loop 1m --no-now continue the project
335
- ```
336
-
337
- Run OpenCode compact every 200 minutes, but only when OpenCode is idle:
338
-
339
- ```text
340
- /loop-command 200m /compact
341
- ```
342
-
343
- Ask a recurring check question every hour:
344
-
345
- ```text
346
- /loop-ask 1h did you run tests, tsc --noEmit, and build? If not, run them and fix any error.
347
- ```
348
-
349
- Run a real shell command every 10 minutes when idle:
350
-
351
- ```text
352
- /loop-shell 10m npm test
353
- ```
354
-
355
- Experimental goal mode: keep working until the objective is actually done, blocked, paused, or cleared:
356
-
357
- ```text
358
- /loop-goal finish the feature, run tsc --noEmit and build, fix every error, and stop only when everything passes
359
- ```
360
-
361
- ### What “when idle” means
362
-
363
- OpenCode Loop is idle-safe. It does **not** intentionally start a new agent turn while OpenCode is already busy. Active tool calls and running child sessions also count as busy, even if OpenCode emits a premature idle/status signal for the parent during long-running background work.
364
-
365
- Example:
62
+ Run a prompt every 5 minutes when idle:
366
63
 
367
64
  ```text
368
65
  /loop 5m continue the project
369
66
  ```
370
67
 
371
- If 5 minutes pass while OpenCode is still working, the job becomes due but waits. As soon as OpenCode becomes idle, the loop sends the prompt. This avoids queued turns, aborted tools, and overlapping responses.
372
-
373
- ### Prompt loops vs command loops
374
-
375
- Use a prompt loop when you want to ask or instruct the agent:
68
+ Wait before the first run:
376
69
 
377
70
  ```text
378
- /loop 1h check if tests, tsc --noEmit, and build pass. If not, fix them.
71
+ /loop 5m --no-now continue the project
379
72
  ```
380
73
 
381
- Use a command loop when the action starts with `/` and should be executed as an OpenCode command:
74
+ Schedule an OpenCode command such as compaction:
382
75
 
383
76
  ```text
384
77
  /loop-command 200m /compact
385
78
  ```
386
79
 
387
- Do not use this for compacting:
388
-
389
- ```text
390
- /loop 200m /compact
391
- ```
392
-
393
- That can look like a chat prompt in older versions or unclear setups. Prefer `/loop-command 200m /compact` or the shortcut below:
394
-
395
- ```text
396
- /loop-compact 200m
397
- ```
398
-
399
- ### Experimental Goal Mode
400
-
401
- Goal Mode is experimental. Use it when you do **not** want a timer such as "every 5 minutes". Use it when you want OpenCode to keep pursuing a result until it is complete or blocked.
402
-
403
- Basic goal:
404
-
405
- ```text
406
- /loop-goal fix the TypeScript build errors. Run tsc --noEmit and npm run build. Stop only when both pass.
407
- ```
408
-
409
- What happens:
410
-
411
- 1. The goal is saved as the active experimental goal.
412
- 2. OpenCode starts working immediately by default.
413
- 3. When OpenCode becomes idle, the plugin checks whether the goal is still active.
414
- 4. If the goal is not complete or blocked, the plugin injects the next Goal Mode continuation prompt.
415
- 5. The agent is instructed to call a local goal tool when it has real progress, completion evidence, or a blocked reason.
416
-
417
- Goal Mode is idle-safe. If OpenCode is busy, it waits. It does not intentionally start another turn on top of a running turn.
418
-
419
- Completion guards:
420
-
421
- - The agent tool cannot mark a goal complete with empty or generic evidence. Evidence should mention commands, files, checks, results, or code inspection details.
422
- - If a goal has `--check` commands, agent-tool completion requires the latest configured checks to pass by default.
423
- - `/loop-goal-done` is still a manual user override when you want to mark the goal complete yourself.
424
- - Goal Mode pauses when a real user message arrives, so a new instruction can take control before the next automatic continuation.
425
- - Goal Mode pauses after 3 turns without recorded meaningful progress by default. Change this with `--max-no-progress <n>`, or disable it with `--max-no-progress 0`.
426
- - Each Goal Mode prompt includes the resolved project directory and requires workspace-relative file paths.
427
- - A running goal turn gets 3 minutes by default before stale-run recovery can finalize it. This avoids overlapping or prematurely closing slower model/tool turns.
428
-
429
- Simple status and control commands:
430
-
431
- ```text
432
- /loop-goal-status
433
- /loop-goal-pause
434
- /loop-goal-resume
435
- /loop-goal-clear
436
- ```
437
-
438
- You can also use subcommands through `/loop-goal`:
439
-
440
- ```text
441
- /loop-goal status
442
- /loop-goal pause
443
- /loop-goal resume
444
- /loop-goal clear
445
- ```
446
-
447
- Manual completion or blocked state:
448
-
449
- ```text
450
- /loop-goal-done shipped the feature and all checks pass
451
- /loop-goal-blocked missing API key for the staging provider
452
- ```
453
-
454
- Goal with acceptance criteria:
455
-
456
- ```text
457
- /loop-goal --acceptance "tsc --noEmit passes" --acceptance "npm run build passes" --acceptance "no new TODO hacks" fix all build errors
458
- ```
459
-
460
- Goal with automatic check commands after each assistant turn:
461
-
462
- ```text
463
- /loop-goal --check "npm run typecheck" --check "npm run build" fix every TypeScript and build error
464
- ```
465
-
466
- Goal that automatically stops when all configured checks pass:
467
-
468
- ```text
469
- /loop-goal --check "npm run typecheck" --check "npm run build" --complete-when-checks-pass make the project build cleanly
470
- ```
471
-
472
- Goal that gives the agent more attempts before the no-progress guard pauses it:
473
-
474
- ```text
475
- /loop-goal --max-no-progress 6 --check "npm test" fix the failing tests and keep evidence in the goal report
476
- ```
477
-
478
- Goal with a safety/runtime limit:
479
-
480
- ```text
481
- /loop-goal --max-turns 20 --max-runtime 3h --check "npm test" fix the failing tests without destructive commands
482
- ```
483
-
484
- Goal Mode writes a report under:
80
+ Run a real shell command on a schedule:
485
81
 
486
82
  ```text
487
- .opencode/opencode-loop/goals/
83
+ /loop-shell 10m npm test
488
84
  ```
489
85
 
490
- You can choose a report file:
86
+ Ask a recurring quality-control question:
491
87
 
492
88
  ```text
493
- /loop-goal --evidence-file goal-report.md --check "npm test" make tests pass and document the result
89
+ /loop-ask 1h did you run tests, typecheck, and build? If not, run them and fix errors.
494
90
  ```
495
91
 
496
- Goal Mode is inspired by persistent-objective workflows such as Codex `/goal`, but this package implements it at the OpenCode plugin layer. It is intentionally marked experimental because model tool-calling behavior and OpenCode plugin APIs may change.
92
+ ## What OpenCode Loop is for
497
93
 
498
- ### Safer development loop
94
+ Use Loop when the important question is **“what should run again, and when?”**
499
95
 
500
- ```text
501
- /loop 0s --name dev --ask-never --safe --no-overlap --batch 5 --compact-every 200m --checkpoint-only --progress-file progress.md Treat progress.md as the main project state file. Continue with the next unfinished TODO, implement it, mark completed items with [x], add useful follow-up TODOs when you discover them, run tests/lint/build when available, and keep going while work remains.
502
- ```
96
+ Typical uses:
503
97
 
504
- ### Test-fix loop
505
-
506
- ```text
507
- /loop 0s --name testfix --ask-never --safe --verify "npm test" Continue from progress.md. If tests fail, analyze the failure, fix it, and run the tests again.
508
- ```
98
+ - Claude Code-style auto-continue after idle;
99
+ - recurring coding prompts;
100
+ - progress.md / TODO workflows;
101
+ - scheduled `/compact` or other OpenCode commands;
102
+ - recurring tests/lint/build shell jobs;
103
+ - retry/fix loops with verification;
104
+ - patch checkpoints;
105
+ - maximum run/runtime/failure limits;
106
+ - prompt-file workflows;
107
+ - background work through `opencode-loopd`;
108
+ - Windows Task Scheduler integration.
509
109
 
510
- ## Background daemon
110
+ Loop is idle-safe: if a job becomes due while the session is busy, active tools or child work are still running, the job waits instead of intentionally stacking another turn on top of the current one.
511
111
 
512
- The `/loop` command is session-bound. It works while OpenCode is open and the current session emits idle/status events.
112
+ ## For stronger persistent Goals, use OpenCode Goals
513
113
 
514
- If you close OpenCode, restart the terminal, lose connection, or your PC sleeps, the TUI loop will not keep running.
114
+ OpenCode Loop still includes the older **experimental** `/loop-goal` workflow. It is useful for compatibility and lightweight outcome-driven automation, but it is not the strongest Goal implementation in this project family.
515
115
 
516
- For long-running loops, use the daemon:
116
+ For durable Goal Contracts, host-owned evidence, semantic verification, native Todo coordination, revision isolation, false-completion protection, restart recovery, Goal audit, budgets, and ordered Goals, install **OpenCode Goals**:
517
117
 
518
118
  ```bash
519
- opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
119
+ npx -y @bybrawe/opencode-goal@latest
520
120
  ```
521
121
 
522
- Run immediately after each OpenCode turn:
122
+ Then use:
523
123
 
524
- ```bash
525
- opencode-loopd --project . --every 0s --prompt "continue from progress.md and implement the next unfinished TODO"
124
+ ```text
125
+ /goal <objective>
126
+ /goal status
127
+ /goal contract
128
+ /goal audit
526
129
  ```
527
130
 
528
- Limit runs:
529
-
530
- ```bash
531
- opencode-loopd --project . --every 5m --max-runs 20 --prompt-file loop-prompt.md
532
- ```
131
+ ### Can Loop and Goals be installed together?
533
132
 
534
- Select the OpenCode model and agent explicitly:
133
+ Yes. `@bybrawe/opencode-loop` and `@bybrawe/opencode-goal` use different package names, commands, and project-state directories, so they can coexist in one OpenCode installation.
535
134
 
536
- ```bash
537
- opencode-loopd --project . --every 0s --max-runs 1 --model opencode/big-pickle --agent build --prompt-file loop-prompt.md
538
- ```
135
+ Recommended split:
539
136
 
540
- When `--max-runs` is finite, the daemon exits with the final OpenCode run's nonzero status so scripts and CI can detect failures.
137
+ - use **`/goal`** for persistent, strongly verified outcome completion;
138
+ - use **`/loop`**, `/loop-command`, `/loop-shell`, and `opencode-loopd` for scheduling/repetition/background infrastructure.
541
139
 
542
- Wait before the first run:
140
+ Do **not** run Loop’s `/loop-goal` and OpenCode Goals `/goal` against the same work in the same session. Both can autonomously continue on idle boundaries and can compete to start turns.
543
141
 
544
- ```bash
545
- opencode-loopd --project . --every 10m --sleep-first --prompt-file loop-prompt.md
546
- ```
142
+ Likewise, avoid leaving a prompt-producing `/loop ...` job continuously injecting agent turns into a session while an OpenCode Goal is actively continuing. Use separate sessions or pause/remove that prompt loop until the Goal is done. Scheduled shell/command jobs should also be chosen carefully so they do not race files or verification.
547
143
 
548
- Use an inline prompt:
144
+ Install both when needed:
549
145
 
550
146
  ```bash
551
- opencode-loopd --project . --every 0s --prompt "continue from progress.md and implement the next unfinished TODO"
552
- ```
553
-
554
- Example `loop-prompt.md`:
555
-
556
- ```md
557
- Continue from progress.md and implement the next unfinished TODO.
558
-
559
- Rules:
560
- - Do not ask questions.
561
- - Make reasonable assumptions.
562
- - Mark completed TODO items with [x].
563
- - Add useful follow-up TODOs when needed.
564
- - Run tests/lint/build when available.
565
- - Do not run destructive commands such as git reset, git clean, rm -rf, force push, deploy, or production migrations.
566
- - Keep going while work remains.
567
- ```
568
-
569
- ## Windows Task Scheduler
570
-
571
- You can create a Windows scheduled task that runs a one-shot daemon job every N minutes.
572
-
573
- Install a scheduled task:
574
-
575
- ```powershell
576
- opencode-loopd install-task --project "C:\path\to\project" --every 10m --prompt-file loop-prompt.md --name OpenCodeLoop
577
- ```
578
-
579
- You can also pass `--model <provider/model>` and `--agent <name>`. The installer stores long task options in a task-specific JSON file and registers only a short launcher with Task Scheduler, avoiding Windows' 261-character `/TR` limit. `uninstall-task` removes that launcher and JSON config after the task is deleted.
580
-
581
- Remove it:
582
-
583
- ```powershell
584
- opencode-loopd uninstall-task --name OpenCodeLoop
585
- ```
586
-
587
- Check existing tasks:
588
-
589
- ```powershell
590
- Get-ScheduledTask | Where-Object { $_.TaskName -like "*OpenCode*" }
591
- ```
592
-
593
- For active development, a visible terminal running daemon mode is usually easier to monitor:
594
-
595
- ```powershell
596
- opencode-loopd --project "C:\path\to\project" --every 0s --prompt-file loop-prompt.md
597
- ```
598
-
599
- ## Multiple loops and duplicate protection
600
-
601
- By default, `/loop ...` uses an upsert/replace behavior. Running `/loop 5m ...` again replaces the existing default loop instead of creating duplicate jobs.
602
-
603
- Use `--name` to manage separate named loops, or `--multi` when you intentionally want multiple loops with the same shape:
604
-
605
- ```text
606
- /loop 5m --name dev continue from progress.md
607
- /loop 200m --name compact /compact
608
- /loop 10m --multi !npm test
147
+ npx -y @bybrawe/opencode-loop@latest
148
+ npx -y @bybrawe/opencode-goal@latest
609
149
  ```
610
150
 
611
151
  ## Core commands
612
152
 
613
153
  | Command | Purpose |
614
154
  |---|---|
615
- | `/loop <interval> <prompt>` | Add an idle/interval prompt loop |
616
- | `/loop-command <interval> <slash-command>` | Schedule an OpenCode slash command such as `/compact` |
155
+ | `/loop <interval> <prompt>` | Add/update an idle/interval prompt loop |
156
+ | `/loop-command <interval> <slash-command>` | Schedule OpenCode slash commands |
617
157
  | `/loop-cmd <interval> <slash-command>` | Alias for `/loop-command` |
618
- | `/loop-ask <interval> <prompt/question>` | Schedule a recurring question/check prompt; first run waits for the interval by default |
619
- | `/loop-prompt <interval> <prompt>` | Force prompt mode, even when you want explicit prompt-loop naming |
620
- | `/loop-shell <interval> <shell-command>` | Schedule a shell command loop |
621
- | `/loop-goal <objective>` | Start experimental persistent Goal Mode |
622
- | `/loop-goal-status` | Show experimental goal state |
623
- | `/loop-goal-pause` | Pause the active experimental goal |
624
- | `/loop-goal-resume` | Resume the active experimental goal |
625
- | `/loop-goal-clear` | Clear experimental goals |
626
- | `/loop-goal-done <summary>` | Manually mark the active goal complete |
627
- | `/loop-goal-blocked <reason>` | Manually mark the active goal blocked |
628
- | `/loop-help` | Show usage help inside OpenCode |
629
- | `/loop-status` | Show active loop jobs |
630
- | `/loop-logs` | Show recent loop log entries |
631
- | `/loop-now [id/name/number/all]` | Run loop job(s) immediately |
632
- | `/loop-pause [id/name/number/all]` | Pause loop job(s) |
633
- | `/loop-resume [id/name/number/all]` | Resume loop job(s) |
634
- | `/loop-remove [id/name/number/all]` | Remove loop job(s) |
635
- | `/loop-stop [id/name/number/all]` | Alias for remove/stop |
636
- | `/loop-clear` | Remove all loop jobs for the current session |
637
- | `/loop-doctor` | Diagnose plugin/session state |
638
- | `/loop-init [file]` | Create a starter `progress.md` or another progress file |
639
- | `/loop-export` | Export current loop state as JSON |
640
-
641
- ## Preset commands
158
+ | `/loop-ask <interval> <question>` | Schedule recurring quality/check prompts |
159
+ | `/loop-shell <interval> <command>` | Schedule a real shell command |
160
+ | `/loop-status` | Show active jobs |
161
+ | `/loop-now [id/name/all]` | Run selected jobs immediately |
162
+ | `/loop-pause [id/name/all]` | Pause jobs |
163
+ | `/loop-resume [id/name/all]` | Resume jobs |
164
+ | `/loop-remove [id/name/all]` | Remove jobs |
165
+ | `/loop-clear` | Remove all current-session Loop jobs |
166
+ | `/loop-doctor` | Diagnose Loop/OpenCode state |
167
+ | `/loop-init` | Create a starter `progress.md` |
168
+ | `/loop-export` | Export Loop state as JSON |
169
+ | `/loop-goal <objective>` | Start the older experimental Loop Goal Mode |
642
170
 
643
- | Command | Purpose |
644
- |---|---|
645
- | `/loop-dev 0s` | General autonomous OpenCode development loop |
646
- | `/loop-progress 0s` | Follow `progress.md` and TODOs |
647
- | `/loop-safe-dev 0s` | Safe dev loop with ask-never, batch 5, and patch checkpoints |
648
- | `/loop-testfix 0s "npm test"` | Run, fix, and re-run tests |
649
- | `/loop-compact 200m` | Compact loop shortcut |
171
+ ## Intervals and job types
650
172
 
651
- ## Intervals
173
+ Examples:
652
174
 
653
175
  ```text
654
- 0s run whenever OpenCode becomes idle, like Claude Code auto-continue
176
+ 0s run whenever OpenCode becomes idle
655
177
  5m run every 5 minutes when idle
656
178
  200m run every 200 minutes when idle
657
179
  1h run every hour when idle
658
180
  ```
659
181
 
660
- The plugin is **idle-driven**. It checks jobs when OpenCode becomes idle, so it avoids intentionally starting a second agent turn on top of an active one.
661
-
662
- If the interval expires while OpenCode is busy, the loop becomes due and waits. It runs on the next idle event.
663
-
664
- ## Loop types
665
-
666
- OpenCode Loop has separate types for prompts, OpenCode slash commands, and shell commands. This matters because `/compact` should be executed as an OpenCode command, not sent to the agent as text.
667
-
668
- | Type | Use | Example | First run |
669
- |---|---|---|---|
670
- | Prompt loop | Ask or instruct the agent repeatedly | `/loop 1h check whether tests, tsc --noEmit, and build pass` | Now by default |
671
- | Scheduled question | Ask/check on a timer | `/loop-ask 1h did you run tests and build?` | After the interval by default |
672
- | Slash-command loop | Run OpenCode commands like `/compact` | `/loop-command 200m /compact` | After the interval by default |
673
- | Shell loop | Run real terminal commands | `/loop-shell 10m npm test` | After the interval by default |
674
- | Experimental goal | Keep pursuing an outcome until complete/blocked | `/loop-goal make build pass` | Now by default |
675
-
676
- You can still force the type on `/loop`:
677
-
678
- ```text
679
- /loop 200m --command /compact
680
- /loop 10m --shell npm test
681
- /loop 1h --prompt did you run tests, tsc --noEmit, and build?
682
- ```
683
-
684
- ## Actions
685
-
686
- ### Prompt action
687
-
688
- ```text
689
- /loop 0s continue from progress.md. Work on the next unfinished TODO. Mark completed items with [x].
690
- ```
691
-
692
- ### Prompt file action
182
+ OpenCode Loop separates prompt, slash-command, and shell work because they should not be executed the same way.
693
183
 
694
- Use this when the prompt is too long for a single command line:
695
-
696
- ```text
697
- /loop 0s --prompt-file loop-prompt.md
698
- ```
699
-
700
- Example `loop-prompt.md`:
701
-
702
- ```md
703
- Continue from progress.md.
704
- Do not ask questions unless truly blocked.
705
- Make reasonable assumptions and keep working.
706
- Complete TODOs in order and mark finished items with [x].
707
- Add useful follow-up TODOs when you discover them.
708
- Run tests, lint, or build when available.
709
- Do not run destructive commands, force pushes, production deploys, or database resets.
710
- ```
711
-
712
- ### Include extra context files
713
-
714
- ```text
715
- /loop 0s --include-file ARCHITECTURE.md --include-file progress.md continue with the next implementation task
716
- ```
717
-
718
- ### Slash command action
719
-
720
- Use `/loop-command` when the action should be executed as an OpenCode command instead of sent to the agent as text.
721
-
722
- ```text
723
- /loop-command 200m /compact
724
- /loop-command 15m /review current changes
725
- ```
726
-
727
- `/compact` and `/summarize` are treated specially and routed to OpenCode's TUI compact action. Custom command templates such as `/review` are routed through OpenCode's session command API. If OpenCode is busy when the interval expires, the command waits and runs when the session becomes idle.
728
-
729
- Equivalent forced type on `/loop`:
730
-
731
- ```text
732
- /loop 200m --command /compact
733
- ```
184
+ | Type | Example |
185
+ |---|---|
186
+ | Prompt | `/loop 0s continue from progress.md` |
187
+ | Scheduled question | `/loop-ask 1h did you run tests?` |
188
+ | OpenCode command | `/loop-command 200m /compact` |
189
+ | Shell | `/loop-shell 10m npm test` |
734
190
 
735
- For most users, the clearer form is preferred:
191
+ Do not use a normal prompt loop when you mean to run `/compact`. Prefer:
736
192
 
737
193
  ```text
738
194
  /loop-command 200m /compact
739
195
  ```
740
196
 
741
- ### Shell action
742
-
743
- Use `/loop-shell` for real terminal commands.
744
-
745
- ```text
746
- /loop-shell 10m npm test
747
- /loop-shell 30m pnpm lint
748
- ```
749
-
750
- Equivalent forced type on `/loop`:
751
-
752
- ```text
753
- /loop 10m --shell npm test
754
- ```
755
-
756
- Shell actions starting with `!` or `$` run through the OpenCode shell tool.
757
-
758
- ## Flags
197
+ ## Useful flags
759
198
 
760
- ### `--name <name>`
761
-
762
- Name a loop so you can manage it later.
199
+ ### Naming and lifecycle
763
200
 
764
201
  ```text
765
- /loop 0s --name dev continue from progress.md
202
+ /loop 0s --name dev continue the project
766
203
  /loop-pause dev
767
204
  /loop-resume dev
768
205
  /loop-stop dev
769
206
  ```
770
207
 
771
- ### `--max-runs <n>`
772
-
773
- Stop after N runs.
774
-
775
- ```text
776
- /loop 5m --max-runs 20 continue from progress.md
777
- ```
778
-
779
- ### `--max-runtime <duration>`
780
-
781
- Stop after total runtime from loop creation.
782
-
783
- ```text
784
- /loop 0s --max-runtime 6h continue from progress.md
785
- ```
786
-
787
- ### `--timeout <duration>`
788
-
789
- Best-effort abort after a single run timeout.
790
-
791
- ```text
792
- /loop 0s --timeout 30m continue from progress.md
793
- ```
794
-
795
- ### `--max-failures <n>`
796
-
797
- Pause after repeated verify/postrun failures.
798
-
799
- ```text
800
- /loop 0s --verify "npm test" --max-failures 3 continue from progress.md and fix test failures
801
- ```
802
-
803
- ### `--pause-on-verify-fail`
804
-
805
- Pause immediately after the first verify failure.
806
-
807
- ```text
808
- /loop 0s --verify "npm test" --pause-on-verify-fail continue from progress.md
809
- ```
810
-
811
- ### `--until <text>`
812
-
813
- Stop when a marker appears in common state files such as `progress.md`, `TODO.md`, or `.opencode/opencode-loop/until.txt`.
814
-
815
- ```text
816
- /loop 5m --until ALL_DONE continue from progress.md
817
- ```
818
-
819
- ### `--stop-file <file>`
820
-
821
- Stop when a file appears. This is a simple manual kill switch.
822
-
823
- ```text
824
- /loop 0s --stop-file STOP_LOOP continue from progress.md
825
- ```
826
-
827
- Create `STOP_LOOP` in the project root to stop that job.
828
-
829
- ### `--no-overlap` and `--allow-overlap`
830
-
831
- `--no-overlap` is the default. It prevents a new run from being triggered while a previous run is still considered active.
832
-
833
- ```text
834
- /loop 5m --no-overlap continue from progress.md
835
- ```
836
-
837
- ### `--compact-every <n|duration>`
838
-
839
- Compact before a run every N runs or every duration.
840
-
841
- ```text
842
- /loop 0s --compact-every 20 continue from progress.md
843
- /loop 0s --compact-every 200m continue from progress.md
844
- ```
845
-
846
- ### `--test "<command>"`
847
-
848
- Adds a test instruction to prompt actions.
849
-
850
- ```text
851
- /loop 0s --test "npm test" continue from progress.md
852
- ```
853
-
854
- ### `--verify "<command>"`
855
-
856
- Runs a real shell verification command after each assistant turn. If it fails, the next loop prompt includes the failure summary so the agent can fix it.
857
-
858
- ```text
859
- /loop 0s --verify "npm test" continue from progress.md and fix any failing tests
860
- ```
861
-
862
- ### `--preflight "<command>"`
863
-
864
- Runs a real shell command before each loop turn. If it fails, the loop pauses.
208
+ ### Limits
865
209
 
866
210
  ```text
867
- /loop 0s --preflight "npm install" continue from progress.md
211
+ --max-runs <n>
212
+ --max-runtime <duration>
213
+ --max-failures <n>
214
+ --timeout <duration>
868
215
  ```
869
216
 
870
- ### `--postrun "<command>"`
871
-
872
- Runs a shell command after each assistant turn and verification.
217
+ ### Verification and safety
873
218
 
874
219
  ```text
875
- /loop 0s --postrun "git status --short" continue from progress.md
220
+ --verify "npm test"
221
+ --preflight "npm install"
222
+ --postrun "git status --short"
223
+ --pause-on-verify-fail
224
+ --safe
225
+ --ask-never
226
+ --no-overlap
876
227
  ```
877
228
 
878
- ### `--notify "<command>"`
879
-
880
- Runs a shell command when a loop stops or pauses due to a control condition. The command can use `{job}` and `{reason}` placeholders.
229
+ ### Context and TODO workflows
881
230
 
882
231
  ```text
883
- /loop 0s --max-runtime 6h --notify "echo {job} stopped because {reason}" continue from progress.md
232
+ --progress-file progress.md
233
+ --prompt-file loop-prompt.md
234
+ --include-file ARCHITECTURE.md
235
+ --batch 5
236
+ --compact-every 20
237
+ --watch progress.md
884
238
  ```
885
239
 
886
- ### `--checkpoint-only`
887
-
888
- Save `git status` and `git diff --binary` snapshots under:
240
+ ### Checkpoints
889
241
 
890
242
  ```text
891
- .opencode/opencode-loop/checkpoints/<session>/
243
+ --checkpoint-only
244
+ --git-checkpoint
892
245
  ```
893
246
 
894
- ### `--git-checkpoint`
247
+ `--git-checkpoint` may stage and commit work. Use it only when that behavior is intentional.
895
248
 
896
- Save a patch checkpoint and attempt to commit all changes after each completed run.
249
+ ## Recommended development loop
897
250
 
898
251
  ```text
899
- /loop 0s --git-checkpoint continue from progress.md
252
+ /loop 0s --name dev --ask-never --safe --no-overlap --batch 5 --compact-every 200m --checkpoint-only --progress-file progress.md Treat progress.md as the project state. Continue with the next unfinished TODO, implement it, mark completed items, add useful follow-up TODOs, run tests/lint/build when available, and keep going while work remains.
900
253
  ```
901
254
 
902
- Use carefully. It runs `git add -A` and `git commit` when changes exist.
903
-
904
- ### `--branch <name>`
905
-
906
- Switch to a branch before the first run, or create it if it does not exist.
255
+ ## Test-fix loop
907
256
 
908
257
  ```text
909
- /loop 0s --branch ai-loop continue from progress.md
910
- ```
911
-
912
- ### `--safe`
913
-
914
- Adds safety instructions to prompt actions and blocks obviously destructive shell actions.
915
-
916
- ```text
917
- /loop 0s --safe continue from progress.md
258
+ /loop 0s --name testfix --ask-never --safe --verify "npm test" --max-failures 3 Continue from progress.md. If tests fail, analyze the failure, fix it, and run the tests again.
918
259
  ```
919
260
 
920
- Safe mode warns against or blocks patterns such as `git reset`, `git clean`, `rm -rf`, `git push`, `terraform destroy`, destructive delete commands, and production deploys.
261
+ ## Background daemon
921
262
 
922
- ### `--batch <n>`
263
+ The normal `/loop` plugin is session-bound. If OpenCode closes, that TUI/session loop cannot keep running in the background.
923
264
 
924
- Tell the agent to process at most N TODO items per run.
265
+ For long-running background jobs use:
925
266
 
926
- ```text
927
- /loop 0s --batch 5 continue from progress.md
267
+ ```bash
268
+ opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
928
269
  ```
929
270
 
930
- ### `--quiet`
271
+ Run immediately on each daemon iteration:
931
272
 
932
- Tell the agent to keep replies short.
933
-
934
- ```text
935
- /loop 0s --quiet continue from progress.md
273
+ ```bash
274
+ opencode-loopd --project . --every 0s --prompt "continue from progress.md and implement the next unfinished TODO"
936
275
  ```
937
276
 
938
- ### `--ask-never`
939
-
940
- Tell the agent not to ask questions and to make reasonable assumptions.
277
+ Select a model and agent:
941
278
 
942
- ```text
943
- /loop 0s --ask-never continue from progress.md
279
+ ```bash
280
+ opencode-loopd --project . --every 0s --max-runs 1 --model provider/model --agent build --prompt-file loop-prompt.md
944
281
  ```
945
282
 
946
- ### `--progress-file <file>`
283
+ Limit total runs:
947
284
 
948
- Tell the agent which state file to treat as the main progress/TODO source.
949
-
950
- ```text
951
- /loop 0s --progress-file progress.md continue from the progress file
285
+ ```bash
286
+ opencode-loopd --project . --every 5m --max-runs 20 --prompt-file loop-prompt.md
952
287
  ```
953
288
 
954
- ### `--watch <file>`
289
+ ## Windows Task Scheduler
955
290
 
956
- Run when watched file metadata changes. This is still checked on idle events.
291
+ Install a scheduled daemon task:
957
292
 
958
- ```text
959
- /loop --watch progress.md continue after progress.md changes
960
- /loop 5m --watch progress.md continue when progress.md changes or the interval is due
293
+ ```powershell
294
+ opencode-loopd install-task --project "C:\path\to\project" --every 10m --prompt-file loop-prompt.md --name OpenCodeLoop
961
295
  ```
962
296
 
963
- You can pass multiple `--watch` flags.
964
-
965
- ### `--dry-run`
966
-
967
- Parse and preview a loop without saving it.
297
+ Remove it:
968
298
 
969
- ```text
970
- /loop 0s --dry-run --ask-never continue from progress.md
299
+ ```powershell
300
+ opencode-loopd uninstall-task --name OpenCodeLoop
971
301
  ```
972
302
 
973
- ### `--now` and `--no-now`
303
+ ## Experimental Loop Goal Mode
974
304
 
975
- By default `/loop` prompt jobs are due immediately. Use `--no-now` to wait for the first interval.
305
+ Loop’s original Goal Mode remains available for existing users:
976
306
 
977
307
  ```text
978
- /loop 1h --no-now did you run tests, tsc --noEmit, and build?
308
+ /loop-goal --check "npm test" --complete-when-checks-pass fix the failing tests
979
309
  ```
980
310
 
981
- Command-style shortcuts such as `/loop-command`, `/loop-ask`, and `/loop-shell` wait for the first interval by default. Use `--now` if you want them to run immediately too.
311
+ Controls:
982
312
 
983
313
  ```text
984
- /loop-command 200m /compact
985
- /loop-command 200m --now /compact
986
- ```
987
-
988
- ## Recommended recipes
989
-
990
- ### Claude Code style auto-continue loop
991
-
992
- ```text
993
- /loop 0s --name dev --ask-never --safe --no-overlap --batch 5 --compact-every 200m --checkpoint-only --progress-file progress.md Treat progress.md as the main project state file. Continue with the next unfinished TODO, implement it, mark completed items with [x], add useful follow-up TODOs when you discover them, run tests/lint/build when available, and keep going while work remains.
314
+ /loop-goal-status
315
+ /loop-goal-pause
316
+ /loop-goal-resume
317
+ /loop-goal-clear
318
+ /loop-goal-done <summary>
319
+ /loop-goal-blocked <reason>
994
320
  ```
995
321
 
996
- ### Long-running autonomous development loop
322
+ It supports acceptance criteria, check commands, evidence text, no-progress guards, turn/runtime limits, and reports under:
997
323
 
998
324
  ```text
999
- /loop 0s --name dev --ask-never --safe --no-overlap --compact-every 20 --timeout 45m --max-runtime 6h --max-failures 3 --stop-file STOP_LOOP --checkpoint-only Continue from progress.md. Do not ask questions. Make reasonable assumptions. Complete TODOs in order, mark finished items with [x], add useful new ideas to progress.md, and keep going while work remains.
325
+ .opencode/opencode-loop/goals/
1000
326
  ```
1001
327
 
1002
- ### Daemon-based long-running development loop
328
+ For new work where completion integrity matters, prefer the dedicated **OpenCode Goals** package instead:
1003
329
 
1004
330
  ```bash
1005
- opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
331
+ npx -y @bybrawe/opencode-goal@latest
1006
332
  ```
1007
333
 
1008
- ### Test-fix loop
334
+ ## State and checkpoints
335
+
336
+ Loop runtime state:
1009
337
 
1010
338
  ```text
1011
- /loop 0s --name testfix --ask-never --safe --verify "npm test" --max-failures 3 Continue from progress.md. If tests fail, analyze the failure, fix it, and run the tests again.
339
+ .opencode/opencode-loop/
1012
340
  ```
1013
341
 
1014
- ### Compact loop
342
+ Patch checkpoints:
1015
343
 
1016
344
  ```text
1017
- /loop-command 200m /compact
345
+ .opencode/opencode-loop/checkpoints/
1018
346
  ```
1019
347
 
1020
- This compacts every 200 minutes when OpenCode is idle. It does not interrupt an active agent turn.
1021
-
1022
- ### Scheduled quality-check question
348
+ Recent plugin events:
1023
349
 
1024
350
  ```text
1025
- /loop-ask 1h did you run tests, tsc --noEmit, and build? If not, run them now and fix errors.
351
+ .opencode/opencode-loop/loop.log
1026
352
  ```
1027
353
 
1028
- This asks the agent every hour when idle. If the hour passes while the agent is working, the question waits and is sent after the current turn finishes.
1029
-
1030
- ### Prompt file loop
354
+ Add `.opencode/opencode-loop/` to `.gitignore` when you do not want runtime noise committed.
1031
355
 
1032
- ```text
1033
- /loop 0s --name dev --prompt-file loop-prompt.md --checkpoint-only --max-runtime 6h
1034
- ```
356
+ ## Suggested OpenCode permissions
1035
357
 
1036
- ## Suggested OpenCode permission config
358
+ For unattended loops, avoid granting every shell command permanently. Allow routine read/edit/test operations and keep destructive operations on ask/deny.
1037
359
 
1038
- Full `permission: "allow"` is convenient but risky. For safer long loops, keep destructive commands as ask/deny.
360
+ Example:
1039
361
 
1040
362
  ```json
1041
363
  {
@@ -1053,182 +375,32 @@ Full `permission: "allow"` is convenient but risky. For safer long loops, keep d
1053
375
  "npm test*": "allow",
1054
376
  "npm run test*": "allow",
1055
377
  "npm run lint*": "allow",
1056
- "pnpm test*": "allow",
1057
- "pnpm lint*": "allow",
1058
378
  "git push*": "ask",
1059
379
  "git reset*": "ask",
1060
380
  "git clean*": "deny",
1061
- "rm *": "deny",
1062
- "del *": "ask",
1063
- "rmdir *": "ask"
381
+ "rm *": "deny"
1064
382
  },
1065
383
  "external_directory": "ask"
1066
384
  }
1067
385
  }
1068
386
  ```
1069
387
 
1070
- ## State files
388
+ `--safe` reduces risk but does not replace careful OpenCode permission configuration.
1071
389
 
1072
- Session loop state is stored under:
390
+ ## Package
1073
391
 
1074
392
  ```text
1075
- .opencode/opencode-loop/
393
+ @bybrawe/opencode-loop
1076
394
  ```
1077
395
 
1078
- Patch checkpoints are stored under:
1079
-
1080
- ```text
1081
- .opencode/opencode-loop/checkpoints/
1082
- ```
1083
-
1084
- Recent plugin events are appended to:
1085
-
1086
- ```text
1087
- .opencode/opencode-loop/loop.log
1088
- ```
396
+ The package also installs:
1089
397
 
1090
- Add `.opencode/opencode-loop/` to project `.gitignore` when possible. Runtime state is rewritten often, and on Windows file locks from scanners or snapshot tools can interrupt in-place renames. Since v0.5.20 the plugin writes state payloads via the OS temp directory with a rename/copy fallback so jobs survive those locks; gitignoring the directory still keeps noise out of commits.
1091
-
1092
- ## Example progress.md
1093
-
1094
- Create one with:
1095
-
1096
- ```text
1097
- /loop-init
1098
- ```
1099
-
1100
- Example content:
1101
-
1102
- ```md
1103
- # Progress
1104
-
1105
- ## Current Goal
1106
- Improve the application in small safe steps.
1107
-
1108
- ## Agent Rules
1109
- - Do not ask questions unless truly blocked.
1110
- - Make reasonable assumptions and continue.
1111
- - Work on unfinished TODOs in order.
1112
- - Mark completed TODOs with [x].
1113
- - Add new bugs, ideas, or follow-up tasks as TODOs.
1114
- - Run tests/lint/build when available.
1115
- - Do not run destructive commands, force pushes, production deploys, or database resets.
1116
-
1117
- ## Active TODO
1118
- - [ ] Review the project structure and identify the next safe improvement.
1119
- - [ ] Fix the highest-priority failing test.
1120
- - [ ] Improve the user-facing error state in the main flow.
1121
-
1122
- ## Completed
1123
- - [x] Added initial project notes.
1124
-
1125
- ## Backlog Ideas
1126
- - [ ] Add a smoke test for the critical path.
1127
- - [ ] Improve developer setup documentation.
1128
-
1129
- ## Blocked
1130
- - None.
398
+ ```bash
399
+ opencode-loop --help
400
+ opencode-loopd --help
1131
401
  ```
1132
402
 
1133
- ## Changelog highlights
1134
-
1135
- ### v0.5.20
1136
-
1137
- - Fixed Windows `EPERM` / `EEXIST` failures when rewriting `.opencode/opencode-loop/ses_*.json` during heartbeat and due-timer updates.
1138
- - Atomic state payloads are staged outside the project so OpenCode no longer git-snapshots `opencode-loop/*.tmp` pathspecs.
1139
-
1140
- ### v0.5.17
1141
-
1142
- - Added a tool-denied local command agent and restored the normal coding agent/model for scheduled iterations.
1143
- - Prevented package/local duplicate plugin loading and deferred bootstrap SDK calls to avoid project startup deadlocks.
1144
- - Fixed watched jobs, preset parsing, repeated-command deduplication, safe-shell patterns, and invalid-action retry storms.
1145
- - Added comprehensive command, lifecycle, installer, JSONC, scheduler, and safety regression tests.
1146
-
1147
- ### v0.5.16
1148
-
1149
- - Treat active tools, shell calls, and running foreground/background child sessions as busy even when the parent session appears idle.
1150
- - Prevent stale-run recovery from enqueueing another continuation while tracked background work is still active.
1151
- - Added regression tests for long-running tool calls and background child sessions.
1152
-
1153
- ### v0.5.15
1154
-
1155
- - Hardened experimental Goal Mode completion with concrete evidence, passing-check requirements, no-progress pausing, and user-message interruption.
1156
- - Preferred OpenCode plugin SDK `{ body }`, `{ path: { id }, body }`, and `{ query }` shapes before compatibility fallbacks.
1157
- - Added explicit workspace path guidance, safer 3-minute active-turn recovery, timer disposal cleanup, and an automated Goal Mode smoke test.
1158
- - Made local installers add the `@opencode-ai/plugin` dependency needed by local `.ts` plugins.
1159
-
1160
- ### v0.5.13
1161
-
1162
- - Wrapped experimental goal tools with OpenCode's `tool()` helper and Zod schemas for current OpenCode tool validation.
1163
- - Added `@opencode-ai/plugin` as a development dependency so fresh clones can resolve the tool helper.
1164
-
1165
- ### v0.5.12
1166
-
1167
- - Changed local installs to write `opencode-loop.ts` and remove stale `opencode-loop.js` copies.
1168
- - Fixed OpenCode CLI command argument parsing, current SDK call shapes, and `opencode-loopd` prompt passing.
1169
-
1170
- ### v0.5.7
1171
-
1172
- - Added experimental Goal Mode with `/loop-goal <objective>`.
1173
- - Added goal lifecycle commands and local goal tools so the agent can report real progress, completion evidence, or blocked state.
1174
- - Added repeated `--acceptance`, `--success`, and `--check` flags for goal criteria and verification.
1175
- - Added `--complete-when-checks-pass`, `--max-turns`, and `--evidence-file` for controlled goal workflows.
1176
- - Goal reports are written under `.opencode/opencode-loop/goals/` by default.
1177
-
1178
- ### v0.5.6
1179
-
1180
- - Added clearer README examples for prompt loops, scheduled question loops, command loops, shell loops, first-run timing, and idle-safe behavior.
1181
- - Stabilized `/loop-command 200m /compact` by routing compact/summarize through OpenCode TUI compact handling instead of treating it as a custom prompt command.
1182
- - Clarified that command loops wait for idle and should be used for slash commands such as `/compact`.
1183
-
1184
- ### v0.5.5
1185
-
1186
- - Added explicit loop action types: prompt, scheduled question, OpenCode slash command, and shell command.
1187
- - Added `/loop-command` / `/loop-cmd` for commands such as `/compact`; these wait for the first interval by default.
1188
- - Added `/loop-ask` for recurring checks such as "did you run tests, tsc --noEmit, and build?"; it waits for the first interval by default.
1189
- - Added `/loop-shell` for recurring shell commands.
1190
- - Added `--prompt`, `--ask`, `--command`, `--cmd`, `--slash`, `--shell`, and `--compact` type flags for `/loop`.
1191
- - Clarified idle behavior: if a job becomes due while OpenCode is busy, it waits and runs on the next idle event.
1192
-
1193
- ### v0.5.4
1194
-
1195
- - Fixed compatibility with recent OpenCode SDK/TUI call shapes.
1196
- - Updated prompt, shell, and toast calls for current OpenCode while keeping backwards-compatible fallbacks.
1197
- - Added `session.status` idle gating and debounce so loop runs do not stack on top of busy/queued agent turns.
1198
- - Improved logging around prompt/shell/toast failures instead of silently swallowing important runtime errors.
1199
- - Fixed the known update-related symptoms where `/loop` could appear queued, stay at `runs=0`, or only work intermittently.
1200
-
1201
- ### v0.5.1
1202
-
1203
- - Cleaned up README installation docs.
1204
- - Removed duplicate npm install section.
1205
- - Removed unresolved merge conflict markers.
1206
- - Added clearer daemon mode documentation.
1207
- - Added Windows Task Scheduler examples.
1208
- - Added daemon usage examples for `--every`, `--max-runs`, `--sleep-first`, and `--prompt-file`.
1209
-
1210
- ### v0.5.0
1211
-
1212
- - Added `opencode-loopd` background daemon.
1213
- - Added Windows Task Scheduler helper.
1214
- - Documented TUI loop vs daemon loop.
1215
- - Added background long-running loop examples.
1216
-
1217
- ### v0.4.3
1218
-
1219
- - Added duplicate loop protection.
1220
- - Quieted command markdown files.
1221
-
1222
- ## Notes and limits
1223
-
1224
- - The TUI plugin is idle-driven. It does not run a background daemon while OpenCode is busy.
1225
- - The TUI `/loop` command stops when OpenCode closes, the terminal closes, the machine sleeps, or the session stops emitting idle events.
1226
- - For long-running work outside the TUI, use `opencode-loopd`.
1227
- - `--timeout` is best-effort and relies on OpenCode's abort API.
1228
- - `--verify`, `--preflight`, `--postrun`, and `--notify` run shell commands, so configure OpenCode permissions carefully.
1229
- - `--until` scans common state files and a limited number of markdown/text/json/yaml files to avoid walking huge projects.
1230
- - `--safe` reduces risk but does not replace careful OpenCode permissions.
1231
- - For truly unattended multi-hour work, use a disposable branch or worktree and checkpoint patches.
403
+ See [CHANGELOG.md](./CHANGELOG.md) for release history.
1232
404
 
1233
405
  ## License
1234
406