@oisin-ee/pi-guardrails 0.38.0 → 0.40.0

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.
@@ -175,14 +175,16 @@ export const IMPERATIVE_MSG = {
175
175
  "execution/install path to mutate infra by hand; use repo-pinned tooling or declarative config. " +
176
176
  "nix eval/flake show/path-info/store ls are allowed.",
177
177
  };
178
+ // The job shows gh's live run view in its tab, and its exit tells the agent the result.
179
+ export const CI_WAIT_ADVICE = "For CI, get the run ID from ci_find, then start `gh run watch <run-id> --exit-status` in the repository " +
180
+ "with Dogsled `run`.";
178
181
  export const WAIT_MSG = "wait-gate: blocked a command that waits instead of working (sleep, watch, a follow flag, a --watch or --wait " +
179
182
  "flag, or a wait subcommand). Never hold a tool call to wait, and never re-read a log to check progress. " +
180
183
  "For long work in pi, use Dogsled `run` (mcp__dogsled__run) and continue other work. " +
181
184
  "Use `read` (mcp__dogsled__read) for output and `stop` (mcp__dogsled__stop) to cancel the job. " +
182
185
  "Start long work so the host reports its exit: in Claude Code, `run_in_background` " +
183
186
  "or Monitor (the exit arrives as a message); in Codex, exec_command, then empty write_stdin calls, which " +
184
- "return when the process exits. " +
185
- "For CI, use ci_find and ci_watch.";
187
+ `return when the process exits. ${CI_WAIT_ADVICE}`;
186
188
  const GH_VALUE_OPTIONS = new Set(["-R", "--repo", "--hostname"]), FOLLOW_FLAGS = new Set(["-f", "-F", "--follow", "--retry"]), LOG_STREAMERS = new Set([
187
189
  "kubectl",
188
190
  "docker",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oisin-ee/pi-guardrails",
3
- "version": "0.38.0",
3
+ "version": "0.40.0",
4
4
  "description": "Agent guardrails for pi, Claude Code, and Codex: Git safety, no waiting, no typing into other agents, GitOps-only clusters.",
5
5
  "keywords": [
6
6
  "claude-code",
package/src/pi/index.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  canonicalToolName,
9
9
  commandsFromToolInput,
10
10
  } from "./tool-inputs.ts";
11
- import { codeWaitViolation, enforceTimeout } from "./tool-timeouts.ts";
11
+ import { codeWaitViolation, enforceTimeout, toolWaitViolation } from "./tool-timeouts.ts";
12
12
  import { classifyEdits, editInputsFromPayload } from "../policies/edit.ts";
13
13
  import { SHELL_CLASSIFIERS } from "../policies/shell.ts";
14
14
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
@@ -81,6 +81,7 @@ const MAX_NESTING = 8,
81
81
  own =
82
82
  enforceTimeout(call.toolName, call.input) ??
83
83
  codeWaitViolation(call.toolName, call.input) ??
84
+ toolWaitViolation(call.toolName) ??
84
85
  (SHELL_TOOL_NAMES.has(call.toolName) ? shellViolation(call, cwd) : null) ??
85
86
  (EDIT_TOOL_NAMES.has(call.toolName) ? editViolation(call, cwd) : null);
86
87
  if (own !== null) {
@@ -1,3 +1,5 @@
1
+ import { CI_WAIT_ADVICE } from "../policies/shell.ts";
2
+
1
3
  // Shell-like tools have no default timeout, so an omitted or oversized value can hold a session for hours.
2
4
  // Each entry names the argument and its unit, because the tools disagree: pi's bash takes seconds, the
3
5
  // Others take milliseconds.
@@ -46,6 +48,15 @@ export function codeWaitViolation(
46
48
  : null;
47
49
  }
48
50
 
51
+ // Tools whose whole job is to hold the call while they poll. Pi settings cannot hide one tool of a package.
52
+ const WAITING_TOOLS: ReadonlySet<string> = new Set(["ci_watch"]);
53
+
54
+ export function toolWaitViolation(toolName: string): string | null {
55
+ return WAITING_TOOLS.has(toolName)
56
+ ? `wait-gate: blocked ${toolName}, which holds the tool call while it polls. ${CI_WAIT_ADVICE}`
57
+ : null;
58
+ }
59
+
49
60
  export const MAX_TIMEOUT_SECONDS = 600;
50
61
  export const DEFAULT_TIMEOUT_SECONDS = 120;
51
62
 
@@ -63,8 +74,7 @@ function limitMessage(
63
74
  `timeout-gate: blocked ${toolName} ${field}=${value}. The ${field} unit is ${unit === "s" ? "seconds" : "milliseconds"} ` +
64
75
  `and the limit is ${max} (${MAX_TIMEOUT_SECONDS / 60} minutes).${unitHint} ` +
65
76
  "For a longer job, start it with Dogsled `run` (mcp__dogsled__run) and continue other work. " +
66
- "Use `read` (mcp__dogsled__read) for output and `stop` (mcp__dogsled__stop) to cancel the job. " +
67
- "For CI, use the ci_find and ci_watch tools."
77
+ `Use \`read\` (mcp__dogsled__read) for output and \`stop\` (mcp__dogsled__stop) to cancel the job. ${CI_WAIT_ADVICE}`
68
78
  );
69
79
  }
70
80
 
@@ -226,6 +226,11 @@ export const IMPERATIVE_MSG = {
226
226
  "nix eval/flake show/path-info/store ls are allowed.",
227
227
  };
228
228
 
229
+ // The job shows gh's live run view in its tab, and its exit tells the agent the result.
230
+ export const CI_WAIT_ADVICE =
231
+ "For CI, get the run ID from ci_find, then start `gh run watch <run-id> --exit-status` in the repository " +
232
+ "with Dogsled `run`.";
233
+
229
234
  export const WAIT_MSG =
230
235
  "wait-gate: blocked a command that waits instead of working (sleep, watch, a follow flag, a --watch or --wait " +
231
236
  "flag, or a wait subcommand). Never hold a tool call to wait, and never re-read a log to check progress. " +
@@ -233,8 +238,7 @@ export const WAIT_MSG =
233
238
  "Use `read` (mcp__dogsled__read) for output and `stop` (mcp__dogsled__stop) to cancel the job. " +
234
239
  "Start long work so the host reports its exit: in Claude Code, `run_in_background` " +
235
240
  "or Monitor (the exit arrives as a message); in Codex, exec_command, then empty write_stdin calls, which " +
236
- "return when the process exits. " +
237
- "For CI, use ci_find and ci_watch.";
241
+ `return when the process exits. ${CI_WAIT_ADVICE}`;
238
242
 
239
243
  const GH_VALUE_OPTIONS: ReadonlySet<string> = new Set(["-R", "--repo", "--hostname"]),
240
244
  FOLLOW_FLAGS: ReadonlySet<string> = new Set(["-f", "-F", "--follow", "--retry"]),