Thank you for your interest in contributing. This guide covers the development workflow and the patterns for extending the plugin.
git clone https://github.com/HiAi-gg/hiai-opencode.git
cd hiai-opencode
bun install
bun run build| Task | Command |
|---|---|
| Build | bun run build |
| Typecheck | bun run typecheck |
| Test | bun test |
| Lint | bun run lint |
| Check docs for private paths / Cyrillic | bun run scripts/check-docs.ts |
- Run
bun run typecheckandbun testbefore submitting. - Keep PRs focused — one logical change per PR.
- Follow existing naming conventions in the directory you are editing.
- Do not add Node.js-specific dependencies — this is a Bun-first project.
Agents are authored as flat files under src/agents/. Checklist:
- Agent prompt — Create
src/agents/<name>.tsexporting the prompt string (assembled fromsrc/prompt-library/*fragments). - Shared fragments — Add reusable policy blocks in src/prompt-library/ if the agent has shared prompt sections.
- Registration — Add the agent to
createAllAgents()in src/agents/index.ts, OR native-upgrade it inline in thehooks.configcallback in src/index.ts (asexplore/plan/build/generaldo). - Default config — Add the model slot to
DEFAULT_CONFIGin src/config.ts and to the 10-slot validation inREQUIRED_AGENT_KEYS. - Permissions — Add per-agent restrictions to
DEFAULT_CONFIG.agent_restrictionsin src/config.ts (resolved byapplyAgentPermissionsin src/permissions.ts). - bob.json — Add the model slot to bob.json (the bundled canonical config).
- README.md — Update the agent table in the Agents section.
- Tests — Add a prompt snapshot test next to the source:
src/agents/<name>.test.ts.
- Tool factory — Create the tool implementation in
src/tools/<name>.ts(orsrc/tools/<name>/index.tsfor multi-file tools). - Tool registration — Register the tool in the
hooks.toolobject in src/index.ts. - Permissions — If the tool needs per-agent restrictions, add its key to
TOOLS_KEYSin src/permissions.ts. - Tests — Add unit tests next to the source:
src/tools/<name>.test.ts.
Hooks live as flat files in src/hooks/. Each exports a create<Name>Hook(config: BobConfig): HookSet factory.
- Create the hook factory in
src/hooks/<hook-name>.ts. - Register it in
ALL_NAMED_HOOK_FACTORIESin src/hooks/index.ts. - Write tests next to the source:
src/hooks/<hook-name>.test.ts.
Hooks are chained via combineHookSets. Throw BlockingHookError (from src/hooks/errors.ts) for hard gates that must halt the pipeline; regular errors are logged and swallowed.
- TypeScript strict mode — no
anyunless unavoidable. - ESM-only — use
import/export, norequire(). - Bun runtime —
Bun.$,bun:test,bun buildare all available. - Descriptive variable names — prefer clarity over brevity.
- Small, focused functions — if a function exceeds ~80 lines, consider splitting.
- Co-locate tests —
foo.tsandfoo.test.tslive side by side.