Skip to content

feat(agent-isolation): add sandbox-status-line-rich.sh — opt-in richer status line - #29

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:feat/sandbox-status-line-rich
May 1, 2026
Merged

feat(agent-isolation): add sandbox-status-line-rich.sh — opt-in richer status line#29
potiuk merged 1 commit into
apache:mainfrom
potiuk:feat/sandbox-status-line-rich

Conversation

@potiuk

@potiuk potiuk commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Add tools/agent-isolation/sandbox-status-line-rich.sh as a sibling
    to the minimal sandbox-status-line.sh. Same sandbox-state
    detection, plus opt-in extras: hash-coloured folder name, git
    branch + dirty + ahead/behind, per-branch PR title (cached, gated
    by gh), and yellow [sandbox-auto] for
    sandbox.autoAllowBashIfSandboxed.
  • Existing minimal script unchanged. The secure-agent-setup.md
    paragraph about composing your own statusLine grows a sentence
    pointing at the new file as an out-of-the-box alternative.
  • tools/agent-isolation/README.md table grows one row for the new
    file.

Why a sibling, not a replacement

The minimal script's "obvious at a glance" design is intentional, and
the existing secure-agent-setup.md paragraph explicitly suggests
adopters with custom statuslines compose the minimal helper into
their own renderer. A sibling preserves that contract while making
the richer composition easy to copy for adopters who want it without
writing one from scratch.

Notes

  • Uses python3 (universally available) for JSON parsing, so the
    new file does not introduce a jq dependency beyond what the
    minimal sibling already needs. Open to converting to jq for
    consistency if preferred.
  • Includes a portable stat chain (GNU -c %Y first, BSD -f %m
    fallback). The obvious "BSD first" ordering breaks on Linux:
    GNU stat -f is interpreted as "filesystem mode" and emits
    multi-line stdout that pollutes the next arithmetic line under
    set -u.
  • gh pr view is wrapped in a portable timeout (with a
    perl -e 'alarm' fallback) so a hung gh call cannot stall every
    status-line render.

Test plan

  • set -u clean on Linux for both code paths (cache hit and
    cache miss).
  • Smoke test in a sandboxed repo prints
    [sandbox] <folder> | <branch>... | <model>; PR segment
    elided when gh unauthenticated.
  • Re-test on macOS (BSD stat -c falls through to -f %m).
  • prek run --files <changed files> clean (markdownlint, typos,
    placeholder linter, doctoc).

…r status line

Adds a sibling to the minimal `sandbox-status-line.sh`. Same
sandbox-state detection (green `[sandbox]` / bold-red `[NO SANDBOX]`),
plus opt-in segments useful when running multiple Claude Code
sessions across worktrees and repos:

- Folder name colour-coded by a stable hash of its basename (each
  repo / worktree keeps the same colour across sessions). Inside a
  Claude Code worktree (`<source>/.claude/worktrees/<name>`) renders
  `<source>/<worktree>` with each segment hash-coloured independently.
- Git branch + dirty marker + ahead/behind, all local-only (no
  network). `-uno` skips untracked-file scan to keep render time
  bounded.
- PR title from `gh pr view`, cached per repo+branch (5 min on
  success, 60 s on miss). Silent when `gh` is missing,
  unauthenticated, or the branch has no PR. Wrapped in a portable
  timeout (with a `perl -e 'alarm'` fallback for systems where
  neither `timeout` nor `gtimeout` is installed) so a hung gh call
  cannot stall every status-line render.
- Yellow `[sandbox-auto]` distinguishes
  `sandbox.autoAllowBashIfSandboxed: true` from plain `[sandbox]` —
  that flag widens the in-sandbox bash blast radius and is worth
  surfacing distinctly.

Includes a portable `stat` chain (GNU `-c %Y` first, BSD `-f %m`
fallback). The obvious "BSD first" ordering breaks on Linux: GNU
`stat -f` is interpreted as "filesystem mode" and emits multi-line
stdout that pollutes the next arithmetic line under `set -u`.

The minimal `sandbox-status-line.sh` remains the documented default
per `secure-agent-setup.md`. The rich variant is opt-in: copy the
`-rich` file in place of the minimal one and point
`statusLine.command` at it.

`secure-agent-setup.md` and `tools/agent-isolation/README.md` get
short pointers to the new file.

Generated-by: Claude Code (Opus 4.7)
@potiuk
potiuk merged commit f0b1cde into apache:main May 1, 2026
6 checks passed
@andreahlert andreahlert added the mode:platform Substrate / infra — not a mode (sandbox, CI, validators) label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mode:platform Substrate / infra — not a mode (sandbox, CI, validators)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants