@krysoworks/kryso 0.0.0-stage → 2.0.0-rc.1

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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +152 -2
  3. package/bin/kryso +31 -0
  4. package/bin/ship-it-status +14 -0
  5. package/bin/ship-ledger +14 -0
  6. package/bin/ship-loop +14 -0
  7. package/bin/ship-pass +14 -0
  8. package/bin/warden +14 -0
  9. package/dist/answer.d.ts +38 -0
  10. package/dist/answer.js +48 -0
  11. package/dist/bytes.d.ts +5 -0
  12. package/dist/bytes.js +35 -0
  13. package/dist/cleanup.d.ts +1 -0
  14. package/dist/cleanup.js +629 -0
  15. package/dist/commands.d.ts +48 -0
  16. package/dist/commands.js +293 -0
  17. package/dist/completions.d.ts +24 -0
  18. package/dist/completions.js +239 -0
  19. package/dist/daemon.d.ts +15 -0
  20. package/dist/daemon.js +23 -0
  21. package/dist/diagnose.d.ts +47 -0
  22. package/dist/diagnose.js +314 -0
  23. package/dist/doctor.d.ts +1 -0
  24. package/dist/doctor.js +241 -0
  25. package/dist/env.d.ts +9 -0
  26. package/dist/env.js +17 -0
  27. package/dist/evidence.d.ts +39 -0
  28. package/dist/evidence.js +327 -0
  29. package/dist/home.d.ts +3 -0
  30. package/dist/home.js +27 -0
  31. package/dist/install.d.ts +59 -0
  32. package/dist/install.js +137 -0
  33. package/dist/isolate.d.ts +28 -0
  34. package/dist/isolate.js +402 -0
  35. package/dist/leftovers.d.ts +5 -0
  36. package/dist/leftovers.js +156 -0
  37. package/dist/machine.d.ts +6 -0
  38. package/dist/machine.js +185 -0
  39. package/dist/palette.d.ts +147 -0
  40. package/dist/palette.js +167 -0
  41. package/dist/plan.d.ts +1 -0
  42. package/dist/plan.js +133 -0
  43. package/dist/proc.d.ts +23 -0
  44. package/dist/proc.js +23 -0
  45. package/dist/read.d.ts +1 -0
  46. package/dist/read.js +297 -0
  47. package/dist/readiness.d.ts +5 -0
  48. package/dist/readiness.js +64 -0
  49. package/dist/remote.d.ts +6 -0
  50. package/dist/remote.js +85 -0
  51. package/dist/self-update.d.ts +1 -0
  52. package/dist/self-update.js +224 -0
  53. package/dist/semver.d.ts +7 -0
  54. package/dist/semver.js +42 -0
  55. package/dist/style.d.ts +71 -0
  56. package/dist/style.js +187 -0
  57. package/dist/update.d.ts +47 -0
  58. package/dist/update.js +190 -0
  59. package/dist/work.d.ts +25 -0
  60. package/dist/work.js +449 -0
  61. package/dist/workflows.d.ts +4 -0
  62. package/dist/workflows.js +73 -0
  63. package/docker/entrypoint.sh +44 -0
  64. package/docker/runner.Dockerfile +39 -0
  65. package/package.json +65 -4
  66. package/scripts/install-skills.sh +607 -0
  67. package/skills/code-review/SKILL.md +231 -0
  68. package/skills/kryso/SKILL.md +107 -0
  69. package/skills/kryso/golden/help.rounded.ansi +23 -0
  70. package/skills/kryso/golden/help.square.ansi +23 -0
  71. package/skills/kryso/golden/help.txt +23 -0
  72. package/skills/kryso/golden/table-narrow.json +11 -0
  73. package/skills/kryso/golden/table-narrow.rounded.ansi +4 -0
  74. package/skills/kryso/golden/table-narrow.square.ansi +4 -0
  75. package/skills/kryso/golden/table.ansi +5 -0
  76. package/skills/kryso/golden/table.json +11 -0
  77. package/skills/kryso/ledger.sh +2146 -0
  78. package/skills/kryso/palette.json +57 -0
  79. package/skills/kryso/reference/resuming.md +30 -0
  80. package/skills/kryso/reference/routing.md +23 -0
  81. package/skills/kryso/reference/stage-1-claim.md +79 -0
  82. package/skills/kryso/reference/stage-2-build.md +133 -0
  83. package/skills/kryso/reference/stage-3-prove.md +51 -0
  84. package/skills/kryso/reference/stage-4-pr.md +76 -0
  85. package/skills/kryso/reference/stage-5-reconcile.md +81 -0
  86. package/skills/kryso/reference/stage-6-merge-or-park.md +73 -0
  87. package/skills/kryso/reference/stage-7-close-out.md +62 -0
  88. package/skills/kryso/reference/terminal.md +7 -0
  89. package/skills/kryso/ship-it-status.sh +1503 -0
  90. package/skills/kryso/ui.py +274 -0
  91. package/skills/kryso/ui.sh +609 -0
  92. package/skills/kryso-build/SKILL.md +168 -0
  93. package/skills/kryso-shift/SKILL.md +167 -0
  94. package/skills/kryso-shift/archive.py +2784 -0
  95. package/skills/kryso-shift/archive_checker.py +462 -0
  96. package/skills/kryso-shift/archive_checker_lambda.py +155 -0
  97. package/skills/kryso-shift/archive_health.py +364 -0
  98. package/skills/kryso-shift/archive_launchd.py +140 -0
  99. package/skills/kryso-shift/archive_remote.py +990 -0
  100. package/skills/kryso-shift/archiving-checker.md +140 -0
  101. package/skills/kryso-shift/archiving-keep.md +115 -0
  102. package/skills/kryso-shift/archiving-recovery.md +112 -0
  103. package/skills/kryso-shift/archiving-remote.md +166 -0
  104. package/skills/kryso-shift/archiving.md +146 -0
  105. package/skills/kryso-shift/coverage.schema.json +225 -0
  106. package/skills/kryso-shift/deadline.sh +254 -0
  107. package/skills/kryso-shift/feedback.schema.json +35 -0
  108. package/skills/kryso-shift/feedback.sh +228 -0
  109. package/skills/kryso-shift/history-manifest.schema.json +331 -0
  110. package/skills/kryso-shift/keep-after.sh +55 -0
  111. package/skills/kryso-shift/measure.sh +611 -0
  112. package/skills/kryso-shift/merge-ready.sh +207 -0
  113. package/skills/kryso-shift/outcome.schema.json +16 -0
  114. package/skills/kryso-shift/pass-rules.md +8 -0
  115. package/skills/kryso-shift/profile.schema.json +42 -0
  116. package/skills/kryso-shift/reader.sh +692 -0
  117. package/skills/kryso-shift/reads.sh +151 -0
  118. package/skills/kryso-shift/reference/allowance.md +21 -0
  119. package/skills/kryso-shift/reference/driver.md +95 -0
  120. package/skills/kryso-shift/reference/measuring.md +67 -0
  121. package/skills/kryso-shift/reference/outputs.md +21 -0
  122. package/skills/kryso-shift/reference/pass-script.md +115 -0
  123. package/skills/kryso-shift/reference/reconcile-and-merge.md +55 -0
  124. package/skills/kryso-shift/reference/second-reader.md +9 -0
  125. package/skills/kryso-shift/reference/sweeps.md +83 -0
  126. package/skills/kryso-shift/repair.schema.json +14 -0
  127. package/skills/kryso-shift/report-template.html +679 -0
  128. package/skills/kryso-shift/report.py +389 -0
  129. package/skills/kryso-shift/report_fixture.py +65 -0
  130. package/skills/kryso-shift/reporting.md +58 -0
  131. package/skills/kryso-shift/result.sh +91 -0
  132. package/skills/kryso-shift/runner.sh +1178 -0
  133. package/skills/kryso-shift/ship-loop.sh +3977 -0
  134. package/skills/kryso-shift/ship-pass.sh +4987 -0
  135. package/skills/kryso-shift/steps.jq +19 -0
  136. package/skills/kryso-shift/workflow.mjs +830 -0
  137. package/skills/kryso-shift/workflows/default.json +22 -0
  138. package/skills/kryso-shift/workflows/ralph.json +13 -0
  139. package/skills/kryso-watch/SKILL.md +100 -0
  140. package/skills/kryso-watch/answer.schema.json +23 -0
  141. package/skills/kryso-watch/base-refs.sh +44 -0
  142. package/skills/kryso-watch/board.sh +58 -0
  143. package/skills/kryso-watch/reference/config.md +23 -0
  144. package/skills/kryso-watch/reference/outputs.md +30 -0
  145. package/skills/kryso-watch/reference/report.md +29 -0
  146. package/skills/kryso-watch/reference/scheduler.md +32 -0
  147. package/skills/kryso-watch/reference/settlement.md +29 -0
  148. package/skills/kryso-watch/reference/shift.md +44 -0
  149. package/skills/kryso-watch/reference/shim-limits.md +22 -0
  150. package/skills/kryso-watch/reference/triage.md +26 -0
  151. package/skills/kryso-watch/schema.jq +40 -0
  152. package/skills/kryso-watch/settle.schema.json +36 -0
  153. package/skills/kryso-watch/stage-common.sh +187 -0
  154. package/skills/kryso-watch/stages/report.sh +525 -0
  155. package/skills/kryso-watch/stages/settle.sh +722 -0
  156. package/skills/kryso-watch/stages/shift.sh +466 -0
  157. package/skills/kryso-watch/stages/triage.sh +379 -0
  158. package/skills/kryso-watch/tracker.sh +27 -0
  159. package/skills/kryso-watch/triage.schema.json +77 -0
  160. package/skills/kryso-watch/warden.launchd.plist +50 -0
  161. package/skills/kryso-watch/warden.schema.json +98 -0
  162. package/skills/kryso-watch/warden.sh +1004 -0
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: kryso-build
3
+ description: "The build stage of /kryso, run in a forked context. Builds, tests, reviews and commits one change in a worktree the caller cut, leaves a ledger the caller can check, and never touches anything outside that worktree. Not for direct use."
4
+ context: fork
5
+ background: false
6
+ user-invocable: false
7
+ ---
8
+
9
+ # Build stage
10
+
11
+ You are the build stage of a `/kryso` run, in a fresh foreground context with no conversation history. The fork-context frontmatter is a Claude Code hint. Any other host must still dispatch this skill in a fresh context and wait for it. Everything you need arrives as arguments and on disk. The caller checks your work mechanically rather than believing your summary, so leave evidence.
12
+
13
+ ## Arguments
14
+
15
+ Five, space-separated, in this order: `$ARGUMENTS`
16
+
17
+ | # | Argument | Meaning |
18
+ | --- | --- | --- |
19
+ | 1 | worktree | Absolute path of the worktree the caller cut. Already installed, env file already copied. |
20
+ | 2 | base | The base branch. The review's fixed point is the merge-base with it. |
21
+ | 3 | brief | Absolute path of `.kryso/pass/brief.md`, the spec this run works from. Its first line names its source. Its directory is the ledger's, `$LEDGER` below: `.kryso/pass/`, or `.kryso/` for a pass parked before #618. |
22
+ | 4 | seam call | `tdd` when the change has a testable seam, `no-seam` when it does not. |
23
+ | 5 | issue | The issue reference, or `none` on a description entry. |
24
+
25
+ Paths with spaces are not supported. Where an argument is missing, stop and return one line saying which, because a guessed worktree is someone else's tree.
26
+
27
+ The caller also names the gate's lint, in a `## Lint` section of its own: the script engine puts it in this prompt above the Dispatch section, and `/kryso` writes it after the fifth argument. The section names one command, or says the gate names none. A prompt with no Lint section names none.
28
+
29
+ After the Lint section comes a `## Testing` section: the repository's testing policy, `.kryso/testing-policy.md` (or `docs/agents/testing-policy.md`, its old place) as the base holds it, whole, or the house default where the repository has none. It takes precedence over any installed skill text, the `/tdd` skill's included, because the copy a host installed may be older or looser than the policy. Where the section and `/tdd` disagree on how many tests a seam gets, how they are written or what may be faked, follow the section. The section's `over-budget` and `threshold` are the caller's to apply once you return: keep within the budget, and never park for it. A prompt with no Testing section gets the house default, as `/tdd` states it.
30
+
31
+ The script engine may add a `## Steps` section next: the skills the workflow gives this build, in order, after the driver decided each step's condition. Run those steps in that order and no others, even where the procedure below names a different order, and leave the evidence each one lists. The driver checks that the evidence is there when you return, and parks the pass when it is not, so a step that left none reads as one that never ran. A `## From the ledger` section, where there is one, holds the ledger records the build declares it reads, and those records are all you get from earlier contexts.
32
+
33
+ A `## Skills` section may follow: the copy of each skill this run pins, one source at one commit, named under the `kryso-pins` plugin on Claude (`/kryso-pins:tdd`) or by its path in the worktree on Codex. Wherever this skill names one of them, `/tdd` or `/implement`, run the pinned copy and never another, your own included. Where there is no such section but the session lists a `kryso-pins` plugin, its skills are the pinned copies in the same way.
34
+
35
+ **Name the worktree by absolute path in every command.** `cd` does not persist between tool calls inside a fork, so a bare `pnpm test` runs wherever the parent happened to be. Use `git -C "$WORKTREE" ...` for git and `(cd "$WORKTREE" && pnpm test)` for everything else, every time.
36
+
37
+ ## What you never do
38
+
39
+ The caller is the only writer to the outside world. You do not:
40
+
41
+ - push, or open a pull request
42
+ - touch the tracker, the board, or any issue
43
+ - stop to ask a question, because nobody is there and the caller cannot answer for you
44
+ - `git stash`, `git checkout` another branch, or `git switch`, because the worktree is on the branch it needs
45
+ - edit anything outside the worktree
46
+ - delegate the gate to a sub-agent, because a summary from zero tool calls reads like a pass
47
+ - write the run's outcome block, or call a structured-output tool if one is offered to you. The outcome is the caller's, and a fork that reports `shipped` has reported something it cannot know
48
+ - end your turn to wait for anything. In a fork, ending the turn is returning to the caller. Every sub-agent you dispatch, the two reviewers included, runs in the foreground with `run_in_background: false`, so the call blocks until the result is in hand
49
+
50
+ ## The ledger
51
+
52
+ `$LEDGER`, the brief's directory, is the caller's record of this run, and `ledger.sh` beside it is the one writer. The caller copied the module there when it opened the ledger, so every command below is `bash "$LEDGER/ledger.sh" <verb> "$WORKTREE" ...`, one command per event, the time read from the clock by the module. Append, never rewrite:
53
+
54
+ - `run.md`: one line per event, `<time> <stage> <outcome> <evidence>`. The caller reads these lines through the same module, so the stage and outcome words are fixed. Write exactly these, substituting only the angle brackets:
55
+
56
+ ```sh
57
+ bash "$LEDGER/ledger.sh" event "$WORKTREE" build committed <sha>
58
+ bash "$LEDGER/ledger.sh" park "$WORKTREE" build no-feedback-loop <what you tried>
59
+ bash "$LEDGER/ledger.sh" park "$WORKTREE" build needs-decision <what the brief leaves open>
60
+ bash "$LEDGER/ledger.sh" event "$WORKTREE" review recorded head=<sha> clean merge-base=<sha>
61
+ bash "$LEDGER/ledger.sh" event "$WORKTREE" review context <standards|spec> <agent id, or unknown>
62
+ bash "$LEDGER/ledger.sh" event "$WORKTREE" review triaged <n> fixed, <n> deferred, <n> rejected
63
+ bash "$LEDGER/ledger.sh" event "$WORKTREE" gate passed <log paths>
64
+ bash "$LEDGER/ledger.sh" event "$WORKTREE" gate failed <log path>
65
+ ```
66
+
67
+ The two parks write the park line and the checkpoint together, so a resume reads one answer. Any other event you want to record is welcome through `event`, but these eight keep their words.
68
+
69
+ The `gate passed` line holds only `logs/...` receipts that ended `exit=0`, or that a green receipt superseded: the ledger's `receipt superseded <log> exit=<n|none> by <new log>` line names it, and `<new log>` ended `exit=0`. The module refuses any other receipt with exit 64, names it, and writes nothing. A red receipt beside a green rerun of the same command is still refused, so name the green rerun alone.
70
+ - `logs/<name>.log`: one receipt per gate command, written by the module. `bash "$LEDGER/ledger.sh" receipt "$WORKTREE" typecheck 'pnpm typecheck'` runs the command in the worktree, prints the path of the receipt it wrote, which is the path a `gate` line names, and returns the command's exit. The header of `$LEDGER/ledger.sh` gives the receipt's format and why one can wait on another worktree's. Never `cat` a receipt into the transcript. A receipt that says on stderr it is waiting is queued, not failed: let the command finish.
71
+ - `review.md`: written by `/code-review`, then its triage table filled in by you, and checked by `bash "$LEDGER/ledger.sh" triage "$WORKTREE" "$LEDGER/review.md" "$LEDGER/logs/diff.patch"` before you return.
72
+ - The seams, when the seam call is `tdd`: one event per seam before the first test, `bash "$LEDGER/ledger.sh" event "$WORKTREE" build seam <why this seam and not a deeper one>`. When the brief has a `Seams:` line, the evidence starts with the seam's source: `build seam brief: <the seam as the brief names it>`, or `build seam added: <the seam>, <why the brief's seams miss it>`. Then, once a seam's tests are green and pruned, one event with how many tests it kept, numbering the seams from 1 in the order of their `build seam` events: `bash "$LEDGER/ledger.sh" event "$WORKTREE" build seam-tests seam=<k> tests=<n>`. A table-driven test is one test. A later count for the same seam replaces the earlier one.
73
+
74
+ ## Build
75
+
76
+ Read the brief, `CLAUDE.md` where it exists, and `CONTEXT.md` where the repo has one, so the repository contract and domain language apply on every host. Respect the ADRs in the area you touch. Where the repository restricts the shape of shell commands (one command per call, no pipes, no `$(...)`), its rule wins over the command blocks in this skill: split a block into separate calls that obey it.
77
+
78
+ Read by range. Where the prompt has a `## From the spec` section, it quotes the parts of the spec the brief cites: work from those, and open the spec at its path only for what they leave open, by line range. Where it has a `## Line index`, read each file it indexes in ranges of 120 lines or fewer, found from the index or with `grep -n`, never whole. Read a whole file only when it is shorter than 120 lines. Every line a context reads is paid for again on each later turn, so a whole read of a large driver or spec costs more than the work it informs.
79
+
80
+ A brief that needs a decision rather than an implementation is not this skill's work either, and the two hand-backs `/implement` makes to a person both end here as a park:
81
+
82
+ - The work is a bug. Go to `/diagnosing-bugs` first. Its feedback loop is the failing test `/tdd` then needs, and a fix without one is a guess. When no loop comes after a real try, park with `build no-feedback-loop` and what you tried, through the module, and return. Do not hypothesise because nobody is awake to object.
83
+ - The shape of a module or its interface is genuinely open. A person would take that to `/codebase-design`, and nobody is here to choose. Park with `build needs-decision` and what the brief leaves open, and return. A design invented at 3am to keep the run moving is the one the reviewer rejects at 9.
84
+
85
+ When the seam call is `tdd`, test at the seams the brief's `Seams:` line names, add a seam only with its reason, and pick them yourself when the brief has no such line. A brief that names no seams, or fewer than you need, is never a reason to park. Record the seams as `build seam` events and run `/tdd` slice by slice: one failing test, the least code that passes it, repeat until the seam's budget is spent. Prune the seam's tests, then record its `build seam-tests` count. Where the `/tdd` copy in play says to agree the seams with a user, the `build seam` lines in the ledger are that agreement: carry on without waiting. When the seam call is `no-seam`, build without tests and say so in the ledger, because a dependency bump or a copy change has nothing a test can observe.
86
+
87
+ A wrapper you put first on PATH, to profile or trace a command, calls the system tools by their full paths, `/bin/ps` and `/bin/sleep`. The suites put their own `ps`, `sleep` and `date` first on PATH, and a wrapper that calls one of them by name can call itself back until the pass's process limit stops it.
88
+
89
+ Typecheck as you go. Run the test files you touch as you touch them. Then run the typecheck, the lint the caller named and the tests related to the change once, to receipts named `typecheck`, `lint` and `test-related`, and commit with a Conventional Commits message that names the user-visible effect. Record `build committed <sha>` through the module.
90
+
91
+ The lint runs as the whole command the caller named, never over a list of the files you changed, because stage 3 runs that same command over the final commit. A red lint is yours to fix, as a red typecheck is: fix it, run the lint again to a fresh receipt, and commit only when it is green. Where the caller names no lint command, run none, and say `lint: none` in the return block.
92
+
93
+ The related tests are every test that can see what you changed. Where the runner has a related mode, give it every source file changed past the base: `vitest related --run <files>`, `jest --findRelatedTests <files>`. An import graph cannot see a file read from disk. For every changed file outside that graph, search the tests and their loaders for its basename, relative path, parent directory and any glob that includes it. Run the tests that exercise a directory or glob loader even when none names the individual file. Migrations, fixtures and config are common cases, not the whole list. Where the runner has no related mode, run the test files beside the code you changed and the ones found by that search. The full suite is not yours to run. Stage 3 owns the full-suite proof over the final commit, and a full run here as well would multiply the heaviest cost of every pass.
94
+
95
+ Run the related set as few times as the work allows: in a repository whose tests reach a shared driver, one run can take ten minutes. Make each receipt and `wait` call in the foreground with the tool's longest timeout, where the default is two minutes. Under a pass, a Claude host's longest timeout is the pass's call bound, which outlasts the longest gate. `printenv BASH_MAX_TIMEOUT_MS` prints it, and the script engine's Dispatch section names it too. With that bound, run each receipt attached, in the foreground, with that timeout and no `--wait`, so the pass's deadline stops a gate that hangs. Where the host bounds a call lower, 600000 ms on Claude Code by default, a receipt that may outlast the call takes `--wait 540`: `bash "$LEDGER/ledger.sh" receipt "$WORKTREE" test-related '<command>' --wait 540`. Past the bound it prints `running <log>` and returns 76, and `bash "$LEDGER/ledger.sh" wait "$WORKTREE" <log> --wait 540` takes the wait up again, as often as it needs. Exit 78, void, and 75, abandoned, are neither a pass nor a fail: run the receipt again over the same HEAD. Never start a receipt in the background or poll its log with `sleep`, because a background command can be stopped before it ends, and the whole set then runs again. Do not edit, commit or switch branch while a receipt runs. A HEAD that moves under it makes it void, and an edit makes its result stand for a tree that never existed.
96
+
97
+ A red related receipt starts a working loop. Fix the cause, and rerun only the suites the receipt reports as failing, and the ones the fix's own files reach by the search above, until they are green. Then run the whole related set once more, to one receipt. The `gate passed` line names only receipts that end `exit=0`, and the suites that passed inside a red receipt have no green receipt of their own.
98
+
99
+ ## Review
100
+
101
+ The review runs on a committed tree, and that is what makes its read-only rule checkable. Record the tree first:
102
+
103
+ ```sh
104
+ git -C "$WORKTREE" rev-parse HEAD
105
+ git -C "$WORKTREE" status --porcelain
106
+ ```
107
+
108
+ Then call `/code-review` (`/kryso:code-review` when the skills came with the kryso plugin) with four things: the fixed point `$(git -C "$WORKTREE" merge-base "$BASE" HEAD)`, the brief as the spec, `$LEDGER/review.md` as the report path, and that the run is unattended. When a Dispatch section at the end of this prompt names a reviewer agent type, pass two more: that type, and `$LEDGER/logs/review-diff.patch` as the diff path. The type can read and search but has no shell, so a reviewer dispatched as it cannot write the tree, and it reads the diff from that file because it cannot run git.
109
+
110
+ Record each reviewer as it returns, one `review context` line per axis with the agent id its dispatch reported, or `unknown` where the host reported none. The caller counts the review's contexts from these lines, once each.
111
+
112
+ When it returns, compare the tree again. `/code-review` makes the same comparison and voids a reviewer that moved the tree, but it reverts nothing, because the tree is not its to touch. This is the check that restores it, because the worktree is yours. A tree that moved was moved by the reviewers. Read what moved with `git -C "$WORKTREE" status --porcelain` and `git -C "$WORKTREE" diff --stat`, record the paths through `bash "$LEDGER/ledger.sh" event "$WORKTREE" review restored <paths>`, then restore exactly those paths: `git -C "$WORKTREE" checkout -- <paths>` for edits and `git -C "$WORKTREE" clean -fd -- <paths>` for new files. Never `clean -x`, which would take `.kryso/pass/` with it. That is the one `checkout` you may run, and it never names a branch.
113
+
114
+ The review that ran on the moved tree is void. After the restore, record the tree again with a fresh `review recorded` line and run `/code-review` once more on the restored tree. A `review restored` line with no `review recorded` after it is a void review. The script engine's pass rejects the build for it and reruns it. Under `/kryso` it is still a review of a tree nobody will see, so do not skip the second run.
115
+
116
+ Fill in the triage table in `review.md`. Every finding gets one of three outcomes with its evidence:
117
+
118
+ - `fixed`, with the commit that fixed it
119
+ - `deferred`, with the reason it falls outside the brief's scope, so the caller can open a tracking issue
120
+ - `rejected`, with the fact you checked that shows the finding is wrong
121
+
122
+ Fix the in-scope findings. Then run the gate again, the typecheck, the named lint and the related tests, to fresh receipts, because the run before the review never saw these fixes. Work the related set out again from the files changed past the base, since a fix can reach a file the first set did not cover. Commit.
123
+
124
+ Then check the review the way the caller will. Save the diff past the fixed point, `git -C "$WORKTREE" diff <merge-base>...HEAD > "$LEDGER/logs/diff.patch"`, and run `bash "$LEDGER/ledger.sh" triage "$WORKTREE" "$LEDGER/review.md" "$LEDGER/logs/diff.patch"`. A refusal names the check that failed, `triage-rows (...)`, `review-quote (...)` or `review-artefact (...)`, with the reason the caller would record. Fix `review.md` and run the verb again until it passes. The caller runs the same verb after you return, so skipping it here spends the pass's one rerun on a table you could have fixed.
125
+
126
+ Record the `review triaged` and `gate passed` lines through the module, or `gate failed` and return.
127
+
128
+ ## Unmet criteria
129
+
130
+ Before you return, read the brief's acceptance criteria once more against what is on disk. Record each one the work left undone, or that asks for a measurement nobody made, with `bash "$LEDGER/ledger.sh" event "$WORKTREE" build unmet "<the criterion, in a few words>"`, one line each. The caller's gate, CI wait and merge prove the suite and the checks, so a criterion they prove is not unmet. A criterion out of reach in this worktree, such as a median of three CI runs, is. A finding you deferred is not: a deferred row is outside the brief, and an unmet criterion is inside it.
131
+
132
+ With any line recorded, the PR refers to the issue rather than closing it, and the closeout leaves the issue open for a person to triage ([ADR 0045](../../docs/adr/0045-a-pass-whose-build-left-criteria-unmet-refers-to-its-issue-and-leaves-it-open-for-triage.md)). The return block's prose cannot do that, because the caller reads the ledger.
133
+
134
+ ## Return
135
+
136
+ Your last message is what the caller receives, and a last message that is only a tool call arrives as an empty placeholder. So the final thing you do, after the last tool call, is write this block as plain text and stop. At most fifteen lines. The caller reads them for orientation and then checks the ledger, the commits and the tree itself, so put nothing here that is not also on disk:
137
+
138
+ ```
139
+ commits: <n> past <base>, head <sha>
140
+ tree: clean | dirty (<paths>)
141
+ seams: <n> | no-seam
142
+ gate: typecheck exit=<n>, lint exit=<n> | lint: none, test-related exit=<n> (logs in .kryso/pass/logs/)
143
+ review: <n> findings, <n> fixed, <n> deferred, <n> rejected
144
+ parked: <reason> | none
145
+ unmet: <n> | none
146
+ ```
147
+
148
+ ## Rationalisations
149
+
150
+ | Excuse | Reality |
151
+ | --- | --- |
152
+ | "The parent will run the gate anyway, so I can skip the rerun" | The parent proves the final commit. Your rerun is what makes that commit worth proving. |
153
+ | "The lint is stage 3's job, so I'll leave it to the caller" | A red lint in stage 3 spends the pass's one fork rerun on a fix you could have made here. Run the named command before each commit. |
154
+ | "The related set looks thin, so I'll run the full suite to be safe" | Stage 3 runs it once over the final commit. A second full run here doubles the pass's heaviest cost and proves nothing stage 3 does not. |
155
+ | "The suite is slow, so I'll run it in the background and check its log" | A background command can be stopped before it ends, and the set then runs again from the start. A foreground call at the pass's call bound outlasts the gate. Under a lower bound, `--wait 540` and `ledger.sh wait` outlast it. |
156
+ | "The bound is long, so `--wait 540` is safer anyway" | A detached receipt is outside the pass's process group, so the deadline cannot stop it when it hangs. Attached is the default wherever the bound allows it. |
157
+ | "The file is long, but reading it whole once is simpler" | It is read again on every later turn. Take the range the index names. |
158
+ | "One test failed, so I'll run the whole related set again after each fix" | Loop on the failing suites alone while you fix them. The whole set runs once more, green, before the gate line. |
159
+ | "The change is only SQL or config, so no test is related" | Grep the tests for the file's name. A file read from disk is invisible to the import graph, not untested. |
160
+ | "The receipt is waiting on another worktree, so I'll run the command directly" | The wait is the lock that stops concurrent passes starving each other's suites. A command run around it has no receipt and restarts the contention. |
161
+ | "The reviewer's edit is an improvement, so I'll keep it" | Then it is your change: restore the tree, make the edit yourself, and test it. An untested reviewer edit in the branch is the bug the read-only rule exists to stop. |
162
+ | "The finding is out of scope, so I'll drop it" | Deferred with a reason. Dropped findings get found again by the next reviewer. |
163
+ | "No feedback loop, but the fix is obvious" | That is the exact failure `/diagnosing-bugs` exists to stop. Park it. |
164
+ | "I'll `cd` once at the start" | It does not persist. Absolute paths, every command. |
165
+ | "The reviewers are running in the background, so I'll wait for the notification" | Ending the turn to wait is returning to the caller with no review on disk. Foreground, always. |
166
+ | "The criterion needs CI runs I cannot make, so I'll leave it out" | Record it as unmet. Left out, the pass closes an issue whose brief is not done, and a person has to reopen it. |
167
+ | "Everything passed, so the outcome is shipped" | Nothing has been pushed, opened or merged. The caller decides the outcome, and it has stages left to run. |
168
+ | "The caller needs the full test output to trust me" | The caller reads the log file. Fifteen lines, and the rest on disk. |
@@ -0,0 +1,167 @@
1
+ ---
2
+ name: kryso-shift
3
+ description: "Clear the ready column, an ordered queue of issues or an epic's sub-issues, one fresh process per issue, by running /kryso or the shell pass script once each. Use for an AFK or overnight shift over the tracker, a loop over several tickets, or a stacked run through a queue."
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # kryso-shift
8
+
9
+ One shift, several issues, one fresh process per issue. `/loop` re-fires into the same session, so the fourth issue of the night inherits three issues' worth of transcript and gets whatever survived a compaction. A new process starts every run at the same place.
10
+
11
+ [ship-loop.sh](ship-loop.sh), the driver, does the work, and runs from a plain terminal with no session at all. This skill is the front end for running it from a session. The driver has two engines: `ship-it`, the default, runs `/kryso` once per issue, and `script` runs [ship-pass.sh](ship-pass.sh), the same stages in shell with the build fork as its model process and up to three reconciliation contexts per issue. The execution profile is a separate choice: `claude` is the default, and `codex` runs either engine with Codex under a ChatGPT subscription.
12
+
13
+ ## Running it
14
+
15
+ The commands below name the canonical project install, `.agents/skills/kryso-shift/`. In the playbook checkout it is `skills/kryso-shift/`, and a user-level install puts it at `~/.agents/skills/kryso-shift/`. A `.claude/skills` path may be a compatibility link to that directory. From a session, the skill's base directory line says which.
16
+
17
+ 1. Run the preflight and show the user what a shift would do:
18
+
19
+ ```sh
20
+ bash .agents/skills/kryso-shift/ship-loop.sh --dry-run
21
+ ```
22
+
23
+ That prints the candidate count, the worktrees already in flight, the caps with their worst-case bounds, and the exact command each pass will run. With a queue it prints the snapshot too, so the issues a shift would spend on can be read before anything is. It spends nothing.
24
+
25
+ 2. Start the shift in the background, with the caps the user asked for or the defaults:
26
+
27
+ ```sh
28
+ bash .agents/skills/kryso-shift/ship-loop.sh --max 4 --budget 20
29
+ ```
30
+
31
+ To have each pass reported somewhere off the Mac as it ends, set two environment variables before starting the shift, in the secrets file the shell sources rather than a flag or a checked-in file, so the token cannot leak through a shift log, a dry-run printout or a process list:
32
+
33
+ ```sh
34
+ export KRYSO_REPORT_URL=https://... # where each pass's JSON body is posted
35
+ export KRYSO_REPORT_TOKEN=... # sent as a bearer token
36
+ ```
37
+
38
+ What the body carries, and what happens when a push fails, is in [Reporting each pass](reference/driver.md#reporting-each-pass).
39
+
40
+ 3. When the script exits, read the `summary.json` its last line names and report from it: the stop state and reason, one row per distinct issue, and every list that names something for a person. The exit code says how the shift ended, and the shift log has the per-run detail for a row that needs it. Every file a shift writes, and every field of `summary.json` and the shift log, is in [What it leaves behind](reference/outputs.md).
41
+
42
+ Do not paste the saved JSON results, the shift log or any pass log into the chat. They are large, they are on disk, the summary names them, and a bad run is opened by its session id.
43
+
44
+ ## What each pass runs
45
+
46
+ ```sh
47
+ env -u ANTHROPIC_API_KEY claude -p "/kryso" --permission-mode auto --permission-prompts none \
48
+ --output-format json --json-schema "$(cat outcome.schema.json)" --max-budget-usd 20 \
49
+ --model claude-opus-5-5 --effort high
50
+ ```
51
+
52
+ The key is unset so a shift spends the plan's allowance rather than API credits, which a shell that exports `ANTHROPIC_API_KEY` would otherwise bill silently. `--api-key` keeps it, for a run that must not stop on plan limits.
53
+
54
+ `--permission-prompts none` denies anything that would prompt, and `--permission-mode auto` decides the rest. The schema in [outcome.schema.json](outcome.schema.json) mirrors `/kryso`'s outcome block, and the run's answer comes back in the result's top-level `structured_output`.
55
+
56
+ ## Profiles and models
57
+
58
+ `--profile` selects the whole execution contract. `--model` is only an exact model-id override inside that profile, and never selects a provider. `--effort` overrides reasoning effort without changing either. Both built-ins default to `high`. The built-in `claude` profile names `claude-opus-5-5`, so a change of the interactive default does not change what a shift runs. Claude accepts `low`, `medium`, `high`, `xhigh` and `max`, while Codex also accepts `none`, `minimal` and `ultra` for models that support them.
59
+
60
+ | Profile | Host and auth | Billing | Skill syntax |
61
+ | --- | --- | --- | --- |
62
+ | `claude` | `claude -p`, with the existing Claude login or the key retained by `--api-key` | subscription or API | `/kryso` |
63
+ | `codex` | `codex exec`, where `codex login status` must say `Logged in using ChatGPT` | ChatGPT subscription | `$kryso` |
64
+
65
+ Codex does not expose a dollar charge for a subscription run, so `cost_usd` is `null`, token usage is retained, and an explicit `--budget` or `--api-key` is rejected rather than pretended.
66
+
67
+ `mcp` and `skills` in the repository's `.kryso/config.json`, and `--mcp` for one shift, set which MCP servers and skills a Claude pass loads. Every server's tools and every skill's listing cost tokens in every context of every pass, so keep only what the repository's passes call. The values each one takes, how to choose the MCP list, how the runner hides the other skills, how the Codex profile keeps its billing path, and how `KRYSO_PROFILE_FILE` names a profile are in [Profiles and models](reference/driver.md#profiles-and-models).
68
+
69
+ ## What the preflight checks
70
+
71
+ The preflight runs before a shift claims anything and spends nothing. A failed check stops the shift with a `preflight:` line and exit 1. It checks the host login, `gh` auth, the base on origin, the skills the workflow pins, fetched into kryso's store where it lacks them, the MCP names, and CI health, which `--no-ci-check` skips. The full list, with the warnings, is in [What the preflight checks](reference/driver.md#what-the-preflight-checks).
72
+
73
+ The settings in scope need `permissions.allow` entries for the `gh` surface `/kryso` uses: `Bash(gh issue *)`, `Bash(gh project *)`, `Bash(gh pr *)`, `Bash(gh run *)`, `Bash(gh repo *)`, `Bash(gh api *)` and `Bash(gh label *)`, in the user-level `~/.claude/settings.json`. The preflight warns when no rule covers `gh issue`, and when the workspace has not been trusted. Why a missing rule matters is in [What the preflight checks](reference/driver.md#what-the-preflight-checks).
74
+
75
+ ## Options
76
+
77
+ `ship-loop.sh --help` lists them with their defaults. Anything after `--` reaches the host unchanged, so host-specific arguments there are the caller's responsibility: for Claude, `--setting-sources project,local` and `--add-dir` travel this way. The Codex profile accepts only inert passthrough options and rejects any that belong to the profile contract. How `--second-reader` resolves is in [Options](reference/driver.md#options).
78
+
79
+ ## A queue instead of the label
80
+
81
+ By default each pass picks its own issue off the label. A queue names the issues instead, in order, and the driver runs the same engine over them one pass each. `--issues "36 37"` names them. `--epic N` takes the epic's open sub-issues that are unassigned, not locked by another run's worktree and not blocked by an open issue, in GitHub's order, and needs a GitHub remote. `ship-loop.sh --help` lists every flag with its default, and [Sweeps](#sweeps), [Adopting a stopped shift](#adopting-a-stopped-shift) and [Stacked sweeps](#stacked-sweeps) below say how `--sweeps`, `--adopt` and `--stack` behave.
82
+
83
+ `--workflow NAME` sets the workflow every pass resolves from its base and records, over each issue's `workflow:<name>` label, and `kryso workflow show NAME` prints it. A `workflow:ralph` label still wins. Under `ship-it`, a pass whose workflow is not the default runs under the script engine, because only that engine runs another workflow, and a repository whose own `default` differs from the built-in stops the preflight with a line that names `--engine script`. The shift runs this workflow's shift stages, or the default's: `after-pass` after each pass and `end` once after the last, in the main checkout with no tracker token. Each command leaves `stage-<id>-pass<n>.<k>.log`, or `stage-<id>-end.<k>.log`, and a `stage=` line in `shift.log`, and a failure is reported in the summary's `shift_stages` and the close, never retried. The dry run names each candidate's workflow and lists the shift stages, and runs none.
84
+
85
+ Pass one of `--issues` and `--epic`. `--base`, `--note`, `--workflow`, `--stack` and `--engine script` need a queue, and the preflight says so rather than dropping them. The dry run prints every cap with its worst case in passes and model starts, and each queued pass's prompt: [A queue instead of the label](reference/driver.md#a-queue-instead-of-the-label).
86
+
87
+ A queued issue that comes back `nothing-to-take` was locked or already taken, which is that issue's answer rather than the column's, so a plain queue moves on to the next. A stacked queue does not: each pass builds on the one before, so a link that could not be taken, or a pass that ended without a PR to stack on, ends the shift with exit 1. How a stacked queue merges, and what the first PR then carries, is in [A stacked queue](reference/driver.md#a-stacked-queue).
88
+
89
+ ## Integration branches
90
+
91
+ An epic whose passes land together merges into an integration branch, and a person lands that on the default branch in one merge once the epic is done. `ship-loop.sh integration <epic> <slug>` cuts it, guards it against deletion on origin, and prints `integration/<epic>-<slug>` to pass as `--base`:
92
+
93
+ ```sh
94
+ bash .agents/skills/kryso-shift/ship-loop.sh --epic 124 --sweeps 3 --base "$(bash .agents/skills/kryso-shift/ship-loop.sh integration 124 lean-passes)"
95
+ ```
96
+
97
+ What it cuts and what a second run does are in [Integration branches](reference/driver.md#integration-branches).
98
+
99
+ ## Sweeps
100
+
101
+ A workset is the ordered set of issues `--issues` names. A sweep is one live eligibility check over an epic's children or a workset, then one traversal of what it found. A pass is one issue worked in its own process. A shift is the sequence of passes one driver runs.
102
+
103
+ `--sweeps` takes a positive whole number and needs an epic or a workset of at least two distinct issues. Anything else is refused in the preflight, before any tracker read or model start. A later pass continues an issue only when this shift owns its worktree. A sweep's scope and filter, its order and bounds, when a later sweep continues an issue, and the fingerprint that stops a stalled one are in [Sweeps](reference/sweeps.md#sweeps).
104
+
105
+ ## Adopting a stopped shift
106
+
107
+ A shift that stops leaves its resumable work claimed, in worktrees it owns, and every later shift reads those worktrees as foreign locks. `--adopt SHIFT` takes that work over: it names the stopped shift by its directory under `.claude/kryso/`, and continues the worktrees that shift owns inside this shift's queue, under this shift's engine, so it needs a queue. It is the one way work crosses engines. A bare `--adopt` finds the owning shifts of the `--issues` queue's worktrees itself and runs one shift per selection they ran, then the issues with no worktree. How the stop is confirmed and which worktrees are taken are in [Adopting a stopped shift](reference/sweeps.md#adopting-a-stopped-shift).
108
+
109
+ ## Stacked sweeps
110
+
111
+ `--stack` with `--sweeps` chains issue to issue along the tracker's blockers rather than the queue's order: a dependent enters the next sweep on the branch of a blocker this shift owns once that blocker's evidence is merge-ready. The default-branch merge stays a person's, every PR stays open, and the tracker is never told. What makes a blocker merge-ready, and which branch a dependent bases on, are in [Stacked sweeps](reference/sweeps.md#stacked-sweeps).
112
+
113
+ ## The allowance and the pass script
114
+
115
+ Every pass runs under an allowance of active execution that the shell keeps, set by `--timeout` and `--grace`. What counts against it, how a pass is stopped, how long `--receipt-wait` waits on a receipt a session left open, and when an interrupted pass may resume are in [The allowance](reference/allowance.md).
116
+
117
+ `--engine script` runs [ship-pass.sh](ship-pass.sh) once per queued issue, and it runs on its own from a terminal too. Its stages, checks, checkpoint, config and outputs are in [The pass script](reference/pass-script.md), and its reconciliation contexts, merge and closeout in [Reconciliation, merge and closeout](reference/reconcile-and-merge.md).
118
+
119
+ ## Where the detail lives
120
+
121
+ Read a reference when a question needs it.
122
+
123
+ | File | Read it when |
124
+ | --- | --- |
125
+ | [driver.md](reference/driver.md) | a report push failed, the Codex profile refused something, the preflight or the CI check stopped a shift, an argument after `--` or a second-reader value was refused, a stacked queue or an integration branch needs explaining, or the output looked different on a terminal |
126
+ | [sweeps.md](reference/sweeps.md) | a sweep left an issue out, held, continued or stalled it, an adoption was refused, or a dependent stayed blocked |
127
+ | [allowance.md](reference/allowance.md) | a pass ended `interrupted` or `locked`, an issue was named `unsafe`, or the shift log has a `tracker=timeout` line |
128
+ | [pass-script.md](reference/pass-script.md) | a script-engine pass failed or parked before its PR, a resume was refused, or a repo is adopting `.kryso/config.json` |
129
+ | [reconcile-and-merge.md](reference/reconcile-and-merge.md) | a script-engine pass parked at reconcile or merge, or its closeout stopped |
130
+ | [second-reader.md](reference/second-reader.md) | a PR's Second reader subsection, a `review second-read` line or a `cut seam-call` line needs explaining |
131
+ | [measuring.md](reference/measuring.md) | comparing engines, profiles or revisions from saved evidence. Per-run tables are [reporting.md](reporting.md). Keeping a pass's evidence after its worktree goes is [archiving.md](archiving.md), with [the keep](archiving-keep.md), [recovery](archiving-recovery.md) and [the checker](archiving-checker.md) |
132
+ | [outputs.md](reference/outputs.md) | a row of the summary needs its file, or a stop state needs explaining |
133
+
134
+ ## How a shift ends
135
+
136
+ | Stop | Exit | State |
137
+ | --- | --- | --- |
138
+ | A run reported `nothing-to-take`, so the column is empty (no queue) | 0 | `frontier-empty`, or `complete` or `review-ready` by the earlier runs' rows |
139
+ | `--epic` or a workset sweep found nothing eligible | 0 | `frontier-empty` |
140
+ | The queue is done | 0 | `complete`, `review-ready` or `frontier-empty` |
141
+ | `--max` runs finished with work left, or a later sweep held an issue at the cap | 0 | `sweep-limit` |
142
+ | A run hit its budget cap | 0 | `sweep-limit` |
143
+ | The sweep cap was reached with an issue still resumable | 0 | `sweep-limit` |
144
+ | A later sweep found nothing resumable and nothing newly eligible | 0 | `complete`, `review-ready` or `frontier-empty` |
145
+ | A continued issue made no progress, and nothing else is left to continue or admit | 0 | `stalled` |
146
+ | Every attempted pass failed, including one pass under `--max 1` | 1 | `failed` |
147
+ | Two failed runs in a row | 1 | `failed` |
148
+ | A later sweep's snapshot could not be read | 1 | `failed` |
149
+ | A stacked queue's pass ended without a PR to stack on, or its issue could not be taken (not under `--sweeps`) | 1 | `failed` |
150
+ | A stacked sweep ran out of sweeps with a dependent its merge-ready blocker would admit | 0 | `sweep-limit` |
151
+ | Still rate limited after three waits | 2 | `rate-limited` |
152
+ | An INT or a TERM to the driver, a ctrl+c or `kryso attach`'s stop | 130 | `complete`, `review-ready` or `frontier-empty` |
153
+
154
+ The state is on the driver's last line and in `summary.json`. What each state means, and what a person does next, is in [How a shift ends](reference/outputs.md#how-a-shift-ends).
155
+
156
+ `shipped` and `parked` both continue: a park is work left claimed for a human, not a reason to end the night. A rate limit waits and retries the same pass, under the rule in [How a shift ends](reference/outputs.md#how-a-shift-ends).
157
+
158
+ ## Rationalisations
159
+
160
+ | Excuse | Reality |
161
+ | --- | --- |
162
+ | "`/loop /kryso` does the same thing" | It re-fires into this session. The fourth issue then runs on a compacted transcript, which is the failure this skill exists to remove. |
163
+ | "A parked run means something is wrong, so stop the shift" | A park is a correct outcome with the work left claimed. Take the next issue. |
164
+ | "The column is empty, so widen the label and keep going" | An empty column ends the shift. Inventing work to stay busy is the one thing an unattended run must not do. |
165
+ | "Run the passes in parallel to finish sooner" | The worktree is the lock, so it would work, and it is deliberately not built yet. One at a time until it is. |
166
+ | "Pass 1 parked without a PR, so stack pass 2 on the shift base and carry on" | The queue was ordered because pass 2 builds on pass 1. Basing it elsewhere ships a branch that will not merge. Exit 1 and let a person resume pass 1. |
167
+ | "Every pass parked with a PR open, so report the shift complete" | Open PRs are a handoff to the merge gate. The state is `review-ready`, and the summary lists the PRs. |