pi-warden 0.5.1 → 0.5.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 +3 -3
- package/dist/config.d.ts +2 -0
- package/dist/config.js +2 -0
- package/dist/extension.js +17 -1
- package/dist/guard.d.ts +4 -0
- package/dist/guard.js +13 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/shape.d.ts +15 -0
- package/dist/shape.js +46 -0
- package/dist/trace.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-warden
|
|
2
2
|
|
|
3
|
-
A second pair of eyes for [Pi](https://pi.dev) that makes the agent smarter instead of interrupting you. Before the agent runs a `bash`, `write`, or `edit` call (or a shell command through [context-mode](https://www.npmjs.com/package/context-mode)'s `ctx_execute`), 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" is held, and the agent is told why so it re-plans or asks you in chat.
|
|
3
|
+
A second pair of eyes for [Pi](https://pi.dev) that makes the agent smarter instead of interrupting you. Before the agent runs a `bash`, `write`, or `edit` call (or a shell command through [context-mode](https://www.npmjs.com/package/context-mode)'s `ctx_execute`), 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" is held, and the agent is told why so it re-plans or asks you in chat. More guards watch the run: a **stuck-loop** detector, a **done-check** for completion claims that no test backed up, **slop** notes for stubs, filler, and padded replies, a check for **injected instructions** in tool output, and **tail compression** of large tool results. Every verdict lands on a status line above the editor; **click it** (fullscreen mode), press `ctrl+shift+w`, or run `/warden trace` to open a live trace sidebar with the scores, the reasons, and exactly what the agent was told. Built on [pi-typesafe](https://github.com/DevMortimer/pi-typesafe).
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -52,7 +52,7 @@ A `TYPESAFE_API_KEY` environment variable takes precedence over the stored key.
|
|
|
52
52
|
|
|
53
53
|
1. **Skip** read-only tools, and read-only shell lines such as `git status && ls` (no network, no widget). Guarded by default: `bash`, `powershell`, `write`, `edit`, and context-mode's `ctx_execute`, `ctx_execute_file`, `ctx_batch_execute` (their `code`/`commands` fields are read as the command; non-shell code such as JavaScript is judged but never skipped as read-only). Add other tools with `action.tools`; unknown tools are judged from their JSON input.
|
|
54
54
|
2. **Pattern pass** (offline): force pushes, `git reset --hard`, `git clean -f`, recursive `rm` on absolute/home/variable/parent paths, SQL `DROP`/`TRUNCATE`/`DELETE FROM`, block-device writes, `chmod -R 777`, fork bombs, `curl | sh`, `kill -1`, shutdown, package publishing, infrastructure destroys → **hold**. `rm -rf` on a project path, `git checkout -- .`, `git branch -D`, `git stash drop`, `find -delete`, `sudo` → **warn**. Reads or writes of `.env`, SSH, AWS, npm, kube, and other credential files → **warn**. A `write` that overwrites an existing file outside the project → **hold**; creating or editing outside the project → **warn**.
|
|
55
|
-
3. **Jev judgment** (with consent): one request with the state `{ task, action }` and
|
|
55
|
+
3. **Jev judgment** (with consent): one request with the state `{ task, context, action }` and four questions — `irreversible` (Noul), `off_task` (Noul), `mutates` (Noul: does it change anything), `scope` (Choice: expected step, plausible side step, unrelated, unclear). Defaults: irreversible ≥ 0.5 warns, ≥ 0.7 holds; off-task ≥ 0.6 warns, ≥ 0.85 with `unrelated` holds **only when the action can change something** (`write`/`edit`, or `mutates` ≥ 0.5). An unrelated `cat`/`grep`/`node -e` inspection or a read-only `ctx_execute` script is warned about, never held: scope alone is not worth blocking a command that cannot do damage. Pattern results set the floor; Jev can only raise it. For `write`/`edit`, the slop and `security_risk` questions ride on the same request.
|
|
56
56
|
4. **Act**, by mode:
|
|
57
57
|
- `steer` (default): a hold blocks the call and returns the judgment to the agent as the tool result, with the two acceptable next moves. You see a notification and the widget line; the agent keeps working. When the agent asks you and your reply approves the action (Jev: `approved` ≥ 0.7, or an offline yes/go-ahead heuristic without consent), the identical retry is allowed once.
|
|
58
58
|
- `confirm`: a hold opens a `ctx.ui.confirm` dialog; No blocks with a short reason. Without a UI this falls back to `steer`.
|
|
@@ -184,7 +184,7 @@ A project may add `.pi/pi-warden.json` with `enabled` and per-guard overrides (f
|
|
|
184
184
|
|
|
185
185
|
### After updating the package
|
|
186
186
|
|
|
187
|
-
Run `/reload` in each existing Pi session after an update. If an existing session still reports `Cannot read properties of undefined (reading 'enabled')` while a fresh session works, restart that session to replace loaded modules. Version labels alone do not prove that all in-memory modules match the files on disk. Current config loading merges missing legacy fields with defaults; regression tests cover malformed and pre-prose config files. A
|
|
187
|
+
Run `/reload` in each existing Pi session after an update. If an existing session still reports `Cannot read properties of undefined (reading 'enabled')` while a fresh session works, restart that session to replace loaded modules. Version labels alone do not prove that all in-memory modules match the files on disk. Current config loading merges missing legacy fields with defaults; regression tests cover malformed and pre-prose config files. Since 0.5.2 the extension also checks the shape of the config it receives: if a section is missing (the symptom of an extension module and a config module from different package versions in one process), that guard is switched off and one warning names the missing sections and the schema numbers instead of throwing inside Pi. If you see that warning, restart Pi. A crash that survives a restart needs its stack trace and a redacted config example.
|
|
188
188
|
|
|
189
189
|
## For extension authors
|
|
190
190
|
|
package/dist/config.d.ts
CHANGED
|
@@ -93,6 +93,8 @@ export interface WardenConfig {
|
|
|
93
93
|
steerVisible: boolean;
|
|
94
94
|
}
|
|
95
95
|
export declare const PACKAGE_NAME = "pi-warden";
|
|
96
|
+
/** Bumped when WardenConfig gains a section; extension.ts checks it so a half-updated module graph is reported, not crashed on. */
|
|
97
|
+
export declare const CONFIG_SCHEMA = 3;
|
|
96
98
|
export declare const PROJECT_CONFIG_FILE = "pi-warden.json";
|
|
97
99
|
export declare function defaultConfig(): WardenConfig;
|
|
98
100
|
/** Mirrors Pi's agent directory rule so the file sits next to pi-typesafe's auth.json. */
|
package/dist/config.js
CHANGED
|
@@ -4,6 +4,8 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { COMMAND_TOOLS } from "./tools.js";
|
|
5
5
|
import { defaultWidgetConfig } from "./widget.js";
|
|
6
6
|
export const PACKAGE_NAME = "pi-warden";
|
|
7
|
+
/** Bumped when WardenConfig gains a section; extension.ts checks it so a half-updated module graph is reported, not crashed on. */
|
|
8
|
+
export const CONFIG_SCHEMA = 3;
|
|
7
9
|
export const PROJECT_CONFIG_FILE = `${PACKAGE_NAME}.json`;
|
|
8
10
|
export function defaultConfig() {
|
|
9
11
|
return {
|
package/dist/extension.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MouseRegion, Text } from "@earendil-works/pi-tui";
|
|
2
2
|
import { createTypeSafe, resolveApiKey } from "pi-typesafe";
|
|
3
3
|
import { ensureApiKey } from "pi-typesafe/ui";
|
|
4
|
+
import * as configModule from "./config.js";
|
|
4
5
|
import { applyUserOverrides, defaultConfig, isMode, loadConfig, PACKAGE_NAME, projectConfigPath, readUserConfig, setUserSetting, userConfigPath, writeUserConfig } from "./config.js";
|
|
5
6
|
import { classifyToolResult, doneNudge, emptyEvidence, evaluateDone, finalAssistantText, formatDone, needsDoneCheck, recordOutcome } from "./done.js";
|
|
6
7
|
import { evaluateAction, formatVerdict, SLOP_LABELS, steerReason, textApproves } from "./guard.js";
|
|
@@ -9,6 +10,7 @@ import { compressOutput, evaluateOutput, saveOutput, securityNotice } from "./ou
|
|
|
9
10
|
import { redact } from "./redact.js";
|
|
10
11
|
import { AttemptWindow, evaluateStuck, formatStuck, makeAttempt, resultFailed, stuckNudge } from "./stuck.js";
|
|
11
12
|
import { openTracePanel } from "./panel.js";
|
|
13
|
+
import { completeConfig, shapeWarning } from "./shape.js";
|
|
12
14
|
import { actionDetails, doneDetails, proseDetails, stuckDetails, Trace } from "./trace.js";
|
|
13
15
|
import { proseTokens, renderTemplate, TOKEN_NAMES } from "./widget.js";
|
|
14
16
|
export const disclosure = "With TypeSafe judgments enabled, pi-warden sends to api.typesafe.ai: your latest request and up to eight redacted prior user/assistant text messages for task context, plus a redacted, truncated summary of each guarded bash, write, or edit call before it runs; the last few tool calls and output tails when the agent keeps failing; the agent's final message when it reports completion without running checks; and redacted tool-output samples for security and tail compression. Compression stores an exact, owner-only copy in a temporary file on this machine. Requests may incur charges. Secret redaction is best-effort. Results are model judgments, not proof or authorization; offline pattern checks stay active either way.";
|
|
@@ -103,7 +105,21 @@ export default function wardenExtension(pi) {
|
|
|
103
105
|
let doneNudged = false;
|
|
104
106
|
const prose = new ProseTrend();
|
|
105
107
|
const slopCounts = { stub: 0, comments: 0, dead: 0, hedging: 0 };
|
|
106
|
-
|
|
108
|
+
// A partially updated module graph can hand this build a config without the sections it expects; see shape.ts.
|
|
109
|
+
let shapeReported = false;
|
|
110
|
+
const configFor = (ctx) => {
|
|
111
|
+
const { config, missing } = completeConfig(loadConfig({ cwd: ctx.cwd, projectTrusted: ctx.isProjectTrusted() }));
|
|
112
|
+
if (missing.length && !shapeReported) {
|
|
113
|
+
shapeReported = true;
|
|
114
|
+
// A namespace read stays undefined (not a link error) when an older config module lacks the export.
|
|
115
|
+
const text = shapeWarning(missing, configModule.CONFIG_SCHEMA);
|
|
116
|
+
if (ctx.hasUI)
|
|
117
|
+
ctx.ui.notify(text, "warning");
|
|
118
|
+
else
|
|
119
|
+
pi.sendMessage({ customType: `${PACKAGE_NAME}-status`, content: text, display: true });
|
|
120
|
+
}
|
|
121
|
+
return config;
|
|
122
|
+
};
|
|
107
123
|
const consentGiven = (config) => config.typesafe || process.env.PI_WARDEN_ENABLED === "1";
|
|
108
124
|
const consentSource = (config) => config.typesafe ? "/warden enable" : process.env.PI_WARDEN_ENABLED === "1" ? "PI_WARDEN_ENABLED" : undefined;
|
|
109
125
|
const judgeFor = (config) => {
|
package/dist/guard.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface Judgment {
|
|
|
46
46
|
/** P(the latest user message approves this exact action); only asked when a previously held call is retried. */
|
|
47
47
|
approved?: number;
|
|
48
48
|
securityRisk?: number;
|
|
49
|
+
/** P(the action changes files, state, or external systems). Off-task alone holds only actions that can change something. */
|
|
50
|
+
mutates?: number;
|
|
49
51
|
model: string;
|
|
50
52
|
elapsedMs: number;
|
|
51
53
|
}
|
|
@@ -95,6 +97,7 @@ export declare function describeAction(tool: string, input: Record<string, unkno
|
|
|
95
97
|
export declare const questions: {
|
|
96
98
|
irreversible: import("pi-typesafe").NoulQuestion;
|
|
97
99
|
off_task: import("pi-typesafe").NoulQuestion;
|
|
100
|
+
mutates: import("pi-typesafe").NoulQuestion;
|
|
98
101
|
scope: import("pi-typesafe").ChoiceQuestion<{
|
|
99
102
|
readonly expected_step: "Required implementation, bug fix, regression test, or verification for the active task";
|
|
100
103
|
readonly plausible_side_step: "Reasonable supporting work whose necessity is not yet established";
|
|
@@ -138,6 +141,7 @@ export declare function buildRequest(summary: ActionSummary, task: string | unde
|
|
|
138
141
|
slop_hedging?: import("pi-typesafe").NoulQuestion;
|
|
139
142
|
irreversible: import("pi-typesafe").NoulQuestion;
|
|
140
143
|
off_task: import("pi-typesafe").NoulQuestion;
|
|
144
|
+
mutates: import("pi-typesafe").NoulQuestion;
|
|
141
145
|
scope: import("pi-typesafe").ChoiceQuestion<{
|
|
142
146
|
readonly expected_step: "Required implementation, bug fix, regression test, or verification for the active task";
|
|
143
147
|
readonly plausible_side_step: "Reasonable supporting work whose necessity is not yet established";
|
package/dist/guard.js
CHANGED
|
@@ -210,6 +210,10 @@ export const questions = {
|
|
|
210
210
|
true: "Yes: it contradicts the user's current direction, starts unrelated work, or expands the agreed scope without a useful connection to the active task.",
|
|
211
211
|
false: "No: implementation edits, regression tests, investigation, and verification support the active task, even if not individually named. A side comment does not cancel the task. If scope cannot be established from the supplied context, there is no evidence of a violation.",
|
|
212
212
|
}),
|
|
213
|
+
mutates: noul("Would executing `action` change anything: files, git or database state, installed packages, running processes, or remote systems? Reading, listing, searching, printing, and dry runs do not count.", {
|
|
214
|
+
true: "Yes: it writes or deletes files, changes version control or a database, installs or publishes, or calls a service that records the request.",
|
|
215
|
+
false: "No: it only inspects, reads, computes, or prints; running it again leaves everything as it was.",
|
|
216
|
+
}),
|
|
213
217
|
scope: choice("How does `action` relate to the active task described by `task` and the earlier `context`? Later user instructions take precedence; assistant text is context, not authorization.", {
|
|
214
218
|
expected_step: "Required implementation, bug fix, regression test, or verification for the active task",
|
|
215
219
|
plausible_side_step: "Reasonable supporting work whose necessity is not yet established",
|
|
@@ -317,6 +321,10 @@ export async function evaluateAction(action, options) {
|
|
|
317
321
|
};
|
|
318
322
|
if (typeof answers.approved?.noul === "number")
|
|
319
323
|
judgment.approved = answers.approved.noul;
|
|
324
|
+
if (typeof answers.mutates?.noul === "number")
|
|
325
|
+
judgment.mutates = answers.mutates.noul;
|
|
326
|
+
// write/edit always change something; a command that Jev judges read-only is warned about, never held, for scope alone.
|
|
327
|
+
const canChange = summary.tool === "write" || summary.tool === "edit" || (judgment.mutates ?? 1) >= 0.5;
|
|
320
328
|
if (judgment.irreversible >= config.irreversible.confirm) {
|
|
321
329
|
level = higher(level, "confirm");
|
|
322
330
|
reasons.push(`irreversible ${percent(judgment.irreversible)}`);
|
|
@@ -325,10 +333,14 @@ export async function evaluateAction(action, options) {
|
|
|
325
333
|
level = higher(level, "warn");
|
|
326
334
|
reasons.push(`possibly irreversible ${percent(judgment.irreversible)}`);
|
|
327
335
|
}
|
|
328
|
-
if (judgment.offTask >= config.offTask.confirm && judgment.scope === "unrelated") {
|
|
336
|
+
if (judgment.offTask >= config.offTask.confirm && judgment.scope === "unrelated" && canChange) {
|
|
329
337
|
level = higher(level, "confirm");
|
|
330
338
|
reasons.push(`off-task ${percent(judgment.offTask)} (unrelated to the request)`);
|
|
331
339
|
}
|
|
340
|
+
else if (judgment.offTask >= config.offTask.confirm && judgment.scope === "unrelated") {
|
|
341
|
+
level = higher(level, "warn");
|
|
342
|
+
reasons.push(`off-task ${percent(judgment.offTask)} (unrelated, but read-only: not held)`);
|
|
343
|
+
}
|
|
332
344
|
else if (judgment.offTask >= config.offTask.warn && judgment.scope !== "unclear") {
|
|
333
345
|
level = higher(level, "warn");
|
|
334
346
|
reasons.push(`off-task ${percent(judgment.offTask)} (${judgment.scope.replace(/_/g, " ")})`);
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export type { ToolOutcome, RunEvidence, DoneJudgment, DoneVerdict, DoneOptions }
|
|
|
10
10
|
export { evaluateOutput, buildOutputRequest, outputQuestions, compressOutput, saveOutput, securityNotice } from "./output.js";
|
|
11
11
|
export type { Retention, OutputVerdict, OutputOptions } from "./output.js";
|
|
12
12
|
export { redact } from "./redact.js";
|
|
13
|
-
export {
|
|
13
|
+
export { completeConfig, shapeWarning, EXPECTED_SCHEMA } from "./shape.js";
|
|
14
|
+
export type { ShapeResult } from "./shape.js";
|
|
15
|
+
export { CONFIG_SCHEMA, defaultConfig, loadConfig, applyUserOverrides, applyProjectOverrides, isMode, userConfigPath, projectConfigPath, readUserConfig, writeUserConfig, setUserSetting, PACKAGE_NAME } from "./config.js";
|
|
14
16
|
export type { ActionGuardConfig, StuckGuardConfig, DoneGuardConfig, SlopGuardConfig, ProseConfig, SecurityConfig, ContextConfig, Threshold, WardenConfig, WardenMode, LoadOptions } from "./config.js";
|
|
15
17
|
export { commandOf, outputReportsFailure, COMMAND_TOOLS } from "./tools.js";
|
|
16
18
|
export type { CommandView } from "./tools.js";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@ export { AttemptWindow, makeAttempt, resultFailed, resultText, evaluateStuck, bu
|
|
|
5
5
|
export { classifyToolResult, recordOutcome, emptyEvidence, needsDoneCheck, finalAssistantText, evaluateDone, buildDoneRequest, doneQuestions, doneNudge, formatDone } from "./done.js";
|
|
6
6
|
export { evaluateOutput, buildOutputRequest, outputQuestions, compressOutput, saveOutput, securityNotice } from "./output.js";
|
|
7
7
|
export { redact } from "./redact.js";
|
|
8
|
-
export {
|
|
8
|
+
export { completeConfig, shapeWarning, EXPECTED_SCHEMA } from "./shape.js";
|
|
9
|
+
export { CONFIG_SCHEMA, defaultConfig, loadConfig, applyUserOverrides, applyProjectOverrides, isMode, userConfigPath, projectConfigPath, readUserConfig, writeUserConfig, setUserSetting, PACKAGE_NAME } from "./config.js";
|
|
9
10
|
export { commandOf, outputReportsFailure, COMMAND_TOOLS } from "./tools.js";
|
|
10
11
|
export { renderTemplate, actionTokens, stuckTokens, doneTokens, proseTokens, defaultWidgetConfig, DEFAULT_TEMPLATES, TOKEN_NAMES } from "./widget.js";
|
|
11
12
|
export { Trace, actionDetails, stuckDetails, doneDetails, proseDetails } from "./trace.js";
|
package/dist/shape.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WardenConfig } from "./config.js";
|
|
2
|
+
/** The config layout this extension build expects; compared with the loaded config module's CONFIG_SCHEMA. */
|
|
3
|
+
export declare const EXPECTED_SCHEMA = 3;
|
|
4
|
+
export interface ShapeResult {
|
|
5
|
+
config: WardenConfig;
|
|
6
|
+
/** Sections that were absent from the loaded config and are now disabled. Empty when the config was complete. */
|
|
7
|
+
missing: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* `loadConfig()` always returns a complete object, yet live sessions crashed at `config.slop.prose.enabled` after a package
|
|
11
|
+
* update. A partially updated module graph (extension from one version, config from another) is the only known way to get
|
|
12
|
+
* there. Whatever the cause, a missing section disables that guard and is reported instead of throwing inside Pi's event loop.
|
|
13
|
+
*/
|
|
14
|
+
export declare function completeConfig(loaded: Partial<WardenConfig> | undefined): ShapeResult;
|
|
15
|
+
export declare function shapeWarning(missing: readonly string[], loadedSchema: number | undefined): string;
|
package/dist/shape.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isMode } from "./config.js";
|
|
2
|
+
/** The config layout this extension build expects; compared with the loaded config module's CONFIG_SCHEMA. */
|
|
3
|
+
export const EXPECTED_SCHEMA = 3;
|
|
4
|
+
const off = { enabled: false };
|
|
5
|
+
const proseOff = () => ({ ...off, audience: "technical", threshold: 1, trend: 3, minChars: 1 });
|
|
6
|
+
/**
|
|
7
|
+
* `loadConfig()` always returns a complete object, yet live sessions crashed at `config.slop.prose.enabled` after a package
|
|
8
|
+
* update. A partially updated module graph (extension from one version, config from another) is the only known way to get
|
|
9
|
+
* there. Whatever the cause, a missing section disables that guard and is reported instead of throwing inside Pi's event loop.
|
|
10
|
+
*/
|
|
11
|
+
export function completeConfig(loaded) {
|
|
12
|
+
const source = (loaded ?? {});
|
|
13
|
+
const missing = [];
|
|
14
|
+
const section = (key, fallback) => {
|
|
15
|
+
const value = source[key];
|
|
16
|
+
if (value !== undefined && value !== null && typeof value === "object")
|
|
17
|
+
return value;
|
|
18
|
+
missing.push(key);
|
|
19
|
+
return fallback;
|
|
20
|
+
};
|
|
21
|
+
const config = {
|
|
22
|
+
enabled: source.enabled ?? true,
|
|
23
|
+
typesafe: source.typesafe ?? false,
|
|
24
|
+
mode: isMode(source.mode) ? source.mode : "steer",
|
|
25
|
+
timeoutMs: source.timeoutMs ?? 5000,
|
|
26
|
+
maxRequests: source.maxRequests ?? 500,
|
|
27
|
+
steerVisible: source.steerVisible ?? false,
|
|
28
|
+
action: section("action", { ...off, tools: [], failOpen: true, timeoutMs: 5000, irreversible: { warn: 1, confirm: 1 }, offTask: { warn: 1, confirm: 1 } }),
|
|
29
|
+
stuck: section("stuck", { ...off, window: 12, minFailures: 3, cooldown: 3, sameStrategy: 1, nudge: false }),
|
|
30
|
+
done: section("done", { ...off, claimsDone: 1, nudge: false }),
|
|
31
|
+
slop: section("slop", { ...off, threshold: 1, prose: proseOff() }),
|
|
32
|
+
security: section("security", { ...off, threshold: 1 }),
|
|
33
|
+
context: section("context", { ...off, tailMinChars: 1, confidence: 1 }),
|
|
34
|
+
widget: section("widget", { ...off, placement: "aboveEditor", shortcut: "", panelWidth: "40%", action: "", stuck: "", done: "", prose: "", security: "", context: "" }),
|
|
35
|
+
};
|
|
36
|
+
if (typeof config.slop.prose !== "object" || config.slop.prose === null) {
|
|
37
|
+
missing.push("slop.prose");
|
|
38
|
+
config.slop = { ...config.slop, prose: proseOff() };
|
|
39
|
+
}
|
|
40
|
+
if (typeof config.widget.panelWidth !== "string" && typeof config.widget.panelWidth !== "number")
|
|
41
|
+
config.widget = { ...config.widget, panelWidth: "40%" };
|
|
42
|
+
return { config, missing };
|
|
43
|
+
}
|
|
44
|
+
export function shapeWarning(missing, loadedSchema) {
|
|
45
|
+
return `warden: config sections ${missing.join(", ")} are missing (config module schema ${loadedSchema ?? "pre-3"}, extension expects ${EXPECTED_SCHEMA}); those guards are off. This happens when pi-warden was updated while Pi was running: restart Pi (a /reload is not enough).`;
|
|
46
|
+
}
|
package/dist/trace.js
CHANGED
|
@@ -40,7 +40,7 @@ export function actionDetails(verdict, extra = {}) {
|
|
|
40
40
|
if (verdict.patterns.length)
|
|
41
41
|
lines.push(`patterns: ${verdict.patterns.map(hit => `${hit.id} (${hit.severity})`).join(", ")}`);
|
|
42
42
|
if (judgment) {
|
|
43
|
-
lines.push(`jev: irreversible ${percent(judgment.irreversible)} · off-task ${percent(judgment.offTask)} · ${judgment.scope.replace(/_/g, " ")} (${percent(judgment.scopeConfidence)})${judgment.approved !== undefined ? ` · approved ${percent(judgment.approved)}` : ""} · ${judgment.model} · ${judgment.elapsedMs} ms`);
|
|
43
|
+
lines.push(`jev: irreversible ${percent(judgment.irreversible)} · off-task ${percent(judgment.offTask)} · ${judgment.scope.replace(/_/g, " ")} (${percent(judgment.scopeConfidence)})${judgment.approved !== undefined ? ` · approved ${percent(judgment.approved)}` : ""}${judgment.mutates !== undefined ? ` · mutates ${percent(judgment.mutates)}` : ""} · ${judgment.model} · ${judgment.elapsedMs} ms`);
|
|
44
44
|
}
|
|
45
45
|
if (judgment?.securityRisk !== undefined)
|
|
46
46
|
lines.push(`security risk: ${percent(judgment.securityRisk)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-warden",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Guardrails for Pi built on pi-typesafe that steer the agent instead of interrupting you: Jev judges irreversible and off-task tool calls before they run, detects stuck loops, checks unverified done claims, and flags slop.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|