opencode-routines 0.1.3 → 0.1.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.
Files changed (2) hide show
  1. package/dist/tui.js +85 -54
  2. package/package.json +1 -1
package/dist/tui.js CHANGED
@@ -111,11 +111,92 @@ function showLoops(api) {
111
111
  }
112
112
  }));
113
113
  }
114
+ function openLoopPrompt(api) {
115
+ const sessionID = activeSessionID(api);
116
+ if (!sessionID) {
117
+ api.ui.toast({ variant: "warning", message: "Open a session before starting /loop." });
118
+ return;
119
+ }
120
+ api.ui.dialog.replace(() => api.ui.DialogPrompt({
121
+ title: "Start loop",
122
+ placeholder: "5m /babysit-prs or /babysit-prs",
123
+ onConfirm: (value) => {
124
+ const parsed = parseLoop(value);
125
+ if (!parsed) {
126
+ api.ui.toast({ variant: "warning", message: "Usage: /loop 5m <prompt> or /loop <prompt>" });
127
+ return;
128
+ }
129
+ const loop = {
130
+ id: loopID(),
131
+ sessionID,
132
+ prompt: parsed.prompt,
133
+ mode: parsed.intervalSeconds === undefined ? "dynamic" : "fixed",
134
+ intervalSeconds: parsed.intervalSeconds,
135
+ createdAt: new Date().toISOString(),
136
+ fires: 0
137
+ };
138
+ loops.set(loop.id, loop);
139
+ if (loop.mode === "fixed")
140
+ scheduleFixed(api, loop);
141
+ else
142
+ submitPrompt(api, loop);
143
+ api.ui.toast({
144
+ variant: "success",
145
+ title: "Loop started",
146
+ message: loop.mode === "fixed" ? `${loop.id} every ${loop.intervalSeconds}s` : `${loop.id} dynamic mode; use ScheduleWakeup to continue`
147
+ });
148
+ api.ui.dialog.clear();
149
+ }
150
+ }));
151
+ }
152
+ function showStandaloneSchedulesHelp(api) {
153
+ api.ui.dialog.replace(() => api.ui.DialogAlert({
154
+ title: "Standalone schedules",
155
+ message: "Use the ScheduleCreate tool (or natural language like 'create a standalone scheduled run...') to create durable OS-backed standalone sessions. The ambiguous /schedule command is intentionally not registered."
156
+ }));
157
+ }
158
+ function legacyCommands(api) {
159
+ return [
160
+ {
161
+ title: "Start same-session loop",
162
+ value: "routines.loop",
163
+ description: "Start a same-session loop. Fixed: 5m <prompt>; dynamic: <prompt>.",
164
+ category: "Scheduler",
165
+ slash: { name: "loop" },
166
+ onSelect: () => openLoopPrompt(api)
167
+ },
168
+ {
169
+ title: "List active loops",
170
+ value: "routines.loops",
171
+ description: "List and stop active same-session loops.",
172
+ category: "Scheduler",
173
+ slash: { name: "loops" },
174
+ onSelect: () => showLoops(api)
175
+ },
176
+ {
177
+ title: "Stop a same-session loop",
178
+ value: "routines.stop-loop",
179
+ description: "List active loops and select one to stop.",
180
+ category: "Scheduler",
181
+ slash: { name: "stop-loop" },
182
+ onSelect: () => showLoops(api)
183
+ },
184
+ {
185
+ title: "Create standalone scheduled session",
186
+ value: "routines.schedule-standalone-session",
187
+ description: "Show help for durable OS-backed standalone schedules.",
188
+ category: "Scheduler",
189
+ slash: { name: "schedule-standalone-session" },
190
+ onSelect: () => showStandaloneSchedulesHelp(api)
191
+ }
192
+ ];
193
+ }
114
194
  var tui = async (api) => {
115
195
  api.lifecycle.onDispose(() => {
116
196
  for (const id of [...loops.keys()])
117
197
  stopLoop(id);
118
198
  });
199
+ api.command?.register(() => legacyCommands(api));
119
200
  api.keymap.registerLayer({
120
201
  commands: [
121
202
  {
@@ -123,78 +204,28 @@ var tui = async (api) => {
123
204
  title: "Start same-session loop",
124
205
  category: "Scheduler",
125
206
  namespace: "palette",
126
- slashName: "loop",
127
- run() {
128
- const sessionID = activeSessionID(api);
129
- if (!sessionID) {
130
- api.ui.toast({ variant: "warning", message: "Open a session before starting /loop." });
131
- return;
132
- }
133
- api.ui.dialog.replace(() => api.ui.DialogPrompt({
134
- title: "Start loop",
135
- placeholder: "5m /babysit-prs or /babysit-prs",
136
- onConfirm: (value) => {
137
- const parsed = parseLoop(value);
138
- if (!parsed) {
139
- api.ui.toast({ variant: "warning", message: "Usage: /loop 5m <prompt> or /loop <prompt>" });
140
- return;
141
- }
142
- const loop = {
143
- id: loopID(),
144
- sessionID,
145
- prompt: parsed.prompt,
146
- mode: parsed.intervalSeconds === undefined ? "dynamic" : "fixed",
147
- intervalSeconds: parsed.intervalSeconds,
148
- createdAt: new Date().toISOString(),
149
- fires: 0
150
- };
151
- loops.set(loop.id, loop);
152
- if (loop.mode === "fixed")
153
- scheduleFixed(api, loop);
154
- else
155
- submitPrompt(api, loop);
156
- api.ui.toast({
157
- variant: "success",
158
- title: "Loop started",
159
- message: loop.mode === "fixed" ? `${loop.id} every ${loop.intervalSeconds}s` : `${loop.id} dynamic mode; use ScheduleWakeup to continue`
160
- });
161
- api.ui.dialog.clear();
162
- }
163
- }));
164
- }
207
+ run: () => openLoopPrompt(api)
165
208
  },
166
209
  {
167
210
  name: "routines.loops",
168
211
  title: "List active loops",
169
212
  category: "Scheduler",
170
213
  namespace: "palette",
171
- slashName: "loops",
172
- run() {
173
- showLoops(api);
174
- }
214
+ run: () => showLoops(api)
175
215
  },
176
216
  {
177
217
  name: "routines.stop_loop",
178
218
  title: "Stop a same-session loop",
179
219
  category: "Scheduler",
180
220
  namespace: "palette",
181
- slashName: "stop-loop",
182
- run() {
183
- showLoops(api);
184
- }
221
+ run: () => showLoops(api)
185
222
  },
186
223
  {
187
224
  name: "routines.schedule_standalone_session",
188
225
  title: "Create standalone scheduled session",
189
226
  category: "Scheduler",
190
227
  namespace: "palette",
191
- slashName: "schedule-standalone-session",
192
- run() {
193
- api.ui.dialog.replace(() => api.ui.DialogAlert({
194
- title: "Standalone schedules",
195
- message: "Use the ScheduleCreate tool (or natural language like 'create a standalone scheduled run...') to create durable OS-backed standalone sessions. The ambiguous /schedule command is intentionally not registered."
196
- }));
197
- }
228
+ run: () => showStandaloneSchedulesHelp(api)
198
229
  }
199
230
  ]
200
231
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-routines",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "OpenCode routines: same-session loops, cron prompts, and host-backed standalone scheduled agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",