Skip to content

feat(opencode): add OpenCode as a new AI coding agent#261

Open
cteyton wants to merge 17 commits intomainfrom
opencode
Open

feat(opencode): add OpenCode as a new AI coding agent#261
cteyton wants to merge 17 commits intomainfrom
opencode

Conversation

@cteyton
Copy link
Copy Markdown
Contributor

@cteyton cteyton commented Mar 27, 2026

Summary

Add OpenCode as a supported AI coding agent in Packmind, enabling standards, commands, and skills deployment for OpenCode users.

  • Standards are rendered in AGENTS.md (shared with agents_md, with explicit supersedence rule)
  • Commands deploy to .opencode/commands/
  • Skills deploy to .opencode/skills/

Type of Change

  • Bug fix
  • New feature
  • Improvement/Enhancement
  • Refactoring
  • Documentation
  • Breaking change

Affected Components

  • Domain packages affected: types, coding-agent, deployments
  • Frontend / Backend / Both: Both (backend + CLI + frontend settings UI)
  • Breaking changes (if any): None

Changes

  • Register OpenCode in the type system — add opencode to CodingAgent, MultiFileCodingAgent, selectable agents, and artefact path mappings
  • Add OpenCodeDeployer — hybrid single-file/multi-file deployer: standards in AGENTS.md, commands and skills in .opencode/ directories
  • Wire into deployer pipeline — register in DeployerService, GitFileUtils, and rendering exports
  • Frontend settings UI — add OpenCode option to the agent rendering configuration page
  • CLI support — add OpenCode to agent detection, selection, parseStandardMd, and diff commands
  • AGENTS.md supersedence (Rule 9) — when both opencode and agents_md are active, agents_md owns AGENTS.md; OpenCode writes are filtered out
  • Deduplicate git fetches — both agents map to AGENTS.md; fetchExistingFilesFromGit now deduplicates by file path before fetching
  • Fix CommandDiffStrategy — compare full file content instead of stripping frontmatter, so OpenCode field changes are visible to playbook diff

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • Test coverage maintained or improved

Test Details:

  • OpenCodeDeployer.spec.ts — standards, commands, skills rendering with frontmatter
  • DeployerService.spec.ts — dual-active scenario (opencode + agents_md) for both standards and artifacts
  • opencode-deployment.spec.ts — integration test for skill deployment
  • CommandDiffStrategy.spec.ts — body diff, frontmatter-only diff, no-frontmatter file, missing local file

TODO List

  • CHANGELOG updated
  • Documentation updated

cteyton and others added 13 commits March 27, 2026 11:10
Add 'opencode' as a new CodingAgent type with corresponding RenderMode,
artefact paths (.opencode/commands/, .opencode/skills/), and render mode
order before AGENTS_MD so that when both are enabled, AGENTS.md output
supersedes OpenCode's via last-write-wins merge.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…file rendering

Implement OpenCodeDeployer extending SingleFileDeployer:
- Standards rendered as sections in AGENTS.md (single-file)
- Commands rendered as individual files in .opencode/commands/ (content as-is)
- Skills rendered as multi-file directories in .opencode/skills/
Register deployer in CodingAgentDeployerRegistry and add AGENTS.md path
to AgentConfiguration.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ection

- Detect OpenCode when .opencode/ directory exists
- Add OpenCode to selectable agents list with display name 'OpenCode'

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Add OpenCode as a selectable agent in the organization distribution
settings with display name 'OpenCode', defaulting to unchecked.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…and UI labels

- Export OpenCodeDeployer from coding-agent package index
- Add opencode → AGENTS.md mapping in GitFileUtils
- Add 'OpenCode' label to DeploymentsHistory and RunDistributionBody

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…e agent

- Integration tests covering recipe (commands as-is) and standards (AGENTS.md sections)
- Update manage-ai-agents.mdx with OpenCode entry
- Update artifact-rendering.mdx with OpenCode standards, commands, and skills locations

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Recipes index in AGENTS.md is no longer supported. Remove the code that
cleared the 'Packmind recipes' section from OpenCodeDeployer.deployRecipes()
and generateFileUpdatesForRecipes(), and update tests accordingly.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Remove stripFrontmatter() before diffing so changes to frontmatter fields
(description, agent, model, subtask) are detected by playbook diff. This
applies to all agent command formats — files without frontmatter are
unaffected; files with frontmatter (OpenCode, Claude Code, GitHub Copilot)
now correctly surface metadata-only changes.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ode and agents_md are active

Add an explicit guard in DeployerService that filters out OpenCode's AGENTS.md
write when agents_md is also in the active agents list (Rule 9). Previously
the correct behavior only happened as a side effect of RENDER_MODE_ORDER
iteration order. Add tests for the dual-active scenario in both
aggregateStandardsDeployments and aggregateArtifactRendering.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…test descriptions

Add integration test asserting OpenCode skill deployment produces
.opencode/skills/<slug>/SKILL.md at the correct path.
Also remove rule number references from DeployerService test descriptions.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ff tests

- Fix wrong SELECTABLE_AGENTS index comment in configAgentsHandler.spec.ts
- Add OpenCode command fixture with all 4 valid frontmatter fields
  (description, agent, model, subtask) in OpenCodeDeployer.spec.ts
- Update DiffArtefactsUseCase tests to reflect full content diff behavior:
  frontmatter-only changes are now correctly detected

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
OpenCode writes standards to AGENTS.md (single-file), so it cannot parse
standards individually — returns null like gitlab_duo.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…t spec

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@mintlify
Copy link
Copy Markdown

mintlify bot commented Mar 27, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
packmind 🟢 Ready View Preview Mar 27, 2026, 12:22 PM

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR adds OpenCode as a supported AI coding agent, wiring it end-to-end through the type system, deployer pipeline, CLI, and frontend settings UI. Standards are rendered into AGENTS.md (via the existing SingleFileDeployer base class), while commands and skills are deployed as individual files under .opencode/commands/ and .opencode/skills/ respectively.\n\nKey design decisions handled well:\n- Rule 9 / dual-active suppression: when both opencode and agents_md are active, agents_md takes ownership of AGENTS.md. The suppressOpenCodeAgentsMdIfAgentsMdActive helper filters OpenCode's AGENTS.md writes from both createOrUpdate and delete arrays, and is applied consistently in both aggregateStandardsDeployments and aggregateArtifactRendering.\n- Git deduplication: fetchExistingFilesFromGit now deduplicates agents by file path before fetching, preventing a redundant AGENTS.md git fetch when both agents are active.\n- CommandDiffStrategy fix: comparisons now use full file content (frontmatter + body) so OpenCode-specific frontmatter fields (agent, model, subtask) are included in playbook diff output.\n- Test coverage: unit tests (OpenCodeDeployer.spec.ts), service-level tests (DeployerService.spec.ts dual-active scenarios), a new CommandDiffStrategy.spec.ts, and an integration test all combine for solid coverage.\n\nThe only improvement opportunity is a minor code duplication inside OpenCodeDeployer.deployArtifacts, where the command-file generation loop is identical to the body of generateFileUpdatesForRecipes and could be replaced by a single method call.

Confidence Score: 5/5

Safe to merge — no functional defects found; all remaining feedback is style/cleanup.

All logic paths for the new agent (standards, commands, skills, removal, cleanup, dual-active suppression) are covered by unit and integration tests. The one comment is a P2 code-duplication style suggestion that does not affect correctness.

packages/coding-agent/src/infra/repositories/opencode/OpenCodeDeployer.ts — minor loop duplication between deployArtifacts and generateFileUpdatesForRecipes

Important Files Changed

Filename Overview
packages/coding-agent/src/infra/repositories/opencode/OpenCodeDeployer.ts New hybrid deployer (standards→AGENTS.md, commands/skills→.opencode/); correct but contains a duplicated recipe loop between deployArtifacts and generateFileUpdatesForRecipes
packages/coding-agent/src/application/services/DeployerService.ts Adds Rule 9 suppression: when both opencode and agents_md are active, AGENTS.md writes from opencode are filtered out of both createOrUpdate and delete arrays; well-tested
packages/deployments/src/application/utils/GitFileUtils.ts Deduplicates git fetches by file path so AGENTS.md is fetched only once when both opencode and agents_md are active; first-wins ordering is safe because result is only used for logging
apps/cli/src/application/useCases/diffStrategies/CommandDiffStrategy.ts Intentional change: compare full file content (including frontmatter) instead of body-only, making OpenCode-specific frontmatter fields visible in diff output
packages/types/src/coding-agent/CodingAgent.ts Adds opencode to CodingAgent union type and CodingAgents record; straightforward and complete
packages/types/src/coding-agent/CodingAgentArtefactPaths.ts Adds opencode to MultiFileCodingAgent and CODING_AGENT_ARTEFACT_PATHS with correct paths for commands (.opencode/commands/) and skills (.opencode/skills/)
packages/integration-tests/src/coding-agents-deployments/opencode-deployment.spec.ts Integration tests cover recipe, standard, and skill deployment for OpenCode; well-structured with proper setup and teardown
packages/coding-agent/src/infra/repositories/opencode/OpenCodeDeployer.spec.ts Comprehensive unit tests for all OpenCodeDeployer methods including removal and cleanup paths
apps/cli/src/infra/commands/config/configAgentsHandler.ts Adds opencode to SELECTABLE_AGENTS (alphabetical order) and AGENT_DISPLAY_NAMES; test expectations updated accordingly
packages/types/src/deployments/RenderMode.ts Adds OPENCODE enum value and positions it after PACKMIND in the display order, before AGENTS_MD

Sequence Diagram

sequenceDiagram
    participant DS as DeployerService
    participant OCD as OpenCodeDeployer
    participant SFD as SingleFileDeployer (super)
    participant Git as GitPort

    DS->>OCD: deployStandards(standards, gitRepo, target)
    OCD->>SFD: deployStandards(standards, gitRepo, target)
    SFD-->>OCD: {createOrUpdate:[{path:AGENTS.md, sections:[...]}]}
    OCD-->>DS: FileUpdates (AGENTS.md sections)

    DS->>OCD: deployArtifacts(recipes, standards, skills)
    OCD->>SFD: deployArtifacts(recipes, standards)
    SFD-->>OCD: {createOrUpdate:[{path:AGENTS.md, sections:[clear-recipes, standards]}]}
    OCD->>OCD: build commandFileUpdates (.opencode/commands/*.md)
    OCD->>SFD: generateFileUpdatesForSkills(skills)
    SFD-->>OCD: {createOrUpdate:[{path:.opencode/skills/*/SKILL.md}]}
    OCD-->>DS: merged FileUpdates (AGENTS.md + commands + skills)

    Note over DS: Rule 9: if agents_md also active…
    DS->>DS: suppressOpenCodeAgentsMdIfAgentsMdActive()
    Note over DS: filter AGENTS.md from opencode updates
Loading

Reviews (4): Last reviewed commit: "💄 refactor(ui): sort agent lists alphab..." | Re-trigger Greptile

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

cteyton and others added 2 commits March 27, 2026 14:27
…istingFilesFromGit

Both opencode and agents_md map to AGENTS.md, causing a redundant fetch
where the second overwrites the first in the map. Deduplicate by file
path before the loop to avoid the unnecessary git call and remove the
implicit dependency on fetch order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cteyton cteyton changed the title fix(opencode): address QA review findings feat(opencode): add OpenCode as a new AI coding agent Mar 27, 2026
@cteyton
Copy link
Copy Markdown
Contributor Author

cteyton commented Mar 27, 2026

@greptile update your review

Applies to both the frontend Distribution Rendering settings and the
CLI config agents selection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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