@bybrawe/opencode-loop 0.5.18 → 0.5.20

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,1228 +1,1235 @@
1
- # OpenCode Loop
2
-
3
- **Claude Code style auto-continue for OpenCode.**
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.
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.
8
-
9
- Repository: **ByBrawe/opencode-loop**
10
- NPM package name: **@bybrawe/opencode-loop**
11
-
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.18 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, and Windows scheduled tasks use a short launcher that stays below the `/TR` limit.
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.18 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.
155
-
156
- ```bash
157
- npx -y @bybrawe/opencode-loop@latest
158
- ```
159
-
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
192
-
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.
194
-
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:
248
-
249
- ```text
250
- /loop-help
251
- /loop-doctor
252
- ```
253
-
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:
268
-
269
- ```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/
274
- ```
275
-
276
- ### Project-local install
277
-
278
- Use this when you want the plugin to be available only inside one repository.
279
-
280
- ```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/
285
- ```
286
-
287
- On Windows PowerShell:
288
-
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:
301
-
302
- ```text
303
- /loop-help
304
- /loop-doctor
305
- ```
306
-
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.
314
-
315
- ## Quick start
316
-
317
- ### The 6 examples most people need
318
-
319
- Auto-continue every time OpenCode finishes a turn:
320
-
321
- ```text
322
- /loop 0s continue from progress.md and implement the next unfinished TODO
323
- ```
324
-
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:
366
-
367
- ```text
368
- /loop 5m continue the project
369
- ```
370
-
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:
376
-
377
- ```text
378
- /loop 1h check if tests, tsc --noEmit, and build pass. If not, fix them.
379
- ```
380
-
381
- Use a command loop when the action starts with `/` and should be executed as an OpenCode command:
382
-
383
- ```text
384
- /loop-command 200m /compact
385
- ```
386
-
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:
485
-
486
- ```text
487
- .opencode/opencode-loop/goals/
488
- ```
489
-
490
- You can choose a report file:
491
-
492
- ```text
493
- /loop-goal --evidence-file goal-report.md --check "npm test" make tests pass and document the result
494
- ```
495
-
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.
497
-
498
- ### Safer development loop
499
-
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
- ```
503
-
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
- ```
509
-
510
- ## Background daemon
511
-
512
- The `/loop` command is session-bound. It works while OpenCode is open and the current session emits idle/status events.
513
-
514
- If you close OpenCode, restart the terminal, lose connection, or your PC sleeps, the TUI loop will not keep running.
515
-
516
- For long-running loops, use the daemon:
517
-
518
- ```bash
519
- opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
520
- ```
521
-
522
- Run immediately after each OpenCode turn:
523
-
524
- ```bash
525
- opencode-loopd --project . --every 0s --prompt "continue from progress.md and implement the next unfinished TODO"
526
- ```
527
-
528
- Limit runs:
529
-
530
- ```bash
531
- opencode-loopd --project . --every 5m --max-runs 20 --prompt-file loop-prompt.md
532
- ```
533
-
534
- Select the OpenCode model and agent explicitly:
535
-
536
- ```bash
537
- opencode-loopd --project . --every 0s --max-runs 1 --model opencode/big-pickle --agent build --prompt-file loop-prompt.md
538
- ```
539
-
540
- When `--max-runs` is finite, the daemon exits with the final OpenCode run's nonzero status so scripts and CI can detect failures.
541
-
542
- Wait before the first run:
543
-
544
- ```bash
545
- opencode-loopd --project . --every 10m --sleep-first --prompt-file loop-prompt.md
546
- ```
547
-
548
- Use an inline prompt:
549
-
550
- ```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
609
- ```
610
-
611
- ## Core commands
612
-
613
- | Command | Purpose |
614
- |---|---|
615
- | `/loop <interval> <prompt>` | Add an idle/interval prompt loop |
616
- | `/loop-command <interval> <slash-command>` | Schedule an OpenCode slash command such as `/compact` |
617
- | `/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
642
-
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 |
650
-
651
- ## Intervals
652
-
653
- ```text
654
- 0s run whenever OpenCode becomes idle, like Claude Code auto-continue
655
- 5m run every 5 minutes when idle
656
- 200m run every 200 minutes when idle
657
- 1h run every hour when idle
658
- ```
659
-
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
693
-
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
- ```
734
-
735
- For most users, the clearer form is preferred:
736
-
737
- ```text
738
- /loop-command 200m /compact
739
- ```
740
-
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
759
-
760
- ### `--name <name>`
761
-
762
- Name a loop so you can manage it later.
763
-
764
- ```text
765
- /loop 0s --name dev continue from progress.md
766
- /loop-pause dev
767
- /loop-resume dev
768
- /loop-stop dev
769
- ```
770
-
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.
865
-
866
- ```text
867
- /loop 0s --preflight "npm install" continue from progress.md
868
- ```
869
-
870
- ### `--postrun "<command>"`
871
-
872
- Runs a shell command after each assistant turn and verification.
873
-
874
- ```text
875
- /loop 0s --postrun "git status --short" continue from progress.md
876
- ```
877
-
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.
881
-
882
- ```text
883
- /loop 0s --max-runtime 6h --notify "echo {job} stopped because {reason}" continue from progress.md
884
- ```
885
-
886
- ### `--checkpoint-only`
887
-
888
- Save `git status` and `git diff --binary` snapshots under:
889
-
890
- ```text
891
- .opencode/opencode-loop/checkpoints/<session>/
892
- ```
893
-
894
- ### `--git-checkpoint`
895
-
896
- Save a patch checkpoint and attempt to commit all changes after each completed run.
897
-
898
- ```text
899
- /loop 0s --git-checkpoint continue from progress.md
900
- ```
901
-
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.
907
-
908
- ```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
918
- ```
919
-
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.
921
-
922
- ### `--batch <n>`
923
-
924
- Tell the agent to process at most N TODO items per run.
925
-
926
- ```text
927
- /loop 0s --batch 5 continue from progress.md
928
- ```
929
-
930
- ### `--quiet`
931
-
932
- Tell the agent to keep replies short.
933
-
934
- ```text
935
- /loop 0s --quiet continue from progress.md
936
- ```
937
-
938
- ### `--ask-never`
939
-
940
- Tell the agent not to ask questions and to make reasonable assumptions.
941
-
942
- ```text
943
- /loop 0s --ask-never continue from progress.md
944
- ```
945
-
946
- ### `--progress-file <file>`
947
-
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
952
- ```
953
-
954
- ### `--watch <file>`
955
-
956
- Run when watched file metadata changes. This is still checked on idle events.
957
-
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
961
- ```
962
-
963
- You can pass multiple `--watch` flags.
964
-
965
- ### `--dry-run`
966
-
967
- Parse and preview a loop without saving it.
968
-
969
- ```text
970
- /loop 0s --dry-run --ask-never continue from progress.md
971
- ```
972
-
973
- ### `--now` and `--no-now`
974
-
975
- By default `/loop` prompt jobs are due immediately. Use `--no-now` to wait for the first interval.
976
-
977
- ```text
978
- /loop 1h --no-now did you run tests, tsc --noEmit, and build?
979
- ```
980
-
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.
982
-
983
- ```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.
994
- ```
995
-
996
- ### Long-running autonomous development loop
997
-
998
- ```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.
1000
- ```
1001
-
1002
- ### Daemon-based long-running development loop
1003
-
1004
- ```bash
1005
- opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
1006
- ```
1007
-
1008
- ### Test-fix loop
1009
-
1010
- ```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.
1012
- ```
1013
-
1014
- ### Compact loop
1015
-
1016
- ```text
1017
- /loop-command 200m /compact
1018
- ```
1019
-
1020
- This compacts every 200 minutes when OpenCode is idle. It does not interrupt an active agent turn.
1021
-
1022
- ### Scheduled quality-check question
1023
-
1024
- ```text
1025
- /loop-ask 1h did you run tests, tsc --noEmit, and build? If not, run them now and fix errors.
1026
- ```
1027
-
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
1031
-
1032
- ```text
1033
- /loop 0s --name dev --prompt-file loop-prompt.md --checkpoint-only --max-runtime 6h
1034
- ```
1035
-
1036
- ## Suggested OpenCode permission config
1037
-
1038
- Full `permission: "allow"` is convenient but risky. For safer long loops, keep destructive commands as ask/deny.
1039
-
1040
- ```json
1041
- {
1042
- "$schema": "https://opencode.ai/config.json",
1043
- "permission": {
1044
- "read": "allow",
1045
- "grep": "allow",
1046
- "glob": "allow",
1047
- "todowrite": "allow",
1048
- "edit": "allow",
1049
- "bash": {
1050
- "*": "ask",
1051
- "git status*": "allow",
1052
- "git diff*": "allow",
1053
- "npm test*": "allow",
1054
- "npm run test*": "allow",
1055
- "npm run lint*": "allow",
1056
- "pnpm test*": "allow",
1057
- "pnpm lint*": "allow",
1058
- "git push*": "ask",
1059
- "git reset*": "ask",
1060
- "git clean*": "deny",
1061
- "rm *": "deny",
1062
- "del *": "ask",
1063
- "rmdir *": "ask"
1064
- },
1065
- "external_directory": "ask"
1066
- }
1067
- }
1068
- ```
1069
-
1070
- ## State files
1071
-
1072
- Session loop state is stored under:
1073
-
1074
- ```text
1075
- .opencode/opencode-loop/
1076
- ```
1077
-
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
- ```
1089
-
1090
- ## Example progress.md
1091
-
1092
- Create one with:
1093
-
1094
- ```text
1095
- /loop-init
1096
- ```
1097
-
1098
- Example content:
1099
-
1100
- ```md
1101
- # Progress
1102
-
1103
- ## Current Goal
1104
- Improve the application in small safe steps.
1105
-
1106
- ## Agent Rules
1107
- - Do not ask questions unless truly blocked.
1108
- - Make reasonable assumptions and continue.
1109
- - Work on unfinished TODOs in order.
1110
- - Mark completed TODOs with [x].
1111
- - Add new bugs, ideas, or follow-up tasks as TODOs.
1112
- - Run tests/lint/build when available.
1113
- - Do not run destructive commands, force pushes, production deploys, or database resets.
1114
-
1115
- ## Active TODO
1116
- - [ ] Review the project structure and identify the next safe improvement.
1117
- - [ ] Fix the highest-priority failing test.
1118
- - [ ] Improve the user-facing error state in the main flow.
1119
-
1120
- ## Completed
1121
- - [x] Added initial project notes.
1122
-
1123
- ## Backlog Ideas
1124
- - [ ] Add a smoke test for the critical path.
1125
- - [ ] Improve developer setup documentation.
1126
-
1127
- ## Blocked
1128
- - None.
1129
- ```
1130
-
1131
- ## Changelog highlights
1132
-
1133
- ### v0.5.17
1134
-
1135
- - Added a tool-denied local command agent and restored the normal coding agent/model for scheduled iterations.
1136
- - Prevented package/local duplicate plugin loading and deferred bootstrap SDK calls to avoid project startup deadlocks.
1137
- - Fixed watched jobs, preset parsing, repeated-command deduplication, safe-shell patterns, and invalid-action retry storms.
1138
- - Added comprehensive command, lifecycle, installer, JSONC, scheduler, and safety regression tests.
1139
-
1140
- ### v0.5.16
1141
-
1142
- - Treat active tools, shell calls, and running foreground/background child sessions as busy even when the parent session appears idle.
1143
- - Prevent stale-run recovery from enqueueing another continuation while tracked background work is still active.
1144
- - Added regression tests for long-running tool calls and background child sessions.
1145
-
1146
- ### v0.5.15
1147
-
1148
- - Hardened experimental Goal Mode completion with concrete evidence, passing-check requirements, no-progress pausing, and user-message interruption.
1149
- - Preferred OpenCode plugin SDK `{ body }`, `{ path: { id }, body }`, and `{ query }` shapes before compatibility fallbacks.
1150
- - Added explicit workspace path guidance, safer 3-minute active-turn recovery, timer disposal cleanup, and an automated Goal Mode smoke test.
1151
- - Made local installers add the `@opencode-ai/plugin` dependency needed by local `.ts` plugins.
1152
-
1153
- ### v0.5.13
1154
-
1155
- - Wrapped experimental goal tools with OpenCode's `tool()` helper and Zod schemas for current OpenCode tool validation.
1156
- - Added `@opencode-ai/plugin` as a development dependency so fresh clones can resolve the tool helper.
1157
-
1158
- ### v0.5.12
1159
-
1160
- - Changed local installs to write `opencode-loop.ts` and remove stale `opencode-loop.js` copies.
1161
- - Fixed OpenCode CLI command argument parsing, current SDK call shapes, and `opencode-loopd` prompt passing.
1162
-
1163
- ### v0.5.7
1164
-
1165
- - Added experimental Goal Mode with `/loop-goal <objective>`.
1166
- - Added goal lifecycle commands and local goal tools so the agent can report real progress, completion evidence, or blocked state.
1167
- - Added repeated `--acceptance`, `--success`, and `--check` flags for goal criteria and verification.
1168
- - Added `--complete-when-checks-pass`, `--max-turns`, and `--evidence-file` for controlled goal workflows.
1169
- - Goal reports are written under `.opencode/opencode-loop/goals/` by default.
1170
-
1171
- ### v0.5.6
1172
-
1173
- - Added clearer README examples for prompt loops, scheduled question loops, command loops, shell loops, first-run timing, and idle-safe behavior.
1174
- - Stabilized `/loop-command 200m /compact` by routing compact/summarize through OpenCode TUI compact handling instead of treating it as a custom prompt command.
1175
- - Clarified that command loops wait for idle and should be used for slash commands such as `/compact`.
1176
-
1177
- ### v0.5.5
1178
-
1179
- - Added explicit loop action types: prompt, scheduled question, OpenCode slash command, and shell command.
1180
- - Added `/loop-command` / `/loop-cmd` for commands such as `/compact`; these wait for the first interval by default.
1181
- - Added `/loop-ask` for recurring checks such as "did you run tests, tsc --noEmit, and build?"; it waits for the first interval by default.
1182
- - Added `/loop-shell` for recurring shell commands.
1183
- - Added `--prompt`, `--ask`, `--command`, `--cmd`, `--slash`, `--shell`, and `--compact` type flags for `/loop`.
1184
- - Clarified idle behavior: if a job becomes due while OpenCode is busy, it waits and runs on the next idle event.
1185
-
1186
- ### v0.5.4
1187
-
1188
- - Fixed compatibility with recent OpenCode SDK/TUI call shapes.
1189
- - Updated prompt, shell, and toast calls for current OpenCode while keeping backwards-compatible fallbacks.
1190
- - Added `session.status` idle gating and debounce so loop runs do not stack on top of busy/queued agent turns.
1191
- - Improved logging around prompt/shell/toast failures instead of silently swallowing important runtime errors.
1192
- - Fixed the known update-related symptoms where `/loop` could appear queued, stay at `runs=0`, or only work intermittently.
1193
-
1194
- ### v0.5.1
1195
-
1196
- - Cleaned up README installation docs.
1197
- - Removed duplicate npm install section.
1198
- - Removed unresolved merge conflict markers.
1199
- - Added clearer daemon mode documentation.
1200
- - Added Windows Task Scheduler examples.
1201
- - Added daemon usage examples for `--every`, `--max-runs`, `--sleep-first`, and `--prompt-file`.
1202
-
1203
- ### v0.5.0
1204
-
1205
- - Added `opencode-loopd` background daemon.
1206
- - Added Windows Task Scheduler helper.
1207
- - Documented TUI loop vs daemon loop.
1208
- - Added background long-running loop examples.
1209
-
1210
- ### v0.4.3
1211
-
1212
- - Added duplicate loop protection.
1213
- - Quieted command markdown files.
1214
-
1215
- ## Notes and limits
1216
-
1217
- - The TUI plugin is idle-driven. It does not run a background daemon while OpenCode is busy.
1218
- - The TUI `/loop` command stops when OpenCode closes, the terminal closes, the machine sleeps, or the session stops emitting idle events.
1219
- - For long-running work outside the TUI, use `opencode-loopd`.
1220
- - `--timeout` is best-effort and relies on OpenCode's abort API.
1221
- - `--verify`, `--preflight`, `--postrun`, and `--notify` run shell commands, so configure OpenCode permissions carefully.
1222
- - `--until` scans common state files and a limited number of markdown/text/json/yaml files to avoid walking huge projects.
1223
- - `--safe` reduces risk but does not replace careful OpenCode permissions.
1224
- - For truly unattended multi-hour work, use a disposable branch or worktree and checkpoint patches.
1225
-
1226
- ## License
1227
-
1228
- MIT
1
+ # OpenCode Loop
2
+
3
+ **Claude Code style auto-continue for OpenCode.**
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.
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.
8
+
9
+ Repository: **ByBrawe/opencode-loop**
10
+ NPM package name: **@bybrawe/opencode-loop**
11
+
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.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.
155
+
156
+ ```bash
157
+ npx -y @bybrawe/opencode-loop@latest
158
+ ```
159
+
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
192
+
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.
194
+
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:
248
+
249
+ ```text
250
+ /loop-help
251
+ /loop-doctor
252
+ ```
253
+
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:
268
+
269
+ ```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/
274
+ ```
275
+
276
+ ### Project-local install
277
+
278
+ Use this when you want the plugin to be available only inside one repository.
279
+
280
+ ```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/
285
+ ```
286
+
287
+ On Windows PowerShell:
288
+
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:
301
+
302
+ ```text
303
+ /loop-help
304
+ /loop-doctor
305
+ ```
306
+
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.
314
+
315
+ ## Quick start
316
+
317
+ ### The 6 examples most people need
318
+
319
+ Auto-continue every time OpenCode finishes a turn:
320
+
321
+ ```text
322
+ /loop 0s continue from progress.md and implement the next unfinished TODO
323
+ ```
324
+
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:
366
+
367
+ ```text
368
+ /loop 5m continue the project
369
+ ```
370
+
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:
376
+
377
+ ```text
378
+ /loop 1h check if tests, tsc --noEmit, and build pass. If not, fix them.
379
+ ```
380
+
381
+ Use a command loop when the action starts with `/` and should be executed as an OpenCode command:
382
+
383
+ ```text
384
+ /loop-command 200m /compact
385
+ ```
386
+
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:
485
+
486
+ ```text
487
+ .opencode/opencode-loop/goals/
488
+ ```
489
+
490
+ You can choose a report file:
491
+
492
+ ```text
493
+ /loop-goal --evidence-file goal-report.md --check "npm test" make tests pass and document the result
494
+ ```
495
+
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.
497
+
498
+ ### Safer development loop
499
+
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
+ ```
503
+
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
+ ```
509
+
510
+ ## Background daemon
511
+
512
+ The `/loop` command is session-bound. It works while OpenCode is open and the current session emits idle/status events.
513
+
514
+ If you close OpenCode, restart the terminal, lose connection, or your PC sleeps, the TUI loop will not keep running.
515
+
516
+ For long-running loops, use the daemon:
517
+
518
+ ```bash
519
+ opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
520
+ ```
521
+
522
+ Run immediately after each OpenCode turn:
523
+
524
+ ```bash
525
+ opencode-loopd --project . --every 0s --prompt "continue from progress.md and implement the next unfinished TODO"
526
+ ```
527
+
528
+ Limit runs:
529
+
530
+ ```bash
531
+ opencode-loopd --project . --every 5m --max-runs 20 --prompt-file loop-prompt.md
532
+ ```
533
+
534
+ Select the OpenCode model and agent explicitly:
535
+
536
+ ```bash
537
+ opencode-loopd --project . --every 0s --max-runs 1 --model opencode/big-pickle --agent build --prompt-file loop-prompt.md
538
+ ```
539
+
540
+ When `--max-runs` is finite, the daemon exits with the final OpenCode run's nonzero status so scripts and CI can detect failures.
541
+
542
+ Wait before the first run:
543
+
544
+ ```bash
545
+ opencode-loopd --project . --every 10m --sleep-first --prompt-file loop-prompt.md
546
+ ```
547
+
548
+ Use an inline prompt:
549
+
550
+ ```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
609
+ ```
610
+
611
+ ## Core commands
612
+
613
+ | Command | Purpose |
614
+ |---|---|
615
+ | `/loop <interval> <prompt>` | Add an idle/interval prompt loop |
616
+ | `/loop-command <interval> <slash-command>` | Schedule an OpenCode slash command such as `/compact` |
617
+ | `/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
642
+
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 |
650
+
651
+ ## Intervals
652
+
653
+ ```text
654
+ 0s run whenever OpenCode becomes idle, like Claude Code auto-continue
655
+ 5m run every 5 minutes when idle
656
+ 200m run every 200 minutes when idle
657
+ 1h run every hour when idle
658
+ ```
659
+
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
693
+
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
+ ```
734
+
735
+ For most users, the clearer form is preferred:
736
+
737
+ ```text
738
+ /loop-command 200m /compact
739
+ ```
740
+
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
759
+
760
+ ### `--name <name>`
761
+
762
+ Name a loop so you can manage it later.
763
+
764
+ ```text
765
+ /loop 0s --name dev continue from progress.md
766
+ /loop-pause dev
767
+ /loop-resume dev
768
+ /loop-stop dev
769
+ ```
770
+
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.
865
+
866
+ ```text
867
+ /loop 0s --preflight "npm install" continue from progress.md
868
+ ```
869
+
870
+ ### `--postrun "<command>"`
871
+
872
+ Runs a shell command after each assistant turn and verification.
873
+
874
+ ```text
875
+ /loop 0s --postrun "git status --short" continue from progress.md
876
+ ```
877
+
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.
881
+
882
+ ```text
883
+ /loop 0s --max-runtime 6h --notify "echo {job} stopped because {reason}" continue from progress.md
884
+ ```
885
+
886
+ ### `--checkpoint-only`
887
+
888
+ Save `git status` and `git diff --binary` snapshots under:
889
+
890
+ ```text
891
+ .opencode/opencode-loop/checkpoints/<session>/
892
+ ```
893
+
894
+ ### `--git-checkpoint`
895
+
896
+ Save a patch checkpoint and attempt to commit all changes after each completed run.
897
+
898
+ ```text
899
+ /loop 0s --git-checkpoint continue from progress.md
900
+ ```
901
+
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.
907
+
908
+ ```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
918
+ ```
919
+
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.
921
+
922
+ ### `--batch <n>`
923
+
924
+ Tell the agent to process at most N TODO items per run.
925
+
926
+ ```text
927
+ /loop 0s --batch 5 continue from progress.md
928
+ ```
929
+
930
+ ### `--quiet`
931
+
932
+ Tell the agent to keep replies short.
933
+
934
+ ```text
935
+ /loop 0s --quiet continue from progress.md
936
+ ```
937
+
938
+ ### `--ask-never`
939
+
940
+ Tell the agent not to ask questions and to make reasonable assumptions.
941
+
942
+ ```text
943
+ /loop 0s --ask-never continue from progress.md
944
+ ```
945
+
946
+ ### `--progress-file <file>`
947
+
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
952
+ ```
953
+
954
+ ### `--watch <file>`
955
+
956
+ Run when watched file metadata changes. This is still checked on idle events.
957
+
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
961
+ ```
962
+
963
+ You can pass multiple `--watch` flags.
964
+
965
+ ### `--dry-run`
966
+
967
+ Parse and preview a loop without saving it.
968
+
969
+ ```text
970
+ /loop 0s --dry-run --ask-never continue from progress.md
971
+ ```
972
+
973
+ ### `--now` and `--no-now`
974
+
975
+ By default `/loop` prompt jobs are due immediately. Use `--no-now` to wait for the first interval.
976
+
977
+ ```text
978
+ /loop 1h --no-now did you run tests, tsc --noEmit, and build?
979
+ ```
980
+
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.
982
+
983
+ ```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.
994
+ ```
995
+
996
+ ### Long-running autonomous development loop
997
+
998
+ ```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.
1000
+ ```
1001
+
1002
+ ### Daemon-based long-running development loop
1003
+
1004
+ ```bash
1005
+ opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
1006
+ ```
1007
+
1008
+ ### Test-fix loop
1009
+
1010
+ ```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.
1012
+ ```
1013
+
1014
+ ### Compact loop
1015
+
1016
+ ```text
1017
+ /loop-command 200m /compact
1018
+ ```
1019
+
1020
+ This compacts every 200 minutes when OpenCode is idle. It does not interrupt an active agent turn.
1021
+
1022
+ ### Scheduled quality-check question
1023
+
1024
+ ```text
1025
+ /loop-ask 1h did you run tests, tsc --noEmit, and build? If not, run them now and fix errors.
1026
+ ```
1027
+
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
1031
+
1032
+ ```text
1033
+ /loop 0s --name dev --prompt-file loop-prompt.md --checkpoint-only --max-runtime 6h
1034
+ ```
1035
+
1036
+ ## Suggested OpenCode permission config
1037
+
1038
+ Full `permission: "allow"` is convenient but risky. For safer long loops, keep destructive commands as ask/deny.
1039
+
1040
+ ```json
1041
+ {
1042
+ "$schema": "https://opencode.ai/config.json",
1043
+ "permission": {
1044
+ "read": "allow",
1045
+ "grep": "allow",
1046
+ "glob": "allow",
1047
+ "todowrite": "allow",
1048
+ "edit": "allow",
1049
+ "bash": {
1050
+ "*": "ask",
1051
+ "git status*": "allow",
1052
+ "git diff*": "allow",
1053
+ "npm test*": "allow",
1054
+ "npm run test*": "allow",
1055
+ "npm run lint*": "allow",
1056
+ "pnpm test*": "allow",
1057
+ "pnpm lint*": "allow",
1058
+ "git push*": "ask",
1059
+ "git reset*": "ask",
1060
+ "git clean*": "deny",
1061
+ "rm *": "deny",
1062
+ "del *": "ask",
1063
+ "rmdir *": "ask"
1064
+ },
1065
+ "external_directory": "ask"
1066
+ }
1067
+ }
1068
+ ```
1069
+
1070
+ ## State files
1071
+
1072
+ Session loop state is stored under:
1073
+
1074
+ ```text
1075
+ .opencode/opencode-loop/
1076
+ ```
1077
+
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
+ ```
1089
+
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.
1131
+ ```
1132
+
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.
1232
+
1233
+ ## License
1234
+
1235
+ MIT