@jeiemgi/cckit 0.5.0 → 0.7.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 (144) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +34 -3
  3. package/README.md +95 -6
  4. package/bin/cckit +90 -3
  5. package/cckit.config.json +7 -2
  6. package/kit.config.schema.json +26 -1
  7. package/package.json +1 -1
  8. package/profiles/automation.json +2 -1
  9. package/profiles/content.json +2 -1
  10. package/profiles/minimal.json +2 -1
  11. package/profiles/research.json +2 -1
  12. package/profiles/software.json +2 -1
  13. package/scripts/benchmark/benchmark-test.sh +83 -0
  14. package/scripts/benchmark/gate.sh +55 -0
  15. package/scripts/benchmark/lib/bench-common.sh +70 -0
  16. package/scripts/benchmark/lib/model.sh +116 -0
  17. package/scripts/benchmark/report.sh +105 -0
  18. package/scripts/benchmark/run-quality.sh +102 -0
  19. package/scripts/benchmark/run.sh +166 -0
  20. package/scripts/benchmark/stop-check.sh +83 -0
  21. package/scripts/commitlint-test.sh +58 -0
  22. package/scripts/init.sh +57 -1
  23. package/scripts/kit-self-update.sh +55 -0
  24. package/scripts/lib/board-view-test.sh +1 -0
  25. package/scripts/lib/board-view.sh +1 -0
  26. package/scripts/lib/captain-test.sh +62 -0
  27. package/scripts/lib/captain.sh +105 -17
  28. package/scripts/lib/cckit-output.sh +1 -0
  29. package/scripts/lib/commitlint.sh +54 -0
  30. package/scripts/lib/config-path-test.sh +1 -0
  31. package/scripts/lib/config-path.sh +1 -0
  32. package/scripts/lib/copilot-test.sh +1 -0
  33. package/scripts/lib/copilot.sh +1 -0
  34. package/scripts/lib/effort-dispatch-test.sh +10 -0
  35. package/scripts/lib/effort-flows-test.sh +1 -0
  36. package/scripts/lib/effort-metrics-test.sh +1 -0
  37. package/scripts/lib/effort-metrics.sh +1 -0
  38. package/scripts/lib/effort-ops-test.sh +360 -0
  39. package/scripts/lib/effort-ops.sh +372 -16
  40. package/scripts/lib/effort-parity-test.sh +1 -0
  41. package/scripts/lib/effort-plan.sh +1 -0
  42. package/scripts/lib/effort-slug-test.sh +32 -0
  43. package/scripts/lib/effort-slug.sh +72 -8
  44. package/scripts/lib/effort.sh +1 -0
  45. package/scripts/lib/engine-adapter.sh +1 -0
  46. package/scripts/lib/errors-header-test.sh +86 -0
  47. package/scripts/lib/gh-log.sh +1 -0
  48. package/scripts/lib/gh-project-test.sh +1 -0
  49. package/scripts/lib/gh-project.sh +1 -0
  50. package/scripts/lib/git-remote-test.sh +1 -0
  51. package/scripts/lib/git-remote.sh +1 -0
  52. package/scripts/lib/handoff.sh +23 -2
  53. package/scripts/lib/kit-brief-test.sh +292 -0
  54. package/scripts/lib/kit-brief.sh +376 -0
  55. package/scripts/lib/kit-cli-test.sh +1 -0
  56. package/scripts/lib/kit-cli.sh +1 -0
  57. package/scripts/lib/kit-config-resolve.sh +1 -0
  58. package/scripts/lib/kit-config-test.sh +14 -0
  59. package/scripts/lib/kit-config.sh +7 -0
  60. package/scripts/lib/kit-engine-test.sh +1 -0
  61. package/scripts/lib/kit-events.sh +1 -0
  62. package/scripts/lib/kit-gc-test.sh +125 -0
  63. package/scripts/lib/kit-gc.sh +193 -5
  64. package/scripts/lib/kit-interview-test.sh +1 -0
  65. package/scripts/lib/kit-interview.sh +1 -0
  66. package/scripts/lib/kit-lib-test.sh +226 -0
  67. package/scripts/lib/kit-lib.sh +308 -0
  68. package/scripts/lib/kit-local.sh +1 -0
  69. package/scripts/lib/kit-manifest.sh +1 -0
  70. package/scripts/lib/kit-mode-test.sh +1 -0
  71. package/scripts/lib/kit-mode.sh +1 -0
  72. package/scripts/lib/kit-msg-test.sh +1 -0
  73. package/scripts/lib/kit-msg.sh +1 -0
  74. package/scripts/lib/kit-operate.sh +1 -0
  75. package/scripts/lib/kit-profile-test.sh +1 -0
  76. package/scripts/lib/kit-profile.sh +1 -0
  77. package/scripts/lib/kit-state-test.sh +89 -0
  78. package/scripts/lib/kit-state.sh +61 -0
  79. package/scripts/lib/kit-status-test.sh +233 -0
  80. package/scripts/lib/kit-status.sh +415 -0
  81. package/scripts/lib/kit-task-ops-test.sh +22 -0
  82. package/scripts/lib/kit-task-ops.sh +51 -2
  83. package/scripts/lib/next.sh +1 -0
  84. package/scripts/lib/plan-machine-test.sh +54 -0
  85. package/scripts/lib/plan-machine.sh +86 -25
  86. package/scripts/lib/plan-next-test.sh +1 -0
  87. package/scripts/lib/plan-next.sh +1 -0
  88. package/scripts/lib/pr-evidence-test.sh +259 -0
  89. package/scripts/lib/pr-evidence.sh +220 -35
  90. package/scripts/lib/project-scan.sh +1 -0
  91. package/scripts/lib/react-detect.sh +1 -0
  92. package/scripts/lib/render-test.sh +1 -0
  93. package/scripts/lib/render.sh +1 -0
  94. package/scripts/lib/role-identity.sh +1 -0
  95. package/scripts/lib/secret-guard.sh +21 -1
  96. package/scripts/lib/toon.sh +1 -0
  97. package/scripts/lib/ui.sh +1 -0
  98. package/scripts/lib/version-bump-test.sh +1 -0
  99. package/scripts/lib/version-bump.sh +1 -0
  100. package/scripts/lib/worktree-bootstrap-test.sh +220 -0
  101. package/scripts/lib/worktree-issue-test.sh +15 -1
  102. package/scripts/lib/worktree-issue.sh +23 -8
  103. package/scripts/lib/worktree-start.sh +191 -7
  104. package/scripts/lib/zsh-safety-test.sh +10 -0
  105. package/scripts/orchestrate.sh +8 -1
  106. package/scripts/portable-test.sh +13 -2
  107. package/scripts/self-install-test.sh +282 -0
  108. package/scripts/setup-labels.sh +1 -0
  109. package/scripts/status.sh +68 -40
  110. package/scripts/task-sync.sh +13 -0
  111. package/scripts/ux-a11y-scan.sh +96 -0
  112. package/scripts/ux-ds-audit.sh +146 -0
  113. package/scripts/ux-graph-scan.sh +188 -0
  114. package/skills/kit-autopilot/SKILL.md +6 -1
  115. package/skills/kit-cleanup/SKILL.md +83 -0
  116. package/skills/kit-effort-close/SKILL.md +3 -0
  117. package/skills/kit-effort-new/SKILL.md +7 -0
  118. package/skills/kit-effort-start/SKILL.md +39 -4
  119. package/skills/kit-gc/SKILL.md +19 -0
  120. package/skills/kit-next/SKILL.md +5 -0
  121. package/skills/kit-status/SKILL.md +92 -0
  122. package/skills/kit-task-start/SKILL.md +7 -1
  123. package/skills/kit-ux-audit/SKILL.md +241 -0
  124. package/skills/kit-ux-audit/references/a11y.md +79 -0
  125. package/skills/kit-ux-audit/references/consistency.md +106 -0
  126. package/skills/kit-ux-audit/references/graph-model.md +92 -0
  127. package/skills/kit-ux-audit/references/heuristics.md +157 -0
  128. package/skills/kit-ux-audit/references/report.md +172 -0
  129. package/templates/agents/ux.md +89 -0
  130. package/templates/benchmarks/SCHEMA.md +75 -0
  131. package/templates/benchmarks/abstain.jsonl +8 -0
  132. package/templates/benchmarks/adversarial.jsonl +8 -0
  133. package/templates/benchmarks/benchmark.config.json +14 -0
  134. package/templates/benchmarks/quality.jsonl +8 -0
  135. package/templates/benchmarks/retrieval.jsonl +7 -0
  136. package/templates/rules/branch-naming.md +20 -1
  137. package/templates/rules/communication-style.md +8 -0
  138. package/templates/rules/delegation-brief.md +38 -4
  139. package/templates/rules/effort-model.md +47 -4
  140. package/templates/rules/naming-and-ids.md +199 -0
  141. package/templates/rules/task-management.md +1 -1
  142. package/templates/settings/settings.json.tmpl +9 -0
  143. package/templates/skills/concrete/SKILL.md +117 -0
  144. package/templates/skills/karpathy-guidelines/SKILL.md +1 -0
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env bash
2
2
  # shellcheck shell=bash
3
- # effort-ops.sh — the effort lifecycle as shell ops, so `cckit effort new|start|pr|close` works from
4
- # any shell or agent (not only via the effort-* skills). Thin: composes the git-mechanics helpers in
5
- # effort.sh (linking, snapshots, title lint) plus gh + git. bash 3.2 compatible. Requires: gh, jq, git.
3
+ # effort-ops.sh — the effort lifecycle as shell ops, so `cckit effort new|chain|start|pr|close` works
4
+ # from any shell or agent (not only via the effort-* skills). Thin: composes the git-mechanics helpers
5
+ # in effort.sh (linking, snapshots, title lint) plus gh + git. bash 3.2 compatible. Requires: gh, jq, git.
6
6
  #
7
7
  # effort_new [flags] "<name>" [<sub spec> …] parent (4-section body + labels) + native sub-issues
8
- # effort_start <slug|N> [<slug>] effort/<N> branch + worktree from the base branch
8
+ # effort_chain <a> <b> [<c> …] wire N issues into a linear blocked_by chain (#243)
9
+ # effort_start [--force] <slug|N> [<slug>] effort/<N> branch + worktree from base, WIP-limited (#244)
9
10
  # effort_pr [<slug|N>] open the ONE PR effort/<N> → base branch
10
11
  # effort_close <slug|N> snapshot sub-diffs, squash-merge the PR, close parent + subs
11
12
  #
@@ -16,6 +17,7 @@
16
17
  # Commands accept the human slug as well as the canonical number (#93): a pure-digits arg is a number,
17
18
  # anything else is resolved via effort_slug_resolve. Repo + base branch come from kit.config.json
18
19
  # (EFFORT_REPO / KIT_BASE_BRANCH), loaded by effort.sh.
20
+ # errors: mixed — lifecycle ops propagate; board + label side effects are best-effort
19
21
 
20
22
  # Slug layer (#93): _eff_slug, _eff_title_slug, effort_display, effort_slug_resolve. One home in
21
23
  # effort-slug.sh; source it here so the lifecycle ops accept `<slug|N>` and render `slug #N`.
@@ -32,9 +34,10 @@ _eff_need() { command -v "$1" >/dev/null 2>&1 || { echo "effort: $1 is required
32
34
 
33
35
  # Compose the four-section parent body (rules/effort-model.md): the sections double as the work
34
36
  # record. An empty section falls back to its template placeholder so a bare call still yields the
35
- # full four-heading scaffold; passing content fills it. $5 is an optional pre-built ## Relations block.
37
+ # full four-heading scaffold; passing content fills it. The `## Relations` chain is NOT composed
38
+ # here — it is layered on afterwards by _eff_relations_add (one formatter, #243).
36
39
  _eff_compose_body() {
37
- local goal="$1" scope="$2" for_agents="$3" verification="$4" relations="$5"
40
+ local goal="$1" scope="$2" for_agents="$3" verification="$4"
38
41
  cat <<EOF
39
42
  ## Goal
40
43
  ${goal:-<!-- problem statement: what outcome, in one or two lines -->}
@@ -46,10 +49,49 @@ ${scope:-<!-- the sub-issue plan; mark each parallel | sequential / dependsOn --
46
49
  ${for_agents:-<!-- exact file paths / entry points a future agent needs -->}
47
50
 
48
51
  ## Verification
49
- ${verification:-<!-- how we know it is done: commands, checks, acceptance -->}${relations}
52
+ ${verification:-<!-- how we know it is done: commands, checks, acceptance -->}
50
53
  EOF
51
54
  }
52
55
 
56
+ # _eff_relations_add <body> <blocker> — echo <body> with `- Depends on #<blocker>` recorded in its
57
+ # `## Relations` section. THE one formatter for the human-readable dependency line (rules/
58
+ # effort-model.md): both `effort_new --depends-on` and `effort_chain` go through it, so the two
59
+ # produce byte-identical lines.
60
+ #
61
+ # Placement: appended to the END of an existing `## Relations` section (the lines before the next
62
+ # `## ` heading, or the end of the body); when the body has no such section, a new one is appended
63
+ # at the end of the body. IDEMPOTENT — a body that already carries the exact line comes back
64
+ # unchanged, so re-running never duplicates a line. Trailing blank lines are trimmed.
65
+ # Pure: no gh, no network — stdin-free, argument in / body out.
66
+ _eff_relations_add() {
67
+ printf '%s\n' "$1" | awk -v dep="$2" '
68
+ BEGIN { want = "- Depends on #" dep; rel = 0; have = 0 }
69
+ {
70
+ L[NR] = $0
71
+ if (rel == 0 && $0 ~ /^[ \t]*##[ \t]+Relations[ \t]*$/) rel = NR
72
+ t = $0; sub(/^[ \t]+/, "", t); sub(/[ \t]+$/, "", t)
73
+ if (t == want) have = 1
74
+ }
75
+ END {
76
+ n = NR
77
+ while (n > 0 && L[n] ~ /^[ \t]*$/) n-- # trim trailing blank lines
78
+ if (have) { for (i = 1; i <= n; i++) print L[i]; exit }
79
+ if (rel == 0) { # no section yet → append one
80
+ for (i = 1; i <= n; i++) print L[i]
81
+ if (n > 0) print "" # no leading blank on an empty body
82
+ print "## Relations"; print want
83
+ exit
84
+ }
85
+ e = n # end of the Relations section
86
+ for (i = rel + 1; i <= n; i++) if (L[i] ~ /^##[ \t]/) { e = i - 1; break }
87
+ while (e > rel && L[e] ~ /^[ \t]*$/) e--
88
+ for (i = 1; i <= e; i++) print L[i]
89
+ print want
90
+ for (i = e + 1; i <= n; i++) print L[i]
91
+ }
92
+ '
93
+ }
94
+
53
95
  # _eff_ensure_label <name> <color> <description> — make sure a kit-defined label exists in the repo
54
96
  # before `gh issue create --label` uses it (which fails hard on a missing label, #153). Idempotent:
55
97
  # creating an existing label is a silent no-op.
@@ -152,15 +194,16 @@ effort_new() {
152
194
  || { echo "effort_new: fix sub title #$i and retry: $sub_name" >&2; return 1; }
153
195
  done
154
196
 
155
- # Compose the four-section body + an optional ## Relations chain from --depends-on.
156
- local relations="" d
197
+ # Compose the four-section body, then layer the ## Relations chain from --depends-on through the
198
+ # ONE formatter (#243) — the same one `effort_chain` uses, so both write identical lines. (It was
199
+ # built inline here before, and `$( … )` ate every newline: the section shipped as the single
200
+ # mangled line `## Relations- Depends on #1- Depends on #2`.)
201
+ local body d; body="$(_eff_compose_body "$goal" "$scope" "$for_agents" "$verification")"
157
202
  if [ -n "$depends_on" ]; then
158
- relations="$(printf '\n\n## Relations\n')"
159
203
  for d in $(printf '%s' "$depends_on" | tr ',' ' '); do
160
- d="${d#\#}"; [ -n "$d" ] && relations="$relations$(printf -- '- Depends on #%s\n' "$d")"
204
+ d="${d#\#}"; [ -n "$d" ] && body="$(_eff_relations_add "$body" "$d")"
161
205
  done
162
206
  fi
163
- local body; body="$(_eff_compose_body "$goal" "$scope" "$for_agents" "$verification" "$relations")"
164
207
 
165
208
  # Label set: ctx (session weight from the sub count) + kind + priority + optional role + optional flow.
166
209
  local subcount=$#; [ "$subcount" -ge 1 ] || subcount=1
@@ -233,6 +276,296 @@ effort_new() {
233
276
  printf '%s\n' "$num"
234
277
  }
235
278
 
279
+ # _eo_source_effort — lazily source the git-mechanics lib (effort.sh) so the ops that need
280
+ # effort_set_blocked_by work when effort-ops.sh is sourced on its own. No-op if already loaded.
281
+ _eo_source_effort() {
282
+ command -v effort_set_blocked_by >/dev/null 2>&1 && return 0
283
+ local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
284
+ # shellcheck source=/dev/null
285
+ [ -f "$d/effort.sh" ] && . "$d/effort.sh"
286
+ }
287
+
288
+ # _eff_blockers <issue> — echo the issue's CURRENT blocked_by numbers, one per line. Empty when the
289
+ # issue has no edges or the API call fails (the caller treats that as "no known edge").
290
+ _eff_blockers() {
291
+ gh api "repos/$(_eff_repo)/issues/$1/dependencies/blocked_by" --jq '.[].number' 2>/dev/null || true
292
+ }
293
+
294
+ # _eff_chain_reaches <from> <target> <pending> — is <target> reachable from <from> by following
295
+ # blocked_by edges? Breadth-first over the COMBINED graph: the edges GitHub already holds plus
296
+ # <pending>, a space-separated list of `child>parent` pairs this call is about to write. Used as the
297
+ # cycle pre-flight: adding "<target> blocked_by <from>" closes a cycle exactly when <from> already
298
+ # depends (transitively) on <target>. rc 0 = reachable.
299
+ _eff_chain_reaches() {
300
+ [ -n "${ZSH_VERSION:-}" ] && setopt local_options ksh_arrays sh_word_split 2>/dev/null
301
+ local from="$1" target="$2" pending="$3"
302
+ local queue="$from" seen=" " cur b
303
+ while [ -n "$queue" ]; do
304
+ # shellcheck disable=SC2086
305
+ set -- $queue; cur="$1"; shift; queue="$*"
306
+ case "$seen" in *" $cur "*) continue ;; esac
307
+ seen="$seen$cur "
308
+ for b in $(_eff_blockers "$cur") \
309
+ $(printf '%s\n' $pending | sed -n "s/^$cur>//p"); do
310
+ [ "$b" = "$target" ] && return 0
311
+ queue="$queue $b"
312
+ done
313
+ done
314
+ return 1
315
+ }
316
+
317
+ # effort_chain <a> <b> [<c> …] — wire N issues into a LINEAR dependency chain (#243): B becomes
318
+ # blocked_by A, C blocked_by B, and so on, and each issue after the first gets a `- Depends on #<its
319
+ # predecessor>` line in its `## Relations` section. This is the verb that FEEDS `cckit plan` — the
320
+ # wave layering in plan-machine.sh reads exactly these `blocked_by` edges, so a chained set lands
321
+ # one issue per wave, in the order given.
322
+ #
323
+ # Everything is VALIDATED BEFORE ANYTHING IS WRITTEN (the effort_new discipline): a rejected chain
324
+ # leaves the board untouched. The rules:
325
+ # arity fewer than two numbers is a usage error — a chain needs a predecessor and a
326
+ # successor. Nothing is written.
327
+ # numbers each arg is an issue number, with an optional leading `#`. Anything else is
328
+ # rejected. Nothing is written.
329
+ # existence every issue is fetched first; a number that does not resolve aborts the whole
330
+ # chain. Nothing is written.
331
+ # cycles a repeated number (`chain 1 2 1`) is refused — the chain would revisit a node. So
332
+ # is a chain whose new edge closes a loop through edges GitHub ALREADY holds (the
333
+ # pre-flight walks the combined graph). `cckit plan` cannot layer a cyclic graph into
334
+ # waves, so a cycle is refused rather than written. Nothing is written.
335
+ # pre-existing an issue already blocked by something else KEEPS that blocker: blocked_by is a set,
336
+ # blockers and this only ever ADDS its edge. The issue ends up with both.
337
+ # idempotent an edge that is already present is skipped (no duplicate POST, no error) and a body
338
+ # that already carries the exact `- Depends on #N` line is left alone (no second
339
+ # line, no `gh issue edit`). A re-run writes nothing and reports each half as
340
+ # `already blocked_by` / `already records`.
341
+ # Progress goes to stderr; rc 0 only when every link of the chain is in place.
342
+ effort_chain() {
343
+ [ -n "${ZSH_VERSION:-}" ] && setopt local_options ksh_arrays sh_word_split 2>/dev/null
344
+ _eff_need gh || return 1
345
+ _eo_source_effort
346
+ local repo; repo="$(_eff_repo)"
347
+ [ -n "$repo" ] || { echo "effort_chain: no repo (KIT_REPO/EFFORT_REPO unset — run in a kit project)" >&2; return 1; }
348
+
349
+ # 1. arity, shape, and repeats — all before a single write. `#12` and `12` are the same issue; a
350
+ # number that appears twice means the chain revisits a node, which is a cycle, not a chain.
351
+ [ "$#" -ge 2 ] || { echo 'effort_chain: usage: effort_chain <a> <b> [<c> …] (two or more issue numbers)' >&2; return 1; }
352
+ local a n b list=""
353
+ for a in "$@"; do
354
+ n="${a#\#}"
355
+ case "$n" in
356
+ ''|*[!0-9]*) echo "effort_chain: '$a' is not an issue number — nothing written" >&2; return 1 ;;
357
+ esac
358
+ for b in $list; do
359
+ [ "$b" = "$n" ] && { echo "effort_chain: #$n appears twice — that is a cycle, not a chain; nothing written" >&2; return 1; }
360
+ done
361
+ list="$list$n "
362
+ done
363
+
364
+ # 2. every issue must exist before a single edge is written.
365
+ for n in $list; do
366
+ gh api "repos/$repo/issues/$n" --jq .number >/dev/null 2>&1 \
367
+ || { echo "effort_chain: #$n does not exist in $repo — nothing written" >&2; return 1; }
368
+ done
369
+
370
+ # 3. cycle pre-flight over the existing graph PLUS the edges this call would add. Adding
371
+ # "next blocked_by prev" closes a loop exactly when prev already depends on next.
372
+ local pending="" prev="" next
373
+ for next in $list; do
374
+ if [ -n "$prev" ] && _eff_chain_reaches "$prev" "$next" "$pending"; then
375
+ echo "effort_chain: #$next blocked_by #$prev would create a dependency cycle — nothing written" >&2
376
+ return 1
377
+ fi
378
+ [ -n "$prev" ] && pending="$pending$next>$prev "
379
+ prev="$next"
380
+ done
381
+
382
+ # 4. write. Per link: the native blocked_by edge and the `Depends on` line, each skipped when it
383
+ # is already there — so a re-run reports and touches nothing.
384
+ local rc=0 have body newbody
385
+ prev=""
386
+ for next in $list; do
387
+ if [ -n "$prev" ]; then
388
+ have=""
389
+ for b in $(_eff_blockers "$next"); do [ "$b" = "$prev" ] && have=1; done
390
+ if [ -n "$have" ]; then
391
+ echo " · #$next already blocked_by #$prev" >&2
392
+ else
393
+ effort_set_blocked_by "$next" "$prev" || rc=1
394
+ fi
395
+
396
+ # A FAILED read is not an empty body: writing the composed body after a failed fetch would
397
+ # wipe the issue. Only a successful read is edited.
398
+ if ! body="$(gh issue view "$next" --repo "$repo" --json body --jq .body 2>/dev/null)"; then
399
+ echo " ✗ could not read #$next's body — 'Depends on #$prev' not recorded" >&2; rc=1
400
+ elif printf '%s\n' "$body" | grep -qE "^[[:space:]]*- Depends on #${prev}[[:space:]]*$"; then
401
+ echo " · #$next already records 'Depends on #$prev'" >&2
402
+ else
403
+ newbody="$(_eff_relations_add "$body" "$prev")"
404
+ gh issue edit "$next" --repo "$repo" --body "$newbody" >/dev/null 2>&1 \
405
+ && echo " ✓ #$next records 'Depends on #$prev'" >&2 \
406
+ || { echo " ✗ could not update #$next's body" >&2; rc=1; }
407
+ fi
408
+ fi
409
+ prev="$next"
410
+ done
411
+
412
+ # The banner must agree with rc: a ✓ over a nonzero exit reports a chain that is not fully wired.
413
+ # Individual failures already printed their own ✗ line above; this is the summary for the whole run.
414
+ if [ "$rc" -eq 0 ]; then
415
+ echo " ✓ chain $(printf '#%s → ' $list | sed 's/ → $//')" >&2
416
+ else
417
+ echo " ✗ chain $(printf '#%s → ' $list | sed 's/ → $//') — incomplete, see the errors above" >&2
418
+ fi
419
+ return "$rc"
420
+ }
421
+
422
+ # ── WIP limit: how many efforts may be in progress at once (#244) ──────────────────────────────
423
+ #
424
+ # WHAT COUNTS AS "IN PROGRESS": an effort whose `effort/<N>-<slug>` branch exists — a local head, or
425
+ # a branch origin has right now (`git ls-remote`, not the cached `refs/remotes`; see effort_wip_rows
426
+ # for why). Both halves are parsed by the effort-slug.sh helpers the slug resolver is built on, so a
427
+ # ref name is decomposed in one place. This is the kit's existing notion of a started effort, not a
428
+ # new one: `effort_start` CREATES that branch and `effort_close` deletes it, so the branch set is
429
+ # exactly "started and not yet closed", by construction.
430
+ #
431
+ # The Projects v2 board Status is deliberately NOT the signal. It is written by the /kit-effort-start
432
+ # skill's additive board step, never by this verb, so the verb would be gating on state it does not
433
+ # set; it is empty whenever `github.projectsV2` is false (cckit's own default); and there is no
434
+ # status:* label to fall back on. One signal, no fallback chain.
435
+
436
+ # _eff_wip_limit_from_config — echo `effort.wipLimit` straight from the project config, so a
437
+ # configured limit applies even to callers that never ran load_kit_config. Mirrors
438
+ # _effort_flows_from_config (effort.sh). Empty output / rc 1 when unset or unreadable.
439
+ _eff_wip_limit_from_config() {
440
+ command -v jq >/dev/null 2>&1 || return 1
441
+ if ! command -v kit_config_path >/dev/null 2>&1; then
442
+ local _wl_dir; _wl_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)"
443
+ # shellcheck source=/dev/null
444
+ [ -n "$_wl_dir" ] && [ -f "$_wl_dir/config-path.sh" ] && . "$_wl_dir/config-path.sh"
445
+ fi
446
+ command -v kit_config_path >/dev/null 2>&1 || return 1
447
+ local _wl_cfg; _wl_cfg="$(kit_config_path 2>/dev/null)" && [ -f "$_wl_cfg" ] || return 1
448
+ jq -r 'if (.effort.wipLimit | type) == "null" then empty else (.effort.wipLimit | tostring) end' \
449
+ "$_wl_cfg" 2>/dev/null
450
+ }
451
+
452
+ # _eff_wip_limit — echo the effective limit. Resolution order mirrors the flow vocabulary (#150), so
453
+ # the kit has ONE config idiom:
454
+ # 1. EFFORT_WIP_LIMIT in the environment always wins (per-invocation override)
455
+ # 2. the project config `effort.wipLimit` — via KIT_EFFORT_WIP_LIMIT (exported by load_kit_config)
456
+ # or read straight from the config file
457
+ # 3. the built-in default, 2.
458
+ # A value that is not a non-negative integer (a typo, a float, a negative) is IGNORED with a warning
459
+ # on stderr and the built-in default is used: a misconfigured limit must not silently disable the
460
+ # gate, and must not wedge the verb either. `0` is valid and means "start no new effort".
461
+ _eff_wip_limit() {
462
+ local v="" src=""
463
+ if [ -n "${EFFORT_WIP_LIMIT:-}" ]; then
464
+ v="$EFFORT_WIP_LIMIT"; src="EFFORT_WIP_LIMIT"
465
+ elif [ -n "${KIT_EFFORT_WIP_LIMIT:-}" ]; then
466
+ v="$KIT_EFFORT_WIP_LIMIT"; src="effort.wipLimit"
467
+ else
468
+ v="$(_eff_wip_limit_from_config 2>/dev/null || true)"; src="effort.wipLimit"
469
+ fi
470
+ [ -n "$v" ] || { printf '2'; return 0; }
471
+ case "$v" in
472
+ ''|*[!0-9]*)
473
+ echo "effort_start: ignoring $src='$v' — the WIP limit must be a non-negative integer; using the default 2" >&2
474
+ printf '2'; return 0 ;;
475
+ esac
476
+ printf '%s' "$v"
477
+ }
478
+
479
+ # effort_wip_rows — one TSV row `<N>\t<slug>` per effort that is IN PROGRESS, each effort exactly
480
+ # once, lowest number first. The counted set behind the WIP gate: local `refs/heads/effort/*` UNION
481
+ # the effort branches origin actually has right now.
482
+ #
483
+ # Why not the cached `refs/remotes` (#244 review): it is wrong in both directions and the gate is
484
+ # wrong with it. A branch pushed since the last fetch is absent, so the gate lets the limit be
485
+ # exceeded — and the gate runs before effort_start's fetch, which is base-only and would not refresh
486
+ # `refs/remotes/origin/effort/*` anyway. A branch DELETED on origin lingers in `refs/remotes` until
487
+ # a prune, so the gate blocks a start that should be allowed. `git ls-remote` answers both: it sees
488
+ # the new branch and does not see the deleted one, without writing or pruning a single ref.
489
+ #
490
+ # The cost is one network round-trip per `effort start`. That is accepted: a gate that miscounts in
491
+ # both directions is not a gate, and `effort start` is a rare interactive command that already
492
+ # fetches and installs dependencies. Two things keep it from being a liability:
493
+ #
494
+ # EFFORT_WIP_REMOTE=0 skips the origin query outright and counts local heads + cached remotes —
495
+ # for a deterministic offline or CI run, and for anyone who would rather have
496
+ # the old approximation than the round-trip.
497
+ # unreachable origin ls-remote failing (offline, no remote, auth) is NOT fatal. The count falls
498
+ # back to the cached `refs/remotes`, one line says so on stderr, and the start
499
+ # proceeds. A gate that hard-fails with no network would be worse than one
500
+ # that miscounts.
501
+ #
502
+ # Deliberately NOT cached between invocations: a cache reintroduces the staleness window this
503
+ # replaces, and there is nothing to amortize — one ls-remote per interactive start.
504
+ effort_wip_rows() {
505
+ command -v effort_branch_rows >/dev/null 2>&1 || return 0
506
+ local remote=""
507
+ {
508
+ effort_branch_rows_local 2>/dev/null
509
+ if [ "${EFFORT_WIP_REMOTE:-1}" = "0" ]; then
510
+ effort_branch_rows 2>/dev/null # opted out: local heads + cached remotes
511
+ elif remote="$(effort_branch_rows_origin 2>/dev/null)"; then
512
+ printf '%s\n' "$remote"
513
+ else
514
+ echo "effort_start: could not read origin's effort branches — counting work in progress from the last fetch, which may be stale (set EFFORT_WIP_REMOTE=0 to silence this)" >&2
515
+ effort_branch_rows 2>/dev/null # offline fallback: local heads + cached remotes
516
+ fi
517
+ } | awk -F'\t' 'NF > 0 && $1 != "" && !seen[$1]++' | sort -n
518
+ }
519
+
520
+ # _eff_wip_gate <num> <force> — rc 0 when starting effort <num> may proceed, rc 1 (with the refusal
521
+ # on stderr) when it may not. READ-ONLY: it reads refs (one of them over the network — see
522
+ # effort_wip_rows) and the config, and writes nothing, so a refusal leaves no branch, no worktree and
523
+ # no board change behind (the effort_new / effort_chain discipline). It is not free of reads: the
524
+ # gate itself queries origin, and for a SLUG argument effort_start has already resolved the handle
525
+ # through effort_slug_resolve, which may have run `gh issue list`. "Writes nothing" is the guarantee;
526
+ # "reads nothing" is not.
527
+ #
528
+ # The rules:
529
+ # already started an effort whose branch already exists is ALREADY in the counted set, so
530
+ # re-running `effort start` on it adds no WIP and the gate does not apply —
531
+ # `effort_start` stays safe to re-run at or over the limit.
532
+ # at the limit `in-progress count >= limit` REFUSES. The limit is a ceiling on concurrent
533
+ # efforts: at 2 of 2, a third would make 3. Only `count < limit` starts.
534
+ # limit 0 refuses every new effort (a deliberate freeze); the override still works.
535
+ # override `--force` (or KIT_FORCE=1, the same escape hatch effort_close uses) starts
536
+ # anyway and says so on stderr.
537
+ _eff_wip_gate() {
538
+ local num="$1" force="${2:-}" limit rows count n tab; tab="$(printf '\t')"
539
+ limit="$(_eff_wip_limit)"
540
+ rows="$(effort_wip_rows)"
541
+
542
+ while IFS="$tab" read -r n _; do
543
+ if [ "$n" = "$num" ]; then return 0; fi
544
+ done <<EOF
545
+ $rows
546
+ EOF
547
+
548
+ count="$(printf '%s\n' "$rows" | grep -cE '^[0-9]+' || true)"
549
+ if [ "${count:-0}" -lt "$limit" ]; then return 0; fi
550
+
551
+ {
552
+ echo "effort_start: $count effort(s) already in progress and the WIP limit is $limit."
553
+ printf '%s\n' "$rows" | grep -E '^[0-9]+' | while IFS="$tab" read -r n _slug; do
554
+ printf ' · %s (effort/%s-%s)\n' "$(effort_display "$n" "$_slug")" "$n" "$_slug"
555
+ done
556
+ } >&2
557
+ if [ -n "$force" ]; then
558
+ echo " → starting #$num anyway (override)." >&2
559
+ return 0
560
+ fi
561
+ {
562
+ echo " → refusing to start #$num — nothing was created."
563
+ echo " Close one with 'cckit effort close <N>', or start anyway with --force (or KIT_FORCE=1)."
564
+ echo " The limit is effort.wipLimit in the project config (default 2); EFFORT_WIP_LIMIT overrides it."
565
+ } >&2
566
+ return 1
567
+ }
568
+
236
569
  # _eo_source_wt — lazily source the worktree mechanic (worktree-start.sh) so effort_start gets the
237
570
  # SAME full worktree setup as `cckit start`: wt_bootstrap (env-file copy + per-worktree dev port +
238
571
  # dependency install) and the _wt_session_owns collision guard. bin/cckit's `effort` verb does not
@@ -244,18 +577,41 @@ _eo_source_wt() {
244
577
  [ -f "$d/worktree-start.sh" ] && . "$d/worktree-start.sh"
245
578
  }
246
579
 
247
- # effort_start <slug|N> [<slug>] — create the effort/<N> integration branch + its worktree from base,
248
- # with the full `cckit start` worktree setup (env copy, per-worktree dev port, dependency install —
249
- # opt out with KIT_WT_INSTALL=0) and a live-session collision guard.
580
+ # effort_start [--force] <slug|N> [<slug>] — create the effort/<N> integration branch + its worktree
581
+ # from base, with the full `cckit start` worktree setup (env copy, per-worktree dev port, dependency
582
+ # install — opt out with KIT_WT_INSTALL=0) and a live-session collision guard.
583
+ #
584
+ # Gated by the WIP limit (#244): when as many efforts are already in progress as `effort.wipLimit`
585
+ # allows (default 2), starting a NEW one is refused before anything is written — see _eff_wip_gate
586
+ # above for the counted set and the exact rules. `--force` (or KIT_FORCE=1) starts anyway.
587
+ # The gate is specific to EFFORTS: `cckit start <issue>` (a plain task worktree, wt_start) is not
588
+ # affected and has no WIP limit.
250
589
  effort_start() {
251
590
  _eff_need git || return 1
252
- local raw="${1:-}" slug_override="${2:-}" num repo base root title slug branch wt
591
+ local raw="" slug_override="" force="" num repo base root title slug branch wt
592
+ # Flags are position-INDEPENDENT (the effort_new parser shape): `--` forces the rest positional.
593
+ local pos=()
594
+ while [ $# -gt 0 ]; do
595
+ case "$1" in
596
+ --force) force=1; shift ;;
597
+ --) shift; while [ $# -gt 0 ]; do pos+=("$1"); shift; done ;;
598
+ --*) echo "effort_start: unknown flag $1" >&2; return 1 ;;
599
+ *) pos+=("$1"); shift ;;
600
+ esac
601
+ done
602
+ set -- "${pos[@]+"${pos[@]}"}"
603
+ raw="${1:-}"; slug_override="${2:-}"
604
+ if [ "${KIT_FORCE:-0}" = "1" ]; then force=1; fi
253
605
  [ -n "$raw" ] || { echo "effort_start: <slug|effort issue #> required" >&2; return 1; }
254
606
  num="$(effort_slug_resolve "$raw")" || { echo "effort_start: could not resolve '$raw' to an effort" >&2; return 1; }
255
607
  repo="$(_eff_repo)"; base="$(_eff_base)"
256
608
  root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree /{print $2; exit}')"
257
609
  [ -n "$root" ] || { echo "effort_start: not in a git repo" >&2; return 1; }
258
610
 
611
+ # WIP gate (#244) — BEFORE the fetch, the branch, the worktree and the bootstrap, so a refusal
612
+ # leaves nothing behind. Reads refs + config only; writes nothing.
613
+ _eff_wip_gate "$num" "$force" || return 1
614
+
259
615
  if [ -n "$slug_override" ]; then slug="$(_eff_slug "$slug_override")"
260
616
  else
261
617
  title="$(gh issue view "$num" --repo "$repo" --json title -q .title 2>/dev/null)"
@@ -8,6 +8,7 @@
8
8
  # - sub-issues carry kind/priority/role labels and are native-linked
9
9
  # - every sub title is linted UP FRONT (a bad sub name aborts before anything is created)
10
10
  # Hermetic: stubs gh (no network/auth). Run: bash scripts/lib/effort-parity-test.sh
11
+ # errors: strict — a test runner: rc 1 on any failed assertion
11
12
  set -u
12
13
  ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
13
14
  LIB="$ROOT/scripts/lib"
@@ -12,6 +12,7 @@
12
12
  # (rules/agent-execution-routing.md).
13
13
  #
14
14
  # Requires: gh, jq. bash 3.2 (no associative arrays — parallel indexed arrays + linear scan; N small).
15
+ # errors: strict — refuses to plan without gh + jq
15
16
 
16
17
  EFFORT_REPO="${EFFORT_REPO:-${KIT_REPO:-}}"
17
18
 
@@ -4,6 +4,7 @@
4
4
  # `slug #N` display, and effort_slug_resolve (number passthrough, branch match, ambiguity, no-match,
5
5
  # slug:<slug> label vs title-derived precedence). Hermetic: a throwaway git repo with effort/* branches
6
6
  # + a stubbed gh (no network/auth). Run: bash scripts/lib/effort-slug-test.sh
7
+ # errors: strict — a test runner: rc 1 on any failed assertion
7
8
  set -u
8
9
  ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
9
10
  LIB="$ROOT/scripts/lib"
@@ -83,5 +84,36 @@ out="$(effort_slug_resolve nope-not-here 2>&1)"; r=$?
83
84
  rc "unknown slug returns nonzero rc" "$r" "1"
84
85
  case "$out" in *"no effort matches"*) echo "ok: unknown slug explains itself" ;; *) echo "FAIL: no-match message: $out"; fail=1 ;; esac
85
86
 
87
+ # ── #244 · effort_branch_rows — the ONE effort-branch scan (shared with the WIP gate) ──────────
88
+ # `<N>\t<slug>` per effort/<N>-<slug> ref, local heads AND remote-tracking. #101 is local+remote
89
+ # (two rows, de-duplication is the caller's job); #102 is remote-only and must still appear.
90
+ t "branch_rows lists local + remote effort refs" \
91
+ "$(effort_branch_rows | sort | tr '\t' '=' | tr '\n' ' ')" \
92
+ "101=resolve-slug 101=resolve-slug 102=accept-slug "
93
+ t "branch_rows ignores non-effort branches" \
94
+ "$(git branch nope/500-not-an-effort >/dev/null 2>&1; effort_branch_rows | grep -c '^500' | tr -d ' ')" "0"
95
+ # refs/heads only — the half that needs no cache and no network. #102 is remote-only, so absent.
96
+ t "branch_rows_local is refs/heads only" \
97
+ "$(effort_branch_rows_local | sort | tr '\t' '=' | tr '\n' ' ')" "101=resolve-slug "
98
+
99
+ # ── #244 review · effort_branch_rows_origin — what origin has NOW, not what the cache remembers ──
100
+ # rc 0 with rows for a reachable origin; rc 1 (never a silent empty) when origin cannot be read.
101
+ t "branch_rows_origin lists origin's effort heads" \
102
+ "$(effort_branch_rows_origin | sort | tr '\t' '=' | tr '\n' ' ')" \
103
+ "101=resolve-slug 102=accept-slug "
104
+ # A branch deleted on origin drops out immediately — no fetch, no prune. Deleted by writing the bare
105
+ # remote directly, not by `git push origin :ref` from HERE: a delete-push updates this clone's own
106
+ # tracking ref, which would hide the very staleness under test. Writing the remote is the honest
107
+ # "another machine deleted it" case, and it is what leaves refs/remotes stale.
108
+ git --git-dir="$tmp/remote.git" update-ref -d refs/heads/effort/102-accept-slug
109
+ t "branch_rows_origin drops a branch deleted on origin" \
110
+ "$(effort_branch_rows_origin | grep -c '^102' | tr -d ' ')" "0"
111
+ t "the deleted branch is still in the local cache" \
112
+ "$(effort_branch_rows | grep -c '^102' | tr -d ' ')" "1"
113
+ # An unreachable origin is rc 1, so a caller can tell "cannot read" from "origin has none".
114
+ git remote set-url origin "$tmp/absent.git"
115
+ effort_branch_rows_origin >/dev/null 2>&1; rc "branch_rows_origin returns rc 1 when origin is unreachable" "$?" "1"
116
+ git remote set-url origin "$tmp/remote.git"
117
+
86
118
  [ "$fail" -eq 0 ] && echo "ALL OK (effort-slug)" || echo "effort-slug: FAILURES"
87
119
  exit "$fail"
@@ -11,6 +11,12 @@
11
11
  # ("[Effort] N · " / "[Effort N] M · ") and any leading [Flow] tag so
12
12
  # the number/flow are NOT duplicated into the slug (#93 doubling fix)
13
13
  # effort_display <N> [slug] render an effort as "slug #N" (or "#N" when no slug is known)
14
+ # effort_branch_rows TSV `<N>\t<slug>` per effort/<N>-<slug> ref in the LOCAL ref
15
+ # store (refs/heads + cached refs/remotes) — network-free (#244)
16
+ # effort_branch_rows_local the same, refs/heads only
17
+ # effort_branch_rows_origin the same, from `git ls-remote origin` — what origin has NOW,
18
+ # so a stale or unfetched remote ref cannot skew a count. rc 1
19
+ # when origin is unreachable (#244)
14
20
  # effort_slug_resolve <slug|N> resolve a slug OR a number to the canonical effort number.
15
21
  # pure-digits → passthrough; otherwise match effort/* branches
16
22
  # (local + remote), then slug:<slug> labels, then open effort titles.
@@ -19,6 +25,8 @@
19
25
  # Number stays canonical: a pure-digits argument is always treated as a number and passed through
20
26
  # unchanged, so every existing `<N>` call keeps working. bash 3.2 compatible. Requires: git; gh (only
21
27
  # for the issue-based fallback when no local/remote branch matches).
28
+ # errors: mixed — _eff_slug/effort_display are pure; effort_slug_resolve needs gh;
29
+ # effort_branch_rows_origin reaches the network and returns rc 1 when it cannot
22
30
 
23
31
  # Repo for the gh fallback — resolved from the same env effort.sh/kit-config populate.
24
32
  _eff_slug_repo() { printf '%s' "${EFFORT_REPO:-${KIT_REPO:-}}"; }
@@ -47,6 +55,66 @@ effort_display() {
47
55
  if [ -n "$s" ]; then printf '%s #%s' "$s" "$n"; else printf '#%s' "$n"; fi
48
56
  }
49
57
 
58
+ # _eff_rows_from_refs — stdin: ref or branch names, one per line (`effort/7-x`,
59
+ # `origin/effort/7-x`, `refs/heads/effort/7-x` all work); stdout: one TSV `<N>\t<slug>` row per name
60
+ # that matches `effort/<N>-<slug>`, others dropped. THE one parser — every effort-branch inventory
61
+ # below funnels through it, so a ref name is decomposed in exactly one place (#244).
62
+ _eff_rows_from_refs() {
63
+ local ref n s
64
+ while IFS= read -r ref; do
65
+ [ -n "$ref" ] || continue
66
+ n="$(printf '%s' "$ref" | sed -nE 's#^(.*/)?effort/([0-9]+)-(.*)$#\2#p')"
67
+ s="$(printf '%s' "$ref" | sed -nE 's#^(.*/)?effort/([0-9]+)-(.*)$#\3#p')"
68
+ [ -n "$n" ] || continue
69
+ printf '%s\t%s\n' "$n" "$s"
70
+ done
71
+ }
72
+
73
+ # effort_branch_rows — one TSV row `<N>\t<slug>` per `effort/<N>-<slug>` ref in the LOCAL ref store:
74
+ # `refs/heads` plus the cached `refs/remotes`. Network-free by contract — the slug resolver below is
75
+ # on the hot path of every effort verb (and of `cckit start <slug>`), so it must never reach the
76
+ # network to answer "which effort is this handle".
77
+ #
78
+ # Cached `refs/remotes` is therefore approximate in BOTH directions: a branch pushed since the last
79
+ # fetch is missing, and a branch deleted on the remote lingers until a prune. That is acceptable for
80
+ # slug lookup, where a wrong hit is caught by the number/ambiguity checks and the gh fallbacks. It is
81
+ # NOT acceptable for counting work in progress, so `effort_wip_rows` (effort-ops.sh) uses
82
+ # effort_branch_rows_origin instead and only falls back here when origin is unreachable (#244).
83
+ #
84
+ # Rows are NOT de-duplicated — one row per matching ref, so `effort/7-a` and `origin/effort/7-b`
85
+ # both appear. The slug resolver needs every distinct slug; a caller that wants distinct EFFORTS
86
+ # de-duplicates on the number column. best-effort: without git, no rows.
87
+ effort_branch_rows() {
88
+ command -v git >/dev/null 2>&1 || return 0
89
+ git for-each-ref --format='%(refname:short)' refs/heads refs/remotes 2>/dev/null \
90
+ | _eff_rows_from_refs
91
+ }
92
+
93
+ # effort_branch_rows_local — the same rows from `refs/heads` ALONE. The half of the inventory that
94
+ # is always authoritative and always available: a local branch is a fact about this machine, with no
95
+ # cache and no network between the caller and the answer.
96
+ effort_branch_rows_local() {
97
+ command -v git >/dev/null 2>&1 || return 0
98
+ git for-each-ref --format='%(refname:short)' 'refs/heads/effort/*' 2>/dev/null \
99
+ | _eff_rows_from_refs
100
+ }
101
+
102
+ # effort_branch_rows_origin — the same rows for the effort branches origin ACTUALLY has right now,
103
+ # read with `git ls-remote` instead of the cached `refs/remotes`. This is what makes the WIP count
104
+ # correct in both directions: ls-remote sees a branch pushed one second ago and does not see one
105
+ # deleted one second ago, neither of which the local cache can do without a fetch --prune.
106
+ #
107
+ # rc 1 when origin cannot be reached or does not exist (no remote, offline, auth failure) — the
108
+ # caller decides what to do, and `effort_wip_rows` falls back to the cached refs rather than failing.
109
+ # An EMPTY result with rc 0 is a real answer (origin has no effort branches) and must not be read as
110
+ # a failure. Read-only: no refs are written, nothing is fetched, nothing is pruned.
111
+ effort_branch_rows_origin() {
112
+ command -v git >/dev/null 2>&1 || return 1
113
+ local out
114
+ out="$(git ls-remote --heads origin 'effort/*' 2>/dev/null)" || return 1
115
+ printf '%s\n' "$out" | awk '{ if (NF >= 2) print $2 }' | _eff_rows_from_refs
116
+ }
117
+
50
118
  # effort_slug_resolve <slug|N> → echo the canonical effort number on stdout (rc 0).
51
119
  # - pure digits → passthrough (number stays canonical; never re-mapped).
52
120
  # - otherwise normalize and match, in order: effort/* branches (local + remote), then (via gh)
@@ -63,16 +131,12 @@ effort_slug_resolve() {
63
131
  local norm; norm="$(_eff_slug "$input")"
64
132
  [ -n "$norm" ] || { echo "effort_slug_resolve: '$input' is not a usable slug" >&2; return 2; }
65
133
 
66
- local matches="" ref n s
67
- # 1. branches (local refs/heads + remote refs/remotes): effort/<N>-<slug>
68
- while IFS= read -r ref; do
69
- [ -n "$ref" ] || continue
70
- n="$(printf '%s' "$ref" | sed -nE 's#^(.*/)?effort/([0-9]+)-(.*)$#\2#p')"
71
- s="$(printf '%s' "$ref" | sed -nE 's#^(.*/)?effort/([0-9]+)-(.*)$#\3#p')"
134
+ local matches="" n s tab; tab="$(printf '\t')"
135
+ # 1. branches (local refs/heads + remote refs/remotes): effort/<N>-<slug>, via the shared scan.
136
+ while IFS="$tab" read -r n s; do
72
137
  [ -n "$n" ] || continue
73
138
  [ "$s" = "$norm" ] && matches="$matches$n"$'\n'
74
- done < <(git for-each-ref --format='%(refname:short)' refs/heads refs/remotes 2>/dev/null \
75
- | grep -E '(^|/)effort/[0-9]+-' )
139
+ done < <(effort_branch_rows)
76
140
  matches="$(printf '%s' "$matches" | grep -E '^[0-9]+$' | sort -un)"
77
141
 
78
142
  # 2. gh fallback (only when no branch matched): slug:<slug> label first, then open effort titles.
@@ -13,6 +13,7 @@
13
13
  # effort_set_blocked_by <issue> <blocker> set a native GitHub blocked_by dependency edge
14
14
  #
15
15
  # Requires: gh, jq, git. bash 3.2 compatible.
16
+ # errors: strict — git mechanics: a failed link, snapshot or lint propagates
16
17
 
17
18
  # Repo resolves from kit.config.json (KIT_REPO) — load it if a caller hasn't already.
18
19
  if [[ -z "${KIT_REPO:-}" ]]; then
@@ -11,6 +11,7 @@
11
11
  # "engine": { "mode": "off" | "http", "url": "https://engine.example", "token_env": "CCKIT_ENGINE_TOKEN" }
12
12
  #
13
13
  # Source it, then call engine_cmd / engine_call. Requires: jq, curl (only when mode != off).
14
+ # errors: mixed — no-op when engine.mode=off; propagates once http is on
14
15
 
15
16
  _engine_cfg() { echo "${KIT_CONFIG:-.claude/kit.config.json}"; }
16
17