Skip to content

Open-source skills for designing and reviewing software with AI agents

feat(copilot): add experimental CLI support (#163)

n3wth86125d186db1
diff --git a/.github/workflows/copilot-native.yml b/.github/workflows/copilot-native.yml
new file mode 100644
index 0000000..a4b65ea
--- /dev/null
+++ b/.github/workflows/copilot-native.yml
@@ -0,0 +1,58 @@
+# Copyright 2026 Google LLC
+# SPDX-License-Identifier: Apache-2.0
+
+name: Copilot native offline probe
+
+on:
+ pull_request:
+ paths:
+ - '.github/workflows/copilot-native.yml'
+ - '.plugin/**'
+ - 'com.github.copilot/**'
+ - 'skills/**'
+ - 'agents/**'
+ - 'resources/**'
+ - 'docs/**'
+ - 'assets/**'
+ - 'plugin.json'
+ - 'tests/integration/copilot_controlled_probe.py'
+ push:
+ branches: [main]
+ paths:
+ - '.github/workflows/copilot-native.yml'
+ - '.plugin/**'
+ - 'com.github.copilot/**'
+ - 'skills/**'
+ - 'agents/**'
+ - 'resources/**'
+ - 'docs/**'
+ - 'assets/**'
+ - 'plugin.json'
+ - 'tests/integration/copilot_controlled_probe.py'
+
+permissions:
+ contents: read
+
+jobs:
+ controlled-probe:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: '3.12'
+ - name: Install the pinned native CLI
+ shell: bash
+ run: |
+ set -euo pipefail
+ curl -fsSL --retry 3 -o "$RUNNER_TEMP/copilot.tgz" \
+ https://registry.npmjs.org/@github/copilot-linux-x64/-/copilot-linux-x64-1.0.82.tgz
+ echo 'bea986f7aeb992d80b1c090628c8e9e2e54c747a8bc62f2e4bdccbfa0da93306543e833b27191a49f3a87b262bf7d71a17b27a5482535afe0b751350c86e63ad '"$RUNNER_TEMP/copilot.tgz" | sha512sum -c -
+ mkdir "$RUNNER_TEMP/copilot"
+ tar -xzf "$RUNNER_TEMP/copilot.tgz" -C "$RUNNER_TEMP/copilot" --strip-components=1
+ echo "$RUNNER_TEMP/copilot" >> "$GITHUB_PATH"
+ - name: Check native child isolation and tool restrictions
+ run: python tests/integration/copilot_controlled_probe.py
diff --git a/.plugin/plugin.json b/.plugin/plugin.json
new file mode 100644
index 0000000..61a07d9
--- /dev/null
+++ b/.plugin/plugin.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
+ "name": "egm",
+ "version": "0.1.0",
+ "description": "Draft specs, review designs, and check implementation drift.",
+ "author": {
+ "name": "Google"
+ },
+ "homepage": "https://egm.dev",
+ "repository": "https://github.com/google/elephant-goldfish-model",
+ "license": "Apache-2.0"
+}
diff --git a/com.github.copilot/agents/egm-codebase-details.agent.md b/com.github.copilot/agents/egm-codebase-details.agent.md
new file mode 100644
index 0000000..384ea0c
--- /dev/null
+++ b/com.github.copilot/agents/egm-codebase-details.agent.md
@@ -0,0 +1,25 @@
+---
+name: egm-codebase-details
+description: Code and documentation accuracy review using the canonical EGM persona. Experimental Copilot CLI adapter.
+tools: [read, search]
+include-custom-instructions: false
+user-invocable: false
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Use only the assigned task and its explicit reading list.
+Require an absolute EGM package root from the caller. Read
+`<EGM_ROOT>/agents/codebase_details.md` before work. Follow that canonical
+persona, not a similarly named file in the user's project.
+Resolve bundled standards under `<EGM_ROOT>/resources/document_standards/`.
+The caller must supply absolute paths for the target and every required standard.
+
+Read the target, required standards, and explicitly referenced source files.
+If a required path is absent or unreadable, return an incomplete review.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+Do not edit files, run commands, delegate, or use MCP tools.
+Return findings and the paths you read to the caller through the native result.
+The caller writes reports. Do not claim independent verification from self-report.
diff --git a/com.github.copilot/agents/egm-comprehension.agent.md b/com.github.copilot/agents/egm-comprehension.agent.md
new file mode 100644
index 0000000..97092a3
--- /dev/null
+++ b/com.github.copilot/agents/egm-comprehension.agent.md
@@ -0,0 +1,25 @@
+---
+name: egm-comprehension
+description: Document comprehension review using the canonical EGM persona. Experimental Copilot CLI adapter.
+tools: [read, search]
+include-custom-instructions: false
+user-invocable: false
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Use only the assigned task and its explicit reading list.
+Require an absolute EGM package root from the caller. Read
+`<EGM_ROOT>/agents/comprehension.md` before work. Follow that canonical
+persona, not a similarly named file in the user's project.
+Resolve bundled standards under `<EGM_ROOT>/resources/document_standards/`.
+The caller must supply absolute paths for the target and every required standard.
+
+Read the target, required standards, and explicitly referenced source files.
+If a required path is absent or unreadable, return an incomplete review.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+Do not edit files, run commands, delegate, or use MCP tools.
+Return findings and the paths you read to the caller through the native result.
+The caller writes reports. Do not claim independent verification from self-report.
diff --git a/com.github.copilot/agents/egm-design.agent.md b/com.github.copilot/agents/egm-design.agent.md
new file mode 100644
index 0000000..c5dcd8a
--- /dev/null
+++ b/com.github.copilot/agents/egm-design.agent.md
@@ -0,0 +1,25 @@
+---
+name: egm-design
+description: Architecture and design review using the canonical EGM persona. Experimental Copilot CLI adapter.
+tools: [read, search]
+include-custom-instructions: false
+user-invocable: false
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Use only the assigned task and its explicit reading list.
+Require an absolute EGM package root from the caller. Read
+`<EGM_ROOT>/agents/design_critic.md` before work. Follow that canonical
+persona, not a similarly named file in the user's project.
+Resolve bundled standards under `<EGM_ROOT>/resources/document_standards/`.
+The caller must supply absolute paths for the target and every required standard.
+
+Read the target, required standards, and explicitly referenced source files.
+If a required path is absent or unreadable, return an incomplete review.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+Do not edit files, run commands, delegate, or use MCP tools.
+Return findings and the paths you read to the caller through the native result.
+The caller writes reports. Do not claim independent verification from self-report.
diff --git a/com.github.copilot/agents/egm-implementation-readiness.agent.md b/com.github.copilot/agents/egm-implementation-readiness.agent.md
new file mode 100644
index 0000000..e27662a
--- /dev/null
+++ b/com.github.copilot/agents/egm-implementation-readiness.agent.md
@@ -0,0 +1,25 @@
+---
+name: egm-implementation-readiness
+description: Implementation readiness review using the canonical EGM persona. Experimental Copilot CLI adapter.
+tools: [read, search]
+include-custom-instructions: false
+user-invocable: false
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Use only the assigned task and its explicit reading list.
+Require an absolute EGM package root from the caller. Read
+`<EGM_ROOT>/agents/implementation_readiness.md` before work. Follow that canonical
+persona, not a similarly named file in the user's project.
+Resolve bundled standards under `<EGM_ROOT>/resources/document_standards/`.
+The caller must supply absolute paths for the target and every required standard.
+
+Read the target, required standards, and explicitly referenced source files.
+If a required path is absent or unreadable, return an incomplete review.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+Do not edit files, run commands, delegate, or use MCP tools.
+Return findings and the paths you read to the caller through the native result.
+The caller writes reports. Do not claim independent verification from self-report.
diff --git a/com.github.copilot/agents/egm-structural.agent.md b/com.github.copilot/agents/egm-structural.agent.md
new file mode 100644
index 0000000..58e2c4c
--- /dev/null
+++ b/com.github.copilot/agents/egm-structural.agent.md
@@ -0,0 +1,25 @@
+---
+name: egm-structural
+description: Document structure review using the canonical EGM persona. Experimental Copilot CLI adapter.
+tools: [read, search]
+include-custom-instructions: false
+user-invocable: false
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Use only the assigned task and its explicit reading list.
+Require an absolute EGM package root from the caller. Read
+`<EGM_ROOT>/agents/structural.md` before work. Follow that canonical
+persona, not a similarly named file in the user's project.
+Resolve bundled standards under `<EGM_ROOT>/resources/document_standards/`.
+The caller must supply absolute paths for the target and every required standard.
+
+Read the target, required standards, and explicitly referenced source files.
+If a required path is absent or unreadable, return an incomplete review.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+Do not edit files, run commands, delegate, or use MCP tools.
+Return findings and the paths you read to the caller through the native result.
+The caller writes reports. Do not claim independent verification from self-report.
diff --git a/com.github.copilot/agents/egm-style.agent.md b/com.github.copilot/agents/egm-style.agent.md
new file mode 100644
index 0000000..6d446ed
--- /dev/null
+++ b/com.github.copilot/agents/egm-style.agent.md
@@ -0,0 +1,25 @@
+---
+name: egm-style
+description: Technical writing review using the canonical EGM persona. Experimental Copilot CLI adapter.
+tools: [read, search]
+include-custom-instructions: false
+user-invocable: false
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Use only the assigned task and its explicit reading list.
+Require an absolute EGM package root from the caller. Read
+`<EGM_ROOT>/agents/style.md` before work. Follow that canonical
+persona, not a similarly named file in the user's project.
+Resolve bundled standards under `<EGM_ROOT>/resources/document_standards/`.
+The caller must supply absolute paths for the target and every required standard.
+
+Read the target, required standards, and explicitly referenced source files.
+If a required path is absent or unreadable, return an incomplete review.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+Do not edit files, run commands, delegate, or use MCP tools.
+Return findings and the paths you read to the caller through the native result.
+The caller writes reports. Do not claim independent verification from self-report.
diff --git a/com.github.copilot/agents/egm-zoom-out.agent.md b/com.github.copilot/agents/egm-zoom-out.agent.md
new file mode 100644
index 0000000..df7bd15
--- /dev/null
+++ b/com.github.copilot/agents/egm-zoom-out.agent.md
@@ -0,0 +1,25 @@
+---
+name: egm-zoom-out
+description: High-level simplicity review using the canonical EGM persona. Experimental Copilot CLI adapter.
+tools: [read, search]
+include-custom-instructions: false
+user-invocable: false
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Use only the assigned task and its explicit reading list.
+Require an absolute EGM package root from the caller. Read
+`<EGM_ROOT>/agents/zoom_out.md` before work. Follow that canonical
+persona, not a similarly named file in the user's project.
+Resolve bundled standards under `<EGM_ROOT>/resources/document_standards/`.
+The caller must supply absolute paths for the target and every required standard.
+
+Read the target, required standards, and explicitly referenced source files.
+If a required path is absent or unreadable, return an incomplete review.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+Do not edit files, run commands, delegate, or use MCP tools.
+Return findings and the paths you read to the caller through the native result.
+The caller writes reports. Do not claim independent verification from self-report.
diff --git a/com.github.copilot/agents/egm.agent.md b/com.github.copilot/agents/egm.agent.md
new file mode 100644
index 0000000..5b6dd4b
--- /dev/null
+++ b/com.github.copilot/agents/egm.agent.md
@@ -0,0 +1,21 @@
+---
+name: egm
+description: Run the shared EGM skills with native Copilot CLI reviewers. Experimental.
+tools: [read, search, edit, agent]
+---
+
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+Require the absolute installed EGM package root from the user or the native
+plugin inventory. Do not guess a cache path. Read `<EGM_ROOT>/docs/copilot.md`
+before work. Read the requested canonical `skills/<skill>/SKILL.md` from that
+same root. Keep hyphens in skill directory names; for example, read
+`<EGM_ROOT>/skills/egm-brainstorm/SKILL.md` for `egm-brainstorm`.
+
+Follow the shared skill's workflow and human approval gates. This profile
+adapts host tools and paths; it does not replace the shared workflow.
+Use the seven registered EGM reviewer profiles for direct native delegation.
+Prefix canonical persona names with `egm:` when selecting native profiles.
+For example, `egm-design` maps to `egm:egm-design`.
+Keep synthesis and artifact writes in this main session.
+Never substitute an inline review for a missing native reviewer.
diff --git a/docs/copilot.md b/docs/copilot.md
new file mode 100644
index 0000000..4fe9dcb
--- /dev/null
+++ b/docs/copilot.md
@@ -0,0 +1,200 @@
+<!-- Copyright 2026 Google LLC. SPDX-License-Identifier: Apache-2.0 -->
+
+# GitHub Copilot CLI integration
+
+Experimental adapter for [issue #147](https://github.com/google/elephant-goldfish-model/issues/147).
+Workflow execution and reviewer isolation remain unverified. This guide does
+not establish support for Copilot in VS Code or the cloud agent.
+
+## Interface and installation
+
+The offline reference version is GitHub Copilot CLI **1.0.82**.
+Use the existing Agent Plugins 1.0 root `plugin.json`. Copilot-specific profiles
+live in `com.github.copilot/agents/`. The shared skills, personas, and standards
+remain in `skills/`, `agents/`, and `resources/`.
+
+Use a complete checkout at a fixed candidate commit. Keep that checkout while
+the session runs. Do not copy only `skills/` or install the profile directory alone.
+The root manifest takes precedence over the Claude compatibility manifest.
+No Copilot hooks, MCP servers, or replacement manifest are required.
+
+Set `EGM_ROOT` to the absolute path of the candidate checkout:
+
+```sh
+EGM_ROOT=/absolute/path/to/elephant-goldfish-model
+git -C "$EGM_ROOT" rev-parse HEAD
+copilot --version
+COPILOT_OFFLINE=true copilot --plugin-dir "$EGM_ROOT" plugin list
+```
+
+The last command must list `egm` under external plugins. It checks registration,
+not reviewer execution. For a separate profile, set `COPILOT_HOME` to a new
+directory. This does not disable every user-level skill or project instruction.
+Inspect the host inventories before any live test.
+
+After explicit authorization for model usage, start Copilot from the target project:
+
+```sh
+copilot --plugin-dir "$EGM_ROOT" --add-dir "$EGM_ROOT" --agent egm:egm
+```
+
+In the first message, supply the absolute package root and requested skill:
+
+```text
+EGM package root: /absolute/path/to/elephant-goldfish-model
+Read that package's docs/copilot.md and run egm-brainstorm.
+EGM artifact directory: .dev/docs
+```
+
+Use `egm-draft` or `egm-review` in later requests. Provide the target document
+for review. Use the `egm:egm` entry agent so the host mapping loads before a skill.
+Selecting a reviewer as the main session does not establish a fresh Goldfish context.
+Check `/agent` for name conflicts before use; personal profiles can override package profiles.
+
+The verified offline path uses `--plugin-dir`. Persistent installation through
+`copilot plugin install` remains unverified. Version 1.0.82 help does not document
+local-path installation, although current GitHub documentation does. Do not infer
+that a newer command interface works on this version.
+
+## Resource paths
+
+Resolve the package root from the mounted checkout or the native plugin inventory.
+For a discovered `skills/<skill>/SKILL.md`, move three parent directories upward.
+Read the guide and canonical skill from that root before delegation.
+
+- Resolve `agents/`, `resources/`, and `docs/` against the package root.
+- Resolve a skill's `references/` against that skill's directory.
+- Resolve user documents against the project working directory.
+- Pass absolute paths to reviewers, including the package root, target, and standards.
+- Preserve spaces and Unicode characters in paths. Do not split paths on whitespace.
+- Stop if any required resource is unavailable. Never substitute a project file.
+
+`<EGM_ROOT>` in a profile is a task-supplied path, not an environment expansion.
+This adapter does not assume that Copilot expands variables inside Markdown bodies.
+
+## Native delegation
+
+Use Copilot's native custom-agent delegation tool. Inspect its exposed schema.
+Select the registered profile by its namespaced ID; do not invent tool arguments.
+Map each canonical persona name to `egm:<name>` for native delegation.
+The entry profile permits `agent` for delegation and `edit` for artifacts.
+Each reviewer permits only `read` and `search`. Reviewers cannot delegate or write reports.
+
+| Profile | Canonical persona |
+| --- | --- |
+| `egm:egm-design` | `agents/design_critic.md` |
+| `egm:egm-codebase-details` | `agents/codebase_details.md` |
+| `egm:egm-comprehension` | `agents/comprehension.md` |
+| `egm:egm-implementation-readiness` | `agents/implementation_readiness.md` |
+| `egm:egm-structural` | `agents/structural.md` |
+| `egm:egm-style` | `agents/style.md` |
+| `egm:egm-zoom-out` | `agents/zoom_out.md` |
+
+Start a new native child for every reviewer invocation, including repeat reviews.
+Use a task that contains only the requested mode, target, line ranges, persona,
+standards, and explicit reading list. Do not forward the conversation, private
+rationale, memory, or answers the target should explain.
+Do not retrieve parent history or memory.
+Read prior reviewer reports only when explicitly supplied in the reading list
+and required by the canonical workflow stage. Do not retrieve other prior findings.
+For example, Step 8 (Intermediate Zoom Out) requires the caller to include the
+absolute path to `zoom_out_report.md` in the reading list. Do not forward other
+previous findings.
+
+Use direct dispatch for the shared skills' synthesizer steps. Read the canonical
+`agents/synthesizer.md` for reviewer selection and report format. The main session
+collects results and writes artifacts. Do not attempt nested delegation or register
+an unrestricted synthesizer. Bootstrap workers are outside this adapter's verified scope.
+
+Keep `include-custom-instructions: false` for reviewers. Current GitHub documentation
+describes this setting for delegated children, not agents selected as the main session.
+The local version's enforcement is unverified. A separate context window alone
+does not prove that instructions, memory, or shared files are isolated.
+
+Wait for each native completion before synthesis. Check required resource reads
+in host records where available. A missing child, read failure, timeout, or denied
+tool makes that stage incomplete. Stop and report the limitation. Never simulate
+a child or treat missing findings as a passing result.
+
+## Human gates and artifacts
+
+Follow the canonical skill's approval steps and stage order. Use one plain-text
+question and wait when a structured question tool is unavailable. A missing tool
+does not grant approval. Do not enable autopilot to bypass these gates.
+
+Write artifacts to the working directory unless the user supplies
+`EGM artifact directory: <path>`. Resolve relative artifact paths against that
+working directory. Preserve the skill's filenames and report their final paths.
+Keep artifact writes in the main session; reviewers return findings only.
+
+## Validation and remaining limits
+
+Run `pytest tests/unit/test_copilot_adapter.py` and `pytest tests/unit` offline.
+The host-specific tests check profiles, path resolution, and canonical resource
+preservation in a relocated package. They do not call a model.
+
+With CLI 1.0.82 installed, include its offline native discovery check:
+
+```sh
+EGM_COPILOT_OFFLINE=1 pytest tests/unit
+```
+
+On 2026-10-24, CLI 1.0.82 loaded all eight profiles and seven skills from the
+mounted package. The test uses a disposable `COPILOT_HOME` and `COPILOT_OFFLINE=true`.
+It starts the installed CLI with `--headless --stdio`, then calls these native
+SDK protocol operations without sending a prompt:
+
+1. `session.create` creates a session with a local rejecting provider.
+2. `session.agent.list` returns eight `source: plugin` records with absolute profile paths.
+3. `session.skills.list` returns seven enabled skills with absolute canonical paths.
+4. `session.destroy` removes the session.
+
+The test checks exact IDs, paths, tool lists, reviewer `userInvocable: false`,
+and empty agent MCP definitions. The local provider receives **zero requests**.
+The model name `gpt-4.1` is session metadata only; no model executes.
+No additional manifest mapping is necessary.
+
+The inspected macOS arm64 CLI binary has SHA-256
+`948a5e69d924559fdfb2292d9cd8584b8fba28f8fd0349eeefc18711225e340f`.
+
+Representative native records, with the local root abbreviated as `<package>`:
+
+```json
+{"id":"egm:egm-design","source":"plugin","path":"<package>/com.github.copilot/agents/egm-design.agent.md","tools":["read","search"],"userInvocable":false,"mcpServers":{}}
+{"name":"egm-review","commandName":"egm:egm-review","source":"plugin","path":"<package>/skills/egm-review/SKILL.md","enabled":true}
+```
+
+The standalone `skill list` command omitted mounted skills on this version.
+Its output is not a session loader inventory. Local `plugins list --help` also
+states that custom-agent inspection requires a session. The native SDK inventory
+resolves this discovery gap without a model run.
+
+Discovery does not prove skill execution, write denial, or context isolation.
+The RPC inventory does not expose `include-custom-instructions` enforcement.
+This historical note does not identify the tested EGM commit or installed package
+checksum. Repeat discovery against the pinned candidate before relying on it for
+that candidate.
+
+Before a support claim, run the existing brainstorm, draft, and review scenarios
+from each skill's `test_scenarios.yaml` with explicit model-use authorization.
+Record these outcomes separately:
+
+1. Installation: candidate SHA, package identity, complete resources, and loaded profiles.
+2. Workflow: host version, model identifier, date, native child starts and completions,
+ required reads, artifact paths, and a real human approval pause.
+3. Isolation: a random parent-only marker, actual child context, injected instructions,
+ memory and MCP exposure, and attempted writes to a disposable fixture.
+
+Inspect tool records to verify write denial. A reviewer promise is not enforcement.
+If records are unavailable, retain an unverified result. Read access to shared files
+can expose prior findings; fresh context is not a filesystem sandbox.
+
+## Official references
+
+- [Plugin format and precedence](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference)
+- [Custom agents and instruction inheritance](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/create-custom-agents-for-cli)
+- [Agent tools and aliases](https://docs.github.com/en/copilot/reference/custom-agents-configuration)
+- [CLI command reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference)
+- [Official SDK protocol operations](https://github.com/github/copilot-sdk/blob/main/python/copilot/generated/rpc.py)
+
+These references describe capabilities. They are not EGM runtime test evidence.
diff --git a/tests/integration/copilot_controlled_probe.py b/tests/integration/copilot_controlled_probe.py
new file mode 100644
index 0000000..f65fad0
--- /dev/null
+++ b/tests/integration/copilot_controlled_probe.py
@@ -0,0 +1,174 @@
+# Copyright 2026 Google LLC.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Exercise native reviewer isolation using a scripted, local provider.
+
+This probe uses no model. It does not verify workflow or approval behavior.
+"""
+
+import http.server
+import json
+from pathlib import Path
+import shutil
+import subprocess
+import tempfile
+import threading
+from typing import Any
+import uuid
+
+
+PACKAGE = Path(__file__).resolve().parents[2]
+CHILD_TAG = 'EGM_CHILD_CONTROLLED'
+
+
+def tool_call(call_id: str, name: str, arguments: dict[str, str]) -> dict[str, Any]:
+ return {
+ 'id': call_id,
+ 'type': 'function',
+ 'function': {'name': name, 'arguments': json.dumps(arguments)},
+ }
+
+
+def main() -> None:
+ cli = shutil.which('copilot')
+ assert cli, 'Copilot CLI is required; the controlled probe must not skip'
+ version = subprocess.check_output([cli, '--version'], text=True)
+ assert 'GitHub Copilot CLI 1.0.82.' in version, version
+
+ marker = 'PRIVATE-' + uuid.uuid4().hex
+ observations: list[dict[str, Any]] = []
+
+ with tempfile.TemporaryDirectory(prefix='egm-copilot-controlled-') as directory:
+ root = Path(directory)
+
+ class Provider(http.server.BaseHTTPRequestHandler):
+ def log_message(self, format: str, *args: object) -> None:
+ pass
+
+ def do_POST(self) -> None:
+ payload = json.loads(self.rfile.read(int(self.headers['Content-Length'])))
+ messages = payload['messages']
+ names = [tool['function']['name'] for tool in payload.get('tools', [])]
+ child = any(CHILD_TAG in str(msg.get('content', '')) for msg in messages)
+ tool_results = sum(msg.get('role') == 'tool' for msg in messages)
+ last = messages[-1]
+ observations.append({
+ 'child': child,
+ 'marker': marker in json.dumps(messages),
+ 'tools': names,
+ 'last_tool_id': last.get('tool_call_id'),
+ 'last_tool_content': last.get('content', ''),
+ })
+
+ if child and tool_results == 0:
+ call = tool_call('call_read', 'view', {
+ 'path': str(PACKAGE / 'agents/zoom_out.md'),
+ })
+ elif child and tool_results == 1:
+ call = tool_call('call_forbidden', 'create', {
+ 'path': str(root / 'copilot-forbidden-write'),
+ 'file_text': 'unexpected',
+ })
+ elif not child and tool_results == 0:
+ call = tool_call('call_child', 'task', {
+ 'description': 'Controlled child probe',
+ 'agent_type': 'egm:egm-zoom-out',
+ 'mode': 'sync',
+ 'name': 'controlled-probe',
+ 'prompt': CHILD_TAG + ': read the canonical persona and reply UNKNOWN.',
+ })
+ else:
+ call = None
+
+ content = 'UNKNOWN' if child else 'DONE'
+ message: dict[str, Any] = {'role': 'assistant', 'content': content}
+ if call:
+ message = {'role': 'assistant', 'content': None, 'tool_calls': [call]}
+ finish = 'tool_calls' if call else 'stop'
+ response = {
+ 'id': 'chatcmpl-test', 'object': 'chat.completion', 'created': 1,
+ 'model': 'gpt-4.1',
+ 'choices': [{'index': 0, 'message': message, 'finish_reason': finish}],
+ 'usage': {'prompt_tokens': 10, 'completion_tokens': 10, 'total_tokens': 20},
+ }
+ self.send_response(200)
+ if payload.get('stream'):
+ self.send_header('Content-Type', 'text/event-stream')
+ self.end_headers()
+ delta: dict[str, Any] = {'role': 'assistant', 'content': content}
+ if call:
+ delta = {'role': 'assistant', 'content': None,
+ 'tool_calls': [{'index': 0, **call}]}
+ chunk = {
+ 'id': 'chatcmpl-test', 'object': 'chat.completion.chunk',
+ 'created': 1, 'model': 'gpt-4.1',
+ 'choices': [{'index': 0, 'delta': delta, 'finish_reason': None}],
+ }
+ self.wfile.write(('data: ' + json.dumps(chunk) + '\n\n').encode())
+ chunk['choices'][0]['delta'] = {}
+ chunk['choices'][0]['finish_reason'] = finish
+ final = 'data: ' + json.dumps(chunk) + '\n\ndata: [DONE]\n\n'
+ self.wfile.write(final.encode())
+ else:
+ body = json.dumps(response).encode()
+ self.send_header('Content-Type', 'application/json')
+ self.send_header('Content-Length', str(len(body)))
+ self.end_headers()
+ self.wfile.write(body)
+
+ with http.server.ThreadingHTTPServer(('127.0.0.1', 0), Provider) as server:
+ threading.Thread(target=server.serve_forever, daemon=True).start()
+ env = {
+ 'HOME': directory,
+ 'PATH': '/usr/local/bin:/usr/bin:/bin',
+ 'COPILOT_HOME': str(root / 'profile'),
+ 'COPILOT_OFFLINE': 'true',
+ 'COPILOT_PROVIDER_BASE_URL': f'http://127.0.0.1:{server.server_port}/v1',
+ 'COPILOT_MODEL': 'gpt-4.1',
+ }
+ args = [
+ cli, '--no-auto-update', '--no-custom-instructions',
+ '--disable-builtin-mcps', '--plugin-dir', str(PACKAGE),
+ '--add-dir', str(PACKAGE), '--agent', 'egm:egm',
+ '--allow-all-tools', '--output-format', 'json',
+ '-p', f'Parent-only marker: {marker}. Invoke the controlled reviewer.',
+ ]
+ result = subprocess.run(
+ args, cwd=root, env=env, text=True, capture_output=True, timeout=90,
+ )
+ server.shutdown()
+
+ events = [json.loads(line) for line in result.stdout.splitlines() if line.startswith('{')]
+ children = [item for item in observations if item['child']]
+ assert result.returncode == 0, result.stderr[-500:]
+ assert children, 'Native child did not reach provider'
+ assert any(item['marker'] and 'create' in item['tools']
+ for item in observations if not item['child']), 'Parent control missing'
+ assert not any(item['marker'] for item in children), 'Marker appeared in child request'
+ assert all(item['tools'] == ['view'] for item in children), 'Unexpected child tools'
+ assert any(
+ event['type'] == 'tool.execution_complete'
+ and event['data'].get('toolCallId') == 'call_child'
+ and event['data'].get('success')
+ and event['data'].get('result', {}).get('content') == 'UNKNOWN'
+ for event in events
+ ), 'Native foreground child did not return'
+ assert any(
+ event['type'] == 'tool.execution_complete'
+ and event['data'].get('success')
+ and event['data'].get('parentToolCallId') == 'call_child'
+ and event['data'].get('toolCallId') == 'call_read'
+ and 'name: egm-zoom-out' in event['data'].get('result', {}).get('content', '')
+ for event in events
+ ), 'No successful child persona read'
+ assert not (root / 'copilot-forbidden-write').exists(), 'Reviewer created a file'
+ assert any(
+ item['last_tool_id'] == 'call_forbidden'
+ and 'does not exist' in str(item['last_tool_content']).lower()
+ for item in children
+ ), 'No forbidden-tool failure'
+ print('PASS: child context, persona read, and forced write denial')
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/unit/test_copilot_adapter.py b/tests/unit/test_copilot_adapter.py
new file mode 100644
index 0000000..2f94b55
--- /dev/null
+++ b/tests/unit/test_copilot_adapter.py
@@ -0,0 +1,207 @@
+# Copyright 2026 Google LLC.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Offline Copilot package contracts; no model or isolation claims."""
+
+from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
+import json
+import os
+from pathlib import Path
+import queue
+import re
+import shutil
+import subprocess
+import threading
+
+import pytest
+
+from .test_harnesses import REVIEWERS, frontmatter
+
+
+def test_copilot_profiles_use_canonical_read_only_reviewers(repo_root: Path) -> None:
+ profiles = repo_root / "com.github.copilot/agents"
+ expected_names = {
+ frontmatter(repo_root / f"agents/{p}.md")["name"] for p in REVIEWERS
+ }
+ assert {p.stem.removesuffix(".agent") for p in profiles.glob("*.agent.md")} == (
+ expected_names | {"egm"}
+ )
+ for persona in REVIEWERS:
+ canonical = repo_root / f"agents/{persona}.md"
+ name = frontmatter(canonical)["name"]
+ profile = profiles / f"{name}.agent.md"
+ config = frontmatter(profile)
+ assert config["name"] == name
+ assert config["tools"] == ["read", "search"]
+ assert config["include-custom-instructions"] is False
+ assert config["user-invocable"] is False
+ assert set(config) == {
+ "name", "description", "tools", "include-custom-instructions",
+ "user-invocable",
+ }
+ text = profile.read_text(encoding="utf-8")
+ assert f"<EGM_ROOT>/agents/{persona}.md" in text
+ assert "incomplete review" in text
+ assert "Do not retrieve parent history" in text
+ assert "${" not in text # No undocumented Markdown variable expansion.
+ entry = profiles / "egm.agent.md"
+ assert frontmatter(entry)["tools"] == ["read", "search", "edit", "agent"]
+ assert "<EGM_ROOT>/docs/copilot.md" in entry.read_text(encoding="utf-8")
+ assert "<EGM_ROOT>/skills/egm-brainstorm/SKILL.md" in entry.read_text(encoding="utf-8")
+
+
[email protected]("persona", [*REVIEWERS, None])
+def test_copilot_prior_reports_require_explicit_stage_input(
+ repo_root: Path, persona: str | None,
+) -> None:
+ """Stage 8 may read its prior report without opening parent context."""
+ path = repo_root / "docs/copilot.md"
+ if persona is not None:
+ name = frontmatter(repo_root / f"agents/{persona}.md")["name"]
+ path = repo_root / f"com.github.copilot/agents/{name}.agent.md"
+ text = " ".join(path.read_text(encoding="utf-8").split())
+ assert "Do not retrieve parent history or memory." in text
+ assert (
+ "Read prior reviewer reports only when explicitly supplied in the reading "
+ "list and required by the canonical workflow stage."
+ ) in text
+
+
+def copilot_package(repo_root: Path, tmp_path: Path) -> Path:
+ """Relocate the full runtime, including paths with spaces and Unicode."""
+ package = tmp_path / "relocated EGM café"
+ package.mkdir()
+ for directory in ("skills", "agents", "resources", "docs", "com.github.copilot", ".plugin"):
+ shutil.copytree(repo_root / directory, package / directory)
+ shutil.copy2(repo_root / "plugin.json", package / "plugin.json")
+ return package
+
+
+def test_copilot_relocated_resources(repo_root: Path, copilot_package: Path) -> None:
+ for directory in ("skills", "agents", "resources", "docs"):
+ for source in (repo_root / directory).rglob("*"):
+ if source.is_file():
+ installed = copilot_package / source.relative_to(repo_root)
+ assert installed.read_bytes() == source.read_bytes()
+ for skill in (copilot_package / "skills").glob("*/SKILL.md"):
+ assert skill.parents[2] == copilot_package
+ profiles = copilot_package / "com.github.copilot/agents"
+ for profile in profiles.glob("*.agent.md"):
+ text = profile.read_text(encoding="utf-8")
+ for relative in re.findall(r"<EGM_ROOT>/([\w/.-]+)", text):
+ assert (copilot_package / relative).exists(), (profile.name, relative)
+ assert not (copilot_package / "com.github.copilot/skills").exists()
+
+
+def test_copilot_native_offline_discovery(
+ copilot_package: Path, tmp_path: Path,
+) -> None:
+ """Inspect the native session loader without sending a model prompt."""
+ if os.environ.get("EGM_COPILOT_OFFLINE") != "1":
+ pytest.skip("Set EGM_COPILOT_OFFLINE=1 for native loader inspection")
+ executable = shutil.which("copilot")
+ if executable is None:
+ pytest.skip("Copilot CLI is not installed")
+ version = subprocess.check_output([executable, "--version"], text=True)
+ assert "GitHub Copilot CLI 1.0.82." in version
+ provider_requests = []
+
+ class RejectProvider(BaseHTTPRequestHandler):
+ def do_POST(self) -> None:
+ provider_requests.append(self.path)
+ self.send_error(503)
+
+ do_GET = do_POST
+
+ def log_message(self, *args: object) -> None:
+ pass
+
+ with ThreadingHTTPServer(("127.0.0.1", 0), RejectProvider) as provider:
+ threading.Thread(target=provider.serve_forever, daemon=True).start()
+ env = {k: v for k, v in os.environ.items() if not any(
+ token in k for token in ("TOKEN", "API_KEY", "BEARER", "COPILOT_")
+ )}
+ base_url = f"http://127.0.0.1:{provider.server_port}/v1"
+ env.update(COPILOT_OFFLINE="true", COPILOT_HOME=str(tmp_path / "profile"),
+ COPILOT_PROVIDER_BASE_URL=base_url, COPILOT_MODEL="gpt-4.1")
+ responses: queue.Queue = queue.Queue()
+ with (tmp_path / "loader.log").open("w") as log:
+ process = subprocess.Popen(
+ [executable, "--plugin-dir", str(copilot_package), "--headless",
+ "--stdio", "--no-auto-update", "--no-auto-login",
+ "--disable-builtin-mcps"],
+ cwd=tmp_path, env=env, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=log,
+ )
+
+ def receive() -> None:
+ try:
+ while True:
+ line = process.stdout.readline()
+ if not line:
+ raise EOFError("Copilot loader closed stdout")
+ if line.lower().startswith(b"content-length:"):
+ length = int(line.split(b":")[1])
+ while process.stdout.readline().strip():
+ pass
+ responses.put(json.loads(process.stdout.read(length)))
+ except Exception as error:
+ responses.put(error)
+
+ threading.Thread(target=receive, daemon=True).start()
+ request_id = 0
+
+ def rpc(method: str, params: dict) -> dict:
+ nonlocal request_id
+ request_id += 1
+ body = json.dumps({"jsonrpc": "2.0", "id": request_id,
+ "method": method, "params": params}).encode()
+ header = f"Content-Length: {len(body)}\r\n\r\n".encode()
+ process.stdin.write(header + body)
+ process.stdin.flush()
+ while True:
+ response = responses.get(timeout=20)
+ if isinstance(response, Exception):
+ raise response
+ if response.get("id") == request_id:
+ assert "error" not in response, response
+ return response["result"]
+
+ try:
+ session = rpc("session.create", {
+ "model": "gpt-4.1", "workingDirectory": str(tmp_path),
+ "provider": {"type": "openai", "baseUrl": base_url},
+ })
+ params = {"sessionId": session["sessionId"]}
+ agents = rpc("session.agent.list", params)["agents"]
+ profiles = copilot_package / "com.github.copilot/agents"
+ expected = {f"egm:{frontmatter(p)['name']}": p
+ for p in profiles.glob("*.agent.md")}
+ loaded = {a["id"]: a for a in agents if a["source"] == "plugin"}
+ assert set(loaded) == set(expected)
+ for name, path in expected.items():
+ config = frontmatter(path)
+ assert Path(loaded[name]["path"]) == path
+ assert loaded[name]["tools"] == config["tools"]
+ assert loaded[name]["userInvocable"] == config.get(
+ "user-invocable", True
+ )
+ assert loaded[name]["mcpServers"] == {}
+ skills = rpc("session.skills.list", params)["skills"]
+ loaded_skills = {s["commandName"]: s for s in skills
+ if s["source"] == "plugin"}
+ expected_skills = {f"egm:{frontmatter(p)['name']}": p
+ for p in (copilot_package / "skills").glob("*/SKILL.md")}
+ assert set(loaded_skills) == set(expected_skills)
+ for name, path in expected_skills.items():
+ assert Path(loaded_skills[name]["path"]) == path
+ assert loaded_skills[name]["enabled"] is True
+ rpc("session.destroy", params)
+ finally:
+ process.terminate()
+ process.wait(timeout=5)
+ process.stdin.close()
+ process.stdout.close()
+ provider.shutdown()
+ assert provider_requests == [], "Loader attempted model access"