Skip to content

feat(plugin): extract opencode-webhooks as a publishable package - #10

Merged
MathurAditya724 merged 3 commits into
mainfrom
feat/extract-webhooks-plugin-package
May 1, 2026
Merged

feat(plugin): extract opencode-webhooks as a publishable package#10
MathurAditya724 merged 3 commits into
mainfrom
feat/extract-webhooks-plugin-package

Conversation

@MathurAditya724

Copy link
Copy Markdown
Member

Extracts the github-webhooks plugin from this image-specific repo into a standalone, publishable npm package at packages/opencode-webhooks/. Other OpenCode users can now consume it the same way they consume @loreai/opencodebun add + add to the plugin: [...] array.

This image's behavior is unchanged. Internal consumption uses a file: dep in opencode-config-package.json so bun install resolves the package into ~/.config/opencode/node_modules/opencode-webhooks/ at build time.

What changed

  • New package: packages/opencode-webhooks/ with its own package.json (MIT, peer dep on @opencode-ai/plugin), tsconfig.json, README.md (full config schema + install instructions), LICENSE, and src/ (11 files moved from plugins/github-webhooks/).
  • Source moves detected as renames by git — semantic edits per file are minimal:
    • index.ts: import paths flattened (./github-webhooks/X./X), default DB path changed from ~/dev/.opencode/github-webhooks.sqlite to ${XDG_DATA_HOME:-~/.local/share}/opencode-webhooks/deliveries.sqlite, type re-exports added so consumers can author config-generators with type safety.
    • All files: log prefix [github-webhooks][opencode-webhooks].
    • handler.ts: /healthz response field {plugin: "github-webhooks"}{plugin: "opencode-webhooks"}. Public API surface change — anyone scripting health checks against this string needs to update.
  • Image wiring:
    • opencode-config-package.json declares "opencode-webhooks": "file:./packages/opencode-webhooks". bun.lock regenerated.
    • opencode-user-config.json references the resolved absolute path in its plugin array (matches the existing @loreai/opencode entry).
    • Dockerfile: COPY plugins/COPY packages/, comments updated.
    • webhooks.json: explicit db_path: "/home/developer/dev/.opencode/github-webhooks.sqlite" added to preserve the existing dedup history (~1000 entries) on the cutover. Without this, the new XDG default would orphan the existing DB.
  • Deletions: plugins/github-webhooks.ts + plugins/github-webhooks/*.ts (all 11 files) — no shim file, package is the single source of truth.
  • Plan + README updates: .opencode/plans/extract-webhooks-plugin-package.md documents the design, including a fact-check against OpenCode's plugin docs. Repo README, .env.example updated to point at the new location and explain the new layout.

Testing

  • tsc --noEmit clean against the new tsconfig.json (with @opencode-ai/plugin and @types/bun as devDeps).
  • bun install clean against the updated opencode-config-package.json (verified by mocking the install in /tmp/; lock file updated).
  • jq valid on webhooks.json, opencode-config-package.json, opencode-user-config.json, package.json.
  • Container boot test: not run locally yet. The Dockerfile path is exercised by the build pipeline; if bun install fails to resolve the file: dep at image-build time, the build will fail loudly. Worth a smoke test once this lands.

Out of scope (tracked in plan doc)

  • npm publishing workflow.
  • Decoupling the gh CLI dependency.
  • Tests (the original plugin had none; not adding here to keep the diff focused).
  • Schema validation for webhooks.json (would be a behavior change).
  • Session reuse + event buffering (separate plan doc, separate PR).

After publish to npm

The plan doc captures a follow-up to simplify the image's wiring: drop the file: dep from opencode-config-package.json, replace the absolute file:// URL in opencode-user-config.json with the bare name "opencode-webhooks", drop the COPY packages/ Dockerfile step. OpenCode auto-installs npm-named plugins into ~/.cache/opencode/node_modules/ at startup.

Moves the github-webhooks plugin from `plugins/github-webhooks{,.ts}` to
`packages/opencode-webhooks/` so it can be published to npm and consumed
by other OpenCode users via the standard `plugin: ["opencode-webhooks"]`
config pattern (matching how lore is consumed today).

Internal consumption (this image) is unchanged in behavior:
- `opencode-config-package.json` declares the package as a `file:` dep,
- Dockerfile copies `packages/` and `bun install` resolves it into
  `~/.config/opencode/node_modules/opencode-webhooks/`,
- `opencode-user-config.json` references the resolved path.

Decoupling: only the default DB path changed. Was hardcoded to
`~/dev/.opencode/github-webhooks.sqlite` (assumes the image's symlinked
volume); now defaults to `${XDG_DATA_HOME:-~/.local/share}/opencode-webhooks/deliveries.sqlite`.
The image's existing `webhooks.json` is updated with an explicit
`db_path` override to preserve the existing dedup history.

Other behavior is bit-identical:
- HMAC verification, identity gating, payload filters, prompt templating,
  bot identity resolution via `gh api user` — all unchanged.
- The plugin's log prefix changed `[github-webhooks]` → `[opencode-webhooks]`
  to match the package name.
- Health check response field changed from `{plugin: "github-webhooks"}`
  to `{plugin: "opencode-webhooks"}` (public API surface, callout in PR).

Out of scope and tracked as follow-ups in the plan doc:
- npm publishing workflow (will simplify the image's wiring once shipped),
- decoupling the `gh` CLI dependency,
- session reuse + event buffering.

See `.opencode/plans/extract-webhooks-plugin-package.md` for the full
design rationale, including a fact-check against OpenCode's plugin docs.
Plans, scratch notes, and OpenCode session data are local-only.
The two plan docs that landed in #9 and earlier in this PR are
removed from tracking but remain on disk; past commits still
carry their content for anyone reading history.
@MathurAditya724
MathurAditya724 marked this pull request as ready for review May 1, 2026 18:40
Two minor review-followup items on PR #10:

1. peerDependencies floor was `@opencode-ai/plugin: >=1.1.0` but version
   1.1.0 was never published to npm. The first existing version
   at-or-above the stated floor is 1.1.1. Range was still semver-valid
   so nothing broke, just an arbitrary floor — bump to >=1.1.1 so the
   stated floor is also resolvable.

2. Source-only TS distribution requires Bun at runtime (uses Bun.serve,
   Bun.spawn, Bun.file, bun:sqlite). README documents this and
   engines.bun is declared, but engines is advisory and a Node-on-Bun-
   fork consumer would have hit a cryptic ReferenceError on first
   dispatch. Add an explicit guard at the top of the plugin function
   that throws a useful message pointing at bun.sh.
@MathurAditya724
MathurAditya724 merged commit e2c744b into main May 1, 2026
1 check passed
@MathurAditya724
MathurAditya724 deleted the feat/extract-webhooks-plugin-package branch May 1, 2026 18:57
MathurAditya724 added a commit that referenced this pull request Aug 7, 2026
…op (#138)

The Agent runs table followed the API's `updatedAt desc` order, so the list
reshuffled on every refresh and working runs could sit anywhere. Sort the
rendered rows client-side: working/busy runs float to the top, everything else
falls back to a natural, name-based order (numeric so #2 precedes #10), giving a
stable table where the runs you care about are always up front.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant