@iceinvein/agent-skills 0.24.0 → 0.26.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.
- package/README.md +4 -3
- package/dist/cli/index.js +775 -236
- package/package.json +2 -1
- package/skills/index.json +2 -2
- package/skills/magpie/README.md +14 -0
- package/skills/magpie/SKILL.md +42 -23
- package/skills/magpie/bin/magpie.ts +91 -3
- package/skills/magpie/evals/README.md +1 -1
- package/skills/magpie/evals/post-folds-selection-events/fixture.sh +35 -0
- package/skills/magpie/evals/post-folds-selection-events/graders/selection-read-from-magpie-view.md +6 -0
- package/skills/magpie/evals/post-folds-selection-events/prompt.md +2 -2
- package/skills/magpie/evals/rules.json +2 -2
- package/skills/magpie/package.json +1 -1
- package/skills/magpie/references/critic.md +2 -2
- package/skills/magpie/references/peer-review.md +7 -7
- package/skills/magpie/references/proof.md +2 -2
- package/skills/magpie/scripts/__tests__/helper.test.ts +300 -0
- package/skills/magpie/scripts/__tests__/labels.test.ts +46 -1
- package/skills/magpie/scripts/__tests__/mark-cmd.test.ts +129 -0
- package/skills/magpie/scripts/__tests__/peer-run.test.ts +231 -0
- package/skills/magpie/scripts/__tests__/post-cmd.test.ts +298 -1
- package/skills/magpie/scripts/__tests__/preflight.test.ts +22 -1
- package/skills/magpie/scripts/__tests__/render-cmd.test.ts +15 -1
- package/skills/magpie/scripts/__tests__/render-findings.test.ts +13 -0
- package/skills/magpie/scripts/__tests__/server.test.ts +96 -1
- package/skills/magpie/scripts/__tests__/setup-cmd.test.ts +14 -0
- package/skills/magpie/scripts/__tests__/skill-lint.test.ts +68 -4
- package/skills/magpie/scripts/__tests__/view-cmd.test.ts +219 -0
- package/skills/magpie/scripts/helper.js +44 -4
- package/skills/magpie/scripts/labels.ts +11 -0
- package/skills/magpie/scripts/mark-cmd.ts +56 -0
- package/skills/magpie/scripts/peer-run.ts +146 -0
- package/skills/magpie/scripts/post-cmd.ts +75 -5
- package/skills/magpie/scripts/preflight.ts +20 -20
- package/skills/magpie/scripts/render-cmd.ts +3 -1
- package/skills/magpie/scripts/render-findings.ts +3 -1
- package/skills/magpie/scripts/server.ts +31 -2
- package/skills/magpie/scripts/setup-cmd.ts +7 -1
- package/skills/magpie/scripts/view-cmd.ts +143 -0
- package/skills/magpie/skill.json +1 -1
- package/skills/sluice/SKILL.md +21 -6
- package/skills/sluice/references/deep-channel.md +35 -25
- package/skills/sluice/references/finish.md +2 -2
- package/skills/sluice/references/intent.md +1 -1
- package/skills/sluice/references/status.md +10 -4
- package/skills/sluice/references/test-first.md +12 -0
- package/skills/sluice/scripts/board-index.sh +59 -37
- package/skills/sluice/scripts/board.sh +72 -40
- package/skills/sluice/scripts/host.sh +60 -0
- package/skills/sluice/scripts/run-stats.sh +41 -3
- package/skills/sluice/scripts/session-start.sh +75 -17
- package/skills/sluice/scripts/status.sh +9 -5
- package/skills/sluice/scripts/stop-guard.sh +101 -37
- package/skills/sluice/scripts/transcript.sh +221 -0
- package/skills/sluice/skill.json +1 -1
|
@@ -183,7 +183,7 @@ partner can settle, one whose answer changes the design's shape (where state
|
|
|
183
183
|
lives, what shares it, which process owns it) rather than a value the design can
|
|
184
184
|
leave as config, ask it as one question with your recommendation before the
|
|
185
185
|
design is written, and write the design on the answer. Ask it with
|
|
186
|
-
|
|
186
|
+
the question tool where there is one, which returns the answer without ending
|
|
187
187
|
the turn; without one, the question is a stop of its own, and the design is
|
|
188
188
|
written, to its file, on the next turn. A design drafted across both branches of
|
|
189
189
|
a fork doubles the reading and still has to be rewritten. Anything you can
|
|
@@ -219,7 +219,7 @@ Ask for three things, each cited by path:
|
|
|
219
219
|
3. **Stated constraints.** Repo instructions, CI gates, the test runner and its
|
|
220
220
|
conventions, and release steps that the design or its plan will answer to.
|
|
221
221
|
|
|
222
|
-
Dispatch it
|
|
222
|
+
Dispatch it to the explorer, a read-only subagent, where the harness has one, for the
|
|
223
223
|
reason the reviewer is dispatched: the file dumps fill its context instead of
|
|
224
224
|
yours, and you only need what it concluded. Where there is no dispatch, it is
|
|
225
225
|
your own read, with the same three questions. Either way the findings go into
|
|
@@ -244,7 +244,7 @@ The spec has a fixed shape, because the intent check reads it by section:
|
|
|
244
244
|
```
|
|
245
245
|
|
|
246
246
|
`## Intent` holds the request quoted verbatim, each question asked through
|
|
247
|
-
|
|
247
|
+
the question tool with the answer it got, and a table mapping each ask to the
|
|
248
248
|
`D<n>` decisions that deliver it, or to `## Out of scope` with the reason.
|
|
249
249
|
Decisions are headed `### D<n>. <title>`, which is what `plan.sh validate`
|
|
250
250
|
reads. Out of scope is its own section and never a numbered decision, because
|
|
@@ -348,7 +348,7 @@ review: your own read is weaker, and your partner should know it was yours.
|
|
|
348
348
|
## Pre-flight
|
|
349
349
|
|
|
350
350
|
Design signed off, plan written, nothing built yet. Before Task 1, stop once
|
|
351
|
-
and settle three things with your partner. Ask them with
|
|
351
|
+
and settle three things with your partner. Ask them with the question tool,
|
|
352
352
|
one question per decision, your recommendation as the first option and the
|
|
353
353
|
counts in the option text: what you are after is a decision, and a wall of
|
|
354
354
|
considerations asks them to extract the decision from it first. A lettered
|
|
@@ -386,7 +386,9 @@ ratification rather than a fresh judgment, and it carries the count: six of
|
|
|
386
386
|
nine at low effort and three at this session's, take it, put everything at the
|
|
387
387
|
session's effort, or name the exceptions. The count is what your partner
|
|
388
388
|
prices. "I will use low effort where it fits" prices nothing, and it also
|
|
389
|
-
arrives after the tokens are spent.
|
|
389
|
+
arrives after the tokens are spent. On a host with no low-effort dispatch
|
|
390
|
+
(the `## Hosts` table in SKILL.md), the count says so: the marked tasks run
|
|
391
|
+
at the session's effort there.
|
|
390
392
|
|
|
391
393
|
**Workspace, commits and concurrency.** One worktree for the plan, one per
|
|
392
394
|
concurrent implementer, or straight onto the current branch; and with it who
|
|
@@ -402,7 +404,9 @@ your partner needs in front of them. Implementing onto main or master needs
|
|
|
402
404
|
their say-so and this is where you get it. Known friction in a worktree for this
|
|
403
405
|
repo, a lint target that resolves through a symlink, a build that needs its own
|
|
404
406
|
install, belongs in the option text where it can affect the answer, not in a
|
|
405
|
-
footnote after they have chosen.
|
|
407
|
+
footnote after they have chosen. Where a sandbox refuses `git worktree add`
|
|
408
|
+
(Codex under `workspace-write`, Antigravity's terminal sandbox), say so in the
|
|
409
|
+
question and make working in the main tree the option.
|
|
406
410
|
|
|
407
411
|
That question settles where the implementers run, not whether a task may be
|
|
408
412
|
dispatched at all, and the shared-tree and current-branch options have to say
|
|
@@ -419,9 +423,12 @@ down to a single question is still a stop.
|
|
|
419
423
|
|
|
420
424
|
**Write the answers down before Task 1's first edit, in the tree the work runs
|
|
421
425
|
in.** The order on the instruction that follows the stop: cut the worktree
|
|
422
|
-
first, when that was the answer,
|
|
423
|
-
|
|
424
|
-
|
|
426
|
+
first, when that was the answer, as the Worktree row of the `## Hosts` table in
|
|
427
|
+
SKILL.md says. Where that is the harness's own worktree tool, it puts this
|
|
428
|
+
session inside it; where it is `git worktree add`, the session stays where it
|
|
429
|
+
was, so work from that path. Either way everything below is issued from the
|
|
430
|
+
worktree, and issued from the main tree instead it lands in the tree the work
|
|
431
|
+
is not in. A fresh
|
|
425
432
|
worktree branches from the remote's default branch, so nothing uncommitted or
|
|
426
433
|
unpushed in the main tree comes across, and `docs/` may not exist there yet.
|
|
427
434
|
Move the design and plan into it yourself, each into its own directory since
|
|
@@ -545,12 +552,13 @@ reads the run state rather than the plan: it sees what has actually landed.
|
|
|
545
552
|
in one tree contend on the git index and on `HEAD` even when their files
|
|
546
553
|
never meet. One worktree per concurrent implementer, or run them serially.
|
|
547
554
|
Those worktrees cost something, which is why pre-flight asks rather than
|
|
548
|
-
assumes. Where
|
|
549
|
-
one yourself, `git worktree add -b <plan-branch>-t<n>
|
|
550
|
-
|
|
555
|
+
assumes. Where dispatching a subagent refuses its own worktree isolation, cut
|
|
556
|
+
each one yourself, `git worktree add -b <plan-branch>-t<n>
|
|
557
|
+
<worktree dir>/<topic>-t<n> <plan-branch>`, name the path in that task's
|
|
551
558
|
brief as the only tree it works in, and merge each branch back once its task
|
|
552
|
-
lands. Keep them
|
|
553
|
-
|
|
559
|
+
lands. Keep them in the host's worktree directory in the repo (the
|
|
560
|
+
`## Hosts` table in SKILL.md), or under `.sluice/worktrees/` where the host
|
|
561
|
+
has none: permissions scoped to the project cover that path, and a
|
|
554
562
|
sibling directory outside it can leave the implementer's Write and Edit
|
|
555
563
|
denied. A refused isolation flag has not
|
|
556
564
|
taken the worktree away, only the tool's way of cutting it, so falling back
|
|
@@ -566,12 +574,14 @@ reads the run state rather than the plan: it sees what has actually landed.
|
|
|
566
574
|
- **The flip runs alone.** Nothing goes concurrent with the task carrying
|
|
567
575
|
`Flips`. The invariant it establishes is what later tasks are checked
|
|
568
576
|
against, and whatever landed beside it was checked against nothing.
|
|
569
|
-
- Isolate the workspace before a multi-task plan
|
|
570
|
-
|
|
577
|
+
- Isolate the workspace before a multi-task plan, as the Worktree row of the
|
|
578
|
+
`## Hosts` table in SKILL.md says. Where the host has a worktree tool, use
|
|
579
|
+
it, not `git worktree` yourself. That tool moves this session into the
|
|
571
580
|
worktree, which `git worktree add` does not: cut by hand, the files are
|
|
572
581
|
isolated and the session is still in the tree they came from, so every bare
|
|
573
582
|
`git`, build and test command you run lands in the wrong one. Enter it by
|
|
574
|
-
path if it already exists.
|
|
583
|
+
path if it already exists. Where it is `git worktree add`, work from that
|
|
584
|
+
path: run every command there, since nothing moves the session for you. Isolating through the harness's tool puts this
|
|
575
585
|
session in worktree mode, which by the cap above makes concurrent
|
|
576
586
|
implementers serial for the whole run, so pre-flight's workspace question
|
|
577
587
|
says so in the option text. Implementing straight onto main or
|
|
@@ -592,12 +602,13 @@ reads the run state rather than the plan: it sees what has actually landed.
|
|
|
592
602
|
- **The plan and pre-flight decide the effort, not the moment of dispatch.** A
|
|
593
603
|
task with no `Effort` line goes out on this session's model and effort, and a
|
|
594
604
|
downshift that was neither marked nor ratified is a saving your partner never
|
|
595
|
-
agreed to. A task ratified at `Effort: low` goes out
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
`
|
|
599
|
-
|
|
600
|
-
|
|
605
|
+
agreed to. A task ratified at `Effort: low` goes out on the
|
|
606
|
+
low-effort row of the `## Hosts` table in SKILL.md. On Claude Code that is
|
|
607
|
+
`sluice-implementer-low`, the agent sluice installs with `effort: low` and
|
|
608
|
+
`model: inherit`, because a Claude dispatch takes a model and no effort, so
|
|
609
|
+
an agent definition is the one place its effort can be set. On Codex the
|
|
610
|
+
dispatch carries the effort itself, and on Antigravity the task runs at the
|
|
611
|
+
session's effort. Reviewers are the
|
|
601
612
|
other half of that rule: a review never runs below the effort that built the
|
|
602
613
|
task, so the review of an `Effort: low` task goes out on this session's
|
|
603
614
|
effort and never on the low agent.
|
|
@@ -698,8 +709,7 @@ something stronger would be promising what is already in use. What a tier buys
|
|
|
698
709
|
is a dispatch. The one effort rule that holds across all of them is that a
|
|
699
710
|
review never runs below the effort that built the task, so tiers 1 and 2 over
|
|
700
711
|
an `Effort: low` task go out at this session's effort rather than on
|
|
701
|
-
|
|
702
|
-
plugin install).
|
|
712
|
+
the low-effort row of `## Hosts`.
|
|
703
713
|
|
|
704
714
|
**Where the repo carries review tiering of its own, this table governs.** It is
|
|
705
715
|
the more specific of the two: wired into `Flips`, the `Effort` marks and the
|
|
@@ -23,7 +23,7 @@ Confirm the base branch instead of assuming it; untangling a wrong merge
|
|
|
23
23
|
costs far more than asking would have.
|
|
24
24
|
|
|
25
25
|
With the suite green and the base confirmed, put exactly three options to
|
|
26
|
-
your partner through
|
|
26
|
+
your partner through the question tool, with the run ledger in the message
|
|
27
27
|
above them so the choice is made against
|
|
28
28
|
what the work actually cost rather than against your account of it;
|
|
29
29
|
`references/meter.md` owns that. Say in one clause whether the work was
|
|
@@ -59,7 +59,7 @@ the one list of them. In order:
|
|
|
59
59
|
controller stat read plus the final whole-plan pass rather than a per-task
|
|
60
60
|
dispatch" is the accurate line, and it is a coverage level rather than a
|
|
61
61
|
debt. Where nothing was priced, it is a debt and says so.
|
|
62
|
-
5. The three options, asked through
|
|
62
|
+
5. The three options, asked through the question tool, and nothing after them.
|
|
63
63
|
|
|
64
64
|
A `deep` run closes when the work stops being yours to act on: after a local
|
|
65
65
|
merge and its re-run of the suite, or when your partner leaves the branch where
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agree intent
|
|
2
2
|
|
|
3
|
-
Ask one question at a time, through
|
|
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
|
|
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
|
|
@@ -503,7 +507,9 @@ combine with `--watch`.
|
|
|
503
507
|
|
|
504
508
|
It reads an index of pointers, never copies, at `$SLUICE_BOARD_DIR`, else
|
|
505
509
|
`$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.
|
|
510
|
+
of the three set nothing is written and the board is empty. The root is the
|
|
511
|
+
same on every host: Codex and Antigravity sessions set no `CLAUDE_CONFIG_DIR`,
|
|
512
|
+
so theirs is `$HOME/.claude/sluice/board`, one board for the machine. `runs/` holds one
|
|
507
513
|
file per tree with a live run, naming the tree, and `sessions/<id>.json` one
|
|
508
514
|
per routed session. `run.json` stays the single authority on a run, so the
|
|
509
515
|
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
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
10
|
-
#
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
+
}
|
|
@@ -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,
|
|
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="$
|
|
44
|
+
sid="$(sluice_session)"
|
|
38
45
|
if [ -z "$sid" ]; then
|
|
39
|
-
echo "run-stats: no --transcript given and
|
|
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
|