@jeiemgi/cckit 0.6.1 → 0.7.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 +34 -3
- package/README.md +86 -5
- package/bin/cckit +72 -3
- package/cckit.config.json +6 -1
- package/kit.config.schema.json +26 -1
- package/package.json +1 -1
- package/profiles/automation.json +2 -1
- package/profiles/content.json +2 -1
- package/profiles/minimal.json +2 -1
- package/profiles/research.json +2 -1
- package/profiles/software.json +2 -1
- package/scripts/init.sh +31 -1
- package/scripts/lib/board-view-test.sh +1 -0
- package/scripts/lib/board-view.sh +1 -0
- package/scripts/lib/captain-test.sh +62 -0
- package/scripts/lib/captain.sh +105 -17
- package/scripts/lib/cckit-output.sh +1 -0
- package/scripts/lib/commitlint.sh +1 -0
- package/scripts/lib/config-path-test.sh +1 -0
- package/scripts/lib/config-path.sh +1 -0
- package/scripts/lib/copilot-test.sh +1 -0
- package/scripts/lib/copilot.sh +1 -0
- package/scripts/lib/effort-dispatch-test.sh +10 -0
- package/scripts/lib/effort-flows-test.sh +1 -0
- package/scripts/lib/effort-metrics-test.sh +1 -0
- package/scripts/lib/effort-metrics.sh +1 -0
- package/scripts/lib/effort-ops-test.sh +360 -0
- package/scripts/lib/effort-ops.sh +372 -16
- package/scripts/lib/effort-parity-test.sh +1 -0
- package/scripts/lib/effort-plan.sh +1 -0
- package/scripts/lib/effort-slug-test.sh +32 -0
- package/scripts/lib/effort-slug.sh +72 -8
- package/scripts/lib/effort.sh +1 -0
- package/scripts/lib/engine-adapter.sh +1 -0
- package/scripts/lib/errors-header-test.sh +86 -0
- package/scripts/lib/gh-log.sh +1 -0
- package/scripts/lib/gh-project-test.sh +1 -0
- package/scripts/lib/gh-project.sh +1 -0
- package/scripts/lib/git-remote-test.sh +1 -0
- package/scripts/lib/git-remote.sh +1 -0
- package/scripts/lib/handoff.sh +23 -2
- package/scripts/lib/kit-brief-test.sh +292 -0
- package/scripts/lib/kit-brief.sh +376 -0
- package/scripts/lib/kit-cli-test.sh +1 -0
- package/scripts/lib/kit-cli.sh +1 -0
- package/scripts/lib/kit-config-resolve.sh +1 -0
- package/scripts/lib/kit-config-test.sh +14 -0
- package/scripts/lib/kit-config.sh +7 -0
- package/scripts/lib/kit-engine-test.sh +1 -0
- package/scripts/lib/kit-events.sh +1 -0
- package/scripts/lib/kit-gc-test.sh +125 -0
- package/scripts/lib/kit-gc.sh +193 -5
- package/scripts/lib/kit-interview-test.sh +1 -0
- package/scripts/lib/kit-interview.sh +1 -0
- package/scripts/lib/kit-lib-test.sh +226 -0
- package/scripts/lib/kit-lib.sh +308 -0
- package/scripts/lib/kit-local.sh +1 -0
- package/scripts/lib/kit-manifest.sh +1 -0
- package/scripts/lib/kit-mode-test.sh +1 -0
- package/scripts/lib/kit-mode.sh +1 -0
- package/scripts/lib/kit-msg-test.sh +1 -0
- package/scripts/lib/kit-msg.sh +1 -0
- package/scripts/lib/kit-operate.sh +1 -0
- package/scripts/lib/kit-profile-test.sh +1 -0
- package/scripts/lib/kit-profile.sh +1 -0
- package/scripts/lib/kit-state-test.sh +89 -0
- package/scripts/lib/kit-state.sh +61 -0
- package/scripts/lib/kit-status-test.sh +233 -0
- package/scripts/lib/kit-status.sh +415 -0
- package/scripts/lib/kit-task-ops-test.sh +1 -0
- package/scripts/lib/kit-task-ops.sh +1 -0
- package/scripts/lib/next.sh +1 -0
- package/scripts/lib/plan-machine-test.sh +54 -0
- package/scripts/lib/plan-machine.sh +86 -25
- package/scripts/lib/plan-next-test.sh +1 -0
- package/scripts/lib/plan-next.sh +1 -0
- package/scripts/lib/pr-evidence-test.sh +259 -0
- package/scripts/lib/pr-evidence.sh +220 -35
- package/scripts/lib/project-scan.sh +1 -0
- package/scripts/lib/react-detect.sh +1 -0
- package/scripts/lib/render-test.sh +1 -0
- package/scripts/lib/render.sh +1 -0
- package/scripts/lib/role-identity.sh +1 -0
- package/scripts/lib/secret-guard.sh +21 -1
- package/scripts/lib/toon.sh +1 -0
- package/scripts/lib/ui.sh +1 -0
- package/scripts/lib/version-bump-test.sh +1 -0
- package/scripts/lib/version-bump.sh +1 -0
- package/scripts/lib/worktree-bootstrap-test.sh +220 -0
- package/scripts/lib/worktree-issue-test.sh +15 -1
- package/scripts/lib/worktree-issue.sh +23 -8
- package/scripts/lib/worktree-start.sh +191 -7
- package/scripts/lib/zsh-safety-test.sh +10 -0
- package/scripts/portable-test.sh +13 -2
- package/scripts/self-install-test.sh +282 -0
- package/scripts/setup-labels.sh +1 -0
- package/scripts/status.sh +25 -10
- package/skills/kit-cleanup/SKILL.md +83 -0
- package/skills/kit-effort-close/SKILL.md +3 -0
- package/skills/kit-effort-new/SKILL.md +7 -0
- package/skills/kit-effort-start/SKILL.md +39 -4
- package/skills/kit-gc/SKILL.md +19 -0
- package/skills/kit-next/SKILL.md +5 -0
- package/skills/kit-status/SKILL.md +92 -0
- package/skills/kit-task-start/SKILL.md +7 -1
- package/templates/rules/branch-naming.md +20 -1
- package/templates/rules/communication-style.md +8 -0
- package/templates/rules/delegation-brief.md +38 -4
- package/templates/rules/effort-model.md +47 -4
- package/templates/rules/naming-and-ids.md +199 -0
- package/templates/rules/task-management.md +1 -1
- package/templates/skills/concrete/SKILL.md +117 -0
- package/templates/skills/karpathy-guidelines/SKILL.md +1 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# shellcheck shell=bash
|
|
3
3
|
# effort-ops-test.sh — covers the effort lifecycle ops (#48). Hermetic: stubs gh (no network/auth)
|
|
4
4
|
# and uses a throwaway git repo with a bare remote. Run: bash scripts/lib/effort-ops-test.sh
|
|
5
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
5
6
|
set -u
|
|
6
7
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
7
8
|
LIB="$ROOT/scripts/lib"
|
|
@@ -186,5 +187,364 @@ tc "$BOARD_LOG" 'ITEM-301 SF1 OPT_DONE' "wave close sets board Done for sub #301
|
|
|
186
187
|
tc "$BOARD_LOG" 'ITEM-302 SF1 OPT_DONE' "wave close sets board Done for sub #302"
|
|
187
188
|
case "$close_out" in *"kit-sync"*".claude/skills/demo.md"*) echo "ok: wave drift check reads the merged PR diffs" ;; *) echo "FAIL: no kit-sync warning in wave close output"; fail=1 ;; esac
|
|
188
189
|
|
|
190
|
+
# ── #243 · _eff_relations_add — the ONE `Depends on` formatter (pure: no gh, no network) ──────────
|
|
191
|
+
rel_body="$(printf '## Verification\nV\n')"
|
|
192
|
+
rel1="$(_eff_relations_add "$rel_body" 5)"
|
|
193
|
+
t "relations_add appends a ## Relations section" "$rel1" "$(printf '## Verification\nV\n\n## Relations\n- Depends on #5')"
|
|
194
|
+
t "relations_add is idempotent (same line twice)" "$(_eff_relations_add "$rel1" 5)" "$rel1"
|
|
195
|
+
t "relations_add appends into an existing section" "$(_eff_relations_add "$rel1" 9)" \
|
|
196
|
+
"$(printf '## Verification\nV\n\n## Relations\n- Depends on #5\n- Depends on #9')"
|
|
197
|
+
t "relations_add on an empty body has no leading blank" "$(_eff_relations_add "" 5)" \
|
|
198
|
+
"$(printf '## Relations\n- Depends on #5')"
|
|
199
|
+
# a ## Relations section in the MIDDLE of a body keeps its place; the line lands at the section end
|
|
200
|
+
t "relations_add respects a mid-body section" \
|
|
201
|
+
"$(_eff_relations_add "$(printf '## Relations\n- Depends on #1\n\n## Verification\nV\n')" 2)" \
|
|
202
|
+
"$(printf '## Relations\n- Depends on #1\n- Depends on #2\n\n## Verification\nV')"
|
|
203
|
+
|
|
204
|
+
# ── #243 · effort_new --depends-on emits a WELL-FORMED Relations block ────────────────────────────
|
|
205
|
+
# It used to be built inline with `$( … )`, which eats trailing newlines — the section shipped as the
|
|
206
|
+
# single mangled line `## Relations- Depends on #4- Depends on #9`. Both now go through the formatter.
|
|
207
|
+
: > "$GH_LOG"; printf '0' > "$GH_N"
|
|
208
|
+
effort_new --depends-on "#4,9" "depends on effort" >/dev/null 2>&1
|
|
209
|
+
tc "$GH_LOG" '^## Relations$' "--depends-on writes ## Relations on its own line"
|
|
210
|
+
tc "$GH_LOG" '^- Depends on #4$' "--depends-on writes the first dep on its own line"
|
|
211
|
+
tc "$GH_LOG" '^- Depends on #9( |$)' "--depends-on writes the second dep on its own line"
|
|
212
|
+
t "--depends-on does not mangle the heading" "$(grep -c '## Relations-' "$GH_LOG")" "0"
|
|
213
|
+
|
|
214
|
+
# ── #243 · effort_chain — a linear blocked_by chain, idempotent, cycle-refusing ────────────────────
|
|
215
|
+
# Its own gh stub (prepended to PATH) with real STATE: which issues exist, the blocked_by edge set,
|
|
216
|
+
# and per-issue bodies — so the edges and the body lines can be asserted, not just the call log.
|
|
217
|
+
cstub="$tmp/cbin"; mkdir -p "$cstub"
|
|
218
|
+
export CH_DIR="$tmp/chain"; mkdir -p "$CH_DIR"
|
|
219
|
+
export CH_LOG="$CH_DIR/gh.log" CH_EDGES="$CH_DIR/edges" CH_EXISTS="$CH_DIR/exists"
|
|
220
|
+
printf '501\n502\n503\n504\n601\n' > "$CH_EXISTS" # #999 deliberately absent
|
|
221
|
+
: > "$CH_EDGES"; : > "$CH_LOG"
|
|
222
|
+
for n in 501 502 503 504; do printf '## Goal\ng%s\n\n## Verification\nv\n' "$n" > "$CH_DIR/body.$n"; done
|
|
223
|
+
cat > "$cstub/gh" <<'SH'
|
|
224
|
+
#!/usr/bin/env bash
|
|
225
|
+
# stub gh with state. DB id of issue N is 900000+N (the dependencies API takes the blocker's db id).
|
|
226
|
+
echo "$*" | tr '\n' ' ' >> "$CH_LOG"; echo >> "$CH_LOG"
|
|
227
|
+
_n() { printf '%s' "$1" | sed -nE 's#.*issues/([0-9]+).*#\1#p'; }
|
|
228
|
+
case "$1" in
|
|
229
|
+
issue)
|
|
230
|
+
case "$2" in
|
|
231
|
+
view) cat "$CH_DIR/body.$3" 2>/dev/null; exit 0 ;;
|
|
232
|
+
edit) n="$3"; shift 3
|
|
233
|
+
# CH_FAIL_EDIT=<n> makes the edit fail for that issue — a POST-validation failure, the
|
|
234
|
+
# only way to reach effort_chain's rc=1 path (pre-flight refusals never write at all).
|
|
235
|
+
[ -n "${CH_FAIL_EDIT:-}" ] && [ "$n" = "$CH_FAIL_EDIT" ] && exit 1
|
|
236
|
+
while [ $# -gt 0 ]; do
|
|
237
|
+
[ "$1" = "--body" ] && { printf '%s' "$2" > "$CH_DIR/body.$n"; break; }
|
|
238
|
+
shift
|
|
239
|
+
done
|
|
240
|
+
exit 0 ;;
|
|
241
|
+
*) exit 0 ;;
|
|
242
|
+
esac ;;
|
|
243
|
+
api)
|
|
244
|
+
case "$*" in
|
|
245
|
+
*"--method POST"*"/dependencies/blocked_by"*)
|
|
246
|
+
n="$(_n "$*")"; bid="$(printf '%s' "$*" | sed -nE 's#.*issue_id=([0-9]+).*#\1#p')"
|
|
247
|
+
b=$((bid - 900000))
|
|
248
|
+
grep -qx "$n $b" "$CH_EDGES" && exit 1 # GitHub rejects a duplicate edge
|
|
249
|
+
echo "$n $b" >> "$CH_EDGES"; exit 0 ;;
|
|
250
|
+
*"/dependencies/blocked_by"*)
|
|
251
|
+
awk -v k="$(_n "$*")" '$1==k{print $2}' "$CH_EDGES"; exit 0 ;;
|
|
252
|
+
*".id"*) n="$(_n "$*")"; echo $((900000 + n)); exit 0 ;;
|
|
253
|
+
*".number"*) n="$(_n "$*")"; grep -qx "$n" "$CH_EXISTS" || exit 1; echo "$n"; exit 0 ;;
|
|
254
|
+
*) exit 0 ;;
|
|
255
|
+
esac ;;
|
|
256
|
+
*) exit 0 ;;
|
|
257
|
+
esac
|
|
258
|
+
SH
|
|
259
|
+
chmod +x "$cstub/gh"
|
|
260
|
+
export PATH="$cstub:$PATH"
|
|
261
|
+
edges() { sort "$CH_EDGES" | tr '\n' ';'; }
|
|
262
|
+
|
|
263
|
+
# happy path: 502 blocked_by 501, 503 blocked_by 502, each body records its predecessor
|
|
264
|
+
: > "$CH_LOG"
|
|
265
|
+
effort_chain 501 502 503 >/dev/null 2>&1; rc=$?
|
|
266
|
+
t "chain happy path returns 0" "$rc" "0"
|
|
267
|
+
t "chain sets both blocked_by edges" "$(edges)" "502 501;503 502;"
|
|
268
|
+
tc "$CH_DIR/body.502" '^- Depends on #501$' "chain records 'Depends on #501' in #502"
|
|
269
|
+
tc "$CH_DIR/body.503" '^- Depends on #502$' "chain records 'Depends on #502' in #503"
|
|
270
|
+
tc "$CH_DIR/body.502" '^## Relations$' "chain adds a ## Relations section"
|
|
271
|
+
t "chain leaves the head issue's body alone" "$(grep -c 'Depends on' "$CH_DIR/body.501")" "0"
|
|
272
|
+
|
|
273
|
+
# idempotency: a second identical run writes NOTHING — no POST, no body edit, no duplicate line
|
|
274
|
+
: > "$CH_LOG"
|
|
275
|
+
effort_chain 501 502 503 >/dev/null 2>&1; rc=$?
|
|
276
|
+
t "chain re-run returns 0" "$rc" "0"
|
|
277
|
+
t "chain re-run sets no new edge" "$(edges)" "502 501;503 502;"
|
|
278
|
+
t "chain re-run POSTs no dependency" "$(grep -c 'method POST' "$CH_LOG")" "0"
|
|
279
|
+
t "chain re-run edits no body" "$(grep -c 'issue edit' "$CH_LOG")" "0"
|
|
280
|
+
t "chain re-run leaves ONE Depends on line" "$(grep -c 'Depends on #501' "$CH_DIR/body.502")" "1"
|
|
281
|
+
# a `#`-prefixed number is the same issue
|
|
282
|
+
: > "$CH_LOG"
|
|
283
|
+
effort_chain '#501' '#502' >/dev/null 2>&1
|
|
284
|
+
t "chain accepts #-prefixed numbers" "$(grep -c 'method POST' "$CH_LOG")" "0"
|
|
285
|
+
|
|
286
|
+
# arity: fewer than two numbers is a usage error and writes nothing
|
|
287
|
+
: > "$CH_LOG"
|
|
288
|
+
effort_chain 501 >/dev/null 2>&1 && rc=0 || rc=1
|
|
289
|
+
t "chain refuses a single issue (rc 1)" "$rc" "1"
|
|
290
|
+
effort_chain >/dev/null 2>&1 && rc=0 || rc=1
|
|
291
|
+
t "chain refuses zero issues (rc 1)" "$rc" "1"
|
|
292
|
+
t "chain arity refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
|
|
293
|
+
|
|
294
|
+
# a non-numeric argument is rejected up front
|
|
295
|
+
: > "$CH_LOG"
|
|
296
|
+
effort_chain 501 not-a-number >/dev/null 2>&1 && rc=0 || rc=1
|
|
297
|
+
t "chain refuses a non-numeric arg (rc 1)" "$rc" "1"
|
|
298
|
+
t "chain non-numeric refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
|
|
299
|
+
|
|
300
|
+
# a nonexistent issue aborts the WHOLE chain — the earlier, valid link is not written either
|
|
301
|
+
: > "$CH_LOG"
|
|
302
|
+
effort_chain 504 999 >/dev/null 2>&1 && rc=0 || rc=1
|
|
303
|
+
t "chain refuses a nonexistent issue (rc 1)" "$rc" "1"
|
|
304
|
+
t "chain missing-issue refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
|
|
305
|
+
t "chain missing-issue refusal adds no edge" "$(edges)" "502 501;503 502;"
|
|
306
|
+
|
|
307
|
+
# a repeated number is a cycle (`chain 1 2 1`) — refused whole
|
|
308
|
+
: > "$CH_LOG"
|
|
309
|
+
effort_chain 504 501 504 >/dev/null 2>&1 && rc=0 || rc=1
|
|
310
|
+
t "chain refuses a repeated number (rc 1)" "$rc" "1"
|
|
311
|
+
t "chain repeat refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
|
|
312
|
+
|
|
313
|
+
# a cycle through edges GitHub ALREADY holds: 503 → 502 → 501 exists, so 501 blocked_by 503 loops
|
|
314
|
+
: > "$CH_LOG"
|
|
315
|
+
effort_chain 503 501 >/dev/null 2>&1 && rc=0 || rc=1
|
|
316
|
+
t "chain refuses a transitive cycle (rc 1)" "$rc" "1"
|
|
317
|
+
t "chain cycle refusal writes nothing" "$(grep -cE 'method POST|issue edit' "$CH_LOG")" "0"
|
|
318
|
+
t "chain cycle refusal adds no edge" "$(edges)" "502 501;503 502;"
|
|
319
|
+
|
|
320
|
+
# an issue already blocked by something ELSE keeps that blocker — chain only ever ADDS its edge
|
|
321
|
+
echo "504 601" >> "$CH_EDGES"
|
|
322
|
+
: > "$CH_LOG"
|
|
323
|
+
effort_chain 501 504 >/dev/null 2>&1; rc=$?
|
|
324
|
+
t "chain wires an already-blocked issue (rc 0)" "$rc" "0"
|
|
325
|
+
t "chain preserves the pre-existing blocker" "$(edges)" "502 501;503 502;504 501;504 601;"
|
|
326
|
+
tc "$CH_DIR/body.504" '^- Depends on #501$' "chain records its own dep on an already-blocked issue"
|
|
327
|
+
|
|
328
|
+
# The summary banner must agree with rc. A ✓ over a nonzero exit reports a chain that is not fully
|
|
329
|
+
# wired, so the failure is invisible to anything reading stderr rather than $?.
|
|
330
|
+
: > "$CH_LOG"
|
|
331
|
+
out="$(effort_chain 501 502 2>&1)"; rc=$?
|
|
332
|
+
t "chain banner: rc 0 on a clean run" "$rc" "0"
|
|
333
|
+
case "$out" in *"✓ chain"*) t "chain banner: ✓ on success" ok ok ;; *) t "chain banner: ✓ on success" "$out" "✓ chain" ;; esac
|
|
334
|
+
|
|
335
|
+
# A POST-validation failure: #601 exists and passes pre-flight, but its body edit fails. This is the
|
|
336
|
+
# only path that reaches rc=1 with writes already attempted — every pre-flight refusal returns early.
|
|
337
|
+
: > "$CH_LOG"
|
|
338
|
+
out="$(CH_FAIL_EDIT=601 effort_chain 502 601 2>&1)"; rc=$?
|
|
339
|
+
t "chain returns rc 1 when a body edit fails" "$rc" "1"
|
|
340
|
+
case "$out" in
|
|
341
|
+
*"✓ chain"*) t "chain banner: no ✓ when a link failed" "$out" "(no '✓ chain')" ;;
|
|
342
|
+
*"✗ chain"*) t "chain banner: ✗ when a link failed" "ok" "ok" ;;
|
|
343
|
+
*) t "chain banner: ✗ when a link failed" "$out" "✗ chain" ;;
|
|
344
|
+
esac
|
|
345
|
+
|
|
346
|
+
# ── #244 · effort_start enforces a WIP limit ──────────────────────────────────────────────────────
|
|
347
|
+
# In progress = an `effort/<N>-<slug>` ref exists (local head OR remote-tracking) — the same scan the
|
|
348
|
+
# slug resolver uses. Its own throwaway repo + bare remote so the branch inventory is exactly what
|
|
349
|
+
# each case sets up, and its own gh log so "a refusal writes NOTHING" can be asserted against zero
|
|
350
|
+
# gh calls as well as zero refs.
|
|
351
|
+
wtmp="$tmp/wip"; mkdir -p "$wtmp"
|
|
352
|
+
( cd "$wtmp" && git init -q --bare remote.git )
|
|
353
|
+
( cd "$wtmp" && git clone -q remote.git work \
|
|
354
|
+
&& cd work && git -c user.email=t@t -c user.name=t commit -q --allow-empty -m init \
|
|
355
|
+
&& git push -q origin HEAD:main )
|
|
356
|
+
cd "$wtmp/work" || exit 1
|
|
357
|
+
unset EFFORT_WIP_LIMIT KIT_EFFORT_WIP_LIMIT KIT_FORCE 2>/dev/null || true
|
|
358
|
+
# `gh` on PATH here is the chain stub, which logs to $CH_LOG — that is the log a refusal must leave
|
|
359
|
+
# empty, so the "writes nothing" assertions read it rather than $GH_LOG.
|
|
360
|
+
|
|
361
|
+
wip_started() { git show-ref --verify --quiet "refs/heads/effort/$1" && echo yes || echo no; }
|
|
362
|
+
wip_reset() { git checkout -q main 2>/dev/null; \
|
|
363
|
+
for b in $(git for-each-ref --format='%(refname:short)' 'refs/heads/effort/*'); do
|
|
364
|
+
git worktree remove --force ".claude/worktrees/effort+${b#effort/}" >/dev/null 2>&1
|
|
365
|
+
git branch -D "$b" >/dev/null 2>&1
|
|
366
|
+
done; git worktree prune >/dev/null 2>&1; }
|
|
367
|
+
|
|
368
|
+
# 1. under the limit → starts. Nothing in progress, default limit 2.
|
|
369
|
+
effort_start 701 one >/dev/null 2>&1; rc=$?
|
|
370
|
+
t "wip: under the limit starts (rc 0)" "$rc" "0"
|
|
371
|
+
t "wip: under the limit created the branch" "$(wip_started 701-one)" "yes"
|
|
372
|
+
|
|
373
|
+
# 2. the SECOND effort still starts (1 < 2) — the limit is a ceiling, not a one-at-a-time rule.
|
|
374
|
+
effort_start 702 two >/dev/null 2>&1; rc=$?
|
|
375
|
+
t "wip: the second effort starts (rc 0)" "$rc" "0"
|
|
376
|
+
|
|
377
|
+
# 3. AT the limit (2 in progress, limit 2) → refuse. A third would make three.
|
|
378
|
+
: > "$CH_LOG"
|
|
379
|
+
out="$(effort_start 703 three 2>&1)"; rc=$?
|
|
380
|
+
t "wip: at the limit refuses (rc 1)" "$rc" "1"
|
|
381
|
+
case "$out" in *"WIP limit is 2"*) echo "ok: refusal names the limit" ;; *) echo "FAIL: refusal did not name the limit: $out"; fail=1 ;; esac
|
|
382
|
+
case "$out" in *"one #701"*) echo "ok: refusal lists what is in progress" ;; *) echo "FAIL: refusal did not list #701: $out"; fail=1 ;; esac
|
|
383
|
+
case "$out" in *"--force"*) echo "ok: refusal says how to override" ;; *) echo "FAIL: refusal did not mention --force: $out"; fail=1 ;; esac
|
|
384
|
+
case "$out" in *"effort.wipLimit"*) echo "ok: refusal names the config key" ;; *) echo "FAIL: refusal did not name effort.wipLimit: $out"; fail=1 ;; esac
|
|
385
|
+
# …and the refusal WRITES nothing: no branch, no worktree dir, no board change.
|
|
386
|
+
t "wip: refusal created no branch" "$(wip_started 703-three)" "no"
|
|
387
|
+
t "wip: refusal created no worktree" "$(ls -d .claude/worktrees/effort+703-three 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
388
|
+
# For a NUMERIC argument the refusal also makes no gh call — the number is passed through, so no
|
|
389
|
+
# resolution happens. This is NOT the guarantee for a <slug> argument (see the next assertion), and
|
|
390
|
+
# the docs claim only "no branch, no worktree, no board change" (#244 review).
|
|
391
|
+
t "wip: a numeric-arg refusal made no gh call" "$(grep -c . "$CH_LOG" | tr -d ' ')" "0"
|
|
392
|
+
# A SLUG argument is resolved BEFORE the gate, and the resolver falls through to `gh issue list`
|
|
393
|
+
# when no branch matches — so a refusal on that path can read from GitHub. Asserted on the resolver
|
|
394
|
+
# itself, which is the mechanism the narrowed doc claim refers to.
|
|
395
|
+
: > "$CH_LOG"
|
|
396
|
+
effort_slug_resolve no-such-effort-anywhere >/dev/null 2>&1 || true
|
|
397
|
+
t "wip: resolving a slug with no branch DOES call gh" \
|
|
398
|
+
"$(grep -c 'issue list' "$CH_LOG" | tr -d ' ')" "2"
|
|
399
|
+
|
|
400
|
+
# 4. --force starts anyway (and says so).
|
|
401
|
+
out="$(effort_start --force 703 three 2>&1)"; rc=$?
|
|
402
|
+
t "wip: --force starts anyway (rc 0)" "$rc" "0"
|
|
403
|
+
t "wip: --force created the branch" "$(wip_started 703-three)" "yes"
|
|
404
|
+
case "$out" in *"anyway"*) echo "ok: --force announces the override" ;; *) echo "FAIL: --force said nothing: $out"; fail=1 ;; esac
|
|
405
|
+
|
|
406
|
+
# 5. ABOVE the limit (3 in progress, limit 2) still refuses.
|
|
407
|
+
effort_start 704 four >/dev/null 2>&1; rc=$?
|
|
408
|
+
t "wip: above the limit refuses (rc 1)" "$rc" "1"
|
|
409
|
+
t "wip: above the limit created no branch" "$(wip_started 704-four)" "no"
|
|
410
|
+
|
|
411
|
+
# 6. KIT_FORCE=1 — the same escape hatch effort_close uses — starts anyway.
|
|
412
|
+
KIT_FORCE=1 effort_start 704 four >/dev/null 2>&1; rc=$?
|
|
413
|
+
t "wip: KIT_FORCE=1 starts anyway (rc 0)" "$rc" "0"
|
|
414
|
+
t "wip: KIT_FORCE=1 created the branch" "$(wip_started 704-four)" "yes"
|
|
415
|
+
|
|
416
|
+
# 7. re-running start on an ALREADY in-progress effort is never gated — it adds no WIP, so
|
|
417
|
+
# `effort start` stays safe to re-run even when the set is at or over the limit.
|
|
418
|
+
out="$(effort_start 701 one 2>&1)"; rc=$?
|
|
419
|
+
t "wip: re-starting an in-progress effort is allowed (rc 0)" "$rc" "0"
|
|
420
|
+
case "$out" in *"WIP limit"*) echo "FAIL: re-start hit the WIP gate: $out"; fail=1 ;; *) echo "ok: re-start bypasses the gate" ;; esac
|
|
421
|
+
|
|
422
|
+
# 8. a REMOTE-only effort branch counts as in progress (another machine owns it).
|
|
423
|
+
wip_reset
|
|
424
|
+
git push -q origin main:refs/heads/effort/705-remote-only
|
|
425
|
+
git fetch -q origin
|
|
426
|
+
t "wip: only a remote effort ref is present" "$(effort_wip_rows | tr '\t' '-' | tr '\n' ' ')" "705-remote-only "
|
|
427
|
+
EFFORT_WIP_LIMIT=1 effort_start 706 local-one >/dev/null 2>&1; rc=$?
|
|
428
|
+
t "wip: a remote-only effort branch counts toward the limit (rc 1)" "$rc" "1"
|
|
429
|
+
git push -q origin :refs/heads/effort/705-remote-only; git fetch -q --prune origin
|
|
430
|
+
|
|
431
|
+
# ── #244 review · the cached refs/remotes is wrong in BOTH directions ─────────────────────────────
|
|
432
|
+
# effort_wip_rows reads origin with `git ls-remote`, not refs/remotes, because the cache under- and
|
|
433
|
+
# over-counts and a gate is wrong with either. Both directions are reproduced here against the real
|
|
434
|
+
# bare remote, with the local cache deliberately left un-fetched / un-pruned.
|
|
435
|
+
|
|
436
|
+
# 8a. OVER-count: a branch DELETED on origin lingers in refs/remotes until a prune. The stale ref
|
|
437
|
+
# must not block a start. The delete is written into the bare remote rather than pushed from
|
|
438
|
+
# here as `origin :ref` — a delete-push updates THIS clone's tracking ref, which would hide the
|
|
439
|
+
# staleness under test. Writing the remote is the "another machine deleted it" case.
|
|
440
|
+
wip_reset
|
|
441
|
+
git push -q origin main:refs/heads/effort/720-stale
|
|
442
|
+
git fetch -q origin # cache it
|
|
443
|
+
git --git-dir="$wtmp/remote.git" update-ref -d refs/heads/effort/720-stale
|
|
444
|
+
t "wip: the deleted branch is still in the local cache" \
|
|
445
|
+
"$(git for-each-ref --format='%(refname:short)' refs/remotes 2>/dev/null | grep -c 'effort/720-stale' | tr -d ' ')" "1"
|
|
446
|
+
t "wip: a stale remote-tracking ref is NOT counted" \
|
|
447
|
+
"$(effort_wip_rows | grep -c '^720' | tr -d ' ')" "0"
|
|
448
|
+
EFFORT_WIP_LIMIT=1 effort_start 721 not-blocked >/dev/null 2>&1; rc=$?
|
|
449
|
+
t "wip: a stale ref does not block a start (rc 0)" "$rc" "0"
|
|
450
|
+
t "wip: the unblocked start created its branch" "$(wip_started 721-not-blocked)" "yes"
|
|
451
|
+
git fetch -q --prune origin
|
|
452
|
+
|
|
453
|
+
# 8b. UNDER-count: a branch pushed to origin since the last fetch is absent from refs/remotes — and
|
|
454
|
+
# effort_start's own fetch is base-only, so it would never appear. It must still be counted.
|
|
455
|
+
# `git update-ref` inside the bare remote is the "another machine pushed" case with no fetch.
|
|
456
|
+
wip_reset
|
|
457
|
+
git --git-dir="$wtmp/remote.git" update-ref refs/heads/effort/722-unfetched \
|
|
458
|
+
"$(git rev-parse origin/main)"
|
|
459
|
+
t "wip: the new branch is absent from the local cache" \
|
|
460
|
+
"$(git for-each-ref --format='%(refname:short)' refs/remotes 2>/dev/null | grep -c 'effort/722-unfetched' | tr -d ' ')" "0"
|
|
461
|
+
t "wip: an unfetched origin branch IS counted" \
|
|
462
|
+
"$(effort_wip_rows | grep -c '^722' | tr -d ' ')" "1"
|
|
463
|
+
out="$(EFFORT_WIP_LIMIT=1 effort_start 723 blocked-by-unfetched 2>&1)"; rc=$?
|
|
464
|
+
t "wip: an unfetched origin branch blocks a start (rc 1)" "$rc" "1"
|
|
465
|
+
t "wip: that refusal created no branch" "$(wip_started 723-blocked-by-unfetched)" "no"
|
|
466
|
+
case "$out" in *"722"*) echo "ok: the refusal names the unfetched effort" ;; *) echo "FAIL: refusal did not name #722: $out"; fail=1 ;; esac
|
|
467
|
+
|
|
468
|
+
# 8c. EFFORT_WIP_REMOTE=0 opts out of the origin query and counts the cache — so with the same
|
|
469
|
+
# un-fetched origin branch the count goes back to the old approximation (absent), which is
|
|
470
|
+
# exactly what "deterministic offline mode" means.
|
|
471
|
+
t "wip: EFFORT_WIP_REMOTE=0 skips the origin query" \
|
|
472
|
+
"$(EFFORT_WIP_REMOTE=0 effort_wip_rows | grep -c '^722' | tr -d ' ')" "0"
|
|
473
|
+
EFFORT_WIP_REMOTE=0 EFFORT_WIP_LIMIT=1 effort_start 724 optout >/dev/null 2>&1; rc=$?
|
|
474
|
+
t "wip: EFFORT_WIP_REMOTE=0 starts under the cached count (rc 0)" "$rc" "0"
|
|
475
|
+
wip_reset
|
|
476
|
+
git --git-dir="$wtmp/remote.git" update-ref -d refs/heads/effort/722-unfetched
|
|
477
|
+
|
|
478
|
+
# 8d. an UNREACHABLE origin must not fail the start: the count falls back to the cached refs, warns
|
|
479
|
+
# once on stderr, and the gate proceeds. A gate that hard-fails offline is worse than one that
|
|
480
|
+
# miscounts.
|
|
481
|
+
wip_reset
|
|
482
|
+
git remote set-url origin "$wtmp/nope-does-not-exist.git"
|
|
483
|
+
rows_out="$(effort_wip_rows 2>&1 >/dev/null)"
|
|
484
|
+
case "$rows_out" in *"may be stale"*) echo "ok: an unreachable origin warns" ;; *) echo "FAIL: no staleness warning: $rows_out"; fail=1 ;; esac
|
|
485
|
+
out="$(effort_start 725 offline 2>&1)"; rc=$?
|
|
486
|
+
t "wip: an unreachable origin still starts the effort (rc 0)" "$rc" "0"
|
|
487
|
+
t "wip: the offline start created its branch" "$(wip_started 725-offline)" "yes"
|
|
488
|
+
git remote set-url origin "$wtmp/remote.git"
|
|
489
|
+
wip_reset
|
|
490
|
+
|
|
491
|
+
# 9. limit 0 freezes new efforts entirely (nothing in progress, and still a refusal).
|
|
492
|
+
wip_reset
|
|
493
|
+
EFFORT_WIP_LIMIT=0 effort_start 707 frozen >/dev/null 2>&1; rc=$?
|
|
494
|
+
t "wip: limit 0 refuses with nothing in progress (rc 1)" "$rc" "1"
|
|
495
|
+
t "wip: limit 0 created no branch" "$(wip_started 707-frozen)" "no"
|
|
496
|
+
EFFORT_WIP_LIMIT=0 effort_start --force 707 frozen >/dev/null 2>&1; rc=$?
|
|
497
|
+
t "wip: limit 0 is still overridable (rc 0)" "$rc" "0"
|
|
498
|
+
|
|
499
|
+
# 10. a misconfigured limit is IGNORED with a warning and the built-in default (2) is used —
|
|
500
|
+
# a typo must neither disable the gate nor wedge the verb.
|
|
501
|
+
wip_reset
|
|
502
|
+
out="$(EFFORT_WIP_LIMIT=lots effort_start 708 typo 2>&1)"; rc=$?
|
|
503
|
+
t "wip: a non-numeric limit still starts under the default (rc 0)" "$rc" "0"
|
|
504
|
+
case "$out" in *"must be a non-negative integer"*) echo "ok: a bad limit warns" ;; *) echo "FAIL: no warning for a bad limit: $out"; fail=1 ;; esac
|
|
505
|
+
out="$(EFFORT_WIP_LIMIT=-1 effort_start 709 negative 2>&1)"; rc=$?
|
|
506
|
+
t "wip: a negative limit falls back to the default too (rc 0)" "$rc" "0"
|
|
507
|
+
# two are now in progress under the fallback default of 2 → the next one is refused
|
|
508
|
+
EFFORT_WIP_LIMIT=lots effort_start 710 third >/dev/null 2>&1; rc=$?
|
|
509
|
+
t "wip: the fallback default is really 2 (rc 1)" "$rc" "1"
|
|
510
|
+
|
|
511
|
+
# 11. the limit is read from `effort.wipLimit` in the project config when no env var is set…
|
|
512
|
+
wip_reset
|
|
513
|
+
mkdir -p .claude
|
|
514
|
+
printf '{"effort":{"wipLimit":1}}\n' > .claude/kit.config.json
|
|
515
|
+
effort_start 711 from-config >/dev/null 2>&1
|
|
516
|
+
out="$(effort_start 712 from-config-two 2>&1)"; rc=$?
|
|
517
|
+
t "wip: effort.wipLimit=1 refuses the second effort (rc 1)" "$rc" "1"
|
|
518
|
+
case "$out" in *"WIP limit is 1"*) echo "ok: the configured limit is the one enforced" ;; *) echo "FAIL: config limit not used: $out"; fail=1 ;; esac
|
|
519
|
+
# …and EFFORT_WIP_LIMIT wins over it, per invocation.
|
|
520
|
+
EFFORT_WIP_LIMIT=3 effort_start 712 from-config-two >/dev/null 2>&1; rc=$?
|
|
521
|
+
t "wip: EFFORT_WIP_LIMIT overrides the config (rc 0)" "$rc" "0"
|
|
522
|
+
# KIT_EFFORT_WIP_LIMIT (what load_kit_config exports) is read when EFFORT_WIP_LIMIT is unset.
|
|
523
|
+
wip_reset
|
|
524
|
+
out="$(KIT_EFFORT_WIP_LIMIT=0 effort_start 713 kitenv 2>&1)"; rc=$?
|
|
525
|
+
t "wip: KIT_EFFORT_WIP_LIMIT is honoured (rc 1)" "$rc" "1"
|
|
526
|
+
rm -f .claude/kit.config.json
|
|
527
|
+
|
|
528
|
+
# 12. effort_wip_rows counts each effort ONCE even when local + remote refs both carry it.
|
|
529
|
+
wip_reset
|
|
530
|
+
effort_start 714 dedup >/dev/null 2>&1
|
|
531
|
+
git push -q origin effort/714-dedup; git fetch -q origin
|
|
532
|
+
t "wip: local + remote refs count as one effort" "$(effort_wip_rows | wc -l | tr -d ' ')" "1"
|
|
533
|
+
git push -q origin :refs/heads/effort/714-dedup >/dev/null 2>&1; git fetch -q --prune origin
|
|
534
|
+
wip_reset
|
|
535
|
+
|
|
536
|
+
# 13. an unknown flag is rejected before anything happens.
|
|
537
|
+
: > "$CH_LOG"
|
|
538
|
+
effort_start --nope 715 x >/dev/null 2>&1; rc=$?
|
|
539
|
+
t "wip: an unknown flag is rejected (rc 1)" "$rc" "1"
|
|
540
|
+
t "wip: an unknown flag writes nothing" "$(grep -c . "$CH_LOG" | tr -d ' ')" "0"
|
|
541
|
+
|
|
542
|
+
# 14. scope: the gate is an EFFORT gate. `cckit start <issue>` (wt_start, worktree-start.sh) has no
|
|
543
|
+
# WIP limit — a static guard so widening the scope can't happen by accident.
|
|
544
|
+
t "wip: the plain-task start path is not gated" \
|
|
545
|
+
"$(grep -c '_eff_wip_gate\|effort_wip_rows' "$LIB/worktree-start.sh" | tr -d ' ')" "0"
|
|
546
|
+
|
|
547
|
+
cd "$tmp/work" || exit 1
|
|
548
|
+
|
|
189
549
|
[ "$fail" -eq 0 ] && echo "ALL OK (effort-ops)" || echo "effort-ops: FAILURES"
|
|
190
550
|
exit "$fail"
|