@jeiemgi/cckit 0.10.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 +136 -127
- package/README.md +66 -43
- package/bin/cckit +151 -181
- package/cckit.config.json +1 -4
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot-run-test.sh +20 -12
- package/scripts/autopilot-run.sh +9 -1
- package/scripts/autopilot-test.sh +29 -13
- package/scripts/autopilot.sh +4 -4
- package/scripts/benchmark/verb-timings-test.sh +4 -0
- package/scripts/benchmark/verb-timings.sh +16 -5
- package/scripts/capture-project-ids.sh +23 -1
- package/scripts/check.sh +25 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/contribute.sh +8 -3
- package/scripts/copilot-loop-test.sh +66 -81
- package/scripts/exec-targets-test.sh +20 -0
- 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/forge-fence-test.sh +69 -0
- package/scripts/forge-fence.baseline +2 -0
- package/scripts/forge-fence.sh +76 -0
- package/scripts/forge-report-test.sh +100 -0
- package/scripts/forge-report.sh +176 -0
- package/scripts/init-guided-test.sh +94 -82
- package/scripts/init.sh +12 -7
- package/scripts/install-test.sh +26 -0
- package/scripts/install.sh +7 -0
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +60 -12
- package/scripts/kit-doctor.sh +170 -77
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +15 -8
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +37 -8
- package/scripts/lib/content-kinds-gc-test.sh +22 -21
- package/scripts/lib/copilot-test.sh +20 -11
- package/scripts/lib/copilot.sh +19 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +5 -3
- package/scripts/lib/effort-metrics-test.sh +7 -12
- package/scripts/lib/effort-metrics.sh +17 -46
- package/scripts/lib/effort-ops-test.sh +261 -167
- package/scripts/lib/effort-ops.sh +449 -171
- package/scripts/lib/effort-parity-test.sh +57 -62
- package/scripts/lib/effort-plan-test.sh +56 -54
- package/scripts/lib/effort-plan.sh +14 -7
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +34 -14
- package/scripts/lib/effort-slug.sh +13 -13
- package/scripts/lib/effort.sh +58 -80
- package/scripts/lib/forge-github.sh +260 -0
- package/scripts/lib/forge-none.sh +24 -0
- package/scripts/lib/forge-test.sh +186 -0
- package/scripts/lib/forge.sh +133 -0
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +151 -31
- package/scripts/lib/gh-project.sh +139 -11
- package/scripts/lib/gh-rest-test.sh +63 -118
- package/scripts/lib/gh-rest.sh +275 -52
- package/scripts/lib/git-core-test.sh +128 -0
- 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/init-github.sh +38 -13
- package/scripts/lib/kinds-test.sh +13 -16
- package/scripts/lib/kit-brief-test.sh +51 -10
- package/scripts/lib/kit-brief.sh +103 -18
- package/scripts/lib/kit-gc-test.sh +90 -109
- package/scripts/lib/kit-gc.sh +19 -22
- package/scripts/lib/kit-hotfix.sh +18 -16
- package/scripts/lib/kit-interview.sh +6 -0
- 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 +19 -14
- package/scripts/lib/kit-task-ops-test.sh +20 -1
- package/scripts/lib/kit-task-ops.sh +177 -94
- package/scripts/lib/kto-hotfix-test.sh +53 -58
- package/scripts/lib/kto-task-close-test.sh +28 -27
- package/scripts/lib/kto-task-new-test.sh +55 -48
- package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
- package/scripts/lib/kto-task-pr-test.sh +30 -34
- package/scripts/lib/light-task-run-test.sh +19 -15
- package/scripts/lib/light-task-test.sh +34 -29
- package/scripts/lib/light-task.sh +24 -13
- 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 +27 -22
- package/scripts/lib/next.sh +13 -7
- package/scripts/lib/orchestration-runtime-test.sh +11 -8
- package/scripts/lib/plan-machine.sh +22 -16
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +63 -74
- package/scripts/lib/pr-evidence.sh +15 -12
- package/scripts/lib/qa-lane-test.sh +59 -27
- package/scripts/lib/qa-lane.sh +14 -6
- package/scripts/lib/review-page-test.sh +34 -25
- package/scripts/lib/review-page.sh +10 -4
- 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 +169 -19
- package/scripts/lib/stage-receipt.sh +195 -10
- package/scripts/lib/test-forge-shim.sh +115 -0
- package/scripts/lib/verbs.sh +105 -0
- package/scripts/lib/verbs.tsv +92 -0
- package/scripts/lib/version-bump-test.sh +20 -0
- package/scripts/lib/version-bump.sh +4 -2
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-issue-test.sh +24 -19
- package/scripts/lib/worktree-issue.sh +10 -10
- package/scripts/lib/worktree-start-test.sh +13 -16
- package/scripts/lib/worktree-start.sh +57 -7
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/marketing-walkthrough-test.sh +25 -30
- package/scripts/night-grant.sh +14 -8
- package/scripts/night-run.mjs +1 -1
- package/scripts/orchestrate-test.sh +27 -31
- package/scripts/orchestrate.sh +9 -3
- package/scripts/portable-test.sh +37 -36
- package/scripts/publish.sh +9 -3
- package/scripts/setup-labels.sh +23 -12
- package/scripts/setup-milestones.sh +8 -2
- package/scripts/status-test.sh +39 -33
- package/scripts/status.sh +12 -6
- package/scripts/task-sync-test.sh +75 -32
- package/scripts/task-sync.sh +97 -6
- package/scripts/terms-check-test.sh +191 -0
- package/scripts/terms-check.sh +242 -0
- package/scripts/verbs-gen.sh +43 -0
- package/scripts/verbs-help-test.sh +61 -0
- package/scripts/verbs-ratchet-test.sh +69 -0
- package/scripts/verbs-ratchet.sh +34 -0
- package/scripts/verbs-test.sh +120 -0
- package/scripts/verbs.baseline +5 -0
- package/skills/kit-add/SKILL.md +2 -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-annotate/SKILL.md +1 -0
- package/skills/kit-autopilot/SKILL.md +2 -1
- package/skills/kit-cleanup/SKILL.md +3 -2
- package/skills/kit-contribute/SKILL.md +1 -0
- package/skills/kit-customize/SKILL.md +1 -0
- package/skills/kit-dev/SKILL.md +1 -0
- package/skills/kit-digest/SKILL.md +1 -0
- package/skills/kit-docs-writer/SKILL.md +4 -3
- package/skills/kit-effort-close/SKILL.md +18 -9
- package/skills/kit-effort-new/SKILL.md +12 -8
- package/skills/kit-effort-pr/SKILL.md +8 -7
- package/skills/kit-effort-start/SKILL.md +1 -0
- package/skills/kit-gc/SKILL.md +1 -0
- package/skills/kit-next/SKILL.md +8 -7
- package/skills/kit-onboard/SKILL.md +1 -0
- package/skills/kit-page/SKILL.md +1 -0
- package/skills/kit-plan-next/SKILL.md +11 -11
- package/skills/kit-security-sweep/SKILL.md +1 -0
- package/skills/kit-ship/SKILL.md +1 -0
- package/skills/kit-status/SKILL.md +6 -5
- package/skills/kit-task-close/SKILL.md +1 -0
- package/skills/kit-task-new/SKILL.md +1 -0
- package/skills/kit-task-pr/SKILL.md +1 -0
- package/skills/kit-task-pr-auto/SKILL.md +2 -1
- package/skills/kit-task-pr-merge/SKILL.md +4 -3
- package/skills/kit-task-start/SKILL.md +1 -0
- package/skills/kit-task-sync/SKILL.md +3 -0
- package/skills/kit-ux-audit/SKILL.md +1 -0
- package/skills/routing.yaml +124 -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/engine-adapter.sh +0 -93
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
# the work (#297); a stop leaves the ports with no listener (#298); a verdict is bound to the
|
|
4
4
|
# commit that was reviewed and a later commit reads it stale (#299).
|
|
5
5
|
#
|
|
6
|
-
# Hermetic: `curl` is a stub on PATH that answers from a table
|
|
7
|
-
#
|
|
6
|
+
# Hermetic: `curl` is a stub on PATH that answers the probes from a table and hands GitHub requests
|
|
7
|
+
# to the forge shim (test-forge-shim.sh), the "stack" is a `sleep`, and every
|
|
8
|
+
# file lands in a scratch repo. `open` and `xdg-open` are stubs too: no browser starts and no
|
|
8
9
|
# network is touched. Only the stop sections listen on a port — a loopback port the kernel picked —
|
|
9
10
|
# and they skip with a printed reason when perl, or both lsof and ss, are absent.
|
|
10
11
|
#
|
|
@@ -44,7 +45,7 @@ done < "$CURL_TABLE"
|
|
|
44
45
|
printf '000'; exit 7
|
|
45
46
|
SH
|
|
46
47
|
chmod +x "$STUB/curl"
|
|
47
|
-
# ── the browser openers
|
|
48
|
+
# ── the browser openers: each logs its arguments ──────────────────────────────────────────────
|
|
48
49
|
OPEN_LOG="$TMP/open.log"; export OPEN_LOG; : > "$OPEN_LOG"
|
|
49
50
|
for o in open xdg-open; do
|
|
50
51
|
cat > "$STUB/$o" <<'SH'
|
|
@@ -53,34 +54,63 @@ printf '%s %s\n' "${0##*/}" "$*" >> "$OPEN_LOG"
|
|
|
53
54
|
SH
|
|
54
55
|
chmod +x "$STUB/$o"
|
|
55
56
|
done
|
|
57
|
+
# ── the forge: test-forge-shim.sh, beside the probe curl ───────────────────────────────────────
|
|
58
|
+
# The shim's curl answers like the REST API and logs `METHOD path {json}` to $GH_LOG; its gh fails
|
|
59
|
+
# on any subcommand. It lives in its own dir, and $STUB/curl above hands every api.github.com
|
|
60
|
+
# request to it, so the readiness probes and the forge share one PATH. A fixture answers the PR
|
|
61
|
+
# (`GET repos/o/r/pulls/<n>`, and the lookup by head branch) from $PR_BODY + $PR_META — a PR exists
|
|
62
|
+
# while either file does; the number, url, head sha and branch are $PR_META's four lines (31 and
|
|
63
|
+
# a generic url without it) — and keeps the PR's comments in $GH_COMMENTS as `<id><TAB><json body>`
|
|
64
|
+
# rows: list, create, edit in place.
|
|
65
|
+
FORGE_BIN="$TMP/forge"
|
|
66
|
+
# shellcheck source=/dev/null
|
|
67
|
+
. "$ROOT/scripts/lib/test-forge-shim.sh"; forge_shim_install "$FORGE_BIN"
|
|
68
|
+
cp "$FORGE_BIN/gh" "$STUB/gh"
|
|
69
|
+
mv "$STUB/curl" "$STUB/curl.probe"
|
|
70
|
+
cat > "$STUB/curl" <<EOF
|
|
71
|
+
#!/usr/bin/env bash
|
|
72
|
+
url=""; for a in "\$@"; do url="\$a"; done
|
|
73
|
+
case "\$url" in *api.github.com/*) exec "$FORGE_BIN/curl" "\$@" ;; esac
|
|
74
|
+
exec "$STUB/curl.probe" "\$@"
|
|
75
|
+
EOF
|
|
76
|
+
chmod +x "$STUB/curl"
|
|
56
77
|
GH_LOG="$TMP/gh.log"; export GH_LOG; : > "$GH_LOG"
|
|
78
|
+
export GH_TOKEN=test-token CCKIT_FORGE=github KIT_REPO=o/r PR_EVIDENCE_REPO=o/r
|
|
57
79
|
PR_BODY="$TMP/pr.body"; export PR_BODY
|
|
58
80
|
PR_META="$TMP/pr.meta"; export PR_META
|
|
59
81
|
GH_COMMENTS="$TMP/gh.comments"; export GH_COMMENTS; : > "$GH_COMMENTS"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
GH_FIXTURE="$TMP/forge.fixture"; export GH_FIXTURE
|
|
83
|
+
cat > "$GH_FIXTURE" <<'FIX'
|
|
84
|
+
pr_json() { # <number> → the PR as the API answers it, from $PR_BODY + $PR_META
|
|
85
|
+
local n="$1" body="" url="" sha="" ref=""
|
|
86
|
+
[ -f "$PR_BODY" ] && body="$(cat "$PR_BODY")"
|
|
87
|
+
if [ -f "$PR_META" ]; then
|
|
88
|
+
n="$(sed -n 1p "$PR_META")"; url="$(sed -n 2p "$PR_META")"; sha="$(sed -n 3p "$PR_META")"; ref="$(sed -n 4p "$PR_META")"
|
|
89
|
+
fi
|
|
90
|
+
[ -n "$url" ] || url="https://github.com/o/r/pull/$n"
|
|
91
|
+
jq -n --argjson n "$n" --arg b "$body" --arg u "$url" --arg s "$sha" --arg r "$ref" \
|
|
92
|
+
'{number: $n, title: "qa", body: $b, state: "open", merged_at: null, mergeable: true, html_url: $u,
|
|
93
|
+
base: {ref: "main"}, head: {sha: $s, ref: $r}}'
|
|
94
|
+
}
|
|
95
|
+
pr_exists() { [ -f "$PR_BODY" ] || [ -f "$PR_META" ]; }
|
|
96
|
+
case "$method $ep" in
|
|
97
|
+
"GET repos/o/r/pulls")
|
|
98
|
+
if pr_exists; then out="[$(pr_json 31)]"; else out='[]'; fi ;;
|
|
99
|
+
"GET repos/o/r/pulls/"*)
|
|
100
|
+
if pr_exists; then out="$(pr_json "${ep##*/}")"; else code=404; out='{"message":"Not Found"}'; fi ;;
|
|
101
|
+
"GET repos/o/r/issues/"*"/comments")
|
|
102
|
+
out="$(jq -R 'split("\t") | {id: (.[0] | tonumber), body: (.[1] | fromjson)}' "$GH_COMMENTS" 2>/dev/null | jq -sc .)" ;;
|
|
103
|
+
"PATCH repos/o/r/issues/comments/"*)
|
|
104
|
+
id="${ep##*/}"
|
|
73
105
|
grep -v "^$id " "$GH_COMMENTS" > "$GH_COMMENTS.tmp"
|
|
74
|
-
printf '%s\t%s\n' "$id" "$(jq -
|
|
75
|
-
mv "$GH_COMMENTS.tmp" "$GH_COMMENTS";
|
|
76
|
-
"
|
|
106
|
+
printf '%s\t%s\n' "$id" "$(printf '%s' "$body" | jq -c .body)" >> "$GH_COMMENTS.tmp"
|
|
107
|
+
mv "$GH_COMMENTS.tmp" "$GH_COMMENTS"; out="{\"id\":$id}" ;;
|
|
108
|
+
"POST repos/o/r/issues/"*"/comments")
|
|
77
109
|
n=$(( $(wc -l < "$GH_COMMENTS" 2>/dev/null || echo 0) + 9001 ))
|
|
78
|
-
printf '%s\t%s\n' "$n" "$(jq -
|
|
110
|
+
printf '%s\t%s\n' "$n" "$(printf '%s' "$body" | jq -c .body)" >> "$GH_COMMENTS"
|
|
111
|
+
out="{\"id\":$n,\"html_url\":\"https://github.com/o/r/pull/31#issuecomment-$n\"}" ;;
|
|
79
112
|
esac
|
|
80
|
-
|
|
81
|
-
cat "$PR_BODY"
|
|
82
|
-
SH
|
|
83
|
-
chmod +x "$STUB/gh"
|
|
113
|
+
FIX
|
|
84
114
|
PATH="$STUB:$PATH"; export PATH
|
|
85
115
|
answers() { printf '%s\n' "$@" > "$CURL_TABLE"; }
|
|
86
116
|
|
|
@@ -218,7 +248,7 @@ url="$(qa_cli open 2>"$TMP/open.err")"; rc=$?
|
|
|
218
248
|
t "open on a usable lane returns 0" "$rc" "0"
|
|
219
249
|
t "a declared route opens on the lane's first port" "$url" "http://localhost:$web7/settings/billing"
|
|
220
250
|
t "the opener got exactly that URL, once" "$(cat "$OPEN_LOG")" "open http://localhost:$web7/settings/billing"
|
|
221
|
-
yes "the PR is looked up by the lane's branch" "$(cat "$GH_LOG")" "
|
|
251
|
+
yes "the PR is looked up by the lane's branch" "$(cat "$GH_LOG")" "GET repos/o/r/pulls?state=all&head=o:task/7-review-stack&per_page=1 "
|
|
222
252
|
yes "open says where the route came from" "$(cat "$TMP/open.err")" "declared route /settings/billing"
|
|
223
253
|
t "open appended one event" "$(events qa.open)" "1"
|
|
224
254
|
t "the open event carries the url and the source" \
|
|
@@ -230,7 +260,7 @@ printf 'Summary only, no route line.\n' > "$PR_BODY"
|
|
|
230
260
|
: > "$OPEN_LOG"
|
|
231
261
|
t "with no declared route the configured one is used" "$(qa_cli open 2>/dev/null)" "http://localhost:$web7/dashboard"
|
|
232
262
|
t "the opener got the configured route" "$(cat "$OPEN_LOG")" "open http://localhost:$web7/dashboard"
|
|
233
|
-
# No PR at all (
|
|
263
|
+
# No PR at all (the forge has none for the branch) reads the same as no declared line.
|
|
234
264
|
rm -f "$PR_BODY"
|
|
235
265
|
t "with no PR the configured route is used" "$(qa_cli open --print 2>/dev/null)" "http://localhost:$web7/dashboard"
|
|
236
266
|
|
|
@@ -238,7 +268,8 @@ t "with no PR the configured route is used" "$(qa_cli open --print 2>/dev/null)"
|
|
|
238
268
|
printf 'QA route: /from-pr-31\n' > "$PR_BODY"
|
|
239
269
|
: > "$GH_LOG"; : > "$OPEN_LOG"
|
|
240
270
|
t "--pr reads the named PR" "$(qa_cli open --pr 31 --print 2>/dev/null)" "http://localhost:$web7/from-pr-31"
|
|
241
|
-
yes "--pr is what
|
|
271
|
+
yes "--pr is what the forge was asked for" "$(cat "$GH_LOG")" "GET repos/o/r/pulls/31 "
|
|
272
|
+
no "--pr skips the lookup by branch" "$(cat "$GH_LOG")" "head=o:task/7-review-stack"
|
|
242
273
|
t "--route overrides the declared route" "$(qa_cli open --route /override --print 2>/dev/null)" "http://localhost:$web7/override"
|
|
243
274
|
t "--port-env picks another port variable" "$(qa_cli open --port-env API_PORT --print 2>/dev/null)" "http://localhost:$api7/from-pr-31"
|
|
244
275
|
t "--print opens no browser" "$(cat "$OPEN_LOG")" ""
|
|
@@ -587,6 +618,7 @@ yes "the verdict comment was edited in place" "$(grep 'qa-verdict' "$GH_COMMENTS
|
|
|
587
618
|
t "the screenshot is its own upserted comment" "$(grep -c 'key=qa-screenshot-1' "$GH_COMMENTS")" "1"
|
|
588
619
|
yes "the screenshot is a path reference" "$(grep 'qa-screenshot-1' "$GH_COMMENTS")" "$TMP/broken-save.png"
|
|
589
620
|
t "verdict and screenshot are the only comments" "$(ncomments)" "2"
|
|
621
|
+
t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
|
|
590
622
|
t "the lane now reads fail" "$(qa_cli verdict 2>/dev/null)" "fail"
|
|
591
623
|
qa_cli verdict >/dev/null 2>&1; t "a fresh fail is rc 1" "$?" "1"
|
|
592
624
|
yes "a PR behind the reviewed commit is said out loud" "$(cat "$TMP/v.err")" "reads stale against it until $sha2 is pushed"
|
package/scripts/lib/qa-lane.sh
CHANGED
|
@@ -87,6 +87,12 @@
|
|
|
87
87
|
|
|
88
88
|
# `${BASH_SOURCE[0]:-$0}`: BASH_SOURCE is empty under zsh, and `dirname ""` is "." — the sibling
|
|
89
89
|
# sources below would silently miss. Same fix as stage-receipt.sh and kit-gc.sh (#219).
|
|
90
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
91
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
92
|
+
# shellcheck source=/dev/null
|
|
93
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
94
|
+
fi
|
|
95
|
+
|
|
90
96
|
_qa_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd)"
|
|
91
97
|
# shellcheck source=/dev/null
|
|
92
98
|
command -v kit_state_dir >/dev/null 2>&1 || . "$_qa_dir/kit-state.sh"
|
|
@@ -436,8 +442,8 @@ qa_route() {
|
|
|
436
442
|
tab="$(printf '\t')"
|
|
437
443
|
ref="$pr"
|
|
438
444
|
[ -n "$ref" ] || ref="$(_qa_lane_branch "$lane")"
|
|
439
|
-
if [ -n "$ref" ] &&
|
|
440
|
-
body="$(
|
|
445
|
+
if [ -n "$ref" ] && forge_available; then
|
|
446
|
+
body="$(forge_pr_view "$(_qa_repo)" "$ref" 2>/dev/null | jq -r '.body // ""')" || body=""
|
|
441
447
|
if [ -n "$body" ] && route="$(printf '%s\n' "$body" | qa_route_declared)"; then
|
|
442
448
|
printf 'declared%s%s\n' "$tab" "$route"
|
|
443
449
|
return 0
|
|
@@ -609,6 +615,9 @@ qa_port_tool() {
|
|
|
609
615
|
# qa_port_pids <port> [<tool>] — the pids LISTENING on TCP <port>, one per line, deduplicated.
|
|
610
616
|
# Empty output is "no listener this user can see": ss names a pid only for the caller's own
|
|
611
617
|
# processes, and so does lsof without root.
|
|
618
|
+
# _qa_repo — the repository the lane's PRs live in: KIT_REPO, else the origin remote.
|
|
619
|
+
_qa_repo() { if [ -n "${KIT_REPO:-}" ]; then printf '%s' "$KIT_REPO"; else forge_repo_from_git 2>/dev/null; fi; }
|
|
620
|
+
|
|
612
621
|
qa_port_pids() {
|
|
613
622
|
local port="$1" tool="${2:-}"
|
|
614
623
|
case "$port" in ''|*[!0-9]*) return 0 ;; esac
|
|
@@ -860,9 +869,8 @@ EOF
|
|
|
860
869
|
_qa_pr_meta() {
|
|
861
870
|
local out=""
|
|
862
871
|
[ -n "${1:-}" ] || return 1
|
|
863
|
-
|
|
864
|
-
out="$(
|
|
865
|
-
--jq '(.number | tostring), .url, .headRefOid, .headRefName' 2>/dev/null)" || return 1
|
|
872
|
+
forge_available || return 1
|
|
873
|
+
out="$(forge_pr_view "$(_qa_repo)" "$1" 2>/dev/null | jq -r '(.number | tostring), .url, .head_sha, .head')" || return 1
|
|
866
874
|
case "$(printf '%s\n' "$out" | sed -n 1p)" in ''|*[!0-9]*) return 1 ;; esac
|
|
867
875
|
printf '%s\n' "$out"
|
|
868
876
|
}
|
|
@@ -1240,7 +1248,7 @@ before the listeners, so nothing respawns. It reports only the processes that ar
|
|
|
1240
1248
|
Exit 0 when the ports are free, including on a lane that was already down; exit 1 names the pid
|
|
1241
1249
|
still listening.
|
|
1242
1250
|
|
|
1243
|
-
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,
|
|
1244
1252
|
else the local tip of the lane's branch, else the PR's head. It upserts ONE comment on the lane's
|
|
1245
1253
|
PR (a second verdict edits it) plus one per --shot; a screenshot is a path reference unless
|
|
1246
1254
|
KIT_EVIDENCE_URL_BASE is set, because gh cannot upload an image. A fail needs notes and mails them
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# review-page-test.sh — a page opens only where a reader can see it, the fallback never fails, and
|
|
3
3
|
# an answer is written to the issue or to a file (#451).
|
|
4
4
|
#
|
|
5
|
-
# Hermetic: `lavish-axi`, `npx`, `
|
|
5
|
+
# Hermetic: `lavish-axi`, `npx`, `uname` and the forge shim's `curl` are stubs on a sealed PATH that log their
|
|
6
6
|
# arguments; no browser starts and no network is touched. Every file lands under one mktemp dir.
|
|
7
7
|
# Each case names the whole session environment it runs in, because the host's own (CI on the
|
|
8
8
|
# runner, CLAUDECODE in an agent's shell) would otherwise decide the outcome.
|
|
@@ -33,7 +33,7 @@ for tool in sh bash jq git grep sed awk sort cat mkdir rm dirname basename chmod
|
|
|
33
33
|
src="$(command -v "$tool" 2>/dev/null)" || continue
|
|
34
34
|
case "$src" in /*) ln -s "$src" "$SEALED/$tool" ;; esac
|
|
35
35
|
done
|
|
36
|
-
STUB="$TMP/stub"; mkdir -p "$STUB" # lavish-axi +
|
|
36
|
+
STUB="$TMP/stub"; mkdir -p "$STUB" # lavish-axi + uname + the forge shim (curl, gh)
|
|
37
37
|
NPXONLY="$TMP/npxonly"; mkdir -p "$NPXONLY"
|
|
38
38
|
LOG="$TMP/calls.log"; : > "$LOG"
|
|
39
39
|
printf '0\n' > "$TMP/lavish-rc"
|
|
@@ -60,22 +60,27 @@ cat > "$NPXONLY/uname" <<EOF
|
|
|
60
60
|
#!/bin/sh
|
|
61
61
|
cat "$TMP/os"
|
|
62
62
|
EOF
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
# The forge: test-forge-shim.sh installs a `curl` that answers like the REST API (and a `gh` that
|
|
64
|
+
# fails on any subcommand) into the stub dir. A fixture keeps the comment store: the listing
|
|
65
|
+
# (GET …/issues/<n>/comments) answers the bodies recorded so far in gh-comments (one JSON string
|
|
66
|
+
# per line); a comment (POST …/issues/<n>/comments) records the body, keeps it in gh-last-body and
|
|
67
|
+
# prints a URL, or fails with 502 when gh-rc is not 0. Every request is logged to $LOG beside the
|
|
68
|
+
# page tool's calls, as `METHOD path {json}`.
|
|
69
|
+
# shellcheck source=/dev/null
|
|
70
|
+
. "$ROOT/scripts/lib/test-forge-shim.sh"; forge_shim_install "$STUB"
|
|
71
|
+
cat > "$TMP/fixture" <<EOF
|
|
72
|
+
case "\$method \$ep" in
|
|
73
|
+
"GET repos/o/r/issues/"*"/comments")
|
|
74
|
+
out="\$(jq -sc 'to_entries | map({id: (.key + 1), body: .value})' "$TMP/gh-comments")" ;;
|
|
75
|
+
"POST repos/o/r/issues/"*"/comments")
|
|
71
76
|
rc="\$(cat "$TMP/gh-rc")"
|
|
72
|
-
[ "\$rc" = 0 ]
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
if [ "\$rc" = 0 ]; then
|
|
78
|
+
n="\${ep#repos/o/r/issues/}"; n="\${n%%/*}"
|
|
79
|
+
printf '%s' "\$body" | jq -c .body >> "$TMP/gh-comments"
|
|
80
|
+
printf '%s' "\$body" | jq -r .body > "$TMP/gh-last-body"
|
|
81
|
+
out="{\"html_url\":\"https://example.invalid/o/r/issues/\$n#issuecomment-1\"}"
|
|
82
|
+
else code=502; out='{"message":"refused"}'; fi ;;
|
|
77
83
|
esac
|
|
78
|
-
exit 0
|
|
79
84
|
EOF
|
|
80
85
|
chmod +x "$STUB"/* "$NPXONLY"/*
|
|
81
86
|
|
|
@@ -102,6 +107,7 @@ page() {
|
|
|
102
107
|
while [ $# -gt 0 ] && [ "$1" != "--" ]; do envs+=("$1"); shift; done
|
|
103
108
|
shift
|
|
104
109
|
( cd "$proj" && env -i HOME="$TMP/home" PATH="$STUB:$SEALED" KIT_CONFIG="$proj/.claude/kit.config.json" \
|
|
110
|
+
GH_LOG="$LOG" GH_FIXTURE="$TMP/fixture" GH_TOKEN=test-token CCKIT_FORGE=github \
|
|
105
111
|
CLAUDECODE=1 CLAUDE_CODE_ENTRYPOINT=cli CLAUDE_CODE_SESSION_ATTENDED=1 DISPLAY=:0 \
|
|
106
112
|
${envs[@]+"${envs[@]}"} bash "$LIBF" "$@" </dev/null 2> "$TMP/err" )
|
|
107
113
|
}
|
|
@@ -205,7 +211,8 @@ reset
|
|
|
205
211
|
printf 'Chose option B: one PR.\n' > "$TMP/answer.md"
|
|
206
212
|
out="$(page "$GH" -- answer --kind decision --title "Ship as one PR" --issue 42 --body-file "$TMP/answer.md")"; rc=$?
|
|
207
213
|
t "answer rc" "$rc" "0"
|
|
208
|
-
yes "answer
|
|
214
|
+
yes "answer read the issue's comments first" "$(calls)" "GET repos/o/r/issues/42/comments?per_page=100 |"
|
|
215
|
+
yes "answer commented on the issue, in the configured repo" "$(calls)" "POST repos/o/r/issues/42/comments {\"body\":"
|
|
209
216
|
yes "answer prints where it went" "$out" "issue #42 https://example.invalid/o/r/issues/42#issuecomment-1"
|
|
210
217
|
body="$(cat "$TMP/gh-last-body")"
|
|
211
218
|
yes "comment: kind and title in the heading" "$body" "### Decision answer: Ship as one PR"
|
|
@@ -215,16 +222,16 @@ t "answer wrote no file in a GitHub project" "$([ -e "$GH/docs/answers" ] && ech
|
|
|
215
222
|
: > "$LOG"
|
|
216
223
|
out="$(page "$GH" -- answer --kind decision --title "Ship as one PR" --issue 42 --body-file "$TMP/answer.md")"; rc=$?
|
|
217
224
|
t "same answer again: rc 0" "$rc" "0"
|
|
218
|
-
no "same answer again: no second comment" "$(calls)" "
|
|
225
|
+
no "same answer again: no second comment" "$(calls)" "POST repos/o/r/issues"
|
|
219
226
|
yes "same answer again: says so" "$out" "issue #42 (already recorded)"
|
|
220
227
|
: > "$LOG"
|
|
221
228
|
# page() feeds /dev/null on stdin, so an answer with no --body-file has an empty body.
|
|
222
229
|
page "$GH" -- answer --kind decision --title "Ship as one PR" --issue '#42' >/dev/null
|
|
223
230
|
t "an empty body is refused" "$?" "2"
|
|
224
|
-
no "an empty body posts nothing" "$(calls)" "
|
|
231
|
+
no "an empty body posts nothing" "$(calls)" "POST repos/o/r/issues"
|
|
225
232
|
printf 'Chose option A instead.\n' > "$TMP/answer2.md"
|
|
226
233
|
page "$GH" -- answer --kind decision --title "Ship as one PR" --issue '#42' --body-file "$TMP/answer2.md" >/dev/null
|
|
227
|
-
yes "a different answer on the same issue is a new comment" "$(calls)" "
|
|
234
|
+
yes "a different answer on the same issue is a new comment" "$(calls)" "POST repos/o/r/issues/42/comments"
|
|
228
235
|
out="$(page "$GH" CCKIT_OUTPUT=json -- answer --kind grill --title "Round 1" --issue 42 --body-file "$TMP/answer.md")"
|
|
229
236
|
t "--llm answer is one JSON object" "$(printf '%s' "$out" | jq -c '[.ok, .where, .issue, .written]')" '[true,"issue",42,true]'
|
|
230
237
|
reset; printf '1\n' > "$TMP/gh-rc"
|
|
@@ -233,7 +240,8 @@ t "a refused comment -> rc 1" "$rc" "1"
|
|
|
233
240
|
yes "a refused comment names the cause" "$(cat "$TMP/err")" "could not comment on #42"
|
|
234
241
|
reset
|
|
235
242
|
page "$GH" CI=true -- answer --kind plan --title "Approved in the terminal" --issue 7 --body-file "$TMP/answer.md" >/dev/null
|
|
236
|
-
yes "terminal mode writes the answer back too" "$(calls)" "
|
|
243
|
+
yes "terminal mode writes the answer back too" "$(calls)" "POST repos/o/r/issues/7/comments"
|
|
244
|
+
no "no gh subcommand ran" "$(cat "$LOG")" "GH-SUBCOMMAND"
|
|
237
245
|
|
|
238
246
|
# ── 9. answer: no GitHub (or no issue) writes a versioned file ─────────────────────────────────
|
|
239
247
|
reset
|
|
@@ -242,7 +250,7 @@ out="$(page "$NOGH" -- answer --kind decision --title "Launch: week 12, not 14!"
|
|
|
242
250
|
want="$NOGH/docs/answers/$today-decision-launch-week-12-not-14.md"
|
|
243
251
|
t "file answer rc" "$rc" "0"
|
|
244
252
|
t "file answer prints the path" "$out" "file $want"
|
|
245
|
-
t "file answer made no
|
|
253
|
+
t "file answer made no forge call" "$(calls)" ""
|
|
246
254
|
f="$(cat "$want" 2>/dev/null)"
|
|
247
255
|
yes "file: heading" "$f" "# Decision answer: Launch: week 12, not 14!"
|
|
248
256
|
yes "file: date" "$f" "- Recorded: $today"
|
|
@@ -264,14 +272,14 @@ yes "no GitHub repo in the config: an --issue still goes to a file" "$out" "file
|
|
|
264
272
|
yes "…and the file records the issue" "$(cat "$NOGH/docs/answers/$today-plan-q3-plan.md")" "- Issue: #9"
|
|
265
273
|
out="$(page "$GH" -- answer --kind plan --title "Before the issue exists" --body-file "$TMP/answer.md")"
|
|
266
274
|
yes "a GitHub project with no --issue writes a file" "$out" "file $GH/docs/answers/$today-plan-before-the-issue-exists.md"
|
|
267
|
-
t "…and makes no
|
|
275
|
+
t "…and makes no forge call" "$(calls)" ""
|
|
268
276
|
|
|
269
277
|
# ── 10. answer: reviewPages.answers / answersDir decide when they are set ──────────────────────
|
|
270
278
|
FORCEF="$(project forcef '{"github":{"repo":"o/r"},"reviewPages":{"answers":"file","answersDir":"knowledge/decisions"}}')"
|
|
271
279
|
reset
|
|
272
280
|
out="$(page "$FORCEF" -- answer --kind decision --title "Pick" --issue 5 --body-file "$TMP/answer.md")"
|
|
273
281
|
yes "answers=file wins over a GitHub issue, in answersDir" "$out" "file $FORCEF/knowledge/decisions/$today-decision-pick.md"
|
|
274
|
-
t "answers=file makes no
|
|
282
|
+
t "answers=file makes no forge call" "$(calls)" ""
|
|
275
283
|
FORCEI="$(project forcei '{"reviewPages":{"answers":"issue"}}')"
|
|
276
284
|
page "$FORCEI" -- answer --kind decision --title "Pick" --body-file "$TMP/answer.md" >/dev/null
|
|
277
285
|
t "answers=issue with no --issue -> rc 2" "$?" "2"
|
|
@@ -303,9 +311,10 @@ if command -v zsh >/dev/null 2>&1; then
|
|
|
303
311
|
yes "zsh: CI -> terminal" "$(zmode CI=true)" "terminal CI is set"
|
|
304
312
|
reset
|
|
305
313
|
( cd "$GH" && env -i HOME="$TMP/home" PATH="$STUB:$SEALED" KIT_CONFIG="$GH/.claude/kit.config.json" \
|
|
314
|
+
GH_LOG="$LOG" GH_FIXTURE="$TMP/fixture" GH_TOKEN=test-token CCKIT_FORGE=github \
|
|
306
315
|
CLAUDECODE=1 CLAUDE_CODE_ENTRYPOINT=cli DISPLAY=:0 "$ZSH" -c ". '$LIBF'; rp_open .lavish/plan.html; rp_answer --kind plan --title 'Z plan' --issue 3 --body-file '$TMP/answer.md'" </dev/null >/dev/null 2>&1 )
|
|
307
316
|
yes "zsh: open runs the tool" "$(calls)" "lavish-axi .lavish/plan.html|"
|
|
308
|
-
yes "zsh: answer comments on the issue" "$(calls)" "
|
|
317
|
+
yes "zsh: answer comments on the issue" "$(calls)" "POST repos/o/r/issues/3/comments"
|
|
309
318
|
zerr="$( cd "$NOGH" && env -i HOME="$TMP/home" PATH="$STUB:$SEALED" KIT_CONFIG="$NOGH/.claude/kit.config.json" \
|
|
310
319
|
"$ZSH" -c ". '$LIBF'; rp_answer --kind grill --title 'Z round' --body-file '$TMP/answer.md'; rp_answer --title x --kind" </dev/null 2>&1 >/dev/null )"
|
|
311
320
|
t "zsh: a file answer is written" "$([ -f "$NOGH/docs/answers/$today-grill-z-round.md" ] && echo yes || echo no)" "yes"
|
|
@@ -46,6 +46,12 @@
|
|
|
46
46
|
# contract); rp_pass in page mode returns the tool's own status; rp_answer is strict: rc 2 on a
|
|
47
47
|
# usage error, rc 1 when the comment or the file could not be written.
|
|
48
48
|
|
|
49
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
50
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
51
|
+
# shellcheck source=/dev/null
|
|
52
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
53
|
+
fi
|
|
54
|
+
|
|
49
55
|
_rp_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
50
56
|
# shellcheck source=/dev/null
|
|
51
57
|
. "$_rp_dir/kit-cli.sh" # kit_is_main, kit_say, kit_warn
|
|
@@ -258,8 +264,8 @@ rp_answer() {
|
|
|
258
264
|
{ printf '%s\n### %s answer: %s\n\n' "$marker" "$label" "$title"; cat "$tmp"
|
|
259
265
|
printf '\n\n_Recorded from a review page with `cckit page answer`, %s._\n' "$today"; } > "$body"
|
|
260
266
|
repo="$(_rp_cfg_get '.github.repo')"
|
|
261
|
-
|
|
262
|
-
|
|
267
|
+
[ -n "$repo" ] || repo="$(forge_repo_from_git 2>/dev/null || true)"
|
|
268
|
+
out="$(gh_rest_issue_comments "$repo" "$issue" 2>/dev/null || true)"
|
|
263
269
|
case "$out" in *"$marker"*)
|
|
264
270
|
rm -f "$tmp" "$body"
|
|
265
271
|
kit_say "page answer: already recorded on #$issue — nothing written"
|
|
@@ -267,8 +273,8 @@ rp_answer() {
|
|
|
267
273
|
else printf 'issue #%s (already recorded)\n' "$issue"; fi
|
|
268
274
|
return 0 ;;
|
|
269
275
|
esac
|
|
270
|
-
|
|
271
|
-
|
|
276
|
+
[ -n "$repo" ] || repo="$(forge_repo_from_git 2>/dev/null || true)"
|
|
277
|
+
out="$(gh_rest_issue_comment "$repo" "$issue" "@$body" 2>&1)"; n=$?
|
|
272
278
|
rm -f "$tmp" "$body"
|
|
273
279
|
if [ "$n" -ne 0 ]; then
|
|
274
280
|
kit_warn "page answer: could not comment on #$issue — $out"
|
|
@@ -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
|
+
}
|