@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
package/scripts/lib/next.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# next.sh — "what can I pick up right now?" The everyday-dev helper (Effort 75 · #79).
|
|
3
3
|
#
|
|
4
4
|
# Surfaces the unblocked set (wave 0 of the plan machine) and the single recommended next issue with
|
|
5
|
-
# the one command to start it. This is the daily-loop counterpart to `cckit wave`: wave fans a whole
|
|
5
|
+
# the one command to start it. This is the daily-loop counterpart to `cckit effort plan --wave`: wave fans a whole
|
|
6
6
|
# wave out to subagents; `cckit next` is for a human (or agent) picking up one issue by hand.
|
|
7
7
|
#
|
|
8
8
|
# cckit next the unblocked issues + the top one's start command + the weekly
|
|
@@ -26,7 +26,7 @@ next_issue() {
|
|
|
26
26
|
local repo="$NEXT_REPO" out="${CCKIT_OUTPUT:-human}" effort="" planargs=()
|
|
27
27
|
while [ "$#" -gt 0 ]; do
|
|
28
28
|
case "$1" in
|
|
29
|
-
--llm|--output=json) out="json"; shift ;;
|
|
29
|
+
--json|--llm|--output=json) out="json"; shift ;;
|
|
30
30
|
--effort) effort="$2"; planargs+=(--effort "$2"); shift 2 ;;
|
|
31
31
|
--effort=*) effort="${1#*=}"; planargs+=(--effort "${1#*=}"); shift ;;
|
|
32
32
|
-h|--help) sed -n '8,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; return 0 ;;
|
|
@@ -49,7 +49,7 @@ next_issue() {
|
|
|
49
49
|
if [ "$out" = "json" ]; then
|
|
50
50
|
local json
|
|
51
51
|
json="$(printf '%s\n' "$wave0" | awk -F'\t' '{
|
|
52
|
-
t=$6; sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/,"",t); sub(/^\[[A-Za-z]+\] /,"",t)
|
|
52
|
+
t=$6; sub(/^\[E[0-9]+(\.[0-9]+)?\] +/, "", t); sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", t); sub(/^\[[A-Za-z]+\] /,"",t)
|
|
53
53
|
print $3"\t"$4"\t"t
|
|
54
54
|
}' \
|
|
55
55
|
| jq -R -s '[ split("\n")[] | select(length>0) | split("\t")
|
|
@@ -66,19 +66,19 @@ next_issue() {
|
|
|
66
66
|
local top topnum toptitle
|
|
67
67
|
top="$(printf '%s\n' "$wave0" | sed -n 1p)"
|
|
68
68
|
topnum="$(printf '%s' "$top" | cut -f3)"
|
|
69
|
-
toptitle="$(printf '%s' "$top" | cut -f6 | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
|
|
69
|
+
toptitle="$(printf '%s' "$top" | cut -f6 | sed -E 's/^\[E[0-9]+(\.[0-9]+)?\] +//; s/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
|
|
70
70
|
{
|
|
71
71
|
printf '# Next up — %s%s\n\n' "$repo" "$([ -n "$effort" ] && echo " · effort #$effort")"
|
|
72
72
|
printf '## Unblocked now\n\n'
|
|
73
73
|
printf '| # | ctx | issue |\n|---|-----|-------|\n'
|
|
74
74
|
printf '%s\n' "$wave0" | awk -F'\t' '{
|
|
75
|
-
t=$6; sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/,"",t); sub(/^\[[A-Za-z]+\] /,"",t)
|
|
75
|
+
t=$6; sub(/^\[E[0-9]+(\.[0-9]+)?\] +/, "", t); sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", t); sub(/^\[[A-Za-z]+\] /,"",t)
|
|
76
76
|
printf "| #%s | %s | %s |\n", $3, $4, t
|
|
77
77
|
}'
|
|
78
78
|
printf '\n## Pick up #%s — %s\n\n' "$topnum" "$toptitle"
|
|
79
79
|
printf 'Start it in an isolated worktree + branch:\n\n'
|
|
80
80
|
printf '```\ncckit start %s\n```\n\n' "$topnum"
|
|
81
|
-
printf 'Or fan the whole unblocked wave out to subagents with `cckit wave%s`.\n' "$([ -n "$effort" ] && echo " --effort $effort")"
|
|
81
|
+
printf 'Or fan the whole unblocked wave out to subagents with `cckit effort plan --wave%s`.\n' "$([ -n "$effort" ] && echo " --effort $effort")"
|
|
82
82
|
# the weekly cadence this verb is the daily step of — human output only; the TOON rows above
|
|
83
83
|
# stay {number,ctx,title}.
|
|
84
84
|
# shellcheck source=/dev/null
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# plan-machine.sh — the wave plan: turn the board into a deps-ordered, file-disjoint, session-fit
|
|
3
3
|
# execution plan the copilot fans out over (Effort 75 · #76).
|
|
4
4
|
#
|
|
5
|
-
# `cckit plan` reads the open board (or one effort's sub-issues), resolves the native GitHub
|
|
5
|
+
# `cckit effort plan --issues` reads the open board (or one effort's sub-issues), resolves the native GitHub
|
|
6
6
|
# `blocked_by` edges, and layers the issues into WAVES: wave 0 is everything unblocked, wave N is
|
|
7
7
|
# everything whose blockers all landed in earlier waves. Every issue in a wave is independent of the
|
|
8
8
|
# others in that wave, so a wave is exactly "what N agents can run in parallel right now". Within a
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
# under a session ctx budget, starting a new batch when the budget would overflow or two issues
|
|
11
11
|
# declare overlapping files (so parallel subagents don't collide).
|
|
12
12
|
#
|
|
13
|
-
# cckit plan human wave plan for the open board
|
|
14
|
-
# cckit plan --llm TOON wave plan (rows: wave,batch,number,ctx,blockers,title,priority)
|
|
15
|
-
# cckit plan --effort <N> plan only effort #N's sub-issues
|
|
16
|
-
# cckit plan --milestone <M> filter to milestone M
|
|
17
|
-
# cckit plan --cap <N> session ctx budget per batch (default KIT_SESSION_BUDGET or 4)
|
|
13
|
+
# cckit effort plan --issues human wave plan for the open board
|
|
14
|
+
# cckit effort plan --issues --llm TOON wave plan (rows: wave,batch,number,ctx,blockers,title,priority)
|
|
15
|
+
# cckit effort plan --issues --effort <N> plan only effort #N's sub-issues
|
|
16
|
+
# cckit effort plan --issues --milestone <M> filter to milestone M
|
|
17
|
+
# cckit effort plan --issues --cap <N> session ctx budget per batch (default KIT_SESSION_BUDGET or 4)
|
|
18
18
|
#
|
|
19
19
|
# ctx weights: S=1 · M=2 · L=4 · XL=8. File hints: a "Files:"/"Touches:" line in the issue body
|
|
20
20
|
# (comma/space-separated paths) drives intra-wave disjointness; absent → ctx budget alone batches.
|
|
@@ -180,7 +180,7 @@ plan_machine() {
|
|
|
180
180
|
local repo="$PLAN_REPO" budget="${KIT_SESSION_BUDGET:-4}" out="${CCKIT_OUTPUT:-human}" effort="" ms=""
|
|
181
181
|
while [ "$#" -gt 0 ]; do
|
|
182
182
|
case "$1" in
|
|
183
|
-
--llm|--output=json) out="json"; shift ;;
|
|
183
|
+
--json|--llm|--output=json) out="json"; shift ;;
|
|
184
184
|
--effort) effort="$2"; shift 2 ;;
|
|
185
185
|
--effort=*) effort="${1#*=}"; shift ;;
|
|
186
186
|
--milestone) ms="$2"; shift 2 ;;
|
|
@@ -307,7 +307,7 @@ EOF2
|
|
|
307
307
|
# shellcheck source=/dev/null
|
|
308
308
|
. "$here/render.sh"
|
|
309
309
|
{
|
|
310
|
-
printf '# cckit plan — %s\n\n' "$repo"
|
|
310
|
+
printf '# cckit effort plan --issues — %s\n\n' "$repo"
|
|
311
311
|
printf '_session budget %s · ctx S=1 M=2 L=4 XL=8 · ? = no ctx: label, weighed %s · each wave runs in parallel, p0 first_\n' "$budget" "$PM_UNSIZED_WEIGHT"
|
|
312
312
|
emit_rows | awk -F'\t' '
|
|
313
313
|
BEGIN { lw="" }
|
|
@@ -319,7 +319,7 @@ EOF2
|
|
|
319
319
|
print "|---|-----|-----|-------|-------|-------|"
|
|
320
320
|
lw=wv
|
|
321
321
|
}
|
|
322
|
-
sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", title)
|
|
322
|
+
sub(/^\[E[0-9]+(\.[0-9]+)?\] +/, "", title); sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", title)
|
|
323
323
|
sub(/^\[[A-Za-z]+\] /, "", title)
|
|
324
324
|
dep="—"
|
|
325
325
|
if (blk != "") { gsub(/,/, ", #", blk); dep="#" blk }
|
package/scripts/lib/plan-next.sh
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
# kit can already do. Run against cckit itself (full inventory) or any project the kit is installed
|
|
6
6
|
# in (degrades to whatever capability dirs exist, never crashes).
|
|
7
7
|
#
|
|
8
|
-
# cckit plan
|
|
9
|
-
# cckit plan
|
|
10
|
-
# cckit plan
|
|
8
|
+
# cckit effort plan --next current capabilities + a proposed forward plan (markdown)
|
|
9
|
+
# cckit effort plan --next --llm the proposed plan as TOON rows {rank,area,proposal,next} (JSON fallback)
|
|
10
|
+
# cckit effort plan --next --root <dir> scan <dir> instead of the resolved project/kit root
|
|
11
11
|
#
|
|
12
12
|
# CRITICAL — context-anxiety rule: this output is HUMAN / orchestrator-facing ONLY. It is NEVER to
|
|
13
13
|
# be injected into a monitored model's prompt or context. The planner pre-grounds planning in the
|
|
@@ -140,7 +140,7 @@ plan_next() {
|
|
|
140
140
|
local out="${CCKIT_OUTPUT:-human}" root=""
|
|
141
141
|
while [ "$#" -gt 0 ]; do
|
|
142
142
|
case "$1" in
|
|
143
|
-
--llm|--output=json) out="json"; shift ;;
|
|
143
|
+
--json|--llm|--output=json) out="json"; shift ;;
|
|
144
144
|
--root) root="$2"; shift 2 ;;
|
|
145
145
|
--root=*) root="${1#*=}"; shift ;;
|
|
146
146
|
-h|--help) sed -n '8,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; return 0 ;;
|
package/scripts/lib/qa-lane.sh
CHANGED
|
@@ -1248,7 +1248,7 @@ before the listeners, so nothing respawns. It reports only the processes that ar
|
|
|
1248
1248
|
Exit 0 when the ports are free, including on a lane that was already down; exit 1 names the pid
|
|
1249
1249
|
still listening.
|
|
1250
1250
|
|
|
1251
|
-
verdict writes a `qa` receipt (cckit receipt show <lane> qa) bound to the reviewed commit: --head,
|
|
1251
|
+
verdict writes a `qa` receipt (cckit agent receipt show <lane> qa) bound to the reviewed commit: --head,
|
|
1252
1252
|
else the local tip of the lane's branch, else the PR's head. It upserts ONE comment on the lane's
|
|
1253
1253
|
PR (a second verdict edits it) plus one per --shot; a screenshot is a path reference unless
|
|
1254
1254
|
KIT_EVIDENCE_URL_BASE is set, because gh cannot upload an image. A fail needs notes and mails them
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# spec-lint-test.sh — the `## Spec` check (scripts/lib/spec-lint.sh, E546.5): an accept/reject table
|
|
3
|
+
# over effort bodies, the reasons it prints, and spec_section, the body builder `effort new` uses.
|
|
4
|
+
# Hermetic, no network.
|
|
5
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
6
|
+
set -u
|
|
7
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
+
fail=0
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
. "$LIB/spec-lint.sh"
|
|
11
|
+
|
|
12
|
+
t() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1"; echo " got: [$2]"; echo " want: [$3]"; fail=1; fi; }
|
|
13
|
+
acc() { if spec_lint "$2" >/dev/null 2>&1; then echo "ok accepts: $1"; else echo "FAIL should accept: $1"; spec_lint "$2"; fail=1; fi; }
|
|
14
|
+
rej() { if spec_lint "$2" >/dev/null 2>&1; then echo "FAIL should reject: $1"; fail=1; else echo "ok rejects: $1"; fi; }
|
|
15
|
+
nl='
|
|
16
|
+
'
|
|
17
|
+
|
|
18
|
+
# --- accept ---
|
|
19
|
+
acc "one bullet" "## Spec${nl}- the verb refuses a body without a Spec"
|
|
20
|
+
acc "numbered items" "## Goal${nl}ship${nl}${nl}## Spec${nl}1. new refuses${nl}2) close refuses${nl}${nl}## Scope${nl}x"
|
|
21
|
+
acc "star and plus bullets" "## Spec${nl}* one${nl}+ two"
|
|
22
|
+
acc "a checkbox item" "## Spec${nl}- [ ] close re-reads the body"
|
|
23
|
+
acc "a sub-heading inside" "## Spec${nl}### Verbs${nl}- new lints it"
|
|
24
|
+
acc "a real item beside a TODO" "## Spec${nl}- TODO${nl}- the lint has a test table"
|
|
25
|
+
acc "trailing spaces on heading" "## Spec ${nl}- done means merged"
|
|
26
|
+
acc "CRLF line endings" "## Spec$(printf '\r')${nl}- done means merged$(printf '\r')"
|
|
27
|
+
|
|
28
|
+
# --- reject ---
|
|
29
|
+
rej "an empty body" ""
|
|
30
|
+
rej "no Spec heading" "## Goal${nl}- ship it"
|
|
31
|
+
rej "a level-3 Spec heading" "### Spec${nl}- ship it"
|
|
32
|
+
rej "an empty section" "## Spec${nl}${nl}## Scope${nl}- x"
|
|
33
|
+
rej "prose but no list item" "## Spec${nl}It is done when it works."
|
|
34
|
+
rej "TODO only" "## Spec${nl}- TODO"
|
|
35
|
+
rej "TBD and placeholders" "## Spec${nl}- TBD${nl}- todo: write this${nl}1. ...${nl}- ?"
|
|
36
|
+
rej "an HTML comment only" "## Spec${nl}<!-- what done means -->"
|
|
37
|
+
rej "a commented-out item" "## Spec${nl}<!-- - the verb refuses -->"
|
|
38
|
+
rej "an empty bullet" "## Spec${nl}-${nl}- "
|
|
39
|
+
rej "items only after the next heading" "## Spec${nl}${nl}## Scope${nl}- a scope item"
|
|
40
|
+
|
|
41
|
+
# --- reasons on stderr, nothing on stdout ---
|
|
42
|
+
err="$(spec_lint "## Goal${nl}x" 2>&1 >/dev/null)"
|
|
43
|
+
case "$err" in *"no '## Spec' section"*) echo "ok names a missing heading" ;; *) echo "FAIL missing-heading reason: $err"; fail=1 ;; esac
|
|
44
|
+
err="$(spec_lint "## Spec${nl}prose" 2>&1 >/dev/null)"
|
|
45
|
+
case "$err" in *"no list item"*) echo "ok names an empty section" ;; *) echo "FAIL empty-section reason: $err"; fail=1 ;; esac
|
|
46
|
+
err="$(spec_lint "## Spec${nl}- TBD" 2>&1 >/dev/null)"
|
|
47
|
+
case "$err" in *"placeholder"*) echo "ok names a placeholder-only section" ;; *) echo "FAIL placeholder reason: $err"; fail=1 ;; esac
|
|
48
|
+
t "stdout stays empty on a refusal" "$(spec_lint "## Goal" 2>/dev/null)" ""
|
|
49
|
+
spec_lint "## Spec${nl}- ok" >/dev/null 2>&1; t "rc 0 on a clean body" "$?" "0"
|
|
50
|
+
spec_lint "## Goal" >/dev/null 2>&1; t "rc 1 on a refusal" "$?" "1"
|
|
51
|
+
spec_lint >/dev/null 2>&1; t "rc 2 with no argument" "$?" "2"
|
|
52
|
+
t "reads the body from stdin with -" "$(printf '## Spec\n- piped\n' | spec_lint - >/dev/null 2>&1; echo $?)" "0"
|
|
53
|
+
|
|
54
|
+
# --- spec_section: the section effort new writes ---
|
|
55
|
+
t "plain lines become bullets" "$(spec_section "close refuses${nl}new refuses")" "## Spec${nl}- close refuses${nl}- new refuses"
|
|
56
|
+
t "a list is kept as written" "$(spec_section "1. first${nl}2. second")" "## Spec${nl}1. first${nl}2. second"
|
|
57
|
+
t "blank lines are dropped" "$(spec_section "${nl}one${nl}${nl}")" "## Spec${nl}- one"
|
|
58
|
+
t "an empty spec gives the heading only" "$(spec_section "")" "## Spec"
|
|
59
|
+
spec_lint "$(spec_section "the gate is green")" >/dev/null 2>&1; t "a built section passes the lint" "$?" "0"
|
|
60
|
+
spec_lint "$(spec_section "TODO")" >/dev/null 2>&1; t "a built TODO fails the lint" "$?" "1"
|
|
61
|
+
|
|
62
|
+
[ "$fail" = 0 ] && echo "spec-lint-test: all ok" || echo "spec-lint-test: FAILURES"
|
|
63
|
+
exit "$fail"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# spec-lint.sh — the `## Spec` check on an effort body (rules/effort-model.md, E546.5). The Spec says
|
|
4
|
+
# what "done" means as a checkable list. `cckit effort new` runs spec_lint on the body it composed
|
|
5
|
+
# before any forge write, and `cckit effort close` runs it on the parent body it reads back, so an
|
|
6
|
+
# effort cannot be filed or closed without one.
|
|
7
|
+
#
|
|
8
|
+
# A body passes when it has a `## Spec` heading followed, before the next `## ` heading, by at least
|
|
9
|
+
# one list item (`- `, `* `, `+ `, `1. `, `1) `; a `[ ]` checkbox is allowed) whose text is not a
|
|
10
|
+
# placeholder. Placeholders: TODO, TBD, TBA, FIXME, XXX, WIP, n/a (alone or leading the item), and
|
|
11
|
+
# items made only of `.`, `…`, `?` or `-`. HTML comments are ignored, so the template hint
|
|
12
|
+
# `<!-- … -->` alone does not count.
|
|
13
|
+
#
|
|
14
|
+
# Functions:
|
|
15
|
+
# spec_lint <body|-> rc 0 clean · 1 + reasons on stderr · 2 usage (no argument)
|
|
16
|
+
# spec_section <text> echo "## Spec" + the items: plain lines become `- ` bullets; text that
|
|
17
|
+
# already holds a list item is kept as written; blank lines are dropped
|
|
18
|
+
#
|
|
19
|
+
# bash 3.2 compatible; sourceable under zsh (awk does the parsing, no arrays).
|
|
20
|
+
# errors: strict — a validator: rc 1 on a body without a checkable Spec
|
|
21
|
+
|
|
22
|
+
# _spec_scan — read a body on stdin, print "<heading 0|1> <items> <real items>".
|
|
23
|
+
_spec_scan() {
|
|
24
|
+
tr -d '\r' | awk '
|
|
25
|
+
BEGIN { head = 0; inside = 0; done = 0; items = 0; real = 0; cmt = 0 }
|
|
26
|
+
{
|
|
27
|
+
line = $0
|
|
28
|
+
if (!head) {
|
|
29
|
+
if (line ~ /^##[ \t]+Spec[ \t]*$/) { head = 1; inside = 1 }
|
|
30
|
+
next
|
|
31
|
+
}
|
|
32
|
+
if (!inside || done) next
|
|
33
|
+
if (line ~ /^##[ \t]/) { done = 1; next }
|
|
34
|
+
# Drop HTML comments, including ones that span lines.
|
|
35
|
+
out = ""
|
|
36
|
+
while (length(line) > 0) {
|
|
37
|
+
if (cmt) {
|
|
38
|
+
e = index(line, "-->")
|
|
39
|
+
if (e == 0) { line = ""; break }
|
|
40
|
+
line = substr(line, e + 3); cmt = 0
|
|
41
|
+
} else {
|
|
42
|
+
s = index(line, "<!--")
|
|
43
|
+
if (s == 0) { out = out line; line = ""; break }
|
|
44
|
+
out = out substr(line, 1, s - 1); line = substr(line, s + 4); cmt = 1
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
line = out
|
|
48
|
+
if (line !~ /^[ \t]*([-*+]|[0-9]+[.)])([ \t]|$)/) next
|
|
49
|
+
items++
|
|
50
|
+
text = line
|
|
51
|
+
sub(/^[ \t]*([-*+]|[0-9]+[.)])[ \t]*/, "", text)
|
|
52
|
+
sub(/^\[[ xX]\][ \t]*/, "", text)
|
|
53
|
+
sub(/[ \t]+$/, "", text)
|
|
54
|
+
if (text == "") next
|
|
55
|
+
low = tolower(text)
|
|
56
|
+
if (low ~ /^(todo|tbd|tba|fixme|xxx|wip|n\/a)([^a-z0-9]|$)/) next
|
|
57
|
+
if (low ~ /^(\.|\?|-|…)+$/) next
|
|
58
|
+
real++
|
|
59
|
+
}
|
|
60
|
+
END { printf "%d %d %d\n", head, items, real }'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
spec_lint() {
|
|
64
|
+
[ $# -ge 1 ] || { echo "spec_lint: usage: spec_lint <body|->" >&2; return 2; }
|
|
65
|
+
local scan head items real reasons=""
|
|
66
|
+
if [ "$1" = "-" ]; then scan="$(_spec_scan)"
|
|
67
|
+
else scan="$(printf '%s\n' "$1" | _spec_scan)"; fi
|
|
68
|
+
read -r head items real <<EOF_SCAN
|
|
69
|
+
$scan
|
|
70
|
+
EOF_SCAN
|
|
71
|
+
head="${head:-0}"; items="${items:-0}"; real="${real:-0}"
|
|
72
|
+
if [ "$head" != 1 ]; then
|
|
73
|
+
reasons="no '## Spec' section — add one: what done means, as a checkable list"
|
|
74
|
+
elif [ "$items" = 0 ]; then
|
|
75
|
+
reasons="the '## Spec' section has no list item — write at least one '- ' or '1. ' item"
|
|
76
|
+
elif [ "$real" = 0 ]; then
|
|
77
|
+
reasons="every '## Spec' item is empty or a placeholder (TODO, TBD, …) — say what done means"
|
|
78
|
+
fi
|
|
79
|
+
[ -n "$reasons" ] || return 0
|
|
80
|
+
{
|
|
81
|
+
echo "✗ the effort body has no checkable Spec (rules/effort-model.md):"
|
|
82
|
+
printf ' - %s\n' "$reasons"
|
|
83
|
+
} >&2
|
|
84
|
+
return 1
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
spec_section() {
|
|
88
|
+
local text="${1:-}"
|
|
89
|
+
echo "## Spec"
|
|
90
|
+
if grep -qE '^[[:space:]]*([-*+]|[0-9]+[.)])([[:space:]]|$)' <<<"$text"; then
|
|
91
|
+
printf '%s\n' "$text" | grep -v '^[[:space:]]*$' || true
|
|
92
|
+
else
|
|
93
|
+
printf '%s\n' "$text" | grep -v '^[[:space:]]*$' | sed 's/^[[:space:]]*/- /' || true
|
|
94
|
+
fi
|
|
95
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# sprint-test.sh — `cckit effort sprint` (scripts/lib/sprint.sh, #570): the week arithmetic, and the
|
|
4
|
+
# milestone open / list / close over the forge shim (test-forge-shim.sh). 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
|
+
tc() { if grep -qE "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
|
|
14
|
+
tn() { if grep -qE "$2" "$1"; then echo "FAIL: $3 (found /$2/)"; fail=1; else echo "ok: $3"; fi; }
|
|
15
|
+
command -v jq >/dev/null 2>&1 || { echo "sprint-test: jq required" >&2; exit 1; }
|
|
16
|
+
|
|
17
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
18
|
+
export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
|
|
19
|
+
stub="$tmp/bin"
|
|
20
|
+
# shellcheck source=/dev/null
|
|
21
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$stub"
|
|
22
|
+
export PATH="$stub:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github KIT_REPO=o/r
|
|
23
|
+
# The milestones and the sprint's issues, per test (MS_JSON / MS_ISSUES).
|
|
24
|
+
export GH_FIXTURE="$tmp/fixture.sh"
|
|
25
|
+
cat > "$GH_FIXTURE" <<'SH'
|
|
26
|
+
case "$method $ep" in
|
|
27
|
+
"GET repos/o/r/milestones") out="${MS_JSON:-[]}" ;;
|
|
28
|
+
"POST repos/o/r/milestones") out='{"number":12}' ;;
|
|
29
|
+
"PATCH repos/o/r/milestones/"*) out='{}' ;;
|
|
30
|
+
"GET repos/o/r/issues") case "$path" in *milestone=*) out="${MS_ISSUES:-[]}" ;; esac ;;
|
|
31
|
+
esac
|
|
32
|
+
SH
|
|
33
|
+
# shellcheck source=/dev/null
|
|
34
|
+
. "$LIB/sprint.sh"
|
|
35
|
+
|
|
36
|
+
# ── the week: ISO week name, Monday to Monday ─────────────────────────────────────────────────
|
|
37
|
+
t "a Tuesday names its ISO week" "$(sprint_name 2026-11-24)" "2026-W48"
|
|
38
|
+
t "a Sunday is still that week" "$(sprint_name 2026-11-29)" "2026-W48"
|
|
39
|
+
t "the next Monday starts the next one" "$(sprint_name 2026-11-30)" "2026-W49"
|
|
40
|
+
t "Jan 1st 2027 (a Friday) is 2026-W53" "$(sprint_name 2027-01-01)" "2026-W53"
|
|
41
|
+
t "bounds: Monday to the next Monday" "$(sprint_bounds 2026-11-24)" "$(printf '2026-11-23\t2026-11-30')"
|
|
42
|
+
t "bounds of a Monday start on it" "$(sprint_bounds 2026-11-30)" "$(printf '2026-11-30\t2026-12-07')"
|
|
43
|
+
t "bounds across a month" "$(sprint_bounds 2026-12-31)" "$(printf '2026-12-28\t2027-01-04')"
|
|
44
|
+
sprint_name 2026-13-45 >/dev/null 2>&1; t "a bad day is a usage error" "$?" "2"
|
|
45
|
+
sprint_name "next week" >/dev/null 2>&1; t "prose is a usage error" "$?" "2"
|
|
46
|
+
t "no date means today" "$(sprint_name)" "$(date '+%G-W%V')"
|
|
47
|
+
|
|
48
|
+
# ── open: create, keep, update the goal ───────────────────────────────────────────────────────
|
|
49
|
+
: > "$GH_LOG"
|
|
50
|
+
out="$(MS_JSON='[{"number":3,"title":"v1"}]' sprint_open --goal "ship the advisor" --date 2026-11-25 2>/dev/null)"
|
|
51
|
+
t "open prints the sprint name" "$out" "2026-W48"
|
|
52
|
+
tc "$GH_LOG" '^POST repos/o/r/milestones \{"title":"2026-W48","description":"Sprint goal: ship the advisor\\n\\nMonday 2026-11-23 to Monday 2026-11-30\.","due_on":"2026-11-30T00:00:00Z"\}' \
|
|
53
|
+
"open creates the milestone: title, goal, due the closing Monday"
|
|
54
|
+
: > "$GH_LOG"
|
|
55
|
+
MS_JSON='[{"number":12,"title":"2026-W48","state":"open"}]' sprint_open --date 2026-11-25 >/dev/null 2>&1
|
|
56
|
+
tn "$GH_LOG" '^(POST|PATCH) ' "open keeps an existing sprint and writes nothing"
|
|
57
|
+
: > "$GH_LOG"
|
|
58
|
+
MS_JSON='[{"number":12,"title":"2026-W48","state":"open"}]' sprint_open --goal "new goal" --date 2026-11-25 >/dev/null 2>&1
|
|
59
|
+
tc "$GH_LOG" '^PATCH repos/o/r/milestones/12 \{"description":"Sprint goal: new goal' "open --goal updates the goal of an existing sprint"
|
|
60
|
+
sprint_open --bogus >/dev/null 2>&1; t "open: an unknown flag is a usage error" "$?" "2"
|
|
61
|
+
|
|
62
|
+
# ── list: only sprint milestones ──────────────────────────────────────────────────────────────
|
|
63
|
+
out="$(MS_JSON='[{"title":"v1","state":"open","open_issues":1,"closed_issues":0},{"title":"2026-W48","state":"open","open_issues":2,"closed_issues":5,"due_on":"2026-11-30T00:00:00Z"}]' sprint_list)"
|
|
64
|
+
t "list: a header and the sprint rows only" "$out" "$(printf 'sprint\tstate\topen\tclosed\tdue\n2026-W48\topen\t2\t5\t2026-11-30')"
|
|
65
|
+
out="$(MS_JSON='[]' sprint_list)"
|
|
66
|
+
case "$out" in *"no open sprint"*"effort sprint open"*) echo "ok: list with none says how to open one" ;; *) echo "FAIL: empty list: $out"; fail=1 ;; esac
|
|
67
|
+
|
|
68
|
+
# ── close: the review + retrospective page, then the milestone ─────────────────────────────────
|
|
69
|
+
export MS_JSON='[{"number":12,"title":"2026-W48","state":"open","description":"Sprint goal: ship the advisor\n\nMonday 2026-11-23 to Monday 2026-11-30."}]'
|
|
70
|
+
export MS_ISSUES='[{"number":579,"title":"Advisor skill","state":"closed"},{"number":580,"title":"Grill stage","state":"closed"},{"number":586,"title":"Release","state":"open"},{"number":9,"title":"a PR","state":"closed","pull_request":{}}]'
|
|
71
|
+
: > "$GH_LOG"
|
|
72
|
+
page="$(sprint_close 2026-W48 --dry-run 2>/dev/null)"
|
|
73
|
+
case "$page" in *"## Sprint goal"*"ship the advisor"*"### Done (2)"*"#579 Advisor skill"*"### Carried over (1)"*"#586 Release"*"## Retrospective"*) echo "ok: close --dry-run prints goal, done, carried over and the retro" ;; *) echo "FAIL: dry-run page: $page"; fail=1 ;; esac
|
|
74
|
+
case "$page" in *"a PR"*) echo "FAIL: a pull request was listed as sprint work"; fail=1 ;; *) echo "ok: pull requests are not sprint items" ;; esac
|
|
75
|
+
tn "$GH_LOG" '^PATCH ' "close --dry-run closes nothing"
|
|
76
|
+
: > "$GH_LOG"
|
|
77
|
+
printf 'Shown: the advisor routing five stages.\n' > "$tmp/review.md"
|
|
78
|
+
path="$(sprint_close 2026-W48 --review-file "$tmp/review.md" --retro "Keep one commit per sub." --out "$tmp/out/sprint.md" 2>/dev/null)"; rc=$?
|
|
79
|
+
t "close succeeds" "$rc" "0"
|
|
80
|
+
t "close prints the page path" "$path" "$tmp/out/sprint.md"
|
|
81
|
+
tc "$tmp/out/sprint.md" '^Shown: the advisor routing five stages\.$' "close puts the review text on the page"
|
|
82
|
+
tc "$tmp/out/sprint.md" '^Keep one commit per sub\.$' "close puts the retrospective text on the page"
|
|
83
|
+
tc "$GH_LOG" '^PATCH repos/o/r/milestones/12 \{"state":"closed","description":"Sprint goal: ship the advisor.*## Review\\n2 done, 1 carried over\. Review and retrospective: sprint\.md"\}' \
|
|
84
|
+
"close closes the milestone and appends the one-line review"
|
|
85
|
+
sprint_close 2026-W99x >/dev/null 2>&1; t "close: a bad sprint name is a usage error" "$?" "2"
|
|
86
|
+
MS_JSON='[]' sprint_close 2026-W40 >/dev/null 2>&1; t "close: no such sprint is rc 1" "$?" "1"
|
|
87
|
+
|
|
88
|
+
# ── without a forge: the week still works, the milestone verbs refuse ─────────────────────────
|
|
89
|
+
t "name runs with no forge" "$(CCKIT_FORGE=none GH_TOKEN='' sprint_name 2026-11-24)" "2026-W48"
|
|
90
|
+
CCKIT_FORGE=none GH_TOKEN='' sprint_open >/dev/null 2>&1; t "open refuses with no forge" "$?" "1"
|
|
91
|
+
|
|
92
|
+
# ── the dispatcher ────────────────────────────────────────────────────────────────────────────
|
|
93
|
+
t "cckit effort sprint name" "$(bash "$ROOT/bin/cckit" effort sprint name 2026-11-24 2>/dev/null)" "2026-W48"
|
|
94
|
+
bash "$ROOT/bin/cckit" effort sprint bogus >/dev/null 2>&1; t "an unknown sprint sub-verb is rc 2" "$?" "2"
|
|
95
|
+
|
|
96
|
+
exit "$fail"
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# sprint.sh — `cckit effort sprint`: one week of work, Monday to Monday, as a forge milestone (#570,
|
|
4
|
+
# E547). The milestone's title is the ISO week (`2026-W48`), its description the sprint goal, its
|
|
5
|
+
# due date the Monday the sprint ends. The issues on it are the sprint backlog; waves run inside it.
|
|
6
|
+
# A sub-verb of `effort`, not a top-level verb: the verb count may only go down (scripts/verbs.baseline).
|
|
7
|
+
#
|
|
8
|
+
# sprint_name [YYYY-MM-DD] the sprint a day falls in (default today): 2026-W48
|
|
9
|
+
# sprint_bounds [YYYY-MM-DD] its Monday and the next Monday, tab-separated
|
|
10
|
+
# sprint_open [--goal G] [--date D] create the milestone; an existing one is kept (and its
|
|
11
|
+
# goal updated when --goal is given) — safe to re-run
|
|
12
|
+
# sprint_list [--all] the sprint milestones: title, state, open, closed, due
|
|
13
|
+
# sprint_close [<name>] [--review T|--review-file F] [--retro T|--retro-file F] [--out F] [--dry-run]
|
|
14
|
+
# write the sprint review + retrospective page, then close
|
|
15
|
+
# the milestone with a one-line review in its description
|
|
16
|
+
# sprint_cli <name|bounds|open|list|close> … the `cckit effort sprint` dispatcher
|
|
17
|
+
#
|
|
18
|
+
# Only `name` and `bounds` run on git alone; the rest read or write the forge (forge_rest).
|
|
19
|
+
# bash 3.2 compatible; GNU and BSD `date` both work.
|
|
20
|
+
# errors: mixed — name/bounds are pure; open/list/close propagate a forge failure (rc 1)
|
|
21
|
+
|
|
22
|
+
if ! command -v forge_rest >/dev/null 2>&1 && ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
23
|
+
# shellcheck source=/dev/null
|
|
24
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
SPRINT_TITLE_RE='^[0-9]{4}-W[0-9]{2}$'
|
|
28
|
+
|
|
29
|
+
# _sprint_date <YYYY-MM-DD> <+%fmt> [<days to add>] — format a day, optionally shifted. GNU first,
|
|
30
|
+
# then BSD. rc 1 on a day neither understands.
|
|
31
|
+
_sprint_date() {
|
|
32
|
+
local d="$1" fmt="$2" add="${3:-0}" sign="+"
|
|
33
|
+
case "$add" in -*) sign="-"; add="${add#-}" ;; esac
|
|
34
|
+
case "$d" in [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]) ;; *) return 1 ;; esac
|
|
35
|
+
date -d "$d $sign$add days" "$fmt" 2>/dev/null && return 0
|
|
36
|
+
date -j -v"$sign${add}d" -f '%Y-%m-%d' "$d" "$fmt" 2>/dev/null && return 0
|
|
37
|
+
return 1
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_sprint_today() { date '+%Y-%m-%d'; }
|
|
41
|
+
|
|
42
|
+
sprint_bounds() {
|
|
43
|
+
local d="${1:-$(_sprint_today)}" dow start end
|
|
44
|
+
dow="$(_sprint_date "$d" '+%u')" || { echo "sprint: not a YYYY-MM-DD date: '$d'" >&2; return 2; }
|
|
45
|
+
start="$(_sprint_date "$d" '+%Y-%m-%d' "-$((dow - 1))")" || return 1
|
|
46
|
+
end="$(_sprint_date "$start" '+%Y-%m-%d' 7)" || return 1
|
|
47
|
+
printf '%s\t%s\n' "$start" "$end"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
sprint_name() {
|
|
51
|
+
local d="${1:-$(_sprint_today)}"
|
|
52
|
+
_sprint_date "$d" '+%G-W%V' || { echo "sprint: not a YYYY-MM-DD date: '$d'" >&2; return 2; }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
_sprint_repo() { printf '%s' "${KIT_REPO:-${EFFORT_REPO:-}}"; }
|
|
56
|
+
_sprint_need() {
|
|
57
|
+
forge_need "effort sprint" || return 1
|
|
58
|
+
command -v jq >/dev/null 2>&1 || { echo "effort sprint: jq is required" >&2; return 1; }
|
|
59
|
+
[ -n "$(_sprint_repo)" ] || { echo "effort sprint: no repository (github.repo unset)" >&2; return 1; }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# _sprint_milestone <title> — echo the milestone's JSON ({number,title,state,description,…}), or
|
|
63
|
+
# nothing when there is none. rc 1 when the read fails.
|
|
64
|
+
_sprint_milestone() {
|
|
65
|
+
forge_rest "repos/$(_sprint_repo)/milestones" -X GET -f state=all -f per_page=100 \
|
|
66
|
+
--jq ".[] | select(.title == \"$1\") | tojson" | sed -n 1p
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_sprint_description() { # <goal> <start> <end>
|
|
70
|
+
printf 'Sprint goal: %s\n\nMonday %s to Monday %s.' "${1:-not set}" "$2" "$3"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
sprint_open() {
|
|
74
|
+
local goal="" d="" name start end ms num desc
|
|
75
|
+
while [ $# -gt 0 ]; do
|
|
76
|
+
case "$1" in
|
|
77
|
+
--goal) goal="${2:-}"; shift 2 ;;
|
|
78
|
+
--date) d="${2:-}"; shift 2 ;;
|
|
79
|
+
*) echo "effort sprint open: unknown argument '$1'" >&2; return 2 ;;
|
|
80
|
+
esac
|
|
81
|
+
done
|
|
82
|
+
d="${d:-$(_sprint_today)}"
|
|
83
|
+
name="$(sprint_name "$d")" || return 2
|
|
84
|
+
IFS="$(printf '\t')" read -r start end <<EOF_B
|
|
85
|
+
$(sprint_bounds "$d")
|
|
86
|
+
EOF_B
|
|
87
|
+
_sprint_need || return 1
|
|
88
|
+
ms="$(_sprint_milestone "$name")" || { echo "effort sprint: could not read the milestones" >&2; return 1; }
|
|
89
|
+
desc="$(_sprint_description "$goal" "$start" "$end")"
|
|
90
|
+
if [ -n "$ms" ]; then
|
|
91
|
+
num="$(printf '%s' "$ms" | jq -r .number)"
|
|
92
|
+
if [ -n "$goal" ]; then
|
|
93
|
+
forge_rest "repos/$(_sprint_repo)/milestones/$num" -X PATCH -f "description=$desc" --silent \
|
|
94
|
+
|| { echo "effort sprint: could not update the goal of $name" >&2; return 1; }
|
|
95
|
+
echo " ✓ sprint $name is open; goal updated" >&2
|
|
96
|
+
else
|
|
97
|
+
echo " ✓ sprint $name is already open (milestone $num)" >&2
|
|
98
|
+
fi
|
|
99
|
+
else
|
|
100
|
+
num="$(forge_rest "repos/$(_sprint_repo)/milestones" -X POST -f "title=$name" -f "description=$desc" \
|
|
101
|
+
-f "due_on=${end}T00:00:00Z" --jq .number)" || { echo "effort sprint: could not create $name" >&2; return 1; }
|
|
102
|
+
echo " ✓ sprint $name opened (milestone $num): Monday $start to Monday $end" >&2
|
|
103
|
+
fi
|
|
104
|
+
printf '%s\n' "$name"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
sprint_list() {
|
|
108
|
+
local state=open
|
|
109
|
+
case "${1:-}" in --all) state=all ;; '') ;; *) echo "effort sprint list: unknown argument '$1'" >&2; return 2 ;; esac
|
|
110
|
+
_sprint_need || return 1
|
|
111
|
+
local rows
|
|
112
|
+
rows="$(forge_rest "repos/$(_sprint_repo)/milestones" -X GET -f "state=$state" -f per_page=100 \
|
|
113
|
+
--jq ".[] | select(.title | test(\"$SPRINT_TITLE_RE\")) | [.title, .state, (.open_issues|tostring), (.closed_issues|tostring), ((.due_on // \"-\") | .[0:10])] | @tsv")" \
|
|
114
|
+
|| { echo "effort sprint: could not read the milestones" >&2; return 1; }
|
|
115
|
+
if [ -z "$rows" ]; then echo "no $state sprint — open one with: cckit effort sprint open --goal \"<goal>\""; return 0; fi
|
|
116
|
+
printf 'sprint\tstate\topen\tclosed\tdue\n%s\n' "$(printf '%s\n' "$rows" | sort)"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# _sprint_text <inline> <file> — the inline text, else the file's, else nothing.
|
|
120
|
+
_sprint_text() {
|
|
121
|
+
if [ -n "$1" ]; then printf '%s\n' "$1"; elif [ -n "$2" ]; then cat "$2"; fi
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
sprint_close() {
|
|
125
|
+
local name="" review="" review_f="" retro="" retro_f="" out="" dry=""
|
|
126
|
+
while [ $# -gt 0 ]; do
|
|
127
|
+
case "$1" in
|
|
128
|
+
--review) review="${2:-}"; shift 2 ;;
|
|
129
|
+
--review-file) review_f="${2:-}"; [ -r "$review_f" ] || { echo "effort sprint close: cannot read '$review_f'" >&2; return 2; }; shift 2 ;;
|
|
130
|
+
--retro) retro="${2:-}"; shift 2 ;;
|
|
131
|
+
--retro-file) retro_f="${2:-}"; [ -r "$retro_f" ] || { echo "effort sprint close: cannot read '$retro_f'" >&2; return 2; }; shift 2 ;;
|
|
132
|
+
--out) out="${2:-}"; shift 2 ;;
|
|
133
|
+
--dry-run) dry=1; shift ;;
|
|
134
|
+
-*) echo "effort sprint close: unknown flag '$1'" >&2; return 2 ;;
|
|
135
|
+
*) name="$1"; shift ;;
|
|
136
|
+
esac
|
|
137
|
+
done
|
|
138
|
+
name="${name:-$(sprint_name)}"
|
|
139
|
+
grep -qE "$SPRINT_TITLE_RE" <<<"$name" || { echo "effort sprint close: '$name' is not a sprint name (YYYY-Www)" >&2; return 2; }
|
|
140
|
+
_sprint_need || return 1
|
|
141
|
+
local ms num desc goal issues done_rows open_rows n_done n_open
|
|
142
|
+
ms="$(_sprint_milestone "$name")" || { echo "effort sprint: could not read the milestones" >&2; return 1; }
|
|
143
|
+
[ -n "$ms" ] || { echo "effort sprint close: no milestone named $name — nothing to close" >&2; return 1; }
|
|
144
|
+
num="$(printf '%s' "$ms" | jq -r .number)"
|
|
145
|
+
desc="$(printf '%s' "$ms" | jq -r '.description // ""')"
|
|
146
|
+
goal="$(printf '%s\n' "$desc" | sed -n 's/^Sprint goal:[[:space:]]*//p' | sed -n 1p)"
|
|
147
|
+
issues="$(forge_rest "repos/$(_sprint_repo)/issues" -X GET -f "milestone=$num" -f state=all -f per_page=100 \
|
|
148
|
+
--jq '[.[] | select(.pull_request | not) | {number, title, state}]')" || { echo "effort sprint: could not read the issues of $name" >&2; return 1; }
|
|
149
|
+
done_rows="$(printf '%s' "$issues" | jq -r '.[] | select(.state == "closed") | "- #\(.number) \(.title)"')"
|
|
150
|
+
open_rows="$(printf '%s' "$issues" | jq -r '.[] | select(.state != "closed") | "- #\(.number) \(.title)"')"
|
|
151
|
+
n_done="$(printf '%s' "$issues" | jq '[.[] | select(.state == "closed")] | length')"
|
|
152
|
+
n_open="$(printf '%s' "$issues" | jq '[.[] | select(.state != "closed")] | length')"
|
|
153
|
+
|
|
154
|
+
local page review_txt retro_txt
|
|
155
|
+
review_txt="$(_sprint_text "$review" "$review_f")"
|
|
156
|
+
retro_txt="$(_sprint_text "$retro" "$retro_f")"
|
|
157
|
+
page="$(cat <<EOF_PAGE
|
|
158
|
+
# Sprint $name · review and retrospective
|
|
159
|
+
|
|
160
|
+
## Sprint goal
|
|
161
|
+
${goal:-not set}
|
|
162
|
+
|
|
163
|
+
## Sprint review
|
|
164
|
+
${review_txt:-<!-- what was shown, what the owner said, what changes in the backlog -->}
|
|
165
|
+
|
|
166
|
+
### Done ($n_done)
|
|
167
|
+
${done_rows:-none}
|
|
168
|
+
|
|
169
|
+
### Carried over ($n_open)
|
|
170
|
+
${open_rows:-none}
|
|
171
|
+
|
|
172
|
+
## Retrospective
|
|
173
|
+
${retro_txt:-<!-- what went well · what to change · the one change the next sprint makes -->}
|
|
174
|
+
EOF_PAGE
|
|
175
|
+
)"
|
|
176
|
+
if [ -n "$dry" ]; then
|
|
177
|
+
printf '%s\n' "$page"
|
|
178
|
+
echo "effort sprint close: --dry-run — no file written, $name left open" >&2
|
|
179
|
+
return 0
|
|
180
|
+
fi
|
|
181
|
+
if [ -z "$out" ]; then
|
|
182
|
+
local root; root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
183
|
+
out="$root/.cckit/reports/$(date '+%Y-%m-%d')-sprint-$name.md"
|
|
184
|
+
fi
|
|
185
|
+
mkdir -p "$(dirname "$out")" || return 1
|
|
186
|
+
printf '%s\n' "$page" > "$out" || return 1
|
|
187
|
+
local line
|
|
188
|
+
line="$(printf '## Review\n%s done, %s carried over. Review and retrospective: %s' "$n_done" "$n_open" "$(basename "$out")")"
|
|
189
|
+
forge_rest "repos/$(_sprint_repo)/milestones/$num" -X PATCH -f state=closed -f "description=$desc
|
|
190
|
+
|
|
191
|
+
$line" --silent || { echo "effort sprint close: wrote $out but could not close milestone $num" >&2; return 1; }
|
|
192
|
+
echo " ✓ sprint $name closed: $n_done done, $n_open carried over" >&2
|
|
193
|
+
printf '%s\n' "$out"
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
sprint_cli() {
|
|
197
|
+
local sub="${1:-}"; shift || true
|
|
198
|
+
case "$sub" in
|
|
199
|
+
name) sprint_name "$@" ;;
|
|
200
|
+
bounds) sprint_bounds "$@" ;;
|
|
201
|
+
open) sprint_open "$@" ;;
|
|
202
|
+
list) sprint_list "$@" ;;
|
|
203
|
+
close) sprint_close "$@" ;;
|
|
204
|
+
''|-h|--help)
|
|
205
|
+
cat <<'EOF_H'
|
|
206
|
+
cckit effort sprint name [YYYY-MM-DD] the sprint a day falls in (ISO week, Monday to Monday)
|
|
207
|
+
cckit effort sprint bounds [YYYY-MM-DD] its Monday and the next Monday
|
|
208
|
+
cckit effort sprint open [--goal G] [--date D] create the sprint milestone; re-running keeps it
|
|
209
|
+
cckit effort sprint list [--all] the sprint milestones with their open and closed counts
|
|
210
|
+
cckit effort sprint close [<YYYY-Www>] [--review T|--review-file F] [--retro T|--retro-file F] [--out F] [--dry-run]
|
|
211
|
+
write the review + retrospective page, close the milestone
|
|
212
|
+
EOF_H
|
|
213
|
+
[ -n "$sub" ] || return 2 ;;
|
|
214
|
+
*) echo "cckit effort sprint <name|bounds|open|list|close>" >&2; return 2 ;;
|
|
215
|
+
esac
|
|
216
|
+
}
|