the-pair
AGENTS.md378 starsChanged 6 months agoApache-2.0View on GitHub
This file contains instructions and context for any AI agents (like yourself) working on the the-pair repository. "The Pair" is a Desktop application (v1.2.3) built with Tauri 2.x, React 19, and TypeScript. It orchestrates two local AI agents — a Mentor (planner/reviewer, read-only) and an Executor (code writer/command runner) — that cross-check each other's work. The app manages their lifecycle, monitors resources, tracks git changes, and provides a polished UI for humans to observe and intervene.
- Commits and pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
25 rules. About 0 are common, 2 are distinctive, and 23 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
23
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Never import Node.js built-ins directly into the Renderer (src/renderer/src/).
- Very specific: line 23
Use Tauri commands in src-tauri/src/ to expose strict APIs to the frontend.
- Very specific: line 26
Always use Tailwind CSS classes.
- Very specific: line 27
Use the cn() utility from src/renderer/src/lib/utils.ts for conditional class merging.
- Very specific: line 30
Use the handoff guard (src/renderer/src/lib/handoffGuard.ts) to prevent race conditions when pairs finish.
- Very specific: line 113
Create src-tauri/src/providers/new_provider.rs implementing the Provider trait
- Very specific: line 114
Add pub mod new_provider; to src-tauri/src/providers/mod.rs
- Very specific: line 115
Add Arc::new(new_provider::NewProvider) to all_providers() in mod.rs
- Very specific: line 116
Add the variant to ProviderKind in provider_registry.rs, plus a detect_* fn there, and extend infer_provider_kind() in provider_adapter.rs
- Very specific: line 117
Add the variant to the TypeScript ProviderKind union in src/renderer/src/types.ts
- Very specific: line 118
Update inferProviderFromModel() in providerResolution.ts (frontend, keep in lockstep with the Rust heuristic) and decide whether …
- Very specific: line 119
Update PROVIDER_PRIORITY in modelCatalogGrouping.ts (frontend)
- Very specific: line 120
Add login command + install URL to the maps in providerSetup.ts (frontend)
- Very specific: line 124
When the user says "update agents", audit every supported provider's CLI interface to make sure The Pair's build_turn_command(), …
- Very specific: line 147
Run tests: after every provider update: cargo test + npm test + npm run typecheck
- Very specific: line 153
UI Components: Keep components modular in src/renderer/src/components/.
- Very specific: line 154
State: Use usePairStore for pair-related global state.
- Very specific: line 155
Tauri Commands: Add new commands to the appropriate Rust module and register them in lib.rs's invoke_handler.
- Very specific: line 156
Models: Update model_catalog.rs when adding new model entries.
- Very specific: line 180
Keep tauri command bodies thin: extract the testable logic into plain functions (see prepare_new_run_workspace, prepare_run_context, …
- Very specific: line 190
Update CHANGELOG.md with release notes under a ## [X.Y.Z] - YYYY-MM-DD heading at the start of a line (npm run validate:changelog checks it.
- Very specific: line 191
Run quality gates locally: npm test && npm run typecheck && npm run lint
- Distinctive: line 207
Check release page for correct artifacts and notes
- Very specific: line 211
Follow Semantic Versioning (MAJOR.MINOR.PATCH):
- Distinctive: line 225
Fallback: If workflow fails to trigger, run:
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Agent Guidelines for "The Pair"
This file contains instructions and context for any AI agents (like yourself) working on the the-pair repository.
Project Identity
"The Pair" is a Desktop application (v1.2.3) built with Tauri 2.x, React 19, and TypeScript. It orchestrates two local AI agents — a Mentor (planner/reviewer, read-only) and an Executor (code writer/command runner) — that cross-check each other's work. The app manages their lifecycle, monitors resources, tracks git changes, and provides a polished UI for humans to observe and intervene.
Tech Stack
- Framework: Tauri 2.0
- Backend: Rust
- Frontend: React 19, TypeScript
- Styling: Tailwind CSS v4,
clsx,tailwind-merge - Icons:
lucide-react - State Management:
zustand(usePairStore,useUpdateStore,useThemeStore) - Animations: Framer Motion
Architecture Rules
- Rust Backend vs. React Frontend:
- Never import Node.js built-ins directly into the Renderer (
src/renderer/src/). - Use Tauri commands in
src-tauri/src/to expose strict APIs to the frontend. - Frontend calls backend via
invoke()from@tauri-apps/api/core.
- Never import Node.js built-ins directly into the Renderer (
- Styling:
- Always use Tailwind CSS classes. Custom dark/light mode palette is defined in
src/renderer/src/assets/main.css. - Use the
cn()utility fromsrc/renderer/src/lib/utils.tsfor conditional class merging.
- Always use Tailwind CSS classes. Custom dark/light mode palette is defined in
- Agent Interactions:
- The application spawns processes. Always implement an iteration limit (
maxIterations) before pausing for human intervention. - Use the handoff guard (
src/renderer/src/lib/handoffGuard.ts) to prevent race conditions when pairs finish.
- The application spawns processes. Always implement an iteration limit (
- Error Handling:
- Handle permissions and locked files defensively in the Rust backend.
- Propagate errors cleanly to the frontend via Tauri commands to display in the
ErrorDetailPanel.
Rust Backend Modules (src-tauri/src/)
| Module | Responsibility |
pair_manager | Pair lifecycle: create, list, delete, pause, resume, assign task, update models; resolves each pair's workspace (in-place, or a fresh worktree on an auto-named the-pair/… branch — per task when requested) |
message_broker | State machine for agent turn coordination and event routing |
process_spawner | Spawns CLI processes, parses JSON event streams; delegates to provider trait for extraction |
worktree_manager | Git worktree lifecycle: repo state checks, branch listing, worktree creation with work-preservation contract on delete (stash + rescued/kept the-pair/… branches) |
provider_adapter | Facade over the provider trait; legacy compatibility shim for ProviderAdapter::build_turn_command() etc. |
provider_registry | ProviderKind enum, shared helpers (which_binary, collect_*), model discovery utilities |
providers | Provider trait + per-provider modules (opencode.rs, codex.rs, claude.rs, gemini.rs, kimi.rs, pi.rs, kiro.rs, aider.rs, grok.rs, muse.rs). Each implements CLI args, token extraction, detection, and model metadata. |
model_catalog | Static model metadata (display names, billing kind, recommended roles); delegates to provider trait for per-provider fields |
session_snapshot | Persists and restores full pair state; supports session recovery after crash/restart |
skill_discovery | Scans project dirs for .md skill files with YAML frontmatter |
resource_monitor | Per-agent CPU/memory polling (1s interval) |
git_tracker | Detects modified/added/deleted files relative to a baseline commit |
file_cache | Lists files and parses @mention references in task specs |
path_env | Refreshes $PATH from login shell so CLI tools are discoverable |
config_paths | Resolves platform-specific config file locations |
intelligence_store | Cross-run intelligence: local SQLite store (intelligence.db) of run outcomes + human interventions, heuristic task tagging, insights/recommendation queries, one-time snapshot backfill |
stubs | Config/model-cache/provider-login commands |
Frontend Components (src/renderer/src/components/)
| Component | Purpose |
App.tsx | Root: routing between dashboard and pair detail views |
AppChrome.tsx | Window chrome, title bar, theme toggle |
OnboardingWizard.tsx | First-run guided setup (model config, directory selection) |
CreatePairModal.tsx | New pair creation form |
PairSettingsModal.tsx | Edit existing pair settings |
AssignTaskModal.tsx | Assign a new task to an existing pair |
ModelPicker.tsx | Model selection dropdown with role headers, drop-up support, recent model tracking (role-specific) |
SkillPicker.tsx | Browse and attach skill files to a task |
SessionRecoveryModal.tsx | Restore interrupted sessions |
TaskHistoryPanel.tsx | View past run history for a pair |
MessageFilterBar.tsx | Filter console messages by role (All/Mentor/Executor) |
ScrollToBottomButton.tsx | Auto-appears when new messages arrive |
IterationProgress.tsx | Visual indicator with warning when approaching iteration limit |
ErrorDetailPanel.tsx | Actionable error display with retry/discard options |
DashboardEmptyState.tsx | Empty state with onboarding explanation |
InsightsPanel.tsx | Cross-run combo leaderboard on the dashboard (hidden until ≥5 recorded runs) |
FileMention.tsx | Renders @file mentions in messages |
StatusBadge.tsx | Pair status pill (Idle/Mentoring/Executing/Reviewing/Paused/Error/Finished) |
UpdateNotification.tsx / UpdateControls.tsx | In-app updater UI |
Key Frontend Libraries (src/renderer/src/lib/)
| File | Purpose |
modelResolution.ts | Resolves display name and provider from a model ID |
modelPreferences.ts | Persists per-role recent model selections (role-specific keys) |
providerResolution.ts | Maps provider kind to label/config |
providerSetup.ts | Checks provider readiness |
handoffGuard.ts | Prevents duplicate handoff events after pair finishes |
workspace.ts | Workspace directory helpers |
animations.ts | Shared Framer Motion variants |
tauri-api.ts | Typed wrappers around invoke() calls |
Pair Status State Machine
Idle → Mentoring → Executing → Reviewing → (loop or Finished)
→ Paused → (resume → Mentoring or Reviewing)
→ Awaiting Human Review
→ ErrorSession Snapshot & Recovery
Snapshots are persisted to Tauri's app data directory. Each snapshot includes full conversation history, agent activity, resource usage, git tracking state, and provider session IDs. On restore, the appropriate resume prompt is injected so agents can continue from where they left off.
Provider Support
Ten provider kinds are supported: opencode, codex (OpenAI Codex CLI), claude (Claude Code CLI), gemini (Antigravity CLI), kimi (Kimi Code CLI), pi (Pi Agent CLI), kiro (AWS Kiro CLI), aider (Aider CLI), grok (xAI Grok Build CLI), muse (Meta Muse Code CLI). Each is implemented as a Provider trait in its own module under src-tauri/src/providers/.
Adding a New Provider
- Create
src-tauri/src/providers/new_provider.rsimplementing theProvidertrait - Add
pub mod new_provider;tosrc-tauri/src/providers/mod.rs - Add
Arc::new(new_provider::NewProvider)toall_providers()inmod.rs - Add the variant to
ProviderKindinprovider_registry.rs, plus adetect_*fn there, and extendinfer_provider_kind()inprovider_adapter.rs - Add the variant to the TypeScript
ProviderKindunion insrc/renderer/src/types.ts - Update
inferProviderFromModel()inproviderResolution.ts(frontend, keep in lockstep with the Rust heuristic) and decide whetherstripProviderPrefix()inmodelResolution.tsstrips the new prefix (strip it only when bare model ids remain self-identifying — see the kimi comments there) - Update
PROVIDER_PRIORITYinmodelCatalogGrouping.ts(frontend) - Add login command + install URL to the maps in
providerSetup.ts(frontend)
Updating Provider CLI Interfaces (update agents)
When the user says "update agents", audit every supported provider's CLI interface to make sure The Pair's build_turn_command(), extract_token_usage(), collect_json_candidates(), and detect_* functions still match the real CLI behavior. CLIs evolve fast — flags get renamed, output formats change, session/resume semantics shift.
Procedure:
- For each provider (
opencode,codex,claude,gemini/agy,kimi,pi,kiro,aider,grok,muse):- Web search the latest CLI documentation and changelog/release notes for the tool. Look for changes to:
- Headless/non-interactive invocation flags (e.g.
-p,--message,exec) - Output format flags (e.g.
--json,--stream,--output-format stream-json,--output-last-message) - Session resume flags (e.g.
--resume,--session,resume <id>) - Permission/sandbox flags (e.g.
--sandbox,--permission-mode,--yes-always) - Model selection flags (e.g.
--model) - Reasoning effort flags (e.g.
-c model_reasoning_effort=) - Token usage / cost reporting in JSON event schema
- Headless/non-interactive invocation flags (e.g.
- If the tool can be installed (pip, npm, brew, curl), install or update it in an isolated environment and run
--help/--jsonsample invocations to examine the actual CLI surface and event output firsthand. This is more reliable than docs alone. - Compare findings against the Rust
Providertrait implementation insrc-tauri/src/providers/<name>.rsand the detection logic inprovider_registry.rs.
- Web search the latest CLI documentation and changelog/release notes for the tool. Look for changes to:
- Update any mismatched code:
build_turn_command()— flags, arg order, flag syntaxruntime_spec()— transport/session/permission strategy if changedextract_token_usage()/collect_json_candidates()/extract_error_detail()— JSON event schemadetect_*()— auth detection, model discovery commands- Frontend maps in
providerSetup.ts,providerResolution.ts,modelCatalogGrouping.ts
- Run tests after every provider update:
cargo test+npm test+npm run typecheck - Report a summary of what changed per provider (flag renames, new features, deprecations).
Adding Features
- UI Components: Keep components modular in
src/renderer/src/components/. Reusable primitives go incomponents/ui/. - State: Use
usePairStorefor pair-related global state. Add new stores insrc/renderer/src/store/only if the concern is orthogonal. - Tauri Commands: Add new commands to the appropriate Rust module and register them in
lib.rs'sinvoke_handler. - Models: Update
model_catalog.rswhen adding new model entries; implement theProvidertrait inproviders/for new CLI tools.
Testing & Coverage
Policy: new or changed code must have 95%+ line coverage from unit tests. Measured as changed lines (git diff) against the coverage report, not whole-repo averages.
Three layers, all headless except the optional desktop smoke:
| Layer | Command | Covers |
| Rust unit tests | npm run test:rust (in cargo test) | PairManager/broker/spawner logic, git worktree operations against real temp git repos |
| Renderer unit tests | npm run test:js (store/logic, tests/*.test.ts) + npm run test:ui (jsdom component tests, tests/render/*.test.tsx) | Store contracts, modal/branch-chip UI |
| Headless e2e | npm run e2e:web (Playwright + a scripted Tauri IPC mock, e2e-web/) | Real app UI against a mocked backend |
| Desktop e2e | npm run e2e (Appium mac2, needs a GUI machine) | Real packaged app, on-demand only |
Coverage commands:
npm run coverage:ts— c8 report for the renderer (runs both unit suites).npm run coverage:rust—cargo llvm-covfor the Rust lib.
Harness notes:
- Renderer component tests (
tests/render/) run React under jsdom vianode:test+@testing-library/react. They useTSX_TSCONFIG_PATH=tsconfig.web.json(throughscripts/with-env.mjs) so tsx applies the automatic JSX transform — component modules rely on it.tests/render/setup-dom.tsinstalls the jsdom globals and the__APP_VERSION__vite define;tests/render/mock-ipc.tsinstalls the realtauri-shimplus a scriptedmockIPChandler coveringrepo_check_stateand friends. - Headless e2e (
e2e-web/) starts the vite dev server (npm run dev:renderer -- --port 5199 --host 127.0.0.1) and injectse2e-web/mock-init.jsbefore app code, definingwindow.__TAURI_INTERNALS__/__TAURI_EVENT_PLUGIN_INTERNALS__. Every IPC call lands onwindow.__MOCK_CALLS__so specs assert exact payloads. Test state is seeded throughopenApp(page, state)ine2e-web/fixtures/app.ts. - Keep tauri command bodies thin: extract the testable logic into plain functions (see
prepare_new_run_workspace,prepare_run_context,validate_assign_taskinpair_manager.rs) — command shells cannot be unit-covered without an app runtime.
Release Process (Automated)
⚠️ CRITICAL: Never manually create or push git tags!
The release workflow (build-signed-mac.yml) is fully automated:
- Prepare release:
- Bump the version with
npm run bump <version>— it updatespackage.json, the root entries ofpackage-lock.json, the[package]version insrc-tauri/Cargo.tomland the app entry insrc-tauri/Cargo.lock(tauri.conf.jsonreads its version frompackage.json) - Update
CHANGELOG.mdwith release notes under a## [X.Y.Z] - YYYY-MM-DDheading at the start of a line (npm run validate:changelogchecks it; the release workflow uses the same matcher,scripts/changelog.mjs, for its gate and for the release notes) - Run quality gates locally:
npm test && npm run typecheck && npm run lint
- Bump the version with
- Publish:
- Commit changes:
git commit -m "chore: bump version to X.Y.Z" - Push to main:
git push - Do NOT run
git tagorgit push --tags
- Commit changes:
- Workflow automation:
- GitHub Actions detects version bump (publishes only when tag
vX.Y.Zdoesn't exist yet) - Release runs are serialized (
concurrency, never cancelled); a run queued behind a release sees the new tag and skips - Builds macOS, Windows, Linux binaries
- Creates the GitHub release and tag
vX.Y.Zon the pushed commit (--target $GITHUB_SHA) with the changelog section as notes - Uploads signed artifacts and
latest.json; if the release already exists it fails instead of overwriting assets
- GitHub Actions detects version bump (publishes only when tag
- Verify:
- Monitor at: https://github.com/timwuhaotian/the-pair/actions
- Check release page for correct artifacts and notes
Version Bump Guidance
Follow Semantic Versioning (MAJOR.MINOR.PATCH):
| Keyword | Bump | When to use |
| patch release | Z +1 | Bug fixes, docs updates, typo corrections, internal refactors (no API change) |
| minor release | Y +1 | New features, new components, new Tauri commands (backward-compatible) |
| major release | X +1 | Breaking changes, UI redesigns, removed APIs, state machine changes |
Quick decision tree:
fix:,docs:,chore:,style:→ patch (e.g. 2.0.0 → 2.0.1)feat:without breaking changes → minor (e.g. 2.0.0 → 2.1.0)feat:with breaking changes, or removing public APIs → major (e.g. 2.0.0 → 3.0.0)
Fallback: If workflow fails to trigger, run:
gh workflow run build-signed-mac.ymlSee docs/RELEASE_CHECKLIST.md for detailed checklist.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

