@jeiemgi/cckit 0.8.0 → 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/README.md +14 -0
- package/bin/cckit +8 -4
- package/cckit.config.json +1 -1
- package/package.json +1 -1
- package/scripts/guard-raw-git-ops-test.sh +8 -0
- package/scripts/lib/effort-metrics.sh +14 -1
- package/scripts/lib/effort-ops-test.sh +12 -0
- package/scripts/lib/effort-ops.sh +88 -11
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +11 -1
- 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/kit-gc.sh +21 -3
- package/scripts/lib/kit-task-ops.sh +190 -61
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +63 -6
- package/scripts/lib/test-env-test.sh +3 -3
- package/scripts/lib/test-env.sh +7 -4
- package/scripts/lib/worktree-issue.sh +14 -0
- package/scripts/lib/worktree-start.sh +16 -1
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +19 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cckit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"installationPreference": "beta",
|
|
5
5
|
"description": "cckit — a project operating system for coding agents. The full GitHub work lifecycle (start/pr/close/sync, efforts, worktrees, orchestrate, gc) as agents + skills + rules, drivable by Claude Code and any other agent. Driven from cckit.config.json; no org or repo hardcoded.",
|
|
6
6
|
"author": {
|
package/README.md
CHANGED
|
@@ -237,6 +237,20 @@ transcript, pipe-safe everywhere. Every human-facing verb (`sync`, `plan`, `next
|
|
|
237
237
|
one rendering seam, so board tables, wave plans, and the status dashboard read the same in every
|
|
238
238
|
surface and never leak escape codes down a pipe (`cckit render` exposes the seam for any script).
|
|
239
239
|
|
|
240
|
+
### Cloud sessions
|
|
241
|
+
|
|
242
|
+
Claude Code cloud sessions reach GitHub through a proxy that refuses GraphQL, and `gh pr` /
|
|
243
|
+
`gh issue` use GraphQL. There cckit switches to REST (`gh api repos/<owner>/<repo>/…`):
|
|
244
|
+
|
|
245
|
+
- **Works:** `cckit pr`, `merge`, `close`, `new`, `effort new`, `effort pr`, `effort close`, plus
|
|
246
|
+
the issue reads behind `start` and `effort start`.
|
|
247
|
+
- **Skipped:** board (Projects v2) steps, with one line on stderr: `cckit: board step skipped …`.
|
|
248
|
+
Turn on the board's built-in workflows (item closed → Done, PR merged → Done, auto-add) and the
|
|
249
|
+
card still moves. Remote branch deletion is skipped too: the proxy rejects it. Delete merged
|
|
250
|
+
branches on GitHub.
|
|
251
|
+
- **Switch:** `CCKIT_GH_TRANSPORT=rest|graphql` forces a transport. Unset, it is `rest` when
|
|
252
|
+
`CLAUDE_CODE_REMOTE=true` and the `gh` subcommands otherwise.
|
|
253
|
+
|
|
240
254
|
## cckit builds cckit
|
|
241
255
|
|
|
242
256
|
None of this is theoretical. cckit is developed *with* cckit — every feature, fix, and tutorial went
|
package/bin/cckit
CHANGED
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
# cckit init --profile <p> scaffold cckit.config.json + .claude/ (--profile required)
|
|
11
11
|
# cckit start <issue> [slug] isolated worktree + branch for an issue
|
|
12
12
|
# cckit pr <issue> <summary> commit + push + open the PR
|
|
13
|
-
# cckit close <issue> <summary>
|
|
13
|
+
# cckit close <issue> <summary> [--reason completed|not-planned|duplicate] [--duplicate-of N]
|
|
14
|
+
# [--superseded-by N] close the issue with a reason + summary comment; board Done
|
|
14
15
|
# cckit new [--role R --kind K --priority P --milestone M --blocked-by "#1" --body B|--body-file F] "<title>"
|
|
15
16
|
# file ONE issue: labels + board (Todo) in one step (never raw gh issue create)
|
|
16
|
-
# cckit merge [<pr>]
|
|
17
|
+
# cckit merge [<pr>] [--merge|--rebase] merge the PR (squash by default; rebases on conflict), close
|
|
18
|
+
# its issues, GC the branch, update the PR's base (develop or effort/<N>)
|
|
17
19
|
# cckit contribute "<summary>" open a contribution PR to cckit, gated on scripts/check.sh
|
|
18
20
|
# (from the cckit checkout or worktree you are in; else the installed one)
|
|
19
21
|
# cckit sync [--llm] board state / what's unblocked
|
|
@@ -179,6 +181,8 @@ case "$cmd" in
|
|
|
179
181
|
source "$LIB/kit-config.sh" && load_kit_config
|
|
180
182
|
# shellcheck source=/dev/null
|
|
181
183
|
source "$LIB/role-identity.sh"; source "$LIB/gh-project.sh"; source "$LIB/kit-task-ops.sh"
|
|
184
|
+
if [ "$cmd" = close ]; then case "${1:-}" in -h|--help)
|
|
185
|
+
echo 'cckit close <issue> ["<summary>"] [--reason completed|not-planned|duplicate] [--duplicate-of N] [--superseded-by N]'; exit 0 ;; esac; fi
|
|
182
186
|
if cckit_is_json; then
|
|
183
187
|
case "$cmd" in
|
|
184
188
|
pr) out="$(kto_task_pr "$@" 2>&1)"; rc=$? ;;
|
|
@@ -231,14 +235,14 @@ case "$cmd" in
|
|
|
231
235
|
kto_task_new "$n_title" "$n_role" "$n_kind" "$n_prio" "$n_ms" "$n_plan" "$n_blocked" "$n_body"; echo
|
|
232
236
|
;;
|
|
233
237
|
merge)
|
|
234
|
-
#
|
|
238
|
+
# Merge (squash by default, --merge / --rebase, #376) through kto_task_pr_merge: rebase on conflict, close the PR's linked issues (native
|
|
235
239
|
# auto-close only fires on the default branch), then clean the branch + worktree. The verb behind
|
|
236
240
|
# every raw `gh pr merge` (#361). An effort's PR merges with `cckit effort close <N>`.
|
|
237
241
|
# shellcheck source=/dev/null
|
|
238
242
|
source "$LIB/kit-config.sh" && load_kit_config
|
|
239
243
|
# shellcheck source=/dev/null
|
|
240
244
|
source "$LIB/role-identity.sh"; source "$LIB/gh-project.sh"; source "$LIB/kit-task-ops.sh"
|
|
241
|
-
case "${1:-}" in -h|--help) echo 'cckit merge [<pr>]
|
|
245
|
+
case "${1:-}" in -h|--help) echo 'cckit merge [<pr>] [--squash|--merge|--rebase] merge (squash by default; rebases on conflict), close linked issues, GC branch + worktree, update the PR base'; exit 0 ;; esac
|
|
242
246
|
kto_task_pr_merge "$@"
|
|
243
247
|
;;
|
|
244
248
|
sync) exec "$ROOT/scripts/task-sync.sh" "$@" ;;
|
package/cckit.config.json
CHANGED
package/package.json
CHANGED
|
@@ -41,6 +41,14 @@ git -C "$kit" checkout -q develop
|
|
|
41
41
|
out="$(jq -n --arg c 'gh issue create -t x' --arg d "$kit" '{tool_input:{command:$c},cwd:$d}' | bash "$HOOK" 2>&1)"
|
|
42
42
|
case "$out" in *"cckit new --role"*) echo "ok: the block names the verb to run" ;; *) echo "FAIL: no verb hint in: $out"; fail=1 ;; esac
|
|
43
43
|
|
|
44
|
+
# #376/#377: the hint names the verb flag matching the raw command's flag
|
|
45
|
+
hint() { jq -n --arg c "$1" --arg d "$kit" '{tool_input:{command:$c},cwd:$d}' | bash "$HOOK" 2>&1 | sed -n 's/^Run instead: //p'; }
|
|
46
|
+
case "$(hint 'gh pr merge 5 --merge')" in "cckit merge [<pr>] --merge"*) echo "ok: gh pr merge --merge -> cckit merge --merge" ;; *) echo "FAIL: merge hint: $(hint 'gh pr merge 5 --merge')"; fail=1 ;; esac
|
|
47
|
+
case "$(hint 'gh pr merge 5 --rebase')" in "cckit merge [<pr>] --rebase"*) echo "ok: gh pr merge --rebase -> cckit merge --rebase" ;; *) echo "FAIL: rebase hint"; fail=1 ;; esac
|
|
48
|
+
case "$(hint 'gh issue close 9 --duplicate-of 4')" in "cckit close <issue> --duplicate-of 4"*) echo "ok: gh issue close --duplicate-of N -> cckit close --duplicate-of N" ;; *) echo "FAIL: duplicate hint: $(hint 'gh issue close 9 --duplicate-of 4')"; fail=1 ;; esac
|
|
49
|
+
case "$(hint 'gh issue close 9 --reason "not planned"')" in *"--reason not-planned"*) echo "ok: gh issue close --reason 'not planned' -> --reason not-planned" ;; *) echo "FAIL: not-planned hint"; fail=1 ;; esac
|
|
50
|
+
t "gh issue close --help is not blocked" "$(run "$kit" 'gh issue close --help')" 0
|
|
51
|
+
|
|
44
52
|
t "KIT_ALLOW_RAW=1 lets one command through" "$(run "$kit" 'KIT_ALLOW_RAW=1 gh pr create --fill')" 0
|
|
45
53
|
t "the bypass is recorded" "$(grep -c 'pr-create' "$kit/.git/cckit/raw-bypass.log" 2>/dev/null)" 1
|
|
46
54
|
|
|
@@ -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 '
|
|
@@ -33,6 +33,7 @@ case "$1 $2" in
|
|
|
33
33
|
*) echo "[Effort] 99 · demo effort" ;; # --json title -q .title
|
|
34
34
|
esac ;;
|
|
35
35
|
"pr create") echo "https://github.com/o/r/pull/7" ;;
|
|
36
|
+
"pr view") echo "${GH_MERGEABLE:-MERGEABLE}" ;; # --json mergeable (#394)
|
|
36
37
|
"pr diff") # a merged sub PR's diff (wave-style close, #164): one kit-managed + one app file
|
|
37
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' ;;
|
|
38
39
|
"api "*|"api")
|
|
@@ -135,6 +136,17 @@ echo "kit-managed" > .claude/skills/demo.md # a kit-managed path → the drift
|
|
|
135
136
|
git -c user.email=t@t -c user.name=t add file.txt .claude/skills/demo.md
|
|
136
137
|
git -c user.email=t@t -c user.name=t commit -q -m "feat: do the thing (#101)"
|
|
137
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
|
+
|
|
138
150
|
# #148: the VERB sets board Status=Done (guarded). Stub the board helpers + captured ids in-shell —
|
|
139
151
|
# _eo_source_board must see them and skip sourcing the real gh-project.sh.
|
|
140
152
|
BOARD_LOG="$tmp/board.log"; : > "$BOARD_LOG"
|
|
@@ -28,6 +28,16 @@ if ! command -v effort_slug_resolve >/dev/null 2>&1; then
|
|
|
28
28
|
unset _eo_dir
|
|
29
29
|
fi
|
|
30
30
|
|
|
31
|
+
# The GitHub transport switch (#396): in rest mode the lifecycle calls below are `gh api repos/…`.
|
|
32
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
33
|
+
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
34
|
+
# shellcheck source=/dev/null
|
|
35
|
+
[ -f "$_eo_dir/gh-rest.sh" ] && . "$_eo_dir/gh-rest.sh"
|
|
36
|
+
unset _eo_dir
|
|
37
|
+
fi
|
|
38
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
39
|
+
command -v cckit_board_skipped >/dev/null 2>&1 || cckit_board_skipped() { return 1; }
|
|
40
|
+
|
|
31
41
|
_eff_repo() { printf '%s' "${EFFORT_REPO:-${KIT_REPO:-}}"; }
|
|
32
42
|
_eff_base() { printf '%s' "${KIT_BASE_BRANCH:-main}"; }
|
|
33
43
|
_eff_need() { command -v "$1" >/dev/null 2>&1 || { echo "effort: $1 is required" >&2; return 1; }; }
|
|
@@ -96,6 +106,7 @@ _eff_relations_add() {
|
|
|
96
106
|
# before `gh issue create --label` uses it (which fails hard on a missing label, #153). Idempotent:
|
|
97
107
|
# creating an existing label is a silent no-op.
|
|
98
108
|
_eff_ensure_label() {
|
|
109
|
+
if cckit_gh_rest; then gh_rest_label_create "$(_eff_repo)" "$1" "$2" "$3"; return 0; fi
|
|
99
110
|
gh label create "$1" --repo "$(_eff_repo)" --color "$2" \
|
|
100
111
|
--description "$3" >/dev/null 2>&1 || true
|
|
101
112
|
}
|
|
@@ -106,6 +117,7 @@ _eff_ensure_label() {
|
|
|
106
117
|
_eff_board_add() {
|
|
107
118
|
local n="$1" role="${2:-}" repo node item ropt
|
|
108
119
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
120
|
+
cckit_board_skipped && return 0
|
|
109
121
|
command -v project_add_item >/dev/null 2>&1 || return 0
|
|
110
122
|
repo="$(_eff_repo)"
|
|
111
123
|
node="$(gh api "repos/$repo/issues/$n" --jq .node_id 2>/dev/null)" || return 0
|
|
@@ -236,15 +248,24 @@ effort_new() {
|
|
|
236
248
|
fi
|
|
237
249
|
|
|
238
250
|
local url num slug
|
|
251
|
+
if cckit_gh_rest; then
|
|
252
|
+
url="$(gh_rest_issue_create "$repo" "[Effort] · ${flow_tag}${name}" "$body" "$labels" "$milestone" 0)" \
|
|
253
|
+
|| { echo "effort_new: failed to create the parent issue" >&2; return 1; }
|
|
254
|
+
else
|
|
239
255
|
url="$(gh issue create --repo "$repo" --title "[Effort] · ${flow_tag}${name}" --body "$body" \
|
|
240
256
|
--label "$labels" ${milestone:+--milestone "$milestone"})" \
|
|
241
257
|
|| { echo "effort_new: failed to create the parent issue" >&2; return 1; }
|
|
258
|
+
fi
|
|
242
259
|
num="${url##*/}"
|
|
243
|
-
|
|
260
|
+
if cckit_gh_rest; then gh_rest_issue_edit_title "$repo" "$num" "[Effort] $num · ${flow_tag}${name}" >/dev/null 2>&1
|
|
261
|
+
else gh issue edit "$num" --repo "$repo" --title "[Effort] $num · ${flow_tag}${name}" >/dev/null 2>&1; fi
|
|
244
262
|
# The human handle (#93): explicit --slug if given, else derived from the title (number/flow peeled).
|
|
245
263
|
if [ -n "$explicit_slug" ]; then slug="$(_eff_slug "$explicit_slug")"
|
|
246
264
|
else slug="$(_eff_title_slug "[Effort] $num · ${flow_tag}${name}")"; fi
|
|
247
|
-
if [ -n "$slug" ]; then
|
|
265
|
+
if [ -n "$slug" ] && cckit_gh_rest; then
|
|
266
|
+
gh_rest_label_create "$repo" "slug:$slug" ededed "effort slug handle"
|
|
267
|
+
gh_rest_issue_add_labels "$repo" "$num" "slug:$slug" >/dev/null 2>&1 || true
|
|
268
|
+
elif [ -n "$slug" ]; then
|
|
248
269
|
gh label create "slug:$slug" --repo "$repo" --color ededed \
|
|
249
270
|
--description "effort slug handle" >/dev/null 2>&1 || true # idempotent: ok if it exists
|
|
250
271
|
gh issue edit "$num" --repo "$repo" --add-label "slug:$slug" >/dev/null 2>&1 || true
|
|
@@ -271,9 +292,14 @@ effort_new() {
|
|
|
271
292
|
sub_title="[Effort $num] $i · $sub_name"
|
|
272
293
|
local sub_labels="kind:task,priority:$priority"
|
|
273
294
|
[ -n "$role" ] && sub_labels="$sub_labels,role:$role"
|
|
295
|
+
if cckit_gh_rest; then
|
|
296
|
+
child="$(gh_rest_issue_create "$repo" "$sub_title" \
|
|
297
|
+
"$(printf '%s\n\nSub-issue of #%s (effort).' "$sub_desc" "$num")" "$sub_labels" "$milestone" 0)" || continue
|
|
298
|
+
else
|
|
274
299
|
child="$(gh issue create --repo "$repo" --title "$sub_title" \
|
|
275
300
|
--body "$(printf '%s\n\nSub-issue of #%s (effort).' "$sub_desc" "$num")" \
|
|
276
301
|
--label "$sub_labels" ${milestone:+--milestone "$milestone"})" || continue
|
|
302
|
+
fi
|
|
277
303
|
child_num="${child##*/}"
|
|
278
304
|
effort_link_sub "$num" "$child_num" || true
|
|
279
305
|
_eff_board_add "$child_num" "$role" || true
|
|
@@ -291,6 +317,17 @@ _eo_source_effort() {
|
|
|
291
317
|
[ -f "$d/effort.sh" ] && . "$d/effort.sh"
|
|
292
318
|
}
|
|
293
319
|
|
|
320
|
+
# _eff_issue_body <repo> <n> / _eff_issue_set_body <repo> <n> <body> — read and replace an issue
|
|
321
|
+
# body on the chosen transport (#396). A failed read returns non-zero, never an empty body.
|
|
322
|
+
_eff_issue_body() {
|
|
323
|
+
if cckit_gh_rest; then gh api "repos/$1/issues/$2" --jq '.body // ""'
|
|
324
|
+
else gh issue view "$2" --repo "$1" --json body --jq .body; fi
|
|
325
|
+
}
|
|
326
|
+
_eff_issue_set_body() {
|
|
327
|
+
if cckit_gh_rest; then gh_rest_issue_set_body "$1" "$2" "$3"
|
|
328
|
+
else gh issue edit "$2" --repo "$1" --body "$3"; fi
|
|
329
|
+
}
|
|
330
|
+
|
|
294
331
|
# _eff_blockers <issue> — echo the issue's CURRENT blocked_by numbers, one per line. Empty when the
|
|
295
332
|
# issue has no edges or the API call fails (the caller treats that as "no known edge").
|
|
296
333
|
_eff_blockers() {
|
|
@@ -401,13 +438,13 @@ effort_chain() {
|
|
|
401
438
|
|
|
402
439
|
# A FAILED read is not an empty body: writing the composed body after a failed fetch would
|
|
403
440
|
# wipe the issue. Only a successful read is edited.
|
|
404
|
-
if ! body="$(
|
|
441
|
+
if ! body="$(_eff_issue_body "$repo" "$next" 2>/dev/null)"; then
|
|
405
442
|
echo " ✗ could not read #$next's body — 'Depends on #$prev' not recorded" >&2; rc=1
|
|
406
443
|
elif printf '%s\n' "$body" | grep -qE "^[[:space:]]*- Depends on #${prev}[[:space:]]*$"; then
|
|
407
444
|
echo " · #$next already records 'Depends on #$prev'" >&2
|
|
408
445
|
else
|
|
409
446
|
newbody="$(_eff_relations_add "$body" "$prev")"
|
|
410
|
-
|
|
447
|
+
_eff_issue_set_body "$repo" "$next" "$newbody" >/dev/null 2>&1 \
|
|
411
448
|
&& echo " ✓ #$next records 'Depends on #$prev'" >&2 \
|
|
412
449
|
|| { echo " ✗ could not update #$next's body" >&2; rc=1; }
|
|
413
450
|
fi
|
|
@@ -620,7 +657,8 @@ effort_start() {
|
|
|
620
657
|
|
|
621
658
|
if [ -n "$slug_override" ]; then slug="$(_eff_slug "$slug_override")"
|
|
622
659
|
else
|
|
623
|
-
title="$(gh
|
|
660
|
+
if cckit_gh_rest; then title="$(gh api "repos/$repo/issues/$num" --jq .title 2>/dev/null)" || title=""
|
|
661
|
+
else title="$(gh issue view "$num" --repo "$repo" --json title -q .title 2>/dev/null)"; fi
|
|
624
662
|
slug="$(_eff_title_slug "${title:-effort}")"; [ -n "$slug" ] || slug="effort"
|
|
625
663
|
fi
|
|
626
664
|
# Worktree dir follows the kind+N-slug convention (branch-naming.md) so kit-gc's issue-open
|
|
@@ -684,7 +722,8 @@ effort_pr() {
|
|
|
684
722
|
case "$branch" in effort/"$num"-*) : ;; *) echo "effort_pr: current branch ($branch) is not effort/$num-…" >&2; return 1 ;; esac
|
|
685
723
|
|
|
686
724
|
# Parent metadata: the PR inherits its labels + milestone, and the role names the title.
|
|
687
|
-
meta="$(
|
|
725
|
+
if cckit_gh_rest; then meta="$(gh_rest_issue_json "$repo" "$num" 2>/dev/null)"
|
|
726
|
+
else meta="$(gh issue view "$num" --repo "$repo" --json title,labels,milestone 2>/dev/null)"; fi
|
|
688
727
|
title="$(printf '%s' "$meta" | jq -r '.title // ""' 2>/dev/null)"
|
|
689
728
|
labels="$(printf '%s' "$meta" | jq -r '[.labels[]?.name] | join(",")' 2>/dev/null)"
|
|
690
729
|
milestone="$(printf '%s' "$meta" | jq -r '.milestone.title // ""' 2>/dev/null)"
|
|
@@ -727,7 +766,9 @@ effort_pr() {
|
|
|
727
766
|
|
|
728
767
|
# Four explicit forms, not ${x:+--flag "$x"}: that idiom word-splits under zsh, and this file is
|
|
729
768
|
# sourced from zsh too.
|
|
730
|
-
if
|
|
769
|
+
if cckit_gh_rest; then
|
|
770
|
+
url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$pr_title" "$body" "$labels" "$milestone")" || return 1
|
|
771
|
+
elif [ -n "$labels" ] && [ -n "$milestone" ]; then
|
|
731
772
|
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" --title "$pr_title" --body "$body" \
|
|
732
773
|
--label "$labels" --milestone "$milestone" --assignee "@me")" || return 1
|
|
733
774
|
elif [ -n "$labels" ]; then
|
|
@@ -765,6 +806,7 @@ _eff_pr_body() {
|
|
|
765
806
|
_eff_pr_board() {
|
|
766
807
|
local num="$1" url="$2" role="${3:-}" repo pr_num node item ropt parent
|
|
767
808
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
809
|
+
cckit_board_skipped && return 0
|
|
768
810
|
_eo_source_board
|
|
769
811
|
command -v project_add_item >/dev/null 2>&1 || return 0
|
|
770
812
|
repo="$(_eff_repo)"; pr_num="${url##*/}"
|
|
@@ -815,6 +857,7 @@ _eo_source_gc() {
|
|
|
815
857
|
# gh-project.sh or ids file degrades to a no-op (the board steps below are themselves guarded).
|
|
816
858
|
_eo_source_board() {
|
|
817
859
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
860
|
+
cckit_board_skipped && return 0
|
|
818
861
|
if ! command -v project_find_item_by_issue >/dev/null 2>&1; then
|
|
819
862
|
local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
820
863
|
# shellcheck source=/dev/null
|
|
@@ -826,12 +869,19 @@ _eo_source_board() {
|
|
|
826
869
|
return 0
|
|
827
870
|
}
|
|
828
871
|
|
|
872
|
+
# _eo_issue_close_completed <repo> <n> — close as completed on the chosen transport (#396), quietly.
|
|
873
|
+
_eo_issue_close_completed() {
|
|
874
|
+
if cckit_gh_rest; then gh_rest_issue_close "$1" "$2" completed >/dev/null 2>&1
|
|
875
|
+
else gh issue close "$2" --repo "$1" --reason completed >/dev/null 2>&1; fi
|
|
876
|
+
}
|
|
877
|
+
|
|
829
878
|
# _eo_board_done <issue #> — set the board Status=Done for one issue. Guarded like _eff_board_add:
|
|
830
879
|
# a no-op unless Projects v2 is on AND the board helpers + field ids are loaded. Best-effort — a
|
|
831
880
|
# board hiccup never fails the close (the merge already landed).
|
|
832
881
|
_eo_board_done() {
|
|
833
882
|
local n="$1" item
|
|
834
883
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
884
|
+
cckit_board_skipped && return 0
|
|
835
885
|
command -v project_find_item_by_issue >/dev/null 2>&1 || return 0
|
|
836
886
|
[ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_DONE:-}" ] || return 0
|
|
837
887
|
item="$(project_find_item_by_issue "$n" 2>/dev/null)" || return 0
|
|
@@ -915,6 +965,21 @@ effort_close() {
|
|
|
915
965
|
fi
|
|
916
966
|
fi
|
|
917
967
|
|
|
968
|
+
# (a2) refuse a conflicting PR before anything is written (#394). The capture below appends a
|
|
969
|
+
# records.jsonl row and consumes the effort's start marker, so a merge that fails after it leaves a
|
|
970
|
+
# row the retry duplicates with build_seconds null. UNKNOWN (GitHub still computing) proceeds.
|
|
971
|
+
local rest_pr="" mergeable
|
|
972
|
+
if cckit_gh_rest; then
|
|
973
|
+
rest_pr="$(gh_rest_pr_for_head "$repo" "$branch" 2>/dev/null)"
|
|
974
|
+
mergeable=""; [ -n "$rest_pr" ] && mergeable="$(gh_rest_pr_json "$repo" "$rest_pr" 2>/dev/null | jq -r .mergeable)"
|
|
975
|
+
else
|
|
976
|
+
mergeable="$(gh pr view "$branch" --repo "$repo" --json mergeable -q .mergeable 2>/dev/null)"
|
|
977
|
+
fi
|
|
978
|
+
if [ "$mergeable" = "CONFLICTING" ]; then
|
|
979
|
+
echo "effort_close: the PR for $branch conflicts with $base — merge or rebase $base into it, then rerun (nothing was written)" >&2
|
|
980
|
+
return 1
|
|
981
|
+
fi
|
|
982
|
+
|
|
918
983
|
# (b) capture effort metrics PRE-squash (needs the live-branch diff + commit signals).
|
|
919
984
|
command -v capture_effort_metrics >/dev/null 2>&1 && capture_effort_metrics "$num" "origin/$base" || true
|
|
920
985
|
|
|
@@ -923,10 +988,18 @@ effort_close() {
|
|
|
923
988
|
kit_touched="$(git diff --name-only "origin/$base"...HEAD 2>/dev/null \
|
|
924
989
|
| grep -E "$_EO_KIT_MANAGED_RE" | sort -u || true)"
|
|
925
990
|
|
|
926
|
-
# (c) squash-merge the effort PR.
|
|
991
|
+
# (c) squash-merge the effort PR. Over REST the remote branch stays: the cloud proxy rejects branch
|
|
992
|
+
# deletion (#396).
|
|
993
|
+
if cckit_gh_rest; then
|
|
994
|
+
{ [ -n "$rest_pr" ] && gh_rest_pr_merge "$repo" "$rest_pr" squash >/dev/null 2>&1; } \
|
|
995
|
+
|| { echo "effort_close: could not squash-merge the PR for $branch (open? mergeable?)" >&2; return 1; }
|
|
996
|
+
echo " ✓ merged $branch" >&2
|
|
997
|
+
echo " (remote branch $branch kept — branch deletion is unavailable here; delete it on GitHub)" >&2
|
|
998
|
+
else
|
|
927
999
|
gh pr merge "$branch" --repo "$repo" --squash --delete-branch >/dev/null 2>&1 \
|
|
928
1000
|
|| { echo "effort_close: could not squash-merge the PR for $branch (open? mergeable?)" >&2; return 1; }
|
|
929
1001
|
echo " ✓ merged $branch" >&2
|
|
1002
|
+
fi
|
|
930
1003
|
|
|
931
1004
|
# (d) judge + sync the metrics (judge reads the durable trace dir; sync no-ops when the engine is off).
|
|
932
1005
|
command -v judge_effort_metrics >/dev/null 2>&1 && judge_effort_metrics "$num" "origin/$base" || true
|
|
@@ -939,10 +1012,10 @@ effort_close() {
|
|
|
939
1012
|
local sub
|
|
940
1013
|
while IFS= read -r sub; do
|
|
941
1014
|
[ -n "$sub" ] || continue
|
|
942
|
-
|
|
1015
|
+
_eo_issue_close_completed "$repo" "$sub" && echo " ✓ closed sub #$sub" >&2
|
|
943
1016
|
_eo_board_done "$sub"
|
|
944
1017
|
done < <(gh api "repos/$repo/issues/$num/sub_issues" --jq '.[].number' 2>/dev/null)
|
|
945
|
-
|
|
1018
|
+
_eo_issue_close_completed "$repo" "$num" && echo " ✓ closed effort #$num" >&2
|
|
946
1019
|
_eo_board_done "$num"
|
|
947
1020
|
|
|
948
1021
|
# (f) GC: switch the main checkout to base, remove the effort worktree, delete the local branch,
|
|
@@ -1005,6 +1078,9 @@ _eo_close_wave() {
|
|
|
1005
1078
|
|
|
1006
1079
|
# (a) read every sub + the merged PR that closed it, one "sub|state|pr|merge-oid|title" line each
|
|
1007
1080
|
# (title LAST so a stray "|" in it can't shift the fields awk/read split on).
|
|
1081
|
+
if cckit_gh_rest; then
|
|
1082
|
+
rows="$(gh_rest_wave_rows "$repo" "$num" 2>/dev/null)"
|
|
1083
|
+
else
|
|
1008
1084
|
rows="$(gh api graphql -f query='
|
|
1009
1085
|
query($o:String!,$r:String!,$n:Int!){ repository(owner:$o,name:$r){ issue(number:$n){
|
|
1010
1086
|
subIssues(first:50){ nodes { number state
|
|
@@ -1013,6 +1089,7 @@ _eo_close_wave() {
|
|
|
1013
1089
|
.data.repository.issue.subIssues.nodes[]
|
|
1014
1090
|
| (((.closedByPullRequestsReferences.nodes // []) | map(select(.merged)) | .[0]) // null) as $pr
|
|
1015
1091
|
| "\(.number)|\(.state)|\($pr.number // "")|\($pr.mergeCommit.oid // "")|\($pr.title // "")"' 2>/dev/null)"
|
|
1092
|
+
fi
|
|
1016
1093
|
[ -n "$rows" ] || { echo "effort_close: no effort/$num-… branch and no readable sub-issues — nothing to close (wave-style needs merged subs, #164)" >&2; return 1; }
|
|
1017
1094
|
|
|
1018
1095
|
# (b) every sub must be CLOSED with a merged closing PR — otherwise the effort is not done.
|
|
@@ -1049,7 +1126,7 @@ _eo_close_wave() {
|
|
|
1049
1126
|
for sub in $(printf '%s\n' "$rows" | cut -d'|' -f1); do
|
|
1050
1127
|
_eo_board_done "$sub"
|
|
1051
1128
|
done
|
|
1052
|
-
|
|
1129
|
+
_eo_issue_close_completed "$repo" "$num" && echo " ✓ closed effort #$num" >&2
|
|
1053
1130
|
_eo_board_done "$num"
|
|
1054
1131
|
|
|
1055
1132
|
# (g) GC: the sub branches/worktrees were GC'd by their own merges — just prune stragglers.
|
|
@@ -28,6 +28,15 @@
|
|
|
28
28
|
# errors: mixed — _eff_slug/effort_display are pure; effort_slug_resolve needs gh;
|
|
29
29
|
# effort_branch_rows_origin reaches the network and returns rc 1 when it cannot
|
|
30
30
|
|
|
31
|
+
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
32
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
33
|
+
_ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
|
|
34
|
+
# shellcheck source=/dev/null
|
|
35
|
+
[ -f "$_ghr_lib" ] && . "$_ghr_lib"
|
|
36
|
+
unset _ghr_lib
|
|
37
|
+
fi
|
|
38
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
39
|
+
|
|
31
40
|
# Repo for the gh fallback — resolved from the same env effort.sh/kit-config populate.
|
|
32
41
|
_eff_slug_repo() { printf '%s' "${EFFORT_REPO:-${KIT_REPO:-}}"; }
|
|
33
42
|
|
|
@@ -143,12 +152,17 @@ effort_slug_resolve() {
|
|
|
143
152
|
if [ -z "$matches" ] && command -v gh >/dev/null 2>&1; then
|
|
144
153
|
local repo; repo="$(_eff_slug_repo)"
|
|
145
154
|
if [ -n "$repo" ]; then
|
|
155
|
+
if cckit_gh_rest; then
|
|
156
|
+
matches="$(gh_rest_issue_numbers_by_label "$repo" "slug:$norm" 2>/dev/null | grep -E '^[0-9]+$' | sort -un)"
|
|
157
|
+
else
|
|
146
158
|
matches="$(gh issue list --repo "$repo" --state open --label "slug:$norm" \
|
|
147
159
|
--json number -q '.[].number' 2>/dev/null | grep -E '^[0-9]+$' | sort -un)"
|
|
160
|
+
fi
|
|
148
161
|
if [ -z "$matches" ]; then
|
|
149
162
|
local in it
|
|
150
|
-
matches="$(
|
|
151
|
-
|
|
163
|
+
matches="$( { if cckit_gh_rest; then gh_rest_open_issue_titles "$repo" | grep -F '[Effort]'
|
|
164
|
+
else gh issue list --repo "$repo" --state open --search '[Effort] in:title' --limit 200 \
|
|
165
|
+
--json number,title -q '.[] | "\(.number)\t\(.title)"'; fi; } 2>/dev/null \
|
|
152
166
|
| while IFS="$(printf '\t')" read -r in it; do
|
|
153
167
|
[ "$(_eff_title_slug "$it")" = "$norm" ] && printf '%s\n' "$in"
|
|
154
168
|
done | grep -E '^[0-9]+$' | sort -un)"
|
package/scripts/lib/effort.sh
CHANGED
|
@@ -15,6 +15,15 @@
|
|
|
15
15
|
# Requires: gh, jq, git. bash 3.2 compatible.
|
|
16
16
|
# errors: strict — git mechanics: a failed link, snapshot or lint propagates
|
|
17
17
|
|
|
18
|
+
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
19
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
20
|
+
_ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
|
|
21
|
+
# shellcheck source=/dev/null
|
|
22
|
+
[ -f "$_ghr_lib" ] && . "$_ghr_lib"
|
|
23
|
+
unset _ghr_lib
|
|
24
|
+
fi
|
|
25
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
26
|
+
|
|
18
27
|
# Repo resolves from kit.config.json (KIT_REPO) — load it if a caller hasn't already.
|
|
19
28
|
if [[ -z "${KIT_REPO:-}" ]]; then
|
|
20
29
|
_eff_root="$(git rev-parse --show-toplevel 2>/dev/null)"
|
|
@@ -150,7 +159,8 @@ effort_snapshot_merged_subs() {
|
|
|
150
159
|
seq=$((seq + 1))
|
|
151
160
|
short="$(printf '%.7s' "$oid")"; [[ -n "$short" ]] || short="pr$pr"
|
|
152
161
|
stub="$(printf '%02d-%s' "$seq" "$short")"
|
|
153
|
-
|
|
162
|
+
if cckit_gh_rest; then gh_rest_pr_diff "$EFFORT_REPO" "$pr" > "$dir/$stub.diff" 2>/dev/null || rm -f "$dir/$stub.diff"
|
|
163
|
+
else gh pr diff "$pr" --repo "$EFFORT_REPO" > "$dir/$stub.diff" 2>/dev/null || rm -f "$dir/$stub.diff"; fi
|
|
154
164
|
[[ -s "$dir/$stub.diff" ]] || { rm -f "$dir/$stub.diff"; seq=$((seq - 1)); continue; }
|
|
155
165
|
jq -c -n --arg parent "$parent" --arg sub "${sub:-}" --arg sha "${oid:-}" \
|
|
156
166
|
--arg subject "$title" --arg pr "$pr" --arg file "$stub.diff" \
|
|
@@ -24,6 +24,14 @@ if [ -f "$SCRIPT_DIR/lib/gh-log.sh" ]; then
|
|
|
24
24
|
fi
|
|
25
25
|
type gh_log >/dev/null 2>&1 || gh_log() { :; }
|
|
26
26
|
|
|
27
|
+
# The transport switch (#396): Projects v2 is GraphQL-only, so in rest mode (a cloud session) every
|
|
28
|
+
# board function below prints the one skip notice and returns 0 with no output.
|
|
29
|
+
if ! type cckit_board_skipped >/dev/null 2>&1 && [ -f "$SCRIPT_DIR/lib/gh-rest.sh" ]; then
|
|
30
|
+
# shellcheck source=gh-rest.sh
|
|
31
|
+
. "$SCRIPT_DIR/lib/gh-rest.sh"
|
|
32
|
+
fi
|
|
33
|
+
type cckit_board_skipped >/dev/null 2>&1 || cckit_board_skipped() { return 1; }
|
|
34
|
+
|
|
27
35
|
# Worktree-durable location for the captured project IDs (#532). The legacy
|
|
28
36
|
# scripts/.project-ids.env is gitignored + untracked, so it is ABSENT in every worktree —
|
|
29
37
|
# load_project_ids then no-ops and board updates silently fail (root cause of board drift).
|
|
@@ -39,6 +47,7 @@ PROJECT_ENV="$(_ghp_shared_env || printf '%s/.project-ids.env' "$SCRIPT_DIR")"
|
|
|
39
47
|
PROJECT_ENV_LEGACY="$SCRIPT_DIR/.project-ids.env" # pre-#532 per-checkout path
|
|
40
48
|
|
|
41
49
|
load_project_ids() {
|
|
50
|
+
cckit_board_skipped && return 0
|
|
42
51
|
# First run in a checkout that still has the legacy file: migrate it to the shared path.
|
|
43
52
|
if [[ ! -f "$PROJECT_ENV" && -f "$PROJECT_ENV_LEGACY" ]]; then
|
|
44
53
|
cp "$PROJECT_ENV_LEGACY" "$PROJECT_ENV" 2>/dev/null || PROJECT_ENV="$PROJECT_ENV_LEGACY"
|
|
@@ -53,6 +62,7 @@ load_project_ids() {
|
|
|
53
62
|
|
|
54
63
|
# Add an issue/PR (by node ID) to the project. Echoes the new item ID.
|
|
55
64
|
project_add_item() {
|
|
65
|
+
cckit_board_skipped && return 0
|
|
56
66
|
gh_log graphql mutation "project_add_item" "gh-project"
|
|
57
67
|
gh api graphql \
|
|
58
68
|
-f query='mutation($project:ID!, $content:ID!) {
|
|
@@ -64,6 +74,7 @@ project_add_item() {
|
|
|
64
74
|
|
|
65
75
|
# Set a single-select field. Args: <item_id> <field_id> <option_id>
|
|
66
76
|
project_set_single_select() {
|
|
77
|
+
cckit_board_skipped && return 0
|
|
67
78
|
gh_log graphql mutation "project_set_single_select" "gh-project"
|
|
68
79
|
gh api graphql \
|
|
69
80
|
-f query='mutation($project:ID!, $item:ID!, $field:ID!, $option:String!) {
|
|
@@ -77,6 +88,7 @@ project_set_single_select() {
|
|
|
77
88
|
|
|
78
89
|
# Set a text field. Args: <item_id> <field_id> <text>
|
|
79
90
|
project_set_text() {
|
|
91
|
+
cckit_board_skipped && return 0
|
|
80
92
|
gh_log graphql mutation "project_set_text" "gh-project"
|
|
81
93
|
gh api graphql \
|
|
82
94
|
-f query='mutation($project:ID!, $item:ID!, $field:ID!, $text:String!) {
|
|
@@ -181,6 +193,7 @@ _ghp_resolve_repo() {
|
|
|
181
193
|
# an issue's cards cheaply (O(1) per issue) whether the board is user- or org-owned, so this finder
|
|
182
194
|
# never paginates. An issue belongs to few projects, so first:20 covers it without a loop.
|
|
183
195
|
project_find_item_by_issue() {
|
|
196
|
+
cckit_board_skipped && return 0
|
|
184
197
|
local issue_num="$1"
|
|
185
198
|
local pnum="${2:-$(_ghp_resolve_pnum)}"
|
|
186
199
|
local repo owner name resp item_id
|
|
@@ -216,6 +229,7 @@ project_find_item_by_issue() {
|
|
|
216
229
|
# The cheap issue.projectItems lookup, same as project_find_item_by_issue. A claim precheck reads this
|
|
217
230
|
# before starting an issue so it can warn on a collision (another session already In Progress). #124.
|
|
218
231
|
project_issue_status() {
|
|
232
|
+
cckit_board_skipped && return 0
|
|
219
233
|
local issue_num="$1" pnum="${2:-$(_ghp_resolve_pnum)}" repo owner name resp
|
|
220
234
|
repo="$(_ghp_resolve_repo)"; owner="${repo%%/*}"; name="${repo##*/}"
|
|
221
235
|
[ -n "$owner" ] && [ -n "$name" ] && [ -n "$pnum" ] || return 1
|