AGENTS.md · diff
git:20260915.bbb8c30 to git:20260916.66f655e
68 added, 166 removed. Audit A to A.
- # AGENTS.md
-
- Shared orientation for agents working in this repository. Read this first.
-
- ## Product direction
+ # Contributor guide
- `cc-multi-cli-plugin` is moving from slash-command delegation to **external models
- and coding harnesses inside one Claude Code session**. Reduce Claude token use by
- letting the selected external model or harness do the work.
+ ## Orientation
- [ARCHITECTURE.md](ARCHITECTURE.md) is the authoritative direction.
- [README.md](README.md) describes the current prototype and its limitations.
- For session continuity in this checkout, read `.agent/HANDOFF.md` if present;
- it records pending work and validation, while this file and the architecture
- define the product direction.
+ Read [ARCHITECTURE.md](ARCHITECTURE.md) and [README.md](README.md) first. Setup
+ and provider details live in [docs/installation.md](docs/installation.md),
+ [docs/openai.md](docs/openai.md), [docs/cursor.md](docs/cursor.md),
+ [docs/zen.md](docs/zen.md), [docs/antigravity.md](docs/antigravity.md),
+ [docs/permissions.md](docs/permissions.md), and [docs/platform-support.md](docs/platform-support.md).
+ `.agent/` is gitignored scratch space. It is never authoritative.
- - Maintain our custom Node gateway and provider-specific adapters. No CLIProxyAPI,
- Go gateway, Vercel engine migration, or user-facing backend selector is planned.
- - Expose explicit model and effort choices through `/model` and named native
- workers while preserving Claude's ordinary tier meanings and configuration.
- - Visible worker lifecycle, elapsed time, streamed progress, completion, failure,
- and cancellation are product requirements.
- - Direct model integrations use Claude Code's tools and execution loop. Harness
- bridges use the real external CLI's execution loop and native authentication.
- Never replay observed external tool events as executable Claude tool calls.
- - Cursor's accepted direction is official SDK ownership of tools, persistent state,
- and native review. Claude Code supplies the session interface and outer worker
- coordination. Display external actions without replaying them as executable
- Claude tools. Initial text/status progress is acceptable; native tool-row
- rendering is a separate integration task. No Sand or alternate auth route.
- - Claude Code's existing permission-mode selector must control Cursor at prompt
- boundaries. Use UserPromptSubmit and SubagentStart hooks plus documented worker
- configuration/inheritance. No separate mode selector or Claude source patches.
- - Initial Cursor delegation supports Claude/OpenAI parents spawning named Cursor
- workers. Keep Cursor-native child spawning disabled and defer Cursor-originated
- delegation until requested; it is not a native-transition completion requirement.
- - Accept the official Cursor SDK's native Auto fallback when its classifier is
- unavailable. Do not require guaranteed review or add a replacement reviewer.
- Preserve explicit tool/Plan restrictions and do not label unverified calls reviewed.
- - The launcher uses the native Cursor harness. The callback runtime and separate
- reviewer are removed; do not restore SDK source patches or a second reviewer.
- - Native Cursor review belongs to the originating run, including workers,
- irrespective of Claude login availability. OpenAI actions likewise use the originating
- OpenAI account's reviewer, even with Claude login available, for main sessions and
- workers. Claude actions retain native Anthropic review; Zen never borrows Codex
- review. Missing GPT review fails explicitly, without Claude fallback. External
- execution retains explicit permissions.
- - Cursor supports Auto, Plan and Bypass at prompt boundaries. Plan excludes shell/edit;
- Bypass disables native Auto-review while retaining explicit capability restrictions;
- unsupported modes, unknown workers and untranslatable policies fail
- explicitly. Claude's PreToolUse/PermissionRequest hooks never run for native
- harness tools; they are observability, not policy, and do not block admission.
- Settings admission is implemented for Linux, WSL, macOS, and Windows; offline coverage is CI-verified when the matrix passes, while live macOS/Windows validation remains pending.
- - Preserve Claude subscription passthrough and isolate provider credentials.
- Do not add our own Claude subscription login/token pool or extract Antigravity
- tokens for direct model requests. External operations retain external permissions.
- - Antigravity is an opt-in official CLI harness. Claude Code's permission mode
- and tool rules take precedence; agy runs with native permissions skipped and a
- namespaced global pre-tool hook enforces Claude's denials; native children and
- MCP remain denied; no reviewer. Explicit native workspace selection is required,
- not just subprocess cwd. Never replay uncertain runs. Main-session PreCompact
- hooks authenticate summary requests with all native tools denied; they never
- authorize replay or rewinding of native state.
- - Targets: OpenAI, Cursor, Antigravity through its real CLI, OpenCode, llama.cpp,
- and Grok Build. The direct GPT gateway and Cursor SDK harness are experimental.
- Native Cursor persists and resumes SDK state. Durable run IDs permit terminal-result
- recovery; when recovery cannot produce one, the session stays interrupted and the
- next request resumes with a notice instead of refusing or replaying a cached
- failure. Once a session has a prior response, only the newest turn (everything
- after the last assistant message) is forwarded, and an outer history that no
- longer contains that response streams a notice and continues on the native
- record. Native state is never rewound. Historical callback compaction
- checks do not prove native fidelity. Antigravity cache reuse remains best-effort;
- CLI usage is cumulative and must be differenced across resume. Other bridges are planned.
+ ## Code map
- ## Refactor scope
+ | Path | Responsibility |
+ | --- | --- |
+ | `plugins/multi-core/src/launcher.ts` | Launches the gateway and registers models and workers. |
+ | `plugins/multi-core/src/gateway/server.ts` | Routes requests and manages sessions. |
+ | `plugins/multi-core/src/gateway/messages.ts`, `fetch.ts`, `tools.ts` | Shared protocol, outbound fetch, and tool aliases. |
+ | `plugins/multi-core/src/gateway/executable.ts`, `process-tree.ts` | Resolves executables and manages child processes. |
+ | `plugins/multi-core/src/gateway/atomic-write.ts`, `state-lock.ts` | Protects files and serializes native state. |
+ | `plugins/multi-core/src/gateway/cursor-settings.ts`, `mode-hook.ts`, `agent-definitions.ts` | Admits settings and maps prompt and worker permissions. |
+ | `plugins/multi-core/src/gateway/approval.ts`, `permission-hook.ts` | Approval protocol and capability checks. |
+ | `plugins/multi-core/src/gateway/mod-*.ts`, `tool-observer.ts` | Claude Mods control-plane routes, compaction, policy, and progress observation. |
+ | `plugins/multi-core/src/account.ts`, `setup.ts`, `install/` | Accounts, bootstrap, plugin discovery, and installation. |
+ | `plugins/multi-openai/src/` | Codex authentication, models, Responses translation, instructions, and reviewer. |
+ | `plugins/multi-cursor/src/` | Cursor SDK harness, permissions, progress, requests, models, and workspaces. |
+ | `plugins/multi-zen/src/` | Zen API-key authentication, catalogs, requests, and translations. |
+ | `plugins/multi-antigravity/src/` | `agy` CLI harness, models, hooks, requests, and permissions. |
+ | `test/unit/` | Offline unit tests for gateway and provider behavior. |
+ | `test/live/` | Opt-in checks against native CLIs and provider services. |
+ | `scripts/` | Development utilities, including banner generation. |
+ | `.github/workflows/ci.yml` | Runs `npm run check` on Node 24 across Linux, macOS, and Windows. |
+ | `package.json`, `biome.json`, `knip.json` | Scripts, lint rules, and entry/project analysis. |
- The TypeScript branch removed the old command, skill, and Sonnet-forwarder
- surface. Those removals do not decide the design of future integrations. The old
- structure is **not a compatibility requirement for the refactor**. Do not expand
- or repair it merely to preserve
- the old design; work on it only when the task calls for that work.
+ Keep provider authentication and catalogs in provider folders. Keep shared protocol
+ types and cross-provider helpers in `plugins/multi-core/src/gateway/`. Import
+ concrete modules directly. Do not add barrel re-exports. Platform-dependent code
+ accepts an explicit `platform` option so every branch is unit-testable on Linux.
- The obsolete Cursor/OpenCode CLI/ACP transports, vendor bundle and companion
- process helpers have been removed. Their history remains in git; do not restore
- reference-only code for a planned integration. Reuse active helpers when they save
- concrete work and implement new bridges against the current execution contract.
- Research and old plans under `.agent/archive/` are historical evidence, not active
- instructions. Keep new scratch research in gitignored `.agent/`.
+ ## Product rules
- ## Current code map
+ - Claude's permission mode controls every provider at prompt boundaries.
+ - Each provider owns its login, reviewer, execution state, and credentials.
+ - Fail explicitly on unsupported modes, unknown workers, ambiguous ownership, or missing review.
+ - Never replay external tool events as executable Claude tools.
+ - Native state is never rewound, and uncertain actions are never rerun blindly.
+ - Antigravity native children and MCP are denied.
+ - New bridges isolate session, worker, provider, and workspace state.
+ - Do not use Cursor Fast in development or live tests; set `fast:false` explicitly.
+ - Keep paid probes bounded and reuse existing usage records when possible.
+ - Do not spawn fleets of Claude agents for implementation or validation.
- Paths below are relative to `plugins/multi-core/src/` unless noted.
+ ## Verification
- - `launcher.ts`: launcher, session-local model picker, worker registration.
- - `setup.ts`, `account.ts`, `install/`: reversible Bash/Zsh wrapper, native plugin
- discovery and provider connection commands. Root `.claude-plugin/plugin.json`
- declares core; the marketplace copies the repository root as its self-contained
- runtime. Provider manifests/skills supply opt-in enablement and login commands.
- Do not assume provider source folders are standalone runtime packages.
- - `gateway/server.ts`: HTTP routing, Claude passthrough, and request/session lifecycle.
- `gateway/fetch.ts`: the `GatewayFetch` outbound-request type, kept separate so
- providers never import the HTTP server for it.
- - `gateway/messages.ts`: shared Claude Messages request/response and stream types.
- `gateway/tools.ts`: stable tool aliases. `gateway/approval.ts` and
- `gateway/permission-hook.ts`: native approval protocol and capability checks.
- - `gateway/tokens.ts`: shared local token estimates (OpenAI, Zen, Cursor and
- Antigravity all use it; `js-tiktoken` stays a dependency). `gateway/state-lock.ts`:
- `lockStateFile` holds kernel file locks across native runs, shared by Cursor and
- Antigravity.
- - `../../multi-openai/src/`: Codex authentication and CLI-owned renewal (`auth.ts`),
- models/workers (`models.ts`), Responses translation (`responses.ts`), and reviewer
- (`approval.ts`, with vendored policy/license files in `guardian/`).
- - `../../multi-zen/src/`: direct API-key auth, bounded model catalog, Chat Completions translation
- and Responses reuse. Claude executes tools; Zen has no independent reviewer.
- Cache affinity and model-owned reasoning survive gateway restarts.
- - `../../multi-cursor/src/`: native runtime (`harness.ts`), request validation,
- permissions, progress and account model/worker choices (`models.ts`).
- `workspaces.ts` routes hook-reported worktrees to separate SDK instances.
- - `gateway/mode-hook.ts` and `agent-definitions.ts`: prompt/worker permissions.
- `gateway/cursor-settings.ts`: per-dispatch Claude settings admission.
- `docs/cursor-refactor.md` records current native behavior and deferred limits.
- - Root `scripts/`: development utilities, including the SVG banner generator.
- - Root `test/unit/`: offline tests. `test/live/`: opt-in live checks.
+ Run `npm run check`. It checks the generated banner, Biome lint, Knip, strict
+ type checking, and offline tests. `npm test` runs `tsc --noEmit` and the unit
+ test suite. Use Node 24.12 or newer and avoid `DEP0190` warnings.
- Keep provider authentication and model catalogs with the provider. Shared Claude
- protocol types and cross-provider helpers (token estimation, kernel file locking)
- belong in `gateway/`; no provider imports the HTTP server for them. Import concrete
- modules directly; no re-export barrels or old-path wrappers. The Cursor bridge
- currently reuses OpenAI request normalization (`responses.ts`); do not mistake that
- explicit reuse for an independent generic protocol layer or duplicate it merely to
- make the folders look independent.
+ | Command | Check | Login needed |
+ | --- | --- | --- |
+ | `npm run test:live:compaction` | Native compaction | Claude |
+ | `npm run test:live:zen` | Zen tools, cache, and resume | Zen API key |
+ | `npm run test:live:cursor` | Cursor SDK tools, continuation, and disk resume | Cursor SDK login |
+ | `npm run test:live:auto-mode` | Native Auto mode | Provider login under test |
+ | `npm run test:live:provider-approval` | Provider approval | Provider login under test |
+ | `npm run test:live:reviewer` | Reviewer ownership | OpenAI/Cursor login as applicable |
+ | `npm run test:live:approval-worker` | Worker approval | Provider login under test |
+ | `npm run test:live:permissions` | Native permissions | Claude and provider login |
+ | `npm run test:live:antigravity` | Antigravity CLI harness | `agy` login |
+ | `npm run test:live:install` | Plugin installation | None |
- ## Development and verification
+ The definition of done is passing relevant checks, no `DEP0190` warnings, and an
+ updated `CHANGELOG.md` for user-facing changes.
- - Do not use Cursor Fast mode for development or live tests. Explicitly select
- advertised `fast:false`; do not inherit an account default. Keep paid probes
- small and bounded, and reuse existing usage records before generating more.
+ ## Code style
- - Run `npm run check` before considering a change done: generated banner freshness, Biome formatting/lint,
- Knip unused-code analysis, strict TypeScript, and offline tests. `npm run format`
- formats files; `npm run lint:fix` applies Biome's safe fixes. Do not apply all
- unsafe fixes without reviewing their effect.
- - Biome requires braces, one variable declaration per statement, no nested
- ternaries, no parameter reassignment, no explicit `any`, no non-null assertions,
- and cognitive complexity at most 15. Tests follow the same rules. Use clear
- names, keep mutable state ownership explicit, and explain protocol constraints.
- Do not manufacture arbitrary helpers to evade complexity checks.
- - Do not disable rules, raise limits, add blanket exclusions, or use assertions
- to evade validation just to pass lint. Any necessary suppression must name the
- specific rule and explain the concrete external/protocol constraint locally.
- - Knip checks active gateway/provider entry points, tests and scripts. `codex`
- and no external lock command is an npm dependency. Biome excludes
- the lockfile; hand-written runtime and test code stay covered.
- - Preserve unrelated uncommitted work. Do not restore removed integrations from
- archived plans or install/publish changes merely because an old skill says to.
- - Do not spawn fleets of Claude agents to implement or validate work here.
- - Node ≥ 24.12; the gateway uses strict TypeScript and Node's type stripping.
- `npm test` runs `tsc --noEmit` before Node's built-in test runner;
- dependencies are declared in `package.json`. The local token
- counter uses `js-tiktoken`; Node type stripping does not replace type checking.
- - Run `npm test` for offline verification. Add or extend meaningful unit tests for
- behavior changes; documentation-only edits do not need new tests.
- - Run appropriate opt-in live checks when changing a live integration path;
- these invoke real CLIs and spend provider usage. The README lists native gateway
- checks; the old companion `test:live` script was removed.
- - `npm run test:live:zen` checks native tools, cache usage and saved resume; optional
- switching, manual compaction and cancellation use bounded Zen requests. Inspect
- recorded cache/429 failures before retrying; do not manufacture cache-hit counts.
- - `npm run test:live:cursor` exercises bounded native SDK tools, continuation and
- disk resume with Fast disabled. Requires the official SDK login (`--cursor-login` on the launcher).
- - `npm run test:live:install` installs core/Zen with the real Claude plugin manager
- in a temporary home and checks cached startup, enablement and uninstall. It may
- download npm dependencies but performs no inference and touches no user logins.
- - Definition of done: relevant checks pass, no `DEP0190` warnings, and
- `CHANGELOG.md` reflects user-facing changes.
- - Future bridges need session/worker/provider/workspace isolation as specified in
- the architecture. The old companion's workspace-only state is not the contract
- to recreate.
+ Biome requires braces, one variable declaration per statement, no nested ternaries,
+ no parameter reassignment, no explicit `any`, no non-null assertions, and cognitive
+ complexity of 15 or less. Do not disable rules, add blanket suppressions, or raise
+ limits. Explain any narrow suppression beside the constrained code. Use clear
+ state ownership and keep protocol constraints explicit.