@oisin-ee/pi-guardrails 0.40.0 → 0.42.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.
@@ -178,13 +178,7 @@ export const IMPERATIVE_MSG = {
178
178
  // The job shows gh's live run view in its tab, and its exit tells the agent the result.
179
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
180
  "with Dogsled `run`.";
181
- export const WAIT_MSG = "wait-gate: blocked a command that waits instead of working (sleep, watch, a follow flag, a --watch or --wait " +
182
- "flag, or a wait subcommand). Never hold a tool call to wait, and never re-read a log to check progress. " +
183
- "For long work in pi, use Dogsled `run` (mcp__dogsled__run) and continue other work. " +
184
- "Use `read` (mcp__dogsled__read) for output and `stop` (mcp__dogsled__stop) to cancel the job. " +
185
- "Start long work so the host reports its exit: in Claude Code, `run_in_background` " +
186
- "or Monitor (the exit arrives as a message); in Codex, exec_command, then empty write_stdin calls, which " +
187
- `return when the process exits. ${CI_WAIT_ADVICE}`;
181
+ export const WAIT_MSG = `wait-gate: blocked a command that waits instead of working. For long work, use \`mcp__dogsled__run\` for the job and \`mcp__dogsled__read\` for its output. ${CI_WAIT_ADVICE}`;
188
182
  const GH_VALUE_OPTIONS = new Set(["-R", "--repo", "--hostname"]), FOLLOW_FLAGS = new Set(["-f", "-F", "--follow", "--retry"]), LOG_STREAMERS = new Set([
189
183
  "kubectl",
190
184
  "docker",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oisin-ee/pi-guardrails",
3
- "version": "0.40.0",
3
+ "version": "0.42.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,12 @@ import {
8
8
  canonicalToolName,
9
9
  commandsFromToolInput,
10
10
  } from "./tool-inputs.ts";
11
- import { codeWaitViolation, enforceTimeout, toolWaitViolation } from "./tool-timeouts.ts";
11
+ import {
12
+ MAX_TIMEOUT_SECONDS,
13
+ codeWaitViolation,
14
+ enforceTimeout,
15
+ toolWaitViolation,
16
+ } from "./tool-timeouts.ts";
12
17
  import { classifyEdits, editInputsFromPayload } from "../policies/edit.ts";
13
18
  import { SHELL_CLASSIFIERS } from "../policies/shell.ts";
14
19
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
@@ -25,6 +30,7 @@ interface ToolCall {
25
30
 
26
31
  // A codemode script's nested calls nest at most this deep before the gate stops looking.
27
32
  const MAX_NESTING = 8,
33
+ BASH_TIMEOUT_GUIDELINE = `The bash timeout limit is ${MAX_TIMEOUT_SECONDS} s. Use mcp__dogsled__run for longer work.`,
28
34
  /**
29
35
  * The block message of the first shell policy that refuses one of `commands`.
30
36
  * @param {readonly Command[]} commands The commands a tool call runs.
@@ -102,6 +108,10 @@ const MAX_NESTING = 8,
102
108
  * @param {GuardrailsAPI} pi The extension API methods used here.
103
109
  */
104
110
  export default function piGuardrails(pi: GuardrailsAPI): void {
111
+ pi.on("before_agent_start", ({ systemPromptOptions }) => {
112
+ const { toolGuidelines } = systemPromptOptions;
113
+ toolGuidelines["bash"] = [...(toolGuidelines["bash"] ?? []), BASH_TIMEOUT_GUIDELINE];
114
+ });
105
115
  pi.on("tool_call", (event, ctx) => {
106
116
  try {
107
117
  const message = toolViolation(event, ctx.cwd);
@@ -231,14 +231,7 @@ export const CI_WAIT_ADVICE =
231
231
  "For CI, get the run ID from ci_find, then start `gh run watch <run-id> --exit-status` in the repository " +
232
232
  "with Dogsled `run`.";
233
233
 
234
- export const WAIT_MSG =
235
- "wait-gate: blocked a command that waits instead of working (sleep, watch, a follow flag, a --watch or --wait " +
236
- "flag, or a wait subcommand). Never hold a tool call to wait, and never re-read a log to check progress. " +
237
- "For long work in pi, use Dogsled `run` (mcp__dogsled__run) and continue other work. " +
238
- "Use `read` (mcp__dogsled__read) for output and `stop` (mcp__dogsled__stop) to cancel the job. " +
239
- "Start long work so the host reports its exit: in Claude Code, `run_in_background` " +
240
- "or Monitor (the exit arrives as a message); in Codex, exec_command, then empty write_stdin calls, which " +
241
- `return when the process exits. ${CI_WAIT_ADVICE}`;
234
+ export const WAIT_MSG = `wait-gate: blocked a command that waits instead of working. For long work, use \`mcp__dogsled__run\` for the job and \`mcp__dogsled__read\` for its output. ${CI_WAIT_ADVICE}`;
242
235
 
243
236
  const GH_VALUE_OPTIONS: ReadonlySet<string> = new Set(["-R", "--repo", "--hostname"]),
244
237
  FOLLOW_FLAGS: ReadonlySet<string> = new Set(["-f", "-F", "--follow", "--retry"]),