@malico/opencode-loop 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -0
  2. package/package.json +9 -1
package/dist/index.js CHANGED
@@ -12519,6 +12519,10 @@ class LoopStore {
12519
12519
  close() {
12520
12520
  this.db.close();
12521
12521
  }
12522
+ findExistingLoop(input) {
12523
+ const cleanPrompt = input.prompt.trim().toLowerCase().replace(/\s+/g, " ");
12524
+ return this.getSessionLoops(input.sessionId, true).find((loop) => loop.intervalMs === input.intervalMs && loop.prompt.trim().toLowerCase().replace(/\s+/g, " ") === cleanPrompt);
12525
+ }
12522
12526
  createLoop(input) {
12523
12527
  const timestamp = now();
12524
12528
  const loop = {
@@ -13056,6 +13060,11 @@ var LoopPlugin = async ({ client }, options) => {
13056
13060
  const prompt = args.prompt.trim();
13057
13061
  if (!prompt)
13058
13062
  return "Missing loop prompt.";
13063
+ const existing = store.findExistingLoop({ sessionId: context.sessionID, prompt, intervalMs: interval.intervalMs });
13064
+ if (existing) {
13065
+ queueLoop(existing.id);
13066
+ return `Loop ${shortId(existing.id)} already exists. Next iteration queued.`;
13067
+ }
13059
13068
  const loop = store.createLoop({ sessionId: context.sessionID, prompt, intervalMs: interval.intervalMs });
13060
13069
  queueLoop(loop.id);
13061
13070
  return `Started loop ${shortId(loop.id)} every ${formatDuration(loop.intervalMs)}. First iteration will run when this session becomes idle.`;
@@ -13131,6 +13140,15 @@ var LoopPlugin = async ({ client }, options) => {
13131
13140
  output.parts = [makeTextPart(commandResult(statusText(store, sessionId)))];
13132
13141
  return;
13133
13142
  }
13143
+ if (input.arguments?.trim().toLowerCase().match(/^(exit|quit|q)$/)) {
13144
+ const active = store.getSessionLoops(sessionId, true);
13145
+ if (active.length) {
13146
+ output.parts = [
13147
+ makeTextPart(commandResult(`You have ${active.length} active loop(s) in this session: ${active.map((loop2) => shortId(loop2.id)).join(", ")}. Cancel them first with \`/loop cancel\`, or run \`/loop exit\` to quit anyway.`))
13148
+ ];
13149
+ return;
13150
+ }
13151
+ }
13134
13152
  if (parsed.type === "cancel") {
13135
13153
  const cancelled = store.cancelLoops(sessionId, parsed.target);
13136
13154
  const cancelledRuns = store.cancelRunningRuns(cancelled);
@@ -13164,6 +13182,12 @@ var LoopPlugin = async ({ client }, options) => {
13164
13182
  output.parts = [makeTextPart(commandResult(`Interval too short. Minimum is ${formatDuration(minIntervalMs)}.`))];
13165
13183
  return;
13166
13184
  }
13185
+ const existing = store.findExistingLoop({ sessionId, prompt: parsed.prompt, intervalMs: parsed.intervalMs });
13186
+ if (existing) {
13187
+ queueLoop(existing.id);
13188
+ output.parts = [makeTextPart(commandResult(`Loop ${shortId(existing.id)} already exists. Next iteration queued.`))];
13189
+ return;
13190
+ }
13167
13191
  const loop = store.createLoop({ sessionId, prompt: parsed.prompt, intervalMs: parsed.intervalMs });
13168
13192
  queueLoop(loop.id);
13169
13193
  output.parts = [makeTextPart(commandResult(`Started loop ${shortId(loop.id)} every ${formatDuration(loop.intervalMs)}. First iteration queued now.`))];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malico/opencode-loop",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Session-tied fixed-delay loops for OpenCode",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -27,6 +27,14 @@
27
27
  "automation"
28
28
  ],
29
29
  "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/yondifon/opencode-loop.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/yondifon/opencode-loop/issues"
36
+ },
37
+ "homepage": "https://github.com/yondifon/opencode-loop#readme",
30
38
  "dependencies": {
31
39
  "@opencode-ai/plugin": "^1.0.162"
32
40
  },