This package is an OpenCode plugin with separate server and TUI entrypoints:
src/server.tsis the server plugin. It registers the/goalcommand, goal tools, chat/session hooks, usage accounting, compaction context, and idle auto-continuation.src/state.tsowns goal persistence and lifecycle state. It stores JSON atOPENCODE_GOAL_STATE_PATHwhen set, otherwise under the user's OpenCode data location.src/tui.tsxis the Solid/OpenTUI sidebar and command-palette UI. It is exported as source, so avoid adding heavy runtime dependencies here unless there is a strong reason.src/prompts.tscontains the goal-mode continuation/system/compaction prompts.test/covers state, server hooks/tools, and TUI behavior with Bun tests.
- Preserve the public Promise-based state API (
getGoal,createGoal,completeGoal, etc.) because OpenCode hooks and tests call it directly. - Keep
zodfor OpenCode tool argument schemas unless the OpenCode plugin API explicitly supports another schema format. - Effect is intentionally used in the state/persistence boundary. Do not spread Effect into the TUI unless the benefit clearly outweighs the extra runtime footprint.
- If server code imports a runtime dependency that should be resolved from
dependencies, externalize it in the Bun build script so the package does not silently bundle it. - State writes should remain atomic: write to a temp file, then
renameinto place. - Use
OPENCODE_GOAL_STATE_PATHfor tests and smoke runs so you do not touch a real user's goal state.
Before treating a code change as complete, run the relevant checks. For release-level changes, run the full local gate:
bun run lint
bun run typecheck
bun test
bun run build
bun run pack:dry-runbun run build writes dist/server.js. The package only publishes dist, src/tui.tsx, LICENSE, and README.md, so confirm npm pack --dry-run includes what runtime installation needs.
This repo publishes from GitHub Actions on pushes to main. The workflow computes the next patch version from npm, builds, publishes, and creates a GitHub release.
After pushing a release change, monitor the workflow with gh run list --branch main and gh run watch <run-id> --exit-status. Verify the release and package metadata after success:
npm view @prevalentware/opencode-goal-plugin version dependencies
gh release view v<version>To test this plugin end to end, do not stop at unit tests. Run the local gates first: bun run lint, bun run typecheck, bun test, bun run build, and bun run pack:dry-run.
After publishing, verify the exact npm version with npm view @prevalentware/opencode-goal-plugin version dependencies. Install that version in an isolated temp OpenCode project with opencode plugin @prevalentware/opencode-goal-plugin@<version>, run opencode debug config to confirm the package is loaded and the goal command is registered, then run a smoke test with an isolated state file, for example:
OPENCODE_GOAL_STATE_PATH="/tmp/opencode-goal-plugin-smoke/goals.json" opencode run "/goal create a smoke-test goal and then report the current goal state"The smoke test should show create_goal and get_goal tool calls and report an active goal. Inspect the state file afterward if you need to confirm JSON persistence.