@jeiemgi/cckit 0.7.1 → 0.9.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 +15 -4
- package/README.md +25 -3
- package/bin/cckit +91 -8
- package/cckit.config.json +1 -1
- package/kit.config.schema.json +43 -2
- package/package.json +1 -1
- package/scripts/autopilot-test.sh +68 -0
- package/scripts/autopilot.sh +16 -10
- package/scripts/check.sh +14 -1
- package/scripts/copilot-loop-test.sh +3 -0
- package/scripts/guard-raw-git-ops-test.sh +73 -0
- package/scripts/init.sh +68 -8
- package/scripts/lib/agent-profile-test.sh +151 -0
- package/scripts/lib/agent-profile.sh +195 -0
- package/scripts/lib/agent-resolve-test.sh +156 -0
- package/scripts/lib/agent-resolve.sh +177 -0
- package/scripts/lib/branch-owner-test.sh +99 -0
- package/scripts/lib/branch-owner.sh +194 -0
- package/scripts/lib/captain-test.sh +86 -0
- package/scripts/lib/captain.sh +142 -7
- package/scripts/lib/contribute-root-test.sh +40 -0
- package/scripts/lib/contribute-root.sh +22 -0
- package/scripts/lib/effort-metrics.sh +14 -1
- package/scripts/lib/effort-ops-test.sh +54 -2
- package/scripts/lib/effort-ops.sh +243 -23
- package/scripts/lib/effort-parity-test.sh +5 -3
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +49 -15
- package/scripts/lib/gh-project.sh +14 -0
- package/scripts/lib/gh-rest-test.sh +301 -0
- package/scripts/lib/gh-rest.sh +289 -0
- package/scripts/lib/hook-refresh-test.sh +65 -0
- package/scripts/lib/hook-refresh.sh +62 -0
- package/scripts/lib/kit-config.sh +6 -0
- package/scripts/lib/kit-gc-test.sh +178 -1
- package/scripts/lib/kit-gc.sh +251 -55
- package/scripts/lib/kit-task-ops-test.sh +15 -0
- package/scripts/lib/kit-task-ops.sh +231 -58
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +129 -0
- package/scripts/lib/kto-task-pr-test.sh +59 -0
- package/scripts/lib/orchestration-runtime-test.sh +142 -0
- package/scripts/lib/orchestration-runtime.sh +171 -0
- package/scripts/lib/review-stage-test.sh +241 -0
- package/scripts/lib/review-stage.sh +259 -0
- package/scripts/lib/stage-receipt-test.sh +252 -0
- package/scripts/lib/stage-receipt.sh +442 -0
- package/scripts/lib/test-env-test.sh +25 -0
- package/scripts/lib/test-env.sh +33 -0
- package/scripts/lib/worker-brief-test.sh +120 -0
- package/scripts/lib/worker-brief.sh +185 -0
- package/scripts/lib/worktree-issue.sh +14 -0
- package/scripts/lib/worktree-ports-test.sh +146 -0
- package/scripts/lib/worktree-start.sh +153 -8
- package/scripts/lib/zsh-safety-test.sh +67 -0
- package/scripts/orchestrate.sh +124 -22
- package/scripts/portable-test.sh +22 -1
- package/scripts/review-lint-baseline.txt +28 -0
- package/scripts/review-lint-test.sh +271 -0
- package/scripts/review-lint.sh +259 -0
- package/scripts/review-rules.conf +55 -0
- package/scripts/setup-labels.sh +21 -1
- package/scripts/skill-frontmatter-baseline.txt +24 -0
- package/scripts/skill-frontmatter-lint-test.sh +156 -0
- package/scripts/skill-frontmatter-lint.sh +182 -0
- package/scripts/task-sync.sh +8 -0
- package/scripts/test.sh +10 -1
- package/skills/kit-autopilot/SKILL.md +13 -1
- package/skills/kit-cleanup/SKILL.md +5 -3
- package/skills/kit-contribute/SKILL.md +6 -5
- package/skills/kit-effort-close/SKILL.md +8 -3
- package/skills/kit-effort-pr/SKILL.md +16 -95
- package/skills/kit-gc/SKILL.md +15 -10
- package/skills/kit-security-sweep/SKILL.md +4 -6
- package/skills/kit-ship/SKILL.md +1 -1
- package/skills/kit-task-pr/SKILL.md +2 -0
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +193 -0
- package/templates/rules/branch-naming.md +6 -0
- package/templates/rules/effort-model.md +3 -0
- package/templates/rules/naming-and-ids.md +4 -1
- package/templates/settings/settings.json.tmpl +4 -2
|
@@ -124,6 +124,92 @@ if [ -n "${CAP_TEST_INNER:-}" ]; then
|
|
|
124
124
|
eq "branch fix" "$(_cap_issue_of_branch 'fix/9-roadmap')" "9"
|
|
125
125
|
eq "branch effort" "$(_cap_issue_of_branch 'effort/123-copilot')" "123"
|
|
126
126
|
eq "branch plain" "$(_cap_issue_of_branch 'main')" ""
|
|
127
|
+
# The effort sub form. The local regex needs a "-" straight after the digits and so returns
|
|
128
|
+
# nothing here; wt_issue_number is what parses it. A sub-branch PR with no issue has no review
|
|
129
|
+
# verdict to look up and would read CLEAN (#348).
|
|
130
|
+
if command -v wt_issue_number >/dev/null 2>&1; then
|
|
131
|
+
eq "branch effort sub" "$(_cap_issue_of_branch 'sub/1604a-parser')" "1604"
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
# ── the agent review gate (#348) ─────────────────────────────────────────────────────────────
|
|
135
|
+
# cap_review_summary: one token out of a receipt, the same shape cap_checks_summary has.
|
|
136
|
+
if command -v jq >/dev/null 2>&1; then
|
|
137
|
+
eq "review: gate pass" "$(printf '{"gate":"pass"}' | cap_review_summary)" "PASS"
|
|
138
|
+
eq "review: gate fail" "$(printf '{"gate":"fail"}' | cap_review_summary)" "FAIL"
|
|
139
|
+
# The detail after the dash is the useful half of a real verdict; matching the whole field
|
|
140
|
+
# would score every annotated receipt as NONE.
|
|
141
|
+
eq "review: annotated fail" "$(printf '{"gate":"fail — the retry loop never exits"}' | cap_review_summary)" "FAIL"
|
|
142
|
+
eq "review: annotated pass" "$(printf '{"gate":"pass — read the whole diff"}' | cap_review_summary)" "PASS"
|
|
143
|
+
eq "review: no gate field" "$(printf '{"outcome":"pr-open"}' | cap_review_summary)" "NONE"
|
|
144
|
+
eq "review: empty stdin" "$(printf '' | cap_review_summary)" "NONE"
|
|
145
|
+
eq "review: unknown word" "$(printf '{"gate":"maybe"}' | cap_review_summary)" "NONE"
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
# A recorded FAIL always blocks — it is evidence, not absence of it, so no flag gates it.
|
|
149
|
+
( KIT_CAPTAIN_REQUIRE_REVIEW=0
|
|
150
|
+
eq "review FAIL blocks even unrequired" "$(cap_classify MERGEABLE CLEAN PASS FAIL)" "REVIEW_FAILING" ) || fail=1
|
|
151
|
+
eq "REVIEW_FAILING -> fix" "$(cap_action REVIEW_FAILING)" "fix"
|
|
152
|
+
|
|
153
|
+
# A MISSING verdict is gated on the requirement, exactly like CHECKS_MISSING.
|
|
154
|
+
( KIT_CAPTAIN_REQUIRE_REVIEW=0
|
|
155
|
+
eq "no verdict merges when not required" "$(cap_classify MERGEABLE CLEAN PASS NONE)" "CLEAN" ) || fail=1
|
|
156
|
+
( KIT_CAPTAIN_REQUIRE_REVIEW=1
|
|
157
|
+
eq "no verdict blocks when required" "$(cap_classify MERGEABLE CLEAN PASS NONE)" "REVIEW_MISSING" ) || fail=1
|
|
158
|
+
eq "REVIEW_MISSING -> verify" "$(cap_action REVIEW_MISSING)" "verify"
|
|
159
|
+
|
|
160
|
+
# A passing verdict never blocks, required or not.
|
|
161
|
+
( KIT_CAPTAIN_REQUIRE_REVIEW=1
|
|
162
|
+
eq "a passing verdict merges" "$(cap_classify MERGEABLE CLEAN PASS PASS)" "CLEAN" ) || fail=1
|
|
163
|
+
|
|
164
|
+
# Red CI outranks the review: the PR will be rewritten before the review matters.
|
|
165
|
+
( KIT_CAPTAIN_REQUIRE_REVIEW=1
|
|
166
|
+
eq "failing checks outrank a missing review" "$(cap_classify MERGEABLE CLEAN FAIL NONE)" "CHECKS_FAILING"
|
|
167
|
+
eq "a conflict outranks a failing review" "$(cap_classify CONFLICTING DIRTY PASS FAIL)" "CONFLICTING"
|
|
168
|
+
eq "a draft outranks a failing review" "$(cap_classify MERGEABLE DRAFT PASS FAIL)" "DRAFT" ) || fail=1
|
|
169
|
+
|
|
170
|
+
# Omitting the argument must not change any existing verdict — every caller predating #348 passes
|
|
171
|
+
# three arguments, and a default of anything but NONE would re-decide them.
|
|
172
|
+
eq "a 3-arg call still reads CLEAN" "$(cap_classify MERGEABLE CLEAN PASS)" "CLEAN"
|
|
173
|
+
( KIT_CAPTAIN_REQUIRE_REVIEW=1
|
|
174
|
+
eq "a 3-arg call defaults to NONE" "$(cap_classify MERGEABLE CLEAN PASS)" "REVIEW_MISSING" ) || fail=1
|
|
175
|
+
|
|
176
|
+
# head_sha binds a verdict to a revision (#351 review). Without it a PASS earned on one commit
|
|
177
|
+
# gates every commit pushed after it — sr_latest is newest-by-issue and knows nothing about SHAs.
|
|
178
|
+
if command -v jq >/dev/null 2>&1; then
|
|
179
|
+
eq "review: a matching head still passes" \
|
|
180
|
+
"$(printf '{"gate":"pass","head_sha":"abc"}' | cap_review_summary abc)" "PASS"
|
|
181
|
+
eq "review: a stale verdict reads NONE, not PASS" \
|
|
182
|
+
"$(printf '{"gate":"pass","head_sha":"abc"}' | cap_review_summary def)" "NONE"
|
|
183
|
+
# A stale FAIL is also absence: the reviewer read code that is no longer there, so it is neither
|
|
184
|
+
# a finding against this revision nor a pass for it.
|
|
185
|
+
eq "review: a stale fail reads NONE too" \
|
|
186
|
+
"$(printf '{"gate":"fail","head_sha":"abc"}' | cap_review_summary def)" "NONE"
|
|
187
|
+
# No head asked: the check is skipped. This is also what keeps a receipt written before head_sha
|
|
188
|
+
# existed (empty field) readable instead of permanently stale.
|
|
189
|
+
eq "review: no head asked skips the check" \
|
|
190
|
+
"$(printf '{"gate":"pass","head_sha":"abc"}' | cap_review_summary)" "PASS"
|
|
191
|
+
eq "review: a head-less receipt does not match a head" \
|
|
192
|
+
"$(printf '{"gate":"pass"}' | cap_review_summary abc)" "NONE"
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
# The config bridge: review.command implies the requirement; requireReview:false opts back out.
|
|
196
|
+
if command -v jq >/dev/null 2>&1; then
|
|
197
|
+
revbridge() {
|
|
198
|
+
( KIT_CONFIG="$1"; KIT_CAPTAIN_FLOORS=; KIT_CAPTAIN_EXTRA_GLOBS=; KIT_CAPTAIN_REQUIRE_CHECKS=
|
|
199
|
+
KIT_CAPTAIN_REQUIRE_REVIEW="$2"
|
|
200
|
+
_cap_load_policy_config; printf '%s' "${KIT_CAPTAIN_REQUIRE_REVIEW:-unset}" )
|
|
201
|
+
}
|
|
202
|
+
rc1="$(mktemp)"; printf '{"review":{"command":"true"}}' > "$rc1"
|
|
203
|
+
rc2="$(mktemp)"; printf '{"review":{"command":"true"},"captain":{"mergePolicy":{"requireReview":false}}}' > "$rc2"
|
|
204
|
+
rc3="$(mktemp)"; printf '{"captain":{"mergePolicy":{"requireReview":true}}}' > "$rc3"
|
|
205
|
+
rc4="$(mktemp)"; printf '{}' > "$rc4"
|
|
206
|
+
eq "bridge: review.command implies required" "$(revbridge "$rc1" "")" "1"
|
|
207
|
+
eq "bridge: requireReview:false opts out" "$(revbridge "$rc2" "")" "0"
|
|
208
|
+
eq "bridge: requireReview:true with no cmd" "$(revbridge "$rc3" "")" "1"
|
|
209
|
+
eq "bridge: neither is off" "$(revbridge "$rc4" "")" "0"
|
|
210
|
+
eq "bridge: env 0 beats review.command" "$(revbridge "$rc1" "0")" "0"
|
|
211
|
+
rm -f "$rc1" "$rc2" "$rc3" "$rc4"
|
|
212
|
+
fi
|
|
127
213
|
|
|
128
214
|
if [ "$fail" -eq 0 ]; then echo "PASS($CAP_TEST_INNER): captain gate policy"; fi
|
|
129
215
|
exit "$fail"
|
package/scripts/lib/captain.sh
CHANGED
|
@@ -34,6 +34,20 @@ if [ -f "$(dirname "$_cap_self")/kit-state.sh" ]; then
|
|
|
34
34
|
# shellcheck source=kit-state.sh
|
|
35
35
|
. "$(dirname "$_cap_self")/kit-state.sh"
|
|
36
36
|
fi
|
|
37
|
+
# The review stage (#346) is sourced here, not left to a caller: captain_pass guards on
|
|
38
|
+
# `command -v rs_needs_dispatch`, so a missing source would switch the stage off silently rather
|
|
39
|
+
# than fail. CAPTAIN_CFG is what rs_command reads `review.command` out of — resolved through
|
|
40
|
+
# kit_config_path because two config layouts are current and neither path is safe to hard-code.
|
|
41
|
+
if [ -f "$(dirname "$_cap_self")/review-stage.sh" ]; then
|
|
42
|
+
# shellcheck source=config-path.sh
|
|
43
|
+
[ -f "$(dirname "$_cap_self")/config-path.sh" ] && . "$(dirname "$_cap_self")/config-path.sh"
|
|
44
|
+
# shellcheck source=review-stage.sh
|
|
45
|
+
. "$(dirname "$_cap_self")/review-stage.sh"
|
|
46
|
+
fi
|
|
47
|
+
if [ -z "${CAPTAIN_CFG:-}" ] && command -v kit_config_path >/dev/null 2>&1; then
|
|
48
|
+
CAPTAIN_CFG="$(kit_config_path 2>/dev/null || true)"
|
|
49
|
+
fi
|
|
50
|
+
CAPTAIN_CFG="${CAPTAIN_CFG:-}"
|
|
37
51
|
unset _cap_self
|
|
38
52
|
if [ -z "${CAPTAIN_STATE:-}" ] && command -v kit_state_file >/dev/null 2>&1; then
|
|
39
53
|
CAPTAIN_STATE="$(kit_state_file captain.state)"
|
|
@@ -53,6 +67,36 @@ cap_checks_summary() {
|
|
|
53
67
|
else "NONE" end' 2>/dev/null || echo NONE
|
|
54
68
|
}
|
|
55
69
|
|
|
70
|
+
# cap_review_summary — collapse a review receipt (stdin, sr_record's JSON) to one token:
|
|
71
|
+
# FAIL (the reviewer said gate: fail) > PASS (gate: pass) > NONE (no receipt, or no gate line).
|
|
72
|
+
# Pure apart from jq. Empty stdin is NONE, which is the state every repo is in until a reviewer runs.
|
|
73
|
+
#
|
|
74
|
+
# `gate` is read on its FIRST WORD, the same way sr_invalid_fields reads it: a receipt says
|
|
75
|
+
# `fail — the retry loop never exits` and the detail after the dash is the useful half, not part of
|
|
76
|
+
# the verdict. Matching the whole field would score every annotated verdict as NONE.
|
|
77
|
+
#
|
|
78
|
+
# <head-sha> BINDS THE VERDICT TO A REVISION. sr_latest returns the newest receipt for an issue and
|
|
79
|
+
# knows nothing about commits, so without this a PASS earned on one commit gates every commit
|
|
80
|
+
# pushed after it — the reviewer approved code that is no longer there. Given a head, a receipt
|
|
81
|
+
# recorded against a different one reads NONE: not a failure, an absence, which is what it is. An
|
|
82
|
+
# empty head skips the check, for a caller with no revision to compare (and for every receipt
|
|
83
|
+
# written before head_sha existed, whose field is empty and would otherwise never match).
|
|
84
|
+
cap_review_summary() {
|
|
85
|
+
local head="${1:-}"
|
|
86
|
+
command -v jq >/dev/null 2>&1 || { echo NONE; return 0; }
|
|
87
|
+
# Empty stdin is the common case — sr_latest echoes nothing when there is no receipt — and jq
|
|
88
|
+
# reads no values from it, printing nothing and exiting 0. So the `|| echo NONE` fallback never
|
|
89
|
+
# fires and the caller gets an empty token instead of a verdict. Substitute an empty object.
|
|
90
|
+
local j; j="$(cat)"
|
|
91
|
+
[ -n "$j" ] || j='{}'
|
|
92
|
+
printf '%s' "$j" | jq -r --arg head "$head" '
|
|
93
|
+
if ($head != "" and ((.head_sha // "") != $head)) then "NONE"
|
|
94
|
+
else (.gate // "") | split(" ")[0] | ascii_upcase
|
|
95
|
+
| if . == "FAIL" then "FAIL" elif . == "PASS" then "PASS" else "NONE" end
|
|
96
|
+
end' 2>/dev/null \
|
|
97
|
+
|| echo NONE
|
|
98
|
+
}
|
|
99
|
+
|
|
56
100
|
# cap_classify <mergeable> <mergeStateStatus> <checksSummary> — pure verdict for one PR.
|
|
57
101
|
# mergeable: MERGEABLE|CONFLICTING|UNKNOWN · mss: CLEAN|DIRTY|DRAFT|BLOCKED|BEHIND|UNSTABLE|…
|
|
58
102
|
#
|
|
@@ -69,8 +113,18 @@ cap_checks_summary() {
|
|
|
69
113
|
# today's behaviour and `captain_pass` instead PRINTS the assumption it is making (see the "green was
|
|
70
114
|
# assumed" advisory) with the key that closes it. The narrow guard below is deliberate: only the
|
|
71
115
|
# verdict that would have been CLEAN can change, so nothing else in the vocabulary moves.
|
|
116
|
+
#
|
|
117
|
+
# REVIEW_FAILING / REVIEW_MISSING (#348) are the same two shapes for the agent review stage, and
|
|
118
|
+
# they split along the same line: a recorded `gate: fail` is EVIDENCE and always blocks, while a
|
|
119
|
+
# missing verdict is ABSENCE of evidence and blocks only when review is required. Absence is the
|
|
120
|
+
# state of every repo that has not run a reviewer — cckit's own included, which has no receipts at
|
|
121
|
+
# all — so requiring it unconditionally would stop every captain on upgrade.
|
|
122
|
+
#
|
|
123
|
+
# Required when review.command is configured (running a reviewer IS the opt-in) or when
|
|
124
|
+
# KIT_CAPTAIN_REQUIRE_REVIEW=1 / captain.mergePolicy.requireReview:true says so; env wins, as it
|
|
125
|
+
# does for checks. Off in both, captain_pass prints the advisory naming the key instead.
|
|
72
126
|
cap_classify() {
|
|
73
|
-
local mergeable="$1" mss="$2" checks="$3" require
|
|
127
|
+
local mergeable="$1" mss="$2" checks="$3" review="${4:-NONE}" require review_req
|
|
74
128
|
case "$mss" in DRAFT) echo DRAFT; return 0 ;; esac
|
|
75
129
|
case "$mergeable" in CONFLICTING) echo CONFLICTING; return 0 ;; esac
|
|
76
130
|
case "$mss" in DIRTY) echo CONFLICTING; return 0 ;; esac
|
|
@@ -78,14 +132,19 @@ cap_classify() {
|
|
|
78
132
|
FAIL) echo CHECKS_FAILING; return 0 ;;
|
|
79
133
|
PENDING) echo CHECKS_PENDING; return 0 ;;
|
|
80
134
|
esac
|
|
135
|
+
# A recorded failing review outranks the requirement flag: the reviewer ran and said no. This sits
|
|
136
|
+
# AFTER the check verdicts because a PR with red CI will be rewritten before the review matters.
|
|
137
|
+
case "$review" in FAIL) echo REVIEW_FAILING; return 0 ;; esac
|
|
81
138
|
# Literal case patterns only (a variable in a case pattern matches literally under zsh).
|
|
82
139
|
case "${KIT_CAPTAIN_REQUIRE_CHECKS:-0}" in 1|true|yes|on) require=1 ;; *) require=0 ;; esac
|
|
140
|
+
case "${KIT_CAPTAIN_REQUIRE_REVIEW:-0}" in 1|true|yes|on) review_req=1 ;; *) review_req=0 ;; esac
|
|
83
141
|
case "$mergeable" in
|
|
84
142
|
MERGEABLE)
|
|
85
143
|
# passing or no required checks, and not draft/dirty/conflicting -> ready.
|
|
86
144
|
case "$mss" in
|
|
87
145
|
CLEAN|UNSTABLE|HAS_HOOKS|"")
|
|
88
146
|
if [ "$require" = "1" ] && [ "$checks" = "NONE" ]; then echo CHECKS_MISSING; return 0; fi
|
|
147
|
+
if [ "$review_req" = "1" ] && [ "$review" = "NONE" ]; then echo REVIEW_MISSING; return 0; fi
|
|
89
148
|
echo CLEAN; return 0 ;;
|
|
90
149
|
esac
|
|
91
150
|
echo BLOCKED; return 0 ;;
|
|
@@ -104,6 +163,8 @@ cap_action() {
|
|
|
104
163
|
CHECKS_FAILING) echo fix ;;
|
|
105
164
|
CHECKS_PENDING) echo wait ;;
|
|
106
165
|
CHECKS_MISSING) echo verify ;;
|
|
166
|
+
REVIEW_FAILING) echo fix ;;
|
|
167
|
+
REVIEW_MISSING) echo verify ;;
|
|
107
168
|
DRAFT) echo wait ;;
|
|
108
169
|
HELD) echo hold ;;
|
|
109
170
|
*) echo skip ;;
|
|
@@ -200,11 +261,35 @@ _cap_load_policy_config() {
|
|
|
200
261
|
true) KIT_CAPTAIN_REQUIRE_CHECKS=1 ;; false) KIT_CAPTAIN_REQUIRE_CHECKS=0 ;;
|
|
201
262
|
esac
|
|
202
263
|
fi
|
|
203
|
-
|
|
264
|
+
# Review requirement (#348). Configuring review.command IS the opt-in — a project that runs a
|
|
265
|
+
# reviewer on every mergeable PR and then merges the ones the reviewer never got to has gained
|
|
266
|
+
# nothing. requireReview:false turns that implication off without giving up the reviewer, and an
|
|
267
|
+
# explicit requireReview:true requires a verdict with no review.command (a reviewer run by hand
|
|
268
|
+
# or by CI, recorded through `cckit receipt`).
|
|
269
|
+
if [ -z "${KIT_CAPTAIN_REQUIRE_REVIEW:-}" ]; then
|
|
270
|
+
case "$(_cap_cfg_bool "$cfg" requireReview)" in
|
|
271
|
+
true) KIT_CAPTAIN_REQUIRE_REVIEW=1 ;;
|
|
272
|
+
false) KIT_CAPTAIN_REQUIRE_REVIEW=0 ;;
|
|
273
|
+
*) if command -v rs_enabled >/dev/null 2>&1 && rs_enabled "$cfg"; then
|
|
274
|
+
KIT_CAPTAIN_REQUIRE_REVIEW=1
|
|
275
|
+
else
|
|
276
|
+
KIT_CAPTAIN_REQUIRE_REVIEW=0
|
|
277
|
+
fi ;;
|
|
278
|
+
esac
|
|
279
|
+
fi
|
|
280
|
+
export KIT_CAPTAIN_FLOORS KIT_CAPTAIN_EXTRA_GLOBS KIT_CAPTAIN_REQUIRE_CHECKS KIT_CAPTAIN_REQUIRE_REVIEW
|
|
204
281
|
}
|
|
205
282
|
|
|
206
283
|
# _cap_issue_of_branch <branch> — issue number a flow branch encodes (task/47-x, fix/9-y, effort/12-z).
|
|
284
|
+
#
|
|
285
|
+
# wt_issue_number when it is loaded, because the local regex requires a "-" immediately after the
|
|
286
|
+
# digits and so does NOT match the effort sub form `sub/<N><letter>-<slug>`. That was cosmetic while
|
|
287
|
+
# the number was only printed; it is not now — the review verdict is looked up BY issue (#348), so a
|
|
288
|
+
# sub-branch PR parsing to no issue would silently have no verdict to gate on and read CLEAN.
|
|
207
289
|
_cap_issue_of_branch() {
|
|
290
|
+
if command -v wt_issue_number >/dev/null 2>&1; then
|
|
291
|
+
wt_issue_number "$1"; return 0
|
|
292
|
+
fi
|
|
208
293
|
printf '%s' "$1" | sed -nE 's#^[a-z]+/([0-9]+)-.*#\1#p'
|
|
209
294
|
}
|
|
210
295
|
|
|
@@ -214,8 +299,8 @@ _cap_issue_of_branch() {
|
|
|
214
299
|
# carries the floor that tripped (empty otherwise). `checks` is the raw rollup token (FAIL/PENDING/
|
|
215
300
|
# PASS/NONE) — REPORTED, not re-decided, so captain_pass can say when a merge rests on NONE.
|
|
216
301
|
captain_gate() {
|
|
217
|
-
local repo="$CAPTAIN_REPO" pr="$1" j mergeable mss checks issue state action title branch files labels reason
|
|
218
|
-
j="$(gh pr view "$pr" --repo "$repo" --json number,title,headRefName,mergeable,mergeStateStatus,statusCheckRollup,files,labels 2>/dev/null)" \
|
|
302
|
+
local repo="$CAPTAIN_REPO" pr="$1" j mergeable mss checks review head issue state action title branch files labels reason
|
|
303
|
+
j="$(gh pr view "$pr" --repo "$repo" --json number,title,headRefName,headRefOid,mergeable,mergeStateStatus,statusCheckRollup,files,labels 2>/dev/null)" \
|
|
219
304
|
|| { echo "captain: cannot read PR #$pr" >&2; return 1; }
|
|
220
305
|
mergeable="$(printf '%s' "$j" | jq -r '.mergeable // "UNKNOWN"')"
|
|
221
306
|
mss="$(printf '%s' "$j" | jq -r '.mergeStateStatus // "UNKNOWN"')"
|
|
@@ -225,7 +310,16 @@ captain_gate() {
|
|
|
225
310
|
files="$(printf '%s' "$j" | jq -r '.files[]?.path // empty')"
|
|
226
311
|
labels="$(printf '%s' "$j" | jq -r '[.labels[]?.name] | join(" ")')"
|
|
227
312
|
issue="$(_cap_issue_of_branch "$branch")"
|
|
228
|
-
state
|
|
313
|
+
# The review verdict is local state, not a GitHub field: sr_latest reads the receipt this repo's
|
|
314
|
+
# reviewer wrote. No receipt, no issue, or no stage-receipt lib all collapse to NONE — absence,
|
|
315
|
+
# which cap_classify gates on only when review is required.
|
|
316
|
+
head="$(printf '%s' "$j" | jq -r '.headRefOid // ""')"
|
|
317
|
+
review=NONE
|
|
318
|
+
if [ -n "$issue" ] && command -v sr_latest >/dev/null 2>&1; then
|
|
319
|
+
review="$(sr_latest "$issue" review 2>/dev/null | cap_review_summary "$head")"
|
|
320
|
+
[ -n "$review" ] || review=NONE
|
|
321
|
+
fi
|
|
322
|
+
state="$(cap_classify "$mergeable" "$mss" "$checks" "$review")"
|
|
229
323
|
action="$(cap_action "$state")"
|
|
230
324
|
reason=""
|
|
231
325
|
# Policy floor: only a would-be merge is at risk, so gate only the CLEAN/merge verdict.
|
|
@@ -233,7 +327,7 @@ captain_gate() {
|
|
|
233
327
|
reason="$(cap_policy_floor "$files" "$labels")"
|
|
234
328
|
[ -n "$reason" ] && { state="HELD"; action="hold"; }
|
|
235
329
|
fi
|
|
236
|
-
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$pr" "${issue:-—}" "$state" "$action" "$title" "$reason" "$checks"
|
|
330
|
+
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$pr" "${issue:-—}" "$state" "$action" "$title" "$reason" "$checks" "$head"
|
|
237
331
|
}
|
|
238
332
|
|
|
239
333
|
# _cap_open_prs [effort] — open PR numbers, optionally only those whose branch-issue is a sub of <effort>.
|
|
@@ -271,7 +365,7 @@ captain_pass() {
|
|
|
271
365
|
CAPTAIN_MERGED=0
|
|
272
366
|
_cap_load_policy_config # bridge captain.mergePolicy from config into the floor env (env wins)
|
|
273
367
|
|
|
274
|
-
local prs pr row state action issue title reason checks merged_any=0 unproven=0
|
|
368
|
+
local prs pr row state action issue issue_num title reason checks head merged_any=0 unproven=0 unreviewed=0
|
|
275
369
|
prs="$(_cap_open_prs "$effort")"
|
|
276
370
|
[ -n "$prs" ] || { echo "captain: no open PRs in scope"; return 0; }
|
|
277
371
|
|
|
@@ -289,10 +383,41 @@ captain_pass() {
|
|
|
289
383
|
title="$(printf '%s' "$row" | cut -f5)"
|
|
290
384
|
reason="$(printf '%s' "$row" | cut -f6)"
|
|
291
385
|
checks="$(printf '%s' "$row" | cut -f7)"
|
|
386
|
+
head="$(printf '%s' "$row" | cut -f8)"
|
|
387
|
+
# Field 2 is a DISPLAY field carrying `—` for a PR whose branch encodes no issue. rs_issue_num
|
|
388
|
+
# is what everything keying storage off it goes through — see its comment for why.
|
|
389
|
+
issue_num="$issue"
|
|
390
|
+
command -v rs_issue_num >/dev/null 2>&1 && issue_num="$(rs_issue_num "$issue")"
|
|
292
391
|
{ printf '%s\t%s\n' "$pr" "$state" >> "$CAPTAIN_STATE"; } 2>/dev/null || true
|
|
293
392
|
# A merge resting on an EMPTY rollup: green was assumed, never observed. Counted here and named
|
|
294
393
|
# once at the end of the pass, so the assumption is on screen even with the requirement OFF.
|
|
295
394
|
if [ "$action" = "merge" ] && [ "$checks" = "NONE" ]; then unproven=$((unproven + 1)); fi
|
|
395
|
+
# Same shape for the review stage: a PR the captain will merge with NO recorded verdict. Counted
|
|
396
|
+
# only while review is NOT required, because once it is those PRs read REVIEW_MISSING -> verify
|
|
397
|
+
# and never reach `merge` — so the advisory self-silences exactly like the checks one.
|
|
398
|
+
if [ "$action" = "merge" ] && [ "${KIT_CAPTAIN_REQUIRE_REVIEW:-0}" != "1" ]; then
|
|
399
|
+
local rv=NONE
|
|
400
|
+
[ -n "$issue_num" ] && command -v sr_latest >/dev/null 2>&1 \
|
|
401
|
+
&& rv="$(sr_latest "$issue_num" review 2>/dev/null | cap_review_summary "$head")"
|
|
402
|
+
[ "${rv:-NONE}" = "NONE" ] && unreviewed=$((unreviewed + 1))
|
|
403
|
+
fi
|
|
404
|
+
# Review stage (#346). Dispatch runs INSIDE this pass, before the merge decision is acted on,
|
|
405
|
+
# so a PR the captain would merge gets a reviewer first. A fresh dispatch never unblocks the
|
|
406
|
+
# same pass: the receipt it writes is read by the gate on the NEXT pass, which is correct —
|
|
407
|
+
# a verdict must be recorded before it can be gated on, not assumed while the agent is running.
|
|
408
|
+
# Off unless review.command is configured; rs_dispatch echoes rc 4 and does nothing then.
|
|
409
|
+
if command -v rs_needs_dispatch >/dev/null 2>&1 && rs_enabled "$CAPTAIN_CFG"; then
|
|
410
|
+
local have=0; rs_have_receipt "$issue_num" "$head" && have=1
|
|
411
|
+
if rs_needs_dispatch "$state" "$action" "$have"; then
|
|
412
|
+
if rs_dispatch "$CAPTAIN_CFG" "$repo" "$pr" "$issue_num" "$head" >/dev/null; then
|
|
413
|
+
printf ' PR #%-4s %-14s -> reviewed (#%s %s)\n' "$pr" "$state" "$issue" "$title"
|
|
414
|
+
fi
|
|
415
|
+
# Held whether or not the reviewer succeeded. A failed dispatch leaves no receipt, and
|
|
416
|
+
# no receipt is missing evidence, not a pass — the same rule the empty-rollup advisory
|
|
417
|
+
# below states for checks.
|
|
418
|
+
action=verify
|
|
419
|
+
fi
|
|
420
|
+
fi
|
|
296
421
|
if [ "$action" = "merge" ] && [ "$do_merge" = "1" ] && [ "$dry" = "0" ]; then
|
|
297
422
|
if gh pr merge "$pr" --repo "$repo" --squash --delete-branch >/dev/null 2>&1; then
|
|
298
423
|
printf ' PR #%-4s %-14s MERGED (#%s %s)\n' "$pr" "$state" "$issue" "$title"
|
|
@@ -321,6 +446,16 @@ captain_pass() {
|
|
|
321
446
|
printf ' -> verify, and the captain will not merge them.\n'
|
|
322
447
|
fi
|
|
323
448
|
|
|
449
|
+
# The review stage's counterpart advisory. It fires only when a reviewer could have run and did
|
|
450
|
+
# not, names the two keys that close it, and goes quiet the moment either is on.
|
|
451
|
+
if [ "$unreviewed" -gt 0 ]; then
|
|
452
|
+
printf 'captain: %s PR(s) read CLEAN with NO agent review recorded.\n' "$unreviewed"
|
|
453
|
+
printf ' run one: set review.command in your kit config (the captain then dispatches a\n'
|
|
454
|
+
printf ' reviewer and requires its verdict). To require a verdict WITHOUT cckit running\n'
|
|
455
|
+
printf ' the reviewer, set captain.mergePolicy.requireReview:true. Those PRs then read\n'
|
|
456
|
+
printf ' REVIEW_MISSING -> verify, and the captain will not merge them.\n'
|
|
457
|
+
fi
|
|
458
|
+
|
|
324
459
|
# advance: after merges, the newly-unblocked work shows up as the next wave.
|
|
325
460
|
if [ "$merged_any" -gt 0 ]; then
|
|
326
461
|
echo "captain: merged $merged_any — next unblocked wave:"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# contribute-root-test.sh — `cckit contribute` acts on the cckit checkout containing cwd (#368).
|
|
3
|
+
# Hermetic: a fixture "cckit" repo whose scripts/contribute.sh is a stub that reports where it ran,
|
|
4
|
+
# so the real gate (scripts/check.sh) never runs from inside the test suite.
|
|
5
|
+
# Run: bash scripts/lib/contribute-root-test.sh
|
|
6
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
7
|
+
set -u
|
|
8
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
fail=0
|
|
10
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
11
|
+
# shellcheck source=/dev/null
|
|
12
|
+
. "$ROOT/scripts/lib/contribute-root.sh"
|
|
13
|
+
|
|
14
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
15
|
+
fx="$tmp/cckit"; plain="$tmp/plain"
|
|
16
|
+
git init -q "$fx"
|
|
17
|
+
mkdir -p "$fx/bin" "$fx/scripts"
|
|
18
|
+
printf '#!/usr/bin/env bash\n' > "$fx/bin/cckit"
|
|
19
|
+
printf '#!/usr/bin/env bash\necho "STUB pwd=$(pwd -P) branch=$(git rev-parse --abbrev-ref HEAD) args=$*"\n' > "$fx/scripts/contribute.sh"
|
|
20
|
+
chmod +x "$fx/bin/cckit" "$fx/scripts/contribute.sh"
|
|
21
|
+
git -C "$fx" add -A && git -C "$fx" -c user.email=t@t -c user.name=t commit -q -m init
|
|
22
|
+
wt="$fx/.claude/worktrees/task+1-x"
|
|
23
|
+
git -C "$fx" worktree add -q -b task/1-x "$wt"
|
|
24
|
+
git init -q "$plain"
|
|
25
|
+
wtp="$(cd "$wt" && pwd -P)"
|
|
26
|
+
|
|
27
|
+
t "a worktree resolves to itself" "$(cd "$(contribute_root "$wt/scripts" /installed)" && pwd -P)" "$wtp"
|
|
28
|
+
t "the main checkout resolves to itself" "$(contribute_root "$fx" /installed)" "$(git -C "$fx" rev-parse --show-toplevel)"
|
|
29
|
+
t "a non-cckit repo falls back to installed" "$(contribute_root "$plain" /installed)" "/installed"
|
|
30
|
+
t "outside any repo falls back to installed" "$(contribute_root / /installed)" "/installed"
|
|
31
|
+
|
|
32
|
+
# End to end through the real dispatcher: run from inside the fixture worktree, the fixture
|
|
33
|
+
# worktree's own contribute.sh must run, on the worktree's branch.
|
|
34
|
+
out="$(cd "$wt/scripts" && bash "$ROOT/bin/cckit" contribute --dry-run "a summary" 2>/dev/null)"
|
|
35
|
+
t "cckit contribute runs in the worktree" "$(printf '%s' "$out" | sed -n 's/.*pwd=\([^ ]*\).*/\1/p')" "$wtp"
|
|
36
|
+
t "on the worktree's branch" "$(printf '%s' "$out" | sed -n 's/.*branch=\([^ ]*\).*/\1/p')" "task/1-x"
|
|
37
|
+
t "with the caller's arguments" "$(printf '%s' "$out" | sed -n 's/.*args=//p')" "--dry-run a summary"
|
|
38
|
+
|
|
39
|
+
[ "$fail" -eq 0 ] && echo "contribute-root: all passed" || echo "contribute-root: FAILURES"
|
|
40
|
+
exit "$fail"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# contribute-root.sh — which cckit checkout `cckit contribute` acts on (#368).
|
|
4
|
+
#
|
|
5
|
+
# contribute_root <dir> <installed-root> print the checkout to contribute from
|
|
6
|
+
#
|
|
7
|
+
# The cckit checkout that contains <dir> wins: a worktree (where the rules say work happens) or any
|
|
8
|
+
# other clone. "A cckit checkout" = a git toplevel carrying bin/cckit and scripts/contribute.sh.
|
|
9
|
+
# Otherwise the installed checkout <installed-root> is used, as before. Before #368 it was always
|
|
10
|
+
# the installed checkout, so contribute ran the gate and opened the PR for whatever branch that
|
|
11
|
+
# checkout had, never the worktree the agent was working in.
|
|
12
|
+
# errors: pure — prints a path, rc 0; never changes directory
|
|
13
|
+
# bash 3.2 + zsh compatible.
|
|
14
|
+
contribute_root() {
|
|
15
|
+
local dir="${1:-$PWD}" installed="${2:-}" top
|
|
16
|
+
top="$(git -C "$dir" rev-parse --show-toplevel 2>/dev/null)" || top=""
|
|
17
|
+
if [ -n "$top" ] && [ -f "$top/bin/cckit" ] && [ -f "$top/scripts/contribute.sh" ]; then
|
|
18
|
+
printf '%s\n' "$top"
|
|
19
|
+
else
|
|
20
|
+
printf '%s\n' "$installed"
|
|
21
|
+
fi
|
|
22
|
+
}
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
# access here) → cost_source="list-price". bash 3.2 compatible. Requires: git, jq.
|
|
15
15
|
# errors: best-effort — local telemetry must never break the op it measures
|
|
16
16
|
|
|
17
|
+
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
18
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
19
|
+
_ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
|
|
20
|
+
# shellcheck source=/dev/null
|
|
21
|
+
[ -f "$_ghr_lib" ] && . "$_ghr_lib"
|
|
22
|
+
unset _ghr_lib
|
|
23
|
+
fi
|
|
24
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
25
|
+
|
|
17
26
|
# Opus 4.8 list price, USD per 1M tokens (correct as of 2026-06; update when prices change).
|
|
18
27
|
_EM_PRICE_IN=5.00; _EM_PRICE_OUT=25.00; _EM_PRICE_CACHE_READ=0.50; _EM_PRICE_CACHE_WRITE=6.25
|
|
19
28
|
|
|
@@ -43,8 +52,11 @@ estimate_effort() {
|
|
|
43
52
|
command -v jq >/dev/null 2>&1 || return 0
|
|
44
53
|
|
|
45
54
|
repo="${EFFORT_REPO:-${KIT_REPO:-}}"
|
|
55
|
+
if cckit_gh_rest; then subs="$(gh_rest_sub_issue_numbers "$repo" "$num" 2>/dev/null | grep -c .)"
|
|
56
|
+
else
|
|
46
57
|
subs="$(gh api graphql -f query='query($o:String!,$r:String!,$n:Int!){repository(owner:$o,name:$r){issue(number:$n){subIssues(first:50){totalCount}}}}' \
|
|
47
58
|
-F o="${repo%/*}" -F r="${repo#*/}" -F n="$num" --jq '.data.repository.issue.subIssues.totalCount' 2>/dev/null)"
|
|
59
|
+
fi
|
|
48
60
|
[[ "$subs" =~ ^[0-9]+$ ]] || subs=1; [[ "$subs" -lt 1 ]] && subs=1
|
|
49
61
|
|
|
50
62
|
cpl="$(jq -r '.model.cost_per_changed_line_usd // .model.cost_per_changed_line // 0.21' "$est")"
|
|
@@ -247,7 +259,8 @@ _em_judge_goal() {
|
|
|
247
259
|
local num="$1" repo body
|
|
248
260
|
command -v gh >/dev/null 2>&1 || { printf ''; return 0; }
|
|
249
261
|
repo="${EFFORT_REPO:-${KIT_REPO:-}}"
|
|
250
|
-
body="$(gh
|
|
262
|
+
if cckit_gh_rest; then body="$(gh api "repos/$repo/issues/$num" --jq '.body // ""' 2>/dev/null)" || { printf ''; return 0; }
|
|
263
|
+
else body="$(gh issue view "$num" --repo "$repo" --json body --jq '.body' 2>/dev/null)" || { printf ''; return 0; }; fi
|
|
251
264
|
[[ -n "$body" ]] || { printf ''; return 0; }
|
|
252
265
|
# Extract the lines after "## Goal" up to the next "## " heading.
|
|
253
266
|
printf '%s\n' "$body" | awk '
|
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
6
6
|
set -u
|
|
7
7
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
8
|
+
# Sealed from the caller's KIT_*/CCKIT_*/EFFORT_* (#369): this suite builds its own fixture.
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
. "$ROOT/scripts/lib/test-env.sh" && test_env_seal
|
|
8
11
|
LIB="$ROOT/scripts/lib"
|
|
12
|
+
SCRIPTS="$ROOT/scripts"
|
|
9
13
|
fail=0
|
|
10
14
|
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
11
15
|
tc() { if grep -qE "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in gh log)"; fail=1; fi; }
|
|
@@ -24,8 +28,12 @@ case "$1 $2" in
|
|
|
24
28
|
"issue create") n=$(( $(cat "$GH_N" 2>/dev/null || echo 0) + 1 )); echo "$n" > "$GH_N"
|
|
25
29
|
echo "https://github.com/o/r/issues/$n" ;;
|
|
26
30
|
"issue edit"|"issue close"|"pr merge") exit 0 ;;
|
|
27
|
-
"issue view")
|
|
31
|
+
"issue view") case "$*" in # effort_pr reads title+labels+milestone
|
|
32
|
+
*labels,milestone*) echo '{"title":"[Effort] 99 · demo effort","labels":[{"name":"role:tech-lead"},{"name":"kind:task"}],"milestone":{"title":"M1"}}' ;;
|
|
33
|
+
*) echo "[Effort] 99 · demo effort" ;; # --json title -q .title
|
|
34
|
+
esac ;;
|
|
28
35
|
"pr create") echo "https://github.com/o/r/pull/7" ;;
|
|
36
|
+
"pr view") echo "${GH_MERGEABLE:-MERGEABLE}" ;; # --json mergeable (#394)
|
|
29
37
|
"pr diff") # a merged sub PR's diff (wave-style close, #164): one kit-managed + one app file
|
|
30
38
|
printf 'diff --git a/.claude/skills/demo.md b/.claude/skills/demo.md\n+kit\ndiff --git a/src/app.ts b/src/app.ts\n+app\n' ;;
|
|
31
39
|
"api "*|"api")
|
|
@@ -92,8 +100,22 @@ t "effort_start bootstrapped the worktree (.env.local copied)" \
|
|
|
92
100
|
# move onto the effort branch (its worktree) for pr/close
|
|
93
101
|
cd "$tmp/work/.claude/worktrees/effort+99-demo"
|
|
94
102
|
: > "$GH_LOG"
|
|
95
|
-
effort_pr 99 >/dev/null 2>&1
|
|
103
|
+
effort_pr 99 --summary "SUMMARY-MARKER" --for-agents "AGENTS-MARKER" >/dev/null 2>&1
|
|
96
104
|
tc "$GH_LOG" 'pr create .*--base main --head effort/99-demo' "effort_pr opens effort/99 → main"
|
|
105
|
+
# #363: parity with the kit-effort-pr skill — the verb is the one implementation.
|
|
106
|
+
tc "$GH_LOG" 'pr create .*--title \[#99\] demo effort' "effort_pr titles with the [#N] id + parent name"
|
|
107
|
+
tc "$GH_LOG" '[-]-label role:tech-lead,kind:task' "effort_pr inherits the parent's labels"
|
|
108
|
+
tc "$GH_LOG" '[-]-milestone M1' "effort_pr inherits the parent's milestone"
|
|
109
|
+
tc "$GH_LOG" 'SUMMARY-MARKER' "effort_pr puts --summary in the body"
|
|
110
|
+
tc "$GH_LOG" 'AGENTS-MARKER' "effort_pr puts --for-agents in the body"
|
|
111
|
+
tc "$GH_LOG" '^Closes #99$' "effort_pr body closes the parent"
|
|
112
|
+
t "effort_pr never commits an untracked .env.local" "$(git ls-files .env.local)" ""
|
|
113
|
+
: > "$GH_LOG"
|
|
114
|
+
effort_pr 99 --title "feat(x): a conventional title" >/dev/null 2>&1 && rc=0 || rc=1
|
|
115
|
+
t "effort_pr refuses a --title without the [#N] id" "$rc" "1"
|
|
116
|
+
t "effort_pr opened nothing on a bad --title" "$(grep -c 'pr create' "$GH_LOG")" "0"
|
|
117
|
+
effort_pr 99 --title "feat(x): a conventional title [#99]" >/dev/null 2>&1
|
|
118
|
+
tc "$GH_LOG" 'pr create .*--title feat\(x\): a conventional title \[#99\]' "effort_pr honours --title"
|
|
97
119
|
|
|
98
120
|
# ── effort_close #120: refuse-squash-without-trace backstop ────────────────────────────────────
|
|
99
121
|
# With NO commits on the effort branch, effort_snapshot_subs captures no trace → close must refuse
|
|
@@ -114,6 +136,17 @@ echo "kit-managed" > .claude/skills/demo.md # a kit-managed path → the drift
|
|
|
114
136
|
git -c user.email=t@t -c user.name=t add file.txt .claude/skills/demo.md
|
|
115
137
|
git -c user.email=t@t -c user.name=t commit -q -m "feat: do the thing (#101)"
|
|
116
138
|
|
|
139
|
+
# ── effort_close #394: a CONFLICTING PR is refused before the metrics capture writes a row ──────
|
|
140
|
+
: > "$GH_LOG"
|
|
141
|
+
close_out="$(GH_MERGEABLE=CONFLICTING effort_close 99 2>&1)"; rc=$?
|
|
142
|
+
t "effort_close refuses a conflicting PR (rc 1)" "$rc" "1"
|
|
143
|
+
t "effort_close did NOT merge a conflicting PR" "$(grep -c 'pr merge' "$GH_LOG")" "0"
|
|
144
|
+
case "$close_out" in
|
|
145
|
+
*"metrics:"*) echo "FAIL: metrics captured before the conflict refusal"; fail=1 ;;
|
|
146
|
+
*"nothing was written"*) echo "ok: conflict refused before the metrics capture" ;;
|
|
147
|
+
*) echo "FAIL: conflict refusal message: $close_out"; fail=1 ;;
|
|
148
|
+
esac
|
|
149
|
+
|
|
117
150
|
# #148: the VERB sets board Status=Done (guarded). Stub the board helpers + captured ids in-shell —
|
|
118
151
|
# _eo_source_board must see them and skip sourcing the real gh-project.sh.
|
|
119
152
|
BOARD_LOG="$tmp/board.log"; : > "$BOARD_LOG"
|
|
@@ -147,6 +180,7 @@ t "effort_close GC deleted the local branch" \
|
|
|
147
180
|
cat > "$stub/khook" <<'SH'
|
|
148
181
|
#!/usr/bin/env bash
|
|
149
182
|
printf 'ingested %s\n' "$1" > "$KHOOK_MARKER"
|
|
183
|
+
pwd -P > "$KHOOK_MARKER.cwd" 2>/dev/null || echo "NO-CWD" > "$KHOOK_MARKER.cwd"
|
|
150
184
|
SH
|
|
151
185
|
chmod +x "$stub/khook"
|
|
152
186
|
start_out="$(effort_start 88 forced 2>/dev/null)"
|
|
@@ -156,6 +190,9 @@ forced_out="$(KHOOK_MARKER="$tmp/khook.out" KIT_EFFORT_KNOWLEDGE_HOOK="$stub/kho
|
|
|
156
190
|
cd "$tmp/work"
|
|
157
191
|
tc "$GH_LOG" 'pr merge effort/88-forced .*--squash' "KIT_FORCE=1 close merges despite no trace"
|
|
158
192
|
t "knowledge-ingest hook ran with the effort number" "$(cat "$tmp/khook.out" 2>/dev/null)" "ingested 88"
|
|
193
|
+
# #371: the close GCs the worktree it was run from; the hook must run in the main checkout, not in
|
|
194
|
+
# that deleted directory (where every relative path and git call fails).
|
|
195
|
+
t "knowledge-ingest hook runs in the main checkout" "$(cat "$tmp/khook.out.cwd" 2>/dev/null)" "$(cd "$tmp/work" && pwd -P)"
|
|
159
196
|
# #148: no kit-managed file touched → the drift check stays silent
|
|
160
197
|
case "$forced_out" in *"kit-sync"*) echo "FAIL: kit-sync warning fired with no kit-managed change"; fail=1 ;; *) echo "ok: drift check silent when no kit-managed file changed" ;; esac
|
|
161
198
|
|
|
@@ -546,5 +583,20 @@ t "wip: the plain-task start path is not gated" \
|
|
|
546
583
|
|
|
547
584
|
cd "$tmp/work" || exit 1
|
|
548
585
|
|
|
586
|
+
# 15. the label `effort_plan` READS is a label `effort_new` WRITES.
|
|
587
|
+
# These drifted apart silently: effort-plan.sh queried `--label effort`, effort_new applied
|
|
588
|
+
# ctx/kind/priority/role/flow/par/slug and never `effort`, and setup-labels.sh never created
|
|
589
|
+
# it. `cckit effort plan` therefore answered "no open efforts found" for every effort ever
|
|
590
|
+
# made, in every repo, with no error anywhere. A static check because the failure mode is
|
|
591
|
+
# silence — there is nothing at runtime to notice.
|
|
592
|
+
plan_label="$(sed -n 's/.*gh issue list [^|]*--label \([a-z][a-z-]*\).*/\1/p' "$LIB/effort-plan.sh" | head -1)"
|
|
593
|
+
t "plan queries a label at all" "${plan_label:-MISSING}" "effort"
|
|
594
|
+
t "effort_new applies the label plan queries" \
|
|
595
|
+
"$(grep -c "labels=\"$plan_label," "$LIB/effort-ops.sh" | tr -d ' ')" "1"
|
|
596
|
+
t "effort_new ensures the label exists before using it" \
|
|
597
|
+
"$(grep -c "_eff_ensure_label \"$plan_label\"" "$LIB/effort-ops.sh" | tr -d ' ')" "1"
|
|
598
|
+
t "setup-labels provisions the label plan queries" \
|
|
599
|
+
"$(grep -c "ensure_label \"$plan_label\"" "$SCRIPTS/setup-labels.sh" | tr -d ' ')" "1"
|
|
600
|
+
|
|
549
601
|
[ "$fail" -eq 0 ] && echo "ALL OK (effort-ops)" || echo "effort-ops: FAILURES"
|
|
550
602
|
exit "$fail"
|