Skip to content

feat: add OpenCode plugin support (closes #6)#9

Open
alfasin wants to merge 1 commit intocytostack:mainfrom
alfasin:main
Open

feat: add OpenCode plugin support (closes #6)#9
alfasin wants to merge 1 commit intocytostack:mainfrom
alfasin:main

Conversation

@alfasin
Copy link
Copy Markdown

@alfasin alfasin commented Apr 5, 2026

Summary

Add OpenCode plugin support to OpenWolf via a new --opencode flag on openwolf init.

  • Creates OpenCode plugin at .opencode/plugin/openwolf.ts
  • Maps OpenCode's native hooks to OpenWolf's .wolf/ infrastructure
  • Injects OpenWolf protocol into OpenCode's system prompt via experimental.chat.system.transform

Changes

File Change
src/cli/init.ts Add initOpenCode() function, --opencode option handling
src/cli/index.ts Register --opencode CLI option
src/hooks/shared.ts Add projectDir param to getWolfDir(), new wolfDirExists()
tsconfig.json Exclude src/templates/*.ts from compilation
src/templates/opencode-plugin.ts OpenCode plugin implementation
src/templates/opencode-md-snippet.md Template for opencode.md injection

Usage

openwolf init --opencode

This creates:

  • .wolf/ directory with all OpenWolf infrastructure
  • .opencode/plugin/openwolf.ts - the plugin
  • Updates opencode.md with OpenWolf instructions

Add --opencode flag to 'openwolf init' for registering OpenCode plugin
instead of Claude Code hooks.

- Create OpenCode plugin directory with separated modules:
  - types.ts: interfaces for SessionState, FileRead, FileWrite, etc.
  - fs.ts: file system helpers (readJSON, writeJSON, etc.)
  - anatomy.ts: anatomy.md parsing and serialization
  - session.ts: session start handling
  - pre-read.ts: repeated read warnings, anatomy lookups
  - pre-write.ts: cerebrum check, buglog lookup
  - post-read.ts: token estimation
  - post-write.ts: anatomy update, memory append, bug detection
  - stop.ts: session summary, ledger update
  - index.ts: main plugin entry point

- Map OpenCode hooks to OpenWolf infrastructure
- Add opencode-md-snippet.md template
- Update shared.ts with projectDir param + wolfDirExists()
- Exclude plugin directory from tsconfig build

Refactors monolithic 1000-line file into 10 focused modules.

Closes cytostack#6
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