@jeiemgi/cckit 0.10.0 → 0.12.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 (193) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +136 -127
  3. package/README.md +66 -43
  4. package/bin/cckit +151 -181
  5. package/cckit.config.json +1 -4
  6. package/package.json +1 -1
  7. package/scripts/advisor-test.sh +55 -0
  8. package/scripts/autopilot-run-test.sh +20 -12
  9. package/scripts/autopilot-run.sh +9 -1
  10. package/scripts/autopilot-test.sh +29 -13
  11. package/scripts/autopilot.sh +4 -4
  12. package/scripts/benchmark/verb-timings-test.sh +4 -0
  13. package/scripts/benchmark/verb-timings.sh +16 -5
  14. package/scripts/capture-project-ids.sh +23 -1
  15. package/scripts/check.sh +25 -0
  16. package/scripts/content-skills-test.sh +1 -1
  17. package/scripts/contribute.sh +8 -3
  18. package/scripts/copilot-loop-test.sh +66 -81
  19. package/scripts/exec-targets-test.sh +20 -0
  20. package/scripts/force-push-fence-test.sh +44 -0
  21. package/scripts/force-push-fence.baseline +1 -0
  22. package/scripts/force-push-fence.sh +51 -0
  23. package/scripts/forge-fence-test.sh +69 -0
  24. package/scripts/forge-fence.baseline +2 -0
  25. package/scripts/forge-fence.sh +76 -0
  26. package/scripts/forge-report-test.sh +100 -0
  27. package/scripts/forge-report.sh +176 -0
  28. package/scripts/init-guided-test.sh +94 -82
  29. package/scripts/init.sh +12 -7
  30. package/scripts/install-test.sh +26 -0
  31. package/scripts/install.sh +7 -0
  32. package/scripts/instruction-budget-baseline.txt +1 -1
  33. package/scripts/kit-doctor-test.sh +60 -12
  34. package/scripts/kit-doctor.sh +170 -77
  35. package/scripts/lib/agent-resolve-test.sh +2 -0
  36. package/scripts/lib/agent-resolve.sh +15 -8
  37. package/scripts/lib/board-view.sh +3 -3
  38. package/scripts/lib/captain.sh +37 -8
  39. package/scripts/lib/content-kinds-gc-test.sh +22 -21
  40. package/scripts/lib/copilot-test.sh +20 -11
  41. package/scripts/lib/copilot.sh +19 -13
  42. package/scripts/lib/effort-close-subs-test.sh +96 -0
  43. package/scripts/lib/effort-dispatch-test.sh +5 -3
  44. package/scripts/lib/effort-metrics-test.sh +7 -12
  45. package/scripts/lib/effort-metrics.sh +17 -46
  46. package/scripts/lib/effort-ops-test.sh +261 -167
  47. package/scripts/lib/effort-ops.sh +449 -171
  48. package/scripts/lib/effort-parity-test.sh +57 -62
  49. package/scripts/lib/effort-plan-test.sh +56 -54
  50. package/scripts/lib/effort-plan.sh +14 -7
  51. package/scripts/lib/effort-review-test.sh +107 -0
  52. package/scripts/lib/effort-review.sh +93 -0
  53. package/scripts/lib/effort-slug-test.sh +34 -14
  54. package/scripts/lib/effort-slug.sh +13 -13
  55. package/scripts/lib/effort.sh +58 -80
  56. package/scripts/lib/forge-github.sh +260 -0
  57. package/scripts/lib/forge-none.sh +24 -0
  58. package/scripts/lib/forge-test.sh +186 -0
  59. package/scripts/lib/forge.sh +133 -0
  60. package/scripts/lib/gh-board-add-test.sh +118 -0
  61. package/scripts/lib/gh-project-test.sh +151 -31
  62. package/scripts/lib/gh-project.sh +139 -11
  63. package/scripts/lib/gh-rest-test.sh +63 -118
  64. package/scripts/lib/gh-rest.sh +275 -52
  65. package/scripts/lib/git-core-test.sh +128 -0
  66. package/scripts/lib/grill-record-test.sh +49 -0
  67. package/scripts/lib/grill-record.sh +88 -0
  68. package/scripts/lib/handoff.sh +1 -1
  69. package/scripts/lib/init-github.sh +38 -13
  70. package/scripts/lib/kinds-test.sh +13 -16
  71. package/scripts/lib/kit-brief-test.sh +51 -10
  72. package/scripts/lib/kit-brief.sh +103 -18
  73. package/scripts/lib/kit-gc-test.sh +90 -109
  74. package/scripts/lib/kit-gc.sh +19 -22
  75. package/scripts/lib/kit-hotfix.sh +18 -16
  76. package/scripts/lib/kit-interview.sh +6 -0
  77. package/scripts/lib/kit-lib-test.sh +1 -1
  78. package/scripts/lib/kit-lib.sh +7 -7
  79. package/scripts/lib/kit-msg.sh +3 -3
  80. package/scripts/lib/kit-status.sh +19 -14
  81. package/scripts/lib/kit-task-ops-test.sh +20 -1
  82. package/scripts/lib/kit-task-ops.sh +177 -94
  83. package/scripts/lib/kto-hotfix-test.sh +53 -58
  84. package/scripts/lib/kto-task-close-test.sh +28 -27
  85. package/scripts/lib/kto-task-new-test.sh +55 -48
  86. package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
  87. package/scripts/lib/kto-task-pr-test.sh +30 -34
  88. package/scripts/lib/light-task-run-test.sh +19 -15
  89. package/scripts/lib/light-task-test.sh +34 -29
  90. package/scripts/lib/light-task.sh +24 -13
  91. package/scripts/lib/loose-issues.sh +65 -0
  92. package/scripts/lib/naming-test.sh +112 -0
  93. package/scripts/lib/naming-verbs-test.sh +126 -0
  94. package/scripts/lib/naming.sh +172 -0
  95. package/scripts/lib/next-test.sh +27 -22
  96. package/scripts/lib/next.sh +13 -7
  97. package/scripts/lib/orchestration-runtime-test.sh +11 -8
  98. package/scripts/lib/plan-machine.sh +22 -16
  99. package/scripts/lib/plan-next.sh +4 -4
  100. package/scripts/lib/pr-evidence-test.sh +63 -74
  101. package/scripts/lib/pr-evidence.sh +15 -12
  102. package/scripts/lib/qa-lane-test.sh +59 -27
  103. package/scripts/lib/qa-lane.sh +14 -6
  104. package/scripts/lib/review-page-test.sh +34 -25
  105. package/scripts/lib/review-page.sh +10 -4
  106. package/scripts/lib/spec-lint-test.sh +63 -0
  107. package/scripts/lib/spec-lint.sh +95 -0
  108. package/scripts/lib/sprint-test.sh +96 -0
  109. package/scripts/lib/sprint.sh +216 -0
  110. package/scripts/lib/stage-receipt-test.sh +169 -19
  111. package/scripts/lib/stage-receipt.sh +195 -10
  112. package/scripts/lib/test-forge-shim.sh +115 -0
  113. package/scripts/lib/verbs.sh +105 -0
  114. package/scripts/lib/verbs.tsv +92 -0
  115. package/scripts/lib/version-bump-test.sh +20 -0
  116. package/scripts/lib/version-bump.sh +4 -2
  117. package/scripts/lib/worker-brief-test.sh +1 -1
  118. package/scripts/lib/worker-brief.sh +1 -1
  119. package/scripts/lib/worktree-issue-test.sh +24 -19
  120. package/scripts/lib/worktree-issue.sh +10 -10
  121. package/scripts/lib/worktree-start-test.sh +13 -16
  122. package/scripts/lib/worktree-start.sh +57 -7
  123. package/scripts/loose-issues-test.sh +102 -0
  124. package/scripts/loose-issues.baseline +5 -0
  125. package/scripts/marketing-walkthrough-test.sh +25 -30
  126. package/scripts/night-grant.sh +14 -8
  127. package/scripts/night-run.mjs +1 -1
  128. package/scripts/orchestrate-test.sh +27 -31
  129. package/scripts/orchestrate.sh +9 -3
  130. package/scripts/portable-test.sh +37 -36
  131. package/scripts/publish.sh +9 -3
  132. package/scripts/setup-labels.sh +23 -12
  133. package/scripts/setup-milestones.sh +8 -2
  134. package/scripts/status-test.sh +39 -33
  135. package/scripts/status.sh +12 -6
  136. package/scripts/task-sync-test.sh +75 -32
  137. package/scripts/task-sync.sh +97 -6
  138. package/scripts/terms-check-test.sh +191 -0
  139. package/scripts/terms-check.sh +242 -0
  140. package/scripts/verbs-gen.sh +43 -0
  141. package/scripts/verbs-help-test.sh +61 -0
  142. package/scripts/verbs-ratchet-test.sh +69 -0
  143. package/scripts/verbs-ratchet.sh +34 -0
  144. package/scripts/verbs-test.sh +120 -0
  145. package/scripts/verbs.baseline +5 -0
  146. package/skills/kit-add/SKILL.md +2 -1
  147. package/skills/kit-advisor/SKILL.md +75 -0
  148. package/skills/kit-advisor/references/close.md +53 -0
  149. package/skills/kit-advisor/references/grill.md +69 -0
  150. package/skills/kit-advisor/references/orchestrate.md +56 -0
  151. package/skills/kit-advisor/references/plan.md +64 -0
  152. package/skills/kit-advisor/references/review.md +47 -0
  153. package/skills/kit-advisor/references/step-report.md +61 -0
  154. package/skills/kit-annotate/SKILL.md +1 -0
  155. package/skills/kit-autopilot/SKILL.md +2 -1
  156. package/skills/kit-cleanup/SKILL.md +3 -2
  157. package/skills/kit-contribute/SKILL.md +1 -0
  158. package/skills/kit-customize/SKILL.md +1 -0
  159. package/skills/kit-dev/SKILL.md +1 -0
  160. package/skills/kit-digest/SKILL.md +1 -0
  161. package/skills/kit-docs-writer/SKILL.md +4 -3
  162. package/skills/kit-effort-close/SKILL.md +18 -9
  163. package/skills/kit-effort-new/SKILL.md +12 -8
  164. package/skills/kit-effort-pr/SKILL.md +8 -7
  165. package/skills/kit-effort-start/SKILL.md +1 -0
  166. package/skills/kit-gc/SKILL.md +1 -0
  167. package/skills/kit-next/SKILL.md +8 -7
  168. package/skills/kit-onboard/SKILL.md +1 -0
  169. package/skills/kit-page/SKILL.md +1 -0
  170. package/skills/kit-plan-next/SKILL.md +11 -11
  171. package/skills/kit-security-sweep/SKILL.md +1 -0
  172. package/skills/kit-ship/SKILL.md +1 -0
  173. package/skills/kit-status/SKILL.md +6 -5
  174. package/skills/kit-task-close/SKILL.md +1 -0
  175. package/skills/kit-task-new/SKILL.md +1 -0
  176. package/skills/kit-task-pr/SKILL.md +1 -0
  177. package/skills/kit-task-pr-auto/SKILL.md +2 -1
  178. package/skills/kit-task-pr-merge/SKILL.md +4 -3
  179. package/skills/kit-task-start/SKILL.md +1 -0
  180. package/skills/kit-task-sync/SKILL.md +3 -0
  181. package/skills/kit-ux-audit/SKILL.md +1 -0
  182. package/skills/routing.yaml +124 -0
  183. package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
  184. package/templates/instructions.md.tmpl +3 -3
  185. package/templates/rules/authoring.md +7 -3
  186. package/templates/rules/delegation-brief.md +4 -0
  187. package/templates/rules/effort-model.md +34 -31
  188. package/templates/rules/gate-and-review.md +1 -1
  189. package/templates/rules/merge-safety.md +9 -7
  190. package/templates/rules/naming-and-ids.md +20 -24
  191. package/templates/rules/plan-next.md +5 -5
  192. package/templates/skills/campaign/SKILL.md +2 -2
  193. package/scripts/lib/engine-adapter.sh +0 -93
package/bin/cckit CHANGED
@@ -1,119 +1,12 @@
1
1
  #!/usr/bin/env bash
2
2
  # cckit — the CLI dispatcher. A thin bash front-end over the git-mechanics bundle (scripts/lib).
3
- # Agent-agnostic: every verb runs from a shell; append --llm for machine-readable output.
3
+ # Agent-agnostic: every verb runs from a shell; append --json for machine-readable output.
4
4
  # Driven entirely from cckit.config.json — no org/repo is hardcoded. See AGENTS.md.
5
5
  #
6
- # Usage:
7
- # cckit resume: print the last session's resume-here handoff
8
- # cckit handoff "<note>" save a resume-here note for the next session
9
- # cckit install [bin-dir] symlink cckit onto your PATH (global install)
10
- # cckit init [<folder>] guided setup: detect the folder, ask, scaffold, then git + GitHub after
11
- # one confirmation (--yes with no terminal; --no-github = scaffold only;
12
- # --answers FILE, --recipe <id>, --database <id>, --public, --dry-run)
13
- # --adapter <claude|codex|both> selects the agent (default claude)
14
- # cckit start <issue> [slug] isolated worktree + branch for an issue
15
- # cckit pr <issue> <summary> [--base <branch>] commit + push + open the PR (--base: target <branch>, not the
16
- # integration branch; the push exports it as KIT_PR_BASE)
17
- # cckit hotfix <pr|sha> [--base B] cherry-pick a merged PR or commit onto B (default main):
18
- # worktree from origin/B, cherry-pick -x, push, PR `Cherry-pick of #N`
19
- # cckit close <issue> <summary> [--reason completed|not-planned|duplicate] [--duplicate-of N]
20
- # [--superseded-by N] close the issue with a reason + summary comment; board Done
21
- # cckit new [--role R --kind K --priority P --milestone M --blocked-by "#1" --body B|--body-file F] "<title>"
22
- # file ONE issue: labels + board (Todo) in one step (never raw gh issue create)
23
- # cckit task <new|list|next|start|finish|run|share|default> light tasks: work tracked in the project, no GitHub issue
24
- # task new [--priority pN --kind K --body B|--body-file F] "<title>" record a task (one file
25
- # under tasks/; a draft in this checkout until it is started or shared)
26
- # task list [--all] · task next every open task and its state · the one to take next
27
- # task start [--force] [--no-push] <id> worktree + branch light/<id>-<slug> from the base (alias: take)
28
- # task finish [<id>] "<summary>" [--all] mark it done on its branch, push, open the pull request;
29
- # the task is done when that PR merges (alias: done). --all also commits new files
30
- # task run <id> [--check "<cmd>"] [--max-iters N] [--max-seconds N] [--agent <cmd>] [--no-finish]
31
- # start the task, run ONE headless objective built from its title and notes, finish it and
32
- # print the review link. Gate: --check, else tasks.check in the config. Never merges
33
- # task share ["<summary>"] one pull request that adds this checkout's drafts to the base;
34
- # they list as shared until it merges. Re-run to retry a share whose push or PR failed
35
- # task default print light | issues: the project's default list (tasks.default).
36
- # With light, a bare `cckit next` prints what `cckit task next` prints
37
- # cckit merge [<pr>] [--merge|--rebase] merge the PR (squash by default; rebases on conflict), close
38
- # its issues, GC the branch, update the PR's base (develop or effort/<N>);
39
- # refuses an effort/* head: that PR merges with cckit effort close <N>
40
- # cckit contribute "<summary>" open a contribution PR to cckit, gated on scripts/check.sh
41
- # (from the cckit checkout or worktree you are in; else the installed one)
42
- # cckit sync [--llm] board state / what's unblocked
43
- # sync --json | --write | --cached [TTL] | --watch [SECS] | --plan
44
- # the dashboard layer: one JSON summary, cached atomically in
45
- # <git-common-dir>/kit-sync-cache.json (--llm stays TOON)
46
- # cckit plan [--llm] [--effort N] wave plan: deps-ordered, p0-first in a wave, file-disjoint (TOON --llm)
47
- # cckit plan-next [--llm] forward plan: current skills/verbs/rules/docs -> what to build next
48
- # cckit effort <new|chain|start|pr|close|plan> the effort lifecycle
49
- # effort new [--flow F --role R --kind K --priority p1 --goal G --scope S --for-agents A
50
- # --verification V --depends-on "#1,#2" --milestone M] "<name>" ["sub :: desc" …]
51
- # parent (4-section body + ctx/kind/priority/role/flow labels) + linted native sub-issues
52
- # effort chain <a> <b> [<c> …] linear order: b blocked_by a, c blocked_by b, + a
53
- # `Depends on #<predecessor>` line in each body. Idempotent; refuses a cycle.
54
- # effort start [--force] <slug|N> [slug] effort branch + worktree, WIP-limited: refuses a NEW
55
- # effort once effort.wipLimit (default 2) are already in progress — an `effort/<N>-<slug>`
56
- # branch exists locally or on origin (git ls-remote, not the cached refs/remotes;
57
- # EFFORT_WIP_REMOTE=0 or an unreachable origin uses the cache and still starts). Refuses
58
- # before writing anything; --force (or KIT_FORCE=1) starts anyway, at limit 0 too.
59
- # `cckit start <issue>` is not affected.
60
- # effort pr [<N>] [--summary S|--summary-file F] [--for-agents A|--for-agents-file F] [--title T] [--type T]
61
- # the ONE effort PR: inherits labels + milestone, rich body, board In Review. Title is a
62
- # Conventional Commit subject carrying the id — `type(scope): name [#N]` (scope = flow:
63
- # label, type = --type or the kind: label, default feat); refused before gh when it fails
64
- # commitlint. pr.titleStyle = issue-title keeps `[Role] [#N] name`, unchecked.
65
- # cckit orchestrate <a> <b> … run N flows in parallel worktrees (--runtime tmux|herdr)
66
- # cckit orchestrate --results how each worker ended: success | failure | interrupted
67
- # cckit autopilot [<a> …] unattended multi-flow: drive (or auto-pick) issues under a cap
68
- # cckit autopilot run [<issue>] --objective "<text>" ONE bounded headless objective on this branch
69
- # cckit watch [--merge] [--loop] captain: gate open PRs, squash-merge CLEAN, advance the wave
70
- # cckit next [--effort N] everyday helper: the unblocked set + how to start the top issue
71
- # + the weekly cadence (plan Monday, next daily, gc Friday)
72
- # cckit wave [--effort N] read open efforts, propose incoming waves: fan-out + captain drive
73
- # cckit msg <send|read|list> session mail across projects: steer a live session (--steer)
74
- # cckit claims live session claims: which session is working which issue (read-only)
75
- # cckit gc [--prune [--yes]] report (default) or prune merged + landed branches and worktrees
76
- # cckit cleanup [--yes] guided destructive sweep over the gc report (plan first)
77
- # cckit status where are we: board, next effort per flow, local undone work,
78
- # PRs waiting on a human, cleanup available, resume handoff
79
- # cckit scan [--llm] detect this repo's stack + kit state (JSON)
80
- # cckit debug [--check] <args> optional browser-debug via chrome-devtools-axi (auto-detected)
81
- # cckit encode-context stdin JSON -> compact TOON (uniform arrays; JSON fallback)
82
- # cckit render stdin markdown -> rich (glow on a TTY; verbatim when piped)
83
- # cckit doctor onboarding preflight (deps, gh auth, selected agent CLIs)
84
- # cckit add [<name>] [--set k=v] list integrations + modules; with a name, switch one on in the config
85
- # cckit page <mode|open|poll|reply|end|answer>
86
- # review pages: open a plan/decision/grill as a page (terminal
87
- # output where there is no browser), and record the answer
88
- # cckit update check whether this project is behind the installed cckit
89
- # cckit migrate reshuffle an old kit layout to the current one
90
- # cckit adopt record kit-shaped files a repo already has into the manifest
91
- # cckit digest <path|url> summarize a file or URL (local model)
92
- # cckit bench [run|report|…] doc-retrieval benchmark: score how well docs are found + used
93
- # cckit bench checkpoint <ver> record a benchmark run as a checkpoint of release <ver>
94
- # (checkpoints: list them · check <ver>: the release gate · page)
95
- # cckit bench verbs [--json] wall time + gh call count of the read-only verbs
96
- # (attach to a checkpoint: bench checkpoint <ver> --verbs <file>)
97
- # cckit release <ver> [--publish] cut a release (dry-run by default); refuses when <ver> has no
98
- # benchmark checkpoint or scores lower (--skip-bench-check overrides)
99
- # cckit version [--llm] the installed cckit version
100
- # cckit commands [--llm] list every verb (the command catalog)
101
- # cckit lib [--llm] [--all] list every scripts/lib helper: functions, purpose, error contract
102
- # cckit brief <issue> the delegation brief for an issue, from real state
103
- # cckit receipt <issue> … record/read one stage receipt (a worker's durable report)
104
- # cckit qa <up|ready> [--lane N] [--timeout S] launch the declared review stack on this lane's
105
- # ports; exit 0 only once every readiness probe answers
106
- # cckit qa open [--lane N] [--pr N] [--route /p] [--print] open the screen the change touched
107
- # (the PR body's `QA route:` line, else qa.route) on a usable lane
108
- # cckit qa stop [--lane N] [--force] stop the lane's stack — supervisors before listeners — and
109
- # exit 0 only when nothing listens on the lane's ports
110
- # cckit qa verdict [pass|fail] [--lane N] [--note T] [--shot F] record the verdict against the
111
- # reviewed commit (PR comment upserted, a fail mailed to the builder);
112
- # with no pass|fail, read it back: pass · fail · stale · none
113
- # cckit qa lanes [--llm] read-only table of every lane: branch, ports, up (listeners on
114
- # its ports), verdict (pass · fail · stale · none), worktree
115
- # cckit completions [bash|zsh] print a shell-completion script to source
116
- # cckit help
6
+ # Every verb, its question, a prompt to paste and its usage live in ONE table: scripts/lib/verbs.tsv
7
+ # (read through scripts/lib/verbs.sh). `cckit help` prints it grouped by question; `cckit commands
8
+ # --json` prints it as data; scripts/verbs-test.sh fails when this dispatcher's case labels, the CLI
9
+ # reference page, skills/routing.yaml or scripts/forge-report.sh drift from it.
117
10
  set -eu
118
11
 
119
12
  # Resolve this script through symlinks — Homebrew and scripts/install.sh link bin/cckit onto
@@ -153,22 +46,68 @@ source "$LIB/cckit-output.sh"
153
46
  # shellcheck source=/dev/null
154
47
  source "$LIB/ui.sh"
155
48
 
156
- usage() { sed -n '/^# Usage:/,/^[^#]/p' "$BIN/cckit" | sed '1d;$d;s/^# \{0,1\}//'; }
49
+ # The verb table (#555): help, the command catalog and completions read it.
50
+ # shellcheck source=/dev/null
51
+ source "$LIB/verbs.sh"
52
+ usage() { verbs_help; }
157
53
 
158
- # --llm flag → structured output (parsed by agents). Strip it from positional args, export a flag.
54
+ # --json → structured output (parsed by agents). Strip it from positional args, export a flag.
55
+ # `--llm` and `--output=json` are older spellings of the same flag and keep working (#588).
159
56
  CCKIT_OUTPUT="human"
57
+ _json_flag=0
160
58
  args=()
161
59
  for a in "$@"; do
162
60
  case "$a" in
163
61
  --llm|--output=json) CCKIT_OUTPUT="json" ;;
62
+ --json) _json_flag=1 ;;
164
63
  *) args+=("$a") ;;
165
64
  esac
166
65
  done
167
66
  set -- "${args[@]+"${args[@]}"}"
168
- export CCKIT_OUTPUT
169
67
 
170
68
  # Bare `cckit` (no verb) resumes the last session's handoff (locked behavior).
171
69
  cmd="${1:-resume}"; shift || true
70
+ # The verb name, for a forge refusal that names it (scripts/lib/forge.sh forge_need).
71
+ export CCKIT_VERB="$cmd"
72
+ # The first argument as typed, before an alias adds words in front of it: `cckit sync --help` is help.
73
+ _first_arg="${1:-}"
74
+
75
+ # An old verb name (a `kind=alias` row of scripts/lib/verbs.tsv) still works (#557): it prints a
76
+ # one-line notice on stderr and runs the verb it was renamed to. A target may carry words after the
77
+ # verb (`status --board`, `agent lib`, #588); they go in front of the typed arguments. CCKIT_VERB
78
+ # keeps the typed name, so a refusal names what the user ran. Aliases are never removed before 1.0.
79
+ if _alias_target="$(verbs_alias_target "$cmd")"; then
80
+ verbs_alias_notice "$cmd" "$_alias_target" >&2
81
+ # shellcheck disable=SC2086 # the target's words split on purpose: "status --board" → status, --board
82
+ set -- $_alias_target "$@"
83
+ cmd="$1"; shift
84
+ fi
85
+
86
+ # `--json` is the documented output flag. Three verbs own a `--json` of their own, with another
87
+ # shape, and receive it untouched: `commands --json` (the full catalog), `status --board --json`
88
+ # (the board as one document) and `bench … --json`. Everywhere else it means CCKIT_OUTPUT=json.
89
+ if [ "$_json_flag" = 1 ]; then
90
+ case "$cmd" in
91
+ commands|bench) set -- "$@" --json ;;
92
+ status) case " $* " in *" --board "*) set -- "$@" --json ;; *) CCKIT_OUTPUT="json" ;; esac ;;
93
+ *) CCKIT_OUTPUT="json" ;;
94
+ esac
95
+ fi
96
+ export CCKIT_OUTPUT
97
+
98
+ # `cckit <verb> --help` (#556): the dispatcher answers from the verb table before the verb runs, so
99
+ # every verb has help and none sees a --help it does not parse. A verb whose table row says
100
+ # ownhelp=yes then runs with that --help too, in a child, and its own text follows under "Details:".
101
+ # Help always exits 0: some verbs print their usage on --help with rc 2.
102
+ case "$_first_arg" in
103
+ -h|--help)
104
+ if [ -z "${_CCKIT_HELP_SHOWN:-}" ] && verbs_entry "$cmd"; then
105
+ [ "$(verbs_get "$cmd" 7)" = yes ] || exit 0
106
+ printf '\nDetails:\n'
107
+ _CCKIT_HELP_SHOWN=1 "$BIN/cckit" "$cmd" --help </dev/null || true
108
+ exit 0
109
+ fi ;;
110
+ esac
172
111
 
173
112
  case "$cmd" in
174
113
  version)
@@ -201,6 +140,13 @@ case "$cmd" in
201
140
  source "$LIB/role-identity.sh" 2>/dev/null || true
202
141
  fi
203
142
  effort_new "$@" ;;
143
+ sub)
144
+ if [ "${KIT_PROJECTS_V2:-}" = "true" ]; then
145
+ # shellcheck source=/dev/null
146
+ source "$LIB/gh-project.sh"; load_project_ids >/dev/null 2>&1 || true
147
+ fi
148
+ effort_sub "$@" ;;
149
+ retitle) effort_retitle "$@" ;;
204
150
  chain) effort_chain "$@" ;;
205
151
  start) effort_start "$@" ;;
206
152
  pr)
@@ -210,8 +156,35 @@ case "$cmd" in
210
156
  source "$LIB/role-identity.sh" 2>/dev/null || true
211
157
  effort_pr "$@" ;;
212
158
  close) effort_close "$@" ;;
213
- plan) source "$LIB/effort-plan.sh"; effort_plan "$@" ;;
214
- *) echo "cckit effort <new|chain|start|pr|close|plan>" >&2; exit 2 ;;
159
+ plan)
160
+ # One planning verb (#585). Bare: the session-fit view of the open efforts. `--issues`: the
161
+ # open issues in dependency waves (was `cckit plan`). `--wave`: the next wave as a fan-out
162
+ # brief plus the captain drive (was `cckit wave` / `copilot`). `--next`: what to build next,
163
+ # from what the kit already does (was `cckit plan-next`). The old names are alias rows.
164
+ case "${1:-}" in
165
+ --issues) shift
166
+ # shellcheck source=/dev/null
167
+ source "$LIB/plan-machine.sh"; plan_machine "$@" ;;
168
+ --wave) shift
169
+ # shellcheck source=/dev/null
170
+ source "$LIB/copilot.sh"; copilot_brief "$@" ;;
171
+ --next) shift
172
+ # shellcheck source=/dev/null
173
+ source "$LIB/plan-next.sh"; plan_next "$@" ;;
174
+ *)
175
+ # shellcheck source=/dev/null
176
+ source "$LIB/effort-plan.sh"; effort_plan "$@" ;;
177
+ esac ;;
178
+ sprint)
179
+ # One week, Monday to Monday, as a forge milestone (#570). A sub-verb, so the top-level verb
180
+ # count does not grow; `name` and `bounds` run on git alone.
181
+ # shellcheck source=/dev/null
182
+ source "$LIB/sprint.sh"; sprint_cli "$@" ;;
183
+ review)
184
+ # Each sub against its own `## Spec`, one verdict line per sub (#583). A read.
185
+ # shellcheck source=/dev/null
186
+ source "$LIB/effort-review.sh"; effort_review "$@" ;;
187
+ *) echo "cckit effort <new|sub|retitle|chain|start|pr|close|plan|sprint|review>" >&2; exit 2 ;;
215
188
  esac
216
189
  ;;
217
190
  start)
@@ -342,25 +315,6 @@ case "$cmd" in
342
315
  case "${1:-}" in -h|--help) echo 'cckit merge [<pr>] [--squash|--merge|--rebase] merge (squash by default; rebases on conflict), close linked issues, GC branch + worktree, update the PR base'; exit 0 ;; esac
343
316
  kto_task_pr_merge "$@"
344
317
  ;;
345
- sync) exec "$ROOT/scripts/task-sync.sh" "$@" ;;
346
- plan)
347
- # Wave plan over the board (deps-ordered, file-disjoint, session-fit). Runs in the invoking
348
- # project; needs config so KIT_REPO is set before plan-machine reads it.
349
- # shellcheck source=/dev/null
350
- source "$LIB/kit-config.sh" && load_kit_config
351
- # shellcheck source=/dev/null
352
- source "$LIB/plan-machine.sh"; plan_machine "$@"
353
- ;;
354
- plan-next)
355
- # Forward planner: introspect the CURRENT capability surface (skills/verbs/rules/docs) and
356
- # propose what to build next, grounded in what the kit can already do. Filesystem-only — config
357
- # is loaded for the project-root inference (KIT_CONFIG), then plan-next scans that root. Output
358
- # is HUMAN / orchestrator-facing only — never wired into a monitored model's context (#86).
359
- # shellcheck source=/dev/null
360
- source "$LIB/kit-config.sh" && load_kit_config 2>/dev/null || true
361
- # shellcheck source=/dev/null
362
- source "$LIB/plan-next.sh"; plan_next "$@"
363
- ;;
364
318
  cleanup)
365
319
  # ONE guided destructive sweep over the gc analysis: plan first, delete only the SAFE rows, and
366
320
  # only with --yes. Orphans, protected branches and stashes are surfaced and left alone.
@@ -443,15 +397,6 @@ case "$cmd" in
443
397
  # shellcheck source=/dev/null
444
398
  source "$LIB/next.sh"; next_issue "$@"
445
399
  ;;
446
- wave|copilot)
447
- # Read the open efforts and propose the incoming waves of work: emit the wave-0 Task-subagent
448
- # fan-out + the between-waves captain drive. (`copilot` is a hidden back-compat alias for `wave`.)
449
- # Runs in the invoking project; needs config so KIT_REPO is set before it reads it.
450
- # shellcheck source=/dev/null
451
- source "$LIB/kit-config.sh" && load_kit_config
452
- # shellcheck source=/dev/null
453
- source "$LIB/copilot.sh"; copilot_brief "$@"
454
- ;;
455
400
  watch)
456
401
  # Captain: gate open PRs, squash-merge the CLEAN ones, advance to the next wave. Runs in the
457
402
  # invoking project; needs config so KIT_REPO is set before captain reads it.
@@ -518,8 +463,6 @@ cckit bench verbs [--runs N] [--checkout <dir>] [--verb "<verb>"] [--json] (at
518
463
  esac
519
464
  ;;
520
465
  scan) source "$LIB/project-scan.sh"; project_scan "$@" ;;
521
- encode-context) source "$LIB/toon.sh"; toon_encode ;;
522
- render) source "$LIB/render.sh"; cckit_render ;;
523
466
  debug) exec "$ROOT/scripts/debug.sh" "$@" ;;
524
467
  contribute)
525
468
  # The cckit checkout containing cwd (a worktree, per the rules) wins over the installed one, so
@@ -529,7 +472,15 @@ cckit bench verbs [--runs N] [--checkout <dir>] [--verb "<verb>"] [--json] (at
529
472
  croot="$(contribute_root "$PWD" "$ROOT")"
530
473
  [ "$croot" = "$ROOT" ] || echo "contribute: using the checkout at $croot" >&2
531
474
  cd "$croot"; exec "$croot/scripts/contribute.sh" "$@" ;;
532
- status|ui) exec "$ROOT/scripts/status.sh" "$@" ;;
475
+ status)
476
+ # `--board` is the board view by role, what `cckit sync` printed before it folded in here (#588);
477
+ # every other form is the "where are we?" dashboard.
478
+ case " $* " in
479
+ *" --board "*)
480
+ board_args=(); for a in "$@"; do [ "$a" = --board ] || board_args+=("$a"); done
481
+ exec "$ROOT/scripts/task-sync.sh" "${board_args[@]+"${board_args[@]}"}" ;;
482
+ esac
483
+ exec "$ROOT/scripts/status.sh" "$@" ;;
533
484
  claims)
534
485
  # Live session claims (#384) — which session is working which issue. Read-only: a dead claim is
535
486
  # skipped here and reaped by the next `cckit start` on that issue, never by this verb.
@@ -546,18 +497,6 @@ cckit bench verbs [--runs N] [--checkout <dir>] [--verb "<verb>"] [--json] (at
546
497
  ;;
547
498
  resume) source "$LIB/handoff.sh"; handoff_read ;;
548
499
  handoff) source "$LIB/handoff.sh"; handoff_write "$@" ;;
549
- msg)
550
- # Session mail (#175) — pure git-local state (.cckit/mail at the root worktree), no config.
551
- source "$LIB/kit-msg.sh"
552
- sub="${1:-}"; shift || true
553
- case "$sub" in
554
- send) msg_send "$@" ;;
555
- read) msg_read "$@" ;;
556
- list) msg_list ;;
557
- hook-check) msg_hook_check "$@" ;;
558
- *) echo 'cckit msg <send|read|list|hook-check>' >&2; exit 2 ;;
559
- esac
560
- ;;
561
500
  install) exec "$ROOT/scripts/install.sh" "$@" ;;
562
501
  init)
563
502
  # init resolves the config from the folder it sets up. The KIT_CONFIG this dispatcher worked out
@@ -567,20 +506,13 @@ cckit bench verbs [--runs N] [--checkout <dir>] [--verb "<verb>"] [--json] (at
567
506
  [ -n "$_KIT_CONFIG_GIVEN" ] || unset KIT_CONFIG
568
507
  exec "$ROOT/scripts/init.sh" "$@" ;;
569
508
  commands)
570
- # The command catalog - verbs parsed from this dispatcher's own case labels (single source).
571
- verbs="$(grep -oE '^ [a-z][a-z|-]*\)' "$BIN/cckit" | sed 's/[) ]//g' | tr '|' '\n' | grep -vE '^(-|$)' | sort -u)"
509
+ # The command catalog, read from scripts/lib/verbs.tsv. `--json`: every verb, default and alias
510
+ # as an object (name, kind, target, group, needs, skill, question, prompt, usage). `--llm` keeps
511
+ # its old shape, a JSON array of names. Human: the names, space-separated (completions read it).
512
+ case " $* " in *" --json "*) verbs_json; exit 0 ;; esac
513
+ verbs="$(verbs_names | sort -u)"
572
514
  if cckit_is_json; then printf '%s\n' "$verbs" | jq -R . | jq -cs .; else printf '%s\n' "$verbs" | tr '\n' ' '; echo; fi
573
515
  ;;
574
- lib)
575
- # The HELPER catalog — the companion to `commands` (#222). `commands` lists the verbs; this
576
- # lists the library they are built from, so a helper like pr-evidence.sh is discoverable
577
- # without an `ls`. Filesystem-only; config is loaded purely for the project-root inference
578
- # (KIT_CONFIG), then it catalogs that project's scripts/lib, else cckit's own.
579
- # shellcheck source=/dev/null
580
- source "$LIB/kit-config.sh" && load_kit_config 2>/dev/null || true
581
- # shellcheck source=/dev/null
582
- source "$LIB/kit-lib.sh"; kit_lib "$@"
583
- ;;
584
516
  brief)
585
517
  # The delegation BRIEF for an issue, generated from real state (#221). The companion to `lib`:
586
518
  # `lib` says what helpers exist, this says which of them THIS issue's files sit on, where the
@@ -597,14 +529,46 @@ cckit bench verbs [--runs N] [--checkout <dir>] [--verb "<verb>"] [--json] (at
597
529
  CCKIT_ROOT="$ROOT" kit_brief "$@"
598
530
  ;;
599
531
 
600
- receipt)
601
- # One durable record per stage attempt (#322). The WORKER calls this itself: cckit never reads
602
- # pane output, because #326 requires that pane history — off by default, and able to hold
603
- # secrets — is never a dependency. The report arrives on stdin in the shape `cckit brief`'s
604
- # receipt contract asked for, so the prompt and this parser cannot drift apart.
605
- # shellcheck source=/dev/null
606
- source "$LIB/stage-receipt.sh"
607
- sr_cli "$@"
532
+ agent)
533
+ # The plumbing agents call and people rarely type (#588): each was a top-level verb and keeps
534
+ # its old name as an alias row of scripts/lib/verbs.tsv.
535
+ sub="${1:-}"; shift || true
536
+ case "$sub" in
537
+ lib)
538
+ # The HELPER catalog — the companion to `commands` (#222). `commands` lists the verbs; this
539
+ # lists the library they are built from, so a helper like pr-evidence.sh is discoverable
540
+ # without an `ls`. Filesystem-only; config is loaded purely for the project-root inference
541
+ # (KIT_CONFIG), then it catalogs that project's scripts/lib, else cckit's own.
542
+ # shellcheck source=/dev/null
543
+ source "$LIB/kit-config.sh" && load_kit_config 2>/dev/null || true
544
+ # shellcheck source=/dev/null
545
+ source "$LIB/kit-lib.sh"; kit_lib "$@"
546
+ ;;
547
+ receipt)
548
+ # One durable record per stage attempt (#322). The WORKER calls this itself: cckit never
549
+ # reads pane output, because #326 requires that pane history — off by default, and able to
550
+ # hold secrets — is never a dependency. The report arrives on stdin in the shape `cckit
551
+ # brief`'s receipt contract asked for, so the prompt and this parser cannot drift apart.
552
+ # shellcheck source=/dev/null
553
+ source "$LIB/stage-receipt.sh"
554
+ sr_cli "$@"
555
+ ;;
556
+ msg)
557
+ # Session mail (#175) — pure git-local state (.cckit/mail at the root worktree), no config.
558
+ source "$LIB/kit-msg.sh"
559
+ msub="${1:-}"; shift || true
560
+ case "$msub" in
561
+ send) msg_send "$@" ;;
562
+ read) msg_read "$@" ;;
563
+ list) msg_list ;;
564
+ hook-check) msg_hook_check "$@" ;;
565
+ *) echo 'cckit agent msg <send|read|list|hook-check>' >&2; exit 2 ;;
566
+ esac
567
+ ;;
568
+ encode-context) source "$LIB/toon.sh"; toon_encode ;;
569
+ render) source "$LIB/render.sh"; cckit_render ;;
570
+ *) echo 'cckit agent <lib|receipt|msg|encode-context|render>' >&2; exit 2 ;;
571
+ esac
608
572
  ;;
609
573
  qa)
610
574
  # The QA lane (#295): launch the stack command the project declared under `qa`, on this lane's
@@ -628,6 +592,12 @@ cckit bench verbs [--runs N] [--checkout <dir>] [--verb "<verb>"] [--json] (at
628
592
  *) echo "cckit completions [bash|zsh]" >&2; exit 2 ;;
629
593
  esac
630
594
  ;;
631
- help|--help|-h) usage ;;
595
+ help|--help|-h)
596
+ # `cckit help <verb>` is `cckit <verb> --help`.
597
+ if [ -n "${1:-}" ]; then
598
+ verbs_get "$1" 2 >/dev/null || { echo "cckit help: no verb '$1' — run 'cckit help'" >&2; exit 2; }
599
+ exec "$BIN/cckit" "$1" --help
600
+ fi
601
+ usage ;;
632
602
  *) echo "cckit: unknown command '$cmd' — run 'cckit help'" >&2; exit 2 ;;
633
603
  esac
package/cckit.config.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "./kit.config.schema.json",
3
- "kitVersion": "0.10.0",
3
+ "kitVersion": "0.12.0",
4
4
  "project": {
5
5
  "name": "cckit",
6
6
  "slug": "cckit",
@@ -28,9 +28,6 @@
28
28
  "enabled": false,
29
29
  "wing": "cckit"
30
30
  },
31
- "engine": {
32
- "mode": "off"
33
- },
34
31
  "captain": {
35
32
  "mergePolicy": {
36
33
  "requireChecks": true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeiemgi/cckit",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "private": false,
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "description": "cckit — a project operating system for coding agents (CLI + Claude Code plugin).",
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # advisor-test.sh — the kit-advisor skill (E547): the router stays short, every stage reference
4
+ # ends with the step report in its one order plus the trail command, and every `cckit` verb the
5
+ # skill names is one the kit has. Text checks only; no forge, no network.
6
+ # errors: strict — a test runner: rc 1 on any failed assertion
7
+ set -u
8
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
9
+ SK="$ROOT/skills/kit-advisor"
10
+ fail=0
11
+ ok() { echo "ok: $1"; }
12
+ bad() { echo "FAIL: $1"; fail=1; }
13
+ # shellcheck source=/dev/null
14
+ . "$ROOT/scripts/lib/kit-brief.sh"
15
+
16
+ ORDER='Status · Done · Waiting for a yes · Numbers · Failing or risky · Open questions · Next step'
17
+ # flat <file> — the file on one line, whitespace and markdown emphasis collapsed, so a sentence the
18
+ # editor wrapped still matches.
19
+ flat() { tr '\n' ' ' < "$1" | sed 's/\*\*//g; s/[[:space:]][[:space:]]*/ /g'; }
20
+
21
+ [ -f "$SK/SKILL.md" ] || { echo "FAIL: no skills/kit-advisor/SKILL.md"; exit 1; }
22
+ lines="$(wc -l < "$SK/SKILL.md" | tr -d ' ')"
23
+ if [ "$lines" -le 80 ]; then ok "SKILL.md is a router ($lines lines, at most 80)"; else bad "SKILL.md has $lines lines (at most 80)"; fi
24
+ case "$(flat "$SK/SKILL.md")" in *"$ORDER"*) ok "SKILL.md states the report order" ;; *) bad "SKILL.md lacks the report order" ;; esac
25
+
26
+ for stage in grill plan orchestrate review close; do
27
+ f="$SK/references/$stage.md"
28
+ [ -f "$f" ] || { bad "no references/$stage.md"; continue; }
29
+ grep -q "references/$stage.md" "$SK/SKILL.md" && ok "SKILL.md routes to $stage" || bad "SKILL.md does not route to $stage"
30
+ body="$(flat "$f")"
31
+ case "$body" in *"$ORDER"*) ok "$stage states the report order" ;; *) bad "$stage lacks the report order" ;; esac
32
+ case "$body" in *'cckit agent receipt <'*'--report .cckit/reports/'*) ok "$stage states the trail command" ;; *) bad "$stage lacks the trail command" ;; esac
33
+ case "$body" in *'references/step-report.md'*) ok "$stage points to the template" ;; *) bad "$stage does not point to step-report.md" ;; esac
34
+ done
35
+ case "$(flat "$SK/references/step-report.md")" in *"$ORDER"*) ok "the template states the order" ;; *) bad "the template lacks the order" ;; esac
36
+
37
+ # The template's seven headings, in order.
38
+ got="$(grep '^## ' "$SK/references/step-report.md" | sed -n '/^## Status$/,/^## Next step$/p' | sed 's/^## //' | paste -sd'|' -)"
39
+ want="$(printf '%s' "$ORDER" | sed 's/ · /|/g')"
40
+ [ "$got" = "$want" ] && ok "the template's headings follow the order" || bad "template headings '$got' != '$want'"
41
+
42
+ # Every `cckit <verb> [<sub>]` the skill names in code (a code line or a backtick span) resolves (an `effort` sub-verb against the dispatcher).
43
+ verbs="$(cat "$SK/SKILL.md" "$SK"/references/*.md | grep -oE '(^|`)cckit [a-z][a-z-]*( [a-z][a-z-]*)?' | sed 's/^`//; s/^cckit //' | sort -u)"
44
+ n=0
45
+ while IFS= read -r v; do
46
+ [ -n "$v" ] || continue
47
+ n=$((n + 1))
48
+ kit_brief_verb_ok "$v" || bad "the skill names an unknown verb: cckit $v"
49
+ done <<EOF_V
50
+ $verbs
51
+ EOF_V
52
+ [ "$n" -gt 5 ] && ok "every one of the $n verbs the skill names resolves" || bad "found only $n verbs in the skill"
53
+
54
+ [ "$fail" -eq 0 ] && echo "ALL OK (advisor)"
55
+ exit "$fail"
@@ -3,8 +3,9 @@
3
3
  # launch kinds, stopped by a failing check, a no-progress round, a kill mid-run (TERM and KILL) and
4
4
  # each configured limit, then resumed without a second PR or a second agent (E257.7, #264).
5
5
  #
6
- # Hermetic. `claude` and `codex` are stub scripts on PATH whose behaviour STUB_MODE selects, `gh` is
7
- # a stub that records every `pr create`, and origin is a bare repo in the temp dir. This proves what
6
+ # Hermetic. `claude` and `codex` are stub scripts on PATH whose behaviour STUB_MODE selects, the forge
7
+ # is the shared shim that records every REST request (a PR opens as `POST repos/…/pulls`), and origin
8
+ # is a bare repo in the temp dir. This proves what
8
9
  # cckit's code decides around an agent process; it does not prove either real agent behaves.
9
10
  # errors: strict — a test runner: rc 1 on any failed assertion
10
11
  # shellcheck shell=bash
@@ -75,24 +76,30 @@ STUB
75
76
  chmod +x "$TMP/bin/agent-stub"
76
77
  cp "$TMP/bin/agent-stub" "$TMP/bin/claude"; cp "$TMP/bin/agent-stub" "$TMP/bin/codex"
77
78
 
78
- cat > "$TMP/bin/gh" <<'STUB'
79
- #!/usr/bin/env bash
80
- case "$1 $2" in
81
- 'pr list') [ -f "$FX/pr.url" ] && cat "$FX/pr.url"; exit 0 ;;
82
- 'pr create') echo "create $*" >> "$FX/gh.log"
83
- echo "https://github.com/fixture/project/pull/41" | tee "$FX/pr.url" ;;
84
- 'issue view') echo '{"title":"thing","labels":[{"name":"kind:task"}],"milestone":null}' ;;
85
- *) echo "other $*" >> "$FX/gh.log"; exit 0 ;;
79
+ # The forge: the shared shim (test-forge-shim.sh) answers the REST API over a curl stand-in and logs
80
+ # every request to GH_LOG. The PR this run opens (#41) and the open-PR lookup that finds it again
81
+ # (`GET pulls?head=…`, answered from $FX/pr.url once a PR was opened) come from this fixture; the
82
+ # issue read (`GET issues/7`) is the shim's own, shaped by GH_TITLE and GH_LABELS.
83
+ # shellcheck source=/dev/null
84
+ . "$ROOT/scripts/lib/test-forge-shim.sh"; forge_shim_install "$TMP/bin"
85
+ export GH_LOG="$TMP/gh.log" GH_FIXTURE="$TMP/fixture.sh" GH_TOKEN=test-token CCKIT_FORGE=github
86
+ export GH_TITLE="thing" GH_LABELS='[{"name":"kind:task"}]'
87
+ # The lookup names the repo: autopilot-run.sh reads it from the origin URL and, when that is not a
88
+ # GitHub form (a local path here), from github.repo in the project config — never an empty repo.
89
+ cat > "$GH_FIXTURE" <<'STUB'
90
+ case "$method $ep" in
91
+ "GET repos/fixture/project/pulls") case "$path" in *head=*) if [ -f "$FX/pr.url" ]; then out="[{\"number\":41,\"html_url\":\"$(cat "$FX/pr.url")\"}]"; else out="[]"; fi ;; esac ;;
92
+ "POST repos/fixture/project/pulls") echo "https://github.com/fixture/project/pull/41" > "$FX/pr.url"
93
+ out='{"number":41,"html_url":"https://github.com/fixture/project/pull/41","user":{"login":"me"}}' ;;
86
94
  esac
87
95
  STUB
88
- chmod +x "$TMP/bin/gh"
89
96
  export PATH="$TMP/bin:$PATH"
90
97
 
91
98
  cd "$P" || exit 1
92
99
  run() { bash "$ROOT/scripts/autopilot.sh" run "$@" > "$TMP/out" 2>&1; }
93
100
  reason() { jq -r .reason "$STATE" 2>/dev/null; }
94
101
  field() { jq -r "$1" "$STATE" 2>/dev/null; }
95
- creates() { if [ -f "$TMP/gh.log" ]; then grep -c '^create ' "$TMP/gh.log"; else echo 0; fi; }
102
+ creates() { if [ -f "$TMP/gh.log" ]; then grep -c '^POST repos/fixture/project/pulls ' "$TMP/gh.log"; else echo 0; fi; }
96
103
  reset() { rm -rf "$TMP/state" "$TMP/rounds" "$TMP/done.flag" "$TMP/agent.pid" "$TMP/gh.log" "$TMP/pr.url"; }
97
104
  UNTIL="test -f '$TMP/done.flag'"
98
105
 
@@ -311,6 +318,7 @@ for agent in claude codex; do
311
318
  t "[$agent] a run with lost state still finishes" "$(reason)" "done"
312
319
  t "[$agent] and still opens no second PR" "$(creates)" "1"
313
320
  t "[$agent] it records the PR it found" "$(field .pr_url)" "https://github.com/fixture/project/pull/41"
321
+ t "[$agent] no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$TMP/gh.log")" "0"
314
322
  done
315
323
 
316
324
  # ── --record-skills: the skills each round loaded, from the CLI's events (#504) ─────────────────
@@ -53,6 +53,12 @@
53
53
  #
54
54
  # Not here, on purpose: merging. A run never merges and never closes an issue.
55
55
  # errors: strict — every stop is a state-file write plus the exit code above
56
+ # The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
57
+ if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
58
+ # shellcheck source=/dev/null
59
+ . "$(cd "$(dirname "$0")" && pwd)/lib/gh-rest.sh"
60
+ fi
61
+
56
62
  set -uo pipefail
57
63
 
58
64
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -360,7 +366,9 @@ publish() {
360
366
  if [ -n "$PR_URL" ]; then echo "autopilot run: PR already recorded - $PR_URL"; return 0; fi
361
367
  local existing
362
368
  # A read, so a run killed between `gh pr create` and the state write still finds its PR.
363
- existing="$(gh pr list --head "$BRANCH" --state open --json url --jq '.[0].url // ""' 2>/dev/null)" || existing=""
369
+ local repo; repo="$(forge_repo_from_git 2>/dev/null || true)"
370
+ [ -n "$repo" ] || repo="${KIT_REPO:-$(jq -r '.github.repo // empty' "${CFG:-/dev/null}" 2>/dev/null)}"
371
+ existing="$(gh_rest_pr_url_for_head "$repo" "$BRANCH" 2>/dev/null)" || existing=""
364
372
  if [ -n "$existing" ]; then
365
373
  PR_URL="$existing"; echo "autopilot run: the branch already has an open PR - $PR_URL"; return 0
366
374
  fi