opencode-routines 0.1.3 → 0.1.5

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 -50
  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
  {
@@ -124,44 +205,7 @@ var tui = async (api) => {
124
205
  category: "Scheduler",
125
206
  namespace: "palette",
126
207
  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
- }
208
+ run: () => openLoopPrompt(api)
165
209
  },
166
210
  {
167
211
  name: "routines.loops",
@@ -169,9 +213,7 @@ var tui = async (api) => {
169
213
  category: "Scheduler",
170
214
  namespace: "palette",
171
215
  slashName: "loops",
172
- run() {
173
- showLoops(api);
174
- }
216
+ run: () => showLoops(api)
175
217
  },
176
218
  {
177
219
  name: "routines.stop_loop",
@@ -179,9 +221,7 @@ var tui = async (api) => {
179
221
  category: "Scheduler",
180
222
  namespace: "palette",
181
223
  slashName: "stop-loop",
182
- run() {
183
- showLoops(api);
184
- }
224
+ run: () => showLoops(api)
185
225
  },
186
226
  {
187
227
  name: "routines.schedule_standalone_session",
@@ -189,12 +229,7 @@ var tui = async (api) => {
189
229
  category: "Scheduler",
190
230
  namespace: "palette",
191
231
  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
- }
232
+ run: () => showStandaloneSchedulesHelp(api)
198
233
  }
199
234
  ]
200
235
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-routines",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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",