feat(cli): emit rules and commands in OpenCode flat builds

Open
#789 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
cli, tooling

Research direction

Start with cli/src/contexts/tools/domain/profiles/opencode/profile.ts for OpenCode artifact paths and capabilities, then read cli/src/contexts/tools/domain/formats/opencode-mcp-merge.ts for preservation-safe configuration merging. Run the flat framework build and existing unit, integration, golden, and runtime tests. Done means namespaced rules and commands are discoverable, user instructions and relative links survive, collisions and reruns are safe, and plugins without these artifacts remain byte-identical.

Written by the indexing model from the issue text.

Description

Problem

The flat framework build deliberately skips plugin rules/ and commands/ for every target. Once a plugin contains those canonical artifacts, an OpenCode archive omits them even though OpenCode can consume project rules and commands.

This is separate from direct generation in #788. #788 writes artifacts into a project; this issue distributes canonical plugin artifacts through aidd framework build --flat.

Scope

  • Materialize canonical plugin rules/ into namespaced Markdown files and merge their paths into opencode.json or opencode.jsonc instructions.
  • Preserve every user-owned instructions entry while merging the generated rule paths.
  • Materialize canonical plugin commands/ into namespaced .opencode/commands/ paths.
  • Prevent cross-plugin filename collisions.
  • Preserve idempotence and rewrite relative links for their materialized locations.
  • Add focused, golden, and OpenCode runtime coverage.

Acceptance criteria

  • A plugin with rules/ produces discoverable OpenCode rules through instructions.
  • Existing user-owned instructions entries survive unchanged in JSON and JSONC configuration.
  • A plugin with commands/ produces discoverable .opencode/commands/ output.
  • Identically named artifacts from two plugins cannot overwrite each other.
  • Re-running the same build creates neither duplicate files nor configuration entries.
  • Relative links still resolve after materialization.
  • A plugin without rules/ or commands/ produces byte-identical output to today.
  • Unit, integration, golden, and target-runtime smoke tests pass.

Prior art

  • cli/src/contexts/tools/domain/profiles/opencode/profile.ts owns OpenCode artifact paths and configuration capabilities.
  • cli/src/contexts/tools/domain/formats/opencode-mcp-merge.ts is the preservation-safe configuration merge precedent.

Out of scope

  • Kilo flat rules are tracked separately in #868. Kilo command materialization is intentionally excluded here because Kilo requires host-specific flat-build support after #744.
  • Direct artifact generation, tracked by #788.
  • Hook conversion or hook-plugin generation.
Dominant language
TypeScript
Stars
481
Forks
45
Avg merge
14h 36m
Merged PRs (30d)
110

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ai-driven-dev/framework

All issues in ai-driven-dev/framework

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.