feat(agent-isolation): add sandbox-status-line-rich.sh — opt-in richer status line - #29
Merged
Merged
Conversation
…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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools/agent-isolation/sandbox-status-line-rich.shas a siblingto the minimal
sandbox-status-line.sh. Same sandbox-statedetection, 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]forsandbox.autoAllowBashIfSandboxed.secure-agent-setup.mdparagraph about composing your own statusLine grows a sentence
pointing at the new file as an out-of-the-box alternative.
tools/agent-isolation/README.mdtable grows one row for the newfile.
Why a sibling, not a replacement
The minimal script's "obvious at a glance" design is intentional, and
the existing
secure-agent-setup.mdparagraph explicitly suggestsadopters 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
python3(universally available) for JSON parsing, so thenew file does not introduce a
jqdependency beyond what theminimal sibling already needs. Open to converting to
jqforconsistency if preferred.
statchain (GNU-c %Yfirst, BSD-f %mfallback). The obvious "BSD first" ordering breaks on Linux:
GNU
stat -fis interpreted as "filesystem mode" and emitsmulti-line stdout that pollutes the next arithmetic line under
set -u.gh pr viewis wrapped in a portable timeout (with aperl -e 'alarm'fallback) so a hung gh call cannot stall everystatus-line render.
Test plan
set -uclean on Linux for both code paths (cache hit andcache miss).
[sandbox] <folder> | <branch>... | <model>; PR segmentelided when
ghunauthenticated.stat -cfalls through to-f %m).prek run --files <changed files>clean (markdownlint, typos,placeholder linter, doctoc).