Repository navigation
Restore two-way agent config sync with standardized bootstrap - #6
Conversation
Bring back the .agents/ canon and the per-checkout, gitignored harness adapters, consolidated: one sync.py now owns rendering, skill symlinks, the skills lock, and validation. The sync is two-way — a skill or MCP server installed through any one harness is adopted into .agents/ and rendered for every other — enforced by a dependency-free git pre-commit hook that .agents/setup installs. Bootstrap is standardized across environments: committed native hooks for devcontainers, Claude Code (SessionStart), Cursor cloud, Copilot's coding agent, and Amp all call the same .agents/setup, which needs only stdlib Python. setup also installs rtk, best-effort, to compress the command output agents read. Instructions consolidate into AGENTS.md (with one-line CLAUDE.md/GEMINI.md imports) plus one .agents/README.md; no skills or MCP servers ship preinstalled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017NWDrWeqhFGvENtps4UNf7
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a428222162
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if name in servers or name in found or not isinstance(entry, dict): | ||
| continue | ||
| config = normalize(entry) | ||
| if isinstance(config.get("url"), str) or isinstance(config.get("command"), str): | ||
| found[name] = (config, rel) |
There was a problem hiding this comment.
Preserve canonical MCP deletions during reverse sync
When a server is removed from .agents/mcp/servers.json while any previously rendered adapter still contains it, foreign_servers() classifies that stale entry as a new foreign server, and absorb() immediately writes it back into the canonical file. This also contaminates branches when an ignored adapter survives a checkout, so the documented edit-and-sync workflow cannot delete or rename a server without manually removing every generated adapter first. Track the last rendered state or otherwise distinguish stale generated entries from genuinely new harness additions.
AGENTS.md reference: AGENTS.md:L28-L32
Useful? React with 👍 / 👎.
| adopted_servers, _ = foreign_servers(servers) | ||
| for name, (config, rel) in adopted_servers.items(): | ||
| servers[name] = config | ||
| print(f"Adopted MCP server {name!r} from {rel} into .agents/mcp/servers.json") | ||
| if adopted_servers: | ||
| atomic_write(SERVERS_PATH, json_document(servers)) |
There was a problem hiding this comment.
Reject inline credentials before adopting MCP entries
When a harness-local MCP entry contains literal credentials in fields such as env or headers, this loop copies the entire ignored configuration into the tracked .agents/mcp/servers.json without validation or redaction. Commands such as an MCP installer commonly persist supplied environment values, so an automatic setup followed by a normal commit can expose those secrets; adoption should reject literal credential values or require environment-variable references before writing the canonical file.
AGENTS.md reference: AGENTS.md:L22-L22
Useful? React with 👍 / 👎.
| foreign, problems = foreign_servers(servers) | ||
| failures.extend( | ||
| f"{rel}: MCP server {name!r} not in .agents/mcp/servers.json (run .agents/sync.py)" | ||
| for name, (_, rel) in foreign.items() | ||
| ) | ||
| failures.extend(problems) |
There was a problem hiding this comment.
Compare existing adapters with rendered output
When an existing canonical server's command, URL, arguments, or tools are edited but the generated adapter is not rerendered, check() passes because foreign_servers() only reports names absent from the canon and the later validation parses newly generated strings in memory rather than the adapter on disk. The pre-commit hook therefore permits an unconverged checkout whose active harness continues using stale settings; compare every existing generated file with its expected render while still allowing adapters for undetected harnesses to be absent.
AGENTS.md reference: AGENTS.md:L36-L38
Useful? React with 👍 / 👎.
Follow-up to #5, which trimmed too far: it dropped the write-once-use-everywhere propagation. This restores that functionality in consolidated form and closes the gaps that kept it from being genuinely cross-environment. Only canonical and standard files are tracked (18 files); everything harness-specific stays generated per checkout and gitignored.
Two-way sync, one script.
.agents/sync.pyreplaces the oldsync.py+check-skills.py+bootstrap.shand now converges both directions:.agents/skills/and.agents/mcp/servers.json; the rest readAGENTS.md+.agents/skills/natively..claude/skills/, or an MCP server added through any one harness (claude mcp add, a hand edit to any rendered config, all dialects including the Codex TOML), is adopted into.agents/and rendered back out to every other harness..agents/setupinstalls a native git pre-commit hook runningsync.py check— no pre-commit framework, no pip — so a commit fails until local state and canon converge. CI runs the same check plus a full--allrender.Standardized bootstrap in every environment. One entry point,
.agents/setup(stdlib Python only — no network or installs required for the core, so it can't fail in restricted sandboxes), reached through committed native hooks:SessionStartin.claude/settings.jsonpostCreateCommand.cursor/environment.jsoninstall.github/workflows/copilot-setup-steps.yml.agents/setupby conventionSlimmer where it counts. Instructions agents load: 45-line
AGENTS.md(plus committed one-lineCLAUDE.md/GEMINI.mdimports), down from 125 lines + two more doc files describing the same machinery. One.agents/README.mdholds the machinery reference. Dropped: the model-mix enforcement hook (restrictive), the pre-commit framework dependency, and the standalone skills checker (folded intosync.py).Shipped contents. No skills and no MCP servers preinstalled (
servers.jsonis{})..agents/setupinstalls rtk best-effort and runsrtk initfor detected agents, so command output is compressed before agents read it.Tested end to end in a scratch clone: full
--allrender (all outputs parse, JSON + TOML), render idempotency, adoption of a server added via.mcp.jsonand via the opencode dialect (local command form),toolsallowlist roundtrip (enabled_tools/includeTools), skill adoption with folded YAML frontmatter (moved to canon, symlinked back, hash-locked), drift detection andlock, skill removal pruning, identical-duplicate dedupe, hook-blocked commit while unconverged and hook-passed commit after, and a cleangit statusafter rendering (nothing untracked, nothing tracked).🤖 Generated with Claude Code
https://claude.ai/code/session_017NWDrWeqhFGvENtps4UNf7
Generated by Claude Code