@bybrawe/opencode-loop 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +755 -706
- package/commands/loop-clear.md +2 -2
- package/commands/loop-compact.md +2 -2
- package/commands/loop-dev.md +2 -2
- package/commands/loop-doctor.md +2 -2
- package/commands/loop-export.md +2 -2
- package/commands/loop-help.md +2 -2
- package/commands/loop-init.md +2 -2
- package/commands/loop-logs.md +2 -2
- package/commands/loop-now.md +2 -2
- package/commands/loop-pause.md +2 -2
- package/commands/loop-progress.md +2 -2
- package/commands/loop-remove.md +2 -2
- package/commands/loop-resume.md +2 -2
- package/commands/loop-safe-dev.md +2 -2
- package/commands/loop-status.md +2 -2
- package/commands/loop-stop.md +2 -2
- package/commands/loop-testfix.md +2 -2
- package/commands/loop.md +2 -2
- package/package.json +1 -1
- package/src/index.js +37 -3
package/commands/loop-clear.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-compact.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-dev.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-doctor.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-export.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-help.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Show OpenCode Loop help
|
|
2
|
+
description: Show OpenCode Loop help.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-init.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-logs.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Show
|
|
2
|
+
description: Show OpenCode Loop logs.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-now.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-pause.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-remove.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-resume.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-status.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Show
|
|
2
|
+
description: Show OpenCode Loop status.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-stop.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Stop
|
|
2
|
+
description: Stop OpenCode Loop jobs.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop-testfix.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: OpenCode Loop plugin command.
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/commands/loop.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Start an OpenCode
|
|
2
|
+
description: Start an OpenCode auto-continue loop. Usage: /loop 5m <task>
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Loop command received. The OpenCode Loop plugin handles this command. Do not explain this command, do not search the web, do not create scheduler files, and do not run extra shell commands because of this command.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bybrawe/opencode-loop",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Claude Code style auto-continue /loop command for OpenCode: autonomous loops, compact scheduling, progress.md TODO automation, verification, checkpoints, and safe long-running coding sessions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/index.js
CHANGED
|
@@ -186,6 +186,7 @@ function parseLoopArgs(raw, defaults = {}) {
|
|
|
186
186
|
gitCheckpoint: defaults.gitCheckpoint ?? false,
|
|
187
187
|
checkpointOnly: defaults.checkpointOnly ?? false,
|
|
188
188
|
dryRun: defaults.dryRun ?? false,
|
|
189
|
+
multi: defaults.multi ?? false,
|
|
189
190
|
batch: defaults.batch ?? 0,
|
|
190
191
|
runCount: 0,
|
|
191
192
|
failureCount: 0,
|
|
@@ -212,6 +213,8 @@ function parseLoopArgs(raw, defaults = {}) {
|
|
|
212
213
|
;[found, rest] = takeFlag(rest, "--checkpoint-only"); if (found) job.checkpointOnly = true
|
|
213
214
|
;[found, rest] = takeFlag(rest, "--pause-on-verify-fail"); if (found) job.pauseOnVerifyFail = true
|
|
214
215
|
;[found, rest] = takeFlag(rest, "--dry-run"); if (found) job.dryRun = true
|
|
216
|
+
;[found, rest] = takeFlag(rest, "--multi"); if (found) job.multi = true
|
|
217
|
+
;[found, rest] = takeFlag(rest, "--replace"); if (found) job.multi = false
|
|
215
218
|
|
|
216
219
|
;[value, rest] = takeFlagValue(rest, "--name"); if (value !== undefined) job.name = value.trim()
|
|
217
220
|
;[value, rest] = takeFlagValue(rest, "--max-runs"); if (value !== undefined) job.maxRuns = parsePositiveInt(value, 0)
|
|
@@ -606,7 +609,7 @@ async function fireAction(directory, client, sessionID, job) {
|
|
|
606
609
|
return { startsAssistantTurn: true }
|
|
607
610
|
}
|
|
608
611
|
const prompt = await buildPrompt(directory, job)
|
|
609
|
-
client.session.prompt({ path: { id: sessionID }, body: { parts: [{ type: "text", text: `
|
|
612
|
+
client.session.prompt({ path: { id: sessionID }, body: { parts: [{ type: "text", text: `AUTONOMOUS OPENCODE LOOP ITERATION. Continue the configured task now. Do not explain the /loop command. Do not search for documentation about this plugin. Do not create scheduler files. Do not ask questions. Make reasonable assumptions and work directly.\n\n${prompt}` }] } }).catch(() => {})
|
|
610
613
|
return { startsAssistantTurn: true }
|
|
611
614
|
}
|
|
612
615
|
|
|
@@ -699,16 +702,47 @@ async function maybeRunDueJobs(directory, client, sessionID, options = {}) {
|
|
|
699
702
|
}
|
|
700
703
|
}
|
|
701
704
|
|
|
705
|
+
function normalizeActionForCompare(value) {
|
|
706
|
+
return String(value || "").replace(/\s+/g, " ").trim()
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function sameLoopDefinition(a, b) {
|
|
710
|
+
if (!a || !b) return false
|
|
711
|
+
return (a.name || "") === (b.name || "") &&
|
|
712
|
+
Number(a.intervalMs || 0) === Number(b.intervalMs || 0) &&
|
|
713
|
+
normalizeActionForCompare(a.action) === normalizeActionForCompare(b.action) &&
|
|
714
|
+
normalizeActionForCompare(a.promptFile) === normalizeActionForCompare(b.promptFile)
|
|
715
|
+
}
|
|
716
|
+
|
|
702
717
|
async function addLoop(directory, client, sessionID, args, defaults = {}) {
|
|
703
718
|
const parsed = parseLoopArgs(args, defaults)
|
|
704
719
|
if (!parsed.ok) { await toast(client, parsed.error, "warning"); return }
|
|
705
720
|
if (parsed.job.watchPaths.length) parsed.job.watchSnapshot = await snapshotPaths(directory, parsed.job.watchPaths)
|
|
706
721
|
if (parsed.job.dryRun) { await toast(client, `Loop dry run: ${jobLabel(parsed.job)}`, "info"); await say(client, sessionID, "OpenCode loop dry run:\n```json\n" + JSON.stringify(parsed.job, null, 2) + "\n```"); return }
|
|
707
722
|
const state = await readState(directory, sessionID)
|
|
723
|
+
const jobs = Array.isArray(state.jobs) ? state.jobs : []
|
|
724
|
+
|
|
725
|
+
// Default behavior is replace/upsert, not append forever. This prevents duplicate
|
|
726
|
+
// loops when OpenCode emits both command.execute.before and command.executed,
|
|
727
|
+
// and it matches the common expectation that /loop configures the current loop.
|
|
728
|
+
let replaced = false
|
|
729
|
+
if (!parsed.job.multi) {
|
|
730
|
+
const targetName = parsed.job.name || "default"
|
|
731
|
+
parsed.job.name = targetName
|
|
732
|
+
state.jobs = jobs.filter((existing) => {
|
|
733
|
+
const existingName = existing.name || "default"
|
|
734
|
+
const shouldReplace = existingName === targetName || sameLoopDefinition(existing, parsed.job)
|
|
735
|
+
if (shouldReplace) replaced = true
|
|
736
|
+
return !shouldReplace
|
|
737
|
+
})
|
|
738
|
+
} else {
|
|
739
|
+
state.jobs = jobs
|
|
740
|
+
}
|
|
741
|
+
|
|
708
742
|
state.jobs.push(parsed.job)
|
|
709
743
|
await writeState(directory, sessionID, state)
|
|
710
|
-
await toast(client,
|
|
711
|
-
await appendLoopLog(directory, "add", { sessionID, job: parsed.job.name || parsed.job.id, label: jobLabel(parsed.job) })
|
|
744
|
+
await toast(client, `${replaced ? "Loop replaced" : "Loop added"}: ${jobLabel(parsed.job)}`, "success")
|
|
745
|
+
await appendLoopLog(directory, replaced ? "replace" : "add", { sessionID, job: parsed.job.name || parsed.job.id, label: jobLabel(parsed.job) })
|
|
712
746
|
}
|
|
713
747
|
|
|
714
748
|
async function stopLoop(directory, client, sessionID, args) {
|