|
| 1 | +--- |
| 2 | +name: pi-agent-rust |
| 3 | +description: >- |
| 4 | + Speeds up pi_agent_rust development and verification workflows. Use when editing providers, |
| 5 | + tools, sessions, extensions, installer/uninstaller logic, or triaging regressions in this repo. |
| 6 | +--- |
| 7 | + |
| 8 | +<!-- pi_agent_rust installer managed skill --> |
| 9 | + |
| 10 | +# Pi Agent Rust |
| 11 | + |
| 12 | +## Use This Skill When |
| 13 | + |
| 14 | +- You are working inside `pi_agent_rust` and need the fastest path to safe, verified edits. |
| 15 | +- You are touching provider/tool/session/extension behavior and need targeted triage. |
| 16 | +- You are changing installer/uninstaller/skill install behavior and need deterministic safety checks. |
| 17 | +- You need symptom-first debugging playbooks instead of ad-hoc command hunting. |
| 18 | + |
| 19 | +## 60-Second Bootstrap |
| 20 | + |
| 21 | +```bash |
| 22 | +export CARGO_TARGET_DIR="/data/tmp/pi_agent_rust/${USER:-agent}" |
| 23 | +export TMPDIR="/data/tmp/pi_agent_rust/${USER:-agent}/tmp" |
| 24 | +mkdir -p "$TMPDIR" |
| 25 | + |
| 26 | +rch exec -- cargo check --all-targets |
| 27 | +rch exec -- cargo clippy --all-targets -- -D warnings |
| 28 | +cargo fmt --check |
| 29 | +bash tests/installer_regression.sh |
| 30 | +``` |
| 31 | + |
| 32 | +## Symptom Router |
| 33 | + |
| 34 | +| Symptom | First 3 Commands | |
| 35 | +|---|---| |
| 36 | +| Provider stream/tool-call regression | `cargo test provider_streaming -- --nocapture` ; `rg -n "stream|tool|delta|event|SSE" src/providers src/sse.rs` ; `cargo test conformance` | |
| 37 | +| Session replay/index drift | `cargo test session -- --nocapture` ; `rg -n "Session|save|open|index|jsonl|sqlite" src/session.rs src/session_index.rs` ; `cargo test conformance` | |
| 38 | +| Extension policy/runtime failure | `cargo test extension -- --nocapture` ; `rg -n "policy|hostcall|capability|quickjs|deny|allow" src/extensions.rs src/extensions_js.rs` ; `cargo test conformance` | |
| 39 | +| Installer/uninstaller/skill issue | `bash tests/installer_regression.sh` ; `rg -n "AGENT_SKILL_STATUS|CHECKSUM_STATUS|SIGSTORE_STATUS|COMPLETIONS_STATUS" install.sh` ; `rg -n "managed skill|expected skill directory|PIAR_AGENT_SKILL" uninstall.sh` | |
| 40 | +| Interactive vs RPC divergence | `cargo test e2e_rpc -- --nocapture` ; `rg -n "interactive|rpc|stdin|event|session" src/main.rs src/interactive.rs src/rpc.rs` ; `cargo test conformance` | |
| 41 | + |
| 42 | +For deeper diagnosis, use `references/DEBUGGING-PLAYBOOKS.md`. |
| 43 | + |
| 44 | +## Non-Negotiables |
| 45 | + |
| 46 | +- Read `AGENTS.md` first, then follow it exactly. |
| 47 | +- Do not delete files or run destructive git/filesystem commands. |
| 48 | +- Keep edits in-place; avoid creating variant files for the same purpose. |
| 49 | +- Use `main` semantics in docs/scripts; do not introduce `master`. |
| 50 | +- Prefer `rg` for fast text recon and `ast-grep` for structural matching/refactors. |
| 51 | +- Prefer `rch exec -- <cargo ...>` for heavy compile/test workloads. |
| 52 | +- After substantive edits, run compile/lint/format gates and the smallest relevant regression slice. |
| 53 | + |
| 54 | +## Core Workflow |
| 55 | + |
| 56 | +- [ ] Recon: identify exact change surface and invariants. |
| 57 | +- [ ] Implement: minimal, behavior-focused patch with explicit failure semantics. |
| 58 | +- [ ] Validate: targeted tests first, broaden only as needed. |
| 59 | +- [ ] Verify UX: error/status output is explicit, stable, and non-ambiguous. |
| 60 | +- [ ] Sync docs: update `README.md` when flags/behavior/user guidance changed. |
| 61 | + |
| 62 | +## Changed Files -> Required Tests |
| 63 | + |
| 64 | +| Changed Files (examples) | Minimum Required Tests | |
| 65 | +|---|---| |
| 66 | +| `install.sh`, `uninstall.sh`, `.claude/skills/pi-agent-rust/**` | `bash -n install.sh uninstall.sh tests/installer_regression.sh` ; `shellcheck -x install.sh uninstall.sh tests/installer_regression.sh` ; `bash tests/installer_regression.sh` ; `bash scripts/skill-smoke.sh` | |
| 67 | +| `src/providers/**`, `src/provider.rs`, `src/sse.rs` | `cargo test provider_streaming` ; `cargo test conformance` | |
| 68 | +| `src/session.rs`, `src/session_index.rs`, `src/session_test.rs` | `cargo test session` ; `cargo test conformance` | |
| 69 | +| `src/extensions.rs`, `src/extensions_js.rs` | `cargo test extension` ; `cargo test conformance` | |
| 70 | +| `src/tools.rs` | `cargo test tools` ; `cargo test conformance` | |
| 71 | +| `src/interactive.rs`, `src/rpc.rs`, `src/main.rs` | `cargo test e2e_rpc` ; `cargo test conformance` | |
| 72 | + |
| 73 | +## Do Not Run Yet |
| 74 | + |
| 75 | +Run these only after targeted repro + focused slice indicates need: |
| 76 | + |
| 77 | +- Broad `cargo test` across entire workspace when a narrower slice already reproduces. |
| 78 | +- Heavy multi-surface runs before confirming changed-file impact. |
| 79 | +- Repeated full conformance loops while the core failing slice is still unstable. |
| 80 | + |
| 81 | +## High-Value Commands |
| 82 | + |
| 83 | +```bash |
| 84 | +# Fast recon |
| 85 | +git status --short |
| 86 | +rg -n "install|uninstall|skill|checksum|sigstore|completion|provider|session|extension" \ |
| 87 | + install.sh uninstall.sh README.md tests/installer_regression.sh src/ |
| 88 | + |
| 89 | +# Installer + skill safety gates |
| 90 | +bash -n install.sh uninstall.sh tests/installer_regression.sh |
| 91 | +shellcheck -x install.sh uninstall.sh tests/installer_regression.sh |
| 92 | +bash tests/installer_regression.sh |
| 93 | +bash scripts/skill-smoke.sh |
| 94 | + |
| 95 | +# Rust gates |
| 96 | +rch exec -- cargo check --all-targets |
| 97 | +rch exec -- cargo clippy --all-targets -- -D warnings |
| 98 | +cargo fmt --check |
| 99 | +``` |
| 100 | + |
| 101 | +For an expanded command cookbook, see `references/COMMANDS.md`. |
| 102 | +For deep incident triage, see `references/DEBUGGING-PLAYBOOKS.md`. |
| 103 | + |
| 104 | +## Critical Files |
| 105 | + |
| 106 | +- `src/main.rs`: CLI entry and mode dispatch. |
| 107 | +- `src/agent.rs`: agent loop and tool iteration behavior. |
| 108 | +- `src/provider.rs`: provider trait contract. |
| 109 | +- `src/providers/`: provider implementations and factory wiring. |
| 110 | +- `src/tools.rs`: built-in tools (`read`, `write`, `edit`, `bash`, `grep`, `find`, `ls`). |
| 111 | +- `src/session.rs`: JSONL session persistence. |
| 112 | +- `src/session_index.rs`: session index and metadata cache. |
| 113 | +- `src/extensions.rs` + `src/extensions_js.rs`: extension policy and QuickJS bridge. |
| 114 | +- `src/interactive.rs` + `src/rpc.rs`: TUI and RPC/stdin surfaces. |
| 115 | +- `install.sh` + `uninstall.sh`: install lifecycle, migration, and skill management. |
| 116 | +- `tests/installer_regression.sh`: installer regression harness. |
| 117 | +- `scripts/skill-smoke.sh`: skill integrity + inline-sync validation. |
| 118 | + |
| 119 | +## Known Footguns |
| 120 | + |
| 121 | +- Custom artifact install paths without compatible release context can fall back incorrectly if not explicitly guarded. |
| 122 | +- Skill status can become misleading on mixed outcomes unless partial/failure branches are explicit. |
| 123 | +- Uninstall logic must enforce both marker checks and expected destination path shape. |
| 124 | +- Installer progress/status text should stay on stderr when stdout is used for data plumbing. |
| 125 | +- Bundled skill and inline fallback can silently drift unless explicitly checked. |
| 126 | + |
| 127 | +## Patch Patterns |
| 128 | + |
| 129 | +### Pattern 1: Mixed Outcome Status Clarity |
| 130 | + |
| 131 | +```bash |
| 132 | +# BEFORE: everything collapsed into "skipped custom" |
| 133 | +if [ "$skipped_custom" -ge 1 ]; then |
| 134 | + AGENT_SKILL_STATUS="skipped (existing custom skill)" |
| 135 | +fi |
| 136 | + |
| 137 | +# AFTER: distinguish custom-skip from write failure |
| 138 | +if [ "$skipped_custom" -ge 1 ] && [ "$failed_writes" -ge 1 ]; then |
| 139 | + AGENT_SKILL_STATUS="partial (custom skill kept; other install failed)" |
| 140 | +elif [ "$skipped_custom" -ge 1 ]; then |
| 141 | + AGENT_SKILL_STATUS="skipped (existing custom skill)" |
| 142 | +fi |
| 143 | +``` |
| 144 | + |
| 145 | +### Pattern 2: Safe Skill Replacement |
| 146 | + |
| 147 | +```bash |
| 148 | +# BEFORE: remove destination before validating copy result |
| 149 | +rm -rf "$destination" |
| 150 | +cp "$source" "$destination/SKILL.md" |
| 151 | + |
| 152 | +# AFTER: stage then atomically move into place |
| 153 | +staged="$(mktemp -d ...)" |
| 154 | +cp "$source" "$staged/SKILL.md" |
| 155 | +mv "$staged" "$destination" |
| 156 | +``` |
| 157 | + |
| 158 | +## Failure Triage |
| 159 | + |
| 160 | +- Installer summary/status mismatch: |
| 161 | + trace `AGENT_SKILL_STATUS`, `CHECKSUM_STATUS`, and `COMPLETIONS_STATUS` in `install.sh`. |
| 162 | +- Install/uninstall safety concern: |
| 163 | + verify marker checks and expected destination guards in both scripts. |
| 164 | +- Provider/session/extension regressions: |
| 165 | + use symptom router, then follow `references/DEBUGGING-PLAYBOOKS.md`. |
| 166 | +- Docs drift: |
| 167 | + ensure `README.md` flags/examples match current installer behavior. |
| 168 | + |
| 169 | +## Done Criteria |
| 170 | + |
| 171 | +- Changed-file matrix minimum tests passed. |
| 172 | +- Compile/lint/format checks passed for touched surfaces. |
| 173 | +- Installer/skill changes pass `tests/installer_regression.sh` and `scripts/skill-smoke.sh`. |
| 174 | +- Behavior is explicit on failure paths; no silent fallback surprises. |
| 175 | +- Skill docs and inline fallback remain aligned and current. |
0 commit comments