@iceinvein/agent-skills 0.25.0 → 0.27.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.
Files changed (44) hide show
  1. package/README.md +14 -5
  2. package/dist/cli/index.js +913 -239
  3. package/package.json +2 -1
  4. package/skills/index.json +4 -4
  5. package/skills/magpie/README.md +24 -6
  6. package/skills/magpie/SKILL.md +35 -18
  7. package/skills/magpie/bin/magpie.ts +28 -0
  8. package/skills/magpie/package.json +1 -1
  9. package/skills/magpie/references/critic.md +2 -2
  10. package/skills/magpie/references/peer-review.md +7 -7
  11. package/skills/magpie/references/proof.md +2 -2
  12. package/skills/magpie/scripts/__tests__/peer-run.test.ts +231 -0
  13. package/skills/magpie/scripts/__tests__/preflight.test.ts +22 -1
  14. package/skills/magpie/scripts/__tests__/setup-cmd.test.ts +14 -0
  15. package/skills/magpie/scripts/__tests__/skill-lint.test.ts +45 -4
  16. package/skills/magpie/scripts/peer-run.ts +146 -0
  17. package/skills/magpie/scripts/preflight.ts +20 -20
  18. package/skills/magpie/scripts/setup-cmd.ts +7 -1
  19. package/skills/magpie/skill.json +21 -3
  20. package/skills/sluice/SKILL.md +24 -7
  21. package/skills/sluice/evals/README.md +4 -3
  22. package/skills/sluice/evals/deep-run-mirrors-the-task-list/case.yaml +4 -0
  23. package/skills/sluice/evals/deep-run-mirrors-the-task-list/fixture.sh +304 -0
  24. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/every-task-done.md +7 -0
  25. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/sluice-fired.md +5 -0
  26. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/task-list-completed.md +7 -0
  27. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/task-list-created.md +8 -0
  28. package/skills/sluice/evals/deep-run-mirrors-the-task-list/prompt.md +13 -0
  29. package/skills/sluice/evals/rules.json +9 -0
  30. package/skills/sluice/references/deep-channel.md +52 -25
  31. package/skills/sluice/references/finish.md +2 -2
  32. package/skills/sluice/references/intent.md +1 -1
  33. package/skills/sluice/references/status.md +18 -7
  34. package/skills/sluice/references/test-first.md +12 -0
  35. package/skills/sluice/scripts/board-index.sh +59 -37
  36. package/skills/sluice/scripts/board.sh +72 -40
  37. package/skills/sluice/scripts/host.sh +60 -0
  38. package/skills/sluice/scripts/postinstall.sh +3 -3
  39. package/skills/sluice/scripts/run-stats.sh +41 -3
  40. package/skills/sluice/scripts/session-start.sh +75 -17
  41. package/skills/sluice/scripts/status.sh +9 -5
  42. package/skills/sluice/scripts/stop-guard.sh +101 -37
  43. package/skills/sluice/scripts/transcript.sh +221 -0
  44. package/skills/sluice/skill.json +28 -4
@@ -1,6 +1,6 @@
1
1
  # Agree intent
2
2
 
3
- Ask one question at a time, through `AskUserQuestion` where the harness has
3
+ Ask one question at a time, through the question tool where the harness has
4
4
  it, with the options as choices and your recommendation first. Prose is the
5
5
  fallback for a harness without the tool or an answer set that is genuinely
6
6
  open, not the default.
@@ -412,9 +412,13 @@ if [ -n "$sluice_line" ]; then printf '%s\n' "$sluice_line"; fi
412
412
  `$cwd` is `workspace.current_dir` and `$session_id` is `session_id`, both from
413
413
  the JSON the harness sends on stdin. The id is what finds a run this session
414
414
  opened in a worktree it never entered, which is every run in a repo that cuts
415
- its worktrees by hand. Substitute the install path:
416
- `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` where a session may set one, or
417
- `$cwd/.claude/skills/sluice/scripts/statusline.sh` for a project-local install.
415
+ its worktrees by hand. Substitute the install path for the host: on Claude
416
+ Code `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` where a session may set one, or
417
+ `$cwd/.claude/skills/sluice/scripts/statusline.sh` for a project-local
418
+ install; on Antigravity `$HOME/.gemini/config/skills/sluice/scripts/statusline.sh`,
419
+ or `$cwd/.agents/skills/sluice/scripts/statusline.sh` for a project install,
420
+ wired through `statusLine.command` in `~/.gemini/antigravity-cli/settings.json`.
421
+ Codex draws no command status line, so there is nothing to wire there.
418
422
 
419
423
  Those two lines are the whole contract, and they are deliberately empty of
420
424
  judgement. Whether a run is visible from a given directory is a question about
@@ -458,10 +462,15 @@ case. `%s` rather than `%b`: the render already carries real escape bytes, and
458
462
  2/9 done · !T6 model tiers rather than model names +1 · ⟲ 1 unreviewed
459
463
  ```
460
464
 
461
- On a machine with no status line at all there is nothing to paste into, so the
462
- install claims the empty `statusLine` slot and points it at
465
+ On a machine with no status line at all there is nothing to paste into, so an
466
+ install given `--statusline` claims the empty `statusLine` slot and points it at
463
467
  `scripts/statusline-command.sh`, a complete command that reads the harness JSON
464
- on stdin and draws the run and nothing else. A slot already holding someone
468
+ on stdin and draws the run and nothing else. Without the flag the slot is never
469
+ touched: the bar is the one setting everyone sees on every keystroke, so it is
470
+ asked for rather than assumed. The choice is kept in the lockfile, so an update
471
+ re-wires it unasked, and a slot an install claimed before the flag existed counts
472
+ as asked for. An install given `--no-statusline` gives the slot back and
473
+ clears the choice, so later updates leave it empty. A slot already holding someone
465
474
  else's command is never touched, on install or on removal, and the one the
466
475
  install claimed is given back when the skill is removed, including on the
467
476
  removal path that has no manifest to read.
@@ -503,7 +512,9 @@ combine with `--watch`.
503
512
 
504
513
  It reads an index of pointers, never copies, at `$SLUICE_BOARD_DIR`, else
505
514
  `$CLAUDE_CONFIG_DIR/sluice/board`, else `$HOME/.claude/sluice/board`; with none
506
- of the three set nothing is written and the board is empty. `runs/` holds one
515
+ of the three set nothing is written and the board is empty. The root is the
516
+ same on every host: Codex and Antigravity sessions set no `CLAUDE_CONFIG_DIR`,
517
+ so theirs is `$HOME/.claude/sluice/board`, one board for the machine. `runs/` holds one
507
518
  file per tree with a live run, naming the tree, and `sessions/<id>.json` one
508
519
  per routed session. `run.json` stays the single authority on a run, so the
509
520
  board can never show a stale copy of one. `SLUICE_BOARD_DIR` exists so the
@@ -51,6 +51,18 @@ function it calls. Keep helpers that exist only for tests inside the test
51
51
  files. If a production class grows a method whose only caller is a test
52
52
  reaching inside it, the test has started reshaping your design.
53
53
 
54
+ **Search the existing tests before writing a new one.** If one already pins
55
+ this behaviour on this input partition, extend it or add a row to its table
56
+ rather than starting a test beside it. Inputs the code does not branch on are
57
+ one test: a missing field and an empty one that decode to the same value take
58
+ the same path, and a second test for them catches nothing the first does not.
59
+
60
+ **Test a rule where it lives.** When a shared check owns the rule (a scoped
61
+ read, a middleware, a policy), its full table of cases belongs once, beside
62
+ that check. A new caller owes one refused case and one allowed case, enough to
63
+ show it is wired to the check. Running the owner's table again through every
64
+ caller adds tests that fail together and find no bug the owner's table misses.
65
+
54
66
  **A test goes when the behaviour it pinned is gone.** Delete it alongside the
55
67
  code, in the same commit, like anything else the change orphaned. Two tests
56
68
  pinning one behaviour are a test and a maintenance bill, so keep the clearer.
@@ -9,9 +9,12 @@
9
9
  # board-index.sh handback <id> [--keep-deep]
10
10
  # board-index.sh prune
11
11
  #
12
- # The root is $SLUICE_BOARD_DIR, else $CLAUDE_CONFIG_DIR/sluice/board, else
13
- # $HOME/.claude/sluice/board. With none of the three set there is nowhere safe
14
- # to write, so every verb exits 0 having written nothing. Runs live at
12
+ # Entries are written under $SLUICE_BOARD_DIR, else under the board of the host
13
+ # this runs in (host.sh's sluice_state_root, plus /board), with Claude's board
14
+ # standing in outside any host, where every entry went before there were others.
15
+ # prune sweeps every host's board. A board whose root would be built from an
16
+ # empty HOME is nowhere safe to write, so with no root at all every verb exits 0
17
+ # having written nothing. Runs live at
15
18
  # <root>/runs/<key>, one line naming the tree, where <key> is the tree with %
16
19
  # encoded as %25 and / as %2F. Sessions live at <root>/sessions/<id>.json.
17
20
  #
@@ -22,6 +25,8 @@
22
25
 
23
26
  set -u
24
27
 
28
+ source "$(dirname "$0")/host.sh"
29
+
25
30
  err() { echo "board-index.sh: $*" >&2; }
26
31
 
27
32
  usage() {
@@ -65,14 +70,29 @@ case "$verb" in
65
70
  *) usage ;;
66
71
  esac
67
72
 
73
+ # A root built from an empty HOME would sit at the filesystem root, so a host
74
+ # counts only when HOME, or the variable it reads in place of HOME, is set.
75
+ anchored() { # <host>
76
+ case "$1" in
77
+ claude) [ -n "${CLAUDE_CONFIG_DIR:-}" ] || [ -n "${HOME:-}" ] ;;
78
+ codex) [ -n "${CODEX_HOME:-}" ] || [ -n "${HOME:-}" ] ;;
79
+ *) [ -n "${HOME:-}" ] ;;
80
+ esac
81
+ }
82
+
68
83
  if [ -n "${SLUICE_BOARD_DIR:-}" ]; then
69
84
  ROOT="$SLUICE_BOARD_DIR"
70
- elif [ -n "${CLAUDE_CONFIG_DIR:-}" ]; then
71
- ROOT="$CLAUDE_CONFIG_DIR/sluice/board"
72
- elif [ -n "${HOME:-}" ]; then
73
- ROOT="$HOME/.claude/sluice/board"
85
+ ROOTS=("$ROOT")
74
86
  else
75
- exit 0
87
+ host="$(sluice_host)"
88
+ [ "$host" != unknown ] || host=claude
89
+ anchored "$host" || exit 0
90
+ ROOT="$(sluice_state_root "$host")" || exit 4
91
+ ROOT="$ROOT/board"
92
+ ROOTS=()
93
+ for h in claude codex antigravity; do
94
+ anchored "$h" && ROOTS+=("$(sluice_state_root "$h")/board")
95
+ done
76
96
  fi
77
97
 
78
98
  case "$verb" in
@@ -125,35 +145,37 @@ case "$verb" in
125
145
  ;;
126
146
  prune)
127
147
  need_jq
128
- # The builtin read rather than a process per pointer, because prune runs
129
- # on every init and route and pointers pile up; read whole, so a tree
130
- # path holding a newline still names its tree. read -d '' stops at EOF
131
- # with a non-zero status, so a failed open is told from a short read by
132
- # whether the file is readable; a pointer that cannot be read is kept.
133
- for f in "$ROOT"/runs/*; do
134
- [ -f "$f" ] || continue
135
- tree=""
136
- { IFS= read -r -d '' tree; } 2>/dev/null <"$f" || [ -n "$tree" ] || [ -r "$f" ] || continue
137
- tree="${tree%$'\n'}"
138
- [ -f "$tree/.sluice/run.json" ] || rm -f "$f"
139
- done
140
- # One jq for every session rather than one each, because prune runs on
141
- # every route and a jq per file made each route slower than the last day
142
- # of sessions. Contents go on stdin as NUL-separated name and contents
143
- # records, as board.sh feeds them, so no count of files meets the argv
144
- # limit. Anything unreadable or unparseable comes back to be removed.
145
- for f in "$ROOT"/sessions/*.json; do
146
- [ -f "$f" ] || continue
147
- entry=""
148
- { IFS= read -r -d '' entry; } 2>/dev/null <"$f"
149
- printf '%s\0%s\0' "$f" "$entry"
150
- done | jq -R -s -j '
151
- (split("\u0000") | .[:-1]) as $p
152
- | range(0; $p | length; 2)
153
- | select(($p[. + 1] | try (fromjson | (now - (.updated | fromdateiso8601)) <= 86400) catch false) != true)
154
- | $p[.] + "\u0000"
155
- ' 2>/dev/null | while IFS= read -r -d '' f; do
156
- rm -f "$f"
148
+ for root in "${ROOTS[@]}"; do
149
+ # The builtin read rather than a process per pointer, because prune runs
150
+ # on every init and route and pointers pile up; read whole, so a tree
151
+ # path holding a newline still names its tree. read -d '' stops at EOF
152
+ # with a non-zero status, so a failed open is told from a short read by
153
+ # whether the file is readable; a pointer that cannot be read is kept.
154
+ for f in "$root"/runs/*; do
155
+ [ -f "$f" ] || continue
156
+ tree=""
157
+ { IFS= read -r -d '' tree; } 2>/dev/null <"$f" || [ -n "$tree" ] || [ -r "$f" ] || continue
158
+ tree="${tree%$'\n'}"
159
+ [ -f "$tree/.sluice/run.json" ] || rm -f "$f"
160
+ done
161
+ # One jq for every session rather than one each, because prune runs on
162
+ # every route and a jq per file made each route slower than the last day
163
+ # of sessions. Contents go on stdin as NUL-separated name and contents
164
+ # records, as board.sh feeds them, so no count of files meets the argv
165
+ # limit. Anything unreadable or unparseable comes back to be removed.
166
+ for f in "$root"/sessions/*.json; do
167
+ [ -f "$f" ] || continue
168
+ entry=""
169
+ { IFS= read -r -d '' entry; } 2>/dev/null <"$f"
170
+ printf '%s\0%s\0' "$f" "$entry"
171
+ done | jq -R -s -j '
172
+ (split("\u0000") | .[:-1]) as $p
173
+ | range(0; $p | length; 2)
174
+ | select(($p[. + 1] | try (fromjson | (now - (.updated | fromdateiso8601)) <= 86400) catch false) != true)
175
+ | $p[.] + "\u0000"
176
+ ' 2>/dev/null | while IFS= read -r -d '' f; do
177
+ rm -f "$f"
178
+ done
157
179
  done
158
180
  ;;
159
181
  esac
@@ -6,13 +6,17 @@
6
6
  #
7
7
  # --json prints the combined state instead of drawing it. --watch redraws every
8
8
  # <seconds> (default 2) until interrupted. The index is read, never written.
9
- # The root is $SLUICE_BOARD_DIR, else $CLAUDE_CONFIG_DIR/sluice/board, else
10
- # $HOME/.claude/sluice/board; with none of the three set the index is empty.
9
+ # The index is read from $SLUICE_BOARD_DIR, else from every host's board
10
+ # (host.sh's sluice_board_roots), so runs and sessions from Claude, Codex and
11
+ # Antigravity share one board. A host whose board would be built from an empty
12
+ # HOME is left out, and with none left the index is empty.
11
13
  #
12
14
  # Exit: 0 ok, 4 bad arguments, 5 jq missing, 6 the board could not be read.
13
15
 
14
16
  set -u
15
17
 
18
+ source "$(dirname "$0")/host.sh"
19
+
16
20
  err() { echo "board.sh: $*" >&2; }
17
21
 
18
22
  usage() {
@@ -52,14 +56,25 @@ fi
52
56
 
53
57
  command -v jq >/dev/null 2>&1 || { err "jq is required"; exit 5; }
54
58
 
55
- if [ -n "${SLUICE_BOARD_DIR:-}" ]; then
56
- ROOT="$SLUICE_BOARD_DIR"
57
- elif [ -n "${CLAUDE_CONFIG_DIR:-}" ]; then
58
- ROOT="$CLAUDE_CONFIG_DIR/sluice/board"
59
- elif [ -n "${HOME:-}" ]; then
60
- ROOT="$HOME/.claude/sluice/board"
59
+ # A root built from an empty HOME would sit at the filesystem root, so a host
60
+ # counts only when HOME, or the variable it reads in place of HOME, is set.
61
+ anchored() { # <host>
62
+ case "$1" in
63
+ claude) [ -n "${CLAUDE_CONFIG_DIR:-}" ] || [ -n "${HOME:-}" ] ;;
64
+ codex) [ -n "${CODEX_HOME:-}" ] || [ -n "${HOME:-}" ] ;;
65
+ *) [ -n "${HOME:-}" ] ;;
66
+ esac
67
+ }
68
+
69
+ ROOTS=()
70
+ if [ -n "${SLUICE_BOARD_DIR:-}" ] || [ -n "${HOME:-}" ]; then
71
+ while IFS= read -r root; do
72
+ ROOTS+=("$root")
73
+ done < <(sluice_board_roots)
61
74
  else
62
- ROOT=""
75
+ for h in claude codex antigravity; do
76
+ anchored "$h" && ROOTS+=("$(sluice_state_root "$h")/board")
77
+ done
63
78
  fi
64
79
 
65
80
  ESC="$(printf '\033')"
@@ -77,50 +92,67 @@ paint() { # <sgr> <text>
77
92
  fi
78
93
  }
79
94
 
95
+ # Two hosts can resolve to one directory (CODEX_HOME set to Claude's config
96
+ # dir, say), and reading it twice would list each of its sessions twice. A root
97
+ # not created yet has no real path, and is kept as written.
98
+ UNIQUE=()
99
+ REALS=()
100
+ for root in "${ROOTS[@]+"${ROOTS[@]}"}"; do
101
+ real="$(cd "$root" 2>/dev/null && pwd -P)" || real="$root"
102
+ seen=0
103
+ for r in "${REALS[@]+"${REALS[@]}"}"; do
104
+ [ "$r" = "$real" ] && seen=1
105
+ done
106
+ [ "$seen" = 1 ] && continue
107
+ REALS+=("$real")
108
+ UNIQUE+=("$root")
109
+ done
110
+ ROOTS=("${UNIQUE[@]+"${UNIQUE[@]}"}")
111
+
80
112
  # The board polls for hours while runs close and sessions are pruned under it,
81
113
  # so each file is read into a variable first and skipped when that read fails,
82
114
  # and jq gets contents rather than paths that may be gone by the time it opens
83
115
  # them. The read is the builtin, so a frame spawns no process per file. TREES
84
116
  # keeps each run's path by index, so a path holding a newline or a tab reaches
85
117
  # status.sh whole rather than through a line-split read. KEYS and VALUES are
86
- # the records emit hands jq. Returns 1 when the root, runs/ or sessions/
118
+ # the records emit hands jq. Returns 1 when any root, runs/ or sessions/
87
119
  # exists but cannot be listed: one not yet created is empty, since nothing has
88
120
  # been written there, but one that cannot be read would draw as nothing running
89
121
  # when it may hold every run on the machine.
90
122
  gather() {
91
- local n=0 f tree run entry d
123
+ local n=0 m=0 f tree run entry d root
92
124
  TREES=()
93
125
  KEYS=()
94
126
  VALUES=()
95
- [ -n "$ROOT" ] || return 0
96
- for d in "$ROOT" "$ROOT/runs" "$ROOT/sessions"; do
97
- if [ -e "$d" ] || [ -L "$d" ]; then
98
- [ -d "$d" ] && [ -r "$d" ] && [ -x "$d" ] || return 1
99
- fi
100
- done
101
- for f in "$ROOT"/runs/*; do
102
- [ -f "$f" ] || continue
103
- # read -d '' stops at EOF with a non-zero status, so a short read is told
104
- # from a failed open by whether anything arrived.
105
- tree=""
106
- { IFS= read -r -d '' tree || [ -n "$tree" ]; } 2>/dev/null <"$f" || continue
107
- tree="${tree%$'\n'}"
108
- [ -n "$tree" ] || continue
109
- run=""
110
- { IFS= read -r -d '' run || [ -n "$run" ]; } 2>/dev/null <"$tree/.sluice/run.json" || continue
111
- TREES[$n]="$tree"
112
- KEYS+=("t$n" "r$n")
113
- VALUES+=("$tree" "$run")
114
- n=$((n + 1))
115
- done
116
- n=0
117
- for f in "$ROOT"/sessions/*.json; do
118
- [ -f "$f" ] || continue
119
- entry=""
120
- { IFS= read -r -d '' entry || [ -n "$entry" ]; } 2>/dev/null <"$f" || continue
121
- KEYS+=("s$n")
122
- VALUES+=("$entry")
123
- n=$((n + 1))
127
+ for root in "${ROOTS[@]+"${ROOTS[@]}"}"; do
128
+ for d in "$root" "$root/runs" "$root/sessions"; do
129
+ if [ -e "$d" ] || [ -L "$d" ]; then
130
+ [ -d "$d" ] && [ -r "$d" ] && [ -x "$d" ] || return 1
131
+ fi
132
+ done
133
+ for f in "$root"/runs/*; do
134
+ [ -f "$f" ] || continue
135
+ # read -d '' stops at EOF with a non-zero status, so a short read is told
136
+ # from a failed open by whether anything arrived.
137
+ tree=""
138
+ { IFS= read -r -d '' tree || [ -n "$tree" ]; } 2>/dev/null <"$f" || continue
139
+ tree="${tree%$'\n'}"
140
+ [ -n "$tree" ] || continue
141
+ run=""
142
+ { IFS= read -r -d '' run || [ -n "$run" ]; } 2>/dev/null <"$tree/.sluice/run.json" || continue
143
+ TREES[$n]="$tree"
144
+ KEYS+=("t$n" "r$n")
145
+ VALUES+=("$tree" "$run")
146
+ n=$((n + 1))
147
+ done
148
+ for f in "$root"/sessions/*.json; do
149
+ [ -f "$f" ] || continue
150
+ entry=""
151
+ { IFS= read -r -d '' entry || [ -n "$entry" ]; } 2>/dev/null <"$f" || continue
152
+ KEYS+=("s$m")
153
+ VALUES+=("$entry")
154
+ m=$((m + 1))
155
+ done
124
156
  done
125
157
  }
126
158
 
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+ # sluice host: which agent host this shell runs under, its session id, and
3
+ # where that host keeps sluice's state. Sourced, never run:
4
+ #
5
+ # source host.sh
6
+ # sluice_host claude | codex | antigravity | unknown
7
+ # sluice_session the host's session id, empty for unknown
8
+ # sluice_state_root <host> the host's sluice state directory
9
+ # sluice_board_roots every board root, one per line
10
+ #
11
+ # $SLUICE_HOST overrides detection, for a hook whose host does not export its
12
+ # session variable. sluice_state_root exits 4 on a host it does not know, so
13
+ # call it in a subshell. No set options here: a sourced file would change
14
+ # them for its caller, and every caller sets its own.
15
+
16
+ sluice_host() {
17
+ if [ -n "${SLUICE_HOST:-}" ]; then
18
+ echo "$SLUICE_HOST"
19
+ elif [ -n "${CLAUDE_CODE_SESSION_ID:-}" ]; then
20
+ echo claude
21
+ elif [ -n "${CODEX_THREAD_ID:-}" ]; then
22
+ echo codex
23
+ elif [ -n "${ANTIGRAVITY_CONVERSATION_ID:-}" ]; then
24
+ echo antigravity
25
+ else
26
+ echo unknown
27
+ fi
28
+ }
29
+
30
+ sluice_session() {
31
+ case "$(sluice_host)" in
32
+ claude) echo "${CLAUDE_CODE_SESSION_ID:-}" ;;
33
+ codex) echo "${CODEX_THREAD_ID:-}" ;;
34
+ antigravity) echo "${ANTIGRAVITY_CONVERSATION_ID:-}" ;;
35
+ *) echo "" ;;
36
+ esac
37
+ }
38
+
39
+ sluice_state_root() {
40
+ case "${1:-}" in
41
+ claude) echo "${CLAUDE_CONFIG_DIR:-${HOME:-}/.claude}/sluice" ;;
42
+ codex) echo "${CODEX_HOME:-${HOME:-}/.codex}/sluice" ;;
43
+ antigravity) echo "${HOME:-}/.gemini/sluice" ;;
44
+ *)
45
+ echo "host.sh: unknown host '${1:-}'" >&2
46
+ exit 4
47
+ ;;
48
+ esac
49
+ }
50
+
51
+ sluice_board_roots() {
52
+ if [ -n "${SLUICE_BOARD_DIR:-}" ]; then
53
+ echo "$SLUICE_BOARD_DIR"
54
+ return
55
+ fi
56
+ local host
57
+ for host in claude codex antigravity; do
58
+ echo "$(sluice_state_root "$host")/board"
59
+ done
60
+ }
@@ -24,9 +24,9 @@ RENDER="$BUNDLE/scripts/statusline.sh"
24
24
  command -v jq >/dev/null 2>&1 || exit 0
25
25
 
26
26
  # Nothing is said to someone with no statusline configured. Either the install
27
- # claimed the empty slot, in which case the branch below reports it, or this is
28
- # a session-mode install that wires nothing, in which case there is no file to
29
- # paste into and no instruction worth printing.
27
+ # was given --statusline and claimed the empty slot, in which case the branch
28
+ # below reports it, or nobody asked for one, and an install that repeated the
29
+ # offer on every update would be the notice nobody can switch off.
30
30
  CONFIGURED="$(jq -r '.statusLine.command // empty' "$SETTINGS" 2>/dev/null || true)"
31
31
  [ -n "$CONFIGURED" ] || exit 0
32
32
 
@@ -8,12 +8,18 @@
8
8
  # Usage: run-stats.sh [--tests "<what the suite reported>"] [--base <git-ref>]
9
9
  # [--transcript <path>]
10
10
  #
11
+ # With no --transcript the session is the host's own (host.sh). On Codex and
12
+ # Antigravity its transcript, and each dispatched agent's, is translated by
13
+ # transcript.sh into Claude's shape first. A --transcript is read as Claude's.
14
+ #
11
15
  # Exit 0 printed a ledger, 2 no run to report. Any other non-zero is the tool
12
16
  # failing rather than a fact about the run: no jq, no readable transcript, an
13
17
  # unknown argument, an unresolvable session id. Each prints its reason first.
14
18
 
15
19
  set -uo pipefail
16
20
 
21
+ source "$(dirname "$0")/host.sh"
22
+
17
23
  TESTS=""
18
24
  BASE=""
19
25
  TRANSCRIPT=""
@@ -23,7 +29,7 @@ while [ $# -gt 0 ]; do
23
29
  --tests) TESTS="${2-}"; shift 2 ;;
24
30
  --base) BASE="${2-}"; shift 2 ;;
25
31
  --transcript) TRANSCRIPT="${2-}"; shift 2 ;;
26
- -h|--help) sed -n '2,11p' "$0" | cut -c3-; exit 0 ;;
32
+ -h|--help) sed -n '2,15p' "$0" | cut -c3-; exit 0 ;;
27
33
  *) echo "run-stats: unknown argument '$1'" >&2; exit 1 ;;
28
34
  esac
29
35
  done
@@ -33,12 +39,44 @@ if ! command -v jq >/dev/null 2>&1; then
33
39
  exit 1
34
40
  fi
35
41
 
42
+ HOST="$(sluice_host)"
36
43
  if [ -z "$TRANSCRIPT" ]; then
37
- sid="${CLAUDE_CODE_SESSION_ID:-}"
44
+ sid="$(sluice_session)"
38
45
  if [ -z "$sid" ]; then
39
- echo "run-stats: no --transcript given and CLAUDE_CODE_SESSION_ID is unset" >&2
46
+ echo "run-stats: no --transcript given and the host gives no session id" >&2
40
47
  exit 1
41
48
  fi
49
+ fi
50
+
51
+ # Laid out as Claude lays a session out, <sid>.jsonl with its agents under
52
+ # <sid>/subagents/, so everything below reads one shape whatever the host.
53
+ if [ -z "$TRANSCRIPT" ] && [ "$HOST" != claude ]; then
54
+ # The id becomes a file name in the temp directory, so one that could climb
55
+ # out of it is refused rather than followed.
56
+ case "$sid" in
57
+ */* | .*) echo "run-stats: session id $sid is not a file name" >&2; exit 1 ;;
58
+ esac
59
+ TRANSLATE="$(dirname "$0")/transcript.sh"
60
+ source_path="$(bash "$TRANSLATE" --host "$HOST" --locate "$sid")" || exit 1
61
+ WORK="$(mktemp -d)" || { echo "run-stats: could not create a temp directory" >&2; exit 1; }
62
+ trap 'rm -rf "$WORK"' EXIT
63
+ # Bash skips the EXIT trap on a signal it has no trap for.
64
+ trap 'exit 130' INT
65
+ trap 'exit 143' TERM
66
+ TRANSCRIPT="$WORK/$sid.jsonl"
67
+ bash "$TRANSLATE" --host "$HOST" "$source_path" >"$TRANSCRIPT" || exit 1
68
+ agents="$(bash "$TRANSLATE" --host "$HOST" --agents "$source_path")" || exit 1
69
+ mkdir -p "$WORK/$sid/subagents" || { echo "run-stats: could not write under $WORK" >&2; exit 1; }
70
+ while IFS=$'\t' read -r id path; do
71
+ [ -n "$id" ] || continue
72
+ # An agent whose log does not translate stays in the ledger unpriced, which
73
+ # the row says, and the translator's reason is already on stderr.
74
+ bash "$TRANSLATE" --host "$HOST" "$path" >"$WORK/$sid/subagents/agent-$id.jsonl" ||
75
+ rm -f "$WORK/$sid/subagents/agent-$id.jsonl"
76
+ done <<<"$agents"
77
+ fi
78
+
79
+ if [ -z "$TRANSCRIPT" ]; then
42
80
  # The session id is unique across projects, so glob rather than guess the slug.
43
81
  # The harness writes under whichever config dir it was started with, so read
44
82
  # CLAUDE_CONFIG_DIR first and fall back to the default: a machine that has run
@@ -10,11 +10,44 @@
10
10
  # Reads the harness's session JSON on stdin for `cwd` and `source`, falling back
11
11
  # to $PWD when there is none. Always exits 0: a hook that fails is noise in a
12
12
  # session that has not started yet.
13
+ #
14
+ # Usage: session-start.sh [--host <claude|codex|antigravity>] [--directive <text>]
15
+ #
16
+ # The installer passes --host, because it knows which host's config it wrote
17
+ # the hook into. Every non-Claude install passes it and no Claude install ever
18
+ # has, so without it the host is Claude, whatever session variable leaks in.
19
+ # --directive is said ahead of the run, for a host that cannot run an `echo`
20
+ # of its own beside the hook.
13
21
 
14
22
  set -uo pipefail
15
23
 
16
24
  here="$(cd "$(dirname "$0")" && pwd)"
17
25
  STATUS="$here/status.sh"
26
+ source "$here/host.sh"
27
+
28
+ host=""
29
+ directive=""
30
+ while [ $# -gt 0 ]; do
31
+ case "$1" in
32
+ --host | --directive)
33
+ if [ $# -lt 2 ]; then
34
+ echo "session-start.sh: $1 needs a value" >&2
35
+ exit 0
36
+ fi
37
+ case "$1" in
38
+ --host) host="$2" ;;
39
+ --directive) directive="$2" ;;
40
+ esac
41
+ shift 2
42
+ ;;
43
+ *)
44
+ echo "session-start.sh: unknown argument '$1'" >&2
45
+ exit 0
46
+ ;;
47
+ esac
48
+ done
49
+ [ -n "$host" ] || host=claude
50
+ state_root="$(sluice_state_root "$host")" || exit 0
18
51
 
19
52
  # Bounded, and skipped on a terminal: the harness closes stdin after the JSON,
20
53
  # but a hook that inherits an open, silent stdin would otherwise never return,
@@ -32,6 +65,11 @@ fi
32
65
  cwd="$PWD"
33
66
  source=""
34
67
  sid=""
68
+ # Antigravity names the same fields its own way; renamed here so nothing below
69
+ # knows which host it is answering.
70
+ if [ "$host" = antigravity ] && [ -n "$input" ] && command -v jq >/dev/null 2>&1; then
71
+ input="$(printf '%s' "$input" | jq -c '{session_id: .conversationId, cwd: (.cwd // .workspacePaths[0]?), transcript_path: .transcriptPath}' 2>/dev/null)" || input=""
72
+ fi
35
73
  if [ -n "$input" ] && command -v jq >/dev/null 2>&1; then
36
74
  got="$(printf '%s' "$input" | jq -r '.cwd // empty' 2>/dev/null || true)"
37
75
  [ -n "$got" ] && cwd="$got"
@@ -56,7 +94,7 @@ stamp_baseline() {
56
94
  tree="$(git -C "$cwd" rev-parse --show-toplevel 2>/dev/null)" || return 0
57
95
  [ -n "$tree" ] || return 0
58
96
 
59
- local dir="${CLAUDE_CONFIG_DIR:-${HOME:-}/.claude}/sluice/stamps"
97
+ local dir="$state_root/stamps"
60
98
  mkdir -p "$dir" 2>/dev/null || return 0
61
99
 
62
100
  # This hook fires again on compact, resume and clear, all carrying the
@@ -130,26 +168,46 @@ stamp_baseline() {
130
168
  }
131
169
  stamp_baseline "$sid" "$source"
132
170
 
171
+ # Claude and Codex add plain stdout to the context; Antigravity adds only the
172
+ # steps it is handed as JSON. Each argument is one message, empty ones dropped.
173
+ say() {
174
+ local part parts=()
175
+ for part in "$@"; do
176
+ [ -n "$part" ] && parts+=("$part")
177
+ done
178
+ [ "${#parts[@]}" -gt 0 ] || return 0
179
+ case "$host" in
180
+ antigravity)
181
+ if ! command -v jq >/dev/null 2>&1; then
182
+ echo "session-start.sh: jq is required to answer antigravity" >&2
183
+ return 0
184
+ fi
185
+ jq -n '{injectSteps: [$ARGS.positional[] | {systemMessage: {systemMessage: .}}]}' --args "${parts[@]}"
186
+ ;;
187
+ *) printf '%s\n' "${parts[@]}" ;;
188
+ esac
189
+ }
190
+
133
191
  # No gate of its own beyond the directory existing: status.sh anchors on the
134
192
  # main worktree of whatever tree it is given, which is what lets a session
135
193
  # opened in a subdirectory or a linked worktree find the run, and on a tree
136
194
  # with no run it exits 2 in silence. Once per session start, that is cheap.
137
- [ -d "$cwd" ] || exit 0
138
- [ -f "$STATUS" ] || exit 0
195
+ report=""
196
+ if [ -d "$cwd" ] && [ -f "$STATUS" ] &&
197
+ shown="$(bash "$STATUS" show --dir "$cwd" ${sid:+--session "$sid"} 2>/dev/null)" && [ -n "$shown" ]; then
198
+ case "$source" in
199
+ compact | resume | clear)
200
+ advice="This session's context was summarised, resumed or cleared. Read the run record before the next dispatch and trust the two files over what you remember."
201
+ ;;
202
+ *)
203
+ advice="If this run is not the work you were asked to continue, it was left open: close it with status.sh close before starting another."
204
+ ;;
205
+ esac
206
+ report="A sluice run is live. Its state, from .sluice/run.json:
139
207
 
140
- shown="$(bash "$STATUS" show --dir "$cwd" ${sid:+--session "$sid"} 2>/dev/null)" || exit 0
141
- [ -n "$shown" ] || exit 0
208
+ $shown
142
209
 
143
- echo "A sluice run is live. Its state, from .sluice/run.json:"
144
- echo
145
- echo "$shown"
146
- echo
147
- case "$source" in
148
- compact | resume | clear)
149
- echo "This session's context was summarised, resumed or cleared. Read the run record before the next dispatch and trust the two files over what you remember."
150
- ;;
151
- *)
152
- echo "If this run is not the work you were asked to continue, it was left open: close it with status.sh close before starting another."
153
- ;;
154
- esac
210
+ $advice"
211
+ fi
212
+ say "$directive" "$report"
155
213
  exit 0