@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
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
# blob->path map. `git worktree prune` deletes that index, orphaning the blobs (real data loss). gc
|
|
6
6
|
# must (a) detect zombies + staged deltas as their own analysis bucket, (b) recover any staged delta
|
|
7
7
|
# to its branch as a commit BEFORE pruning, and (c) never prune in a dry-run.
|
|
8
|
-
# Hermetic: a throwaway git repo
|
|
8
|
+
# Hermetic: a throwaway git repo and the forge shim (test-forge-shim.sh) in place of GitHub, no network.
|
|
9
|
+
# Run: bash scripts/lib/kit-gc-test.sh
|
|
9
10
|
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
10
11
|
set -u
|
|
11
12
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
@@ -69,22 +70,48 @@ t "pr index lookup finds a branch" "$(_kit_gc_pr_for "$IDX" feat/1-a)" "P
|
|
|
69
70
|
t "pr index lookup finds another branch" "$(_kit_gc_pr_for "$IDX" feat/2-b)" "PR#22 OPEN"
|
|
70
71
|
t "pr index lookup misses an absent branch" "$(_kit_gc_pr_for "$IDX" feat/9-z)" ""
|
|
71
72
|
|
|
72
|
-
# kit_gc_analyze must issue exactly ONE
|
|
73
|
+
# kit_gc_analyze must issue exactly ONE PR list read regardless of branch count (no per-branch N+1).
|
|
73
74
|
git branch feat/30-x >/dev/null 2>&1; git branch feat/31-y >/dev/null 2>&1; git branch feat/32-z >/dev/null 2>&1
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
# The forge shim stands in for GitHub. Every section below writes ONE fixture (GH_FIXTURE), a bash
|
|
76
|
+
# snippet the shim's curl sources with $method, $ep (the path without its query string) and may set
|
|
77
|
+
# `out` (the JSON body) and `code`. gcfix writes it from case arms; the defaults after the arms are:
|
|
78
|
+
# an issue's timeline carries no closing PR (the shim's own default would land every issue), the
|
|
79
|
+
# parent lookup is a 404, issue 41 is open and every other issue closed.
|
|
80
|
+
stub="$tmp/ghbin"
|
|
81
|
+
# shellcheck source=/dev/null
|
|
82
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$stub"
|
|
83
|
+
export GH_TOKEN=test-token CCKIT_FORGE=github GH_FIXTURE="$tmp/gc-fixture"
|
|
84
|
+
export GH_CALLS="$tmp/ghcalls" GH_LOG="$tmp/ghcalls"; : > "$GH_CALLS"
|
|
85
|
+
gcfix() {
|
|
86
|
+
cat > "$GH_FIXTURE" <<FIX
|
|
87
|
+
case "\$method \$ep" in
|
|
88
|
+
$1
|
|
89
|
+
"GET repos/o/r/issues/"*"/timeline") out='[]' ;;
|
|
90
|
+
"GET repos/o/r/issues/"*"/parent") code=404; out='{"message":"Not Found"}' ;;
|
|
91
|
+
"GET repos/o/r/issues/"*) n="\${ep##*/}"; case "\$n" in 41) st=open ;; *) st=closed ;; esac
|
|
92
|
+
out="{\"number\":\$n,\"state\":\"\$st\"}" ;;
|
|
82
93
|
esac
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
FIX
|
|
95
|
+
}
|
|
96
|
+
# pulls_json "<branch>\tPR#<n> <STATE>" … → the REST PR list those rows describe
|
|
97
|
+
pulls_json() {
|
|
98
|
+
local row b pr st j="" sep=""
|
|
99
|
+
for row in "$@"; do
|
|
100
|
+
b="${row%% *}"; pr="${row#* }"; st="${pr#* }"; pr="${pr%% *}"; pr="${pr#PR#}"
|
|
101
|
+
case "$st" in
|
|
102
|
+
MERGED) j="$j$sep{\"number\":$pr,\"head\":{\"ref\":\"$b\"},\"state\":\"closed\",\"merged_at\":\"2026-01-01T00:00:00Z\"}" ;;
|
|
103
|
+
*) j="$j$sep{\"number\":$pr,\"head\":{\"ref\":\"$b\"},\"state\":\"$(printf '%s' "$st" | tr '[:upper:]' '[:lower:]')\",\"merged_at\":null}" ;;
|
|
104
|
+
esac
|
|
105
|
+
sep=","
|
|
106
|
+
done
|
|
107
|
+
printf '[%s]' "$j"
|
|
108
|
+
}
|
|
109
|
+
PR_LIST='^GET repos/o/r/pulls?state=all&per_page=100 '
|
|
110
|
+
gcfix " \"GET repos/o/r/pulls\") out='$(pulls_json "feat/30-x PR#30 MERGED")' ;;"
|
|
111
|
+
: > "$GH_CALLS"
|
|
86
112
|
PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze >/dev/null 2>&1
|
|
87
|
-
t "kit_gc_analyze makes exactly ONE
|
|
113
|
+
t "kit_gc_analyze makes exactly ONE PR list read" "$(grep -c "$PR_LIST" "$GH_CALLS")" "1"
|
|
114
|
+
t "kit_gc_analyze runs no gh subcommand" "$(grep -c '^GH-SUBCOMMAND' "$GH_CALLS")" "0"
|
|
88
115
|
|
|
89
116
|
# ── the protection helper is MANDATORY (#219) ───────────────────────────────────────────────────
|
|
90
117
|
# With worktree-issue.sh absent, `wt_protected_reason` is undefined and every issue-open check would
|
|
@@ -111,18 +138,7 @@ git branch task/41-open >/dev/null 2>&1
|
|
|
111
138
|
git checkout -q -b task/42-orphan
|
|
112
139
|
echo "only here" > orphan.txt; git add orphan.txt; git commit -qm "orphan work"
|
|
113
140
|
git checkout -q "$init_branch"
|
|
114
|
-
|
|
115
|
-
#!/usr/bin/env bash
|
|
116
|
-
echo "$*" >> "$GH_CALLS"
|
|
117
|
-
case "$1 $2" in
|
|
118
|
-
"pr list") printf 'task/40-merged\tPR#40 MERGED\n' ;;
|
|
119
|
-
"issue view")
|
|
120
|
-
for a in "$@"; do case "$a" in 41) echo open; exit 0 ;; esac; done
|
|
121
|
-
echo closed ;;
|
|
122
|
-
*) : ;;
|
|
123
|
-
esac
|
|
124
|
-
SH
|
|
125
|
-
chmod +x "$stub/gh"
|
|
141
|
+
gcfix " \"GET repos/o/r/pulls\") out='$(pulls_json "task/40-merged PR#40 MERGED")' ;;"
|
|
126
142
|
|
|
127
143
|
plan="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_cleanup 2>&1)"
|
|
128
144
|
has "cleanup prints a plan" "$plan" "# cleanup plan"
|
|
@@ -199,15 +215,7 @@ t "_kit_gc_remote_ahead sees remote-only history" "$(_kit_gc_remote_ahead task/4
|
|
|
199
215
|
t "_kit_gc_has_unpushed clears it (local ⊆ remote)" "$(_kit_gc_has_unpushed task/44-behind && echo yes || echo no)" "no"
|
|
200
216
|
|
|
201
217
|
# End to end: a MERGED PR on a branch with unpushed commits must survive --yes.
|
|
202
|
-
|
|
203
|
-
#!/usr/bin/env bash
|
|
204
|
-
case "$1 $2" in
|
|
205
|
-
"pr list") printf 'task/43-ahead\tPR#43 MERGED\n' ;;
|
|
206
|
-
"issue view") echo closed ;;
|
|
207
|
-
*) : ;;
|
|
208
|
-
esac
|
|
209
|
-
SH
|
|
210
|
-
chmod +x "$stub/gh"
|
|
218
|
+
gcfix " \"GET repos/o/r/pulls\") out='$(pulls_json "task/43-ahead PR#43 MERGED")' ;;"
|
|
211
219
|
out="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_prune --yes 2>&1)"
|
|
212
220
|
t "merged-but-ahead branch survives prune --yes" "$(git branch --list task/43-ahead | wc -l | tr -d ' ')" "1"
|
|
213
221
|
has "prune says why it skipped it" "$out" "unpushed commits"
|
|
@@ -249,17 +257,7 @@ echo "agent two" > ../agentwt2/agent2.txt; git -C ../agentwt2 add agent2.txt; gi
|
|
|
249
257
|
git checkout -q worktree-agent-def456 -- agent2.txt; git commit -qm "feat: squash of agent two"
|
|
250
258
|
echo "uncommitted" > ../agentwt2/scratch.txt
|
|
251
259
|
|
|
252
|
-
|
|
253
|
-
#!/usr/bin/env bash
|
|
254
|
-
case "$1 $2" in
|
|
255
|
-
"pr list") printf 'effort/50-thing\tPR#55 MERGED\n' ;;
|
|
256
|
-
"issue view")
|
|
257
|
-
for a in "$@"; do case "$a" in 41) echo open; exit 0 ;; esac; done
|
|
258
|
-
echo closed ;;
|
|
259
|
-
*) : ;;
|
|
260
|
-
esac
|
|
261
|
-
SH
|
|
262
|
-
chmod +x "$stub/gh"
|
|
260
|
+
gcfix " \"GET repos/o/r/pulls\") out='$(pulls_json "effort/50-thing PR#55 MERGED")' ;;"
|
|
263
261
|
|
|
264
262
|
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
265
263
|
row() { printf '%s\n' "$analysis" | awk -v b="$1" '$1==b && $2=="->" && !hit {sub(/^ [^ ]+ -> /, ""); print; hit=1}'; }
|
|
@@ -317,32 +315,23 @@ echo "agent old" > agentold.txt; git add agentold.txt; git commit -qm "feat: age
|
|
|
317
315
|
git checkout -q "$init_branch"
|
|
318
316
|
git checkout -q worktree-agent-old777 -- agentold.txt; git commit -qm "squash of the agent's part"
|
|
319
317
|
echo "changed again" > agentold.txt; git add agentold.txt; git commit -qm "later change on base"
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
"
|
|
325
|
-
"issue
|
|
326
|
-
case "$*" in
|
|
327
|
-
*closedByPullRequestsReferences*) for a in "$@"; do case "$a" in 60) echo 61; exit 0 ;; esac; done ;;
|
|
328
|
-
*) echo closed ;;
|
|
329
|
-
esac ;;
|
|
330
|
-
"pr view") for a in "$@"; do case "$a" in 61) echo MERGED; exit 0 ;; esac; done; echo CLOSED ;;
|
|
331
|
-
*) : ;;
|
|
332
|
-
esac
|
|
333
|
-
SH
|
|
334
|
-
chmod +x "$stub/gh"
|
|
318
|
+
# REST has no closedByPullRequestsReferences: the closing PR is the merged cross-reference in the
|
|
319
|
+
# issue's timeline whose body closes #60 (gh_rest_issue_closing_prs). The timeline also carries an
|
|
320
|
+
# OPEN PR 62 that says "Closes #60" — a PR that is not merged lands nothing, so PR#61 must be the one
|
|
321
|
+
# named (the MERGED confirmation the old `pr view 61` made, now read off the same timeline entry).
|
|
322
|
+
gcfix " \"GET repos/o/r/pulls\") out='$(pulls_json "effort/50-thing PR#55 MERGED")' ;;
|
|
323
|
+
\"GET repos/o/r/issues/60/timeline\") out='[{\"event\":\"cross-referenced\",\"source\":{\"issue\":{\"number\":62,\"body\":\"Closes #60\",\"repository_url\":\"https://api.github.com/repos/o/r\",\"pull_request\":{\"merged_at\":null}}}},{\"event\":\"cross-referenced\",\"source\":{\"issue\":{\"number\":61,\"body\":\"Closes #60\",\"repository_url\":\"https://api.github.com/repos/o/r\",\"pull_request\":{\"merged_at\":\"2026-01-01T00:00:00Z\"}}}}]' ;;"
|
|
335
324
|
: > "$GH_CALLS"
|
|
336
325
|
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
337
326
|
has "sub landed via the issue's closing PR" "$(row sub/60a-old)" "LANDED (issue #60 closed by merged PR#61)"
|
|
338
327
|
has "agent branch with [#60] subject landed too" "$(row worktree-agent-old777)" "LANDED (agent worktree; issue #60 closed by merged PR#61)"
|
|
339
328
|
t "the closedBy lookup ran ONCE for #60 across both branches" \
|
|
340
|
-
"$(grep -c '
|
|
341
|
-
t "the
|
|
329
|
+
"$(grep -c '^GET repos/o/r/issues/60/timeline' "$GH_CALLS")" "1"
|
|
330
|
+
t "the merged state came from the timeline, not a PR read" "$(grep -c 'repos/o/r/pulls/6[12] ' "$GH_CALLS")" "0"
|
|
342
331
|
# A fresh run must not trust the previous run's cache (the issue could have been reopened).
|
|
343
332
|
: > "$GH_CALLS"
|
|
344
333
|
PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_prune >/dev/null 2>&1
|
|
345
|
-
t "a new run looks the issue up again" "$(grep -c '
|
|
334
|
+
t "a new run looks the issue up again" "$(grep -c '^GET repos/o/r/issues/60/timeline' "$GH_CALLS")" "1"
|
|
346
335
|
|
|
347
336
|
# ── `(#N)` subjects + a sub-issue closed through its parent's PR ──────────────────────────────
|
|
348
337
|
# Measured on a consuming repo: agent branches whose subjects end in `(#N)` — GitHub's own trailing ref,
|
|
@@ -357,30 +346,16 @@ echo "changed again" > onto.txt; git add onto.txt; git commit -qm "later change
|
|
|
357
346
|
git checkout -q -b effort/80-not-planned
|
|
358
347
|
echo "abandoned" > np.txt; git add np.txt; git commit -qm "[Effort 80] 1 · never landed"
|
|
359
348
|
git checkout -q "$init_branch"
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
case "$1 $2" in
|
|
364
|
-
"pr list") printf 'effort/50-thing\tPR#55 MERGED\n' ;;
|
|
365
|
-
"issue view")
|
|
366
|
-
case "$*" in
|
|
367
|
-
*closedByPullRequestsReferences*) for a in "$@"; do case "$a" in 75) echo 76; exit 0 ;; esac; done ;; # 70, 80: nothing
|
|
368
|
-
*) echo closed ;;
|
|
369
|
-
esac ;;
|
|
370
|
-
"pr view") for a in "$@"; do case "$a" in 76) echo MERGED; exit 0 ;; esac; done; echo CLOSED ;;
|
|
371
|
-
"api repos/o/r/issues/70/parent") echo 75 ;;
|
|
372
|
-
"api repos/o/r/issues/80/parent") echo "gh: Not Found (HTTP 404)" >&2; exit 1 ;;
|
|
373
|
-
*) : ;;
|
|
374
|
-
esac
|
|
375
|
-
SH
|
|
376
|
-
chmod +x "$stub/gh"
|
|
349
|
+
gcfix " \"GET repos/o/r/pulls\") out='$(pulls_json "effort/50-thing PR#55 MERGED")' ;;
|
|
350
|
+
\"GET repos/o/r/issues/75/timeline\") out='[{\"event\":\"cross-referenced\",\"source\":{\"issue\":{\"number\":76,\"body\":\"Closes #75\",\"repository_url\":\"https://api.github.com/repos/o/r\",\"pull_request\":{\"merged_at\":\"2026-01-01T00:00:00Z\"}}}}]' ;;
|
|
351
|
+
\"GET repos/o/r/issues/70/parent\") out='{\"number\":75}' ;;"
|
|
377
352
|
: > "$GH_CALLS"
|
|
378
353
|
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
379
354
|
has "(#N) subject lands through the parent's merged PR" "$(row worktree-agent-sub70)" \
|
|
380
355
|
"LANDED (agent worktree; issue #70 closed, parent #75 closed by merged PR#76)"
|
|
381
356
|
has "closed NOT_PLANNED with no PR and no parent stays ORPHAN" "$(row effort/80-not-planned)" "ORPHAN"
|
|
382
|
-
t "the parent was climbed once for #70" "$(grep -c '^
|
|
383
|
-
t "the parent lookup for #80 ran once and was cached as a miss" "$(grep -c '^
|
|
357
|
+
t "the parent was climbed once for #70" "$(grep -c '^GET repos/o/r/issues/70/parent ' "$GH_CALLS")" "1"
|
|
358
|
+
t "the parent lookup for #80 ran once and was cached as a miss" "$(grep -c '^GET repos/o/r/issues/80/parent ' "$GH_CALLS")" "1"
|
|
384
359
|
applied="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_prune --yes --only '^(worktree-agent-sub70|effort/80-)' 2>&1)"
|
|
385
360
|
t "--yes deleted the parent-landed agent branch" "$(git branch --list worktree-agent-sub70 | wc -l | tr -d ' ')" "0"
|
|
386
361
|
t "--yes KEPT the not-planned effort branch" "$(git branch --list effort/80-not-planned | wc -l | tr -d ' ')" "1"
|
|
@@ -486,20 +461,18 @@ echo base > base.txt; git add base.txt; git commit -q -m init
|
|
|
486
461
|
export KIT_BASE_BRANCH=main
|
|
487
462
|
git branch task/41-fresh
|
|
488
463
|
git checkout -q -b task/42-work; echo w > w.txt; git add w.txt; git commit -q -m "work"; git checkout -q "$KIT_BASE_BRANCH"
|
|
489
|
-
ghfail() { # ghfail <case-arms> — a
|
|
490
|
-
cat > "$
|
|
491
|
-
|
|
492
|
-
case "\$1 \$2" in
|
|
464
|
+
ghfail() { # ghfail <case-arms> — a forge that answers the given arms and FAILS everything else (403)
|
|
465
|
+
cat > "$GH_FIXTURE" <<FIX
|
|
466
|
+
case "\$method \$ep" in
|
|
493
467
|
$1
|
|
494
|
-
*)
|
|
468
|
+
*) code=403; out='{"message":"API rate limit exceeded"}' ;;
|
|
495
469
|
esac
|
|
496
|
-
|
|
497
|
-
chmod +x "$stub/gh"
|
|
470
|
+
FIX
|
|
498
471
|
}
|
|
499
|
-
|
|
500
|
-
|
|
472
|
+
# REST over the forge is the one transport (E537.3): the graphql/rest pair of #396 is one pass now.
|
|
473
|
+
transport=rest
|
|
501
474
|
# (b) the PR list read fails; the issue-state read answers `closed`.
|
|
502
|
-
ghfail ' "
|
|
475
|
+
ghfail ' "GET repos/o/r/issues/41"|"GET repos/o/r/issues/42") out='"'"'{"state":"closed"}'"'"' ;;'
|
|
503
476
|
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze 2>"$tmp/outage.err")"
|
|
504
477
|
has "$transport: PR list failed -> could not determine" "$(row task/42-work)" "UNKNOWN (could not determine"
|
|
505
478
|
lacks "$transport: PR list failed -> never 'no PR'" "$(row task/42-work)" "no PR"
|
|
@@ -526,35 +499,43 @@ for transport in graphql rest; do
|
|
|
526
499
|
t "$transport: cleanup plan counts no LANDED" "$(printf '%s\n' "$plan" | awk '/^ LANDED branches/{print $3}')" "0"
|
|
527
500
|
|
|
528
501
|
# (e) only the issue-state read fails; the PR list answers, and it is empty.
|
|
529
|
-
ghfail ' "
|
|
502
|
+
ghfail ' "GET repos/o/r/pulls") out='"'"'[]'"'"' ;;'
|
|
530
503
|
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
531
504
|
has "$transport: issue read failed, PR list ok -> 41 is UNKNOWN" "$(row task/41-fresh)" "state read for issue #41 failed"
|
|
532
505
|
|
|
533
|
-
# (d) the verbs' JSON stays valid JSON with the failing
|
|
506
|
+
# (d) the verbs' JSON stays valid JSON with the failing forge, and carries the count.
|
|
534
507
|
if command -v jq >/dev/null 2>&1; then
|
|
535
508
|
ghfail ''
|
|
536
509
|
js="$(PATH="$stub:$PATH" KIT_REPO="o/r" KIT_GC_REPO="o/r" "$ROOT/bin/cckit" gc --llm 2>/dev/null)"
|
|
537
|
-
t "$transport: cckit gc --llm is valid JSON with
|
|
510
|
+
t "$transport: cckit gc --llm is valid JSON with the forge failing" "$(printf '%s' "$js" | jq -r 'type' 2>/dev/null)" "object"
|
|
538
511
|
t "$transport: cckit gc --llm counts the unknown rows" "$(printf '%s' "$js" | jq -r '.unknown' 2>/dev/null)" "2"
|
|
539
512
|
t "$transport: cckit gc --llm reports no orphan" "$(printf '%s' "$js" | jq -r '.orphan' 2>/dev/null)" "0"
|
|
540
513
|
js="$(PATH="$stub:$PATH" KIT_REPO="o/r" KIT_GC_REPO="o/r" "$ROOT/bin/cckit" cleanup --llm 2>/dev/null)"
|
|
541
514
|
t "$transport: cckit cleanup --llm counts the unknown rows" "$(printf '%s' "$js" | jq -r '.unknown' 2>/dev/null)" "2"
|
|
542
515
|
fi
|
|
543
|
-
done
|
|
544
|
-
unset CCKIT_GH_TRANSPORT
|
|
545
516
|
|
|
546
|
-
#
|
|
547
|
-
#
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
"
|
|
552
|
-
"
|
|
553
|
-
|
|
517
|
+
# (f) no forge at all: the PR list and the issue states are all "could not determine", nothing is
|
|
518
|
+
# prunable, and nothing is asked of the network.
|
|
519
|
+
: > "$GH_CALLS"
|
|
520
|
+
analysis="$(unset _FORGE_LOADED; PATH="$stub:$PATH" CCKIT_FORGE=none KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
521
|
+
has "no forge -> 41 is UNKNOWN" "$(row task/41-fresh)" "UNKNOWN (could not determine"
|
|
522
|
+
has "no forge -> 42 is UNKNOWN" "$(row task/42-work)" "UNKNOWN (could not determine"
|
|
523
|
+
t "no forge -> nothing is prunable" \
|
|
524
|
+
"$(unset _FORGE_LOADED; PATH="$stub:$PATH" CCKIT_FORGE=none KIT_GC_REPO="o/r" kit_gc_has_prunable && echo yes || echo no)" "no"
|
|
525
|
+
t "no forge -> no request was made" "$(wc -l < "$GH_CALLS" | tr -d ' ')" "0"
|
|
526
|
+
t "no forge -> the merged-PR lookup answers nothing" "$(unset _FORGE_LOADED; CCKIT_FORGE=none _kit_gc_issue_merged_pr 41 o/r)" ""
|
|
527
|
+
unset _FORGE_LOADED
|
|
528
|
+
|
|
529
|
+
# A definite answer still classifies as before: GitHub says "no such issue" for #41 (404) and
|
|
530
|
+
# returns an empty PR list — the branch is LANDED by content, not UNKNOWN.
|
|
531
|
+
cat > "$GH_FIXTURE" <<'FIX'
|
|
532
|
+
case "$method $ep" in
|
|
533
|
+
"GET repos/o/r/pulls") out='[]' ;;
|
|
534
|
+
"GET repos/o/r/issues/41") code=404; out='{"message":"Not Found"}' ;;
|
|
535
|
+
*) code=403; out='{"message":"API rate limit exceeded"}' ;;
|
|
554
536
|
esac
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" CCKIT_GH_TRANSPORT=graphql kit_gc_analyze 2>/dev/null)"
|
|
537
|
+
FIX
|
|
538
|
+
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
558
539
|
has "an absent issue is not a failed read: 41 is LANDED" "$(row task/41-fresh)" "LANDED (ancestor of"
|
|
559
540
|
unset KIT_BASE_BRANCH
|
|
560
541
|
|
package/scripts/lib/kit-gc.sh
CHANGED
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
# errors: mixed — kit_gc_analyze is read-only and forgiving; the prune path propagates
|
|
28
28
|
|
|
29
29
|
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
30
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
31
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
32
|
+
# shellcheck source=/dev/null
|
|
33
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
34
|
+
fi
|
|
35
|
+
|
|
30
36
|
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
31
37
|
_ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
|
|
32
38
|
# shellcheck source=/dev/null
|
|
@@ -85,21 +91,15 @@ _kit_gc_require_deps() {
|
|
|
85
91
|
# always: kit-status.sh calls this in a bare assignment under `set -e`.
|
|
86
92
|
_kit_gc_pr_index() {
|
|
87
93
|
local repo="${1:-$KIT_GC_REPO}" out
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|| { _kit_gc_pr_index_failed; return 0; }
|
|
92
|
-
else
|
|
93
|
-
out="$(gh pr list --repo "$repo" --state all --limit 200 --json number,state,headRefName \
|
|
94
|
-
--jq '.[] | "\(.headRefName)\tPR#\(.number) \(.state)"' 2>/dev/null)" \
|
|
95
|
-
|| { _kit_gc_pr_index_failed; return 0; }
|
|
96
|
-
fi
|
|
94
|
+
out="$(forge_rest "repos/$repo/pulls" -X GET -f state=all -f per_page=100 --paginate \
|
|
95
|
+
--jq '.[] | "\(.head.ref)\tPR#\(.number) \(if .merged_at then "MERGED" else (.state | ascii_upcase) end)"' 2>/dev/null)" \
|
|
96
|
+
|| { _kit_gc_pr_index_failed; return 0; }
|
|
97
97
|
[ -n "$out" ] && printf '%s\n' "$out"
|
|
98
98
|
return 0
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
_kit_gc_pr_index_failed() {
|
|
102
|
-
echo "kit-gc: could not read the PR list from GitHub
|
|
102
|
+
echo "kit-gc: could not read the PR list from GitHub — a branch whose PR is not known is reported UNKNOWN and kept" >&2
|
|
103
103
|
printf '?\tUNKNOWN\n'
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -201,25 +201,19 @@ _kit_gc_cache_reset() { rm -rf "$_KIT_GC_CACHE_DIR" 2>/dev/null; mkdir -p "$_KIT
|
|
|
201
201
|
_kit_gc_issue_merged_pr() {
|
|
202
202
|
local n="$1" repo="${2:-$KIT_GC_REPO}" depth="${3:-0}" cache="" cand result="" parent
|
|
203
203
|
[ -n "$n" ] || return 0
|
|
204
|
-
|
|
204
|
+
forge_available || { forge_note_none gc "merged pull requests cannot be read; a branch whose issue state is unknown is kept, never deleted"; return 0; }
|
|
205
205
|
[ -d "$_KIT_GC_CACHE_DIR" ] && cache="$_KIT_GC_CACHE_DIR/issue-$n"
|
|
206
206
|
if [ -n "$cache" ] && [ -f "$cache" ]; then cat "$cache"; return 0; fi
|
|
207
207
|
while IFS= read -r cand; do
|
|
208
208
|
[ -n "$cand" ] || continue
|
|
209
209
|
case "$cand" in *[!0-9]*) continue ;; esac
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
result="$cand"; break
|
|
213
|
-
elif [ "$(gh pr view "$cand" --repo "$repo" --json state --jq .state 2>/dev/null)" = "MERGED" ]; then
|
|
214
|
-
result="$cand"; break
|
|
215
|
-
fi
|
|
210
|
+
# The candidate came from a merged cross-reference that closes <n> (gh_rest_issue_closing_prs).
|
|
211
|
+
result="$cand"; break
|
|
216
212
|
done <<EOF
|
|
217
|
-
$(
|
|
218
|
-
else gh issue view "$n" --repo "$repo" --json closedByPullRequestsReferences \
|
|
219
|
-
--jq '.closedByPullRequestsReferences[].number' 2>/dev/null || true; fi)
|
|
213
|
+
$(gh_rest_issue_closing_prs "$repo" "$n" 2>/dev/null || true)
|
|
220
214
|
EOF
|
|
221
215
|
if [ -z "$result" ] && [ "$depth" -eq 0 ]; then
|
|
222
|
-
parent="$(
|
|
216
|
+
parent="$(forge_rest "repos/$repo/issues/$n/parent" --jq .number 2>/dev/null || true)"
|
|
223
217
|
case "$parent" in ''|*[!0-9]*) parent="" ;; esac
|
|
224
218
|
if [ -n "$parent" ]; then
|
|
225
219
|
result="$(_kit_gc_issue_merged_pr "$parent" "$repo" 1)"
|
|
@@ -330,6 +324,9 @@ _kit_gc_detached_rows() {
|
|
|
330
324
|
kit_gc_analyze() {
|
|
331
325
|
_kit_gc_require_deps || return 1
|
|
332
326
|
_kit_gc_cache_reset
|
|
327
|
+
# Without a forge no issue or pull request state can be read: every issue branch is UNKNOWN and
|
|
328
|
+
# kept. Said once here, since the per-branch reads below are quiet.
|
|
329
|
+
forge_available || forge_note_none gc "issue and pull request states cannot be read; every issue branch is UNKNOWN and kept, never deleted"
|
|
333
330
|
# `wtpath`, not `path`: under zsh `path` is tied to PATH (special array), so a bare `path` local
|
|
334
331
|
# here would clobber the command search path on assignment. A namespaced name is inert.
|
|
335
332
|
local repo="$KIT_GC_REPO" b ref wtpath reason
|
|
@@ -757,7 +754,7 @@ ZEOF
|
|
|
757
754
|
printf '%s\n' "$orphan_list" | grep . | sed 's/^/ /' || true
|
|
758
755
|
printf ' PROTECTED kept %3s issue still OPEN\n' "$n_prot"
|
|
759
756
|
printf '%s\n' "$prot_list" | grep . | sed 's/^/ /' || true
|
|
760
|
-
printf ' UNKNOWN kept %3s a GitHub read failed — could not determine, rerun when
|
|
757
|
+
printf ' UNKNOWN kept %3s a GitHub read failed — could not determine, rerun when GitHub answers\n' "$n_unknown"
|
|
761
758
|
printf '%s\n' "$unknown_list" | grep . | sed 's/^/ /' || true
|
|
762
759
|
printf ' stashes kept %3s irreversible — drop by hand after reading each diff\n' "$n_stash"
|
|
763
760
|
printf '%s\n' "$stash_list" | grep . | sed 's/^/ /' || true
|
|
@@ -33,6 +33,12 @@
|
|
|
33
33
|
# Runs under the dispatcher's `set -e`: every read that may fail carries `|| true` and is checked
|
|
34
34
|
# on the next line, so a refusal prints its reason instead of exiting silently.
|
|
35
35
|
|
|
36
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
37
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
38
|
+
# shellcheck source=/dev/null
|
|
39
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
40
|
+
fi
|
|
41
|
+
|
|
36
42
|
if ! type cckit_gh_rest >/dev/null 2>&1; then
|
|
37
43
|
if [ -n "${BASH_SOURCE:-}" ]; then _kh_self="${BASH_SOURCE[0]}"
|
|
38
44
|
elif [ -n "${ZSH_VERSION:-}" ]; then eval '_kh_self="${(%):-%x}"'
|
|
@@ -96,8 +102,8 @@ kto_hotfix() {
|
|
|
96
102
|
;;
|
|
97
103
|
*)
|
|
98
104
|
pr="${src#\#}"
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
forge_available || { echo "✗ hotfix: no forge — PR #$pr cannot be read; pass the merge commit's sha instead" >&2; return 1; }
|
|
106
|
+
meta="$(gh_rest_pr_json "$repo" "$pr" || true)"
|
|
101
107
|
[ -n "$meta" ] || { echo "✗ hotfix: PR #$pr not found in $repo" >&2; return 1; }
|
|
102
108
|
[ "$(printf '%s' "$meta" | jq -r '.state // ""')" = "MERGED" ] \
|
|
103
109
|
|| { echo "✗ hotfix: PR #$pr is not merged — a hotfix carries a change that already landed" >&2; return 1; }
|
|
@@ -113,8 +119,7 @@ kto_hotfix() {
|
|
|
113
119
|
# merge it is the LAST of the PR's commits, the others sitting right under it with their
|
|
114
120
|
# subjects unchanged — that run of subjects is the tell, and then the whole run is picked.
|
|
115
121
|
if [ "$(git -C "$root" rev-list --parents -n 1 "$sha" | wc -w | tr -d ' ')" -eq 2 ]; then
|
|
116
|
-
|
|
117
|
-
else subjects="$(printf '%s' "$meta" | jq -r '.commits[]?.messageHeadline // empty')"; fi
|
|
122
|
+
subjects="$(gh_rest_pr_commit_subjects "$repo" "$pr" || true)"
|
|
118
123
|
n="$(printf '%s\n' "$subjects" | grep -c . || true)"
|
|
119
124
|
[ "$n" -ge 1 ] || { echo "✗ hotfix: cannot read the commits of PR #$pr, so cannot tell a squash from a rebase merge — pass the commit sha instead" >&2; return 1; }
|
|
120
125
|
if [ "$n" -gt 1 ] \
|
|
@@ -190,13 +195,15 @@ kto_hotfix() {
|
|
|
190
195
|
KIT_PR_BASE="$base" git -C "$wt" push -u origin "$branch" >&2 || return 1
|
|
191
196
|
echo "worktree: $wt"
|
|
192
197
|
|
|
193
|
-
# 5. the PR
|
|
194
|
-
if
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
# 5. the PR — without a forge the branch is pushed and the compare page printed, nothing opened.
|
|
199
|
+
if ! forge_available; then
|
|
200
|
+
forge_note_none hotfix "the pull request is not opened; $branch is pushed"
|
|
201
|
+
url="$(forge_compare_url "$base" "$branch" "$wt" 2>/dev/null || true)"
|
|
202
|
+
if [ -n "$url" ]; then echo "✓ pushed $branch → open the pull request: $url"
|
|
203
|
+
else echo "✓ pushed $branch (no forge: open the pull request on your forge, $branch → $base)"; fi
|
|
204
|
+
return 0
|
|
199
205
|
fi
|
|
206
|
+
url="$(gh_rest_pr_url_for_head "$repo" "$branch" 2>/dev/null || true)"
|
|
200
207
|
if [ -n "$url" ]; then
|
|
201
208
|
echo "[hotfix] a PR is already open for $branch" >&2
|
|
202
209
|
echo "✓ $url"
|
|
@@ -206,11 +213,6 @@ kto_hotfix() {
|
|
|
206
213
|
body="$(printf 'Cherry-pick of #%s onto `%s`.\n\nSource commits (rebase-merged, oldest first):\n%s' "$pr" "$base" "$picks")"
|
|
207
214
|
elif [ -n "$pr" ]; then body="$(printf 'Cherry-pick of #%s onto `%s`.\n\nSource commit: %s' "$pr" "$base" "$sha")"
|
|
208
215
|
else body="$(printf 'Cherry-pick of %s onto `%s`.' "$sha" "$base")"; fi
|
|
209
|
-
|
|
210
|
-
url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$title" "$body" "" "")" || return 1
|
|
211
|
-
else
|
|
212
|
-
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" \
|
|
213
|
-
--title "$title" --body "$body" --assignee "@me")" || return 1
|
|
214
|
-
fi
|
|
216
|
+
url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$title" "$body" "" "")" || return 1
|
|
215
217
|
echo "✓ $url"
|
|
216
218
|
}
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
# Requires: jq.
|
|
23
23
|
# errors: pure — the deriving half: catalog, context, render, apply — no side effects
|
|
24
24
|
|
|
25
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
26
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
27
|
+
# shellcheck source=/dev/null
|
|
28
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
29
|
+
fi
|
|
30
|
+
|
|
25
31
|
_kit_iv_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
26
32
|
# shellcheck source=/dev/null
|
|
27
33
|
. "$_kit_iv_dir/kit-cli.sh" # kit_is_main, kit_say/warn/die
|
|
@@ -159,7 +159,7 @@ if [ -n "${KL_TEST_INNER:-}" ]; then
|
|
|
159
159
|
eq "empty exits 0" "$erc" "0"
|
|
160
160
|
has "empty has a graceful state" "$eout" 'no `.sh` helpers'
|
|
161
161
|
|
|
162
|
-
eq "help lists the flags" "$(KIT_LIB_DIR="$fix" kit_lib --help | grep -c '^cckit lib')" "5"
|
|
162
|
+
eq "help lists the flags" "$(KIT_LIB_DIR="$fix" kit_lib --help | grep -c '^cckit agent lib')" "5"
|
|
163
163
|
|
|
164
164
|
if command -v jq >/dev/null 2>&1; then
|
|
165
165
|
llm="$(KIT_LIB_DIR="$fix" CCKIT_OUTPUT=json kit_lib --llm)"
|
package/scripts/lib/kit-lib.sh
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
# functions its PUBLIC functions (`_`-prefixed names are private by convention, so they are cut)
|
|
11
11
|
# purpose the file's own header sentence — derived, never invented
|
|
12
12
|
#
|
|
13
|
-
# cckit lib
|
|
14
|
-
# cckit lib --
|
|
15
|
-
# cckit lib --all
|
|
16
|
-
# cckit lib --reasons
|
|
17
|
-
# cckit lib --root <dir>
|
|
13
|
+
# cckit agent lib the helper catalog as a markdown table
|
|
14
|
+
# cckit agent lib --json TOON rows {file,errors,functions,purpose} (JSON fallback)
|
|
15
|
+
# cckit agent lib --all include the *-test.sh runners (excluded by default)
|
|
16
|
+
# cckit agent lib --reasons every file's failure reason, not only the `mixed` ones
|
|
17
|
+
# cckit agent lib --root <dir> catalog <dir>'s library instead of the resolved one
|
|
18
18
|
#
|
|
19
19
|
# Filesystem-only — no network, no gh; jq only for --llm (TOON/JSON). Runs in any project cckit is
|
|
20
20
|
# installed in: it catalogs that project's own scripts/lib when it has one, otherwise the cckit
|
|
@@ -216,7 +216,7 @@ kit_lib_dir() {
|
|
|
216
216
|
# ── the verb ──────────────────────────────────────────────────────────────────────────────────
|
|
217
217
|
|
|
218
218
|
# _kl_usage — the usage block, read back from this file's own header (one source of truth).
|
|
219
|
-
_kl_usage() { sed -n 's/^# \(cckit lib.*\)$/\1/p' "${BASH_SOURCE[0]:-$0}"; }
|
|
219
|
+
_kl_usage() { sed -n 's/^# \(cckit agent lib.*\)$/\1/p' "${BASH_SOURCE[0]:-$0}"; }
|
|
220
220
|
|
|
221
221
|
# _kl_err — structured error for --llm mode (mirrors the other verbs' failure shape).
|
|
222
222
|
_kl_err() { printf '{"error":"lib: %s"}\n' "$1"; }
|
|
@@ -226,7 +226,7 @@ kit_lib() {
|
|
|
226
226
|
local out="${CCKIT_OUTPUT:-human}" root="" all=0 reasons=0
|
|
227
227
|
while [ "$#" -gt 0 ]; do
|
|
228
228
|
case "$1" in
|
|
229
|
-
--llm|--output=json) out="json"; shift ;;
|
|
229
|
+
--json|--llm|--output=json) out="json"; shift ;;
|
|
230
230
|
--all) all=1; shift ;;
|
|
231
231
|
--reasons) reasons=1; shift ;;
|
|
232
232
|
--root) # Validate BEFORE shifting: `shift 2` on a single remaining argument aborts bash
|
package/scripts/lib/kit-msg.sh
CHANGED
|
@@ -56,7 +56,7 @@ msg_send() {
|
|
|
56
56
|
local steer=0
|
|
57
57
|
[ "${1:-}" = "--steer" ] && { steer=1; shift; }
|
|
58
58
|
local text="$*"
|
|
59
|
-
[ -n "$target" ] && [ -n "$text" ] || { echo 'msg_send: usage: cckit msg send <branch|all|project:branch|project:all> [--steer] "<text>"' >&2; return 1; }
|
|
59
|
+
[ -n "$target" ] && [ -n "$text" ] || { echo 'msg_send: usage: cckit agent msg send <branch|all|project:branch|project:all> [--steer] "<text>"' >&2; return 1; }
|
|
60
60
|
_msg_parse "$target" || { echo "msg_send: bad target '$target'" >&2; return 1; }
|
|
61
61
|
local from_proj from_branch
|
|
62
62
|
from_proj="$(_msg_proj)"; from_branch="$(_msg_branch)"; from_branch="${from_branch:-unknown}"
|
|
@@ -64,7 +64,7 @@ msg_send() {
|
|
|
64
64
|
# A typo'd target would silently create a dead mailbox (hcom hard-fails here; we warn) — flag a
|
|
65
65
|
# first-time mailbox so a misaddressed steer doesn't just vanish.
|
|
66
66
|
[ -d "$(dirname "$box")" ] || [ "$_MSG_BOX" = "all" ] \
|
|
67
|
-
|| echo " ⚠ new mailbox $_MSG_PROJ:$_MSG_BOX — no session has mail here yet; check the target if you expected one (cckit msg list)" >&2
|
|
67
|
+
|| echo " ⚠ new mailbox $_MSG_PROJ:$_MSG_BOX — no session has mail here yet; check the target if you expected one (cckit agent msg list)" >&2
|
|
68
68
|
mkdir -p "$box" || return 1
|
|
69
69
|
local kind="note"; [ "$steer" = 1 ] && kind="steer"
|
|
70
70
|
# epoch-$$ alone collides for two sends in the same second from one shell — the second message
|
|
@@ -204,7 +204,7 @@ EOF_UNREAD
|
|
|
204
204
|
fi
|
|
205
205
|
[ "$count" -gt 0 ] || return 0
|
|
206
206
|
|
|
207
|
-
local msg="SESSION MAIL (cckit msg): a parallel session sent you the message(s) below. If one is kind: steer, act on it BEFORE continuing your current plan.
|
|
207
|
+
local msg="SESSION MAIL (cckit agent msg): a parallel session sent you the message(s) below. If one is kind: steer, act on it BEFORE continuing your current plan.
|
|
208
208
|
$body"
|
|
209
209
|
local esc; esc="$(printf '%s' "$msg" | _msg_json_escape)"
|
|
210
210
|
if [ "$event" = "Stop" ]; then
|