Skip to content
This repository was archived by the owner on Jul 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c26546f
feat: incremental analyzer graph with versioned lineage and Pi-AI pro…
v2nic Jun 11, 2026
521a821
docs: replace analyzer-design-c with root DESIGN.md
v2nic Jun 11, 2026
192b77f
docs: point AGENTS.md at DESIGN.md as required first reading
v2nic Jun 11, 2026
23a9eee
docs: refresh AGENTS.md code-organization, integration-test, and CI s…
v2nic Jun 11, 2026
e22c5b7
docs: define turn (Pi-aligned) and fix the pair framing in DESIGN.md
v2nic Jun 11, 2026
845d59e
analyze: make resolved model part of node identity
v2nic Jun 11, 2026
3a624dc
analyze: align turn boundaries with host platform
v2nic Jun 11, 2026
754c25b
analyze: bring --model to life as a per-run model pin
v2nic Jun 11, 2026
b05e042
design: replace shallow/deep with revise reasons and graded versions
v2nic Jun 11, 2026
e751d7b
analyze: implement revise reasons and graded analyzer versions
v2nic Jun 11, 2026
82053fe
docs: rewrite README for the analyzer-graph extension
v2nic Jun 11, 2026
dd70391
analyze: fix LLM-enrichment merge, enforce pair cap, align role spell…
v2nic Jun 11, 2026
fec941f
analyze: fail fast on truncated LLM responses; retry transient thrott…
v2nic Jun 11, 2026
beacb71
commands: add --prospect CLI flag for non-interactive runs
v2nic Jun 11, 2026
815ba0c
analyze: self-heal failed units via decoupled error-node identity
v2nic Jun 11, 2026
960f58e
proposals: rank by confidence and add --full evidence/source view
v2nic Jun 11, 2026
a506b81
proposals: group recommendations by session
v2nic Jun 12, 2026
5ce8fa0
analyze: content-address identities (input_key + output_key), add verify
v2nic Jun 12, 2026
e49e57f
commands: add `prospect show <id>` evidence drill-down
v2nic Jun 12, 2026
f8f7ae2
docs: document prospect show + verify; fix stale dedup/term slips
v2nic Jun 12, 2026
e73f760
show: list titles and distinct id prefixes for ambiguous matches
v2nic Jun 12, 2026
d0cfdde
feat: un-gate synthesizer from correction regex; feed tool evidence t…
v2nic Jun 12, 2026
a042fb7
trajectory: add deterministic tool-trajectory analyzer (loops, oscill…
v2nic Jun 12, 2026
cd43e6e
recall-9: add success/failure contrast, positive signals, reinforceme…
v2nic Jun 12, 2026
70a8148
analyze: enumerate-then-propose synthesis (textual gradient); scale e…
v2nic Jun 12, 2026
a18d8a4
analyze: add proposal replay validation to ground confidence (#6)
v2nic Jun 12, 2026
2238b4a
docs: refresh analyzer code descriptions and add README Analyzers sec…
v2nic Jun 12, 2026
6e17487
analyze: force structured output via tool calls (reliable JSON from r…
v2nic Jun 12, 2026
2a492ca
test: cover forced-tool-call structured-output path
v2nic Jun 12, 2026
fb9e76c
analyze: dedup same-recipe units within a run
v2nic Jun 12, 2026
da73a40
analyze: materialise proposals once per input_key regardless of status
v2nic Jun 12, 2026
3847eee
db: add append-only proposal_decisions table + queries
v2nic Jun 12, 2026
6fc904e
commands: capture rationale + disposition on accept/reject
v2nic Jun 12, 2026
94c436a
commands: surface the latest human decision in proposals + show
v2nic Jun 12, 2026
cb09011
docs: document the decision model in DESIGN.md + README
v2nic Jun 12, 2026
421a009
analyze: run sessions concurrently with bounded LLM concurrency
v2nic Jun 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 46 additions & 16 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# pi-prospector

## Start here: read DESIGN.md first

Before writing or reviewing any code in this repo, read **`DESIGN.md`** at the
repository root. It is the single source of truth for *what this system is* and
*why it is shaped the way it is* — and it will save you from the most expensive
mistakes you can make here.

This is not an ordinary codebase. It is an **append-only analysis graph** with
idempotent, recipe-addressed nodes, typed-edge relationships, scan-based
incremental recomputation, and versioned lineage. Those are load-bearing
invariants, not stylistic preferences: a change that looks harmless in isolation
(mutating a node, hiding a relationship outside the edge table, leaving identity
out of the recipe, tracking progress in side state) can quietly break
traceability or idempotency across the whole system. DESIGN.md tells you which
invariants must hold and gives you a checklist for evaluating any change against
them.

It also fixes a **ubiquitous language** — precise, one-meaning definitions for
every core concept (session, pair, analysis node, node/edge kinds, recipe and
input hash, scan, unit status, run modes, lineage, model tiers, proposal
lifecycle). Use exactly these words with exactly these meanings in code, commits,
comments, and discussion. When you and the code agree on vocabulary, you stop
guessing what `stale`, `revises`, or `consumes` mean and start reasoning
correctly the first time. If you reach for a concept the glossary doesn't name,
define it there before you build it.

In short: a few minutes in DESIGN.md is the difference between contributing
*with* the architecture and accidentally fighting it. Read it, then come back
for the operational rules below.

## Session data safety

`~/.pi/agent/sessions/` is read-only. Never write, delete, or move session files. Before running sync for the first time, back up your sessions manually (e.g. `tar czf ~/prospector-backup/sessions-$(date +%Y%m%d).tgz ~/.pi/agent/sessions/`). pi-prospector does not create this backup for you.
Expand All @@ -18,31 +48,31 @@ TypeBox for all data shapes. No bare `interface` or `type` declarations. Every s
- Runner: `node:test` + `node:assert`. No test frameworks.
- Fixtures in `tests/fixtures/`. Hand-written, deterministic, version-controlled. No real session data — synthetic only.

## Integration tests (tmux + real Pi)
## Integration tests

Run the latest pi-coding-agent inside tmux, send `/prospect` commands, capture text screenshots, upload as GH Actions artifacts. This exercises the real extension loaded into a real Pi session.
`test/integration/test-commands.ts` exercises the real pipeline end-to-end without a Pi runtime: it syncs fixtures, runs the analyzer framework with a deterministic mock LLM, and asserts the analysis graph, materialised proposals, idempotent re-runs, revise-mode version lineage, and the proposal lifecycle (accept/reject). Run it with `node --import tsx test/integration/test-commands.ts`, or via the wrapper `test/integration/run-integration.sh`.

- `test/integration/run-screenshots.js` — orchestrates tmux session, sends commands, captures screenshots
- Uses the latest pi from npm (auto-installed in CI)
- Each screenshot is a `.txt` file from `tmux capture-pane`
- Scenarios: extension loads, `/prospect sync`, `/prospect stats`, `/prospect proposals`, `/prospect analyze` (mocked LLM), accept/reject
- No real API keys — mock the LLM provider via a local HTTP server
- Real SQLite (temp file), hand-written synthetic fixtures, mock LLM caller.
- No real API keys, no network, no real Pi session — the mock LLM is injected via the framework's LLM seam, not an HTTP server.

## CI

GitHub Actions on every push. Node 22 (matches Pi's minimum) and 24 (current). Three jobs:
GitHub Actions on every push and pull request to `main`. Two jobs:

1. `test` — `npm test` (unit + component, mocked LLM)
2. `integration-test` — tmux screenshots with real Pi + mocked LLM
3. Screenshots uploaded as artifacts, retained 30 days
1. `test` — matrix on Node 22 (Pi's minimum) and 24 (current); runs `npm test` (unit + component, mock LLM).
2. `integration-test` — Node 22; runs `node --import tsx test/integration/test-commands.ts` (full pipeline, mock LLM).

## Code organization

- `src/sync/` — session scanning and parsing (no LLM)
- `src/db/` — all SQL lives in `db/queries.ts` only. Migrations in `db/schema.ts`.
- `src/analyze/` — LLM prompt in `analyze/prompt.ts` only. Response parsing in `analyze/parser.ts`.
- `src/commands/` — Pi slash commands and tool registration
- `src/types.ts` — shared TypeBox schemas
- `src/sync/` — session scanning and parsing (no LLM).
- `src/db/` — all SQL lives here, nowhere else. Conversation and proposal queries in `db/queries.ts`; analysis-graph queries (nodes, edges, runs, configs, lineage) in `db/analysis-queries.ts`. Schema and the single migration in `db/schema.ts`.
- `src/analyze/` — the analyzer framework. `framework.ts` (register / scan / run), `types.ts` (TypeBox schemas), `input-hash.ts` (recipe + idempotency hashing), `edge-kinds.ts` (typed-edge vocabulary and validation), `model-tiers.ts`, `proposal-materializer.ts`, `defaults.ts` (default analyzer registration). The LLM seam is `pi-llm.ts` (production, via Pi's provider system) and `mock-llm.ts` (deterministic test double).
- `src/analyze/analyzers/<id>/` — one directory per analyzer (`turn-pair-core`, `turn-pair-llm`, `session-overview`, `tool-trajectory`), each with `index.ts`, its prompt(s), and `config.ts`.
- `src/commands/` — Pi slash commands and the `prospect` tool; registered from `src/index.ts`.
- `src/config.ts` — config loading with env overrides (`PROSPECTOR_DB_PATH`, `PROSPECTOR_SESSIONS_DIR`, `PROSPECTOR_CONFIG`).
- `src/types.ts` — shared TypeBox schemas.

See `DESIGN.md` for the concepts these modules implement and the ubiquitous language to use when naming them.

## Code style

Expand Down
Loading
Loading