Skip to content

feat(agents): Add subagent runtime support#106

Open
dcramer wants to merge 20 commits into
mainfrom
feat/subagents
Open

feat(agents): Add subagent runtime support#106
dcramer wants to merge 20 commits into
mainfrom
feat/subagents

Conversation

@dcramer

@dcramer dcramer commented May 31, 2026

Copy link
Copy Markdown
Member

Add [[subagents]] so a repo can declare reusable coding-agent subagents once, install them into .agents/agents/, and generate runtime-native files for Claude, Cursor, Codex, and OpenCode.

Typical Project Usage

A project can point at a shared agent pack and let dotagents generate files for every configured runtime that supports subagents:

version = 1
agents = ["claude", "cursor", "codex", "opencode"]

[[subagents]]
name = "code-reviewer"
source = "getsentry/agent-pack"

If the upstream repo contains agents/code-reviewer.md, dotagents install writes the canonical installed file plus runtime outputs:

.agents/agents/code-reviewer.md
.claude/agents/code-reviewer.md
.cursor/agents/code-reviewer.md
.codex/agents/code-reviewer.toml
.opencode/agents/code-reviewer.md

Native Sources Stay Native

Teams can also publish native agent files directly. For example, a Codex-first source can keep Codex-specific fields in .codex/agents/code-reviewer.toml:

name = "code_reviewer"
description = "Review code for correctness and missing tests."
developer_instructions = "Review the current diff and return actionable findings."
sandbox_mode = "read-only"

When installing to Codex, dotagents preserves that TOML as the Codex output and only adds the managed-file marker. When installing to Claude, Cursor, or OpenCode, it generates Markdown from the portable name, description, and instructions instead of trying to standardize Codex-only behavior.

Explicit File Selection

Conventional directories such as agents/, .agents/agents/, .claude/agents/, .cursor/agents/, .codex/agents/, and .opencode/agents/ are discovered automatically. Root-level Markdown files require an explicit path so unrelated docs do not get imported by accident:

[[subagents]]
name = "release-notes"
source = "getsentry/agent-pack"
path = "release-notes.md"

Install and sync both understand the generated files. install --frozen validates declared subagents against agents.lock, sync repairs or prunes managed subagent files without network access, and doctor --fix preserves lockfile subagent ignore entries until stale files are pruned.

@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dotagents Ready Ready Preview, Comment Jun 9, 2026 11:34pm

Request Review

Comment thread packages/dotagents/src/cli/commands/install.ts
Comment thread packages/dotagents/src/agents/subagent-store.ts
Comment thread packages/dotagents/src/config/loader.ts
Comment thread packages/dotagents/src/cli/commands/install.ts Outdated
Comment thread packages/dotagents/src/agents/definitions/helpers.ts
Comment thread packages/dotagents/src/agents/subagent-writer.ts Outdated
Comment thread packages/dotagents/src/agents/definitions/helpers.ts Outdated
Comment thread packages/dotagents/src/agents/subagent-store.ts
Comment thread packages/dotagents/src/cli/commands/doctor.ts
Comment thread packages/dotagents/src/agents/subagent-store.ts
Comment thread packages/dotagents/src/cli/commands/install.ts Outdated
Comment thread packages/dotagents/src/agents/subagent-store.ts
Comment thread packages/dotagents/src/agents/definitions/cursor.ts
Comment thread packages/dotagents/src/agents/definitions/helpers.ts
Comment thread packages/dotagents/src/agents/types.ts
Comment thread packages/dotagents/src/cli/commands/install.ts
@dcramer dcramer marked this pull request as ready for review June 9, 2026 18:18
Comment thread packages/dotagents/src/agents/subagent-writer.ts Outdated
Comment thread packages/dotagents/src/agents/subagent-writer.ts
Comment thread packages/dotagents/src/agents/definitions/helpers.ts
Comment thread packages/dotagents/src/cli/commands/install.ts Outdated
Comment thread packages/dotagents/src/cli/commands/install.ts
dcramer and others added 5 commits June 9, 2026 15:25
Convert unmanaged canonical subagent file conflicts into typed store errors and InstallError at the install boundary.

This preserves user-owned files while letting the CLI print a clean message instead of surfacing an unexpected exception.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Document subagent lockfile and trust behavior, keep subagent runtime pruning explicit, and avoid exposing subagent internals on the host package surface.

Make git-heavy tests deterministic under the full Vitest suite and keep install test setup lazy for path-only cases.

Co-Authored-By: GPT-5 Codex <noreply@openai.com>
Remove stale managed skill directories whenever install rewrites them out of the lockfile, while preserving in-place local skills. Guard stale deletion with a safe managed skill path so malformed lockfile keys cannot delete unrelated files.

Also tolerate BOM-prefixed markdown frontmatter with spaces after the opening marker when parsing or marking native subagent files.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Treat empty subagent targets as every configured agent and make managed marker detection format-aware so body text is not trusted.

Keep frozen installs from pruning managed subagent files or dropping their gitignore entries, while normal installs still prune explicitly.

Co-Authored-By: Codex <codex@openai.com>
Load configured subagents from the installed store during frozen installs instead of resolving their sources.

This keeps frozen installs network-free for subagents while preserving managed files and lock entries.

Co-Authored-By: Codex <codex@openai.com>
Comment thread packages/dotagents/src/cli/commands/install.ts
Comment thread packages/dotagents/src/agents/subagent-writer.ts Outdated
Keep declared managed runtime files out of prune candidates even when an unmanaged file claims the same subagent identity. This leaves the conflict visible as a warning or sync issue without deleting the configured output.

Write the prepared lockfile before mutating installed subagent files so a write conflict does not discard lock updates after skill directories have changed.

Co-Authored-By: OpenAI Codex <codex@openai.com>
Comment thread packages/dotagents/src/cli/commands/sync.ts Outdated
Comment thread packages/dotagents/src/cli/commands/install.ts
Comment thread packages/dotagents/src/cli/commands/install.ts Outdated
Update install to write skill lock changes while preserving prior subagent lock entries until installed subagent files are written successfully.

Include lockfile-tracked subagents when sync regenerates .agents/.gitignore so generated files remain ignored until stale entries are pruned.

Co-Authored-By: OpenAI Codex <codex@openai.com>
Comment thread packages/dotagents/src/cli/commands/install.ts
When subagent writes fail during install, preserve only previously locked subagent entries that still match the newly resolved lock. This lets skill lock updates land without carrying removed or updated subagent entries forward.

Co-Authored-By: Codex <codex@openai.com>
Comment thread packages/dotagents/src/cli/commands/install.ts
Move the fallback install lockfile write into the subagent error path so successful subagent file writes can be reflected when later pruning fails. Failed subagent writes still preserve only unchanged prior subagent lock entries while keeping skill lock updates.

Co-Authored-By: Codex <codex@openai.com>
Comment thread packages/dotagents/src/cli/commands/sync.ts
Sync should repair generated runtime configs from the subagents that were successfully loaded, not every declared subagent. This removes stale generated files when a declared subagent is missing or fails to load.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aadfa12. Configure here.

Comment thread packages/dotagents/src/cli/commands/sync.ts
Comment thread packages/dotagents/src/agents/subagent-writer.ts
Sync reports declared subagents that are not installed, but it should not delete their generated runtime files. Preserve those files until install can repair the canonical subagent source.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Pruning should only inspect files that may be removed. Skip desired runtime files before reading them so unreadable desired files do not abort install or sync.

Co-Authored-By: OpenAI Codex <noreply@openai.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