@jeiemgi/cckit 0.11.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 (121) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +45 -41
  3. package/README.md +39 -29
  4. package/bin/cckit +111 -70
  5. package/cckit.config.json +1 -1
  6. package/package.json +1 -1
  7. package/scripts/advisor-test.sh +55 -0
  8. package/scripts/autopilot.sh +4 -4
  9. package/scripts/capture-project-ids.sh +16 -0
  10. package/scripts/check.sh +6 -0
  11. package/scripts/content-skills-test.sh +1 -1
  12. package/scripts/copilot-loop-test.sh +8 -8
  13. package/scripts/force-push-fence-test.sh +44 -0
  14. package/scripts/force-push-fence.baseline +1 -0
  15. package/scripts/force-push-fence.sh +51 -0
  16. package/scripts/init.sh +2 -2
  17. package/scripts/instruction-budget-baseline.txt +1 -1
  18. package/scripts/kit-doctor-test.sh +5 -0
  19. package/scripts/kit-doctor.sh +96 -2
  20. package/scripts/lib/agent-resolve-test.sh +2 -0
  21. package/scripts/lib/agent-resolve.sh +3 -2
  22. package/scripts/lib/board-view.sh +3 -3
  23. package/scripts/lib/captain.sh +1 -1
  24. package/scripts/lib/copilot-test.sh +4 -4
  25. package/scripts/lib/copilot.sh +13 -13
  26. package/scripts/lib/effort-close-subs-test.sh +96 -0
  27. package/scripts/lib/effort-dispatch-test.sh +2 -2
  28. package/scripts/lib/effort-ops-test.sh +98 -9
  29. package/scripts/lib/effort-ops.sh +390 -63
  30. package/scripts/lib/effort-parity-test.sh +37 -31
  31. package/scripts/lib/effort-plan.sh +3 -3
  32. package/scripts/lib/effort-review-test.sh +107 -0
  33. package/scripts/lib/effort-review.sh +93 -0
  34. package/scripts/lib/effort-slug-test.sh +4 -0
  35. package/scripts/lib/effort-slug.sh +5 -4
  36. package/scripts/lib/effort.sh +47 -74
  37. package/scripts/lib/forge-github.sh +18 -7
  38. package/scripts/lib/gh-board-add-test.sh +118 -0
  39. package/scripts/lib/gh-project-test.sh +115 -0
  40. package/scripts/lib/gh-project.sh +128 -6
  41. package/scripts/lib/gh-rest-test.sh +12 -8
  42. package/scripts/lib/gh-rest.sh +189 -15
  43. package/scripts/lib/git-core-test.sh +2 -2
  44. package/scripts/lib/grill-record-test.sh +49 -0
  45. package/scripts/lib/grill-record.sh +88 -0
  46. package/scripts/lib/handoff.sh +1 -1
  47. package/scripts/lib/kit-brief-test.sh +29 -0
  48. package/scripts/lib/kit-brief.sh +91 -6
  49. package/scripts/lib/kit-lib-test.sh +1 -1
  50. package/scripts/lib/kit-lib.sh +7 -7
  51. package/scripts/lib/kit-msg.sh +3 -3
  52. package/scripts/lib/kit-status.sh +1 -1
  53. package/scripts/lib/kit-task-ops-test.sh +17 -0
  54. package/scripts/lib/kit-task-ops.sh +73 -22
  55. package/scripts/lib/kto-task-new-test.sh +18 -0
  56. package/scripts/lib/kto-task-pr-merge-test.sh +44 -0
  57. package/scripts/lib/kto-task-pr-test.sh +3 -3
  58. package/scripts/lib/light-task.sh +16 -1
  59. package/scripts/lib/loose-issues.sh +65 -0
  60. package/scripts/lib/naming-test.sh +112 -0
  61. package/scripts/lib/naming-verbs-test.sh +126 -0
  62. package/scripts/lib/naming.sh +172 -0
  63. package/scripts/lib/next-test.sh +1 -1
  64. package/scripts/lib/next.sh +6 -6
  65. package/scripts/lib/plan-machine.sh +9 -9
  66. package/scripts/lib/plan-next.sh +4 -4
  67. package/scripts/lib/qa-lane.sh +1 -1
  68. package/scripts/lib/spec-lint-test.sh +63 -0
  69. package/scripts/lib/spec-lint.sh +95 -0
  70. package/scripts/lib/sprint-test.sh +96 -0
  71. package/scripts/lib/sprint.sh +216 -0
  72. package/scripts/lib/stage-receipt-test.sh +132 -0
  73. package/scripts/lib/stage-receipt.sh +184 -5
  74. package/scripts/lib/test-forge-shim.sh +2 -1
  75. package/scripts/lib/verbs.sh +1 -1
  76. package/scripts/lib/verbs.tsv +17 -15
  77. package/scripts/lib/worker-brief-test.sh +1 -1
  78. package/scripts/lib/worker-brief.sh +1 -1
  79. package/scripts/lib/worktree-start.sh +42 -1
  80. package/scripts/loose-issues-test.sh +102 -0
  81. package/scripts/loose-issues.baseline +5 -0
  82. package/scripts/night-grant.sh +1 -1
  83. package/scripts/portable-test.sh +1 -1
  84. package/scripts/status-test.sh +1 -1
  85. package/scripts/status.sh +4 -4
  86. package/scripts/task-sync-test.sh +34 -0
  87. package/scripts/task-sync.sh +81 -1
  88. package/scripts/terms-check.sh +1 -1
  89. package/scripts/verbs-ratchet-test.sh +6 -1
  90. package/scripts/verbs-test.sh +4 -4
  91. package/scripts/verbs.baseline +1 -1
  92. package/skills/kit-add/SKILL.md +1 -1
  93. package/skills/kit-advisor/SKILL.md +75 -0
  94. package/skills/kit-advisor/references/close.md +53 -0
  95. package/skills/kit-advisor/references/grill.md +69 -0
  96. package/skills/kit-advisor/references/orchestrate.md +56 -0
  97. package/skills/kit-advisor/references/plan.md +64 -0
  98. package/skills/kit-advisor/references/review.md +47 -0
  99. package/skills/kit-advisor/references/step-report.md +61 -0
  100. package/skills/kit-autopilot/SKILL.md +1 -1
  101. package/skills/kit-cleanup/SKILL.md +2 -2
  102. package/skills/kit-effort-close/SKILL.md +16 -8
  103. package/skills/kit-effort-new/SKILL.md +11 -8
  104. package/skills/kit-effort-pr/SKILL.md +7 -7
  105. package/skills/kit-next/SKILL.md +7 -7
  106. package/skills/kit-plan-next/SKILL.md +10 -11
  107. package/skills/kit-status/SKILL.md +5 -5
  108. package/skills/kit-task-pr-auto/SKILL.md +1 -1
  109. package/skills/kit-task-pr-merge/SKILL.md +3 -3
  110. package/skills/kit-task-sync/SKILL.md +2 -0
  111. package/skills/routing.yaml +5 -0
  112. package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
  113. package/templates/instructions.md.tmpl +3 -3
  114. package/templates/rules/authoring.md +7 -3
  115. package/templates/rules/delegation-brief.md +4 -0
  116. package/templates/rules/effort-model.md +34 -31
  117. package/templates/rules/gate-and-review.md +1 -1
  118. package/templates/rules/merge-safety.md +9 -7
  119. package/templates/rules/naming-and-ids.md +20 -24
  120. package/templates/rules/plan-next.md +5 -5
  121. package/templates/skills/campaign/SKILL.md +2 -2
@@ -278,6 +278,138 @@ unset GH_FIXTURE SR_REPO
278
278
  rm -rf "$ghtmp"
279
279
 
280
280
 
281
+ # ── the agent trail (#572): a step report becomes one short comment on its issue ───────────────
282
+ # The forge shim records every request with its JSON body. Synthetic leak words only: the real
283
+ # list is private and never appears in a test.
284
+ trtmp="$(mktemp -d)"; mkdir -p "$trtmp/bin"
285
+ forge_shim_install "$trtmp/bin"
286
+ export GH_LOG="$trtmp/gh.log" GH_COMMENTS="$trtmp/comments.txt" GH_FIXTURE="$trtmp/fixture"
287
+ export GH_TOKEN=test-token CCKIT_FORGE=github SR_REPO=o/r
288
+ printf 'zorblaxian\n# a comment line\nquuxcorp\n' > "$trtmp/leak-words"
289
+ CCKIT_LEAK_WORDS_FILE="$trtmp/leak-words"; export CCKIT_LEAK_WORDS_FILE; unset CCKIT_LEAK_WORDS
290
+ : > "$GH_LOG"; : > "$GH_COMMENTS"
291
+ cat > "$GH_FIXTURE" <<'FIX'
292
+ case "$method $ep" in
293
+ "GET repos/o/r/issues/"*"/comments")
294
+ out="$(jq -R 'split("\t") | {id: (.[0] | tonumber), body: (.[1] | fromjson)}' "$GH_COMMENTS" | jq -sc .)" ;;
295
+ "PATCH repos/o/r/issues/comments/"*) out="{\"id\":${ep##*/}}" ;;
296
+ esac
297
+ FIX
298
+ PATH="$trtmp/bin:$OLDPATH"; export PATH
299
+ # The suite keeps CCKIT_RECEIPT_REMOTE=0 so nothing else can post; the trail cases turn it on over
300
+ # the shim, and one case checks that off means not posted.
301
+ CCKIT_RECEIPT_REMOTE=1; export CCKIT_RECEIPT_REMOTE
302
+ TRAIL_POST='^POST repos/o/r/issues/77/comments '
303
+
304
+ REP="$trtmp/2026-11-24-1200-build-77.md"
305
+ cat > "$REP" <<'EOF'
306
+ # Build 77
307
+
308
+ ## Status
309
+ Built and gated; PR open.
310
+ Second status line.
311
+
312
+ ## Done
313
+ - one commit, see https://github.com/o/r/pull/12.
314
+ - the issue https://github.com/o/r/issues/77
315
+
316
+ ## Waiting for a yes
317
+ - merge the PR
318
+
319
+ ## Numbers
320
+ check.sh 120 passed
321
+
322
+ ## Next step
323
+ review
324
+ EOF
325
+
326
+ out="$(CCKIT_RECEIPT_REMOTE=0 sr_cli 77 --report "$REP" 2>&1)"
327
+ yes "CCKIT_RECEIPT_REMOTE=0 says the comment was not posted" "$out" "the comment was NOT posted to #77"
328
+ t "CCKIT_RECEIPT_REMOTE=0 makes no request" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
329
+
330
+ out="$(sr_cli 77 --report "$REP" 2>&1)"; rc=$?
331
+ t "a report posts with rc 0" "$rc" "0"
332
+ yes "the verb says it posted" "$out" "trail comment posted on #77"
333
+ posted="$(grep "$TRAIL_POST" "$GH_LOG")"
334
+ t "exactly one comment was posted" "$(printf '%s\n' "$posted" | grep -c .)" "1"
335
+ yes "the comment carries the Status head" "$posted" "Built and gated; PR open."
336
+ yes "the comment carries the PR URL, trailing dot dropped" "$posted" "- https://github.com/o/r/pull/12\\n"
337
+ yes "the comment carries the issue URL" "$posted" "https://github.com/o/r/issues/77"
338
+ yes "the comment carries the waiting items" "$posted" "- merge the PR"
339
+ yes "the comment names the report file" "$posted" 'Full report: `2026-11-24-1200-build-77.md`'
340
+ yes "the comment carries its trail marker" "$posted" "cckit:trail report=2026-11-24-1200-build-77.md"
341
+ case "$posted" in *"check.sh 120 passed"*) t "the Numbers section stays in the full report" "present" "absent" ;;
342
+ *) t "the Numbers section stays in the full report" "absent" "absent" ;; esac
343
+ case "$posted" in *"$trtmp"*) t "no absolute path reaches the comment" "present" "absent" ;;
344
+ *) t "no absolute path reaches the comment" "absent" "absent" ;; esac
345
+
346
+ # The same report again edits its comment instead of appending a second.
347
+ printf '%s\t%s\n' 901 '"<!-- cckit:trail report=2026-11-24-1200-build-77.md --> earlier"' > "$GH_COMMENTS"
348
+ : > "$GH_LOG"
349
+ yes "a second post of one report edits" "$(sr_cli 77 --report "$REP" 2>&1)" "updated"
350
+ yes "and it PATCHed the existing comment" "$(cat "$GH_LOG")" "PATCH repos/o/r/issues/comments/901 "
351
+ t "it did not also create one" "$(grep -c "$TRAIL_POST" "$GH_LOG" || true)" "0"
352
+ : > "$GH_COMMENTS"
353
+
354
+ # No waiting items reads "none".
355
+ NOW="$trtmp/no-wait.md"; printf '## Status\nAll done.\n\n## Done\n- x\n' > "$NOW"
356
+ yes "no Waiting section reads none" "$(sr_cli 77 --report "$NOW" --dry-run 2>/dev/null)" "$(printf '**Waiting for a yes**\nnone')"
357
+
358
+ # Truncation: a long report is cut to the cap, says so, and still names the file last.
359
+ LONG="$trtmp/long.md"
360
+ { printf '## Status\nlong one\n\n## Waiting for a yes\n'; i=0; while [ "$i" -lt 80 ]; do printf -- '- decision number %s needs an answer from the owner\n' "$i"; i=$((i+1)); done; } > "$LONG"
361
+ long="$(sr_cli 77 --report "$LONG" --dry-run 2>/dev/null)"
362
+ t "a long comment stays within the cap" "$([ "${#long}" -le 1500 ] && echo yes || echo "no (${#long})")" "yes"
363
+ yes "a cut comment says it was truncated" "$long" "Truncated to 1500 characters"
364
+ t "a cut comment's last line names the file" "$(printf '%s\n' "$long" | tail -n 1)" 'Full report: `long.md` (local, not on GitHub)'
365
+
366
+ # A leak-list word refuses the whole comment, posts nothing, and does not echo the word.
367
+ LEAK="$trtmp/leak.md"; printf '## Status\nShipped the QuuxCorp import.\n' > "$LEAK"
368
+ : > "$GH_LOG"
369
+ out="$(sr_cli 77 --report "$LEAK" 2>&1)"; rc=$?
370
+ t "a leak word is refused with rc 1" "$rc" "1"
371
+ yes "the refusal names the leak list" "$out" "private leak list"
372
+ case "$out" in *[Qq]uux[Cc]orp*) t "the refusal does not echo the word" "echoed" "hidden" ;;
373
+ *) t "the refusal does not echo the word" "hidden" "hidden" ;; esac
374
+ t "a refused comment posts nothing" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
375
+ sr_cli 77 --report "$LEAK" --dry-run >/dev/null 2>&1; t "dry run refuses a leak word too" "$?" "1"
376
+
377
+ # An absolute home path is refused the same way.
378
+ HOMEP="$trtmp/home.md"; printf '## Status\nlog at /Users/alice/work/log.txt\n' > "$HOMEP"
379
+ out="$(sr_cli 77 --report "$HOMEP" 2>&1)"; rc=$?
380
+ t "a home path is refused with rc 1" "$rc" "1"
381
+ yes "the refusal names the home path" "$out" "absolute home path"
382
+ t "a home-path comment posts nothing" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
383
+
384
+ # --dry-run prints and writes nothing.
385
+ : > "$GH_LOG"
386
+ dry="$(sr_cli 77 --report "$REP" --dry-run 2>/dev/null)"; rc=$?
387
+ t "dry run exits 0" "$rc" "0"
388
+ yes "dry run prints the comment" "$dry" "Built and gated; PR open."
389
+ t "dry run makes no request" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
390
+
391
+ # No forge: the comment is not posted, the verb says so and prints it.
392
+ : > "$GH_LOG"
393
+ out="$(unset _FORGE_LOADED; CCKIT_FORGE=none sr_cli 77 --report "$REP" 2>&1)"; rc=$?
394
+ t "no forge exits 0" "$rc" "0"
395
+ yes "no forge says the comment was not posted" "$out" "the comment was NOT posted to #77"
396
+ yes "no forge still prints the comment" "$out" "Built and gated; PR open."
397
+ t "no forge makes no request" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
398
+
399
+ # Usage errors.
400
+ NOST="$trtmp/nostatus.md"; printf '## Done\n- x\n' > "$NOST"
401
+ sr_cli 77 --report "$NOST" --dry-run >/dev/null 2>&1; t "a report with no Status is refused" "$?" "2"
402
+ sr_cli 77 --report "$trtmp/missing.md" >/dev/null 2>&1; t "a missing report is refused" "$?" "2"
403
+ sr_cli 77 --report </dev/null >/dev/null 2>&1; t "--report with no file is refused" "$?" "2"
404
+ sr_cli 77 --stage build --dry-run </dev/null >/dev/null 2>&1; t "--dry-run without --report is refused" "$?" "2"
405
+ yes "the help names the trail mode" "$(sr_cli --help 2>&1)" "--report <file> [--dry-run]"
406
+
407
+ t "no gh subcommand ran in the trail cases" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG" || true)" "0"
408
+ PATH="$OLDPATH"; export PATH
409
+ unset GH_FIXTURE SR_REPO CCKIT_LEAK_WORDS_FILE
410
+ CCKIT_RECEIPT_REMOTE=0; export CCKIT_RECEIPT_REMOTE
411
+ rm -rf "$trtmp"
412
+
281
413
  rm -rf "$(dirname "$KIT_STATE_DIR")"
282
414
  [ "$fail" -eq 0 ] && echo "ALL OK" || echo "stage receipt: FAILURES"
283
415
  exit "$fail"
@@ -242,7 +242,7 @@ _sr_same_as_latest() {
242
242
  >/dev/null 2>&1
243
243
  }
244
244
 
245
- # sr_cli <args> — the `cckit receipt` verb.
245
+ # sr_cli <args> — `cckit agent receipt` (old name `cckit receipt`).
246
246
  #
247
247
  # The WORKER records its own receipt. Nothing else can: cckit does not read pane output, and #326
248
248
  # is explicit that pane history is off by default, may hold secrets, and must never be required.
@@ -257,27 +257,34 @@ sr_cli() {
257
257
  # Every local gets a value: `local n stage` leaves them UNSET, not empty, and a caller running
258
258
  # under `set -u` (bin/cckit does) dies on the first reference instead of reaching the refusal.
259
259
  local sub="${1:-}" n="" stage="" attempt="" prof="" tier="" src="" perms="" report="" remote=1
260
+ local trail="" dry=""
260
261
  case "$sub" in
261
262
  list) shift; sr_list "${1:-}"; return $? ;;
262
263
  show)
263
264
  shift
264
- [ -n "${1:-}" ] && [ -n "${2:-}" ] || { echo "cckit receipt show <issue> <stage> [<attempt>]" >&2; return 2; }
265
+ [ -n "${1:-}" ] && [ -n "${2:-}" ] || { echo "cckit agent receipt show <issue> <stage> [<attempt>]" >&2; return 2; }
265
266
  if [ -n "${3:-}" ]; then sr_read "$1" "$2" "$3"; else sr_latest "$1" "$2"; fi
266
267
  return $?
267
268
  ;;
268
269
  ''|-h|--help)
269
270
  cat >&2 <<'EOF'
270
- cckit receipt <issue> --stage <stage> [--attempt <n>] [--profile <p>] [--tier <t>]
271
+ cckit agent receipt <issue> --stage <stage> [--attempt <n>] [--profile <p>] [--tier <t>]
271
272
  [--source <where>] [--permissions <policy>] [--no-remote]
272
273
  < the report on stdin
273
- cckit receipt list [<issue>]
274
- cckit receipt show <issue> <stage> [<attempt>]
274
+ cckit agent receipt <issue> --report <file> [--dry-run]
275
+ cckit agent receipt list [<issue>]
276
+ cckit agent receipt show <issue> <stage> [<attempt>]
275
277
 
276
278
  Stages: build review design docs qa none
277
279
  Outcomes: merged pr-open closed-no-op blocked
278
280
 
279
281
  The receipt is written locally AND mirrored as a comment on the issue. --no-remote (or
280
282
  CCKIT_RECEIPT_REMOTE=0) writes the file and posts nothing; a remote failure only warns.
283
+
284
+ --report posts the trail comment for a step report (sections: Status · Done · Waiting for a
285
+ yes · Numbers · Failing or risky · Open questions · Next step): the Status head, the report's
286
+ URLs, the Waiting for a yes items and the report's file name, capped at 1500 characters. It
287
+ is refused when it would carry a private leak-list word or a home path. --dry-run prints it.
281
288
  EOF
282
289
  return 2
283
290
  ;;
@@ -300,9 +307,19 @@ EOF
300
307
  --permissions) perms="$2"; shift 2 ;;
301
308
  --permissions=*) perms="${1#*=}"; shift ;;
302
309
  --no-remote) remote=0; shift ;;
310
+ --report) [ -n "${2:-}" ] || { echo "cckit receipt: --report needs a file" >&2; return 2; }
311
+ trail="$2"; shift 2 ;;
312
+ --report=*) trail="${1#*=}"; shift ;;
313
+ --dry-run) dry=--dry-run; shift ;;
303
314
  *) echo "cckit receipt: unknown arg '$1'" >&2; return 2 ;;
304
315
  esac
305
316
  done
317
+ # The trail mode (#572): post a short comment from a step report file. No stdin, no receipt.
318
+ if [ -n "$trail" ]; then
319
+ sr_trail_post "$n" "$trail" "$dry"
320
+ return $?
321
+ fi
322
+ [ -z "$dry" ] || { echo "cckit receipt: --dry-run goes with --report <file>" >&2; return 2; }
306
323
  [ -n "$stage" ] || { echo "cckit receipt: --stage is required (one of: $SR_STAGES)" >&2; return 2; }
307
324
  _sr_in "$stage" "$SR_STAGES" || { echo "cckit receipt: stage '$stage' is not one of: $SR_STAGES" >&2; return 2; }
308
325
  _sr_need_jq || return $?
@@ -451,3 +468,165 @@ sr_mirror() {
451
468
  fi
452
469
  rm -f "$body"; _sr_mirror_warn post-failed "could not comment on #$n"; return 0
453
470
  }
471
+
472
+ # ── the agent trail (#572) ──────────────────────────────────────────────────────────────────────
473
+ # A step report is the long form of what a worker did, kept in `.cckit/reports/`, which is local and
474
+ # gitignored. Agents working in parallel cannot read each other's `.cckit/`, but they can all read
475
+ # the issue. So `cckit receipt <issue> --report <file>` posts a SHORT comment built from the report:
476
+ # the head of its `## Status`, the bare URLs it names, its `## Waiting for a yes` items, and the
477
+ # report's file name, so the trail is readable on GitHub and the full report stays local.
478
+ #
479
+ # The report format, section by section: Status · Done · Waiting for a yes · Numbers · Failing or
480
+ # risky · Open questions · Next step. Only `## Status` is required; the comment reads two sections.
481
+ #
482
+ # Nothing private reaches GitHub. The comment is checked against the leak fence's own word list
483
+ # (scripts/lib/leak-fence.sh: the built-in word, `.cckit/leak-words`, `CCKIT_LEAK_WORDS`) and
484
+ # against absolute home paths, and refused whole on a hit — the matched text is never printed.
485
+ #
486
+ # UPSERT keyed by the report's file name, on the same marker pattern as the receipt mirror: posting
487
+ # one report twice edits its comment instead of appending a second.
488
+ #
489
+ # sr_trail_body <report> <shown-path> the comment, marker first (pure; no forge)
490
+ # sr_trail_check <file> rc 1 naming the reason when the comment must not be posted
491
+ # sr_trail_post <issue> <report> [--dry-run] build, check, upsert; rc 0 posted or printed
492
+
493
+ SR_TRAIL_MAX="${SR_TRAIL_MAX:-1500}"
494
+ SR_TRAIL_STATUS_LINES=6
495
+ SR_TRAIL_MARKER_PREFIX='<!-- cckit:trail report='
496
+
497
+ command -v leak_fence_patterns >/dev/null 2>&1 || . "$_sr_dir/leak-fence.sh"
498
+
499
+ # _sr_trail_section <file> <heading> — the lines under `## <heading>` up to the next `## `, blank
500
+ # lines dropped. Case-insensitive on the heading, so `## Waiting for a Yes` still reads.
501
+ _sr_trail_section() {
502
+ awk -v want="$2" '
503
+ /^##[[:space:]]/ {
504
+ h = $0; sub(/^##[[:space:]]+/, "", h); sub(/[[:space:]]+$/, "", h)
505
+ on = (tolower(h) == tolower(want)); next
506
+ }
507
+ on && NF { print }
508
+ ' "$1"
509
+ }
510
+
511
+ # _sr_trail_shown_path <report> — the report's path as the comment names it: relative to the
512
+ # checkout or the primary checkout when it lives inside one, else the bare file name. Never
513
+ # absolute, so no home directory reaches the comment through it.
514
+ _sr_trail_shown_path() {
515
+ local f="$1" dir base abs root
516
+ dir="$(cd "$(dirname "$f")" 2>/dev/null && pwd -P)" || { basename "$f"; return 0; }
517
+ base="$(basename "$f")"; abs="$dir/$base"
518
+ for root in "$(git rev-parse --show-toplevel 2>/dev/null)" "$(_kit_state_root)"; do
519
+ [ -n "$root" ] || continue
520
+ root="$(cd "$root" 2>/dev/null && pwd -P)" || continue
521
+ case "$abs" in "$root"/*) printf '%s\n' "${abs#"$root"/}"; return 0 ;; esac
522
+ done
523
+ printf '%s\n' "$base"
524
+ }
525
+
526
+ _sr_trail_marker() { printf '%s%s -->' "$SR_TRAIL_MARKER_PREFIX" "$1"; }
527
+
528
+ # sr_trail_body <report> <shown-path> — the comment. rc 2 when the report has no `## Status`.
529
+ # Capped at $SR_TRAIL_MAX characters; a cut comment says so, and its last line still names the file.
530
+ sr_trail_body() {
531
+ local f="$1" shown="$2" status urls waiting body footer note line
532
+ [ -f "$f" ] || { echo "cckit receipt: no report at '$f'" >&2; return 2; }
533
+ status="$(_sr_trail_section "$f" "Status" | sed -n "1,${SR_TRAIL_STATUS_LINES}p")"
534
+ [ -n "$status" ] || { echo "cckit receipt: the report has no '## Status' section — nothing to post" >&2; return 2; }
535
+ urls="$(grep -oE 'https?://[^][[:space:]<>()`"'"'"']+' "$f" | sed -E 's/[.,;:]+$//' | awk '!seen[$0]++')"
536
+ waiting="$(_sr_trail_section "$f" "Waiting for a yes")"
537
+
538
+ body="$(_sr_trail_marker "$(basename "$f")")"
539
+ body="$body"$'\n\n'"**cckit step report** · \`$(basename "$f")\`"
540
+ body="$body"$'\n\n'"**Status**"
541
+ while IFS= read -r line; do body="$body"$'\n'"> ${line:0:300}"; done <<S
542
+ $status
543
+ S
544
+ body="$body"$'\n\n'"**Links**"
545
+ if [ -n "$urls" ]; then
546
+ while IFS= read -r line; do body="$body"$'\n'"- $line"; done <<S
547
+ $urls
548
+ S
549
+ else
550
+ body="$body"$'\n'"none"
551
+ fi
552
+ body="$body"$'\n\n'"**Waiting for a yes**"
553
+ if [ -n "$waiting" ]; then
554
+ while IFS= read -r line; do
555
+ case "$line" in [-*]\ *) ;; *) line="- $line" ;; esac
556
+ body="$body"$'\n'"${line:0:300}"
557
+ done <<S
558
+ $waiting
559
+ S
560
+ else
561
+ body="$body"$'\n'"none"
562
+ fi
563
+
564
+ footer="Full report: \`$shown\` (local, not on GitHub)"
565
+ if [ "$(( ${#body} + ${#footer} + 2 ))" -gt "$SR_TRAIL_MAX" ]; then
566
+ note="_Truncated to $SR_TRAIL_MAX characters; the rest is in the full report._"
567
+ body="${body:0:$(( SR_TRAIL_MAX - ${#footer} - ${#note} - 6 ))}"
568
+ body="${body%$'\n'*}"$'\n\n'"$note"
569
+ fi
570
+ printf '%s\n\n%s\n' "$body" "$footer"
571
+ }
572
+
573
+ # sr_trail_check <file> — rc 0 when the comment may be posted. rc 1 names the reason on stderr and
574
+ # never the matched text: the leak fence's patterns, an absolute home path, or a pattern set that
575
+ # does not compile (a check that cannot run is not a clean check).
576
+ sr_trail_check() {
577
+ local f="$1" pat rc
578
+ pat="$(leak_fence_patterns | paste -sd'|' -)"
579
+ grep -iqE "$pat" "$f" 2>/dev/null; rc=$?
580
+ if [ "$rc" -eq 0 ]; then
581
+ echo "cckit receipt: refused — the comment would carry a word from the private leak list (the word is not shown)" >&2
582
+ return 1
583
+ elif [ "$rc" -ge 2 ]; then
584
+ echo "cckit receipt: refused — the leak list did not compile, so the comment could not be checked" >&2
585
+ return 1
586
+ fi
587
+ if grep -qE '(^|[^[:alnum:]_.])/(Users|home)/[^/[:space:]]+' "$f" \
588
+ || { [ "${#HOME}" -gt 1 ] && grep -qF "$HOME" "$f"; }; then
589
+ echo "cckit receipt: refused — the comment would carry an absolute home path" >&2
590
+ return 1
591
+ fi
592
+ return 0
593
+ }
594
+
595
+ # sr_trail_post <issue> <report> [--dry-run] — build, check, then upsert the comment. rc 0 posted,
596
+ # printed (--dry-run), or not posted for want of a forge or with CCKIT_RECEIPT_REMOTE off (said,
597
+ # and printed); 1 a refusal or a
598
+ # forge failure; 2 a usage error or a report with no Status.
599
+ sr_trail_post() {
600
+ local n="$1" f="$2" dry="${3:-}" tmp repo marker listing ids id rc
601
+ tmp="$(mktemp 2>/dev/null)" || { echo "cckit receipt: no temp file" >&2; return 1; }
602
+ sr_trail_body "$f" "$(_sr_trail_shown_path "$f")" > "$tmp" || { rc=$?; rm -f "$tmp"; return "$rc"; }
603
+ sr_trail_check "$tmp" || { rm -f "$tmp"; echo "cckit receipt: nothing was posted to #$n" >&2; return 1; }
604
+
605
+ if [ "$dry" = "--dry-run" ]; then
606
+ echo "cckit receipt: dry run — the comment for #$n, not posted:" >&2
607
+ cat "$tmp"; rm -f "$tmp"; return 0
608
+ fi
609
+ case "${CCKIT_RECEIPT_REMOTE:-1}" in
610
+ 0|false|no|off|FALSE|NO|OFF)
611
+ echo "cckit receipt: CCKIT_RECEIPT_REMOTE is off — the comment was NOT posted to #$n; here it is:" >&2
612
+ cat "$tmp"; rm -f "$tmp"; return 0 ;;
613
+ esac
614
+ if ! forge_available; then
615
+ echo "cckit receipt: no forge is configured — the comment was NOT posted to #$n; here it is:" >&2
616
+ cat "$tmp"; rm -f "$tmp"; return 0
617
+ fi
618
+
619
+ repo="$(_sr_repo)"; [ -n "$repo" ] || repo="$(forge_repo_from_git 2>/dev/null)" || repo=""
620
+ [ -n "$repo" ] || { rm -f "$tmp"; echo "cckit receipt: no repo (set github.repo or an origin remote) — nothing posted" >&2; return 1; }
621
+ marker="$(_sr_trail_marker "$(basename "$f")")"
622
+ listing="$(_sr_mirror_list "$repo" "$n")" || {
623
+ rm -f "$tmp"; echo "cckit receipt: could not read the comments on #$n — not posting (a blind post would duplicate)" >&2; return 1; }
624
+ ids="$(printf '%s\n' "$listing" | _sr_mirror_match_id "$marker")" || ids=""
625
+ if [ -n "$ids" ]; then
626
+ id="$(printf '%s\n' "$ids" | sed -n 1p)"
627
+ _sr_mirror_edit "$repo" "$id" "$tmp" || { rm -f "$tmp"; echo "cckit receipt: could not edit comment $id on #$n" >&2; return 1; }
628
+ rm -f "$tmp"; echo "cckit receipt: trail comment on #$n updated"; return 0
629
+ fi
630
+ _sr_mirror_create "$repo" "$n" "$tmp" || { rm -f "$tmp"; echo "cckit receipt: could not comment on #$n" >&2; return 1; }
631
+ rm -f "$tmp"; echo "cckit receipt: trail comment posted on #$n"
632
+ }
@@ -15,6 +15,7 @@
15
15
  # GH_GRAPHQL the JSON every POST graphql answers (default {"data":{}})
16
16
  # GH_DIFF the diff every `GET pulls/<n>` with the diff Accept header answers
17
17
  # GH_SHIM_TOKEN what `gh auth token` prints; empty = not signed in (tests usually set GH_TOKEN)
18
+ # GH_HDR_LOG one line per extra request header (not Accept, not Authorization)
18
19
  #
19
20
  # A test that needs other fixtures sets GH_FIXTURE=<file>: a bash snippet sourced by the shim after
20
21
  # its own case, which may set `out` and `code` for the current `$method $path`.
@@ -28,7 +29,7 @@ method=GET; url=""; body=""; accept=""; hdr=""
28
29
  while [ $# -gt 0 ]; do
29
30
  case "$1" in
30
31
  -X) method="$2"; shift 2 ;;
31
- -H) case "$2" in Accept:*) accept="$2" ;; esac; shift 2 ;;
32
+ -H) case "$2" in Accept:*) accept="$2" ;; Authorization:*) ;; *) [ -n "${GH_HDR_LOG:-}" ] && printf '%s\n' "$2" >> "$GH_HDR_LOG" ;; esac; shift 2 ;;
32
33
  --data-binary) body="$2"; shift 2 ;;
33
34
  -D) hdr="$2"; shift 2 ;;
34
35
  -w|-o|-m|--max-time|--retry|--retry-delay) shift 2 ;;
@@ -10,7 +10,7 @@
10
10
  # verbs_count the number of `verb` rows (the ratchet in scripts/verbs.baseline)
11
11
  # verbs_help the grouped help: one line per verb under each group's question
12
12
  # verbs_entry <name> usage, question, prompt, needs and skill of one verb; rc 1 if none
13
- # verbs_alias_target <name> the verb an old name runs; rc 1 when <name> is not an alias
13
+ # verbs_alias_target <name> the verb an old name runs, with any words after it; rc 1 when not an alias
14
14
  # verbs_alias_notice <old> <new> the one-line notice an old name prints on stderr (#557)
15
15
  # verbs_json every non-group row as a JSON array of objects (no jq needed)
16
16
  # verbs_reference_md the CLI reference page's generated block: one table per group
@@ -11,7 +11,7 @@
11
11
  # scripts/verbs.baseline (it may only go down)
12
12
  # default what bare `cckit` runs; never typed
13
13
  # alias an old name; the dispatcher prints a one-line notice and runs <target>
14
- # 3 target alias: the verb it runs · every other kind: -
14
+ # 3 target alias: the verb it runs, optionally followed by words (`agent lib`) · every other kind: -
15
15
  # 4 group the group id the verb is listed under in `cckit help` (- for group and alias rows)
16
16
  # 5 needs git runs on git alone
17
17
  # forge reads or writes the forge (GitHub) when one is configured
@@ -25,7 +25,7 @@
25
25
  # Rows are listed in the order `cckit help` prints them: each group, then its verbs.
26
26
 
27
27
  git group - - - - - How do I take one change from a branch to merged? - -
28
- start verb - git forge kit-task-start no How do I start work on an issue without touching my main checkout? Start the issue I pick in its own worktree. cckit start [--force] <issue> [slug]
28
+ start verb - git forge kit-task-start no How do I start work on an issue without touching my main checkout? Start the issue I pick in its own worktree. cckit start [--force] <issue|E<n>|E<n>.<step>> [slug]
29
29
  pr verb - git forge kit-task-pr no How do I open the pull request for this issue? Commit this work and open its pull request. cckit pr <issue> "<summary>" ["<commit-msg>"] [--base <branch>]
30
30
  merge verb - git forge kit-task-pr-merge no Can this pull request land, and what does landing clean up? Merge this branch's pull request once its gate is green, and clean up the branch. cckit merge [<pr>] [--squash|--merge|--rebase]
31
31
  close verb - git forge kit-task-close no How do I close an issue that no pull request closed? Close the issue I name, with a one-line summary of why. cckit close <issue> ["<summary>"] [--reason completed|not-planned|duplicate] [--duplicate-of N] [--superseded-by N]
@@ -33,25 +33,19 @@ hotfix verb - git forge - yes How do I carry one merged fix to the release branc
33
33
  task verb - git forge - yes How do I track work in the project itself, without a GitHub issue? Record this as a light task, then show me the task list. cckit task new [--priority p0|p1|p2|p3] [--kind K] [--body B|--body-file F] "<title>"\ncckit task list [--all] · cckit task next\ncckit task start [--force] [--no-push] <id>\ncckit task finish [<id>] "<summary>" [--all]\ncckit task run <id> [--check "<cmd>"] [--max-iters N] [--max-seconds N] [--agent <cmd>] [--no-finish]\ncckit task share ["<summary>"] · cckit task default
34
34
 
35
35
  where group - - - - - Where are we, and what comes next? - -
36
- status verb - where forge kit-status no Where are we? Where are we? Show me what is undone, what waits on me and what can be cleaned up. cckit status
37
- sync verb - where forge kit-task-sync no What is on the board, by role, and what is blocked? Sync the board and show me what is ready. cckit sync [--role <name>] [--milestone <label>] [--plan]\ncckit sync --json | --write | --cached [TTL] | --watch [SECS]
36
+ status verb - where forge kit-status no Where are we, and what is on the board? Where are we? Show me what is undone, what waits on me and what can be cleaned up. cckit status [--json]\ncckit status --board [--role <name>] [--milestone <label>] [--plan]\ncckit status --board --json | --write | --cached [TTL] | --watch [SECS]
38
37
  next verb - where forge kit-next no What should I pick up next? Show me what is unblocked and how to start the top item; I will pick. cckit next [--effort N]
39
- plan verb - where forge - no In what order can the open issues run? Plan the open issues into waves and show me the first wave. cckit plan [--effort N]
40
- plan-next verb - where git kit-plan-next yes Given what the kit already does, what should we build next? Inventory what the kit can do and propose what to build next. cckit plan-next
41
- wave verb - where forge kit-next no Which waves of work can start from the open efforts? Read the open efforts and propose the next wave of work. cckit wave [--effort N] [--adapter <claude|codex|both>]
42
38
  claims verb - where git - no Which session is working on which issue? Show me which live session holds which issue. cckit claims
43
39
  handoff verb - where git - no How do I leave the next session a note? Save a handoff note: what is pending, the next step, the references. cckit handoff "<note>"
44
40
  resume default - where git - no Where did the last session stop? Read the last handoff and pick up where it stopped. cckit
45
41
 
46
42
  work group - - - - - How do I plan the work and run it? - -
47
43
  new verb - work forge kit-task-new no How do I track a new piece of work as an issue? File an issue for this, with its labels, and put it on the board. cckit new [--role R --kind K --priority P --milestone M --plan L --blocked-by "#1" --body B|--body-file F] "<title>"
48
- effort verb - work forge kit-effort-new no How do I scope, start, open and close a piece of work with several parts? Scope this goal as an effort with sub-issues, show it to me, then start it. cckit effort new [--flow F --role R --kind K --priority P --goal G --scope S --for-agents A --verification V --depends-on "#1,#2" --milestone M] "<name>" ["sub :: desc" …]\ncckit effort chain <a> <b> [<c> …]\ncckit effort start [--force] <slug|N> [slug]\ncckit effort pr [<N>] [--summary S|--summary-file F] [--for-agents A|--for-agents-file F] [--title T] [--type T]\ncckit effort close <N>\ncckit effort plan
44
+ effort verb - work forge kit-effort-new no How do I scope, start, open and close a piece of work with several parts? Scope this goal as an effort with sub-issues, show it to me, then start it. cckit effort new --spec T|--spec-file F [--grilling T|--grilling-file F] [--sprint[=YYYY-MM-DD]] [--flow F --role R --kind K --priority P --goal G --scope S --for-agents A --verification V --depends-on "#1,#2" --milestone M] "<name>" ["sub :: desc" …]\ncckit effort sub <N> "<name>" [--kind K] [--body B] [--spec T]\ncckit effort retitle [<N>] [--apply]\ncckit effort chain <a> <b> [<c> …]\ncckit effort start [--force] <slug|N> [slug]\ncckit effort pr [<N>] [--summary S|--summary-file F] [--for-agents A|--for-agents-file F] [--title T] [--type T]\ncckit effort close <N> [--no-spec-check]\ncckit effort plan\ncckit effort plan --issues [--effort N] [--cap N]\ncckit effort plan --wave [--effort N] [--adapter <claude|codex|both>]\ncckit effort plan --next\ncckit effort sprint <name|bounds|open|list|close> [--goal G] [--date D]\ncckit effort review <N> [--branch B]
49
45
  orchestrate verb - work forge - yes How do I run several issues at once, each in its own worktree? Run the issues I pick in parallel worktrees; show me the dry run first. cckit orchestrate <issues…> [--dry-run] [--cap N] [--agent A|--profile P] [--runtime tmux|herdr]\ncckit orchestrate --results [--session=<s>] [--wait <secs>]
50
46
  autopilot verb - work forge kit-autopilot yes How do I run approved work unattended, under a cap? Run the unblocked work unattended under a cap of two; show me the dry run first. cckit autopilot [<issues…>] [--cap N] [--dry-run]\ncckit autopilot run [<issue>] --objective "<text>" [--until "<cmd>"] [--check "<cmd>"]
51
47
  watch verb - work forge - no Which open pull requests can merge now, and what is the next wave? Gate the open pull requests and tell me which are clean to merge. cckit watch [--merge] [--loop]
52
- brief verb - work forge - no What does an agent need to know before it works an issue? Write the delegation brief for the issue I pick. cckit brief <issue>
53
- receipt verb - work forge - yes How does a worker record what one stage did? Record this stage's receipt on its issue. cckit receipt <issue> --stage <s> [--no-remote]\ncckit receipt list [<issue>] · cckit receipt show <issue> <stage> [<attempt>]
54
- msg verb - work git - no How do I tell another live session something? Send the other live session a message about what I just changed. cckit msg <send|read|list|hook-check>
48
+ brief verb - work forge - no What does an agent need to know before it works an issue? Write the delegation brief for the issue I pick. cckit brief <issue> [--skills a,b] [--verbs 'x,effort start']
55
49
 
56
50
  clean group - - - - - What can be cleaned up? - -
57
51
  gc verb - clean forge kit-gc no Which branches and worktrees can go? Show me which branches and worktrees can be deleted, and why. cckit gc [--prune [--yes]]
@@ -80,11 +74,19 @@ version verb - setup git - no Which cckit is installed? Which cckit version is i
80
74
  catalog group - - - - - What does cckit offer, and what is it built from? - -
81
75
  help verb - catalog git - no What can cckit do? List the cckit verbs by the question each one answers. cckit help [<verb>]
82
76
  commands verb - catalog git - no Which verbs exist? List every cckit verb with the question it answers. cckit commands [--json]
83
- lib verb - catalog git - yes Which helper already does this? Find the cckit helper that already does this before writing one. cckit lib [--all] [--reasons] [--root <dir>]
77
+ agent verb - catalog forge - no Which plumbing does an agent call: helpers, receipts, session mail, TOON, rendering? Find the cckit helper that already does this before writing one. cckit agent lib [--all] [--reasons] [--root <dir>]\ncckit agent receipt <issue> --stage <s> [--no-remote]\ncckit agent receipt <issue> --report <file> [--dry-run]\ncckit agent receipt list [<issue>] · cckit agent receipt show <issue> <stage> [<attempt>]\ncckit agent msg <send|read|list|hook-check>\ncckit agent encode-context < data.json\ncckit agent render < notes.md
84
78
  scan verb - catalog git - no What stack is this repo, and what kit state does it have? Scan this repo's stack and kit state. cckit scan
85
- encode-context verb - catalog git - no How do I hand a subagent JSON in fewer tokens? Encode this JSON as TOON before you hand it to the subagent. cckit encode-context < data.json
86
- render verb - catalog git - no How do I read markdown rendered in the terminal? Render this markdown in the terminal. cckit render < notes.md
87
79
 
88
80
  # Old names. Each runs its target after a one-line notice on stderr; none is removed before 1.0.
89
- copilot alias wave - forge - - - - -
81
+ # A target may carry words after the verb; they go in front of the typed arguments (#588).
82
+ copilot alias effort plan --wave - forge - - - - -
83
+ plan alias effort plan --issues - forge - - - - -
84
+ plan-next alias effort plan --next - git - - - - -
85
+ wave alias effort plan --wave - forge - - - - -
90
86
  ui alias status - forge - - - - -
87
+ sync alias status --board - forge - - - - -
88
+ lib alias agent lib - git - - - - -
89
+ encode-context alias agent encode-context - git - - - - -
90
+ render alias agent render - git - - - - -
91
+ receipt alias agent receipt - forge - - - - -
92
+ msg alias agent msg - git - - - - -
@@ -55,7 +55,7 @@ yes "the receipt contract names the PR verb" "$rc" "cckit pr 41"
55
55
  yes "the receipt contract names the no-op close" "$rc" "cckit close 41"
56
56
  # The contract must name the verb that PERSISTS it (#322). A prompt that only asks the worker to
57
57
  # "report" leaves the record in the pane, which is what the receipt exists to replace.
58
- yes "the receipt contract names the recording verb" "$rc" "cckit receipt 41 --stage"
58
+ yes "the receipt contract names the recording verb" "$rc" "cckit agent receipt 41 --stage"
59
59
  yes "the receipt contract says a re-run is safe" "$rc" "rewrites its own attempt"
60
60
 
61
61
  # ── unbounded: everything survives ─────────────────────────────────────────────────────────────
@@ -49,7 +49,7 @@ If no change is needed, close the issue yourself with the reason:
49
49
 
50
50
  Then RECORD your receipt — this is the only durable record of the run, and your pane is not one:
51
51
 
52
- cckit receipt $num --stage <your stage> <<'RECEIPT'
52
+ cckit agent receipt $num --stage <your stage> <<'RECEIPT'
53
53
  outcome: merged | pr-open | closed-no-op | blocked
54
54
  url: <PR or issue URL>
55
55
  gate: pass | fail — <the failing check, if any>
@@ -4,7 +4,8 @@
4
4
  # Family 1 of kit-engine-boundary.md (rule #1/#2): one bash home for the op, consumed by the
5
5
  # kit-task-start skill, scripts/orchestrate.sh, and `kit task start`. No second implementation.
6
6
  #
7
- # wt_start [--force] <issue-number> [slug-override]
7
+ # wt_start [--force] <issue-number|E<n>|E<n>.<step>> [slug-override]
8
+ # A token resolves first: E<n> is issue n, E<n>.<step> the effort's sub at that step.
8
9
  # Refuses (rc 1, before any fetch / branch / worktree) when another LIVE session already holds
9
10
  # the issue's claim in <git-common-dir>/kit-sessions (session-registry.sh). `--force` or
10
11
  # KIT_FORCE=1 starts anyway and takes the claim over.
@@ -57,6 +58,42 @@ _wt_kind_prefix() {
57
58
 
58
59
  WT_START_REPO="${WT_START_REPO:-${KIT_REPO:-}}"
59
60
 
61
+ # The token parser (naming.sh, E546.1): `start E545` / `start E545.1` name an effort or a sub.
62
+ if ! command -v naming_token_parse >/dev/null 2>&1; then
63
+ _wt_naming="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/naming.sh"
64
+ # shellcheck source=/dev/null
65
+ [ -f "$_wt_naming" ] && . "$_wt_naming"
66
+ unset _wt_naming
67
+ fi
68
+
69
+ # _wt_resolve_token <token> — the issue number a token names (rules/naming-and-ids.md). E<n> is
70
+ # issue n. E<n>.<step> reads effort n's native sub-issues and takes the one titled [E<n>.<step>]
71
+ # (or the legacy [Effort <n>] <step> · ), else the sub at position <step>. rc 1, with the reason on
72
+ # stderr, when no sub matches or the sub-issues cannot be read.
73
+ _wt_resolve_token() {
74
+ local tok="$1" parsed n s subs hit
75
+ parsed="$(naming_token_parse "$tok")" || { echo "wt_start: '$tok' is not an E<n> or E<n>.<step> token" >&2; return 1; }
76
+ n="${parsed%% *}"; s=""
77
+ case "$parsed" in *" "*) s="${parsed#* }" ;; esac
78
+ if [ -z "$s" ]; then printf '%s' "$n"; return 0; fi
79
+ if ! forge_available; then
80
+ echo "wt_start: $tok is step $s of effort $n; resolving it reads the effort's sub-issues and no forge is configured — pass the sub's issue number" >&2
81
+ return 1
82
+ fi
83
+ subs="$(forge_rest "repos/$WT_START_REPO/issues/$n/sub_issues" -X GET -f per_page=100 \
84
+ --jq '.[] | "\(.number)\t\(.title // "")"' 2>/dev/null)" \
85
+ || { echo "wt_start: could not read the sub-issues of effort $n" >&2; return 1; }
86
+ hit="$(printf '%s\n' "$subs" | awk -F'\t' -v t="[E$n.$s] " -v l="[Effort $n] $s " \
87
+ 'index($2, t) == 1 || index($2, l) == 1 { print $1; exit }')"
88
+ [ -n "$hit" ] || hit="$(printf '%s\n' "$subs" | awk -F'\t' -v s="$s" 'NF && ++i == s { print $1; exit }')"
89
+ if [ -z "$hit" ]; then
90
+ echo "wt_start: $tok not found — effort $n has no sub titled [E$n.$s] and fewer than $s sub-issues" >&2
91
+ return 1
92
+ fi
93
+ echo "[$tok] → #$hit" >&2
94
+ printf '%s' "$hit"
95
+ }
96
+
60
97
  # _wt_set_port <app-env-file> <port> <issue-num> — append a per-worktree dev PORT to an app's
61
98
  # .env.local, but only where one exists (i.e. the app is locally runnable). Idempotent: an existing
62
99
  # PORT= line wins.
@@ -617,6 +654,10 @@ wt_start() {
617
654
  esac
618
655
  done
619
656
  [[ -n "$num" ]] || { echo "wt_start: issue number required" >&2; return 1; }
657
+ # An E<n> / E<n>.<step> token resolves to its issue number before anything else runs.
658
+ case "$num" in
659
+ [Ee][0-9]*) num="$(_wt_resolve_token "$num")" || return 1 ;;
660
+ esac
620
661
 
621
662
  root="$(git worktree list --porcelain | awk '/^worktree / && !hit {print $2; hit=1}')"
622
663
  [[ -n "$root" ]] || { echo "wt_start: not in a git repo" >&2; return 1; }