Skip to content

Support wiki-link extends for agent definitions #62

@riatzukiza

Description

@riatzukiza

Summary

  • add an extends frontmatter key for agent markdown files so child agents can inherit prompts, models, permissions, and tooling from a base configuration
  • resolve extends targets via wiki-link syntax (e.g. [[foo/build]]) using the shortest unique path segments so name collisions are disambiguated automatically

Background

  • packages/opencode/src/config/config.ts loads agent markdown and schema-validates fields, but there is no inheritance mechanism today
  • packages/opencode/src/agent/agent.ts merges built-in agents with user-defined ones; this is where resolved inheritance chains need to be flattened into the final runtime map
  • the existing config markdown helper (packages/opencode/src/config/markdown.ts) only parses @file references; we need equivalent wiki-link parsing to drive extends

Requirements

  1. Accept extends: [[agent-path]] (and multi-hop chains) in agent frontmatter; make parsing errors obvious when the link is malformed or the target agent does not exist
  2. Implement wiki-link path resolution that picks the smallest unique suffix when duplicate filenames exist in different folders, expanding only as needed to uniquely identify the target
  3. Merge inherited settings before exposing agents to the rest of the app: prompts, tools, permissions, and arbitrary option keys should fall back to the parent while allowing explicit overrides in the child
  4. Detect cycles or ambiguous wiki links during config load and raise configuration errors that include the offending filenames/paths
  5. Add docs and tests (e.g. packages/opencode/test/config) that cover the resolver behavior, a successful inheritance chain, and failure modes for collisions or circular references; ensure existing suites still pass

Definition of Done

  • Agent schema validates extends links and errors early on invalid inputs
  • wiki-link resolver can uniquely identify any agent markdown using minimal path segments
  • inherited agents appear in opencode agent list/TUI with merged settings and correct prompts
  • tests and docs describe how to author extends: [[agent-name]]

References

  • spec/explicit-prototypal-agent.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions