@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
@@ -3,7 +3,7 @@
3
3
  # effort-parity-test.sh — effort #98: the verb (`cckit effort new`) and the skill (/kit-effort-new)
4
4
  # create structurally IDENTICAL efforts because both call the one shared core `effort_new`. This test
5
5
  # drives that core with the full skill-shaped inputs and asserts the parity contract:
6
- # - the four body sections are FILLED (no `<!--` template placeholder left)
6
+ # - the five body sections are FILLED (no `<!--` template placeholder left)
7
7
  # - the ctx/kind/priority/role/flow label set is applied to the parent
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)
@@ -46,6 +46,7 @@ parent="$(effort_new \
46
46
  --scope "1. share core | 2. verb fills body | 3. skill delegates" \
47
47
  --for-agents "scripts/lib/effort-ops.sh and skills/kit-effort-new/SKILL.md" \
48
48
  --verification "the verb and skill produce identical issues" \
49
+ --spec "the verb and the skill file the same body" \
49
50
  "demo parity effort" "share core :: factor the logic" "fill the body :: verb wiring")"
50
51
 
51
52
  t "core returns the parent number" "$parent" "1"
@@ -58,33 +59,38 @@ tc "$GH_LOG" 'Close the parity gap between the verb' "body fills ## Goal"
58
59
  tc "$GH_LOG" '1\. share core \| 2\. verb fills body' "body fills ## Scope"
59
60
  tc "$GH_LOG" 'scripts/lib/effort-ops\.sh and skills' "body fills ## For agents"
60
61
  tc "$GH_LOG" 'the verb and skill produce identical' "body fills ## Verification"
62
+ tc "$GH_LOG" '## Spec\\n- the verb and the skill file' "body fills ## Spec, a plain line made a bullet"
61
63
  tn "$GH_LOG" '<!--' "no template placeholder left in a filled body"
62
64
 
63
65
  # Label set on the parent: effort + ctx + kind + priority + role + flow (flow lowercased).
64
66
  # `effort` leads: it is the one `effort_plan` queries, and it was read by that verb while nothing
65
67
  # wrote it — so `cckit effort plan` answered "no open efforts found" on every repo.
66
- tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[Effort\] · .*"labels":\["effort","ctx:[SMLX]+","kind:task","priority:p2","role:tech-lead","flow:core"\]' \
68
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"[^[].*"labels":\["effort","ctx:[SMLX]+","kind:task","priority:p2","role:tech-lead","flow:core"\]' \
67
69
  "parent carries effort/ctx/kind/priority/role/flow labels"
68
70
  # Flow tag on the composed title.
69
- tc "$GH_LOG" '^PATCH repos/o/r/issues/1 \{"title":"\[Effort\] 1 · \[Core\] demo parity effort"\}$' \
71
+ tc "$GH_LOG" '^PATCH repos/o/r/issues/1 \{"title":"\[E1\] demo parity effort"\}$' \
70
72
  "parent title carries the [Core] flow tag + injected number"
71
73
  # Sub labels: kind/priority/role (no ctx/flow on subs — those are parent-level).
72
- tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[Effort 1\] 1 · share core".*"labels":\["kind:task","priority:p2","role:tech-lead"\]' \
73
- "sub #1 carries kind/priority/role labels + a proper [Effort N] M title"
74
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[E1\.1\] share core".*"labels":\["kind:task","priority:p2","role:tech-lead"\]' \
75
+ "sub #1 carries kind/priority/role labels + a proper [E<n>.<step>] title"
74
76
 
75
77
  # ── A bad sub title aborts the whole op BEFORE anything is created (parity contract) ─────────────
76
78
  : > "$GH_LOG"; printf '0' > "$GH_N"
77
- effort_new --role tech-lead --goal G --scope S --for-agents A --verification V \
79
+ effort_new --role tech-lead --goal G --scope S --for-agents A --verification V --spec "it ships" \
78
80
  "clean parent name" "refactor the whole wiring layer thing now" >/dev/null 2>&1 && rc=0 || rc=1
79
81
  t "core rejects a bad sub title" "$rc" "1"
80
82
  t "core creates nothing on a bad sub title" "$(grep -cE "$CREATE_RE" "$GH_LOG")" "0"
81
83
 
82
- # ── A bare verb-style call (no body flags) still yields the 4-section scaffold ───────────────────
84
+ # ── A call with only --spec still yields the 5-section scaffold; with no Spec it refuses (E546.5) ─
83
85
  : > "$GH_LOG"; printf '0' > "$GH_N"
84
- effort_new "minimal effort name" >/dev/null 2>&1
85
- tc "$GH_LOG" '## Goal' "bare call still emits ## Goal"
86
- tc "$GH_LOG" '## Verification' "bare call still emits ## Verification"
87
- tc "$GH_LOG" '<!--' "bare call leaves the template placeholders (nothing to fill)"
86
+ effort_new --spec "it ships" "minimal effort name" >/dev/null 2>&1
87
+ tc "$GH_LOG" '## Goal' "spec-only call still emits ## Goal"
88
+ tc "$GH_LOG" '## Verification' "spec-only call still emits ## Verification"
89
+ tc "$GH_LOG" '<!--' "spec-only call leaves the template placeholders (nothing to fill)"
90
+ : > "$GH_LOG"; printf '0' > "$GH_N"
91
+ effort_new "minimal effort name" >/dev/null 2>&1 && rc=0 || rc=1
92
+ t "a bare call with no Spec refuses" "$rc" "1"
93
+ t "a bare call with no Spec writes nothing" "$(grep -c . "$GH_LOG")" "0"
88
94
 
89
95
  # ── #121: the ONE shared effort-PR title composer + the mandatory-[#N] check ─────────────────────
90
96
  # #237: the composed title is a Conventional Commit subject carrying [#N] — the form the
@@ -92,19 +98,19 @@ tc "$GH_LOG" '<!--' "bare call leaves the template placeholders (noth
92
98
  # shellcheck source=/dev/null
93
99
  source "$LIB/commitlint.sh"
94
100
  unset KIT_PR_TITLE_STYLE
95
- t "effort_pr_title composes type: name [#N]" "$(effort_pr_title 115 'adoption hardening')" "feat: adoption hardening [#115]"
96
- t "effort_pr_title takes the scope from flow:" "$(effort_pr_title 115 'adoption hardening' 'role:tech-lead,kind:task,flow:core')" "feat(core): adoption hardening [#115]"
97
- t "effort_pr_title peels [Effort] + uses [Flow] as scope" "$(effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening')" "feat(core): adoption hardening [#115]"
98
- t "effort_pr_title flow: label wins over the [Flow] tag" "$(effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening' 'flow:docs')" "feat(docs): adoption hardening [#115]"
99
- t "effort_pr_title drops a tag that is no valid scope" "$(effort_pr_title 115 '[¡Hola!] adoption hardening')" "feat: adoption hardening [#115]"
100
- t "effort_pr_title tolerates a #-prefixed num" "$(effort_pr_title '#42' 'x')" "feat: x [#42]"
101
- t "effort_pr_title derives the type from kind:" "$(effort_pr_title 115 'x' 'kind:chore,flow:core')" "chore(core): x [#115]"
102
- t "effort_pr_title maps a bug label to fix" "$(effort_pr_title 115 'x' 'bug,kind:task')" "fix: x [#115]"
103
- t "effort_pr_title explicit type wins" "$(effort_pr_title 115 'x' 'kind:chore' fix)" "fix: x [#115]"
101
+ t "effort_pr_title composes type: name [#N]" "$(effort_pr_title 115 'adoption hardening')" "feat: adoption hardening [E115]"
102
+ t "effort_pr_title takes the scope from flow:" "$(effort_pr_title 115 'adoption hardening' 'role:tech-lead,kind:task,flow:core')" "feat(core): adoption hardening [E115]"
103
+ t "effort_pr_title peels [Effort] + uses [Flow] as scope" "$(effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening')" "feat(core): adoption hardening [E115]"
104
+ t "effort_pr_title flow: label wins over the [Flow] tag" "$(effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening' 'flow:docs')" "feat(docs): adoption hardening [E115]"
105
+ t "effort_pr_title drops a tag that is no valid scope" "$(effort_pr_title 115 '[¡Hola!] adoption hardening')" "feat: adoption hardening [E115]"
106
+ t "effort_pr_title tolerates a #-prefixed num" "$(effort_pr_title '#42' 'x')" "feat: x [E42]"
107
+ t "effort_pr_title derives the type from kind:" "$(effort_pr_title 115 'x' 'kind:chore,flow:core')" "chore(core): x [E115]"
108
+ t "effort_pr_title maps a bug label to fix" "$(effort_pr_title 115 'x' 'bug,kind:task')" "fix: x [E115]"
109
+ t "effort_pr_title explicit type wins" "$(effort_pr_title 115 'x' 'kind:chore' fix)" "fix: x [E115]"
104
110
  t "effort_pr_title issue-title style keeps [Role] [#N] name" "$(KIT_PR_TITLE_STYLE=issue-title effort_pr_title 115 '[Effort] 115 · [Core] adoption hardening' 'flow:core' '' 'Tech Lead')" "[Tech Lead] [#115] [Core] adoption hardening"
105
111
  t "effort_pr_title issue-title style without a role" "$(KIT_PR_TITLE_STYLE=issue-title effort_pr_title 115 'adoption hardening')" "[#115] adoption hardening"
106
112
  _t237="$(effort_pr_title 220 '[Effort] 220 · [Core] agents cannot see what cckit provides' 'flow:core,kind:task,role:tech-lead')"
107
- t "the #237 reproduction composes the conventional form" "$_t237" "feat(core): agents cannot see what cckit provides [#220]"
113
+ t "the #237 reproduction composes the conventional form" "$_t237" "feat(core): agents cannot see what cckit provides [E220]"
108
114
  commitlint_check "$_t237" 2>/dev/null; t "the generated title passes commitlint_check" "$?" "0"
109
115
  effort_pr_title_check "$_t237" 220 2>/dev/null; t "the generated title carries the [#N] id" "$?" "0"
110
116
  effort_pr_title_check "[Tech Lead] [#115] adoption hardening" 115; t "check accepts a title carrying [#N]" "$?" "0"
@@ -113,26 +119,26 @@ effort_pr_title_check "[#7] anything" 2>/dev/null; t "check accepts any [#N] whe
113
119
 
114
120
  # ── #277: --kind picks the kind: label (parent + subs) from the closed set; --par is gone ──────────
115
121
  : > "$GH_LOG"; printf '0' > "$GH_N"
116
- effort_new --flow Core --kind fix "kind fix effort" "a :: x" >/dev/null 2>&1
117
- tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[Effort\] · .*"labels":\["effort","ctx:[SMLX]+","kind:fix",' "--kind fix labels the parent kind:fix"
118
- tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[Effort 1\] 1 · a".*"labels":\["kind:fix",' "--kind fix labels every sub kind:fix"
122
+ effort_new --spec "it ships" --flow Core --kind fix "kind fix effort" "a :: x" >/dev/null 2>&1
123
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"[^[].*"labels":\["effort","ctx:[SMLX]+","kind:fix",' "--kind fix labels the parent kind:fix"
124
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[E1\.1\] a".*"labels":\["kind:fix",' "--kind fix labels every sub kind:fix"
119
125
  tc "$GH_LOG" '^POST repos/o/r/labels \{"name":"kind:fix"' "--kind ensures the kind label exists"
120
126
  tn "$GH_LOG" 'kind:task' "--kind fix leaves no kind:task behind"
121
127
  : > "$GH_LOG"; printf '0' > "$GH_N"
122
- effort_new --kind=chore "kind chore effort" >/dev/null 2>&1
128
+ effort_new --spec "it ships" --kind=chore "kind chore effort" >/dev/null 2>&1
123
129
  tc "$GH_LOG" '^POST repos/o/r/issues \{.*"labels":\["effort","ctx:[SMLX]+","kind:chore",' "--kind=chore (equals form) is accepted"
124
130
  for k in $KIT_KINDS; do
125
131
  : > "$GH_LOG"; printf '0' > "$GH_N"
126
- effort_new --kind "$k" "kind vocabulary effort" >/dev/null 2>&1 && rc=0 || rc=1
132
+ effort_new --spec "it ships" --kind "$k" "kind vocabulary effort" >/dev/null 2>&1 && rc=0 || rc=1
127
133
  t "--kind $k is accepted" "$rc" "0"
128
134
  done
129
135
  for k in $KIT_CONTENT_KINDS; do
130
136
  : > "$GH_LOG"; printf '0' > "$GH_N"
131
- effort_new --kind "$k" "content kind effort" >/dev/null 2>&1 && rc=0 || rc=1
137
+ effort_new --spec "it ships" --kind "$k" "content kind effort" >/dev/null 2>&1 && rc=0 || rc=1
132
138
  t "--kind $k (content kind) is accepted" "$rc" "0"
133
139
  tc "$GH_LOG" "^POST repos/o/r/issues \\{.*\"labels\":\\[\"effort\",\"ctx:[SMLX]+\",\"kind:$k\"," "--kind $k labels the parent kind:$k"
134
140
  done
135
- t "effort_pr_title: a content kind titles as docs" "$(effort_pr_title 115 'spring launch' 'kind:campaign')" "docs: spring launch [#115]"
141
+ t "effort_pr_title: a content kind titles as docs" "$(effort_pr_title 115 'spring launch' 'kind:campaign')" "docs: spring launch [E115]"
136
142
  : > "$GH_LOG"; printf '0' > "$GH_N"
137
143
  err="$(effort_new --kind bug "bad kind effort" 2>&1 >/dev/null)" && rc=0 || rc=1
138
144
  t "--kind rejects a value outside the closed set" "$rc" "1"
@@ -146,11 +152,11 @@ t "nothing in effort-ops.sh writes a par: label" "$(grep -c 'par:' "$LIB/eff
146
152
 
147
153
  # ── #121: flags are position-INDEPENDENT — trailing --flow/--role no longer become junk sub-issues ─
148
154
  : > "$GH_LOG"; printf '0' > "$GH_N"
149
- effort_new "flags after title effort" "real sub :: desc" --flow Docs --role docs >/dev/null 2>&1
155
+ effort_new "flags after title effort" "real sub :: desc" --flow Docs --role docs --spec "it ships" >/dev/null 2>&1
150
156
  t "trailing flags do NOT create junk subs (parent + 1 real sub)" "$(grep -cE "$CREATE_RE" "$GH_LOG")" "2"
151
157
  tc "$GH_LOG" '^POST repos/o/r/issues \{.*"labels":\[[^]]*"flow:docs"\]' "trailing --flow is honored (flow:docs label)"
152
- tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[Effort 1\] 1 · real sub"' "the one real sub is created from the positional"
153
- tn "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[Effort 1\] [0-9]+ · --flow' "no '--flow' junk sub-issue created"
158
+ tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[E1\.1\] real sub"' "the one real sub is created from the positional"
159
+ tn "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[E1\.[0-9]+\] --flow' "no '--flow' junk sub-issue created"
154
160
 
155
161
  [ "$fail" -eq 0 ] && echo "ALL OK (effort-parity)" || echo "effort-parity: FAILURES"
156
162
  exit "$fail"
@@ -102,7 +102,7 @@ effort_next_pick() {
102
102
  if ($6 != "-") { waiting[f]++; next }
103
103
  r = rank($4); n = $1 + 0
104
104
  if (!(f in bn) || r < br[f] || (r == br[f] && n < bn[f])) {
105
- t = $7; sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", t); sub(/^\[[A-Za-z]+\] /, "", t)
105
+ t = $7; sub(/^\[E[0-9]+(\.[0-9]+)?\] +/, "", t); sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", t); sub(/^\[[A-Za-z]+\] /, "", t)
106
106
  bn[f] = n; br[f] = r; bc[f] = $3; bt[f] = t
107
107
  }
108
108
  }
@@ -128,7 +128,7 @@ effort_next_rows() {
128
128
  # Every verb named here runs as written. `cckit digest` is deliberately absent: it summarises one
129
129
  # <path|url> with a local model, it does not report on the week.
130
130
  effort_cadence_md() {
131
- printf '%s\n' '**Weekly cadence** — Monday: `cckit plan` orders the week · daily: `cckit next` picks up one issue · Friday: `cckit gc` reports what can be pruned.'
131
+ printf '%s\n' '**Weekly cadence** — Monday: `cckit effort plan --issues` orders the week · daily: `cckit next` picks up one issue · Friday: `cckit gc` reports what can be pruned.'
132
132
  }
133
133
 
134
134
  # Rows travel between the readers and the planner as five fields joined by the ASCII unit
@@ -281,7 +281,7 @@ effort_plan() {
281
281
  local note=""; case "${ctxs[$i]}" in L|XL) note=" → delegate subs" ;; esac
282
282
  local dep=""; [[ -n "${blocks[$i]}" ]] && dep=" (after #${blocks[$i]//,/, #})"
283
283
  # strip the "[Effort] N · " prefix + a leading "[Flow] " tag — #N and the flow are already shown.
284
- local disp; disp="$(printf '%s' "${titles[$i]}" | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
284
+ local disp; disp="$(printf '%s' "${titles[$i]}" | sed -E 's/^\[E[0-9]+(\.[0-9]+)?\] +//; s/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
285
285
  printf ' #%-4s [%-2s] %s%s%s\n' "${nums[$i]}" "${ctxs[$i]}" "$disp" "$dep" "$note"
286
286
  done
287
287
  done
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # effort-review-test.sh — `cckit effort review` (scripts/lib/effort-review.sh, #583): the verdict
4
+ # table, over the forge shim and a throwaway repo with an effort branch. Hermetic, no network.
5
+ # errors: strict — a test runner: rc 1 on any failed assertion
6
+ set -u
7
+ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
8
+ # shellcheck source=/dev/null
9
+ . "$ROOT/scripts/lib/test-env.sh" && test_env_seal
10
+ LIB="$ROOT/scripts/lib"
11
+ fail=0
12
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
13
+ has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> lacks '$3' in: $2"; fail=1 ;; esac; }
14
+ command -v jq >/dev/null 2>&1 || { echo "effort-review-test: jq required" >&2; exit 1; }
15
+
16
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
17
+ export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
18
+ stub="$tmp/bin"
19
+ # shellcheck source=/dev/null
20
+ . "$LIB/test-forge-shim.sh"; forge_shim_install "$stub"
21
+ export PATH="$stub:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github KIT_REPO=o/r
22
+ export GH_FIXTURE="$tmp/fixture.sh"
23
+ cat > "$GH_FIXTURE" <<'SH'
24
+ case "$method $ep" in
25
+ "GET repos/o/r/issues/7/sub_issues") out="${SUBS_JSON:-[]}" ;;
26
+ "GET repos/o/r/issues/8/sub_issues") out='[]' ;;
27
+ esac
28
+ SH
29
+ # shellcheck source=/dev/null
30
+ . "$LIB/effort-review.sh"
31
+
32
+ # ── the verdict, pure ─────────────────────────────────────────────────────────────────────────
33
+ t "closed + spec + landed is done" "$(effort_review_verdict closed ok yes)" "done"
34
+ t "closed + spec, no branch to check" "$(effort_review_verdict closed ok -)" "done"
35
+ t "closed but not on the branch" "$(effort_review_verdict closed ok no)" "closed, not on the branch"
36
+ t "landed, issue still open" "$(effort_review_verdict open ok yes)" "landed, still open"
37
+ t "open" "$(effort_review_verdict open ok no)" "open"
38
+ t "no spec wins over a closed state" "$(effort_review_verdict closed none yes)" "no spec"
39
+
40
+ # ── a repo with the effort branch: #11 and #12 have commits, #13 does not ─────────────────────
41
+ repo="$tmp/repo"; mkdir -p "$repo"
42
+ git -C "$repo" init -q -b main
43
+ git -C "$repo" -c user.name=t -c user.email=t@t commit -q --allow-empty -m "base"
44
+ git -C "$repo" checkout -q -b effort/7-the-thing
45
+ git -C "$repo" -c user.name=t -c user.email=t@t commit -q --allow-empty -m "feat: one [E7.1]
46
+
47
+ Closes #11"
48
+ git -C "$repo" -c user.name=t -c user.email=t@t commit -q --allow-empty -m "feat: two (#12)"
49
+ git -C "$repo" -c user.name=t -c user.email=t@t commit -q --allow-empty -m "chore: mentions #130 only"
50
+ git -C "$repo" checkout -q main
51
+
52
+ spec='## Spec\n- the thing works'
53
+ SUBS_JSON="$(jq -cn --arg s "$(printf "$spec")" '[
54
+ {number: 11, state: "closed", title: "One", body: $s},
55
+ {number: 12, state: "open", title: "Two", body: $s},
56
+ {number: 13, state: "closed", title: "Three", body: $s},
57
+ {number: 14, state: "open", title: "Four", body: "## Spec\n- TODO"}
58
+ ]')"
59
+ export SUBS_JSON
60
+ : > "$GH_LOG"
61
+ out="$(cd "$repo" && effort_review 7 2>&1)"; rc=$?
62
+ t "a sub not done is rc 1" "$rc" "1"
63
+ has "the table header" "$out" "$(printf 'sub\tstate\tspec\tlanded\tverdict\ttitle')"
64
+ has "#11 is done" "$out" "$(printf '#11\tclosed\tok\tyes\tdone\tOne')"
65
+ has "#12 landed but open" "$out" "$(printf '#12\topen\tok\tyes\tlanded, still open\tTwo')"
66
+ has "#13 is not matched by #130" "$out" "$(printf '#13\tclosed\tok\tno\tclosed, not on the branch\tThree')"
67
+ has "#14 has only a placeholder Spec" "$out" "$(printf '#14\topen\tnone\tno\tno spec\tFour')"
68
+ has "the summary names the branch" "$out" "review #7: 1 of 4 done (branch effort/7-the-thing)"
69
+ t "one read, no writes" "$(grep -c . "$GH_LOG")" "1"
70
+ t "the read is the sub-issues list" "$(grep -c '^GET repos/o/r/issues/7/sub_issues' "$GH_LOG")" "1"
71
+
72
+ SUBS_JSON="$(jq -cn --arg s "$(printf "$spec")" '[{number: 11, state: "closed", title: "One", body: $s}]')"
73
+ out="$(cd "$repo" && effort_review 7 2>&1)"; rc=$?
74
+ t "every sub done is rc 0" "$rc" "0"
75
+ has "all done summary" "$out" "review #7: 1 of 1 done"
76
+
77
+ out="$(cd "$repo" && effort_review 7 --branch main 2>&1)"; rc=$?
78
+ has "--branch picks the branch" "$out" "$(printf '#11\tclosed\tok\tno\tclosed, not on the branch')"
79
+ out="$(cd "$repo" && effort_review 7 --branch nope 2>&1)"; rc=$?
80
+ t "an unreadable branch is rc 1" "$rc" "1"
81
+
82
+ out="$(cd "$tmp" && effort_review 7 2>&1)"; rc=$?
83
+ has "no branch: landed is unknown" "$out" "$(printf '#11\tclosed\tok\t-\tdone')"
84
+
85
+ out="$(cd "$repo" && effort_review 8 2>&1)"; rc=$?
86
+ t "no subs is rc 1" "$rc" "1"
87
+ has "no subs says so" "$out" "#8 has no sub-issues"
88
+
89
+ # ── usage ─────────────────────────────────────────────────────────────────────────────────────
90
+ : > "$GH_LOG"
91
+ effort_review >/dev/null 2>&1; t "no effort is rc 2" "$?" "2"
92
+ effort_review abc >/dev/null 2>&1; t "a non-number is rc 2" "$?" "2"
93
+ effort_review 7 8 >/dev/null 2>&1; t "two efforts is rc 2" "$?" "2"
94
+ effort_review 7 --bogus >/dev/null 2>&1; t "an unknown flag is rc 2" "$?" "2"
95
+ t "usage errors read nothing" "$(grep -c . "$GH_LOG")" "0"
96
+
97
+ out="$(CCKIT_FORGE=none; export CCKIT_FORGE; unset _FORGE_LOADED; effort_review 7 2>&1)"; rc=$?
98
+ t "no forge: rc 1" "$rc" "1"
99
+ has "no forge: names the verb" "$out" "effort review"
100
+
101
+ # ── the dispatcher routes it ──────────────────────────────────────────────────────────────────
102
+ out="$(cd "$repo" && "$ROOT/bin/cckit" effort review 2>&1)"; rc=$?
103
+ t "cckit effort review with no N is rc 2" "$rc" "2"
104
+ has "cckit effort review prints its usage" "$out" "usage: cckit effort review"
105
+
106
+ [ "$fail" -eq 0 ] && echo "ALL OK (effort-review)"
107
+ exit "$fail"
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # effort-review.sh — `cckit effort review <N>` (E547, #583): check each sub of an effort against its
4
+ # own `## Spec`, one verdict line per sub. A read: it writes nothing on the forge or in git.
5
+ #
6
+ # effort_review <N> [--branch B]
7
+ #
8
+ # Per sub it reads the forge state and the body, runs spec_lint on the body, and looks on the
9
+ # effort branch (`effort/<N>-*`, local or origin, or --branch) for a commit that names the sub
10
+ # (`#<sub>`). Verdicts, first match wins:
11
+ # no spec the sub's body has no checkable `## Spec` — nothing to review against
12
+ # done closed, and on the branch (or no branch found to check)
13
+ # closed, not on the branch closed on the forge, but no commit on the effort branch names it
14
+ # landed, still open a commit names it, the issue is still open
15
+ # open neither
16
+ # Output: a TSV table (sub, state, spec, landed, verdict, title), then `review #N: D of M done`.
17
+ # rc 0 when every sub is done · 1 when one is not, or the forge read failed · 2 usage.
18
+ # bash 3.2 compatible.
19
+ # errors: strict — a check: rc 1 on any sub that is not done
20
+
21
+ if ! command -v spec_lint >/dev/null 2>&1; then
22
+ # shellcheck source=/dev/null
23
+ . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/spec-lint.sh"
24
+ fi
25
+ if ! command -v forge_rest >/dev/null 2>&1 && ! command -v gh_rest_issue_json >/dev/null 2>&1; then
26
+ # shellcheck source=/dev/null
27
+ . "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
28
+ fi
29
+
30
+ # _er_branch <N> — the effort branch: a local `effort/<N>-*`, else origin's. Empty when neither.
31
+ _er_branch() {
32
+ git for-each-ref --format='%(refname:short)' "refs/heads/effort/$1-*" "refs/remotes/origin/effort/$1-*" 2>/dev/null | sed -n 1p
33
+ }
34
+
35
+ # effort_review_verdict <state> <spec ok|none> <landed yes|no|-> — the verdict for one sub. Pure.
36
+ effort_review_verdict() {
37
+ local state="$1" spec="$2" landed="$3"
38
+ if [ "$spec" != ok ]; then echo "no spec"; return; fi
39
+ case "$state:$landed" in
40
+ closed:yes|closed:-) echo "done" ;;
41
+ closed:no) echo "closed, not on the branch" ;;
42
+ open:yes) echo "landed, still open" ;;
43
+ *) echo "open" ;;
44
+ esac
45
+ }
46
+
47
+ effort_review() {
48
+ local num="" branch="" repo subs n i sub state title body spec landed verdict log done_n=0
49
+ while [ $# -gt 0 ]; do
50
+ case "$1" in
51
+ --branch) [ $# -ge 2 ] || { echo "effort review: --branch needs a name" >&2; return 2; }; branch="$2"; shift 2 ;;
52
+ --branch=*) branch="${1#--branch=}"; shift ;;
53
+ -*) echo "effort review: unknown flag '$1'" >&2; return 2 ;;
54
+ *) [ -z "$num" ] || { echo "effort review: one effort at a time" >&2; return 2; }; num="${1#\#}"; shift ;;
55
+ esac
56
+ done
57
+ case "$num" in ''|*[!0-9]*) echo "usage: cckit effort review <N> [--branch B]" >&2; return 2 ;; esac
58
+ forge_need "effort review" || return 1
59
+ command -v jq >/dev/null 2>&1 || { echo "effort review: jq is required" >&2; return 1; }
60
+ repo="${EFFORT_REPO:-${KIT_REPO:-}}"
61
+ [ -n "$repo" ] || repo="$(forge_repo_from_git 2>/dev/null)" || { echo "effort review: no repository (github.repo unset)" >&2; return 1; }
62
+
63
+ subs="$(forge_rest "repos/$repo/issues/$num/sub_issues" -X GET -f per_page=100 \
64
+ --jq '[.[] | {number, state, title, body: (.body // "")}] | tojson' 2>&1)" || {
65
+ printf 'effort review: could not read the subs of #%s\n%s\n' "$num" "$subs" >&2; return 1; }
66
+ n="$(printf '%s' "$subs" | jq 'length')"
67
+ [ "${n:-0}" -gt 0 ] || { echo "effort review: #$num has no sub-issues" >&2; return 1; }
68
+
69
+ [ -n "$branch" ] || branch="$(_er_branch "$num")"
70
+ log=""
71
+ if [ -n "$branch" ]; then
72
+ log="$(git log --format=%B "$branch" 2>/dev/null)" || { echo "effort review: cannot read branch '$branch'" >&2; return 1; }
73
+ fi
74
+
75
+ printf 'sub\tstate\tspec\tlanded\tverdict\ttitle\n'
76
+ i=0
77
+ while [ "$i" -lt "$n" ]; do
78
+ sub="$(printf '%s' "$subs" | jq -r ".[$i].number")"
79
+ state="$(printf '%s' "$subs" | jq -r ".[$i].state")"
80
+ title="$(printf '%s' "$subs" | jq -r ".[$i].title")"
81
+ body="$(printf '%s' "$subs" | jq -r ".[$i].body")"
82
+ if spec_lint "$body" 2>/dev/null; then spec=ok; else spec=none; fi
83
+ if [ -z "$branch" ]; then landed="-"
84
+ elif grep -qE "(^|[^0-9A-Za-z])#$sub([^0-9]|$)" <<<"$log"; then landed=yes
85
+ else landed=no; fi
86
+ verdict="$(effort_review_verdict "$state" "$spec" "$landed")"
87
+ [ "$verdict" = done ] && done_n=$((done_n + 1))
88
+ printf '#%s\t%s\t%s\t%s\t%s\t%s\n' "$sub" "$state" "$spec" "$landed" "$verdict" "$title"
89
+ i=$((i + 1))
90
+ done
91
+ printf 'review #%s: %s of %s done%s\n' "$num" "$done_n" "$n" "${branch:+ (branch $branch)}"
92
+ [ "$done_n" -eq "$n" ]
93
+ }
@@ -43,6 +43,10 @@ t "_eff_title_slug peels prefix + flow (sub)" \
43
43
  "$(_eff_title_slug '[Effort 93] 2 · [UI] Accept slug in commands')" "accept-slug-in-commands"
44
44
  t "_eff_title_slug without a flow tag" \
45
45
  "$(_eff_title_slug '[Effort] 12 · plain outcome name')" "plain-outcome-name"
46
+ t "_eff_title_slug peels the [E<n>] prefix" \
47
+ "$(_eff_title_slug '[E93] Slug handles for efforts')" "slug-handles-for-efforts"
48
+ t "_eff_title_slug peels the [E<n>.<step>] prefix" \
49
+ "$(_eff_title_slug '[E93.2] Accept slug in commands')" "accept-slug-in-commands"
46
50
  t "_eff_slug lowercases + dashes arbitrary text" \
47
51
  "$(_eff_slug 'Some Mixed CASE!!')" "some-mixed-case"
48
52
 
@@ -57,8 +57,9 @@ _eff_slug() {
57
57
  # the cosmetic doubling that produced branches like `effort/98-98-core-…`). See #93 / sub #96.
58
58
  _eff_title_slug() {
59
59
  local t="$1"
60
- # structural prefix: "[Effort] N · " (parent) or "[Effort N] M · " (sub)
61
- t="$(printf '%s' "$t" | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ ·? ?//')"
60
+ # structural prefix: "[E<n>] " / "[E<n>.<step>] ", or the legacy "[Effort] N · " (parent) and
61
+ # "[Effort N] M · " (sub)
62
+ t="$(printf '%s' "$t" | sed -E -e 's/^\[E[0-9]+(\.[0-9]+)?\] +//' -e 's/^\[Effort( [0-9]+)?\] [0-9]+ ·? ?//')"
62
63
  # one optional leading [Flow] tag
63
64
  t="$(printf '%s' "$t" | sed -E 's/^\[[A-Za-z]+\][[:space:]]*//')"
64
65
  _eff_slug "$t"
@@ -133,7 +134,7 @@ effort_branch_rows_origin() {
133
134
  # effort_slug_resolve <slug|N> → echo the canonical effort number on stdout (rc 0).
134
135
  # - pure digits → passthrough (number stays canonical; never re-mapped).
135
136
  # - otherwise normalize and match, in order: effort/* branches (local + remote), then (via gh)
136
- # slug:<slug> labels, then title-derived slugs of open `[Effort]` issues.
137
+ # slug:<slug> labels, then title-derived slugs of open `[E<n>]` (or legacy `[Effort]`) issues.
137
138
  # - no match → rc 1; >1 distinct match → rc 1 (ambiguous, never a wrong guess); empty/unusable → rc 2.
138
139
  effort_slug_resolve() {
139
140
  local input="${1:-}"
@@ -161,7 +162,7 @@ effort_slug_resolve() {
161
162
  matches="$(gh_rest_issue_numbers_by_label "$repo" "slug:$norm" 2>/dev/null | grep -E '^[0-9]+$' | sort -un)"
162
163
  if [ -z "$matches" ]; then
163
164
  local in it
164
- matches="$( { gh_rest_open_issue_titles "$repo" | grep -F '[Effort]'; } 2>/dev/null \
165
+ matches="$( { gh_rest_open_issue_titles "$repo" | grep -E "$(printf '\t')"'\[(Effort\]|E[0-9]+\] )'; } 2>/dev/null \
165
166
  | while IFS="$(printf '\t')" read -r in it; do
166
167
  [ "$(_eff_title_slug "$it")" = "$norm" ] && printf '%s\n' "$in"
167
168
  done | grep -E '^[0-9]+$' | sort -un)"