Skip to content

feat(agents): Add subagent runtime support#106

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

feat(agents): Add subagent runtime support#106
dcramer wants to merge 29 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 12, 2026 5:10am

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 Outdated
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 2 commits June 11, 2026 14:34
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>
Add a checked-in full example fixture and smoke script that exercises install, list, doctor, sync, generated runtime files, and optional Codex runtime subagent spawning.

Document harness-specific QA references so future dotagents changes can distinguish file-level wiring from true runtime proof.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/dotagents/src/cli/commands/install.ts Outdated
Comment thread packages/dotagents/src/agents/definitions/helpers.ts Outdated
Preflight installed subagent conflicts before writing canonical files and roll back write-phase failures so the lockfile fallback cannot omit partially written subagents.

Preserve trailing blank lines in native subagent overlays by using keep chomping for newline-terminated YAML block scalars.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/dotagents/src/agents/subagent-store.ts Outdated
Trigger a fresh Warden app evaluation after resolving the stale review thread.

Co-Authored-By: Codex <noreply@openai.com>
Replace installed subagent files through same-directory temporary files before renaming them into place. This prevents failed writes from truncating existing managed files and keeps rollback lossless.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/dotagents/src/agents/definitions/helpers.ts
Include the current attempted installed subagent file in rollback so failed write paths restore all affected files conservatively.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/dotagents/src/agents/subagent-store.ts
Require installed canonical subagent files to carry the dotagents managed marker before loading them for sync or frozen install. This keeps unmanaged user files from driving generated runtime configs.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/dotagents/src/cli/commands/install.ts
Treat canonical subagent write and prune as one filesystem phase before recording new subagent lock entries. If pruning aborts, keep only unchanged subagent lock entries so the lockfile does not claim a complete install.

Co-Authored-By: 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 ff95532. Configure here.

Comment thread packages/dotagents/src/cli/commands/remove.ts
Comment thread packages/dotagents/src/cli/commands/install.ts
Include lockfile-tracked subagents when remove regenerates .agents/.gitignore. This matches sync and doctor so stale managed canonical subagent files remain ignored until they are pruned.

Co-Authored-By: Codex <noreply@openai.com>
Comment thread packages/dotagents/src/cli/commands/install.ts
Keep the fallback lockfile rewrite best-effort when subagent install or prune fails. This prevents a secondary lockfile write failure from masking the original install failure.

Co-Authored-By: Codex <noreply@openai.com>
Comment on lines +189 to +192
const serialized = JSON.stringify(value);
if (serialized !== undefined) {
lines.push(`${prefix}${toYamlKey(key)}: ${serialized}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The regex in parseMarkdownFrontmatterContent for extracting frontmatter is non-greedy and will terminate prematurely if a YAML block scalar's content contains a line with just ---.
Severity: MEDIUM

Suggested Fix

Replace the regular expression-based frontmatter extraction with a more robust parsing mechanism that correctly handles YAML document separators and does not fail on content that coincidentally contains separator-like sequences.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/dotagents/src/agents/definitions/helpers.ts#L189-L192

Potential issue: The function `parseMarkdownFrontmatterContent` uses a non-greedy
regular expression to extract YAML frontmatter from markdown files. This regex will
terminate at the first occurrence of a line containing `---`. If a native subagent's
content, which is stored inside a YAML block scalar, contains a `---` sequence on its
own line (e.g., as a separator in TOML comments), the regex will incorrectly truncate
the frontmatter. This will cause the subsequent YAML parsing to fail with a
`SkillLoadError`, preventing the subagent from being loaded and presenting a potentially
confusing error to the user.

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