-
Notifications
You must be signed in to change notification settings - Fork 1
Development
-
opencode-plugin-loopandopencode-plugin-loop/server: scheduling server plugin -
opencode-plugin-loop/tui: native interactive result dialog - Root export: backward-compatible server entrypoint
OpenCode 1.17.18 or newer detects the server and TUI targets when the package is installed through opencode plugin.
Each task owns a sessionID. A 5-second ticker checks due tasks, but a task fires only when its session is active. Persistent state lives under .opencode/cache/loop/; deterministic jitter spreads execution times; TTL cleanup removes expired tasks; inflight guards prevent duplicate firing during overlapping ticks or hot reloads.
The server tracks the active session through OpenCode hooks. Session deletion cancels that session's tasks, and legacy persisted tasks without a sessionID are dropped during state migration.
git clone https://github.com/jkrandom-sudo/opencode-plugin-loop.git
cd opencode-plugin-loop
npm install
npm run build
npm test
opencode plugin "file:///absolute/path/to/opencode-plugin-loop" --global --forceRebuild after editing src/, then restart OpenCode to reload the file plugin.
scripts/build.mjs first runs TypeScript in declaration-only mode. It then compiles TypeScript and TSX with Babel. TUI TSX uses Solid's universal transform with @opentui/solid, which keeps selected-row style properties reactive in the OpenTUI renderer.
Published JavaScript and declarations are written to dist/. The package exposes the server, TUI, and bundled command definition through explicit package exports.
| File | Responsibility |
|---|---|
src/index.ts |
Plugin initialization, defaults, OpenCode hooks, ticker lifecycle |
src/scheduler.ts |
Command parsing, task scheduling, firing, pause/resume/cancel behavior |
src/store.ts |
Persistent task state, limits, TTL cleanup, session filtering |
src/tools/loop-tools.ts |
loop_schedule and loop_status tool definitions |
src/tui.ts |
TUI-only plugin entrypoint and dialog lifecycle |
src/tui-feedback-model.ts |
Recognition and modeling of plugin-owned feedback |
src/tui-dialog-actions.ts |
Copy ID, Copy all, Close actions and clipboard outcomes |
src/tui-dialog-interaction.ts |
Keyboard and mouse event mapping |
src/tui-dialog-layout.ts |
Responsive dialog sizing and viewport allocation |
src/tui-dialog-view.tsx |
Reactive OpenTUI dialog rendering |
Supporting modules include cron-parser.ts, jitter.ts, runtime-feedback.ts, and types.ts.
npm testThe test command builds fresh output before running all Node test files. Package tests also verify the published entrypoints and confirm that the compiled dialog contains Solid reactive updates rather than a static JSX runtime result.
Before publishing a change:
- Install the local file plugin and restart OpenCode.
- Create a fixed task, for example
/loop 1h local smoke test. - Run
/loop listand verify the task appears only in the current session. - Move through Copy ID, Copy all, and Close with Up/Down and Tab/Shift+Tab, including wraparound.
- Verify Enter and Space activate the selected action.
- Verify mouse hover changes selection and click activates the exact row.
- Confirm a successful copy closes the dialog and a clipboard failure keeps it open.
- Cancel the test task and verify
/loop listreports no tasks. - Run
npm testagain.