diff --git a/.dev-brain/STATE.md b/.dev-brain/STATE.md index 89dc6a0..ec4ea2b 100644 --- a/.dev-brain/STATE.md +++ b/.dev-brain/STATE.md @@ -1,25 +1,26 @@ # State — agents-platform -Updated: 2026-11-15 +Updated: 2026-11-20 ## Goal -Claude Code plugin for readable, maintainable code at the lowest context cost — acceptance: installs from GitHub with two commands, every claim backed by `evals/` evidence, measured benefit on real tasks. +Plugin (Claude Code; Codex CLI and Copilot read it too) for readable, maintainable code at the lowest context cost — acceptance: installs from GitHub with two commands, every claim backed by `evals/` evidence, measured benefit on real tasks. ## Done (latest first, max 5) -- Plugin 2.2.1 in a PR, not merged: `handoff` stops writing branch/HEAD/commit status (state header is `Updated: `), step 4 names commands, tooling, gotchas; CI pin 2.1.325 plus a newest-release job — evidence: `python3 evals/offline/check.py` ALL PASS on 2.1.325 (local; PR #6 CI success, manual run of both jobs success; weekly schedule NOT RUN until merged) +- Plugin 2.3.0 in a PR, not merged: Codex 0.171.0 and Copilot CLI 1.0.114 support (six `agents/openai.yaml`, guard denies on Codex, Copilot context key) — evidence: `python3 evals/offline/check.py` ALL PASS (24 checks, local), six mutations each FAIL the intended check; PR #7 CI success, manual run of both jobs success (newest: Claude Code 2.1.329, Codex 0.171.0, Copilot CLI 1.0.114) +- Plugin 2.2.1 merged (PR #6): `handoff` stops writing branch/HEAD/commit status, CI pin 2.1.325 plus a newest-release job — evidence: CI success on both jobs; weekly schedule NOT RUN until it first fires - Offline check on GitHub Actions for every PR — evidence: PR #5 run `offline-check` success, ALL PASS on a clean runner - Plugin 2.2.0 merged (PR #4): minimal `start`, review passes the Goal line, reviewer checks weakened tests — evidence: `python3 evals/offline/check.py` ALL PASS on a clean clone of main (0d01d2b) - No commit without the user, enforced: `PreToolUse` git guard (2.1.0) — evidence: `python3 evals/offline/check.py` ALL PASS; mutation without the hook FAILs -- Plugin-only layout: rules + state via `SessionStart` hook, workflows as zero-cost skills — evidence: `python3 evals/offline/check.py` ALL PASS ## In progress / blockers - Benefit of the rules on real code — status: NOT RUN; `claude plugin eval` (with/without plugin) would measure it but needs the user's credentials and tokens - Minimal `start` with a real model — status: partly seen on Presidio (deny rules and Stop hook adopted, `AGENTS.md` kept, not trimmed); its deletion-candidate list not seen - Opus 5.5 system card read only through secondary reports (PDF unreachable here) +- VS Code Copilot, interactive Copilot prompts and the Codex `/hooks` trust screen — status: NOT RUN (cannot be driven here) ## Known pre-existing failures - none ## Next (max 3) -1. User: review the 2.2.1 PR and decide the merge, then `claude plugin marketplace update dev-brain`; review hph PR #10. +1. User: try 2.3.0 in VS Code Copilot (do the rules arrive? do the workflows list?) and in Codex (`/hooks` trust), then decide the PR merge and run `claude plugin marketplace update dev-brain`; review hph PR #10. 2. User decision: draft a `claude plugin eval` suite (authorization, weakened tests, `start` size) and run it with `--max-cost-usd`. 3. Collect Presidio feedback: `/context all` from a fresh session, the `start` candidate list; change only what repeats twice. diff --git a/.github/workflows/offline-check.yml b/.github/workflows/offline-check.yml index 79fd33d..b0815d9 100644 --- a/.github/workflows/offline-check.yml +++ b/.github/workflows/offline-check.yml @@ -1,9 +1,9 @@ name: offline-check -# Runs evals/offline/check.py: the real Claude Code binary against a local mock -# model. No secrets, no tokens, no network beyond the package registry. -# Pull requests test the pinned version. Pushes to main, the weekly schedule and -# manual runs also test the newest release, to see a Claude Code change early. +# Runs evals/offline/check.py: the real Claude Code, Codex CLI and Copilot CLI +# binaries against a local mock model. No secrets, no tokens, no network beyond the +# package registry. Pull requests test the pinned versions. Pushes to main, the +# weekly schedule and manual runs also test the newest releases, to see a change early. on: pull_request: push: @@ -21,7 +21,7 @@ concurrency: jobs: pinned: - name: Claude Code 2.1.325 (pinned) + name: Pinned versions (Claude Code 2.1.325, Codex 0.171.0, Copilot CLI 1.0.114) runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -31,15 +31,19 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 - # The version the check was last tested against. Bump it deliberately, + # The versions the check was last tested against. Bump them deliberately, # together with the "provato su" line in MANUALE.md. - - name: Install Claude Code 2.1.325 - run: npm install --global @anthropic-ai/claude-code@2.1.325 + - name: Install the agents + run: npm install --global @anthropic-ai/claude-code@2.1.325 @openai/codex@0.171.0 @github/copilot@1.0.114 + # CODEX and COPILOT make those checks required: a missing binary fails the job. - name: Offline check + env: + CODEX: codex + COPILOT: copilot run: python3 evals/offline/check.py latest: - name: Claude Code latest (early warning) + name: Latest versions (early warning) if: github.event_name != 'pull_request' runs-on: ubuntu-latest timeout-minutes: 10 @@ -50,9 +54,15 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 - - name: Install the newest Claude Code - run: npm install --global @anthropic-ai/claude-code@latest - - name: Show the version under test - run: claude --version + - name: Install the newest agents + run: npm install --global @anthropic-ai/claude-code@latest @openai/codex@latest @github/copilot@latest + - name: Show the versions under test + run: | + claude --version + codex --version + copilot --version - name: Offline check + env: + CODEX: codex + COPILOT: copilot run: python3 evals/offline/check.py diff --git a/AGENTS.md b/AGENTS.md index ddb8d36..91cdb1a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # Maintaining dev-brain -This repository is a Claude Code plugin marketplace with one plugin, `dev-brain`, in `core/`. It is not an application. +This repository is a plugin marketplace with one plugin, `dev-brain`, in `core/`, built for Claude Code. Codex CLI and Copilot read the same marketplace and plugin unchanged; the few host differences are listed below. It is not an application. Its primary goal is readable, maintainable code across languages and frameworks. Workflows and saved state support that goal. ## What belongs where @@ -8,10 +8,11 @@ Its primary goal is readable, maintainable code across languages and frameworks. - `core/AGENTS.md` — the global rules, injected into every session by the `SessionStart` hook. Keep it short: only instructions that change default behavior. - `core/skills/` — Agent Skills. User-invoked workflows (`start`, `resume`, `handoff`, `impact`, `learn`, `review`) set `disable-model-invocation: true`, so they cost no context until invoked; `debugging`, `engineering-risk`, `review-feedback` are loaded by the model when relevant. - `core/agents/reviewer.md` — the read-only reviewer; its `tools` line is the enforcement. -- `core/hooks/hooks.json` + `core/bin/dev-brain-context` — inject rules and the project state (3000-character budget). -- `core/bin/dev-brain-guard` — `PreToolUse` hook that answers "ask" for git commands changing history, branches or the remote; keep its list in sync with the Authorization rules in `core/AGENTS.md`. +- `core/hooks/hooks.json` + `core/bin/dev-brain-context` — inject rules and the project state (3000-character budget). Copilot CLI also needs a top-level `additionalContext`, which Codex rejects, so the script adds it only when `COPILOT_PLUGIN_ROOT` is set. +- `core/bin/dev-brain-guard` — `PreToolUse` hook that answers "ask" for git commands changing history, branches or the remote; keep its list in sync with the Authorization rules in `core/AGENTS.md`. Codex cannot ask (an "ask" fails the hook and the command runs), so there it answers "deny". +- `core/skills//agents/openai.yaml` — Codex ignores `disable-model-invocation`; this file (`allow_implicit_invocation: false`) keeps the six workflows out of its skill listing. Add one to every new workflow skill. - `core/.claude-plugin/plugin.json` — bump `version` on every change so installed copies refresh. `.claude-plugin/marketplace.json` at the root lists the plugin. -- `evals/` — scenarios, measured results, and `offline/check.py` with `offline/mock_model.py`, a zero-token check against the real Claude Code binary. +- `evals/` — scenarios, measured results, and `offline/check.py` with `offline/mock_model.py`, a zero-token check against the real Claude Code, Codex CLI and Copilot CLI binaries. VS Code cannot run here, so it is untested. ## Changing the harness @@ -27,6 +28,6 @@ Never add rules by intuition alone. A rule that the model already follows is pur - All kit content is English. Exception: `MANUALE.md` is the Italian user manual. - Runtime dependencies: Claude Code, `python3`, `git`. -- Skills and rules stay in standard formats (`AGENTS.md`, `SKILL.md`) with no absolute paths, so another agent can be supported later with an adapter instead of a rewrite. +- Skills and rules stay in standard formats (`AGENTS.md`, `SKILL.md`) with no absolute paths, so another agent is supported with an adapter instead of a rewrite. Host-specific code stays limited to the items above. - Do not duplicate a rule or template across files: `core/` holds each once. - Do not copy project facts (stack, commands, state) from a destination repository into this source repository. diff --git a/MANUALE.md b/MANUALE.md index d20cc84..f4e51fe 100644 --- a/MANUALE.md +++ b/MANUALE.md @@ -1,6 +1,6 @@ # dev-brain — Manuale d'uso -> Manuale utente in italiano; il resto del kit è in inglese. Versione 2026-11-15, plugin 2.2.1, provato su Claude Code 2.1.325. Indipendente dal provider del modello. +> Manuale utente in italiano; il resto del kit è in inglese. Versione 2026-11-20, plugin 2.3.0, provato su Claude Code 2.1.325, Codex CLI 0.171.0 e Copilot CLI 1.0.114. Indipendente dal provider del modello. ## Avvio rapido @@ -21,7 +21,7 @@ Da lì: `resume` a inizio sessione → lavoro → `review` → `handoff` a fine ## 1. Cos'è -Un plugin per Claude Code. Fa tre cose: +Un plugin per Claude Code, installabile anche in Codex CLI e GitHub Copilot (sezione 12). Fa tre cose: 1. **Regole globali** in ogni sessione: soluzione più semplice e completa, idiomi del progetto, una sola fonte per ogni regola di business, errori mai nascosti, niente commit senza la tua decisione, controlli riportati come PASS / FAIL / NOT RUN. 2. **Continuità**: lo stato del progetto (`.dev-brain/STATE.md`) arriva in ogni sessione, anche dopo `/clear` e dopo la compattazione. @@ -33,7 +33,7 @@ Non decide quando committare, non sostituisce test né la tua revisione, e non g ## 2. Installazione -Prerequisiti: Claude Code, `python3`, `git`. +Prerequisiti: Claude Code (o Codex / Copilot, sezione 12), `python3`, `git`. ```bash claude plugin marketplace add Stcant/agents-platform @@ -188,7 +188,9 @@ Il **controllo offline** installa il plugin in una home temporanea e sostituisce - reviewer che legge il diff ma non scrive; - commit e push che chiedono conferma anche con git permesso nelle impostazioni. -Non valuta la qualità delle risposte. Su GitHub Actions gira a ogni pull request sulla versione fissata di Claude Code; a ogni push su `main`, ogni lunedì e su richiesta gira anche sull'ultima versione, per accorgersi presto di un cambiamento. +Se trova `codex` o `copilot` nel PATH (o nelle variabili `CODEX` e `COPILOT`, che in quel caso li rendono obbligatori) ripete su ciascuno i controlli che hanno senso: regole e stato, workflow fuori dall'elenco, commit e push fermati, reviewer senza shell su Copilot. + +Non valuta la qualità delle risposte. Su GitHub Actions gira a ogni pull request sulle versioni fissate (Claude Code 2.1.325, Codex 0.171.0, Copilot CLI 1.0.114); a ogni push su `main`, ogni lunedì e su richiesta gira anche sulle ultime versioni, per accorgersi presto di un cambiamento. `core/AGENTS.md` e le skill restano in formati standard: supportare un altro agente in futuro richiede un adattatore, non una riscrittura. @@ -213,3 +215,26 @@ Non valuta la qualità delle risposte. Su GitHub Actions gira a ogni pull reques - Il controllo offline verifica cosa il kit invia e permette, non le risposte. - Il reviewer chiede approvazione per le scritture: se approvi, scrive. - Le regole costano circa 1200 token per sessione; se rendano non è ancora dimostrato. +- Codex e Copilot sono provati solo con il modello finto e con i loro programmi a riga di comando; VS Code non è stato eseguito (sezione 12). + +--- + +## 12. Codex e GitHub Copilot + +Lo stesso marketplace e lo stesso plugin si installano senza modifiche. Provato con i programmi reali contro il modello finto, non con un modello vero. + +| | Codex CLI | Copilot CLI | +| --- | --- | --- | +| Installazione | `codex plugin marketplace add Stcant/agents-platform`, poi `codex plugin add dev-brain@dev-brain` | `copilot plugin marketplace add Stcant/agents-platform`, poi `copilot plugin install dev-brain@dev-brain` | +| Regole e stato | Sì, ma solo dopo che approvi gli hook del plugin con `/hooks`: finché non lo fai regole, stato e guardia git sono spenti senza alcun avviso | Sì | +| Workflow | `$dev-brain:start`; non costano contesto (file `agents/openai.yaml` in ogni workflow) | Elencati da `copilot skill list`, non costano contesto; la chiamata in sessione interattiva non è stata provata | +| Commit, push, cambio di branch | **Rifiutati**: gli hook di Codex non sanno chiedere conferma, quindi il comando lo esegui tu | Chiede conferma (la richiesta interattiva non è stata provata; in `-p`, che non può chiedere, rifiuta) | +| Reviewer | Non viene caricato: `review` lo dice e si ferma | Caricato, in sola lettura ma senza shell: non può lanciare git e legge i file elencati | + +**VS Code (Copilot in modalità agente): NON PROVATO**, non si può eseguire qui. La documentazione dice che i plugin agente leggono il formato Claude: aggiungi `Stcant/agents-platform` dall'editor delle personalizzazioni (Configure Marketplaces) o con l'impostazione `chat.plugins.marketplaces`, poi installa `dev-brain`. Come VS Code carichi hook e agenti di un plugin non è documentato: verifica che le regole arrivino; se non arrivano, incolla `core/AGENTS.md` nelle istruzioni di Copilot. + +Cosa è stato aggiunto per far funzionare tutto (solo ciò che i programmi reali hanno mostrato rotto): + +- 6 file `agents/openai.yaml` (Codex ignora `disable-model-invocation`: senza, i 6 workflow comparivano nell'elenco, circa 1100 caratteri a sessione); +- la guardia git risponde "deny" invece di "ask" quando gira su Codex (Codex segna l'hook come fallito e il comando parte lo stesso); +- l'hook di contesto aggiunge la chiave `additionalContext` che Copilot CLI legge al posto di `hookSpecificOutput`, solo quando è Copilot a eseguirlo (Codex la rifiuta). diff --git a/README.md b/README.md index 4e36e51..78a094b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # dev-brain -A Claude Code plugin that steers ordinary coding requests toward readable, maintainable code, keeps each project's state across sessions, and spends as little context as possible. Works with any model Claude Code can use. +A plugin for Claude Code (also installable in Codex CLI and GitHub Copilot, see below) that steers ordinary coding requests toward readable, maintainable code, keeps each project's state across sessions, and spends as little context as possible. Works with any model the host can use. It provides: - global engineering rules, injected into every session; @@ -8,7 +8,7 @@ It provides: - user-invoked workflows: `start`, `resume`, `handoff`, `impact`, `learn`, `review` (no context cost until invoked); - three skills the model loads when relevant: `debugging`, `engineering-risk`, `review-feedback`; - a read-only reviewer subagent; -- a guard that makes Claude Code ask you before any commit, push or destructive git command. +- a guard that makes the host ask you before any commit, push or destructive git command (Codex refuses instead, see below). > Manuale utente in italiano: [MANUALE.md](MANUALE.md). @@ -21,6 +21,21 @@ claude plugin install dev-brain@dev-brain Requires `python3` and `git`. Update with `claude plugin marketplace update dev-brain`. For local development, add the cloned folder instead: `claude plugin marketplace add /path/to/agents-platform` (read in place). +## Codex and GitHub Copilot + +The same marketplace and plugin install unchanged; nothing is copied or forked. Checked with the real binaries against a mock model (`python3 evals/offline/check.py`), not with a real model. + +| | Claude Code | Codex CLI | Copilot CLI | +| --- | --- | --- | --- | +| Install | `claude plugin marketplace add Stcant/agents-platform`, then `claude plugin install dev-brain@dev-brain` | `codex plugin marketplace add Stcant/agents-platform`, then `codex plugin add dev-brain@dev-brain` | `copilot plugin marketplace add Stcant/agents-platform`, then `copilot plugin install dev-brain@dev-brain` | +| Rules and state | yes | yes, once you trust the plugin's hooks with `/hooks`; until then they are silently off, and so is the git guard | yes | +| Workflow call | `/dev-brain:start` | `$dev-brain:start` | listed by `copilot skill list`; calling them in an interactive session is NOT RUN | +| Workflows cost no context | yes | yes, through `agents/openai.yaml` in each workflow | yes | +| Commit, push, branch change | asks you | refused: Codex hooks cannot ask, so you run the command | asks you (the interactive prompt is NOT RUN; `-p` mode cannot ask and refuses) | +| Reviewer | read-only, reads the diff with git | not loaded: `review` says so and stops | read-only, but without a shell: it cannot run git and reads the listed files | + +VS Code (Copilot agent mode) is NOT RUN: it cannot be executed here. Its documentation says agent plugins read the Claude format: add `Stcant/agents-platform` in the Customizations editor (Configure Marketplaces) or in the `chat.plugins.marketplaces` setting, then install `dev-brain`. How VS Code loads a plugin's hooks and agents is not documented, so check that the rules arrive; if they do not, paste `core/AGENTS.md` into your Copilot instructions. + ## First step in every repository: `/dev-brain:start` Run it once in each repository, from its root. Everything else builds on the two files it creates: `resume` and `handoff` read and rewrite the state, every session gets it automatically, and Claude Code reads the project facts natively. @@ -53,7 +68,7 @@ For planning use Claude Code's native plan mode (Shift+Tab): it is read-only by ## What is enforced, what is instructed -- **No commit without you: enforced.** A `PreToolUse` hook answers "ask" for `git commit` (including `--amend`), `push`, `merge`, `rebase`, `cherry-pick`, `revert`, `checkout`/`switch`, history-moving `reset`, `clean -f`, `branch -d/-m/-f`, `stash drop/pop/clear` and tag deletion, even inside chained commands and even when your settings allow git. Read-only git runs normally. +- **No commit without you: enforced.** A `PreToolUse` hook answers "ask" (on Codex, which cannot ask: "deny") for `git commit` (including `--amend`), `push`, `merge`, `rebase`, `cherry-pick`, `revert`, `checkout`/`switch`, history-moving `reset`, `clean -f`, `branch -d/-m/-f`, `stash drop/pop/clear` and tag deletion, even inside chained commands and even when your settings allow git. Read-only git runs normally. - **Reviewer read-only: enforced.** Its tool list allows Read, Grep, Glob and `git diff/log/show/status`; any command that creates, changes or removes files needs your approval. - **State budget: enforced.** Over 3000 characters only a notice is injected, telling the model to read the file and suggest `handoff`. - **Everything else is instructed:** rules guide the model; they do not guarantee good code. @@ -61,10 +76,10 @@ For planning use Claude Code's native plan mode (Shift+Tab): it is read-only by ## Evaluation ```bash -python3 evals/offline/check.py # CLAUDE= if claude is not on PATH +python3 evals/offline/check.py # CLAUDE / CODEX / COPILOT= if not on PATH ``` -Installs the plugin into a throwaway home, replaces the model with a local mock that records every request, and checks in about 20 seconds, at zero token cost: rules and state reach the session, oversized state becomes a notice, workflows expand and stay out of the skill listing, the reviewer reads the diff but cannot write, and commit and push need you even when your settings allow git. GitHub Actions runs it on every pull request (`.github/workflows/offline-check.yml`, Claude Code pinned to 2.1.325, no secrets); pushes to `main`, a weekly run and manual runs also test the newest Claude Code release. It does not judge model behavior; `evals/scenarios/` describes the real-model scenarios and `evals/results.md` records decisions and evidence. +Installs the plugin into a throwaway home, replaces the model with a local mock that records every request, and checks in about 20 seconds, at zero token cost. Claude Code (required): rules and state reach the session, oversized state becomes a notice, workflows expand and stay out of the skill listing, the reviewer reads the diff but cannot write, and commit and push need you even when your settings allow git. Codex CLI and Copilot CLI (run when found; an explicit `CODEX` or `COPILOT` variable makes them required): rules and state arrive, workflows stay out of the skill listing, commit and push are stopped, and Copilot's reviewer has no shell. GitHub Actions runs it on every pull request (`.github/workflows/offline-check.yml`, Claude Code 2.1.325, Codex 0.171.0, Copilot CLI 1.0.114, no secrets); pushes to `main`, a weekly run and manual runs also test the newest releases. It does not judge model behavior; `evals/scenarios/` describes the real-model scenarios and `evals/results.md` records decisions and evidence. ## Layout diff --git a/core/.claude-plugin/plugin.json b/core/.claude-plugin/plugin.json index f8b3b81..94d98f4 100644 --- a/core/.claude-plugin/plugin.json +++ b/core/.claude-plugin/plugin.json @@ -1,5 +1,5 @@ { "name": "dev-brain", - "version": "2.2.1", + "version": "2.3.0", "description": "Readable, maintainable code at low context cost: global rules, project state, workflows, skills and a read-only reviewer." } diff --git a/core/bin/dev-brain-context b/core/bin/dev-brain-context index 88ee6ef..6dfdf8a 100755 --- a/core/bin/dev-brain-context +++ b/core/bin/dev-brain-context @@ -2,9 +2,11 @@ """SessionStart hook: give the agent the global rules and the project's saved state. Claude Code runs it at startup, resume, /clear and after compaction, and adds the -printed `additionalContext` to the session. The project is found from the hook's -JSON on stdin (`cwd`), else from the current directory. `--text` prints the plain -context instead, for checking it by hand. +printed `additionalContext` to the session; Codex does the same with the same output. +Copilot CLI ignores the `hookSpecificOutput` form and reads a top-level +`additionalContext` instead (Codex rejects that key, so only Copilot gets it). The +project is found from the hook's JSON on stdin (`cwd`), else from the current +directory. `--text` prints the plain context instead, for checking it by hand. """ import json import os @@ -73,7 +75,10 @@ def main(): if "--text" in sys.argv: print(context) else: - print(json.dumps({"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": context}})) + output = {"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": context}} + if os.environ.get("COPILOT_PLUGIN_ROOT"): + output["additionalContext"] = context + print(json.dumps(output)) if __name__ == "__main__": diff --git a/core/bin/dev-brain-guard b/core/bin/dev-brain-guard index e94d7df..7281e03 100755 --- a/core/bin/dev-brain-guard +++ b/core/bin/dev-brain-guard @@ -4,13 +4,20 @@ The global rules say no commit, push, branch change or destructive git command without the user's explicit decision. This hook enforces it: for such a command it answers "ask", so Claude Code requests confirmation whatever the model decided or -the permission settings allow. Everything else passes untouched (no output). +the permission settings allow (Copilot CLI asks too). Codex cannot ask: an "ask" fails +the hook and the command still runs, so there the answer is "deny" and the user runs +the command. Everything else passes untouched (no output). """ import json +import os import re import shlex import sys +# Codex sets PLUGIN_ROOT for plugin hooks; Copilot CLI sets it too, plus COPILOT_PLUGIN_ROOT; +# Claude Code sets only CLAUDE_PLUGIN_ROOT. +CANNOT_ASK = bool(os.environ.get("PLUGIN_ROOT")) and not os.environ.get("COPILOT_PLUGIN_ROOT") + # git global options that take a separate value: `git -C dir commit` is still a commit. OPTIONS_WITH_VALUE = {"-c", "-C", "--git-dir", "--work-tree", "--namespace", "--exec-path"} @@ -62,10 +69,11 @@ def main(): for segment in re.split(r"&&|\|\||[;|\n]|\$\(|`", command): reason = git_reason(segment.strip().lstrip("(")) if reason: + suffix = "; this host cannot ask, so the user must run it" if CANNOT_ASK else "" print(json.dumps({"hookSpecificOutput": { "hookEventName": "PreToolUse", - "permissionDecision": "ask", - "permissionDecisionReason": f"dev-brain: {reason}; it needs your explicit decision.", + "permissionDecision": "deny" if CANNOT_ASK else "ask", + "permissionDecisionReason": f"dev-brain: {reason}; it needs your explicit decision{suffix}.", }})) return diff --git a/core/skills/handoff/agents/openai.yaml b/core/skills/handoff/agents/openai.yaml new file mode 100644 index 0000000..5b1f887 --- /dev/null +++ b/core/skills/handoff/agents/openai.yaml @@ -0,0 +1,2 @@ +policy: + allow_implicit_invocation: false diff --git a/core/skills/impact/agents/openai.yaml b/core/skills/impact/agents/openai.yaml new file mode 100644 index 0000000..5b1f887 --- /dev/null +++ b/core/skills/impact/agents/openai.yaml @@ -0,0 +1,2 @@ +policy: + allow_implicit_invocation: false diff --git a/core/skills/learn/agents/openai.yaml b/core/skills/learn/agents/openai.yaml new file mode 100644 index 0000000..5b1f887 --- /dev/null +++ b/core/skills/learn/agents/openai.yaml @@ -0,0 +1,2 @@ +policy: + allow_implicit_invocation: false diff --git a/core/skills/resume/agents/openai.yaml b/core/skills/resume/agents/openai.yaml new file mode 100644 index 0000000..5b1f887 --- /dev/null +++ b/core/skills/resume/agents/openai.yaml @@ -0,0 +1,2 @@ +policy: + allow_implicit_invocation: false diff --git a/core/skills/review/agents/openai.yaml b/core/skills/review/agents/openai.yaml new file mode 100644 index 0000000..5b1f887 --- /dev/null +++ b/core/skills/review/agents/openai.yaml @@ -0,0 +1,2 @@ +policy: + allow_implicit_invocation: false diff --git a/core/skills/start/agents/openai.yaml b/core/skills/start/agents/openai.yaml new file mode 100644 index 0000000..5b1f887 --- /dev/null +++ b/core/skills/start/agents/openai.yaml @@ -0,0 +1,2 @@ +policy: + allow_implicit_invocation: false diff --git a/evals/offline/check.py b/evals/offline/check.py index a5ac00b..d11ac98 100644 --- a/evals/offline/check.py +++ b/evals/offline/check.py @@ -1,17 +1,23 @@ #!/usr/bin/env python3 -"""Zero-token check of the dev-brain plugin against the real Claude Code binary. +"""Zero-token check of the dev-brain plugin against the real agent binaries. The plugin is installed from this repository's marketplace into a throwaway home, and the model is replaced by evals/offline/mock_model.py, which replays scripted tool calls and records every request. Nothing reaches a real provider. -It verifies what the kit controls: global rules and saved state reach the session, -an oversized state becomes a notice, workflows expand and stay out of the skill -listing, and the reviewer reads the diff with git but cannot write. It does not -judge model behavior; use evals/scenarios/ for that. It also checks that commit and push -need the user even when the user's settings allow git. +Claude Code (required): global rules and saved state reach the session, an oversized +state becomes a notice, workflows expand and stay out of the skill listing, the +reviewer reads the diff with git but cannot write, and commit and push need the user +even when the user's settings allow git. +Codex CLI and Copilot CLI (when found on PATH; an explicit CODEX / COPILOT variable +makes them required): the same plugin installs unchanged; rules and state arrive, +workflows stay out of the skill listing, and git commit is stopped. Copilot's reviewer +must also have no shell. VS Code is not covered: it cannot run here. -usage: python3 evals/offline/check.py (CLAUDE= if claude is not on PATH) +It does not judge model behavior; use evals/scenarios/ for that. + +usage: python3 evals/offline/check.py + (CLAUDE / CODEX / COPILOT= if not on PATH) """ import json import os @@ -72,6 +78,24 @@ def tool_results(bodies): return list(results.values()) +def make_repo(root): + """Fixture repository with one commit, a pending change and a small saved state.""" + repo = root / "repo" + (repo / ".dev-brain").mkdir(parents=True) + git = ["git", "-c", "user.name=check", "-c", "user.email=check@example.invalid"] + subprocess.run(["git", "init", "-q", "-b", "main"], cwd=repo, check=True) + (repo / "app.txt").write_text("hello\n") + subprocess.run(git + ["add", "app.txt"], cwd=repo, check=True) + subprocess.run(git + ["commit", "-qm", "fixture"], cwd=repo, check=True) + (repo / "app.txt").write_text("hello, world\n") + (repo / ".dev-brain" / "STATE.md").write_text(STATE) + return repo + + +def commit_count(repo): + return subprocess.run(["git", "rev-list", "--count", "HEAD"], cwd=repo, capture_output=True, text=True).stdout.strip() + + class Sandbox: """Throwaway home with the plugin installed, and a fixture repository with a pending change.""" @@ -89,15 +113,7 @@ def __init__(self, claude, mock): result = subprocess.run([claude, "plugin", *args], env=self.env, capture_output=True, text=True) if result.returncode: raise SystemExit(f"FAIL claude plugin {' '.join(args)}: {result.stdout}{result.stderr}") - self.repo = self.root / "repo" - (self.repo / ".dev-brain").mkdir(parents=True) - git = ["git", "-c", "user.name=check", "-c", "user.email=check@example.invalid"] - subprocess.run(["git", "init", "-q", "-b", "main"], cwd=self.repo, check=True) - (self.repo / "app.txt").write_text("hello\n") - subprocess.run(git + ["add", "app.txt"], cwd=self.repo, check=True) - subprocess.run(git + ["commit", "-qm", "fixture"], cwd=self.repo, check=True) - (self.repo / "app.txt").write_text("hello, world\n") - self.write_state(STATE) + self.repo = make_repo(self.root) def write_state(self, text): (self.repo / ".dev-brain" / "STATE.md").write_text(text) @@ -113,6 +129,118 @@ def run(self, prompt, steps, *extra): return bodies +def function_outputs(bodies): + """Tool outputs fed back to a Responses-API agent (Codex), once per call id.""" + results = {} + for body in bodies: + for item in body.get("input", []): + if isinstance(item, dict) and item.get("type") == "function_call_output": + results.setdefault(item.get("call_id"), json.dumps(item.get("output"))) + return list(results.values()) + + +def host_setup(prefix, **extra): + """A clean environment in a throwaway home, for an agent CLI other than Claude Code.""" + root = Path(tempfile.mkdtemp(prefix=prefix)) + home = root / "home" + home.mkdir() + identity = {"GIT_AUTHOR_NAME": "check", "GIT_COMMITTER_NAME": "check", + "GIT_AUTHOR_EMAIL": "check@example.invalid", "GIT_COMMITTER_EMAIL": "check@example.invalid"} + env = {"PATH": os.environ.get("PATH", "/usr/bin:/bin"), "HOME": str(home), "LANG": "C.UTF-8", "TERM": "dumb", + "NO_PROXY": "127.0.0.1,localhost", **identity, **extra} + return root, env + + +def host_install(binary, env, *commands): + for args in commands: + result = subprocess.run([binary, *args], env=env, capture_output=True, text=True) + if result.returncode: + raise SystemExit(f"FAIL {Path(binary).name} {' '.join(args)}: {result.stdout}{result.stderr}") + + +def host_run(cmd, env, repo, mock, steps): + mock.script(steps) + subprocess.run(cmd, cwd=repo, env={**env, "PWD": str(repo)}, stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=240) + bodies = mock.agent_calls() + if not bodies: + check(f"{Path(cmd[0]).name} sent a request to the mock model", False) + return bodies + + +GIT_COMMANDS = ["git status --short", "git commit -am wip", "git push origin main"] + + +def check_codex(codex, mock): + root, env = host_setup("dev-brain-offline-codex-", MOCK_KEY="offline-check") + try: + host_install(codex, env, ["plugin", "marketplace", "add", str(KIT)], ["plugin", "add", "dev-brain@dev-brain"]) + repo = make_repo(root) + provider = (f'model_providers.mock={{ name = "mock", base_url = "{mock.url}/v1", ' + 'wire_api = "responses", env_key = "MOCK_KEY" }') + + def run(prompt, steps, *extra): + cmd = [codex, "exec", "--skip-git-repo-check", "-c", 'model_provider="mock"', "-c", 'model="mock"', + "-c", provider, *extra, prompt] + return host_run(cmd, env, repo, mock, steps) + + # Plugin hooks run only after the user trusts them; the check bypasses that inside its own sandbox. + trust = "--dangerously-bypass-hook-trust" + check("codex: hooks wait for the user's trust", RULES not in json.dumps(run("hello", [{"text": "done"}]))) + text = json.dumps(run("hello", [{"text": "done"}], trust)) + check("codex: global rules and saved state arrive once trusted", RULES in text and STATE_MARK in text) + check("codex: workflows stay out of the skill listing", + "dev-brain:debugging" in text and "dev-brain:handoff" not in text) + for name, marker in WORKFLOWS.items(): + bodies = run(f"$dev-brain:{name}", [{"text": "done"}], trust) + check(f"codex: $dev-brain:{name} expands the workflow", marker in json.dumps(bodies)) + # Without the sandbox the commit would succeed, so only the guard can stop it. + steps = [{"tool": "exec_command", "args": {"cmd": cmd}} for cmd in GIT_COMMANDS] + [{"text": "done"}] + before = commit_count(repo) + results = function_outputs(run("save my work", steps, trust, "-s", "danger-full-access")) + check("codex: read-only git runs", any("app.txt" in r for r in results)) + guarded = sum("needs your explicit decision" in r for r in results) + check("codex: commit and push are refused", guarded == 2 and commit_count(repo) == before, f"{guarded}/2 refused") + finally: + shutil.rmtree(root, ignore_errors=True) + + +def check_copilot(copilot, mock): + root, env = host_setup("dev-brain-offline-copilot-", NO_COLOR="1", COPILOT_OFFLINE="true", + COPILOT_PROVIDER_BASE_URL=mock.url, COPILOT_PROVIDER_TYPE="anthropic", + COPILOT_PROVIDER_API_KEY="sk-offline-check", COPILOT_MODEL="mock-model", + COPILOT_PROVIDER_MODEL_ID="claude-sonnet-4.5", COPILOT_PROVIDER_WIRE_MODEL="mock-model") + env["COPILOT_HOME"] = str(Path(env["HOME"]) / ".copilot") + Path(env["COPILOT_HOME"]).mkdir() + try: + host_install(copilot, env, ["plugin", "marketplace", "add", str(KIT)], ["plugin", "install", "dev-brain@dev-brain"]) + repo = make_repo(root) + + def run(prompt, steps, *extra): + return host_run([copilot, "-p", prompt, *extra], env, repo, mock, steps) + + text = json.dumps(run("hello", [{"text": "done"}])) + check("copilot: global rules and saved state arrive", RULES in text and STATE_MARK in text) + check("copilot: workflows stay out of the skill listing", + "debugging" in text and "handoff" not in text) + steps = [{"tool": "bash", "args": {"command": cmd, "description": "git", "mode": "sync", "initial_wait": 30}} + for cmd in GIT_COMMANDS] + [{"text": "done"}] + before = commit_count(repo) + results = tool_results(run("save my work", steps, "--allow-all-tools")) + check("copilot: read-only git runs", any("app.txt" in r for r in results)) + guarded = sum("needs your explicit decision" in r for r in results) + check("copilot: commit and push are stopped", guarded == 2 and commit_count(repo) == before, f"{guarded}/2 stopped") + steps = [{"tool": "task", "args": {"description": "review changes", "prompt": "Review all changes.", + "agent_type": "dev-brain:reviewer", "name": "rev", "mode": "sync"}}, + {"text": "no findings"}, {"text": "done"}] + bodies = run("check the changes", steps) + tools = {tool["name"] for body in bodies if "independent reviewer" in json.dumps(body.get("system")) + for tool in body["tools"]} + check("copilot: the reviewer has read tools only", bool(tools) and tools <= {"view", "grep", "glob"}, str(sorted(tools))) + finally: + shutil.rmtree(root, ignore_errors=True) + + def main(): claude = os.environ.get("CLAUDE") or shutil.which("claude") if not claude: @@ -156,8 +284,7 @@ def main(): {"tool": "Bash", "args": {"command": "git push origin main", "description": "Push"}}, {"text": "done"}, ] - commits = lambda: subprocess.run(["git", "rev-list", "--count", "HEAD"], cwd=sandbox.repo, - capture_output=True, text=True).stdout.strip() + commits = lambda: commit_count(sandbox.repo) before = commits() results = tool_results(sandbox.run("save my work", steps, "--allowedTools", "Bash(git:*)")) check("read-only git runs", any("app.txt" in r for r in results)) @@ -169,6 +296,15 @@ def main(): bodies = sandbox.run("hello", [{"text": "done"}]) system = system_text(bodies[0]) if bodies else "" check("oversized state becomes a notice", NOTICE in system and "stale line" not in system) + + for name, variable, check_host in (("codex", "CODEX", check_codex), ("copilot", "COPILOT", check_copilot)): + binary = shutil.which(os.environ.get(variable) or name) + if binary: + check_host(binary, mock) + elif os.environ.get(variable): + check(f"{name} found", False, f"{variable}={os.environ[variable]}") + else: + print(f"SKIP {name}: not on PATH (set {variable}= to require it)") finally: mock.server.shutdown() shutil.rmtree(sandbox.root, ignore_errors=True) diff --git a/evals/offline/mock_model.py b/evals/offline/mock_model.py index 0508120..49eb546 100644 --- a/evals/offline/mock_model.py +++ b/evals/offline/mock_model.py @@ -1,4 +1,7 @@ -"""Local Anthropic Messages endpoint that records requests and replays scripted replies. +"""Local model endpoint that records requests and replays scripted replies. + +Speaks two wire formats: Anthropic Messages (Claude Code, and Copilot CLI configured +with its Anthropic provider) and OpenAI Responses (Codex CLI, `/responses`). Requests that offer tools are agent-loop calls: each one pops the first scripted step whose optional "when" / "unless" text matches the request, either @@ -26,12 +29,13 @@ def do_GET(self): def do_POST(self): body = json.loads(self.rfile.read(int(self.headers.get("content-length", 0))) or b"{}") - if self.path.split("?")[0].endswith("/count_tokens"): + path = self.path.split("?")[0] + if path.endswith("/count_tokens"): return self._json({"input_tokens": 1}) with mock.lock: mock.requests.append(body) step = mock.next_step(body) - self._reply(body, step) + (self._responses if path.endswith("/responses") else self._reply)(body, step) def _json(self, payload): data = json.dumps(payload).encode() @@ -41,6 +45,36 @@ def _json(self, payload): self.end_headers() self.wfile.write(data) + def _sse(self, events): + self.send_response(200) + self.send_header("content-type", "text/event-stream") + self.send_header("connection", "close") + self.end_headers() + for name, data in events: + self.wfile.write(f"event: {name}\ndata: {json.dumps(data)}\n\n".encode()) + self.wfile.flush() + self.close_connection = True + + def _responses(self, body, step): + n = len(mock.requests) + if "tool" in step: + item = {"type": "function_call", "id": f"fc_{n}", "call_id": f"call_{n}", "name": step["tool"], + "arguments": json.dumps(step["args"]), "status": "completed"} + else: + item = {"type": "message", "id": f"msg_{n}", "role": "assistant", "status": "completed", + "content": [{"type": "output_text", "text": step["text"], "annotations": []}]} + usage = {"input_tokens": 1, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 1, + "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 2} + response = {"id": f"resp_{n}", "object": "response", "status": "in_progress", "model": "mock", "output": []} + self._sse([ + ("response.created", {"type": "response.created", "response": response}), + ("response.output_item.added", {"type": "response.output_item.added", "output_index": 0, + "item": dict(item, status="in_progress")}), + ("response.output_item.done", {"type": "response.output_item.done", "output_index": 0, "item": item}), + ("response.completed", {"type": "response.completed", + "response": dict(response, status="completed", output=[item], usage=usage)}), + ]) + def _reply(self, body, step): if "tool" in step: block = {"type": "tool_use", "id": f"toolu_{len(mock.requests)}", "name": step["tool"], "input": {}} @@ -63,14 +97,7 @@ def _reply(self, body, step): "usage": {"output_tokens": 1}}), ("message_stop", {"type": "message_stop"}), ] - self.send_response(200) - self.send_header("content-type", "text/event-stream") - self.send_header("connection", "close") - self.end_headers() - for name, data in events: - self.wfile.write(f"event: {name}\ndata: {json.dumps(data)}\n\n".encode()) - self.wfile.flush() - self.close_connection = True + self._sse(events) self.server = ThreadingHTTPServer(("127.0.0.1", 0), Handler) threading.Thread(target=self.server.serve_forever, daemon=True).start() diff --git a/evals/results.md b/evals/results.md index eeed27d..8bf2bc4 100644 --- a/evals/results.md +++ b/evals/results.md @@ -6,6 +6,28 @@ A log of decisions and the evidence behind them, newest first. Full run details Not measured. Real-model evidence so far: one model per scenario, one run, small synthetic Python fixtures; the no-kit baseline already solved every task. The one measured gain is the review policy (below). Next: the same real tasks with and without the plugin, same model; compare tokens per task, fix iterations, review findings, time to resume after a break. Keep what moves the numbers. +## 2026-11-20 — Codex CLI and Copilot (CLI) support, plugin 2.3.0 + +The user asked to use the plugin in Codex and GitHub Copilot (VS Code). This reverses the 2026-10-25 "Claude Code only" decision; the adapters removed then are not restored. Principle: install the unchanged plugin first and change only what the real binaries show broken. + +Read: OpenAI's Codex plugin, skills and hooks pages; VS Code's agent-plugin and hooks references; GitHub's Copilot CLI hooks reference (first 100,000 of 136,092 characters). Run: Codex CLI 0.171.0 and Copilot CLI 1.0.114 (`@github/copilot`, offline with `COPILOT_OFFLINE` and an Anthropic-type provider pointed at the mock). + +Worked unchanged on both: `marketplace add` of this repository (Codex reads `.claude-plugin/marketplace.json` as a legacy format), plugin install from `core/.claude-plugin/plugin.json`, all nine skills, `tool_input.command` in the `PreToolUse` payload, and on Copilot the Claude-format `ask`/`deny` answer. + +Broken, and fixed: +1. Codex lists all nine skills, the six workflows included (about 1,090 characters each session): it ignores `disable-model-invocation`. Fix: `agents/openai.yaml` with `policy.allow_implicit_invocation: false` in the six workflows (documented key); the listing drops to the three model-loaded skills and `$dev-brain:` still expands. +2. Codex cannot ask: the guard's "ask" marks the hook failed and the command runs (observed, as documented). Fix: the guard answers "deny" when `PLUGIN_ROOT` is set without `COPILOT_PLUGIN_ROOT` (Codex sets the first only; Claude Code sets neither). The user then runs the command: stricter than "ask", with no approval path in the chat. +3. Copilot CLI ignores `hookSpecificOutput.additionalContext` of `SessionStart` and reads a top-level `additionalContext`; rules and state were missing. Fix: the context hook adds that key when `COPILOT_PLUGIN_ROOT` is set. Measured: both keys give one injection on Copilot, Claude Code ignores the extra key, Codex fails the hook on it, hence the condition. + +Observed, not changed (documented as limits): +- Codex runs plugin hooks only after the user trusts them (`/hooks`); `codex exec` prints nothing when they are not, and with them untrusted a `git commit` went through (commits 1 -> 2). Codex does not load the plugin's `agents/reviewer.md`, so `review` stops at its "no reviewer" step by design. +- Copilot CLI loads the reviewer but its `Bash(git diff:*)` entries map to nothing: the sub-agent gets `view`, `grep` and `glob` only. Read-only holds; it cannot run git and reads the listed files. Giving it a shell would break read-only, so no change. +- Copilot ignores hook matchers, and its `source` is `new`; the Claude-format hook file still ran. + +Evidence: `python3 evals/offline/check.py` ALL PASS, 24 checks (11 Claude Code 2.1.325, 8 Codex 0.171.0, 5 Copilot CLI 1.0.114), about 13 s. Six mutations each failed the intended check: no `openai.yaml` for one workflow, guard always "ask" (Codex: 0/2 refused), no top-level key (Copilot rules missing), top-level key for everyone (Codex rules missing), reviewer with `Bash` (Copilot reviewer tools included `bash`), no hooks (guard and context checks on all three hosts). `claude plugin validate core`: passes with the same warnings as `main`. CI now installs the three CLIs at pinned versions on pull requests and at `@latest` on pushes to `main`, weekly and on demand; `CODEX` and `COPILOT` make their checks required there. On GitHub Actions: pull request #7, pinned job success; manual run of the branch, both jobs success, and `latest` resolved to Claude Code 2.1.329, Codex 0.171.0, Copilot CLI 1.0.114, so Claude Code 2.1.329 (newer than the 2.1.325 pin) also passes. The weekly schedule is still NOT RUN. + +Limits: VS Code is NOT RUN (cannot be executed here); the docs say its Local hook harness reads `hookSpecificOutput`, which the unchanged output satisfies, and that harness is deprecated (removal announced for February 2027), but plugin hook and agent loading in VS Code is undocumented. Calling the workflows in an interactive Copilot session, Copilot's interactive "ask" prompt, and the Codex `/hooks` trust screen are NOT RUN (the binaries were driven non-interactively). No real model was used on any host, so whether the rules improve code there is as unmeasured as on Claude Code. The host markers are env variables read from the binaries' behavior today; if a host changes them the matching check fails. + ## 2026-11-15 — New releases reviewed; state without branch or commit status; CI on the newest Claude Code (plugin 2.2.1) Read: Anthropic's Opus 5.5 announcement (22 Sep, primary); the Opus 5.5 system card only through two secondary reports (its PDF is not reachable from this environment, so card-level figures are second-hand); TechCrunch on Fable 5.2 / Mythos 5.2 (9 Nov; no system card read); Claude Code's changelog for 2.1.299–2.1.311 (2.1.312–2.1.325 not read) and the `claude plugin eval` docs. @@ -58,7 +80,7 @@ The no-commit rule was instruction only; the user asked for enforcement. `core/b ## 2026-10-25 — Claude Code only, distributed as a plugin -The user works with Claude Code only. Adapters for OpenCode, Codex CLI and Cursor were removed; `core/` keeps standard formats (`AGENTS.md`, `SKILL.md`) so another agent remains an adapter away. +The user works with Claude Code only (reversed on 2026-11-20 for Codex and Copilot, see above). Adapters for OpenCode, Codex CLI and Cursor were removed; `core/` keeps standard formats (`AGENTS.md`, `SKILL.md`) so another agent remains an adapter away. - Global rules and state come from one `SessionStart` hook (`startup|resume|clear|compact`); no edit to `CLAUDE.md` or settings. Claude Code puts the hook output in a system-role message. - Workflows are plugin skills with `disable-model-invocation: true`: not listed in the system prompt (verified), invoked as `/dev-brain:`. The bare `/review` keeps opening Claude Code's built-in review.