@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.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +45 -41
- package/README.md +39 -29
- package/bin/cckit +111 -70
- package/cckit.config.json +1 -1
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot.sh +4 -4
- package/scripts/capture-project-ids.sh +16 -0
- package/scripts/check.sh +6 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/copilot-loop-test.sh +8 -8
- package/scripts/force-push-fence-test.sh +44 -0
- package/scripts/force-push-fence.baseline +1 -0
- package/scripts/force-push-fence.sh +51 -0
- package/scripts/init.sh +2 -2
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +5 -0
- package/scripts/kit-doctor.sh +96 -2
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +3 -2
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +1 -1
- package/scripts/lib/copilot-test.sh +4 -4
- package/scripts/lib/copilot.sh +13 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +2 -2
- package/scripts/lib/effort-ops-test.sh +98 -9
- package/scripts/lib/effort-ops.sh +390 -63
- package/scripts/lib/effort-parity-test.sh +37 -31
- package/scripts/lib/effort-plan.sh +3 -3
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +4 -0
- package/scripts/lib/effort-slug.sh +5 -4
- package/scripts/lib/effort.sh +47 -74
- package/scripts/lib/forge-github.sh +18 -7
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +115 -0
- package/scripts/lib/gh-project.sh +128 -6
- package/scripts/lib/gh-rest-test.sh +12 -8
- package/scripts/lib/gh-rest.sh +189 -15
- package/scripts/lib/git-core-test.sh +2 -2
- package/scripts/lib/grill-record-test.sh +49 -0
- package/scripts/lib/grill-record.sh +88 -0
- package/scripts/lib/handoff.sh +1 -1
- package/scripts/lib/kit-brief-test.sh +29 -0
- package/scripts/lib/kit-brief.sh +91 -6
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +7 -7
- package/scripts/lib/kit-msg.sh +3 -3
- package/scripts/lib/kit-status.sh +1 -1
- package/scripts/lib/kit-task-ops-test.sh +17 -0
- package/scripts/lib/kit-task-ops.sh +73 -22
- package/scripts/lib/kto-task-new-test.sh +18 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +44 -0
- package/scripts/lib/kto-task-pr-test.sh +3 -3
- package/scripts/lib/light-task.sh +16 -1
- package/scripts/lib/loose-issues.sh +65 -0
- package/scripts/lib/naming-test.sh +112 -0
- package/scripts/lib/naming-verbs-test.sh +126 -0
- package/scripts/lib/naming.sh +172 -0
- package/scripts/lib/next-test.sh +1 -1
- package/scripts/lib/next.sh +6 -6
- package/scripts/lib/plan-machine.sh +9 -9
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/qa-lane.sh +1 -1
- package/scripts/lib/spec-lint-test.sh +63 -0
- package/scripts/lib/spec-lint.sh +95 -0
- package/scripts/lib/sprint-test.sh +96 -0
- package/scripts/lib/sprint.sh +216 -0
- package/scripts/lib/stage-receipt-test.sh +132 -0
- package/scripts/lib/stage-receipt.sh +184 -5
- package/scripts/lib/test-forge-shim.sh +2 -1
- package/scripts/lib/verbs.sh +1 -1
- package/scripts/lib/verbs.tsv +17 -15
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-start.sh +42 -1
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/night-grant.sh +1 -1
- package/scripts/portable-test.sh +1 -1
- package/scripts/status-test.sh +1 -1
- package/scripts/status.sh +4 -4
- package/scripts/task-sync-test.sh +34 -0
- package/scripts/task-sync.sh +81 -1
- package/scripts/terms-check.sh +1 -1
- package/scripts/verbs-ratchet-test.sh +6 -1
- package/scripts/verbs-test.sh +4 -4
- package/scripts/verbs.baseline +1 -1
- package/skills/kit-add/SKILL.md +1 -1
- package/skills/kit-advisor/SKILL.md +75 -0
- package/skills/kit-advisor/references/close.md +53 -0
- package/skills/kit-advisor/references/grill.md +69 -0
- package/skills/kit-advisor/references/orchestrate.md +56 -0
- package/skills/kit-advisor/references/plan.md +64 -0
- package/skills/kit-advisor/references/review.md +47 -0
- package/skills/kit-advisor/references/step-report.md +61 -0
- package/skills/kit-autopilot/SKILL.md +1 -1
- package/skills/kit-cleanup/SKILL.md +2 -2
- package/skills/kit-effort-close/SKILL.md +16 -8
- package/skills/kit-effort-new/SKILL.md +11 -8
- package/skills/kit-effort-pr/SKILL.md +7 -7
- package/skills/kit-next/SKILL.md +7 -7
- package/skills/kit-plan-next/SKILL.md +10 -11
- package/skills/kit-status/SKILL.md +5 -5
- package/skills/kit-task-pr-auto/SKILL.md +1 -1
- package/skills/kit-task-pr-merge/SKILL.md +3 -3
- package/skills/kit-task-sync/SKILL.md +2 -0
- package/skills/routing.yaml +5 -0
- package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
- package/templates/instructions.md.tmpl +3 -3
- package/templates/rules/authoring.md +7 -3
- package/templates/rules/delegation-brief.md +4 -0
- package/templates/rules/effort-model.md +34 -31
- package/templates/rules/gate-and-review.md +1 -1
- package/templates/rules/merge-safety.md +9 -7
- package/templates/rules/naming-and-ids.md +20 -24
- package/templates/rules/plan-next.md +5 -5
- package/templates/skills/campaign/SKILL.md +2 -2
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
# from any shell or agent (not only via the effort-* skills). Thin: composes the git-mechanics helpers
|
|
5
5
|
# in effort.sh (linking, snapshots, title lint) plus gh + git. bash 3.2 compatible. Requires: gh, jq, git.
|
|
6
6
|
#
|
|
7
|
-
# effort_new [flags] "<name>" [<sub spec> …] parent (
|
|
7
|
+
# effort_new [flags] "<name>" [<sub spec> …] parent (5-section body + labels) + native sub-issues;
|
|
8
|
+
# --grilling[-file] appends a linted `## Grilling` record;
|
|
9
|
+
# --sprint[=YYYY-MM-DD] files it into that week's sprint
|
|
10
|
+
# effort_sub <slug|N> "<name>" [--kind K] add one sub-issue, titled [E<N>.<step>] <name>
|
|
11
|
+
# effort_retitle [<slug|N>] [--apply] rename legacy [Effort] titles (dry run by default)
|
|
8
12
|
# effort_chain <a> <b> [<c> …] wire N issues into a linear blocked_by chain (#243)
|
|
9
13
|
# effort_start [--force] <slug|N> [<slug>] effort/<N> branch + worktree from base, WIP-limited (#244)
|
|
10
14
|
# effort_pr [<slug|N>] open the ONE PR effort/<N> → base branch
|
|
11
|
-
# effort_close <slug|N>
|
|
15
|
+
# effort_close <slug|N> [--no-spec-check] check the Spec, snapshot sub-diffs, squash-merge, close the
|
|
16
|
+
# parent + finished subs (unfinished stay open, listed)
|
|
12
17
|
#
|
|
13
18
|
# effort_new is the SHARED creation core (effort #98): both `cckit effort new` (the verb) and
|
|
14
19
|
# /kit-effort-new (the skill) call it, so they produce structurally identical efforts — one source of
|
|
@@ -34,6 +39,40 @@ if ! command -v effort_slug_resolve >/dev/null 2>&1; then
|
|
|
34
39
|
unset _eo_dir
|
|
35
40
|
fi
|
|
36
41
|
|
|
42
|
+
# The one title convention (naming.sh, E546.1): every title effort_new / effort_sub / effort_pr
|
|
43
|
+
# writes is linted there first, and every title read back is stripped there.
|
|
44
|
+
if ! command -v naming_title_lint >/dev/null 2>&1; then
|
|
45
|
+
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
46
|
+
# shellcheck source=/dev/null
|
|
47
|
+
[ -f "$_eo_dir/naming.sh" ] && . "$_eo_dir/naming.sh"
|
|
48
|
+
unset _eo_dir
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# The `## Spec` check (spec-lint.sh, E546.5): effort_new lints the body it composed, effort_close
|
|
52
|
+
# the body it reads back.
|
|
53
|
+
if ! command -v spec_lint >/dev/null 2>&1; then
|
|
54
|
+
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
55
|
+
# shellcheck source=/dev/null
|
|
56
|
+
[ -f "$_eo_dir/spec-lint.sh" ] && . "$_eo_dir/spec-lint.sh"
|
|
57
|
+
unset _eo_dir
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# The `## Grilling` record check (grill-record.sh, E547.2): effort_new lints --grilling before writing.
|
|
61
|
+
if ! command -v grill_record_lint >/dev/null 2>&1; then
|
|
62
|
+
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
63
|
+
# shellcheck source=/dev/null
|
|
64
|
+
[ -f "$_eo_dir/grill-record.sh" ] && . "$_eo_dir/grill-record.sh"
|
|
65
|
+
unset _eo_dir
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# The sprint (sprint.sh, #570): effort_new --sprint files the effort into the current week's sprint.
|
|
69
|
+
if ! command -v sprint_name >/dev/null 2>&1; then
|
|
70
|
+
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
71
|
+
# shellcheck source=/dev/null
|
|
72
|
+
[ -f "$_eo_dir/sprint.sh" ] && . "$_eo_dir/sprint.sh"
|
|
73
|
+
unset _eo_dir
|
|
74
|
+
fi
|
|
75
|
+
|
|
37
76
|
# The closed kind: vocabulary (KIT_KINDS / kit_kind_valid) — what `effort new --kind` accepts.
|
|
38
77
|
if ! command -v kit_kind_valid >/dev/null 2>&1; then
|
|
39
78
|
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
@@ -58,16 +97,21 @@ _eff_need() { command -v "$1" >/dev/null 2>&1 || { echo "effort: $1 is required
|
|
|
58
97
|
# _eff_forge — rc 0 with a forge; without one, forge_need's one line (naming the verb), rc 1.
|
|
59
98
|
_eff_forge() { forge_need; }
|
|
60
99
|
|
|
61
|
-
# Compose the
|
|
100
|
+
# Compose the five-section parent body (rules/effort-model.md): the sections double as the work
|
|
62
101
|
# record. An empty section falls back to its template placeholder so a bare call still yields the
|
|
63
|
-
# full
|
|
64
|
-
#
|
|
102
|
+
# full scaffold; passing content fills it. The Spec is built by spec_section (plain lines become
|
|
103
|
+
# bullets); an empty one keeps only its hint, which spec_lint refuses. The `## Relations` chain is
|
|
104
|
+
# NOT composed here — it is layered on afterwards by _eff_relations_add (one formatter, #243).
|
|
65
105
|
_eff_compose_body() {
|
|
66
|
-
local goal="$1" scope="$2" for_agents="$3" verification="$4"
|
|
106
|
+
local goal="$1" scope="$2" for_agents="$3" verification="$4" spec="${5:-}" spec_md
|
|
107
|
+
if [ -n "$spec" ]; then spec_md="$(spec_section "$spec")"
|
|
108
|
+
else spec_md="$(printf '## Spec\n<!-- what done means: a checkable list, one item per line -->')"; fi
|
|
67
109
|
cat <<EOF
|
|
68
110
|
## Goal
|
|
69
111
|
${goal:-<!-- problem statement: what outcome, in one or two lines -->}
|
|
70
112
|
|
|
113
|
+
${spec_md}
|
|
114
|
+
|
|
71
115
|
## Scope
|
|
72
116
|
${scope:-<!-- the sub-issue plan; mark each parallel | sequential / dependsOn -->}
|
|
73
117
|
|
|
@@ -135,7 +179,7 @@ _eff_board_add() {
|
|
|
135
179
|
command -v project_add_item >/dev/null 2>&1 || return 0
|
|
136
180
|
repo="$(_eff_repo)"
|
|
137
181
|
node="$(forge_rest "repos/$repo/issues/$n" --jq .node_id 2>/dev/null)" || return 0
|
|
138
|
-
item="$(project_add_item "$node" 2>/dev/null)" || return 0
|
|
182
|
+
item="$(project_add_item "$node" "$repo" "$n" Issue 2>/dev/null)" || return 0
|
|
139
183
|
[ -n "$item" ] || return 0
|
|
140
184
|
[ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_TODO:-}" ] \
|
|
141
185
|
&& project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_TODO" 2>/dev/null || true
|
|
@@ -148,9 +192,10 @@ _eff_board_add() {
|
|
|
148
192
|
}
|
|
149
193
|
|
|
150
194
|
# effort_new [flags] "<name>" [<sub spec> …] — the shared creation core (effort #98).
|
|
151
|
-
# Flags
|
|
195
|
+
# Flags: --spec T | --spec-file F (required: what done means, checked by spec_lint before any forge
|
|
196
|
+
# write); optional --flow F --role R --priority p1 --goal G --scope S --for-agents A
|
|
152
197
|
# --verification V --depends-on "#1,#2" --milestone M --slug S. A <sub spec> is "name :: one-line
|
|
153
|
-
# desc" (the desc is optional → just "name"). Fills the
|
|
198
|
+
# desc" (the desc is optional → just "name"). Fills the five body sections, applies the
|
|
154
199
|
# ctx/kind/priority/role/flow label set, lints the parent + EVERY sub title up front (so a bad sub
|
|
155
200
|
# name aborts before anything is created), links native sub-issues, sets blocked_by edges, adds
|
|
156
201
|
# everything to the board (guarded), and records the human slug handle (#93) as a slug:<slug> label.
|
|
@@ -160,7 +205,7 @@ effort_new() {
|
|
|
160
205
|
local repo; repo="$(_eff_repo)"
|
|
161
206
|
[ -n "$repo" ] || { echo "effort_new: no repo (KIT_REPO/EFFORT_REPO unset — run in a kit project)" >&2; return 1; }
|
|
162
207
|
|
|
163
|
-
local flow="" role="" priority="p1" goal="" scope="" for_agents="" verification="" depends_on="" milestone="" explicit_slug="" kind="task"
|
|
208
|
+
local flow="" role="" priority="p1" goal="" scope="" for_agents="" verification="" depends_on="" milestone="" explicit_slug="" kind="task" spec_text="" grilling="" sprint_day=""
|
|
164
209
|
# Flags are position-INDEPENDENT: recognized --flag [value] pairs are consumed wherever they occur
|
|
165
210
|
# (before the title, between subs, or after them) and the remaining positionals are collected as the
|
|
166
211
|
# title (first) + sub specs (rest). Previously the parser broke at the first positional, so any flag
|
|
@@ -176,6 +221,17 @@ effort_new() {
|
|
|
176
221
|
--scope) scope="${2:-}"; shift 2 ;;
|
|
177
222
|
--for-agents) for_agents="${2:-}"; shift 2 ;;
|
|
178
223
|
--verification) verification="${2:-}"; shift 2 ;;
|
|
224
|
+
--spec) spec_text="${2:-}"; shift 2 ;;
|
|
225
|
+
--spec=*) spec_text="${1#*=}"; shift ;;
|
|
226
|
+
--spec-file)
|
|
227
|
+
[ -r "${2:-}" ] || { echo "effort_new: --spec-file: cannot read '${2:-}'" >&2; return 1; }
|
|
228
|
+
spec_text="$(cat "$2")"; shift 2 ;;
|
|
229
|
+
--grilling) grilling="${2:-}"; shift 2 ;;
|
|
230
|
+
--grilling-file)
|
|
231
|
+
[ -r "${2:-}" ] || { echo "effort_new: --grilling-file: cannot read '${2:-}'" >&2; return 1; }
|
|
232
|
+
grilling="$(cat "$2")"; shift 2 ;;
|
|
233
|
+
--sprint) sprint_day="today"; shift ;;
|
|
234
|
+
--sprint=*) sprint_day="${1#*=}"; shift ;;
|
|
179
235
|
--depends-on) depends_on="${2:-}"; shift 2 ;;
|
|
180
236
|
--milestone) milestone="${2:-}"; shift 2 ;;
|
|
181
237
|
--slug) explicit_slug="${2:-}"; shift 2 ;;
|
|
@@ -200,29 +256,49 @@ effort_new() {
|
|
|
200
256
|
local name="${1:-}"; shift || true
|
|
201
257
|
[ -n "$name" ] || { echo 'effort_new: usage: effort_new [flags] "<name>" [<sub spec> …]' >&2; return 1; }
|
|
202
258
|
|
|
203
|
-
#
|
|
204
|
-
|
|
259
|
+
# The title is `[E<n>] <name>` (rules/naming-and-ids.md, E546.1): the flow lives in the flow:
|
|
260
|
+
# label, so no [Flow] tag is written into the title any more. Lint the parent name BEFORE creating
|
|
261
|
+
# anything (synthetic number 0: the rule is about the NAME, not the not-yet-assigned N).
|
|
262
|
+
naming_title_lint effort "$(naming_effort_title 0 "$name")" || { echo "effort_new: fix the name and retry" >&2; return 1; }
|
|
205
263
|
|
|
206
|
-
#
|
|
207
|
-
#
|
|
208
|
-
effort_title_lint "[Effort] 0 · ${flow_tag}${name}" || { echo "effort_new: fix the name and retry" >&2; return 1; }
|
|
209
|
-
|
|
210
|
-
# Lint EVERY sub title up front too (parity with the skill's intent) so a bad sub name fails the
|
|
211
|
-
# whole op before a half-effort exists. Synthetic parent number 0 for the lint.
|
|
264
|
+
# Lint EVERY sub title up front too, so a bad sub name fails the whole op before a half-effort
|
|
265
|
+
# exists. Synthetic parent number 0 for the lint.
|
|
212
266
|
local i=0 spec sub_name sub_title
|
|
213
267
|
for spec in "$@"; do
|
|
214
268
|
i=$((i + 1))
|
|
215
269
|
sub_name="${spec%% :: *}"
|
|
216
|
-
sub_title="
|
|
217
|
-
|
|
270
|
+
sub_title="$(naming_sub_title 0 "$i" "$sub_name")"
|
|
271
|
+
naming_title_lint sub "$sub_title" \
|
|
218
272
|
|| { echo "effort_new: fix sub title #$i and retry: $sub_name" >&2; return 1; }
|
|
219
273
|
done
|
|
220
274
|
|
|
221
|
-
# Compose the
|
|
275
|
+
# Compose the five-section body, then layer the ## Relations chain from --depends-on through the
|
|
222
276
|
# ONE formatter (#243) — the same one `effort_chain` uses, so both write identical lines. (It was
|
|
223
277
|
# built inline here before, and `$( … )` ate every newline: the section shipped as the single
|
|
224
278
|
# mangled line `## Relations- Depends on #1- Depends on #2`.)
|
|
225
|
-
local body d; body="$(_eff_compose_body "$goal" "$scope" "$for_agents" "$verification")"
|
|
279
|
+
local body d; body="$(_eff_compose_body "$goal" "$scope" "$for_agents" "$verification" "$spec_text")"
|
|
280
|
+
# The Spec (E546.5): checked on the composed body, before any label or issue is written.
|
|
281
|
+
spec_lint "$body" || { echo 'effort_new: say what done means with --spec "<item>" or --spec-file F, and retry' >&2; return 1; }
|
|
282
|
+
# The Grilling record (E547.2): optional, but a record that is passed must be one — linted here,
|
|
283
|
+
# before any forge write, then appended as the body's `## Grilling` section.
|
|
284
|
+
if [ -n "$grilling" ]; then
|
|
285
|
+
grill_record_lint "$grilling" || { echo 'effort_new: fix the --grilling record and retry' >&2; return 1; }
|
|
286
|
+
body="$body"$'\n\n'"$(grill_record_section "$grilling")"
|
|
287
|
+
fi
|
|
288
|
+
# The sprint (#570): --sprint names the week the effort is planned into, in the body and as the
|
|
289
|
+
# milestone of the parent and every sub. The milestone is opened when it does not exist yet.
|
|
290
|
+
local sprint="" sprint_start="" sprint_end=""
|
|
291
|
+
if [ -n "$sprint_day" ]; then
|
|
292
|
+
[ "$sprint_day" = today ] && sprint_day="$(_sprint_today)"
|
|
293
|
+
sprint="$(sprint_name "$sprint_day")" || { echo "effort_new: --sprint=YYYY-MM-DD names a day of the sprint" >&2; return 1; }
|
|
294
|
+
IFS="$(printf '\t')" read -r sprint_start sprint_end <<EOF_SB
|
|
295
|
+
$(sprint_bounds "$sprint_day")
|
|
296
|
+
EOF_SB
|
|
297
|
+
[ -z "$milestone" ] || [ "$milestone" = "$sprint" ] \
|
|
298
|
+
|| { echo "effort_new: --sprint and --milestone name different milestones ($sprint, $milestone)" >&2; return 1; }
|
|
299
|
+
milestone="$sprint"
|
|
300
|
+
body="$body"$'\n\n'"$(printf '## Sprint\n%s · Monday %s to Monday %s' "$sprint" "$sprint_start" "$sprint_end")"
|
|
301
|
+
fi
|
|
226
302
|
if [ -n "$depends_on" ]; then
|
|
227
303
|
for d in $(printf '%s' "$depends_on" | tr ',' ' '); do
|
|
228
304
|
d="${d#\#}"; [ -n "$d" ] && body="$(_eff_relations_add "$body" "$d")"
|
|
@@ -255,19 +331,27 @@ effort_new() {
|
|
|
255
331
|
labels="$labels,flow:$flow_lc"
|
|
256
332
|
fi
|
|
257
333
|
|
|
334
|
+
if [ -n "$sprint" ]; then
|
|
335
|
+
sprint_open --date "$sprint_day" >/dev/null 2>&1 \
|
|
336
|
+
|| echo "effort_new: could not open the sprint milestone $sprint — the effort is filed without it" >&2
|
|
337
|
+
fi
|
|
338
|
+
|
|
258
339
|
local url num slug
|
|
259
|
-
|
|
340
|
+
# The number is assigned by the create, so the parent is filed under its plain name and renamed
|
|
341
|
+
# to `[E<n>] <name>` at once. The `effort` label marks it as an effort in between.
|
|
342
|
+
url="$(gh_rest_issue_create "$repo" "$name" "$body" "$labels" "$milestone" 0)" \
|
|
260
343
|
|| { echo "effort_new: failed to create the parent issue" >&2; return 1; }
|
|
261
344
|
num="${url##*/}"
|
|
262
|
-
gh_rest_issue_edit_title "$repo" "$num" "
|
|
263
|
-
|
|
345
|
+
gh_rest_issue_edit_title "$repo" "$num" "$(naming_effort_title "$num" "$name")" >/dev/null 2>&1 \
|
|
346
|
+
|| echo "effort_new: #$num was created but not renamed to $(naming_effort_title "$num" "$name") — run: cckit effort retitle $num --apply" >&2
|
|
347
|
+
# The human handle (#93): explicit --slug if given, else derived from the name.
|
|
264
348
|
if [ -n "$explicit_slug" ]; then slug="$(_eff_slug "$explicit_slug")"
|
|
265
|
-
else slug="$(_eff_title_slug "
|
|
349
|
+
else slug="$(_eff_title_slug "$(naming_effort_title "$num" "$name")")"; fi
|
|
266
350
|
if [ -n "$slug" ]; then
|
|
267
351
|
gh_rest_label_create "$repo" "slug:$slug" ededed "effort slug handle"
|
|
268
352
|
gh_rest_issue_add_labels "$repo" "$num" "slug:$slug" >/dev/null 2>&1 || true
|
|
269
353
|
fi
|
|
270
|
-
echo " ✓ effort $(effort_display "$num" "$slug") · ${
|
|
354
|
+
echo " ✓ effort $(effort_display "$num" "$slug") · ${name}" >&2
|
|
271
355
|
|
|
272
356
|
# Native dependency edges (the visible board chain) — guarded on the helper being available.
|
|
273
357
|
if [ -n "$depends_on" ] && command -v effort_set_blocked_by >/dev/null 2>&1; then
|
|
@@ -286,7 +370,7 @@ effort_new() {
|
|
|
286
370
|
i=$((i + 1))
|
|
287
371
|
sub_name="${spec%% :: *}"
|
|
288
372
|
sub_desc="${spec#* :: }"; [ "$sub_desc" = "$spec" ] && sub_desc=""
|
|
289
|
-
sub_title="
|
|
373
|
+
sub_title="$(naming_sub_title "$num" "$i" "$sub_name")"
|
|
290
374
|
local sub_labels="kind:$kind,priority:$priority"
|
|
291
375
|
[ -n "$role" ] && sub_labels="$sub_labels,role:$role"
|
|
292
376
|
child="$(gh_rest_issue_create "$repo" "$sub_title" \
|
|
@@ -299,6 +383,144 @@ effort_new() {
|
|
|
299
383
|
printf '%s\n' "$num"
|
|
300
384
|
}
|
|
301
385
|
|
|
386
|
+
# effort_sub <slug|N> "<name>" [--kind K] [--body B] [--spec T] — add ONE sub-issue to an effort
|
|
387
|
+
# (E546.1). The title is `[E<N>.<step>] <name>`, step = the effort's current native sub count + 1; it
|
|
388
|
+
# is linted before any forge write. The sub takes the parent's priority, role and milestone, and
|
|
389
|
+
# the kind:<k> label (--kind, else the parent's kind, else task), as effort_new's subs do; it is
|
|
390
|
+
# linked natively under the parent and added to the board. --spec adds an optional `## Spec` section
|
|
391
|
+
# (E546.5), linted like the parent's when given; a sub needs none. Echoes the new sub's number.
|
|
392
|
+
effort_sub() {
|
|
393
|
+
_eff_forge || return 1; _eff_need jq || return 1
|
|
394
|
+
local raw="" name="" kind="" body_in="" spec="" pos=()
|
|
395
|
+
while [ $# -gt 0 ]; do
|
|
396
|
+
case "$1" in
|
|
397
|
+
--kind) kind="${2:-}"; shift 2 ;;
|
|
398
|
+
--kind=*) kind="${1#*=}"; shift ;;
|
|
399
|
+
--body) body_in="${2:-}"; shift 2 ;;
|
|
400
|
+
--body=*) body_in="${1#*=}"; shift ;;
|
|
401
|
+
--spec) spec="${2:-}"; shift 2 ;;
|
|
402
|
+
--spec=*) spec="${1#*=}"; shift ;;
|
|
403
|
+
--) shift; while [ $# -gt 0 ]; do pos+=("$1"); shift; done ;;
|
|
404
|
+
-*) echo "effort_sub: unknown flag $1" >&2; return 2 ;;
|
|
405
|
+
*) pos+=("$1"); shift ;;
|
|
406
|
+
esac
|
|
407
|
+
done
|
|
408
|
+
set -- "${pos[@]+"${pos[@]}"}"
|
|
409
|
+
raw="${1:-}"; name="${2:-}"
|
|
410
|
+
[ -n "$raw" ] && [ -n "$name" ] || { echo 'effort_sub: usage: cckit effort sub <N> "<name>" [--kind K] [--body B] [--spec T]' >&2; return 2; }
|
|
411
|
+
# The rule is about the NAME: lint it first, with a synthetic token, before any forge read or write.
|
|
412
|
+
naming_title_lint sub "$(naming_sub_title 0 1 "$name")" || { echo "effort_sub: fix the name and retry" >&2; return 1; }
|
|
413
|
+
if [ -n "$spec" ]; then
|
|
414
|
+
if [ -n "$body_in" ]; then body_in="$(printf '%s\n\n%s' "$body_in" "$(spec_section "$spec")")"
|
|
415
|
+
else body_in="$(spec_section "$spec")"; fi
|
|
416
|
+
spec_lint "$body_in" || { echo "effort_sub: fix the --spec and retry" >&2; return 1; }
|
|
417
|
+
fi
|
|
418
|
+
if [ -n "$kind" ] && command -v kit_kind_label_valid >/dev/null 2>&1 && ! kit_kind_label_valid "$kind"; then
|
|
419
|
+
echo "effort_sub: --kind must be one of: $KIT_KINDS $KIT_CONTENT_KINDS (got '$kind')" >&2; return 1
|
|
420
|
+
fi
|
|
421
|
+
local repo num meta labels milestone priority role count step title child child_num sub_labels
|
|
422
|
+
repo="$(_eff_repo)"
|
|
423
|
+
[ -n "$repo" ] || { echo "effort_sub: no repo (KIT_REPO/EFFORT_REPO unset — run in a kit project)" >&2; return 1; }
|
|
424
|
+
num="$(effort_slug_resolve "$raw")" || { echo "effort_sub: could not resolve '$raw' to an effort" >&2; return 1; }
|
|
425
|
+
meta="$(gh_rest_issue_json "$repo" "$num" 2>/dev/null)" || { echo "effort_sub: effort #$num not found" >&2; return 1; }
|
|
426
|
+
labels="$(printf '%s' "$meta" | jq -r '[.labels[]?.name] | join(",")' 2>/dev/null)"
|
|
427
|
+
case ",$labels," in *,effort,*) : ;; *)
|
|
428
|
+
echo "effort_sub: #$num is not an effort (no 'effort' label) — file a standalone issue with cckit new" >&2; return 1 ;;
|
|
429
|
+
esac
|
|
430
|
+
milestone="$(printf '%s' "$meta" | jq -r '.milestone.title // ""' 2>/dev/null)"
|
|
431
|
+
priority="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^priority://p' | sed -n 1p)"; priority="${priority:-p1}"
|
|
432
|
+
role="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^role://p' | sed -n 1p)"
|
|
433
|
+
[ -n "$kind" ] || kind="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^kind://p' | sed -n 1p)"
|
|
434
|
+
kind="${kind:-task}"
|
|
435
|
+
count="$(forge_rest "repos/$repo/issues/$num/sub_issues" -X GET -f per_page=100 --jq 'length' 2>/dev/null)" \
|
|
436
|
+
|| { echo "effort_sub: could not read the sub-issues of #$num" >&2; return 1; }
|
|
437
|
+
step=$(( ${count:-0} + 1 ))
|
|
438
|
+
title="$(naming_sub_title "$num" "$step" "$name")"
|
|
439
|
+
naming_title_lint sub "$title" || return 1
|
|
440
|
+
_eff_ensure_label "kind:$kind" d4c5f9 "kit issue kind"
|
|
441
|
+
_eff_ensure_label "priority:$priority" e99695 "kit priority"
|
|
442
|
+
sub_labels="kind:$kind,priority:$priority"
|
|
443
|
+
[ -n "$role" ] && sub_labels="$sub_labels,role:$role"
|
|
444
|
+
child="$(gh_rest_issue_create "$repo" "$title" \
|
|
445
|
+
"$(printf '%s\n\nSub-issue of #%s (effort).' "$body_in" "$num")" "$sub_labels" "$milestone" 0)" \
|
|
446
|
+
|| { echo "effort_sub: failed to create the sub-issue" >&2; return 1; }
|
|
447
|
+
child_num="${child##*/}"
|
|
448
|
+
effort_link_sub "$num" "$child_num" || true
|
|
449
|
+
_eff_board_add "$child_num" "$role" || true
|
|
450
|
+
echo " ✓ sub #$child_num · $title" >&2
|
|
451
|
+
printf '%s\n' "$child_num"
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
# _eff_retitle_rows <N> — the legacy titles of effort N and its open subs, one "num<TAB>old<TAB>new"
|
|
455
|
+
# row each. A title already in the new form, or one with no prefix at all, gives no row.
|
|
456
|
+
_eff_retitle_rows() {
|
|
457
|
+
local repo num title new tab subs s_num s_title tok
|
|
458
|
+
repo="$(_eff_repo)"; num="$1"; tab="$(printf '\t')"
|
|
459
|
+
title="$(forge_rest "repos/$repo/issues/$num" --jq '.title // ""' 2>/dev/null)" || return 1
|
|
460
|
+
case "$title" in
|
|
461
|
+
"[Effort] "*)
|
|
462
|
+
new="$(naming_effort_title "$num" "$(naming_strip_prefix "$title")")"
|
|
463
|
+
printf '%s\t%s\t%s\n' "$num" "$title" "$new" ;;
|
|
464
|
+
esac
|
|
465
|
+
subs="$(forge_rest "repos/$repo/issues/$num/sub_issues" -X GET -f per_page=100 \
|
|
466
|
+
--jq '.[] | select((.state // "open") == "open") | "\(.number)\t\(.title // "")"' 2>/dev/null)" || return 0
|
|
467
|
+
while IFS="$tab" read -r s_num s_title; do
|
|
468
|
+
[ -n "$s_num" ] || continue
|
|
469
|
+
case "$s_title" in "[Effort "[0-9]*) : ;; *) continue ;; esac
|
|
470
|
+
tok="$(naming_title_token "$s_title")" || continue
|
|
471
|
+
new="$(naming_sub_title "$num" "${tok#*.}" "$(naming_strip_prefix "$s_title")")"
|
|
472
|
+
printf '%s\t%s\t%s\n' "$s_num" "$s_title" "$new"
|
|
473
|
+
done <<EOF_SUBS
|
|
474
|
+
$subs
|
|
475
|
+
EOF_SUBS
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
# effort_retitle [<slug|N>] [--apply] — rename legacy `[Effort] N · ` / `[Effort N] M · ` titles to
|
|
479
|
+
# `[E<n>] ` / `[E<n>.<step>] ` (E546.1). Without <N>: every open effort (label `effort`) and its open
|
|
480
|
+
# subs. A dry run by default: it lists each old title and the new one and writes nothing. --apply
|
|
481
|
+
# edits the titles through the forge. A [Flow] tag is dropped: the flow lives in the flow: label.
|
|
482
|
+
effort_retitle() {
|
|
483
|
+
_eff_forge || return 1; _eff_need jq || return 1
|
|
484
|
+
local raw="" apply=0 a repo nums n rows="" tab line r_num r_old r_new count=0 failed=0
|
|
485
|
+
for a in "$@"; do
|
|
486
|
+
case "$a" in
|
|
487
|
+
--apply) apply=1 ;;
|
|
488
|
+
-*) echo "effort_retitle: unknown flag $a — usage: cckit effort retitle [<N>] [--apply]" >&2; return 2 ;;
|
|
489
|
+
*) [ -z "$raw" ] && raw="$a" ;;
|
|
490
|
+
esac
|
|
491
|
+
done
|
|
492
|
+
repo="$(_eff_repo)"; tab="$(printf '\t')"
|
|
493
|
+
[ -n "$repo" ] || { echo "effort_retitle: no repo (KIT_REPO/EFFORT_REPO unset — run in a kit project)" >&2; return 1; }
|
|
494
|
+
if [ -n "$raw" ]; then
|
|
495
|
+
nums="$(effort_slug_resolve "$raw")" || { echo "effort_retitle: could not resolve '$raw' to an effort" >&2; return 1; }
|
|
496
|
+
else
|
|
497
|
+
nums="$(gh_rest_issue_numbers_by_label "$repo" effort)" || { echo "effort_retitle: could not list the open efforts" >&2; return 1; }
|
|
498
|
+
fi
|
|
499
|
+
while IFS= read -r n; do
|
|
500
|
+
[ -n "$n" ] || continue
|
|
501
|
+
line="$(_eff_retitle_rows "$n")" || { echo "effort_retitle: could not read #$n" >&2; failed=1; continue; }
|
|
502
|
+
[ -n "$line" ] && rows="${rows:+$rows
|
|
503
|
+
}$line"
|
|
504
|
+
done <<EOF_NUMS
|
|
505
|
+
$nums
|
|
506
|
+
EOF_NUMS
|
|
507
|
+
if [ -z "$rows" ]; then echo "(no legacy titles: every effort and sub already reads [E<n>] / [E<n>.<step>])"; return "$failed"; fi
|
|
508
|
+
while IFS="$tab" read -r r_num r_old r_new; do
|
|
509
|
+
[ -n "$r_num" ] || continue
|
|
510
|
+
count=$((count + 1))
|
|
511
|
+
printf '#%s %s\n -> %s\n' "$r_num" "$r_old" "$r_new"
|
|
512
|
+
if [ "$apply" = 1 ]; then
|
|
513
|
+
gh_rest_issue_edit_title "$repo" "$r_num" "$r_new" >/dev/null 2>&1 \
|
|
514
|
+
|| { echo " ✗ #$r_num not renamed" >&2; failed=1; }
|
|
515
|
+
fi
|
|
516
|
+
done <<EOF_ROWS
|
|
517
|
+
$rows
|
|
518
|
+
EOF_ROWS
|
|
519
|
+
if [ "$apply" = 1 ]; then echo "renamed $count title(s)"
|
|
520
|
+
else echo "dry run: $count title(s) would change — run again with --apply to rename them"; fi
|
|
521
|
+
return "$failed"
|
|
522
|
+
}
|
|
523
|
+
|
|
302
524
|
# _eo_source_effort — lazily source the git-mechanics lib (effort.sh) so the ops that need
|
|
303
525
|
# effort_set_blocked_by work when effort-ops.sh is sourced on its own. No-op if already loaded.
|
|
304
526
|
_eo_source_effort() {
|
|
@@ -344,7 +566,7 @@ _eff_chain_reaches() {
|
|
|
344
566
|
|
|
345
567
|
# effort_chain <a> <b> [<c> …] — wire N issues into a LINEAR dependency chain (#243): B becomes
|
|
346
568
|
# blocked_by A, C blocked_by B, and so on, and each issue after the first gets a `- Depends on #<its
|
|
347
|
-
# predecessor>` line in its `## Relations` section. This is the verb that FEEDS `cckit plan` — the
|
|
569
|
+
# predecessor>` line in its `## Relations` section. This is the verb that FEEDS `cckit effort plan --issues` — the
|
|
348
570
|
# wave layering in plan-machine.sh reads exactly these `blocked_by` edges, so a chained set lands
|
|
349
571
|
# one issue per wave, in the order given.
|
|
350
572
|
#
|
|
@@ -358,7 +580,7 @@ _eff_chain_reaches() {
|
|
|
358
580
|
# chain. Nothing is written.
|
|
359
581
|
# cycles a repeated number (`chain 1 2 1`) is refused — the chain would revisit a node. So
|
|
360
582
|
# is a chain whose new edge closes a loop through edges GitHub ALREADY holds (the
|
|
361
|
-
# pre-flight walks the combined graph). `cckit plan` cannot layer a cyclic graph into
|
|
583
|
+
# pre-flight walks the combined graph). `cckit effort plan --issues` cannot layer a cyclic graph into
|
|
362
584
|
# waves, so a cycle is refused rather than written. Nothing is written.
|
|
363
585
|
# pre-existing an issue already blocked by something else KEEPS that blocker: blocked_by is a set,
|
|
364
586
|
# blockers and this only ever ADDS its edge. The issue ends up with both.
|
|
@@ -695,12 +917,14 @@ effort_start() {
|
|
|
695
917
|
}
|
|
696
918
|
|
|
697
919
|
# effort_pr [<slug|N>] — open the single PR effort/<N> → base. Defaults to the current effort branch.
|
|
920
|
+
_EO_PR_USAGE='cckit effort pr [<slug|N>] [--summary S|--summary-file F] [--for-agents A|--for-agents-file F] [--message M] [--title T] [--type T] open the ONE PR effort/<N> → base'
|
|
698
921
|
effort_pr() {
|
|
699
922
|
# The ONE effort-PR implementation (#363). The kit-effort-pr skill calls this; before, the skill
|
|
700
923
|
# carried its own inline copy, so agents hand-copied the script and the copy drifted (a PR missing
|
|
701
924
|
# from the board, a mangled body). Args: [<slug|N>] [--summary S|--summary-file F]
|
|
702
925
|
# [--for-agents A|--for-agents-file F] [--message M] [--title T]. SUMMARY / FOR_AGENTS / COMMIT_MSG env are
|
|
703
926
|
# honoured as fallbacks.
|
|
927
|
+
case "${1:-}" in -h|--help) echo "$_EO_PR_USAGE"; return 0 ;; esac
|
|
704
928
|
_eff_forge || return 1
|
|
705
929
|
local raw="" summary="${SUMMARY:-}" for_agents="${FOR_AGENTS:-}" msg="${COMMIT_MSG:-}" title_override="" ctype=""
|
|
706
930
|
while [ $# -gt 0 ]; do
|
|
@@ -712,6 +936,7 @@ effort_pr() {
|
|
|
712
936
|
--message|-m) msg="${2:-}"; shift 2 ;;
|
|
713
937
|
--title) title_override="${2:-}"; shift 2 ;;
|
|
714
938
|
--type) ctype="${2:-}"; shift 2 ;;
|
|
939
|
+
-h|--help) echo "$_EO_PR_USAGE"; return 0 ;;
|
|
715
940
|
*) [ -z "$raw" ] && raw="$1"; shift ;;
|
|
716
941
|
esac
|
|
717
942
|
done
|
|
@@ -736,7 +961,18 @@ effort_pr() {
|
|
|
736
961
|
if [ -n "$role" ] && command -v role_display >/dev/null 2>&1; then
|
|
737
962
|
role_disp="$(role_display "$role" 2>/dev/null || true)"
|
|
738
963
|
fi
|
|
739
|
-
name="$(
|
|
964
|
+
name="$(naming_strip_structural "$title")"
|
|
965
|
+
|
|
966
|
+
# ONE shared composer (effort.sh) so every surface titles identically, then the naming rule and
|
|
967
|
+
# the effort-token check before the commit, the push or any forge write — refuse rather than open
|
|
968
|
+
# an id-less PR (#121).
|
|
969
|
+
# --title replaces the composed title; it must still carry the effort's token, checked below.
|
|
970
|
+
pr_title="${title_override:-$(effort_pr_title "$num" "${name:-effort}" "$labels" "$ctype" "$role_disp")}"
|
|
971
|
+
effort_pr_title_check "$pr_title" "$num" || { echo "effort_pr: refusing to open a PR without the [E$num] effort token" >&2; return 1; }
|
|
972
|
+
# #237 + E546.1: under pr.titleStyle = conventional (the default) the title becomes the squash
|
|
973
|
+
# commit the commitlint gate checks, so naming_title_lint pr holds it to the Conventional Commit
|
|
974
|
+
# form with a trailing token. issue-title repos run no such gate; the lint passes them through.
|
|
975
|
+
naming_title_lint pr "$pr_title" || { echo "effort_pr: refusing to open a PR whose title breaks the naming rule (pass --type <type> or --title, or set pr.titleStyle to issue-title)" >&2; return 1; }
|
|
740
976
|
|
|
741
977
|
# Commit pending changes. Role identity is a Co-authored-by TRAILER, never the git author (some
|
|
742
978
|
# deploy providers refuse commits whose author email matches no account). TRACKED changes only:
|
|
@@ -760,26 +996,6 @@ effort_pr() {
|
|
|
760
996
|
fi
|
|
761
997
|
git push -u origin "$branch" >/dev/null 2>&1 || echo "effort_pr: push of $branch failed — continuing (the PR may already be current)" >&2
|
|
762
998
|
|
|
763
|
-
# ONE shared composer (effort.sh) so every surface titles identically, then the mandatory-[#N]
|
|
764
|
-
# check before we ever call gh — refuse rather than open an id-less PR (#121).
|
|
765
|
-
# --title replaces the composed title; it must still carry the [#N] id, checked below.
|
|
766
|
-
pr_title="${title_override:-$(effort_pr_title "$num" "${name:-effort}" "$labels" "$ctype" "$role_disp")}"
|
|
767
|
-
effort_pr_title_check "$pr_title" "$num" || { echo "effort_pr: refusing to open a PR without the [#$num] effort id" >&2; return 1; }
|
|
768
|
-
# #237: under pr.titleStyle = conventional (the default) the title becomes the squash commit the
|
|
769
|
-
# commitlint gate checks, so a title that gate rejects — composed (a bad --type) or passed with
|
|
770
|
-
# --title — is refused here, before gh. issue-title repos run no such gate and skip the check.
|
|
771
|
-
if [ "${KIT_PR_TITLE_STYLE:-conventional}" != "issue-title" ]; then
|
|
772
|
-
if ! command -v commitlint_check >/dev/null 2>&1; then
|
|
773
|
-
local _cl_dir; _cl_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)"
|
|
774
|
-
# shellcheck source=/dev/null
|
|
775
|
-
[ -f "$_cl_dir/commitlint.sh" ] && . "$_cl_dir/commitlint.sh"
|
|
776
|
-
fi
|
|
777
|
-
if command -v commitlint_check >/dev/null 2>&1; then
|
|
778
|
-
commitlint_check "$pr_title" || { echo "effort_pr: refusing to open a PR whose title is not a Conventional Commit subject (pass --type <type> or --title, or set pr.titleStyle to issue-title)" >&2; return 1; }
|
|
779
|
-
else
|
|
780
|
-
echo "effort_pr: commitlint.sh not found — the PR title was not checked against Conventional Commits" >&2
|
|
781
|
-
fi
|
|
782
|
-
fi
|
|
783
999
|
body="$(_eff_pr_body "$num" "$summary" "$for_agents" "$role")"
|
|
784
1000
|
|
|
785
1001
|
url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$pr_title" "$body" "$labels" "$milestone")" || return 1
|
|
@@ -824,7 +1040,7 @@ _eff_pr_board() {
|
|
|
824
1040
|
repo="$(_eff_repo)"; pr_num="${url##*/}"
|
|
825
1041
|
node="$(forge_rest "repos/$repo/pulls/$pr_num" --jq .node_id 2>/dev/null)" || node=""
|
|
826
1042
|
item=""
|
|
827
|
-
[ -n "$node" ] && item="$(project_add_item "$node" 2>/dev/null || true)"
|
|
1043
|
+
[ -n "$node" ] && item="$(project_add_item "$node" "$repo" "$pr_num" PullRequest 2>/dev/null || true)"
|
|
828
1044
|
if [ -z "$item" ]; then
|
|
829
1045
|
echo "⚠ PR #$pr_num was opened but NOT added to the board — add it by hand" >&2
|
|
830
1046
|
else
|
|
@@ -1010,15 +1226,28 @@ EOF_SUBS
|
|
|
1010
1226
|
# effort_close <N> — the SINGLE close implementation (#148): the /kit-effort-close skill is a thin
|
|
1011
1227
|
# caller of this function, never a second close. Snapshot per-sub diffs + capture metrics BEFORE the
|
|
1012
1228
|
# squash (the squash erases the per-sub history), REFUSE to squash if no work trace was captured
|
|
1013
|
-
# (KIT_FORCE=1 overrides), squash-merge, judge the metrics, close parent + subs, set the board
|
|
1229
|
+
# (KIT_FORCE=1 overrides), squash-merge, judge the metrics, close parent + finished subs, set the board
|
|
1014
1230
|
# Status=Done for each (guarded), GC the worktree/branch, run the optional knowledge-ingest hook,
|
|
1015
1231
|
# and finish with the advisory kit-sync drift check. Destructive: it merges, closes, and prunes.
|
|
1232
|
+
# First of all it re-reads the parent body and refuses an effort whose `## Spec` fails spec_lint
|
|
1233
|
+
# (E546.5); --no-spec-check skips that one check and says so on stderr.
|
|
1234
|
+
_EO_CLOSE_USAGE='cckit effort close <slug|N> [--no-spec-check] squash-merge the effort PR, close the parent and its finished subs (unfinished subs stay open, linked, and are listed), GC'
|
|
1016
1235
|
effort_close() {
|
|
1236
|
+
case "${1:-}" in -h|--help) echo "$_EO_CLOSE_USAGE"; return 0 ;; esac
|
|
1017
1237
|
_eff_forge || return 1; _eff_need jq || return 1
|
|
1018
|
-
local raw="
|
|
1238
|
+
local raw="" spec_check=1 num repo base branch root self_wt trace_dir kit_touched
|
|
1239
|
+
while [ $# -gt 0 ]; do
|
|
1240
|
+
case "$1" in
|
|
1241
|
+
-h|--help) echo "$_EO_CLOSE_USAGE"; return 0 ;;
|
|
1242
|
+
--no-spec-check) spec_check=0; shift ;;
|
|
1243
|
+
-*) echo "effort_close: unknown flag $1" >&2; return 2 ;;
|
|
1244
|
+
*) [ -z "$raw" ] && raw="$1"; shift ;;
|
|
1245
|
+
esac
|
|
1246
|
+
done
|
|
1019
1247
|
[ -n "$raw" ] || { echo "effort_close: <slug|effort issue #> required" >&2; return 1; }
|
|
1020
1248
|
num="$(effort_slug_resolve "$raw")" || { echo "effort_close: could not resolve '$raw' to an effort" >&2; return 1; }
|
|
1021
1249
|
repo="$(_eff_repo)"; base="$(_eff_base)"
|
|
1250
|
+
_eo_spec_check "$repo" "$num" "$spec_check" || return 1
|
|
1022
1251
|
branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
|
|
1023
1252
|
case "$branch" in
|
|
1024
1253
|
effort/"$num"-*) : ;;
|
|
@@ -1092,6 +1321,19 @@ effort_close() {
|
|
|
1092
1321
|
kit_touched="$(git diff --name-only "origin/$base"...HEAD 2>/dev/null \
|
|
1093
1322
|
| grep -E "$_EO_KIT_MANAGED_RE" | sort -u || true)"
|
|
1094
1323
|
|
|
1324
|
+
# (b3) which subs are finished (#565, decision 52), read PRE-squash while the effort branch's
|
|
1325
|
+
# commits still exist. A sub is finished when it is already closed, or a commit on this branch
|
|
1326
|
+
# delivers it (_eo_delivered_refs). Unfinished subs are NOT closed and NOT detached: they stay
|
|
1327
|
+
# open under the parent and are listed in the close comment and in this command's output.
|
|
1328
|
+
local sub_rows delivered sub_split done_subs="" open_subs="" open_lines=""
|
|
1329
|
+
sub_rows="$(forge_rest "repos/$repo/issues/$num/sub_issues" \
|
|
1330
|
+
--jq '.[] | "\(.number)|\(.state)|\(.title // "")"' 2>/dev/null)" || sub_rows=""
|
|
1331
|
+
delivered="$(_eo_delivered_refs "origin/$base")"
|
|
1332
|
+
sub_split="$(printf '%s\n' "$sub_rows" | _eo_partition_subs "$num" "$delivered")"
|
|
1333
|
+
done_subs="$(printf '%s\n' "$sub_split" | awk -F'|' '$1 == "done" {print $2 "|" $3}')"
|
|
1334
|
+
open_subs="$(printf '%s\n' "$sub_split" | awk -F'|' '$1 == "open" {print $2}')"
|
|
1335
|
+
open_lines="$(printf '%s\n' "$sub_split" | awk -F'|' '$1 == "open" {t=$0; sub(/^[^|]*\|[^|]*\|/, "", t); print "- #" $2 (t == "" ? "" : " " t)}')"
|
|
1336
|
+
|
|
1095
1337
|
# (c) squash-merge the effort PR, then delete the remote branch (git, not the API). In a cloud
|
|
1096
1338
|
# session the proxy rejects the deletion (#396): the branch is kept and the close says so.
|
|
1097
1339
|
{ [ -n "$rest_pr" ] && gh_rest_pr_merge "$repo" "$rest_pr" squash >/dev/null 2>&1; } \
|
|
@@ -1107,17 +1349,32 @@ effort_close() {
|
|
|
1107
1349
|
# (d) judge the metrics (reads the durable trace dir; the record stays in the local buffer).
|
|
1108
1350
|
command -v judge_effort_metrics >/dev/null 2>&1 && judge_effort_metrics "$num" "origin/$base" || true
|
|
1109
1351
|
|
|
1110
|
-
# (e) close
|
|
1111
|
-
# (guarded: a no-op when Projects v2 is off or the board helpers/ids are unavailable).
|
|
1112
|
-
#
|
|
1352
|
+
# (e) close the FINISHED sub-issues (#565), then the parent — and set the board Status=Done for
|
|
1353
|
+
# each (guarded: a no-op when Projects v2 is off or the board helpers/ids are unavailable). A sub
|
|
1354
|
+
# already closed keeps its own close reason (no second PATCH). An unfinished sub stays open and
|
|
1355
|
+
# linked; the close comment on the parent lists it. Board + issue + record state are owned by
|
|
1356
|
+
# this ONE op (effort-model.md) — never a separate "mark done".
|
|
1113
1357
|
_eo_source_board
|
|
1114
|
-
local sub
|
|
1115
|
-
while IFS= read -r sub; do
|
|
1358
|
+
local sub sstate done_list="" comment
|
|
1359
|
+
while IFS='|' read -r sub sstate; do
|
|
1116
1360
|
[ -n "$sub" ] || continue
|
|
1117
|
-
|
|
1361
|
+
if [ "$sstate" = closed ]; then
|
|
1362
|
+
echo " ✓ sub #$sub already closed" >&2
|
|
1363
|
+
else
|
|
1364
|
+
_eo_issue_close_completed "$repo" "$sub" && echo " ✓ closed sub #$sub" >&2
|
|
1365
|
+
fi
|
|
1118
1366
|
_eo_board_done "$sub"
|
|
1119
|
-
|
|
1120
|
-
|
|
1367
|
+
done_list="${done_list:+$done_list, }#$sub"
|
|
1368
|
+
done <<EOF_DONE
|
|
1369
|
+
$done_subs
|
|
1370
|
+
EOF_DONE
|
|
1371
|
+
while IFS= read -r sub; do
|
|
1372
|
+
[ -n "$sub" ] && echo " ⚠ left open: sub #$sub — unfinished, still linked under #$num" >&2
|
|
1373
|
+
done <<EOF_OPEN
|
|
1374
|
+
$open_subs
|
|
1375
|
+
EOF_OPEN
|
|
1376
|
+
comment="$(_eo_close_comment "$branch" "$done_list" "$open_lines")"
|
|
1377
|
+
gh_rest_issue_close "$repo" "$num" completed "$comment" >/dev/null 2>&1 && echo " ✓ closed effort #$num" >&2
|
|
1121
1378
|
_eo_board_done "$num"
|
|
1122
1379
|
|
|
1123
1380
|
# (f) GC: switch the main checkout to base, remove the effort worktree, delete the local branch,
|
|
@@ -1150,6 +1407,76 @@ effort_close() {
|
|
|
1150
1407
|
|
|
1151
1408
|
# (h) kit-sync drift check — kit ⇄ project stay in sync (#148, moved here from the skill).
|
|
1152
1409
|
_eo_kit_sync_warn "$kit_touched"
|
|
1410
|
+
|
|
1411
|
+
# (i) the report's last word: the subs this close left open (#565).
|
|
1412
|
+
if [ -n "$open_lines" ]; then
|
|
1413
|
+
echo "" >&2
|
|
1414
|
+
echo " ⚠ #$num closed with unfinished sub-issues still open (linked under it):" >&2
|
|
1415
|
+
printf '%s\n' "$open_lines" | sed 's/^/ /' >&2
|
|
1416
|
+
fi
|
|
1417
|
+
return 0
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
# _eo_delivered_refs <base_ref> — what the commits in <base_ref>..HEAD deliver, one token per line:
|
|
1421
|
+
# `#N` for an issue number, `E<n>.<k>` for a sub step id. A commit delivers (1) the LAST `#N` it
|
|
1422
|
+
# mentions — the same commit→sub pairing effort_snapshot_subs writes to the trace, (2) every `#N`
|
|
1423
|
+
# after a closing keyword (close/fix/resolve and their forms), and (3) every `[E<n>.<k>]` step tag.
|
|
1424
|
+
# Pure git; prints nothing when there are no commits.
|
|
1425
|
+
_eo_delivered_refs() {
|
|
1426
|
+
local sha msg
|
|
1427
|
+
git rev-list "$1..HEAD" 2>/dev/null | while IFS= read -r sha; do
|
|
1428
|
+
[ -n "$sha" ] || continue
|
|
1429
|
+
msg="$(git log -1 --format='%s%n%b' "$sha" 2>/dev/null)"
|
|
1430
|
+
printf '%s\n' "$msg" | grep -oE '#[0-9]+' | tail -1
|
|
1431
|
+
printf '%s\n' "$msg" | grep -oiE '(close[sd]?|fix(e[sd])?|resolve[sd]?):?[[:space:]]+#[0-9]+' | grep -oE '#[0-9]+'
|
|
1432
|
+
printf '%s\n' "$msg" | grep -oE '\[E[0-9]+\.[0-9]+\]' | tr -d '[]'
|
|
1433
|
+
done | sort -u
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
# _eo_partition_subs <effort#> <delivered-refs> — stdin: "<sub#>|<state>|<title>" rows (state as the
|
|
1437
|
+
# REST API spells it). stdout: "done|<sub#>|<state>" or "open|<sub#>|<title>", one per sub. A sub is
|
|
1438
|
+
# done when it is already closed, its `#N` is in <delivered-refs>, or its title carries a step id
|
|
1439
|
+
# `[E<effort>.<k>]` that a commit tagged. Pure: no forge, no git.
|
|
1440
|
+
_eo_partition_subs() {
|
|
1441
|
+
local eff="$1" refs="$2" n st title step
|
|
1442
|
+
while IFS='|' read -r n st title; do
|
|
1443
|
+
[ -n "$n" ] || continue
|
|
1444
|
+
st="$(printf '%s' "$st" | tr '[:upper:]' '[:lower:]')"
|
|
1445
|
+
if [ "$st" = closed ]; then echo "done|$n|closed"; continue; fi
|
|
1446
|
+
if grep -qxF "#$n" <<<"$refs"; then echo "done|$n|$st"; continue; fi
|
|
1447
|
+
step="$(grep -oE "\[E$eff\.[0-9]+\]" <<<"$title" | sed -n 1p | tr -d '[]')"
|
|
1448
|
+
if [ -n "$step" ] && grep -qxF "$step" <<<"$refs"; then echo "done|$n|$st"; continue; fi
|
|
1449
|
+
echo "open|$n|$title"
|
|
1450
|
+
done
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
# _eo_close_comment <branch> <done-list> <open-lines> — the comment effort_close posts on the parent
|
|
1454
|
+
# as it closes it: which subs closed with it and which stay open, linked (#565).
|
|
1455
|
+
_eo_close_comment() {
|
|
1456
|
+
printf 'Closed by `cckit effort close` (merged `%s`).\n\n' "$1"
|
|
1457
|
+
printf 'Finished sub-issues: %s\n' "${2:-none}"
|
|
1458
|
+
if [ -n "${3:-}" ]; then
|
|
1459
|
+
printf '\nLeft open, still linked under this effort (no commit on the effort branch delivers them):\n%s\n' "$3"
|
|
1460
|
+
fi
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
# _eo_spec_check <repo> <num> <1|0> — the close-time Spec check (E546.5), shared by both close
|
|
1464
|
+
# styles because it runs before they split. 1: read the parent body and refuse, with spec_lint's
|
|
1465
|
+
# reasons, when it has no checkable `## Spec`; a failed read refuses too, since an unread body is not
|
|
1466
|
+
# a checked one. 0 (--no-spec-check): skip, and print one line recording that the check was skipped.
|
|
1467
|
+
_eo_spec_check() {
|
|
1468
|
+
local repo="$1" num="$2" body
|
|
1469
|
+
if [ "${3:-1}" = 0 ]; then
|
|
1470
|
+
echo "effort_close: Spec check skipped for #$num (--no-spec-check) — the close does not confirm what done means" >&2
|
|
1471
|
+
return 0
|
|
1472
|
+
fi
|
|
1473
|
+
body="$(_eff_issue_body "$repo" "$num" 2>/dev/null)" || {
|
|
1474
|
+
echo "effort_close: could not read #$num's body to check its Spec — rerun when GitHub answers, or pass --no-spec-check (nothing was written)" >&2
|
|
1475
|
+
return 1
|
|
1476
|
+
}
|
|
1477
|
+
spec_lint "$body" && return 0
|
|
1478
|
+
echo "effort_close: refusing to close #$num — add a '## Spec' list to its body (what done means), or pass --no-spec-check (nothing was written)" >&2
|
|
1479
|
+
return 1
|
|
1153
1480
|
}
|
|
1154
1481
|
|
|
1155
1482
|
# _eo_kit_sync_warn <files> — the advisory kit-sync drift warning, shared by both close styles
|
|
@@ -1166,7 +1493,7 @@ _eo_kit_sync_warn() {
|
|
|
1166
1493
|
}
|
|
1167
1494
|
|
|
1168
1495
|
# _eo_close_wave <num> <repo> <base> — close a WAVE-style effort (#164): every sub was delivered as
|
|
1169
|
-
# its own task PR squash-merged straight to base (`cckit wave` → fan-out → `cckit watch --merge`),
|
|
1496
|
+
# its own task PR squash-merged straight to base (`cckit effort plan --wave` → fan-out → `cckit watch --merge`),
|
|
1170
1497
|
# so no effort/<N> integration branch ever existed. Verifies every sub is CLOSED with a merged
|
|
1171
1498
|
# closing PR (refuses and lists the stragglers otherwise), snapshots the work trace from the merged
|
|
1172
1499
|
# sub PR diffs, then runs the SAME close tail as the branch path: judge the metrics, close the
|