@bybrawe/opencode-loop 0.5.24 → 0.5.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,1041 +1,414 @@
1
1
  # OpenCode Loop
2
2
 
3
- **Claude Code style auto-continue for OpenCode.**
3
+ **Claude Code-style auto-continue, scheduled OpenCode work, and background loops.**
4
4
 
5
- OpenCode Loop adds a practical `/loop` command and `opencode-loopd` daemon to OpenCode so an agent can keep working after each idle turn instead of waiting for you to type “continue” again.
5
+ OpenCode Loop adds `/loop`, scheduled prompt/command/shell jobs, compact scheduling, safe long-running continuation helpers, and the `opencode-loopd` background daemon.
6
6
 
7
- It is useful for long coding sessions, `progress.md` workflows, TODO automation, test-fix loops, periodic `/compact`, checkpoints, safe autonomous development, and background OpenCode continuation jobs.
7
+ > **Current release: `0.5.26`.** Loop also contains an older experimental `/loop-goal` mode, but for strong persistent Goal contracts and host-verified completion, use the separate **OpenCode Goals** plugin described below.
8
8
 
9
- Repository: **ByBrawe/opencode-loop**
10
- NPM package name: **@bybrawe/opencode-loop**
9
+ ## Install or update
11
10
 
12
- ### Scheduler heartbeat note
11
+ Choose either installation method below.
13
12
 
14
- v0.5.11 includes a referenced heartbeat scheduler. This is important in OpenCode TUI because local command hooks are event-driven: a normal `/loop-status` command can wake the plugin, but a timer-only loop should not depend on a user typing another command. The heartbeat periodically checks active loop jobs, clears stale completed runs, and starts due work only when the session appears idle.
15
-
16
-
17
- ## Current status
18
-
19
- **v0.5.24 uses OpenCode's native compaction lifecycle, serializes compact-before-run work, fixes current headless summarize payloads, and validates stale `busy` recovery against a genuinely completed assistant tail.** **v0.5.23 adds immediate, token-safe recovery when a scheduler prompt/shell dispatch is rejected, without automatically replaying the prompt.** **v0.5.22 adds forward-compatible OpenCode command handling plus Bun and peer-range compatibility CI.** **v0.5.21 targets current OpenCode 1.18.x compatibility and safer releases.** Server-plugin control commands keep their locked-down acknowledgement prompt instead of creating an empty command message, `/compact` prefers the current `session.compact` TUI command, and CI now covers Ubuntu and Windows before publishing. **v0.5.20 fixes Windows TUI state writes.** Session job state is written through the OS temp directory with rename plus copy/unlink fallback and short retries, so antivirus locks and OpenCode snapshots no longer drop `/loop` jobs with `EPERM` on rename. **v0.5.19** hardens Goal Mode, package updates, and the background daemon: package installs are pinned to the installed version so OpenCode cannot keep loading an older cached release, scheduler-created goal messages no longer self-interrupt on delayed updates, finite daemon failures return nonzero, model/agent selection is supported, Windows scheduled tasks use a short launcher that stays below the `/TR` limit, and asynchronous release verification is reliable under load.
20
-
21
- The known update-related symptoms from older builds are fixed:
22
-
23
- - `/loop` looks queued but the job stays at `runs=0`
24
- - a loop job is replaced but does not fire after OpenCode becomes idle
25
- - repeated `/loop` commands create confusing queued turns
26
- - prompt, shell, or toast calls silently fail after OpenCode SDK changes
27
- - `/compact` accidentally being treated as a normal agent prompt
28
- - intermittent `Tool execution aborted` behavior caused by triggering a new turn too early
29
- - experimental `/loop-goal` support for goal-driven work that continues until complete, blocked, paused, cleared, or paused by no-progress/user-interrupt guards
30
- - `--no-now` interval jobs not waking until another OpenCode event happens
31
- - `/loop-ask`, `/loop-command`, and `/loop-shell` being configured but not reliably firing on their own
32
-
33
- The TUI loop is still intentionally session-bound: it runs while OpenCode is open and the current session emits status/idle events. For long-running background work after closing the terminal or OpenCode, use `opencode-loopd`.
34
-
35
- ## v0.5.19 quick behavior guide
36
-
37
- OpenCode Loop has two triggers now:
38
-
39
- 1. **Idle/status events** from OpenCode. These are used when OpenCode finishes a turn.
40
- 2. **A real due timer** inside the plugin. This wakes delayed jobs even when no new OpenCode event happens.
41
-
42
- All TUI jobs are still idle-safe. If the timer expires while OpenCode is busy, or while a tool/background child session is still executing, the job does not interrupt the active turn. It waits and retries until that work finishes and the parent session becomes idle.
43
-
44
- Simple examples:
45
-
46
- ```text
47
- /loop 0s continue the project
48
- ```
49
-
50
- Run every time OpenCode becomes idle.
51
-
52
- ```text
53
- /loop 1m --no-now continue the project
54
- ```
55
-
56
- Wait 1 minute first, then run when OpenCode is idle.
57
-
58
- ```text
59
- /loop-command 200m /compact
60
- ```
61
-
62
- Run OpenCode compact about every 200 minutes, but only when OpenCode is idle.
63
-
64
- ```text
65
- /loop-ask 1h did you run tests, tsc --noEmit, and build? If not, run them and fix errors.
66
- ```
67
-
68
- Ask a recurring quality-control question every hour.
69
-
70
- ```text
71
- /loop-shell 10m npm test
72
- ```
73
-
74
- Run a shell command every 10 minutes when idle.
75
-
76
- ```text
77
- /loop-goal --max-turns 5 --check "npm run build" --complete-when-checks-pass make the project build cleanly
78
- ```
79
-
80
- Experimental persistent goal mode: keep working until the goal is complete, blocked, paused, cleared, or a safety limit is reached.
81
-
82
- > Note: OpenCode custom command markdown still creates an assistant turn for slash commands. v0.5.17 routes that acknowledgement through the installed `opencode-loop-local` agent, which denies tools and subagents. The real scheduled iteration explicitly restores the normal coding agent/model, so a status or control command cannot launch background exploration or leave later loop work tool-disabled.
83
-
84
- ## Why this exists
85
-
86
- Claude Code users often rely on a loop-like workflow where the agent finishes one step, then immediately continues with the next step.
87
-
88
- OpenCode is powerful, but long-running autonomous workflows usually need extra control around:
89
-
90
- - auto-continue after idle
91
- - compact / summarize scheduling
92
- - `progress.md` and TODO-driven development
93
- - test verification after each turn
94
- - patch checkpoints
95
- - maximum runtime limits
96
- - failure limits
97
- - background daemon execution
98
- - Windows Task Scheduler support
99
- - safety prompts and destructive command guards
100
-
101
- OpenCode Loop is designed for developers searching for:
102
-
103
- - OpenCode loop
104
- - OpenCode Claude Code loop
105
- - OpenCode auto continue
106
- - OpenCode continue automatically
107
- - OpenCode `/loop` command
108
- - OpenCode compact scheduler
109
- - OpenCode Ralph loop alternative
110
- - Claude Code style loop for OpenCode
111
- - autonomous coding loop for OpenCode
112
- - progress.md TODO automation for OpenCode
113
- - OpenCode background daemon
114
- - OpenCode loop daemon
115
- - OpenCode Windows Task Scheduler loop
116
-
117
- ## Features
118
-
119
- > The TUI `/loop` command is session-bound. It runs while OpenCode is open and the session receives idle/status events. If the terminal closes, the machine sleeps, the process is killed, or the provider connection is lost for a long time, the TUI loop cannot continue in the background. For long-running loops, use `opencode-loopd` daemon mode.
120
-
121
- - **Claude Code style auto-continue** with `/loop 0s ...`.
122
- - **TUI loop mode** with `/loop`, active while OpenCode is open.
123
- - **Background daemon mode** with `opencode-loopd` for long-running loops outside the OpenCode TUI.
124
- - **Windows Task Scheduler helper** with `opencode-loopd install-task`.
125
- - **One-shot scheduled runs** for periodic continuation jobs.
126
- - **Interval loops** for prompts, slash commands, and shell commands.
127
- - **Prompt-file support** with `--prompt-file loop-prompt.md` for long reusable instructions.
128
- - **Prompt-file daemon support** with `opencode-loopd --prompt-file loop-prompt.md`.
129
- - **Include extra context files** with `--include-file`.
130
- - **progress.md workflow** with `--progress-file progress.md`.
131
- - **Large TODO support** with `--batch`.
132
- - **Compact scheduling** with `/loop 200m /compact` or `--compact-every`.
133
- - **Verification loops** with `--verify "npm test"`.
134
- - **Preflight checks** with `--preflight "npm install"`.
135
- - **Post-run commands** with `--postrun`.
136
- - **Failure control** with `--max-failures` and `--pause-on-verify-fail`.
137
- - **Runtime control** with `--max-runtime 6h`.
138
- - **Run limit support** with `--max-runs`.
139
- - **Wait-before-first-run support** with `--no-now` for TUI loops and `--sleep-first` for daemon mode.
140
- - **Checkpoints** with `--checkpoint-only` or `--git-checkpoint`.
141
- - **Safe mode** with `--safe` and prompt-level destructive command warnings.
142
- - **Branch setup** with `--branch ai-loop`.
143
- - **Stop controls** with `--stop-file STOP_LOOP`, `--until`, `/loop-stop`, `/loop-pause`, `/loop-resume`, and `/loop-remove`.
144
- - **Watch mode** with `--watch progress.md`.
145
- - **Experimental Goal Mode** with `/loop-goal`, goal status, goal tools, acceptance criteria, and verification checks.
146
- - **Diagnostics** with `/loop-doctor`.
147
- - **Starter progress file** with `/loop-init`.
148
- - **State export** with `/loop-export`.
149
-
150
- ## Installation
151
-
152
- ### Recommended: install from npm
153
-
154
- Use the npm installer from any shell: Windows PowerShell, Windows CMD, macOS, or Linux.
13
+ ### Option 1 — one-command install with `npx` (recommended)
155
14
 
156
15
  ```bash
157
16
  npx -y @bybrawe/opencode-loop@latest
158
17
  ```
159
18
 
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()`.
19
+ Run the same command again whenever you want to update.
161
20
 
162
- Windows target paths:
21
+ ### Option 2 — install with npm
163
22
 
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:
23
+ Install OpenCode Loop globally so its installer and daemon commands are available:
186
24
 
187
25
  ```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
- }
26
+ npm install -g @bybrawe/opencode-loop@latest
27
+ opencode-loop
212
28
  ```
213
29
 
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:
30
+ To update later:
219
31
 
220
32
  ```bash
221
- npx -y @bybrawe/opencode-loop
33
+ npm install -g @bybrawe/opencode-loop@latest
34
+ opencode-loop
222
35
  ```
223
36
 
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:
37
+ `npm install @bybrawe/opencode-loop` by itself only adds the Node package to the current project. For a normal OpenCode installation, use the global npm method above or the recommended `npx` installer.
231
38
 
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
- ```
39
+ The installer:
237
40
 
238
- macOS / Linux / Git Bash:
41
+ - installs/updates the OpenCode Loop plugin;
42
+ - installs the `/loop-*` slash-command definitions;
43
+ - installs the tool-denied `opencode-loop-local` command agent;
44
+ - keeps an existing npm plugin entry pinned to the installer’s exact version to avoid stale OpenCode package-cache resolution;
45
+ - removes duplicate old local Loop plugin copies when the package entry is authoritative.
239
46
 
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:
47
+ Then **fully restart OpenCode** and verify:
248
48
 
249
49
  ```text
250
50
  /loop-help
251
51
  /loop-doctor
252
52
  ```
253
53
 
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
- ```
54
+ ### Uninstall
266
55
 
267
- macOS / Linux:
56
+ If you use the `npx` installer:
268
57
 
269
58
  ```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/
59
+ npx -y @bybrawe/opencode-loop@latest --uninstall
274
60
  ```
275
61
 
276
- ### Project-local install
277
-
278
- Use this when you want the plugin to be available only inside one repository.
62
+ If you installed OpenCode Loop globally with npm:
279
63
 
280
64
  ```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/
65
+ opencode-loop --uninstall
66
+ npm uninstall -g @bybrawe/opencode-loop
285
67
  ```
286
68
 
287
- On Windows PowerShell:
69
+ Run `opencode-loop --uninstall` before removing the global npm package so it can clean its OpenCode registrations and managed command files.
288
70
 
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
71
+ Uninstall removes known OpenCode Loop package registrations, local plugin files, `/loop-*` command markdown files, and the Loop local command agent while preserving unrelated OpenCode configuration.
299
72
 
300
- After restarting OpenCode, run:
73
+ Project Loop state is intentionally preserved under:
301
74
 
302
75
  ```text
303
- /loop-help
304
- /loop-doctor
76
+ .opencode/opencode-loop/
305
77
  ```
306
78
 
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.
79
+ Delete that directory yourself only when you intentionally want to erase saved Loop jobs, logs, checkpoints, or related local state. Restart OpenCode after uninstalling.
314
80
 
315
81
  ## Quick start
316
82
 
317
- ### The 6 examples most people need
318
-
319
- Auto-continue every time OpenCode finishes a turn:
83
+ Auto-continue whenever OpenCode becomes idle:
320
84
 
321
85
  ```text
322
86
  /loop 0s continue from progress.md and implement the next unfinished TODO
323
87
  ```
324
88
 
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:
89
+ Run a prompt every 5 minutes when idle:
366
90
 
367
91
  ```text
368
92
  /loop 5m continue the project
369
93
  ```
370
94
 
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:
95
+ Wait before the first run:
376
96
 
377
97
  ```text
378
- /loop 1h check if tests, tsc --noEmit, and build pass. If not, fix them.
98
+ /loop 5m --no-now continue the project
379
99
  ```
380
100
 
381
- Use a command loop when the action starts with `/` and should be executed as an OpenCode command:
101
+ Schedule an OpenCode command such as compaction:
382
102
 
383
103
  ```text
384
104
  /loop-command 200m /compact
385
105
  ```
386
106
 
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:
107
+ Run a real shell command on a schedule:
430
108
 
431
109
  ```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
110
+ /loop-shell 10m npm test
458
111
  ```
459
112
 
460
- Goal with automatic check commands after each assistant turn:
113
+ Ask a recurring quality-control question:
461
114
 
462
115
  ```text
463
- /loop-goal --check "npm run typecheck" --check "npm run build" fix every TypeScript and build error
116
+ /loop-ask 1h did you run tests, typecheck, and build? If not, run them and fix errors.
464
117
  ```
465
118
 
466
- Goal that automatically stops when all configured checks pass:
119
+ ## What OpenCode Loop is for
467
120
 
468
- ```text
469
- /loop-goal --check "npm run typecheck" --check "npm run build" --complete-when-checks-pass make the project build cleanly
470
- ```
121
+ Use Loop when the important question is **“what should run again, and when?”**
471
122
 
472
- Goal that gives the agent more attempts before the no-progress guard pauses it:
123
+ Typical uses:
473
124
 
474
- ```text
475
- /loop-goal --max-no-progress 6 --check "npm test" fix the failing tests and keep evidence in the goal report
476
- ```
125
+ - Claude Code-style auto-continue after idle;
126
+ - recurring coding prompts;
127
+ - progress.md / TODO workflows;
128
+ - scheduled `/compact` or other OpenCode commands;
129
+ - recurring tests/lint/build shell jobs;
130
+ - retry/fix loops with verification;
131
+ - patch checkpoints;
132
+ - maximum run/runtime/failure limits;
133
+ - prompt-file workflows;
134
+ - background work through `opencode-loopd`;
135
+ - Windows Task Scheduler integration.
477
136
 
478
- Goal with a safety/runtime limit:
137
+ Loop is idle-safe: if a job becomes due while the session is busy, active tools or child work are still running, the job waits instead of intentionally stacking another turn on top of the current one.
479
138
 
480
- ```text
481
- /loop-goal --max-turns 20 --max-runtime 3h --check "npm test" fix the failing tests without destructive commands
482
- ```
139
+ ## For stronger persistent Goals, use OpenCode Goals
483
140
 
484
- Goal Mode writes a report under:
141
+ OpenCode Loop still includes the older **experimental** `/loop-goal` workflow. It is useful for compatibility and lightweight outcome-driven automation, but it is not the strongest Goal implementation in this project family.
485
142
 
486
- ```text
487
- .opencode/opencode-loop/goals/
488
- ```
143
+ For durable Goal Contracts, host-owned evidence, semantic verification, native Todo coordination, revision isolation, false-completion protection, restart recovery, Goal audit, budgets, and ordered Goals, install **OpenCode Goals**.
489
144
 
490
- You can choose a report file:
145
+ Recommended one-command installer:
491
146
 
492
- ```text
493
- /loop-goal --evidence-file goal-report.md --check "npm test" make tests pass and document the result
147
+ ```bash
148
+ npx -y @bybrawe/opencode-goal@latest
494
149
  ```
495
150
 
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
151
+ Or install its CLI globally with npm and run the installer:
499
152
 
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.
153
+ ```bash
154
+ npm install -g @bybrawe/opencode-goal@latest
155
+ opencode-goal
502
156
  ```
503
157
 
504
- ### Test-fix loop
158
+ Then use:
505
159
 
506
160
  ```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
161
+ /goal <objective>
162
+ /goal status
163
+ /goal contract
164
+ /goal audit
520
165
  ```
521
166
 
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
- ```
167
+ ### Can Loop and Goals be installed together?
527
168
 
528
- Limit runs:
169
+ Yes. `@bybrawe/opencode-loop` and `@bybrawe/opencode-goal` use different package names, commands, and project-state directories, so they can coexist in one OpenCode installation.
529
170
 
530
- ```bash
531
- opencode-loopd --project . --every 5m --max-runs 20 --prompt-file loop-prompt.md
532
- ```
171
+ Recommended split:
533
172
 
534
- Select the OpenCode model and agent explicitly:
173
+ - use **`/goal`** for persistent, strongly verified outcome completion;
174
+ - use **`/loop`**, `/loop-command`, `/loop-shell`, and `opencode-loopd` for scheduling/repetition/background infrastructure.
535
175
 
536
- ```bash
537
- opencode-loopd --project . --every 0s --max-runs 1 --model opencode/big-pickle --agent build --prompt-file loop-prompt.md
538
- ```
176
+ Do **not** run Loop’s `/loop-goal` and OpenCode Goals `/goal` against the same work in the same session. Both can autonomously continue on idle boundaries and can compete to start turns.
539
177
 
540
- When `--max-runs` is finite, the daemon exits with the final OpenCode run's nonzero status so scripts and CI can detect failures.
178
+ Likewise, avoid leaving a prompt-producing `/loop ...` job continuously injecting agent turns into a session while an OpenCode Goal is actively continuing. Use separate sessions or pause/remove that prompt loop until the Goal is done. Scheduled shell/command jobs should also be chosen carefully so they do not race files or verification.
541
179
 
542
- Wait before the first run:
180
+ Install both when needed with `npx`:
543
181
 
544
182
  ```bash
545
- opencode-loopd --project . --every 10m --sleep-first --prompt-file loop-prompt.md
183
+ npx -y @bybrawe/opencode-loop@latest
184
+ npx -y @bybrawe/opencode-goal@latest
546
185
  ```
547
186
 
548
- Use an inline prompt:
187
+ Or install both globally with npm, then run both installers:
549
188
 
550
189
  ```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
190
+ npm install -g @bybrawe/opencode-loop@latest @bybrawe/opencode-goal@latest
191
+ opencode-loop
192
+ opencode-goal
609
193
  ```
610
194
 
611
195
  ## Core commands
612
196
 
613
197
  | Command | Purpose |
614
198
  |---|---|
615
- | `/loop <interval> <prompt>` | Add an idle/interval prompt loop |
616
- | `/loop-command <interval> <slash-command>` | Schedule an OpenCode slash command such as `/compact` |
199
+ | `/loop <interval> <prompt>` | Add/update an idle/interval prompt loop |
200
+ | `/loop-command <interval> <slash-command>` | Schedule OpenCode slash commands |
617
201
  | `/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
202
+ | `/loop-ask <interval> <question>` | Schedule recurring quality/check prompts |
203
+ | `/loop-shell <interval> <command>` | Schedule a real shell command |
204
+ | `/loop-status` | Show active jobs |
205
+ | `/loop-now [id/name/all]` | Run selected jobs immediately |
206
+ | `/loop-pause [id/name/all]` | Pause jobs |
207
+ | `/loop-resume [id/name/all]` | Resume jobs |
208
+ | `/loop-remove [id/name/all]` | Remove jobs |
209
+ | `/loop-clear` | Remove all current-session Loop jobs |
210
+ | `/loop-doctor` | Diagnose Loop/OpenCode state |
211
+ | `/loop-init` | Create a starter `progress.md` |
212
+ | `/loop-export` | Export Loop state as JSON |
213
+ | `/loop-goal <objective>` | Start the older experimental Loop Goal Mode |
642
214
 
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 |
215
+ ## Intervals and job types
650
216
 
651
- ## Intervals
217
+ Examples:
652
218
 
653
219
  ```text
654
- 0s run whenever OpenCode becomes idle, like Claude Code auto-continue
220
+ 0s run whenever OpenCode becomes idle
655
221
  5m run every 5 minutes when idle
656
222
  200m run every 200 minutes when idle
657
223
  1h run every hour when idle
658
224
  ```
659
225
 
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
226
+ OpenCode Loop separates prompt, slash-command, and shell work because they should not be executed the same way.
685
227
 
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
- ```
228
+ | Type | Example |
229
+ |---|---|
230
+ | Prompt | `/loop 0s continue from progress.md` |
231
+ | Scheduled question | `/loop-ask 1h did you run tests?` |
232
+ | OpenCode command | `/loop-command 200m /compact` |
233
+ | Shell | `/loop-shell 10m npm test` |
734
234
 
735
- For most users, the clearer form is preferred:
235
+ Do not use a normal prompt loop when you mean to run `/compact`. Prefer:
736
236
 
737
237
  ```text
738
238
  /loop-command 200m /compact
739
239
  ```
740
240
 
741
- ### Shell action
241
+ ## Useful flags
742
242
 
743
- Use `/loop-shell` for real terminal commands.
243
+ ### Naming and lifecycle
744
244
 
745
245
  ```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
246
+ /loop 0s --name dev continue the project
766
247
  /loop-pause dev
767
248
  /loop-resume dev
768
249
  /loop-stop dev
769
250
  ```
770
251
 
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.
252
+ ### Limits
873
253
 
874
254
  ```text
875
- /loop 0s --postrun "git status --short" continue from progress.md
255
+ --max-runs <n>
256
+ --max-runtime <duration>
257
+ --max-failures <n>
258
+ --timeout <duration>
876
259
  ```
877
260
 
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.
261
+ ### Verification and safety
881
262
 
882
263
  ```text
883
- /loop 0s --max-runtime 6h --notify "echo {job} stopped because {reason}" continue from progress.md
264
+ --verify "npm test"
265
+ --preflight "npm install"
266
+ --postrun "git status --short"
267
+ --pause-on-verify-fail
268
+ --safe
269
+ --ask-never
270
+ --no-overlap
884
271
  ```
885
272
 
886
- ### `--checkpoint-only`
887
-
888
- Save `git status` and `git diff --binary` snapshots under:
273
+ ### Context and TODO workflows
889
274
 
890
275
  ```text
891
- .opencode/opencode-loop/checkpoints/<session>/
276
+ --progress-file progress.md
277
+ --prompt-file loop-prompt.md
278
+ --include-file ARCHITECTURE.md
279
+ --batch 5
280
+ --compact-every 20
281
+ --watch progress.md
892
282
  ```
893
283
 
894
- ### `--git-checkpoint`
895
-
896
- Save a patch checkpoint and attempt to commit all changes after each completed run.
284
+ ### Checkpoints
897
285
 
898
286
  ```text
899
- /loop 0s --git-checkpoint continue from progress.md
287
+ --checkpoint-only
288
+ --git-checkpoint
900
289
  ```
901
290
 
902
- Use carefully. It runs `git add -A` and `git commit` when changes exist.
903
-
904
- ### `--branch <name>`
291
+ `--git-checkpoint` may stage and commit work. Use it only when that behavior is intentional.
905
292
 
906
- Switch to a branch before the first run, or create it if it does not exist.
293
+ ## Recommended development loop
907
294
 
908
295
  ```text
909
- /loop 0s --branch ai-loop continue from progress.md
296
+ /loop 0s --name dev --ask-never --safe --no-overlap --batch 5 --compact-every 200m --checkpoint-only --progress-file progress.md Treat progress.md as the project state. Continue with the next unfinished TODO, implement it, mark completed items, add useful follow-up TODOs, run tests/lint/build when available, and keep going while work remains.
910
297
  ```
911
298
 
912
- ### `--safe`
913
-
914
- Adds safety instructions to prompt actions and blocks obviously destructive shell actions.
299
+ ## Test-fix loop
915
300
 
916
301
  ```text
917
- /loop 0s --safe continue from progress.md
302
+ /loop 0s --name testfix --ask-never --safe --verify "npm test" --max-failures 3 Continue from progress.md. If tests fail, analyze the failure, fix it, and run the tests again.
918
303
  ```
919
304
 
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.
305
+ ## Background daemon
921
306
 
922
- ### `--batch <n>`
307
+ The normal `/loop` plugin is session-bound. If OpenCode closes, that TUI/session loop cannot keep running in the background.
923
308
 
924
- Tell the agent to process at most N TODO items per run.
309
+ For long-running background jobs use:
925
310
 
926
- ```text
927
- /loop 0s --batch 5 continue from progress.md
311
+ ```bash
312
+ opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
928
313
  ```
929
314
 
930
- ### `--quiet`
931
-
932
- Tell the agent to keep replies short.
315
+ Run immediately on each daemon iteration:
933
316
 
934
- ```text
935
- /loop 0s --quiet continue from progress.md
317
+ ```bash
318
+ opencode-loopd --project . --every 0s --prompt "continue from progress.md and implement the next unfinished TODO"
936
319
  ```
937
320
 
938
- ### `--ask-never`
939
-
940
- Tell the agent not to ask questions and to make reasonable assumptions.
321
+ Select a model and agent:
941
322
 
942
- ```text
943
- /loop 0s --ask-never continue from progress.md
323
+ ```bash
324
+ opencode-loopd --project . --every 0s --max-runs 1 --model provider/model --agent build --prompt-file loop-prompt.md
944
325
  ```
945
326
 
946
- ### `--progress-file <file>`
947
-
948
- Tell the agent which state file to treat as the main progress/TODO source.
327
+ Limit total runs:
949
328
 
950
- ```text
951
- /loop 0s --progress-file progress.md continue from the progress file
329
+ ```bash
330
+ opencode-loopd --project . --every 5m --max-runs 20 --prompt-file loop-prompt.md
952
331
  ```
953
332
 
954
- ### `--watch <file>`
333
+ ## Windows Task Scheduler
955
334
 
956
- Run when watched file metadata changes. This is still checked on idle events.
335
+ Install a scheduled daemon task:
957
336
 
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
337
+ ```powershell
338
+ opencode-loopd install-task --project "C:\path\to\project" --every 10m --prompt-file loop-prompt.md --name OpenCodeLoop
961
339
  ```
962
340
 
963
- You can pass multiple `--watch` flags.
964
-
965
- ### `--dry-run`
966
-
967
- Parse and preview a loop without saving it.
341
+ Remove it:
968
342
 
969
- ```text
970
- /loop 0s --dry-run --ask-never continue from progress.md
343
+ ```powershell
344
+ opencode-loopd uninstall-task --name OpenCodeLoop
971
345
  ```
972
346
 
973
- ### `--now` and `--no-now`
347
+ ## Experimental Loop Goal Mode
974
348
 
975
- By default `/loop` prompt jobs are due immediately. Use `--no-now` to wait for the first interval.
349
+ Loop’s original Goal Mode remains available for existing users:
976
350
 
977
351
  ```text
978
- /loop 1h --no-now did you run tests, tsc --noEmit, and build?
352
+ /loop-goal --check "npm test" --complete-when-checks-pass fix the failing tests
979
353
  ```
980
354
 
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.
355
+ Controls:
982
356
 
983
357
  ```text
984
- /loop-command 200m /compact
985
- /loop-command 200m --now /compact
358
+ /loop-goal-status
359
+ /loop-goal-pause
360
+ /loop-goal-resume
361
+ /loop-goal-clear
362
+ /loop-goal-done <summary>
363
+ /loop-goal-blocked <reason>
986
364
  ```
987
365
 
988
- ## Recommended recipes
989
-
990
- ### Claude Code style auto-continue loop
366
+ It supports acceptance criteria, check commands, evidence text, no-progress guards, turn/runtime limits, and reports under:
991
367
 
992
368
  ```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.
369
+ .opencode/opencode-loop/goals/
994
370
  ```
995
371
 
996
- ### Long-running autonomous development loop
372
+ For new work where completion integrity matters, prefer the dedicated **OpenCode Goals** package instead:
997
373
 
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.
374
+ ```bash
375
+ npx -y @bybrawe/opencode-goal@latest
1000
376
  ```
1001
377
 
1002
- ### Daemon-based long-running development loop
378
+ or:
1003
379
 
1004
380
  ```bash
1005
- opencode-loopd --project . --every 5m --prompt-file loop-prompt.md
381
+ npm install -g @bybrawe/opencode-goal@latest
382
+ opencode-goal
1006
383
  ```
1007
384
 
1008
- ### Test-fix loop
385
+ ## State and checkpoints
386
+
387
+ Loop runtime state:
1009
388
 
1010
389
  ```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.
390
+ .opencode/opencode-loop/
1012
391
  ```
1013
392
 
1014
- ### Compact loop
393
+ Patch checkpoints:
1015
394
 
1016
395
  ```text
1017
- /loop-command 200m /compact
396
+ .opencode/opencode-loop/checkpoints/
1018
397
  ```
1019
398
 
1020
- This compacts every 200 minutes when OpenCode is idle. It does not interrupt an active agent turn.
1021
-
1022
- ### Scheduled quality-check question
399
+ Recent plugin events:
1023
400
 
1024
401
  ```text
1025
- /loop-ask 1h did you run tests, tsc --noEmit, and build? If not, run them now and fix errors.
402
+ .opencode/opencode-loop/loop.log
1026
403
  ```
1027
404
 
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
405
+ Add `.opencode/opencode-loop/` to `.gitignore` when you do not want runtime noise committed.
1031
406
 
1032
- ```text
1033
- /loop 0s --name dev --prompt-file loop-prompt.md --checkpoint-only --max-runtime 6h
1034
- ```
407
+ ## Suggested OpenCode permissions
1035
408
 
1036
- ## Suggested OpenCode permission config
409
+ For unattended loops, avoid granting every shell command permanently. Allow routine read/edit/test operations and keep destructive operations on ask/deny.
1037
410
 
1038
- Full `permission: "allow"` is convenient but risky. For safer long loops, keep destructive commands as ask/deny.
411
+ Example:
1039
412
 
1040
413
  ```json
1041
414
  {
@@ -1053,182 +426,32 @@ Full `permission: "allow"` is convenient but risky. For safer long loops, keep d
1053
426
  "npm test*": "allow",
1054
427
  "npm run test*": "allow",
1055
428
  "npm run lint*": "allow",
1056
- "pnpm test*": "allow",
1057
- "pnpm lint*": "allow",
1058
429
  "git push*": "ask",
1059
430
  "git reset*": "ask",
1060
431
  "git clean*": "deny",
1061
- "rm *": "deny",
1062
- "del *": "ask",
1063
- "rmdir *": "ask"
432
+ "rm *": "deny"
1064
433
  },
1065
434
  "external_directory": "ask"
1066
435
  }
1067
436
  }
1068
437
  ```
1069
438
 
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.
439
+ `--safe` reduces risk but does not replace careful OpenCode permission configuration.
1091
440
 
1092
- ## Example progress.md
1093
-
1094
- Create one with:
441
+ ## Package
1095
442
 
1096
443
  ```text
1097
- /loop-init
444
+ @bybrawe/opencode-loop
1098
445
  ```
1099
446
 
1100
- Example content:
1101
-
1102
- ```md
1103
- # Progress
1104
-
1105
- ## Current Goal
1106
- Improve the application in small safe steps.
447
+ The package also installs:
1107
448
 
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.
449
+ ```bash
450
+ opencode-loop --help
451
+ opencode-loopd --help
1131
452
  ```
1132
453
 
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.
454
+ See [CHANGELOG.md](./CHANGELOG.md) for release history.
1232
455
 
1233
456
  ## License
1234
457