Skip to content

Feat/opencode support#12

Merged
josephgoksu merged 11 commits intomainfrom
feat/opencode-support
Jan 22, 2026
Merged

Feat/opencode support#12
josephgoksu merged 11 commits intomainfrom
feat/opencode-support

Conversation

@josephgoksu
Copy link
Owner

No description provided.

Add OpenCode AI assistant integration alongside existing Claude, Gemini,
Codex, Cursor, and Copilot support.

Changes:
- Add "opencode" entry to aiHelpers map with skillsDir=true flag
- Implement createOpenCodeSkills() for nested directory structure:
  .opencode/skills/<skill-name>/SKILL.md
- Add skill name validation using OpenCode's required regex:
  ^[a-z0-9]+(-[a-z0-9]+)*$
- Implement installOpenCodePlugin() for JavaScript-based hooks in
  .opencode/plugins/taskwing-hooks.js
- Plugin implements session.created and session.idle hooks using
  Bun shell API (ctx.$) to invoke taskwing CLI commands
- Add comprehensive tests for all OpenCode functionality

OpenCode uses different patterns than other AI tools:
- Skills instead of slash commands (nested directories with SKILL.md)
- JavaScript plugins instead of JSON settings for hooks
- YAML frontmatter with "name" and "description" fields
Add `taskwing mcp install opencode` command to configure OpenCode's
MCP integration by creating opencode.json at the project root.

Implementation:
- Add OpenCodeMCPServerConfig and OpenCodeConfig structs for config format
- Implement installOpenCode() and upsertOpenCodeMCPServer() functions
- Add "opencode" case to mcpInstallCmd switch and "all" target
- Update help text to include opencode option

OpenCode config format differences from other tools:
- File location: project root (opencode.json), not subdirectory
- Top-level "$schema" key for validation
- "mcp" object (not "mcpServers")
- Command as JSON array ["taskwing", "mcp"] (not string)
- Type must be "local" for command execution

Includes comprehensive tests:
- Success case with JSON structure validation
- Command array format verification
- Existing config preservation
- Idempotency
- No secrets validation
- Input validation (empty path/name, invalid type, empty command)
- Malformed JSON handling
Add tests for IngestFindings covering:
- Basic finding ingestion
- OpenCode skill metadata patterns
- Empty/nil findings (no-op cases)
- Multiple node types (decision, pattern, constraint, feature, documentation)
- Workspace-aware tagging for monorepo support

Also add repository integration tests for:
- NewDefaultRepository create/retrieve operations
- SQLite persistence across close/reopen cycles
- Add 'opencode' case in installMCPServers() calling installOpenCode()
- Add 'opencode' to aiConfigOrder and aiConfigs for AI selection UI
- OpenCode uses project-local config (opencode.json) like Cursor/Copilot

Tests:
- TestInstallMCPServers_OpenCode - verifies opencode.json creation
- TestInstallMCPServers_AllIncludesOpenCode - verifies multiple AI install
- TestAIConfigOrder_IncludesOpenCode - verifies AI selection list
- TestAIConfigs_OpenCodeEntry - verifies config values
Implement checkOpenCodeMCP() to validate OpenCode configuration:
- Validates opencode.json exists and has valid JSON structure
- Checks for taskwing-mcp entry with correct type ("local") and command format
- Validates .opencode/skills/*/SKILL.md files:
  - YAML frontmatter presence
  - Required fields (name, description)
  - Name field matches directory name

Tests: 14 new tests covering valid/invalid scenarios for:
- opencode.json (missing, invalid JSON, empty MCP, missing taskwing-mcp, wrong type)
- Skills (missing frontmatter, missing fields, name mismatch, multiple valid)
- Add tests/integration/opencode_test.go with E2E tests:
  - TestOpenCode_BootstrapAndDoctor validates artifacts creation
  - TestOpenCode_MCPServerConfig validates config structure
  - Tests use local binary (go run .), NOT system-installed taskwing

- Add integration-opencode CI job to .github/workflows/ci.yml
  - Runs on main merges and PRs
  - Builds binary before running tests

- Add make test-opencode target to Makefile

- Document OpenCode in docs/TUTORIAL.md:
  - Add OpenCode section with setup, skills, and hooks info
  - Update AI selection prompt examples
  - Add development notes about local dev MCP
Staticcheck S1009: len() for nil maps is defined as zero, so the nil check is unnecessary.
@josephgoksu josephgoksu merged commit 28dd676 into main Jan 22, 2026
3 checks passed
@josephgoksu josephgoksu deleted the feat/opencode-support branch January 22, 2026 18:28
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

Comments