@xaccefy/pi-casefile 0.9.4 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,88 +1,53 @@
1
- # pi-casefile
2
-
3
- Local security case book for Pi Agent. Keeps your guesses → proven findings behind a PoC gate, saved in SQLite, run in a sandbox.
1
+ <div align="center">
4
2
 
5
- ## Install
3
+ # pi-casefile
6
4
 
7
- ```bash
8
- pi install npm:@xaccefy/pi-casefile
9
- ```
5
+ **Security case ledger for the [Pi agent](https://github.com/earendil-works/pi-coding-agent)** — evidence tracking with machine-verified PoC gates.
10
6
 
11
- Or via the XPI umbrella package: `pi install npm:@xaccefy/pi-xpi`
7
+ [![npm](https://img.shields.io/npm/v/@xaccefy/pi-casefile?style=flat-square&color=cb3837)](https://www.npmjs.com/package/@xaccefy/pi-casefile)
8
+ [![License: MIT](https://img.shields.io/github/license/xaccefy/pi-casefile?style=flat-square&color=blueviolet)](LICENSE)
12
9
 
13
- ## XP mode (default OFF)
10
+ </div>
14
11
 
15
- The attack-mode text stays **quiet by default** so your normal coding isn't buried in security talk.
12
+ ## What it is
16
13
 
17
- | Control | Effect |
18
- |---------|--------|
19
- | `/xp` | Toggle SWARM/OFF |
20
- | `/xp on` | Default enabled mode: SWARM |
21
- | `/xp swarm` | Bounded multi-agent workflow: auditor/tracer/skeptic/chain only |
22
- | `/xp lite` | Focused workflow: single-agent, no subagent dispatch |
23
- | `/xp off` | Quiet mode explicitly |
24
- | `PI_XP_MODE=on` | Force SWARM for this process (same as `swarm`) |
25
- | `PI_XP_MODE=swarm` | Force SWARM for this process (overrides file) |
26
- | `PI_XP_MODE=lite` | Force LITE (single-agent, no subagent dispatch) |
27
- | `PI_XP_MODE=off` | Force OFF |
14
+ A structured ledger for offensive-security work — bug bounties, CTFs, audits — built around one idea: **an agent's claim is not evidence until the machine replays it**.
28
15
 
29
- When **LITE**, every prompt gets the attacker-minded workflow plus any open cases, done by the main agent alone — no `subagent` dispatch (CTF / single-shot engagements). When **SWARM**, the bounded pipeline is injected and only auditor/tracer/skeptic/chain are delegated; validation, patching, reporting, and ConfirmFinding stay with the main agent. When **OFF**, nothing is added; tools still work.
16
+ Cases move `hypothesis investigating confirmed reported`. Promotion between phases is gated:
30
17
 
31
- State is persisted next to the ledger as `xp-mode` (e.g. `.pi/xp-mode`).
18
+ - **Zero exit is necessary but never proof** direct-response findings require nonce-bound body evidence plus a DNS-pinned, conclusive `target_only` replay against an operator-approved control
19
+ - **Differential confirmation** — `inter_host` (attack vs control host) or `intra_target` (attack vs baseline request) so "it worked" means *the discriminator fired*, not "the agent said so"
20
+ - **Blind/OOB classes** confirm through an operator-run oracle with per-run tokens and source-separation attestation
21
+ - Only the main agent makes the semantic decision and commits phase transitions
32
22
 
33
- ## Environment
23
+ Designed for **human + AI workflows**: every confirmed finding carries a reproducible evidence trail a human can audit.
34
24
 
35
- | Variable | Purpose |
36
- |----------|---------|
37
- | `PI_CASEFILE_PATH` | Absolute path to the SQLite ledger file |
38
- | `CASEFILE_WORKSPACE_ROOT` / `PI_WORKSPACE_ROOT` | Override workspace root used to place `.pi/casefile.db` |
39
- | `PI_POC_ALLOW_NETWORK=1` | Operator authorization for a networked PoC sandbox |
40
- | `PI_POC_ALLOW_PRIVATE_REPLAY=1` | Operator authorization for harness replay to private/internal targets |
41
- | `PI_POC_CONTROL_TARGETS` | Comma/newline-separated operator-approved control hosts/origins; agent-invented controls are rejected |
25
+ ## Tools
42
26
 
43
- Default DB path: `<workspace>/.pi/casefile.db`
27
+ | Tool | Purpose |
28
+ |---|---|
29
+ | `CaseAdd` / `CaseList` / `CaseSearch` / `CaseGet` / `CaseUpdate` / `CaseLink` / `CaseUnlink` / `CaseContext` | case lifecycle, search, links, and report context |
30
+ | `EvidenceAdd` | attach raw evidence to a case |
31
+ | `CoverageAdd` | record tested (asset × class) cells — found or clean |
32
+ | `PromoteFinding` → harness replay → `ConfirmFinding` | gated finding pipeline |
33
+ | `ScratchpadWrite` / `ScratchpadRead` / `ScratchpadClear` | working notes, resume-safe (no pipeline orchestration) |
44
34
 
45
- ## State machine
35
+ ## Install
46
36
 
37
+ ```bash
38
+ pi install npm:@xaccefy/pi-casefile
47
39
  ```
48
- hypothesis → investigating → confirmed → reported
49
- ↓ ↓
50
- blocked killed (terminal)
51
- ```
52
-
53
- - **investigating** needs `evidence` + `confidence`
54
- - **confirmed** only through the two-phase gate — `PromoteFinding` runs the PoC 2× target + 1× control, requires complete zero-exit runs and nonce-bound discriminating response-body evidence, then the harness performs a DNS-pinned identical replay and requires two conclusive responses with `target_only`. Reflection-capable requests may add a post-PoC harness-generated canary that must appear only on target. Status-only/trivial matchers and incomplete response capture are rejected. Exit zero is necessary but never proof. The main agent performs semantic review and calls `ConfirmFinding`, which captures a second fresh harness replay and binds it to the verdict; worker processes are rejected. Blind/OOB claims fail closed without a source-separated oracle.
55
- - **Every promotion requires a distinct `control_target`** pre-approved by the operator in `PI_POC_CONTROL_TARGETS`; an agent cannot invent its own easy control. `control_path` defaults to `poc_path` and exists only as an override — if supplied, it must contain the same bytes as the PoC (sha256 enforced). The control run is stored as `controlVerified`. Crashes, transport-inconclusive controls, status-only evidence, and missing evidence all block promotion.
56
- - **New cases require `disproveIf`** — falsification conditions (what would disprove this hypothesis). A hypothesis that can't say what kills it isn't one yet.
57
- - **A kill must be justified**: either an EvidenceAdd `refutation` item, or a canonical kill-reason token (intended_behavior, duplicate, framework_protection, out_of_scope, insufficient_impact, no_attack_path, ...) in assumptions/nextStep. Bare `status: "killed"` is rejected.
58
- - **reported** needs `CaseContext` first (records the report path; the main agent produces the final file)
59
- - **killed** / **reported** are final (no more edits)
60
40
 
61
- ## Evidence items
62
-
63
- `EvidenceAdd` records role-typed, artifact-backed evidence (observation / reproduction / impact / refutation / cleanup). Artifact reads are restricted to regular, non-symlink files inside the workspace. Bytes are copied durably and stored as basename + SHA-256; the full source path is never persisted. The PoC gate auto-records the `reproduction` item at promotion.
64
-
65
- ## Tools
66
-
67
- | Tool | Use |
68
- |------|-----|
69
- | `CaseAdd` | Open a case (`title` + `disproveIf` required; start as `hypothesis` or `investigating`) |
70
- | `CaseUpdate` | Evidence, impact, severity, status (not direct confirm) |
71
- | `EvidenceAdd` | Role-typed, hashed evidence item on a case (refutation justifies kills; cleanup tracks cleanup) |
72
- | `PromoteFinding` | Phase 1: main-agent-only PoC 2× target + 1× operator-approved control, then DNS-pinned harness-owned replay requiring conclusive `target_only`; optional reflection canary upgrades the recorded proof strength when observed only on target. `local:true` and private replay are operator-gated; blind/OOB proof fails closed without source separation |
73
- | `ConfirmFinding` | Phase 2: main-agent-only semantic decision plus a fresh harness-owned target/control replay (CONFIRMED promotes; NOT_CONFIRMED keeps investigating; worker/subagent gate calls are rejected) |
74
- | `CaseGet` / `CaseList` / `CaseSearch` | Read / filter / search |
75
- | `CaseLink` / `CaseUnlink` | Bidirectional exploit chains |
76
- | `ChainSuggest` | Scan cases for exploitable chain combinations (credential+endpoint→ATO, redirect+OAuth→token theft, XSS+state-change→CSRF, IDOR+user-data, SSTI→RCE, race+payment, info-disclosure+SSRF), ranked by confidence |
77
- | `CoverageAdd` | Record a tested (asset × attack-class) cell — `scope: wide` (deployment-wide verdict, applies to every later asset) or `local`; both found and clean results count. Optionally link the cell to an artifact-backed evidence item (`evidence_item_id`); unbacked cells render as ⚠ unbacked in the report |
78
- | `CoverageReport` | Render the machine-checkable coverage matrix (which classes are tested where; plateau claims must match it) |
79
- | `CaseContext` | Context bundle for a confirmed/reported case (full record, logs, links, artifacts) + report path |
80
-
81
- Commands: `/casefile` (dashboard), `/xp` (XP mode).
41
+ Peer-depends on a Pi-compatible agent host (`@earendil-works/pi-coding-agent`, `pi-ai`, `pi-tui`, `typebox`). Runtime deps: `@xaccefy/pi-shared`, `undici`.
82
42
 
83
43
  ## Development
84
44
 
85
45
  ```bash
86
- bun test packages/pi-casefile
46
+ bun install
47
+ bun test --isolate
87
48
  bun run typecheck
88
49
  ```
50
+
51
+ ## License
52
+
53
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xaccefy/pi-casefile",
3
- "version": "0.9.4",
4
- "description": "Offensive security case tracker for Pi Agent bug bounties, CTFs, security audits",
3
+ "version": "0.10.1",
4
+ "description": "Offensive security case tracker for Pi Agent \u2014 bug bounties, CTFs, security audits",
5
5
  "keywords": [
6
6
  "pi-package",
7
7
  "pi-extension",
@@ -15,16 +15,17 @@
15
15
  "license": "MIT",
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://github.com/xaccefy/pi-xpi.git",
19
- "directory": "packages/pi-casefile"
18
+ "url": "git+https://github.com/xaccefy/pi-casefile.git"
20
19
  },
21
- "homepage": "https://github.com/xaccefy/pi-xpi/tree/main/packages/pi-casefile#readme",
20
+ "homepage": "https://github.com/xaccefy/pi-casefile#readme",
22
21
  "bugs": {
23
- "url": "https://github.com/xaccefy/pi-xpi/issues"
22
+ "url": "https://github.com/xaccefy/pi-casefile/issues"
24
23
  },
25
24
  "scripts": {
26
- "test": "bun test test",
27
- "typecheck": "tsc --noEmit --project tsconfig.json"
25
+ "test": "bun test --isolate",
26
+ "typecheck": "tsc --noEmit",
27
+ "lint": "biome check .",
28
+ "lint:fix": "biome check . --write"
28
29
  },
29
30
  "publishConfig": {
30
31
  "access": "public",
@@ -34,16 +35,15 @@
34
35
  "src/index.ts",
35
36
  "src/evidence.ts",
36
37
  "src/harness-verify.ts",
38
+ "src/oob-oracle.ts",
39
+ "src/confirmation.ts",
40
+ "src/ledger-internal.ts",
37
41
  "src/safe-state.ts",
38
- "src/ledger-worker.ts",
39
- "src/ledger-worker-entry.ts",
40
42
  "src/ledger.ts",
41
- "src/workflow.ts",
42
43
  "src/poc-runner.ts",
43
- "src/pipeline-submit.ts",
44
44
  "src/scratchpad.ts",
45
+ "src/workflow.ts",
45
46
  "src/sqlite-compat/index.ts",
46
- "skills",
47
47
  "README.md",
48
48
  "LICENSE"
49
49
  ],
@@ -55,9 +55,6 @@
55
55
  "pi": {
56
56
  "extensions": [
57
57
  "./src/index.ts"
58
- ],
59
- "skills": [
60
- "./skills"
61
58
  ]
62
59
  },
63
60
  "devDependencies": {