From 345ac508191b7ed1a624fba783fd83114040dacd Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 27 Aug 2026 23:34:00 +0000 Subject: [PATCH 1/3] Generate every harness adapter from .agents/ with as-needed detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace link-skills.sh + sync-mcp.sh with one declarative generator, .agents/scripts/sync.py: a HARNESSES table mapping each harness to a detection probe (env var, CLI on PATH, config dir), a skills directory for the few tools that do not read .agents/skills/ natively, and an MCP renderer for tools with a project-level MCP file. By default it renders only for harnesses detected on the machine; --all covers everything (CI default), `list` prints the table, `check` verifies the managed keys in the two committed seed files, and install-codex keeps its old behavior. Coverage now spans the classic gsd installer's 15 runtimes plus dsh and friends. Most of them cost nothing: Codex, Cursor, Copilot's coding agent, OpenCode, Amp, Factory, Goose, Zed, Crush, Kilo, Antigravity, Cline, and dsh all read AGENTS.md and .agents/skills/ natively. Rendered adapters: .mcp.json + .claude/skills/ (Claude Code), .cursor/mcp.json, .codex/config.toml (trusted projects), .vscode/mcp.json (servers key), opencode.json / kilo.jsonc (local/remote dialect), .factory/mcp.json, .qwen/settings.json (httpUrl + contextFileName), .amp/settings.json, and per-skill symlink dirs for Windsurf, Hermes, Trae, Augment, and CodeBuddy. All generated output is gitignored; CI now fails if a bootstrap run leaves anything untracked, which keeps .gitignore and the generator in lockstep. Unify the environment story around the same bootstrap entrypoint: - .github/workflows/copilot-setup-steps.yml (Copilot's coding agent does not honor devcontainers) - .cursor/environment.json install hook for Cursor cloud agents - .agents/setup shim for Amp orbs - delete .codex/environments/environment.toml — Codex cloud reads no in-repo setup file; its UI Setup script field takes the bootstrap one-liner, now documented with the Jules/Devin/Factory equivalents - session-start.sh now always exits 0 so a failed bootstrap degrades instead of killing the Claude cloud session Cursor skill symlinks are gone rather than moved: Cursor reads .agents/skills/ natively, so the adapter was pure noise. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_019vB3bUsXcLptQySBnJz2aG --- .agents/AGENTS.md | 58 +-- .agents/README.md | 57 ++- .agents/scripts/bootstrap.sh | 11 +- .agents/scripts/link-skills.sh | 42 -- .agents/scripts/sync-mcp.sh | 200 ---------- .agents/scripts/sync.py | 443 ++++++++++++++++++++++ .agents/setup | 3 + .claude/hooks/session-start.sh | 9 +- .codex/environments/environment.toml | 5 - .cursor/environment.json | 3 + .github/workflows/agent-config.yml | 64 ++-- .github/workflows/copilot-setup-steps.yml | 25 ++ .gitignore | 32 +- .pre-commit-config.yaml | 12 +- AGENTS.md | 61 +-- CLAUDE.md | 5 +- 16 files changed, 660 insertions(+), 370 deletions(-) delete mode 100755 .agents/scripts/link-skills.sh delete mode 100755 .agents/scripts/sync-mcp.sh create mode 100755 .agents/scripts/sync.py create mode 100755 .agents/setup delete mode 100644 .codex/environments/environment.toml create mode 100644 .cursor/environment.json create mode 100644 .github/workflows/copilot-setup-steps.yml diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 4eddd35..2c31d46 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -1,31 +1,38 @@ # `.agents/` -Agent-agnostic configuration following the [Agent Skills](https://agentskills.io) -open standard and [AGENTS.md](https://agents.md) conventions. +The one canonical agent folder, following the +[Agent Skills](https://agentskills.io) open standard and +[AGENTS.md](https://agents.md) conventions. Every piece of agent configuration is one of three things: -| Category | Strategy | +| Tier | Strategy | |---|---| -| **Portable** — same format everywhere | Store once here, symlink into agent directories | -| **Generated** — same data, different format | Canonical source here, sync script renders each adapter | -| **Agent-specific** — no cross-agent equivalent | Leave it in the agent's own directory | +| **Canonical** — the single source of truth | Lives here: `skills/`, `mcp/servers.json`, `scripts/` | +| **Seed** — a harness reads it straight from the clone, before any script can run | Committed in the harness's own location, kept minimal: hook and environment registrations, one managed key per settings file | +| **Generated** — everything else a harness wants | Rendered by `scripts/sync.py`, gitignored, recreated per checkout for the harnesses detected on that machine | -Portable things get symlinks, generated things get a sync script, agent-specific -things stay put. +Most harnesses need no generated adapter at all: `AGENTS.md` and +`.agents/skills/` are read natively by Codex, Cursor, Copilot's coding agent, +OpenCode, Amp, Factory, Goose, Zed, Crush, Kilo, Antigravity, dsh, and gsd, +among others. `sync.py list` shows the full table. ## Layout - `skills/` — Shared skills. Each is a directory with `SKILL.md`. -- `mcp/servers.json` — Canonical MCP server configuration. -- `scripts/` — Portable environment setup, synchronization, and validation. +- `mcp/servers.json` — Canonical MCP server configuration (Claude `mcpServers` + dialect, plus an optional `tools` read-only allowlist per server). +- `scripts/` — `bootstrap.sh` (environment setup entry point), `sync.py` + (adapter generator), `check-skills.py` (vendored-skill lock). +- `setup` — Entry shim for harnesses that execute `.agents/setup` (Amp orbs). ## Adding a skill 1. Create `.agents/skills//SKILL.md` with `name` and `description` frontmatter, where `name` matches the directory. -2. Run `.agents/scripts/link-skills.sh` and `.agents/scripts/check-skills.py --update`. -3. Commit the skill directory, the generated symlinks, and `skills-lock.json`. +2. Run `.agents/scripts/sync.py` and `.agents/scripts/check-skills.py --update`. +3. Commit the skill directory and `skills-lock.json`. Skill symlinks are + generated and gitignored — do not commit them. ## Installing a third-party skill @@ -33,24 +40,31 @@ things stay put. npx skills add @ -y ``` +It installs into `.agents/skills/` and maintains the same `skills-lock.json`. + ## Adding an MCP server 1. Edit `.agents/mcp/servers.json`. -2. Run `.agents/scripts/sync-mcp.sh`. -3. Commit the canonical file and all generated adapters. +2. Run `.agents/scripts/sync.py`. +3. Commit the canonical file plus the two committed seeds it updates + (`.claude/settings.json`, `.gemini/settings.json`). Every other rendered + adapter is gitignored. An optional `tools` array on a server is a read-only allowlist. It renders as -`enabled_tools` for Codex and `includeTools` for Gemini; Claude Code and Cursor -have no equivalent and receive the server's whole tool surface. +`enabled_tools` for Codex and `includeTools` for Gemini and Qwen; the other +harnesses have no equivalent and receive the server's whole tool surface. ## Rules -- Edit skills in `.agents/skills/`, never through `.claude/skills/` or - `.cursor/skills/`. -- Edit MCP definitions in `.agents/mcp/servers.json`, never in `.mcp.json`, - `.cursor/mcp.json`, `.codex/config.toml`, or `.gemini/settings.json`. -- `.claude/settings.json` and `.gemini/settings.json` are hand-owned except for - their `enabledMcpjsonServers` and `mcpServers` keys, which the sync rewrites. +- Edit skills in `.agents/skills/`, never through a harness's skills directory — + those are symlinks or native readers of this one. +- Edit MCP definitions in `.agents/mcp/servers.json`, never in a rendered + adapter. +- To support a new harness, add one entry to the `HARNESSES` table in + `scripts/sync.py` (detection, skills dir if it doesn't read `.agents/skills/` + natively, MCP renderer if it has a project-level MCP file) and mirror any new + output path in `.gitignore`'s generated-adapters block. CI fails if the two + fall out of step. - Agent-specific configuration stays put. `.cursor/rules/*.mdc` and `.github/instructions/*.instructions.md` use glob scoping and conditional loading with no equivalent elsewhere — do not convert them into skills. diff --git a/.agents/README.md b/.agents/README.md index f109a16..6576640 100644 --- a/.agents/README.md +++ b/.agents/README.md @@ -1,8 +1,10 @@ # Agent configuration This directory is the canonical home for portable agent assets. Shared skills -are symlinked into tool-native discovery paths; MCP definitions are rendered -into each tool's configuration format. +follow the Agent Skills standard and are read from `.agents/skills/` natively +by most harnesses (symlinked into the few that still want their own +directory); MCP definitions are rendered into each tool's configuration +format. Rendered adapters are gitignored and recreated per checkout. ## Commands @@ -10,42 +12,55 @@ into each tool's configuration format. # Install development tooling and refresh agent configuration .agents/scripts/bootstrap.sh -# Create or refresh shared-skill symlinks -.agents/scripts/link-skills.sh +# Render adapters for the harnesses detected on this machine +.agents/scripts/sync.py -# Regenerate the Claude, Cursor, Codex, and Gemini MCP adapters -.agents/scripts/sync-mcp.sh +# Render adapters for every known harness / a specific one +.agents/scripts/sync.py --all +.agents/scripts/sync.py windsurf -# Fail if an MCP adapter is missing or stale -.agents/scripts/sync-mcp.sh check +# Show the harness table: detection state and what each gets +.agents/scripts/sync.py list + +# Fail if a managed key in a committed seed file is stale +.agents/scripts/sync.py check # Explicitly install this repo's managed MCP block in the user Codex config -.agents/scripts/sync-mcp.sh install-codex +.agents/scripts/sync.py install-codex # Verify skills-lock.json against the skills on disk (--update to re-lock) .agents/scripts/check-skills.py ``` -## Cloud environments +## Environments -Every environment runs the same script. Nothing is environment-specific except -the hook that calls it: +Every environment runs the same `bootstrap.sh`. Nothing is +environment-specific except the hook that calls it: | Environment | Entry point | |---|---| | Local | `.agents/scripts/bootstrap.sh`, once per checkout | -| Claude Code (web) | `SessionStart` hook → `.claude/hooks/session-start.sh` | -| Codex cloud | `.codex/environments/environment.toml` `[setup] script` | -| GitHub Codespaces / devcontainers | `.devcontainer/devcontainer.json` `postCreateCommand` | +| Claude Code (web/cloud) | `SessionStart` hook → `.claude/hooks/session-start.sh` | +| GitHub Codespaces / devcontainers / Ona | `.devcontainer/devcontainer.json` `postCreateCommand` | +| GitHub Copilot coding agent | `.github/workflows/copilot-setup-steps.yml` (devcontainers are not honored there) | +| Cursor cloud agents | `.cursor/environment.json` `install` | +| Amp orbs | `.agents/setup` | +| Codex cloud | No in-repo hook — put `.agents/scripts/bootstrap.sh` in the environment's Setup script field (chatgpt.com/codex/settings/environments) | +| Jules / Devin / Factory | No in-repo hook — same one-liner in their UI setup/snapshot configuration | | CI | `.github/workflows/agent-config.yml` | To add another environment, call `bash .agents/scripts/bootstrap.sh` from its -native setup hook. Do not fork the setup logic. +native setup hook. Do not fork the setup logic. Bootstrap must stay +idempotent, non-interactive, fast when there is nothing to do, and free of +secrets at setup time (Codex cloud strips them before the agent phase). ## Generated files -`.mcp.json`, `.cursor/mcp.json`, `.codex/config.toml`, and the `mcpServers` and -`enabledMcpjsonServers` keys of `.gemini/settings.json` and -`.claude/settings.json` are generated from `.agents/mcp/servers.json`. The -`Validate agent configuration` workflow enforces synchronization on pull -requests and pushes to `main`; the bootstrap installs the local hook. +`sync.py` renders adapters from `.agents/mcp/servers.json` and links +`.agents/skills/` for harnesses that don't read it natively — by default only +for harnesses it detects on the machine (CLI on PATH, config directory, or +environment variable; CI renders all). All of it is gitignored; the +`Validate agent configuration` workflow fails if a rendered file ever shows up +untracked. The two committed exceptions, `.claude/settings.json` and +`.gemini/settings.json`, are hand-owned apart from one managed key each +(`enabledMcpjsonServers`, `mcpServers`), which `sync.py check` keeps honest. diff --git a/.agents/scripts/bootstrap.sh b/.agents/scripts/bootstrap.sh index 26e77f6..bcc8134 100755 --- a/.agents/scripts/bootstrap.sh +++ b/.agents/scripts/bootstrap.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash # Agent-agnostic environment setup for a fresh checkout. # -# Safe to re-run; every step is idempotent. Works locally and in remote agent -# containers (Claude Code on the web, Codex cloud, Codespaces, CI). +# Safe to re-run; every step is idempotent and non-interactive. Every +# environment calls this same script through its native hook — see the +# environments table in .agents/README.md. set -euo pipefail REPO_ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)" @@ -19,10 +20,10 @@ if ! command -v pre-commit >/dev/null 2>&1; then fi fi -.agents/scripts/link-skills.sh -.agents/scripts/sync-mcp.sh +.agents/scripts/sync.py "$@" .agents/scripts/check-skills.py pre-commit install # Project setup goes here (dependency install, codegen, migrations). Keep it -# idempotent so every harness can call this script on every session start. +# idempotent and fast when there is nothing to do, so every harness can call +# this script on every session start. diff --git a/.agents/scripts/link-skills.sh b/.agents/scripts/link-skills.sh deleted file mode 100755 index d24f3fc..0000000 --- a/.agents/scripts/link-skills.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -AGENTS_DIR="$(cd "$(dirname "$0")/.." && pwd)" -REPO_ROOT="$(cd "$AGENTS_DIR/.." && pwd)" -TARGETS=(".claude/skills" ".cursor/skills") - -for target_dir in "${TARGETS[@]}"; do - mkdir -p "$REPO_ROOT/$target_dir" - - for skill_dir in "$AGENTS_DIR"/skills/*/; do - [ -d "$skill_dir" ] || continue - name="$(basename "$skill_dir")" - link_target="../../.agents/skills/$name" - link_path="$REPO_ROOT/$target_dir/$name" - - if [ -L "$link_path" ]; then - [ "$(readlink "$link_path")" = "$link_target" ] && continue - rm "$link_path" - elif [ -e "$link_path" ]; then - echo "ERROR: $link_path exists but is not a symlink." >&2 - exit 1 - fi - - ln -s "$link_target" "$link_path" - echo "Linked: $link_path -> $link_target" - done - - for link_path in "$REPO_ROOT/$target_dir"/*; do - [ -L "$link_path" ] || continue - link_target="$(readlink "$link_path")" - case "$link_target" in - ../../.agents/skills/*) - name="$(basename "$link_path")" - if [ ! -d "$AGENTS_DIR/skills/$name" ]; then - rm "$link_path" - echo "Pruned: $link_path" - fi - ;; - esac - done -done diff --git a/.agents/scripts/sync-mcp.sh b/.agents/scripts/sync-mcp.sh deleted file mode 100755 index b793020..0000000 --- a/.agents/scripts/sync-mcp.sh +++ /dev/null @@ -1,200 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -AGENTS_DIR="$(cd "$(dirname "$0")/.." && pwd)" -REPO_ROOT="$(cd "$AGENTS_DIR/.." && pwd)" -MODE="${1:-sync}" - -case "$MODE" in - sync|check|install-codex) ;; - *) - echo "Usage: $0 [sync|check|install-codex]" >&2 - exit 2 - ;; -esac - -python3 - "$REPO_ROOT" "$MODE" <<'PY' -import json -import os -import re -import sys -import tempfile -from pathlib import Path - -repo_root = Path(sys.argv[1]) -mode = sys.argv[2] -source = repo_root / ".agents" / "mcp" / "servers.json" - -try: - servers = json.loads(source.read_text(encoding="utf-8")) -except (OSError, json.JSONDecodeError) as exc: - raise SystemExit(f"ERROR: cannot read {source}: {exc}") - -if not isinstance(servers, dict): - raise SystemExit("ERROR: .agents/mcp/servers.json must contain a JSON object") -for name, config in servers.items(): - if not isinstance(name, str) or not name: - raise SystemExit("ERROR: every MCP server must have a non-empty string name") - if not isinstance(config, dict): - raise SystemExit(f"ERROR: MCP server {name!r} must contain an object") - tools = config.get("tools") - if tools is not None and not ( - isinstance(tools, list) and all(isinstance(tool, str) and tool for tool in tools) - ): - raise SystemExit(f"ERROR: MCP server {name!r} has a malformed tools allowlist") - - -def json_document(value): - return json.dumps(value, indent=2, ensure_ascii=False) + "\n" - - -def toml_key(value): - if re.fullmatch(r"[A-Za-z0-9_-]+", value): - return value - return json.dumps(value, ensure_ascii=False) - - -def toml_value(value): - if isinstance(value, str): - # json.dumps escapes U+0000-U+001F but leaves U+007F raw, which TOML forbids. - return json.dumps(value, ensure_ascii=False).replace("\x7f", "\\u007f") - if isinstance(value, bool): - return "true" if value else "false" - if isinstance(value, (int, float)) and not isinstance(value, bool): - return repr(value) - if isinstance(value, list): - return "[" + ", ".join(toml_value(item) for item in value) + "]" - if isinstance(value, dict): - pairs = (f"{toml_key(key)} = {toml_value(item)}" for key, item in value.items()) - return "{ " + ", ".join(pairs) + " }" - raise SystemExit(f"ERROR: unsupported TOML value in MCP config: {value!r}") - - -# `tools` is a canonical read-only allowlist; each harness spells it differently -# and Claude Code and Cursor have no equivalent, so they get the whole surface. -claude_servers = {} -cursor_servers = {} -gemini_servers = {} -for name, config in servers.items(): - body = {key: value for key, value in config.items() if key != "tools"} - tools = config.get("tools") - - claude_config = dict(body) - if "url" in claude_config: - claude_config.setdefault("type", "http") - claude_servers[name] = claude_config - - cursor_config = dict(body) - cursor_config.pop("type", None) - cursor_servers[name] = cursor_config - - # Gemini CLI names streamable HTTP `httpUrl` and keeps `url` for SSE. - gemini_config = dict(body) - transport = gemini_config.pop("type", None) - if "url" in gemini_config and transport != "sse": - gemini_config["httpUrl"] = gemini_config.pop("url") - if tools: - gemini_config["includeTools"] = list(tools) - gemini_servers[name] = gemini_config - -codex_lines = ["# Generated by .agents/scripts/sync-mcp.sh; do not edit."] -for name, config in servers.items(): - codex_lines.extend(("", f"[mcp_servers.{toml_key(name)}]")) - for key, value in config.items(): - if key in ("type", "tools"): - continue - codex_lines.append(f"{toml_key(key)} = {toml_value(value)}") - if config.get("tools"): - codex_lines.append(f"enabled_tools = {toml_value(list(config['tools']))}") - -outputs = { - repo_root / ".mcp.json": json_document({"mcpServers": claude_servers}), - repo_root / ".cursor" / "mcp.json": json_document({"mcpServers": cursor_servers}), - repo_root / ".codex" / "config.toml": "\n".join(codex_lines) + "\n", -} - -# Files an agent also owns by hand: only the listed key is generated, the rest -# of the document is left exactly as the repository wrote it. -managed_keys = { - repo_root / ".gemini" / "settings.json": ("mcpServers", gemini_servers), - # Claude Code ignores project MCP servers until they are opted into here. - repo_root / ".claude" / "settings.json": ("enabledMcpjsonServers", sorted(servers)), -} - - -def merged_document(path, key, value): - try: - document = json.loads(path.read_text(encoding="utf-8")) - except FileNotFoundError: - document = {} - except (OSError, json.JSONDecodeError) as exc: - raise SystemExit(f"ERROR: cannot read {path}: {exc}") - if not isinstance(document, dict): - raise SystemExit(f"ERROR: {path} must contain a JSON object") - document[key] = value - return json_document(document) - - -for path, (key, value) in managed_keys.items(): - outputs[path] = merged_document(path, key, value) - -# Only managed_keys paths stay committed (a harness reads them before any -# setup script runs, so they can't be purely generated); the rest of -# `outputs` is gitignored and regenerated fresh on every bootstrap, so it has -# no "already on disk and correct" invariant for `check` to enforce. -tracked_outputs = {path: outputs[path] for path in managed_keys} - - -def atomic_write(path, content): - path.parent.mkdir(parents=True, exist_ok=True) - fd, temporary = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent) - try: - with os.fdopen(fd, "w", encoding="utf-8") as handle: - handle.write(content) - umask = os.umask(0) - os.umask(umask) - os.chmod(temporary, 0o666 & ~umask) - os.replace(temporary, path) - finally: - if os.path.exists(temporary): - os.unlink(temporary) - - -if mode == "check": - stale = [] - for path, expected in tracked_outputs.items(): - try: - current = path.read_text(encoding="utf-8") - except OSError: - current = None - if current != expected: - stale.append(path.relative_to(repo_root)) - if stale: - print("Stale tracked MCP adapter keys:", file=sys.stderr) - for path in stale: - print(f" {path}", file=sys.stderr) - print("Run .agents/scripts/sync-mcp.sh to regenerate them.", file=sys.stderr) - raise SystemExit(1) - print("Tracked MCP adapter keys are current.") -elif mode == "sync": - for path, content in outputs.items(): - atomic_write(path, content) - print(f"Generated: {path.relative_to(repo_root)}") -else: - repo_name = re.sub(r"[^A-Za-z0-9_-]+", "-", repo_root.name).strip("-") or "repo" - begin = f"# BEGIN {repo_name} managed MCP" - end = f"# END {repo_name} managed MCP" - block = begin + "\n" + outputs[repo_root / ".codex" / "config.toml"] + end - user_config = Path.home() / ".codex" / "config.toml" - try: - current = user_config.read_text(encoding="utf-8") - except FileNotFoundError: - current = "" - pattern = re.compile( - rf"(?ms)^[ \t]*{re.escape(begin)}\n.*?^[ \t]*{re.escape(end)}[ \t]*\n?" - ) - current = re.sub(r"\n{3,}", "\n\n", pattern.sub("", current)).rstrip() - merged = (current + "\n\n" if current else "") + block + "\n" - atomic_write(user_config, merged) - print(f"Installed managed MCP block: {user_config}") -PY diff --git a/.agents/scripts/sync.py b/.agents/scripts/sync.py new file mode 100755 index 0000000..0b4d3ed --- /dev/null +++ b/.agents/scripts/sync.py @@ -0,0 +1,443 @@ +#!/usr/bin/env python3 +"""Render harness adapters from the canonical assets in .agents/. + +Canonical sources: + .agents/skills/ shared skills (Agent Skills standard) + .agents/mcp/servers.json MCP servers, Claude `mcpServers` dialect plus an + optional `tools` read-only allowlist per server + +Committed seed files (always kept in sync, because they are committed): + .claude/settings.json `enabledMcpjsonServers` key only + .gemini/settings.json `mcpServers` key only + +Generated adapters (gitignored, rendered per checkout) are produced only for +harnesses detected on this machine, so a checkout carries adapters for the +tools that actually run here and nothing else. + +Usage: + sync.py [harness ...] sync seeds + adapters for detected (or named) harnesses + sync.py --all sync adapters for every known harness (CI default) + sync.py check verify the managed keys in committed seed files + sync.py list show known harnesses, detection state, and adapters + sync.py install-codex install this repo's MCP block into ~/.codex/config.toml + +Harnesses that read AGENTS.md and .agents/skills/ natively need no adapter and +no entry here: dsh (DeepSeek Harness), Goose, Zed, Crush, Cline, Antigravity, +Jules, Devin, gsd. Copilot's cloud coding agent also reads both natively; the +`vscode` entry below covers local VS Code, which wants .vscode/mcp.json. +""" +import json +import os +import re +import shutil +import sys +import tempfile +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[2] +SKILLS_ROOT = REPO_ROOT / ".agents" / "skills" +SERVERS_PATH = REPO_ROOT / ".agents" / "mcp" / "servers.json" + +# Each harness: how to detect it on this machine (env vars set, commands on +# PATH, directories under $HOME or the project), where its per-skill symlinks +# go (None = it reads .agents/skills natively), and which MCP renderer feeds it +# (None = it has no project-scoped MCP file). +HARNESSES = { + "claude": {"env": ["CLAUDECODE", "CLAUDE_CODE_REMOTE"], "cmd": ["claude"], "home": [".claude"], "skills": ".claude/skills", "mcp": "claude"}, + "codex": {"cmd": ["codex"], "home": [".codex"], "skills": None, "mcp": "codex"}, + "cursor": {"cmd": ["cursor-agent", "cursor"], "home": [".cursor"], "skills": None, "mcp": "cursor"}, + "gemini": {"cmd": ["gemini"], "home": [".gemini"], "skills": None, "mcp": "gemini"}, + "qwen": {"cmd": ["qwen"], "home": [".qwen"], "skills": None, "mcp": "qwen"}, + "opencode": {"cmd": ["opencode"], "home": [".config/opencode"], "skills": None, "mcp": "opencode"}, + "vscode": {"cmd": ["code"], "project": [".vscode"], "skills": None, "mcp": "vscode"}, + "kilo": {"cmd": ["kilo"], "home": [".config/kilo"], "skills": None, "mcp": "kilo"}, + "factory": {"cmd": ["droid"], "home": [".factory"], "skills": None, "mcp": "factory"}, + "amp": {"cmd": ["amp"], "home": [".amp"], "skills": None, "mcp": "amp"}, + "windsurf": {"home": [".codeium"], "project": [".windsurf"], "skills": ".windsurf/skills", "mcp": None}, + "hermes": {"cmd": ["hermes"], "home": [".hermes"], "skills": ".hermes/skills", "mcp": None}, + "trae": {"home": [".trae"], "project": [".trae"], "skills": ".trae/skills", "mcp": None}, + "augment": {"cmd": ["auggie"], "home": [".augment"], "skills": ".augment/skills", "mcp": None}, + "codebuddy": {"cmd": ["codebuddy"], "home": [".codebuddy"], "skills": ".codebuddy/skills", "mcp": None}, +} + +# Read AGENTS.md and .agents/skills/ natively; listed so `list` can say so. +NATIVE = ("dsh", "goose", "zed", "crush", "cline", "antigravity", "jules", "devin", "gsd") + + +def detected(spec): + return ( + any(os.environ.get(var) for var in spec.get("env", ())) + or any(shutil.which(cmd) for cmd in spec.get("cmd", ())) + or any((Path.home() / rel).exists() for rel in spec.get("home", ())) + or any((REPO_ROOT / rel).exists() for rel in spec.get("project", ())) + ) + + +def load_servers(): + try: + servers = json.loads(SERVERS_PATH.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError) as exc: + raise SystemExit(f"ERROR: cannot read {SERVERS_PATH}: {exc}") + if not isinstance(servers, dict): + raise SystemExit("ERROR: .agents/mcp/servers.json must contain a JSON object") + for name, config in servers.items(): + if not isinstance(name, str) or not name: + raise SystemExit("ERROR: every MCP server must have a non-empty string name") + if not isinstance(config, dict): + raise SystemExit(f"ERROR: MCP server {name!r} must contain an object") + tools = config.get("tools") + if tools is not None and not ( + isinstance(tools, list) and all(isinstance(tool, str) and tool for tool in tools) + ): + raise SystemExit(f"ERROR: MCP server {name!r} has a malformed tools allowlist") + return servers + + +def json_document(value): + return json.dumps(value, indent=2, ensure_ascii=False) + "\n" + + +def body_of(config): + """The server config without the canonical-only `tools` allowlist.""" + return {key: value for key, value in config.items() if key != "tools"} + + +def is_remote(config): + return "url" in config + + +# ── MCP renderers ───────────────────────────────────────────────────────────── +# Each takes the canonical servers dict and returns {relative path: content}. + + +def render_claude(servers): + rendered = {} + for name, config in servers.items(): + body = body_of(config) + if is_remote(body): + body.setdefault("type", "http") + rendered[name] = body + return {".mcp.json": json_document({"mcpServers": rendered})} + + +def render_cursor(servers): + rendered = {} + for name, config in servers.items(): + body = body_of(config) + body.pop("type", None) + rendered[name] = body + return {".cursor/mcp.json": json_document({"mcpServers": rendered})} + + +def render_vscode(servers): + # VS Code names the top-level key `servers` and wants an explicit type. + rendered = {} + for name, config in servers.items(): + body = body_of(config) + body["type"] = "http" if is_remote(body) else "stdio" + rendered[name] = body + return {".vscode/mcp.json": json_document({"servers": rendered})} + + +def gemini_servers(servers): + # Gemini CLI names streamable HTTP `httpUrl`, keeps `url` for SSE, and + # spells the allowlist `includeTools`. + rendered = {} + for name, config in servers.items(): + body = body_of(config) + transport = body.pop("type", None) + if "url" in body and transport != "sse": + body["httpUrl"] = body.pop("url") + if config.get("tools"): + body["includeTools"] = list(config["tools"]) + rendered[name] = body + return rendered + + +def render_gemini(servers): + # Merged into the committed .gemini/settings.json; handled as a seed. + return {} + + +def render_qwen(servers): + document = { + "contextFileName": ["AGENTS.md", "QWEN.md"], + "mcpServers": gemini_servers(servers), + } + return {".qwen/settings.json": json_document(document)} + + +def opencode_mcp(servers): + rendered = {} + for name, config in servers.items(): + if is_remote(config): + entry = {"type": "remote", "url": config["url"]} + if config.get("headers"): + entry["headers"] = config["headers"] + else: + entry = {"type": "local", "command": [config["command"], *config.get("args", [])]} + if config.get("env"): + entry["environment"] = config["env"] + rendered[name] = entry + return rendered + + +def render_opencode(servers): + return {"opencode.json": json_document({"mcp": opencode_mcp(servers)})} + + +def render_kilo(servers): + return {"kilo.jsonc": json_document({"mcp": opencode_mcp(servers)})} + + +def render_factory(servers): + rendered = {} + for name, config in servers.items(): + body = body_of(config) + body["type"] = body.get("type", "http" if is_remote(body) else "stdio") + rendered[name] = body + return {".factory/mcp.json": json_document({"mcpServers": rendered})} + + +def render_amp(servers): + rendered = {name: body_of(config) for name, config in servers.items()} + return {".amp/settings.json": json_document({"amp.mcpServers": rendered})} + + +def toml_key(value): + if re.fullmatch(r"[A-Za-z0-9_-]+", value): + return value + return json.dumps(value, ensure_ascii=False) + + +def toml_value(value): + if isinstance(value, str): + # json.dumps escapes U+0000-U+001F but leaves U+007F raw, which TOML forbids. + return json.dumps(value, ensure_ascii=False).replace("\x7f", "\\u007f") + if isinstance(value, bool): + return "true" if value else "false" + if isinstance(value, (int, float)) and not isinstance(value, bool): + return repr(value) + if isinstance(value, list): + return "[" + ", ".join(toml_value(item) for item in value) + "]" + if isinstance(value, dict): + pairs = (f"{toml_key(key)} = {toml_value(item)}" for key, item in value.items()) + return "{ " + ", ".join(pairs) + " }" + raise SystemExit(f"ERROR: unsupported TOML value in MCP config: {value!r}") + + +def codex_toml(servers): + lines = ["# Generated by .agents/scripts/sync.py; do not edit."] + for name, config in servers.items(): + lines.extend(("", f"[mcp_servers.{toml_key(name)}]")) + for key, value in config.items(): + if key in ("type", "tools"): + continue + lines.append(f"{toml_key(key)} = {toml_value(value)}") + if config.get("tools"): + lines.append(f"enabled_tools = {toml_value(list(config['tools']))}") + return "\n".join(lines) + "\n" + + +def render_codex(servers): + # Codex loads a project .codex/config.toml only once the project is + # trusted; `install-codex` covers the user-level config instead. + return {".codex/config.toml": codex_toml(servers)} + + +MCP_RENDERERS = { + "claude": render_claude, + "codex": render_codex, + "cursor": render_cursor, + "gemini": render_gemini, + "qwen": render_qwen, + "opencode": render_opencode, + "vscode": render_vscode, + "kilo": render_kilo, + "factory": render_factory, + "amp": render_amp, +} + + +# ── Committed seeds: one managed key each, merged in place ──────────────────── + + +def merged_document(path, key, value): + try: + document = json.loads(path.read_text(encoding="utf-8")) + except FileNotFoundError: + document = {} + except (OSError, json.JSONDecodeError) as exc: + raise SystemExit(f"ERROR: cannot read {path}: {exc}") + if not isinstance(document, dict): + raise SystemExit(f"ERROR: {path} must contain a JSON object") + document[key] = value + return json_document(document) + + +def seed_outputs(servers): + """{path: expected content} for the committed files sync owns one key of. + + Claude Code ignores project MCP servers until they are opted into + `enabledMcpjsonServers`; Gemini CLI keeps MCP servers inside its settings + file. Both files are committed and hand-owned apart from that one key. + """ + seeds = { + REPO_ROOT / ".claude" / "settings.json": ("enabledMcpjsonServers", sorted(servers)), + REPO_ROOT / ".gemini" / "settings.json": ("mcpServers", gemini_servers(servers)), + } + return {path: merged_document(path, key, value) for path, (key, value) in seeds.items()} + + +# ── Skill symlinks ──────────────────────────────────────────────────────────── + + +def sync_skills(target_rel): + target_dir = REPO_ROOT / target_rel + target_dir.mkdir(parents=True, exist_ok=True) + link_prefix = Path(os.path.relpath(SKILLS_ROOT, target_dir)) + + for skill_dir in sorted(SKILLS_ROOT.iterdir()): + if not skill_dir.is_dir(): + continue + link_target = link_prefix / skill_dir.name + link_path = target_dir / skill_dir.name + if link_path.is_symlink(): + if os.readlink(link_path) == str(link_target): + continue + link_path.unlink() + elif link_path.exists(): + raise SystemExit(f"ERROR: {link_path} exists but is not a symlink.") + link_path.symlink_to(link_target) + + for link_path in target_dir.iterdir(): + if not link_path.is_symlink(): + continue + resolved = Path(os.path.normpath(target_dir / os.readlink(link_path))) + if resolved.parent == SKILLS_ROOT and not resolved.exists(): + link_path.unlink() + + +# ── Modes ───────────────────────────────────────────────────────────────────── + + +def atomic_write(path, content): + path.parent.mkdir(parents=True, exist_ok=True) + fd, temporary = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent) + try: + with os.fdopen(fd, "w", encoding="utf-8") as handle: + handle.write(content) + umask = os.umask(0) + os.umask(umask) + os.chmod(temporary, 0o666 & ~umask) + os.replace(temporary, path) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + +def active_harnesses(arguments): + named = [argument for argument in arguments if not argument.startswith("-")] + unknown = sorted(set(named) - set(HARNESSES) - set(NATIVE)) + if unknown: + known = ", ".join([*HARNESSES, *NATIVE]) + raise SystemExit(f"ERROR: unknown harness {', '.join(unknown)}. Known: {known}") + for name in named: + if name in NATIVE: + print(f"{name}: reads AGENTS.md and .agents/skills natively, nothing to generate") + if "--all" in arguments or os.environ.get("GITHUB_ACTIONS") == "true": + return list(HARNESSES) + if named: + return [name for name in named if name in HARNESSES] + return [name for name, spec in HARNESSES.items() if detected(spec)] + + +def sync(arguments): + servers = load_servers() + for path, content in seed_outputs(servers).items(): + atomic_write(path, content) + + generated = [] + for name in active_harnesses(arguments): + spec = HARNESSES[name] + files = MCP_RENDERERS[spec["mcp"]](servers) if spec["mcp"] else {} + for rel, content in files.items(): + atomic_write(REPO_ROOT / rel, content) + if spec["skills"]: + sync_skills(spec["skills"]) + files = {**files, spec["skills"] + "/": None} + if files: + generated.append(f"{name}: {', '.join(sorted(files))}") + print("Synced committed seeds: .claude/settings.json, .gemini/settings.json") + for line in generated: + print(f"Generated {line}") + if not generated and not any(not argument.startswith("-") for argument in arguments): + print("No harnesses detected; run with --all or name one to force.") + + +def check(): + stale = [] + for path, expected in seed_outputs(load_servers()).items(): + try: + current = path.read_text(encoding="utf-8") + except OSError: + current = None + if current != expected: + stale.append(path.relative_to(REPO_ROOT)) + if stale: + print("Stale managed keys in committed seed files:", file=sys.stderr) + for path in stale: + print(f" {path}", file=sys.stderr) + print("Run .agents/scripts/sync.py to regenerate them.", file=sys.stderr) + raise SystemExit(1) + print("Managed keys in committed seed files are current.") + + +def list_harnesses(): + servers = load_servers() + for name, spec in HARNESSES.items(): + adapters = [] + if spec["skills"]: + adapters.append(f"skills → {spec['skills']}") + if spec["mcp"]: + targets = MCP_RENDERERS[spec["mcp"]](servers) or {".gemini/settings.json (seed)": None} + adapters.append("mcp → " + ", ".join(targets)) + state = "detected" if detected(spec) else "not detected" + print(f"{name:10} {state:13} {'; '.join(adapters)}") + print(f"{'native':10} {'—':13} AGENTS.md + .agents/skills, no adapter: {', '.join(NATIVE)}") + + +def install_codex(): + repo_name = re.sub(r"[^A-Za-z0-9_-]+", "-", REPO_ROOT.name).strip("-") or "repo" + begin = f"# BEGIN {repo_name} managed MCP" + end = f"# END {repo_name} managed MCP" + block = begin + "\n" + codex_toml(load_servers()) + end + user_config = Path.home() / ".codex" / "config.toml" + try: + current = user_config.read_text(encoding="utf-8") + except FileNotFoundError: + current = "" + pattern = re.compile( + rf"(?ms)^[ \t]*{re.escape(begin)}\n.*?^[ \t]*{re.escape(end)}[ \t]*\n?" + ) + current = re.sub(r"\n{3,}", "\n\n", pattern.sub("", current)).rstrip() + merged = (current + "\n\n" if current else "") + block + "\n" + atomic_write(user_config, merged) + print(f"Installed managed MCP block: {user_config}") + + +def main(arguments): + modes = {"check": check, "list": list_harnesses, "install-codex": install_codex} + if arguments and arguments[0] in modes: + if arguments[1:]: + raise SystemExit(f"ERROR: {arguments[0]} takes no further arguments") + modes[arguments[0]]() + elif all(argument == "--all" or not argument.startswith("-") for argument in arguments): + sync(arguments) + else: + print(__doc__, file=sys.stderr) + raise SystemExit(2) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/.agents/setup b/.agents/setup new file mode 100755 index 0000000..72f6903 --- /dev/null +++ b/.agents/setup @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Amp orbs run .agents/setup by convention; route it to the shared bootstrap. +exec "$(dirname "$0")/scripts/bootstrap.sh" diff --git a/.claude/hooks/session-start.sh b/.claude/hooks/session-start.sh index b858782..49e87ad 100755 --- a/.claude/hooks/session-start.sh +++ b/.claude/hooks/session-start.sh @@ -2,11 +2,16 @@ # Claude Code SessionStart hook: bootstrap remote sessions (Claude Code on the # web) automatically. Local sessions skip it — run .agents/scripts/bootstrap.sh # once per fresh checkout instead of paying for it on every session start. -set -euo pipefail +# +# Always exits 0: a failing SessionStart hook kills the whole cloud session, +# and a session without generated adapters is still recoverable by hand. +set -uo pipefail if [ "${CLAUDE_CODE_REMOTE:-}" != "true" ]; then exit 0 fi project_dir="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" -exec "$project_dir/.agents/scripts/bootstrap.sh" +"$project_dir/.agents/scripts/bootstrap.sh" || + echo "bootstrap failed; run .agents/scripts/bootstrap.sh manually" >&2 +exit 0 diff --git a/.codex/environments/environment.toml b/.codex/environments/environment.toml deleted file mode 100644 index 7a30cd3..0000000 --- a/.codex/environments/environment.toml +++ /dev/null @@ -1,5 +0,0 @@ -version = 1 - -# Codex cloud runs the same bootstrap as every other environment. -[setup] -script = "bash .agents/scripts/bootstrap.sh" diff --git a/.cursor/environment.json b/.cursor/environment.json new file mode 100644 index 0000000..ea5e42f --- /dev/null +++ b/.cursor/environment.json @@ -0,0 +1,3 @@ +{ + "install": ".agents/scripts/bootstrap.sh" +} diff --git a/.github/workflows/agent-config.yml b/.github/workflows/agent-config.yml index 2f15368..cf80d81 100644 --- a/.github/workflows/agent-config.yml +++ b/.github/workflows/agent-config.yml @@ -9,12 +9,11 @@ on: paths: - '.agents/**' - '.claude/**' - - '.codex/**' - '.cursor/**' - '.gemini/**' - '.devcontainer/**' - - '.github/workflows/agent-config.yml' - - '.mcp.json' + - '.github/**' + - '.gitignore' - '.pre-commit-config.yaml' - 'skills-lock.json' - 'AGENTS.md' @@ -25,12 +24,11 @@ on: paths: - '.agents/**' - '.claude/**' - - '.codex/**' - '.cursor/**' - '.gemini/**' - '.devcontainer/**' - - '.github/workflows/agent-config.yml' - - '.mcp.json' + - '.github/**' + - '.gitignore' - '.pre-commit-config.yaml' - 'skills-lock.json' - 'AGENTS.md' @@ -51,33 +49,47 @@ jobs: - name: Validate scripts run: | bash -n .agents/scripts/bootstrap.sh \ - .agents/scripts/link-skills.sh \ - .agents/scripts/sync-mcp.sh \ + .agents/setup \ .claude/hooks/session-start.sh - python3 -m py_compile .agents/scripts/check-skills.py + python3 -m py_compile .agents/scripts/sync.py .agents/scripts/check-skills.py - - name: Verify MCP adapters + - name: Verify managed keys in committed seeds # Must run before bootstrap: it checks the committed - # enabledMcpjsonServers key in .claude/settings.json against + # enabledMcpjsonServers key in .claude/settings.json and the + # mcpServers key in .gemini/settings.json against # .agents/mcp/servers.json as checked out, before anything - # regenerates it. .mcp.json and friends are gitignored and have no - # committed state to drift-check, so this only covers that one key. - run: .agents/scripts/sync-mcp.sh check + # regenerates them. All other adapters are gitignored and have no + # committed state to drift-check. + run: .agents/scripts/sync.py check - name: Verify skill lock run: .agents/scripts/check-skills.py - name: Bootstrap environment - # Regenerates every gitignored agent adapter (skill symlinks, MCP - # configs) so the steps below can validate them. + # GITHUB_ACTIONS=true makes sync.py generate every harness's + # adapters, so the steps below validate all of them. run: .agents/scripts/bootstrap.sh + - name: Verify generated files are gitignored + # Every file bootstrap generates must be ignored; anything untracked + # after a bootstrap run means .gitignore fell out of step with + # sync.py's renderers. + shell: bash + run: | + untracked="$(git status --porcelain)" + if [ -n "$untracked" ]; then + echo "Bootstrap left files that are neither tracked nor ignored:" + echo "$untracked" + echo "Add them to the generated-adapters block in .gitignore." + exit 1 + fi + - name: Verify skill links shell: bash run: | - broken_links="$(find .claude/skills .cursor/skills -type l ! -exec test -e {} \; -print)" + broken_links="$(find . -maxdepth 3 -type l ! -exec test -e {} \; -print)" if [ -n "$broken_links" ]; then - echo "Broken skill links:" + echo "Broken symlinks:" echo "$broken_links" exit 1 fi @@ -95,17 +107,21 @@ jobs: Path(".claude/settings.json"), Path(".gemini/settings.json"), Path(".devcontainer/devcontainer.json"), + Path(".cursor/environment.json"), + Path("skills-lock.json"), + # Generated by the bootstrap step above: Path(".mcp.json"), Path(".cursor/mcp.json"), - Path("skills-lock.json"), + Path(".vscode/mcp.json"), + Path("opencode.json"), + Path("kilo.jsonc"), + Path(".factory/mcp.json"), + Path(".qwen/settings.json"), + Path(".amp/settings.json"), ): json.loads(path.read_text(encoding="utf-8")) - for path in ( - Path(".codex/config.toml"), - Path(".codex/environments/environment.toml"), - ): - tomllib.loads(path.read_text(encoding="utf-8")) + tomllib.loads(Path(".codex/config.toml").read_text(encoding="utf-8")) PY - name: Reject trailing whitespace outside vendored skills diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000..b3f55b7 --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,25 @@ +# GitHub Copilot's coding agent runs the `copilot-setup-steps` job before the +# agent gets control; it does not honor .devcontainer/. The push/pull_request +# triggers exist only so edits to this file validate in CI. +name: Copilot Setup Steps + +on: + workflow_dispatch: + push: + paths: + - '.github/workflows/copilot-setup-steps.yml' + pull_request: + paths: + - '.github/workflows/copilot-setup-steps.yml' + +jobs: + copilot-setup-steps: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Check out repository + uses: actions/checkout@v7 + + - name: Bootstrap agent environment + run: .agents/scripts/bootstrap.sh diff --git a/.gitignore b/.gitignore index 6730ae9..e9c5c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,17 +4,29 @@ .agent-tools/ # ─── Generated agent adapters ───────────────────────────── -# Written wholesale by .agents/scripts/link-skills.sh and sync-mcp.sh on -# every bootstrap run; nothing here is a bootstrap entry point, so none of it -# needs to exist before that script runs, and none of it carries any -# hand-authored content. Do not hand-edit or commit these. (.claude/settings.json -# and .gemini/settings.json are similar but stay committed — a generator -# only owns one key in each, the rest is left to hand-editing.) +# Written wholesale by .agents/scripts/sync.py (via bootstrap.sh) for the +# harnesses detected on this machine; nothing here is a bootstrap entry point, +# so none of it needs to exist before that script runs, and none of it carries +# any hand-authored content. Do not hand-edit or commit these. +# (.claude/settings.json and .gemini/settings.json are similar but stay +# committed — the generator only owns one key in each, the rest is +# hand-edited. CI fails if a sync.py output ever shows up untracked here, +# so keep this list in step with sync.py's renderers.) /.mcp.json -.cursor/mcp.json -.cursor/skills/ -.codex/config.toml -.claude/skills/ +/.claude/skills/ +/.cursor/mcp.json +/.codex/config.toml +/.vscode/mcp.json +/opencode.json +/kilo.jsonc +/.factory/mcp.json +/.qwen/settings.json +/.amp/settings.json +/.windsurf/skills/ +/.hermes/skills/ +/.trae/skills/ +/.augment/skills/ +/.codebuddy/skills/ # ─── Secrets & env ──────────────────────────────────────── .env diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a1ccd1..ea8cea4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,9 @@ repos: - repo: local hooks: - - id: link-agent-skills - name: Sync agent skill symlinks - entry: .agents/scripts/link-skills.sh + - id: check-agent-sync + name: Verify managed keys in committed agent seeds + entry: .agents/scripts/sync.py check language: script always_run: true pass_filenames: false @@ -13,12 +13,6 @@ repos: language: system always_run: true pass_filenames: false - - id: check-agent-mcp - name: Verify MCP adapters are current - entry: .agents/scripts/sync-mcp.sh check - language: script - always_run: true - pass_filenames: false - id: trailing-whitespace name: Reject trailing whitespace outside vendored skills entry: bash -c '! git grep -nI -E "[[:blank:]]+$" -- . ":(exclude).agents/skills/**"' diff --git a/AGENTS.md b/AGENTS.md index 083d982..39b2dd3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,9 +7,9 @@ of truth, and what it must not touch.> | Path | Purpose | |---|---| -| `.agents/` | Canonical shared skills, MCP definitions, and adapter scripts. | -| `.claude/`, `.cursor/`, `.codex/`, `.gemini/`, `.github/`, `.mcp.json` | Agent adapters. Most files are generated and gitignored — never edit or commit them directly. `.claude/settings.json` and `.gemini/settings.json` stay committed because a generator only owns one key in each and the rest is hand-edited; `.claude/hooks/session-start.sh`, `.codex/environments/environment.toml`, and everything under `.github/` stay committed because a harness reads them before any setup script can run. | -| `.devcontainer/` | Container definition for Codespaces and local devcontainers. | +| `.agents/` | The one canonical agent folder: shared skills, MCP definitions, scripts, and the `setup` entry shim. Everything agent-related is edited here and only here. | +| `.claude/`, `.cursor/`, `.gemini/`, `.github/` | Committed seeds only: files a harness reads straight from the clone before any script can run (hook and environment registrations, one managed key per settings file). Everything else a harness needs is generated from `.agents/` and gitignored — never edit or commit generated adapters. | +| `.devcontainer/` | Container definition for Codespaces, Ona, and local devcontainers. | ## Code quality @@ -65,28 +65,34 @@ is using when it matters. ## Agent configuration - Run `.agents/scripts/bootstrap.sh` once per fresh checkout. It is idempotent - and is what every cloud environment runs on startup. -- Edit shared skills only in `.agents/skills/`, then run - `.agents/scripts/link-skills.sh`. -- Edit MCP servers only in `.agents/mcp/servers.json`, then run - `.agents/scripts/sync-mcp.sh`. -- Repo-local `.codex/config.toml` is generated for parity but is not loaded - automatically by the Codex CLI. Run `.agents/scripts/sync-mcp.sh install-codex` - only when the user wants this repo's MCP servers in their user config. -- `.mcp.json`, `.cursor/mcp.json`, `.cursor/skills/`, `.codex/config.toml`, - and `.claude/skills/` are gitignored — `bootstrap.sh` recreates them every - run, so a fresh checkout has none of them until it runs. They stay out of - git because nothing reads them before that script can generate them, and - nothing in them is hand-authored. + and is what every cloud environment runs on startup — see the environments + table in `.agents/README.md`. Environments with no in-repo hook (Codex + cloud, Jules, Devin, Factory) take that same line in their UI setup field. +- Edit shared skills only in `.agents/skills/`; edit MCP servers only in + `.agents/mcp/servers.json`; then run `.agents/scripts/sync.py`. It renders + adapters for the harnesses detected on this machine (`--all` for every + harness, `list` to see the table). Most harnesses — including dsh, Codex, + Cursor, Copilot's coding agent, OpenCode, Amp, Goose, Zed, Crush, and Kilo — + read `AGENTS.md` and `.agents/skills/` natively and need no adapter at all. +- Generated adapters (`.mcp.json`, `.claude/skills/`, `.cursor/mcp.json`, + `.codex/config.toml`, `.vscode/mcp.json`, `opencode.json`, `kilo.jsonc`, + `.factory/mcp.json`, `.qwen/settings.json`, `.amp/settings.json`, and the + per-harness `*/skills/` link dirs) are gitignored: nothing reads them before + `sync.py` can generate them, and nothing in them is hand-authored. CI fails + if a generated file is not covered by `.gitignore`. - `.claude/settings.json` and `.gemini/settings.json` stay committed even - though `sync-mcp.sh` writes into them: it only owns one key in each - (`enabledMcpjsonServers`, `mcpServers`) and merges it into whatever the - rest of the file already says, so any other hand-authored keys survive a - regen. Files a harness reads to *find* the setup script in the first place - (`.claude/settings.json`'s hook registration, `.claude/hooks/session-start.sh`, - `.codex/environments/environment.toml`, `.github/workflows/agent-config.yml`) - stay committed for the same reason `.gitignore`-ing them would break: they - have to exist before that script can run at all. + though `sync.py` writes into them: it only owns one key in each + (`enabledMcpjsonServers`, `mcpServers`) and merges it into whatever the rest + of the file already says. Files a harness reads to *find* the setup script + in the first place (`.claude/settings.json` + `.claude/hooks/session-start.sh`, + `.cursor/environment.json`, `.github/workflows/copilot-setup-steps.yml`, + `.agents/setup`, `.devcontainer/`) stay committed because they have to exist + before that script can run at all. +- Codex loads a repo-local `.codex/config.toml` only for trusted projects; run + `.agents/scripts/sync.py install-codex` only when the user wants this repo's + MCP servers in their user-level Codex config instead. dsh has no + project-level MCP surface at all (user-level `$DSH_HOME` config only) — + its skills and instructions come from `.agents/skills/` and `AGENTS.md`. - Never commit credentials. Secrets come from the environment or an ignored `.env`; `.env.example` documents the variables. @@ -106,15 +112,14 @@ is using when it matters. Run the checks relevant to the files changed: ```bash -.agents/scripts/link-skills.sh -.agents/scripts/sync-mcp.sh check +.agents/scripts/sync.py check .agents/scripts/check-skills.py git diff --check pre-commit run --all-files ``` -Verify that every generated symlink under `.claude/skills/` and -`.cursor/skills/` resolves and review the final diff before committing. Use +Verify that every generated skill symlink resolves and review the final diff +before committing. Use focused, imperative commit messages and avoid combining unrelated changes. GitHub Actions runs the same agent-configuration checks on pull requests and pushes to `main`; treat that workflow as the enforcement diff --git a/CLAUDE.md b/CLAUDE.md index 3629746..5debd9b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,4 +1,5 @@ @AGENTS.md -This repo keeps reusable agent assets in `.agents/` and syncs tool-specific -adapters with `.agents/scripts/`. +This repo keeps all reusable agent assets in `.agents/` and generates +tool-specific adapters from it with `.agents/scripts/sync.py`; generated +adapters are gitignored. From bae3a0c8946e66d6a3489c1b75742aca444fa7e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 27 Aug 2026 23:55:01 +0000 Subject: [PATCH 2/3] Enforce the model-mix rule for multi-agent workflows with a hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AGENTS.md already tells agents to balance model tiers when work fans out, but a rule that relies on the agent remembering it at authoring time gets skipped — the harness default is to omit model: and inherit the session's strongest tier for every step. Add a PreToolUse hook on the Workflow tool that blocks a script spawning two or more agent() calls when none of them sets model: and no `// single-tier: ` comment claims the exception, feeding the rule back as the block reason. Resumes, named workflows, and single-agent scripts pass through untouched. The hook ships as a committed seed in .claude/settings.json, so every repo created from this template inherits the enforcement; the Dispatching work section now documents the mechanism and the opt-out. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_019vB3bUsXcLptQySBnJz2aG --- .claude/hooks/workflow-model-mix.py | 58 +++++++++++++++++++++++++++++ .claude/settings.json | 11 ++++++ .github/workflows/agent-config.yml | 4 +- AGENTS.md | 7 ++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100755 .claude/hooks/workflow-model-mix.py diff --git a/.claude/hooks/workflow-model-mix.py b/.claude/hooks/workflow-model-mix.py new file mode 100755 index 0000000..b1965b7 --- /dev/null +++ b/.claude/hooks/workflow-model-mix.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +"""PreToolUse hook for the Workflow tool: enforce AGENTS.md's model-mix rule. + +A multi-agent workflow script that never sets `model:` runs every step on the +session's strongest tier. AGENTS.md (Dispatching work) requires balancing +tiers instead, so block such scripts with feedback. Deliberate single-tier +runs opt out with a `// single-tier: ` comment. +""" +import json +import re +import sys + + +def main(): + try: + data = json.load(sys.stdin) + except json.JSONDecodeError: + return 0 + if data.get("tool_name") != "Workflow": + return 0 + + tool_input = data.get("tool_input") or {} + if tool_input.get("resumeFromRunId"): + # The original invocation was already checked; a resume replays it. + return 0 + + script = tool_input.get("script") or "" + if not script and tool_input.get("scriptPath"): + try: + with open(tool_input["scriptPath"], encoding="utf-8") as handle: + script = handle.read() + except OSError: + return 0 + if not script: + # Named workflow; its source is not visible here. + return 0 + + agent_calls = len(re.findall(r"\bagent\s*\(", script)) + if agent_calls < 2: + return 0 + if re.search(r"\bmodel\s*:", script) or re.search(r"//\s*single-tier:", script): + return 0 + + print( + f"This workflow spawns {agent_calls} agent() calls and none sets `model:`, " + "so every step inherits the strongest tier. AGENTS.md (Dispatching work) " + "requires a mix: set model: 'haiku' or 'sonnet' on mechanical scan, " + "fan-out, and summarisation steps, and keep the strongest tier for " + "design, adversarial verification, and final synthesis. If one tier " + "really fits every step, say why in a `// single-tier: ` " + "comment and re-invoke.", + file=sys.stderr, + ) + return 2 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.claude/settings.json b/.claude/settings.json index e719eb3..8d0fe13 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -10,6 +10,17 @@ } ] } + ], + "PreToolUse": [ + { + "matcher": "Workflow", + "hooks": [ + { + "type": "command", + "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/workflow-model-mix.py" + } + ] + } ] }, "enabledMcpjsonServers": [ diff --git a/.github/workflows/agent-config.yml b/.github/workflows/agent-config.yml index cf80d81..ff97617 100644 --- a/.github/workflows/agent-config.yml +++ b/.github/workflows/agent-config.yml @@ -51,7 +51,9 @@ jobs: bash -n .agents/scripts/bootstrap.sh \ .agents/setup \ .claude/hooks/session-start.sh - python3 -m py_compile .agents/scripts/sync.py .agents/scripts/check-skills.py + python3 -m py_compile .agents/scripts/sync.py \ + .agents/scripts/check-skills.py \ + .claude/hooks/workflow-model-mix.py - name: Verify managed keys in committed seeds # Must run before bootstrap: it checks the committed diff --git a/AGENTS.md b/AGENTS.md index 39b2dd3..e00db87 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,6 +48,13 @@ summarisation; the strongest available for design, adversarial review, and final synthesis. Prefer a mix over a single tier by default, and say which tier a step is using when it matters. +Concretely, in `Workflow` scripts set `model:` per `agent()` call — omitting it +inherits the session's strongest tier for every step, which is exactly the +failure mode. A deliberately single-tier workflow states why in a +`// single-tier: ` comment; a committed Claude Code hook +(`.claude/hooks/workflow-model-mix.py`) blocks multi-agent scripts that do +neither. + ## Skills and MCP - **Ponytail is always on**, at its default `full` intensity, for every coding From edc1c3c965998cf6a844aff55ada4e66d9f1dabf Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Aug 2026 00:43:09 +0000 Subject: [PATCH 3/3] Apply adversarial-review findings to the adapter generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirmed against current vendor docs: Windsurf, Hermes, Trae, and Augment all scan .agents/skills/ natively alongside their own dirs, so their symlink adapters were the same noise this branch already deleted for Cursor. Their rows collapse into the native list; only CodeBuddy keeps a generated skills dir. Verified code fixes: - sync_skills no longer crashes when .agents/skills/ is absent - atomic_write preserves an existing file's permissions (install-codex was resetting a possibly-600 ~/.codex/config.toml to 644) and gives new files a plain 644 instead of the umask dance - an explicitly named harness now beats the GITHUB_ACTIONS implicit --all, which silently rendered everything in any Actions job - .vscode/mcp.json keeps an explicit canonical transport (sse) instead of overwriting it with http - detection no longer probes project paths sync.py itself creates, so one --all run can't make a harness permanently "detected" - servers.json entries must carry a url or a command — every renderer depends on one of the two - render_gemini, an empty renderer kept only to occupy the registry, becomes a `note` on the gemini row; dead bool branch in toml_value dropped Docs: resolve the "need no adapter at all" wording that contradicted the MCP renderer table, trim the Agent configuration section to what sync.py list doesn't already say, and label .github/ honestly (seeds plus CI enforcement). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_019vB3bUsXcLptQySBnJz2aG --- .agents/AGENTS.md | 8 ++++-- .agents/README.md | 2 +- .agents/scripts/sync.py | 63 ++++++++++++++++++++++------------------- .gitignore | 4 --- AGENTS.md | 33 +++++++++------------ 5 files changed, 54 insertions(+), 56 deletions(-) diff --git a/.agents/AGENTS.md b/.agents/AGENTS.md index 2c31d46..309ab02 100644 --- a/.agents/AGENTS.md +++ b/.agents/AGENTS.md @@ -12,10 +12,12 @@ Every piece of agent configuration is one of three things: | **Seed** — a harness reads it straight from the clone, before any script can run | Committed in the harness's own location, kept minimal: hook and environment registrations, one managed key per settings file | | **Generated** — everything else a harness wants | Rendered by `scripts/sync.py`, gitignored, recreated per checkout for the harnesses detected on that machine | -Most harnesses need no generated adapter at all: `AGENTS.md` and +Instructions and skills need almost no adapters: `AGENTS.md` and `.agents/skills/` are read natively by Codex, Cursor, Copilot's coding agent, -OpenCode, Amp, Factory, Goose, Zed, Crush, Kilo, Antigravity, dsh, and gsd, -among others. `sync.py list` shows the full table. +OpenCode, Amp, Factory, Windsurf, Hermes, Trae, Augment, Goose, Zed, Crush, +Kilo, Antigravity, dsh, and gsd, among others — only Claude Code and CodeBuddy +get generated skill symlinks. What `sync.py` mostly renders is MCP configs for +tools with a project-level MCP surface; `sync.py list` shows the full table. ## Layout diff --git a/.agents/README.md b/.agents/README.md index 6576640..dab3447 100644 --- a/.agents/README.md +++ b/.agents/README.md @@ -17,7 +17,7 @@ format. Rendered adapters are gitignored and recreated per checkout. # Render adapters for every known harness / a specific one .agents/scripts/sync.py --all -.agents/scripts/sync.py windsurf +.agents/scripts/sync.py opencode # Show the harness table: detection state and what each gets .agents/scripts/sync.py list diff --git a/.agents/scripts/sync.py b/.agents/scripts/sync.py index 0b4d3ed..ac1e76b 100755 --- a/.agents/scripts/sync.py +++ b/.agents/scripts/sync.py @@ -22,9 +22,10 @@ sync.py install-codex install this repo's MCP block into ~/.codex/config.toml Harnesses that read AGENTS.md and .agents/skills/ natively need no adapter and -no entry here: dsh (DeepSeek Harness), Goose, Zed, Crush, Cline, Antigravity, -Jules, Devin, gsd. Copilot's cloud coding agent also reads both natively; the -`vscode` entry below covers local VS Code, which wants .vscode/mcp.json. +no entry here: dsh (DeepSeek Harness), Windsurf, Hermes, Trae, Augment, Goose, +Zed, Crush, Cline, Antigravity, Jules, Devin, gsd. Copilot's cloud coding agent +also reads both natively; the `vscode` entry below covers local VS Code, which +wants .vscode/mcp.json. """ import json import os @@ -39,29 +40,31 @@ SERVERS_PATH = REPO_ROOT / ".agents" / "mcp" / "servers.json" # Each harness: how to detect it on this machine (env vars set, commands on -# PATH, directories under $HOME or the project), where its per-skill symlinks -# go (None = it reads .agents/skills natively), and which MCP renderer feeds it -# (None = it has no project-scoped MCP file). +# PATH, directories under $HOME), where its per-skill symlinks go (None = it +# reads .agents/skills natively), and which MCP renderer feeds it (None = no +# generated project-scoped MCP file). Detection never probes a path sync.py +# itself creates — one run would make that harness sticky-detected. HARNESSES = { "claude": {"env": ["CLAUDECODE", "CLAUDE_CODE_REMOTE"], "cmd": ["claude"], "home": [".claude"], "skills": ".claude/skills", "mcp": "claude"}, "codex": {"cmd": ["codex"], "home": [".codex"], "skills": None, "mcp": "codex"}, "cursor": {"cmd": ["cursor-agent", "cursor"], "home": [".cursor"], "skills": None, "mcp": "cursor"}, - "gemini": {"cmd": ["gemini"], "home": [".gemini"], "skills": None, "mcp": "gemini"}, + "gemini": {"cmd": ["gemini"], "home": [".gemini"], "skills": None, "mcp": None, + "note": "mcp → .gemini/settings.json (committed seed, always synced)"}, "qwen": {"cmd": ["qwen"], "home": [".qwen"], "skills": None, "mcp": "qwen"}, "opencode": {"cmd": ["opencode"], "home": [".config/opencode"], "skills": None, "mcp": "opencode"}, - "vscode": {"cmd": ["code"], "project": [".vscode"], "skills": None, "mcp": "vscode"}, + "vscode": {"cmd": ["code"], "skills": None, "mcp": "vscode"}, "kilo": {"cmd": ["kilo"], "home": [".config/kilo"], "skills": None, "mcp": "kilo"}, "factory": {"cmd": ["droid"], "home": [".factory"], "skills": None, "mcp": "factory"}, "amp": {"cmd": ["amp"], "home": [".amp"], "skills": None, "mcp": "amp"}, - "windsurf": {"home": [".codeium"], "project": [".windsurf"], "skills": ".windsurf/skills", "mcp": None}, - "hermes": {"cmd": ["hermes"], "home": [".hermes"], "skills": ".hermes/skills", "mcp": None}, - "trae": {"home": [".trae"], "project": [".trae"], "skills": ".trae/skills", "mcp": None}, - "augment": {"cmd": ["auggie"], "home": [".augment"], "skills": ".augment/skills", "mcp": None}, "codebuddy": {"cmd": ["codebuddy"], "home": [".codebuddy"], "skills": ".codebuddy/skills", "mcp": None}, } # Read AGENTS.md and .agents/skills/ natively; listed so `list` can say so. -NATIVE = ("dsh", "goose", "zed", "crush", "cline", "antigravity", "jules", "devin", "gsd") +# Windsurf, Hermes, Trae, and Augment scan .agents/skills/ alongside their own +# dirs per their current docs, so they need no symlink adapter (only CodeBuddy +# still does). +NATIVE = ("dsh", "windsurf", "hermes", "trae", "augment", "goose", "zed", + "crush", "cline", "antigravity", "jules", "devin", "gsd") def detected(spec): @@ -69,7 +72,6 @@ def detected(spec): any(os.environ.get(var) for var in spec.get("env", ())) or any(shutil.which(cmd) for cmd in spec.get("cmd", ())) or any((Path.home() / rel).exists() for rel in spec.get("home", ())) - or any((REPO_ROOT / rel).exists() for rel in spec.get("project", ())) ) @@ -85,6 +87,8 @@ def load_servers(): raise SystemExit("ERROR: every MCP server must have a non-empty string name") if not isinstance(config, dict): raise SystemExit(f"ERROR: MCP server {name!r} must contain an object") + if not isinstance(config.get("url"), str) and not isinstance(config.get("command"), str): + raise SystemExit(f"ERROR: MCP server {name!r} needs a `url` or a `command`") tools = config.get("tools") if tools is not None and not ( isinstance(tools, list) and all(isinstance(tool, str) and tool for tool in tools) @@ -134,7 +138,7 @@ def render_vscode(servers): rendered = {} for name, config in servers.items(): body = body_of(config) - body["type"] = "http" if is_remote(body) else "stdio" + body.setdefault("type", "http" if is_remote(body) else "stdio") rendered[name] = body return {".vscode/mcp.json": json_document({"servers": rendered})} @@ -154,11 +158,6 @@ def gemini_servers(servers): return rendered -def render_gemini(servers): - # Merged into the committed .gemini/settings.json; handled as a seed. - return {} - - def render_qwen(servers): document = { "contextFileName": ["AGENTS.md", "QWEN.md"], @@ -194,7 +193,7 @@ def render_factory(servers): rendered = {} for name, config in servers.items(): body = body_of(config) - body["type"] = body.get("type", "http" if is_remote(body) else "stdio") + body.setdefault("type", "http" if is_remote(body) else "stdio") rendered[name] = body return {".factory/mcp.json": json_document({"mcpServers": rendered})} @@ -216,7 +215,7 @@ def toml_value(value): return json.dumps(value, ensure_ascii=False).replace("\x7f", "\\u007f") if isinstance(value, bool): return "true" if value else "false" - if isinstance(value, (int, float)) and not isinstance(value, bool): + if isinstance(value, (int, float)): return repr(value) if isinstance(value, list): return "[" + ", ".join(toml_value(item) for item in value) + "]" @@ -249,7 +248,6 @@ def render_codex(servers): "claude": render_claude, "codex": render_codex, "cursor": render_cursor, - "gemini": render_gemini, "qwen": render_qwen, "opencode": render_opencode, "vscode": render_vscode, @@ -293,6 +291,8 @@ def seed_outputs(servers): def sync_skills(target_rel): + if not SKILLS_ROOT.is_dir(): + return target_dir = REPO_ROOT / target_rel target_dir.mkdir(parents=True, exist_ok=True) link_prefix = Path(os.path.relpath(SKILLS_ROOT, target_dir)) @@ -327,9 +327,11 @@ def atomic_write(path, content): try: with os.fdopen(fd, "w", encoding="utf-8") as handle: handle.write(content) - umask = os.umask(0) - os.umask(umask) - os.chmod(temporary, 0o666 & ~umask) + try: + mode = path.stat().st_mode & 0o777 + except OSError: + mode = 0o644 + os.chmod(temporary, mode) os.replace(temporary, path) finally: if os.path.exists(temporary): @@ -345,10 +347,12 @@ def active_harnesses(arguments): for name in named: if name in NATIVE: print(f"{name}: reads AGENTS.md and .agents/skills natively, nothing to generate") - if "--all" in arguments or os.environ.get("GITHUB_ACTIONS") == "true": + if "--all" in arguments: return list(HARNESSES) if named: return [name for name in named if name in HARNESSES] + if os.environ.get("GITHUB_ACTIONS") == "true": + return list(HARNESSES) return [name for name, spec in HARNESSES.items() if detected(spec)] @@ -400,8 +404,9 @@ def list_harnesses(): if spec["skills"]: adapters.append(f"skills → {spec['skills']}") if spec["mcp"]: - targets = MCP_RENDERERS[spec["mcp"]](servers) or {".gemini/settings.json (seed)": None} - adapters.append("mcp → " + ", ".join(targets)) + adapters.append("mcp → " + ", ".join(MCP_RENDERERS[spec["mcp"]](servers))) + if spec.get("note"): + adapters.append(spec["note"]) state = "detected" if detected(spec) else "not detected" print(f"{name:10} {state:13} {'; '.join(adapters)}") print(f"{'native':10} {'—':13} AGENTS.md + .agents/skills, no adapter: {', '.join(NATIVE)}") diff --git a/.gitignore b/.gitignore index e9c5c8f..f1901ba 100644 --- a/.gitignore +++ b/.gitignore @@ -22,10 +22,6 @@ /.factory/mcp.json /.qwen/settings.json /.amp/settings.json -/.windsurf/skills/ -/.hermes/skills/ -/.trae/skills/ -/.augment/skills/ /.codebuddy/skills/ # ─── Secrets & env ──────────────────────────────────────── diff --git a/AGENTS.md b/AGENTS.md index e00db87..f293b83 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ of truth, and what it must not touch.> | Path | Purpose | |---|---| | `.agents/` | The one canonical agent folder: shared skills, MCP definitions, scripts, and the `setup` entry shim. Everything agent-related is edited here and only here. | -| `.claude/`, `.cursor/`, `.gemini/`, `.github/` | Committed seeds only: files a harness reads straight from the clone before any script can run (hook and environment registrations, one managed key per settings file). Everything else a harness needs is generated from `.agents/` and gitignored — never edit or commit generated adapters. | +| `.claude/`, `.cursor/`, `.gemini/`, `.github/` | Committed seeds (files a harness reads straight from the clone before any script can run: hook and environment registrations, one managed key per settings file) plus CI enforcement under `.github/workflows/`. Everything else a harness needs is generated from `.agents/` and gitignored — never edit or commit generated adapters. | | `.devcontainer/` | Container definition for Codespaces, Ona, and local devcontainers. | ## Code quality @@ -77,29 +77,24 @@ neither. cloud, Jules, Devin, Factory) take that same line in their UI setup field. - Edit shared skills only in `.agents/skills/`; edit MCP servers only in `.agents/mcp/servers.json`; then run `.agents/scripts/sync.py`. It renders - adapters for the harnesses detected on this machine (`--all` for every - harness, `list` to see the table). Most harnesses — including dsh, Codex, - Cursor, Copilot's coding agent, OpenCode, Amp, Goose, Zed, Crush, and Kilo — - read `AGENTS.md` and `.agents/skills/` natively and need no adapter at all. -- Generated adapters (`.mcp.json`, `.claude/skills/`, `.cursor/mcp.json`, - `.codex/config.toml`, `.vscode/mcp.json`, `opencode.json`, `kilo.jsonc`, - `.factory/mcp.json`, `.qwen/settings.json`, `.amp/settings.json`, and the - per-harness `*/skills/` link dirs) are gitignored: nothing reads them before - `sync.py` can generate them, and nothing in them is hand-authored. CI fails - if a generated file is not covered by `.gitignore`. + gitignored adapters for the harnesses detected on this machine (`--all` for + every harness, `list` for the full table of who gets what). Instructions and + skills ride the standards: harnesses read `AGENTS.md` (Claude Code through + the committed `CLAUDE.md` pointer, Gemini through the committed + `context.fileName` seed) and `.agents/skills/` (Claude Code and CodeBuddy + through generated symlinks). The rendered files are MCP configs for tools + with a project-level MCP surface; dsh has none (user-level `$DSH_HOME` + config only). - `.claude/settings.json` and `.gemini/settings.json` stay committed even though `sync.py` writes into them: it only owns one key in each (`enabledMcpjsonServers`, `mcpServers`) and merges it into whatever the rest - of the file already says. Files a harness reads to *find* the setup script - in the first place (`.claude/settings.json` + `.claude/hooks/session-start.sh`, - `.cursor/environment.json`, `.github/workflows/copilot-setup-steps.yml`, - `.agents/setup`, `.devcontainer/`) stay committed because they have to exist - before that script can run at all. + of the file already says. The other committed agent files are the hooks that + reach the setup script before it can run (see the repository-layout table); + everything else is generated, and CI fails if a generated file is not + covered by `.gitignore`. - Codex loads a repo-local `.codex/config.toml` only for trusted projects; run `.agents/scripts/sync.py install-codex` only when the user wants this repo's - MCP servers in their user-level Codex config instead. dsh has no - project-level MCP surface at all (user-level `$DSH_HOME` config only) — - its skills and instructions come from `.agents/skills/` and `AGENTS.md`. + MCP servers in their user-level Codex config instead. - Never commit credentials. Secrets come from the environment or an ignored `.env`; `.env.example` documents the variables.