pi-warden 0.1.0 → 0.1.2

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,10 +1,19 @@
1
1
  # pi-warden
2
2
 
3
- Harness guardrails for [Pi](https://pi.dev), built on [pi-typesafe](https://github.com/DevMortimer/pi-typesafe). Before the agent runs a `bash`, `write`, or `edit` call, pi-warden checks it twice: a fast offline pattern pass for the obvious hazards, then one TypeSafe (Jev) request that scores how **irreversible** and how **off-task** the action is relative to your latest request. High scores open a confirm dialog; you decide, and a declined call is blocked with a short reason the agent can act on.
3
+ A second pair of eyes for [Pi](https://pi.dev). Before the agent runs a `bash`, `write`, or `edit` call, pi-warden asks [Jev](https://typesafe.ai) two questions about it in ~250 ms: *would this destroy something that cannot be recovered?* and *is this what the user actually asked for?* The answers are probabilities, so `rm -rf dist` after "rebuild from scratch" sails through while `npm run db:reset` after "add a column" stops for your confirmation. Built on [pi-typesafe](https://github.com/DevMortimer/pi-typesafe).
4
4
 
5
- Independent project. Not affiliated with TypeSafe AI or the Pi authors.
5
+ ![Real verdicts from pi-warden: the same command gets a different verdict depending on what the user asked for](https://raw.githubusercontent.com/DevMortimer/pi-warden/main/docs/preview.png)
6
6
 
7
- ![Pi asking for confirmation before a destructive command, with pi-warden's irreversible and off-task scores in the dialog](https://raw.githubusercontent.com/DevMortimer/pi-warden/main/docs/preview.png)
7
+ The verdicts above are real output from `npm run test:live`. Independent project; not affiliated with TypeSafe AI or the Pi authors.
8
+
9
+ ## Why a coding agent needs this
10
+
11
+ Agents are good at picking the next command and bad at noticing when that command is out of proportion to the request. Pattern lists catch `rm -rf /` and force pushes; they cannot tell `db:reset` when you asked for a reset from `db:reset` when you asked for a column. A generative model can, but a second LLM call per tool call is slow and expensive. Jev is a System One model: it returns calibrated probabilities instead of text, in a quarter of a second, for a fraction of a cent. That makes it cheap enough to sit in front of **every** guarded call:
12
+
13
+ - **Irreversible actions get a dialog** before they run: history rewrites, deleted untracked work, dropped tables, overwritten files outside the project, publishes and deploys. You decide; a declined call is blocked with a one-line reason the agent can act on, not a stack trace.
14
+ - **Scope drift gets flagged.** Poems in a bugfix, refactors nobody asked for, dependency installs unrelated to the task: warned at 0.6, confirmed at 0.85 when Jev also calls the action `unrelated`.
15
+ - **Nothing slows down the boring calls.** Read-only shell lines are skipped without a request; anything else costs one request of ~600 input tokens.
16
+ - **It degrades gracefully.** Offline pattern checks run with no account at all. On an API timeout or outage the call is allowed with a warning (configurable), and the reasons never include your command text or upstream error bodies.
8
17
 
9
18
  ## Install
10
19
 
@@ -99,6 +108,7 @@ npm install
99
108
  npm run check # typecheck, offline tests (mocked transport), build
100
109
  npm run test:live # nine billable synthetic judgments against api.typesafe.ai (key from .env or the stored login)
101
110
  npm run dev:pi # start Pi with this working tree plus an installed pi-typesafe
111
+ npm run preview # re-render docs/preview.png from the recorded live verdicts (needs a Chrome binary)
102
112
  ```
103
113
 
104
114
  ## License
package/dist/extension.js CHANGED
@@ -193,6 +193,11 @@ export default function wardenExtension(pi) {
193
193
  if (ctx.hasUI)
194
194
  ctx.ui.setWidget(WIDGET, [formatVerdict(verdict)]);
195
195
  report(`${formatVerdict(verdict)}${verdict.reasons.length ? ` — ${verdict.reasons.join("; ")}` : ""}${judge ? "" : " (pattern checks only: TypeSafe judgments are not enabled or no key is configured)"}${verdict.error ? ` — ${verdict.error}` : ""}`);
196
+ if (ctx.hasUI && verdict.level === "confirm") {
197
+ // Show the same dialog a real call would get, so users can see what blocking looks like without touching anything.
198
+ const allowed = await ctx.ui.confirm("warden: allow this bash call? (demo)", `${confirmMessage(verdict)}\n\nThis is /warden test: nothing runs either way.`);
199
+ report(allowed ? "Demo: you chose Yes, so a real call would have run." : "Demo: you chose No, so a real call would have been blocked and the agent told why.");
200
+ }
196
201
  return;
197
202
  }
198
203
  report(`Unknown action "${action}". Use: ${actions.join(", ")}.`, "warning");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-warden",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Harness guardrails for Pi built on pi-typesafe: pattern checks plus Jev judgments flag irreversible or off-task bash, write, and edit calls before they run.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -52,6 +52,7 @@
52
52
  "test": "node --import tsx --test tests/*.test.ts",
53
53
  "test:live": "node --env-file-if-exists=.env scripts/live-smoke.mjs",
54
54
  "dev:pi": "node scripts/dev-pi.mjs",
55
+ "preview": "node scripts/render-preview.mjs",
55
56
  "check": "npm run typecheck && npm test && npm run build",
56
57
  "prepack": "npm run build"
57
58
  },