@jeiemgi/cckit 0.11.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 +45 -41
- package/README.md +39 -29
- package/bin/cckit +111 -70
- package/cckit.config.json +1 -1
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot.sh +4 -4
- package/scripts/capture-project-ids.sh +16 -0
- package/scripts/check.sh +6 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/copilot-loop-test.sh +8 -8
- 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/init.sh +2 -2
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +5 -0
- package/scripts/kit-doctor.sh +96 -2
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +3 -2
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +1 -1
- package/scripts/lib/copilot-test.sh +4 -4
- package/scripts/lib/copilot.sh +13 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +2 -2
- package/scripts/lib/effort-ops-test.sh +98 -9
- package/scripts/lib/effort-ops.sh +390 -63
- package/scripts/lib/effort-parity-test.sh +37 -31
- package/scripts/lib/effort-plan.sh +3 -3
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +4 -0
- package/scripts/lib/effort-slug.sh +5 -4
- package/scripts/lib/effort.sh +47 -74
- package/scripts/lib/forge-github.sh +18 -7
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +115 -0
- package/scripts/lib/gh-project.sh +128 -6
- package/scripts/lib/gh-rest-test.sh +12 -8
- package/scripts/lib/gh-rest.sh +189 -15
- package/scripts/lib/git-core-test.sh +2 -2
- 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/kit-brief-test.sh +29 -0
- package/scripts/lib/kit-brief.sh +91 -6
- 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 +1 -1
- package/scripts/lib/kit-task-ops-test.sh +17 -0
- package/scripts/lib/kit-task-ops.sh +73 -22
- package/scripts/lib/kto-task-new-test.sh +18 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +44 -0
- package/scripts/lib/kto-task-pr-test.sh +3 -3
- package/scripts/lib/light-task.sh +16 -1
- 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 +1 -1
- package/scripts/lib/next.sh +6 -6
- package/scripts/lib/plan-machine.sh +9 -9
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/qa-lane.sh +1 -1
- 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 +132 -0
- package/scripts/lib/stage-receipt.sh +184 -5
- package/scripts/lib/test-forge-shim.sh +2 -1
- package/scripts/lib/verbs.sh +1 -1
- package/scripts/lib/verbs.tsv +17 -15
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-start.sh +42 -1
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/night-grant.sh +1 -1
- package/scripts/portable-test.sh +1 -1
- package/scripts/status-test.sh +1 -1
- package/scripts/status.sh +4 -4
- package/scripts/task-sync-test.sh +34 -0
- package/scripts/task-sync.sh +81 -1
- package/scripts/terms-check.sh +1 -1
- package/scripts/verbs-ratchet-test.sh +6 -1
- package/scripts/verbs-test.sh +4 -4
- package/scripts/verbs.baseline +1 -1
- package/skills/kit-add/SKILL.md +1 -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-autopilot/SKILL.md +1 -1
- package/skills/kit-cleanup/SKILL.md +2 -2
- package/skills/kit-effort-close/SKILL.md +16 -8
- package/skills/kit-effort-new/SKILL.md +11 -8
- package/skills/kit-effort-pr/SKILL.md +7 -7
- package/skills/kit-next/SKILL.md +7 -7
- package/skills/kit-plan-next/SKILL.md +10 -11
- package/skills/kit-status/SKILL.md +5 -5
- package/skills/kit-task-pr-auto/SKILL.md +1 -1
- package/skills/kit-task-pr-merge/SKILL.md +3 -3
- package/skills/kit-task-sync/SKILL.md +2 -0
- package/skills/routing.yaml +5 -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/effort.sh
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
# effort_branch_num echo the effort issue # parsed from the current branch
|
|
10
10
|
# effort_trace_dir <parent_num> echo (and mkdir -p) the trace dir under the git-common-dir
|
|
11
11
|
# effort_snapshot_subs <parent_num> [base_ref] snapshot per-sub-issue diffs BEFORE squash (work trace)
|
|
12
|
-
# effort_title_lint <full-title>
|
|
12
|
+
# effort_title_lint <full-title> the effort/sub title rule (wrapper over naming.sh)
|
|
13
13
|
# effort_set_blocked_by <issue> <blocker> set a native GitHub blocked_by dependency edge
|
|
14
14
|
#
|
|
15
15
|
# Requires: gh, jq, git. bash 3.2 compatible.
|
|
@@ -47,6 +47,15 @@ if ! command -v kit_kind_commit_type >/dev/null 2>&1; then
|
|
|
47
47
|
unset _eff_kinds
|
|
48
48
|
fi
|
|
49
49
|
|
|
50
|
+
# The one title convention (naming.sh, E546.1): effort_title_lint and effort_pr_title_check below
|
|
51
|
+
# are thin wrappers over naming_title_lint.
|
|
52
|
+
if ! command -v naming_title_lint >/dev/null 2>&1; then
|
|
53
|
+
_eff_naming="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/naming.sh"
|
|
54
|
+
# shellcheck source=/dev/null
|
|
55
|
+
[ -f "$_eff_naming" ] && . "$_eff_naming"
|
|
56
|
+
unset _eff_naming
|
|
57
|
+
fi
|
|
58
|
+
|
|
50
59
|
EFFORT_REPO="${EFFORT_REPO:-${KIT_REPO:-}}"
|
|
51
60
|
|
|
52
61
|
# Link a child issue as a native GitHub sub-issue of a parent.
|
|
@@ -192,29 +201,29 @@ EOF_ROWS
|
|
|
192
201
|
}
|
|
193
202
|
|
|
194
203
|
# ── Effort PR title — ONE composer shared by the verb + the skill (#121) ────────────────────────
|
|
195
|
-
# `cckit effort pr` (the verb) and /kit-effort-pr (the skill)
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
# (effort-model.md), enforced by effort_pr_title_check.
|
|
204
|
+
# `cckit effort pr` (the verb) and /kit-effort-pr (the skill) both call effort_pr_title, so an effort
|
|
205
|
+
# PR is titled identically no matter who opens it. The MANDATORY element is the trailing [E<n>]
|
|
206
|
+
# effort token (rules/naming-and-ids.md), enforced by naming_title_lint pr and effort_pr_title_check.
|
|
199
207
|
#
|
|
200
208
|
# effort_pr_title <num> <name> [labels_csv] [type] [role_display] — compose the title (#237).
|
|
201
209
|
# PRs are squash-merged, so the title becomes the commit release-please reads and the commitlint
|
|
202
210
|
# gate (.github/workflows/commitlint.yml) checks. The default is therefore a Conventional Commit
|
|
203
|
-
# subject with the
|
|
204
|
-
# effort_pr_title 115 "adoption hardening" -> "feat: adoption hardening [
|
|
205
|
-
# effort_pr_title 115 "adoption hardening" "flow:core,kind:chore" -> "chore(core): adoption hardening [
|
|
206
|
-
# effort_pr_title 115 "[
|
|
207
|
-
#
|
|
208
|
-
#
|
|
211
|
+
# subject with the token trailing:
|
|
212
|
+
# effort_pr_title 115 "adoption hardening" -> "feat: adoption hardening [E115]"
|
|
213
|
+
# effort_pr_title 115 "adoption hardening" "flow:core,kind:chore" -> "chore(core): adoption hardening [E115]"
|
|
214
|
+
# effort_pr_title 115 "[E115] adoption hardening" -> "feat: adoption hardening [E115]"
|
|
215
|
+
# effort_pr_title 115 "[Effort] 115 · [Core] adoption hardening" -> "feat(core): adoption hardening [E115]"
|
|
216
|
+
# scope the `flow:<flow>` label, else the name's leading [Flow] tag (legacy titles); lowercased,
|
|
217
|
+
# and dropped when it is not a valid Conventional Commit scope. The tag is peeled.
|
|
209
218
|
# type the explicit <type> (`effort pr --type`), else the `kind:` label mapped as kto_pr_title
|
|
210
219
|
# maps it (kind:task and anything unknown -> feat; a content kind -> docs; a `bug` label -> fix).
|
|
211
|
-
# A full parent title
|
|
220
|
+
# A full parent title, new or legacy, is accepted: its prefix is peeled so the id is never doubled.
|
|
212
221
|
# pr.titleStyle = issue-title (KIT_PR_TITLE_STYLE) keeps the non-conventional form, for a repo with
|
|
213
222
|
# no commitlint gate: "[Role] [#N] <name>" (the role prefix only when <role_display> is given).
|
|
214
223
|
effort_pr_title() {
|
|
215
224
|
local num="${1:-}" name="${2:-}" labels="${3:-}" ctype="${4:-}" role="${5:-}" tag scope kind
|
|
216
225
|
num="${num#\#}"
|
|
217
|
-
name="$(
|
|
226
|
+
name="$(naming_strip_structural "$name")"
|
|
218
227
|
[ -n "$name" ] || name="effort"
|
|
219
228
|
if [ "${KIT_PR_TITLE_STYLE:-conventional}" = "issue-title" ]; then
|
|
220
229
|
if [ -n "$role" ]; then printf '[%s] [#%s] %s' "$role" "$num" "$name"
|
|
@@ -244,31 +253,28 @@ effort_pr_title() {
|
|
|
244
253
|
fi
|
|
245
254
|
case ",$labels," in *,bug,*) ctype=fix ;; esac
|
|
246
255
|
fi
|
|
247
|
-
if [ -n "$scope" ]; then printf '%s(%s): %s [
|
|
248
|
-
else printf '%s: %s [
|
|
256
|
+
if [ -n "$scope" ]; then printf '%s(%s): %s [E%s]' "$ctype" "$scope" "$name" "$num"
|
|
257
|
+
else printf '%s: %s [E%s]' "$ctype" "$name" "$num"; fi
|
|
249
258
|
}
|
|
250
259
|
|
|
251
|
-
# effort_pr_title_check <title> [num] — rc 0 iff <title> carries the effort
|
|
252
|
-
# [
|
|
253
|
-
# and the skill
|
|
260
|
+
# effort_pr_title_check <title> [num] — rc 0 iff <title> carries the effort's token: [E<num>] or the
|
|
261
|
+
# legacy [#<num>] when <num> is given, else any [E<digits>] or [#<digits>]. Prints the reason + rc 1
|
|
262
|
+
# when it doesn't, so the verb and the skill refuse to open a PR whose title lacks the effort id.
|
|
254
263
|
effort_pr_title_check() {
|
|
255
264
|
local title="${1:-}" num="${2:-}"
|
|
256
265
|
if [ -n "$num" ]; then
|
|
257
266
|
num="${num#\#}"
|
|
258
|
-
case "$title" in *"[#$num]"*) return 0 ;; esac
|
|
259
|
-
echo "effort_pr_title_check: PR title lacks the [
|
|
267
|
+
case "$title" in *"[E$num]"*|*"[#$num]"*) return 0 ;; esac
|
|
268
|
+
echo "effort_pr_title_check: PR title lacks the [E$num] effort token: '$title'" >&2; return 1
|
|
260
269
|
fi
|
|
261
|
-
grep -qE '\[
|
|
262
|
-
echo "effort_pr_title_check: PR title lacks
|
|
270
|
+
grep -qE '\[(E|#)[0-9]+\]' <<<"$title" && return 0
|
|
271
|
+
echo "effort_pr_title_check: PR title lacks an [E<n>] effort token: '$title'" >&2; return 1
|
|
263
272
|
}
|
|
264
273
|
|
|
265
|
-
# ── Effort-title rule —
|
|
266
|
-
#
|
|
267
|
-
#
|
|
268
|
-
#
|
|
269
|
-
# sub-clauses, or >6 words (detail goes in the body). See rules/effort-model.md § Titles.
|
|
270
|
-
|
|
271
|
-
# Controlled flow vocabulary for the optional leading [Flow] title tag. Resolution order (#150):
|
|
274
|
+
# ── Effort-title rule — one convention, linted in naming.sh ───────────────────────────────────────
|
|
275
|
+
# `[E<n>] <name>` for an effort, `[E<n>.<step>] <name>` for a sub (rules/naming-and-ids.md). The
|
|
276
|
+
# flow lives in the `flow:` label; a legacy leading `[Flow]` tag is still tolerated by the lint, and
|
|
277
|
+
# validated against this controlled vocabulary. Resolution order (#150):
|
|
272
278
|
# 1. an explicit EFFORT_FLOWS env var always wins (per-invocation override)
|
|
273
279
|
# 2. the project config `effort.flows[]` — via KIT_EFFORT_FLOWS (exported by load_kit_config) or
|
|
274
280
|
# read straight from the config file, so a configured vocabulary works even for callers that
|
|
@@ -292,50 +298,17 @@ EFFORT_FLOWS="${EFFORT_FLOWS:-Core UI API Docs Infra Auth Data Web App}"
|
|
|
292
298
|
# Jargon denylist — internal terms that read as noise on the board. Override via EFFORT_TITLE_JARGON.
|
|
293
299
|
EFFORT_TITLE_JARGON="${EFFORT_TITLE_JARGON:-chrome seam contract claim rescue stash teardown scaffolding shim boilerplate refactor wiring}"
|
|
294
300
|
|
|
295
|
-
# effort_title_lint <full-title> — 0 if the title is clean; 1 + reasons on stderr otherwise.
|
|
296
|
-
#
|
|
301
|
+
# effort_title_lint <full-title> — 0 if the title is clean; 1 + reasons on stderr otherwise. A thin
|
|
302
|
+
# wrapper over naming_title_lint: a sub title ([E<n>.<step>] or legacy [Effort N] M · ) is linted as
|
|
303
|
+
# a sub, anything else as an effort ([E<n>] or legacy [Effort] N · ).
|
|
297
304
|
effort_title_lint() {
|
|
298
|
-
local title="$1"
|
|
299
|
-
local -a reasons=()
|
|
305
|
+
local title="${1:-}"
|
|
300
306
|
[[ -n "$title" ]] || { echo "effort_title_lint: title required" >&2; return 2; }
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
# 2. peel one optional leading [Flow] tag and validate it against the controlled vocabulary.
|
|
307
|
-
if [[ "$name" =~ ^\[([A-Za-z]+)\]\ (.+)$ ]]; then
|
|
308
|
-
flow="${BASH_REMATCH[1]}"; rest="${BASH_REMATCH[2]}"; name="$rest"
|
|
309
|
-
case " $EFFORT_FLOWS " in
|
|
310
|
-
*" $flow "*) : ;;
|
|
311
|
-
*) reasons+=("flow tag [$flow] is not in the vocabulary ($EFFORT_FLOWS)") ;;
|
|
312
|
-
esac
|
|
313
|
-
fi
|
|
314
|
-
|
|
315
|
-
# 3. the remaining name must be a concise, plain outcome phrase.
|
|
316
|
-
case "$name" in *"("*|*")"*) reasons+=("no parentheses — detail goes in the body") ;; esac
|
|
317
|
-
case "$name" in *" — "*|*" · "*|*" / "*) reasons+=("no ' — ' / ' · ' / ' / ' sub-clauses — one clear phrase") ;; esac
|
|
318
|
-
case "$name" in *—*|*▾*|*▸*|*→*|*✓*|*✗*|*…*|*•*) reasons+=("no glyphs (— ▾ ▸ → ✓ ✗ … •) in the title") ;; esac
|
|
319
|
-
# code identifiers: file extensions, snake_case, or a code-dir path.
|
|
320
|
-
if grep -qE '\.(sh|ts|tsx|js|mjs|json|css|md|ya?ml)([^A-Za-z0-9]|$)|[a-z0-9]+_[a-z0-9]+|(^|[^A-Za-z])(scripts|apps|packages|src)/' <<<"$name"; then
|
|
321
|
-
reasons+=("no code identifiers (file names, paths, snake_case) — name the outcome")
|
|
322
|
-
fi
|
|
323
|
-
# jargon denylist (word-boundary, case-insensitive).
|
|
324
|
-
local w
|
|
325
|
-
for w in $EFFORT_TITLE_JARGON; do
|
|
326
|
-
grep -qiwE "$w" <<<"$name" && reasons+=("jargon word '$w' — use plain language")
|
|
327
|
-
done
|
|
328
|
-
# word count ≤ 6.
|
|
329
|
-
local wc; wc=$(printf '%s\n' "$name" | wc -w | tr -d ' ')
|
|
330
|
-
[[ "$wc" -gt 6 ]] && reasons+=("name is $wc words — keep it ≤ 6 (detail goes in the body)")
|
|
331
|
-
|
|
332
|
-
if [[ "${#reasons[@]}" -gt 0 ]]; then
|
|
333
|
-
{ echo "✗ effort title fails the concise / no-jargon rule: $title"
|
|
334
|
-
for w in "${reasons[@]}"; do echo " - $w"; done
|
|
335
|
-
} >&2
|
|
336
|
-
return 1
|
|
307
|
+
if grep -qE '^\[(E[0-9]+\.[0-9]+|Effort [0-9]+)\] ' <<<"$title"; then
|
|
308
|
+
naming_title_lint sub "$title"
|
|
309
|
+
else
|
|
310
|
+
naming_title_lint effort "$title"
|
|
337
311
|
fi
|
|
338
|
-
return 0
|
|
339
312
|
}
|
|
340
313
|
|
|
341
314
|
# effort_set_blocked_by <issue> <blocker-issue> — declare the native GitHub dependency "<issue> is
|
|
@@ -356,11 +329,11 @@ if [[ "${BASH_SOURCE[0]:-}" == "${0:-}" && "${1:-}" == "--selftest" ]]; then
|
|
|
356
329
|
_et_rc=0
|
|
357
330
|
_et_fail() { if effort_title_lint "$1" >/dev/null 2>&1; then echo "FAIL expected-reject passed: $1"; _et_rc=1; else echo "ok reject: $1"; fi; }
|
|
358
331
|
_et_pass() { if effort_title_lint "$1" >/dev/null 2>&1; then echo "ok accept: $1"; else echo "FAIL expected-accept rejected: $1"; effort_title_lint "$1"; _et_rc=1; fi; }
|
|
359
|
-
_et_fail "[
|
|
360
|
-
_et_fail "[
|
|
332
|
+
_et_fail "[E12] operator chrome — Settings ▾ dropdown + layout fixes"
|
|
333
|
+
_et_fail "[E12.4] Section tables — columns + joins (contract B)"
|
|
361
334
|
_et_fail "[Effort] 12 · refactor scripts/kit + quote-aware free-prompt args"
|
|
335
|
+
_et_pass "[E12] operator navigation"
|
|
362
336
|
_et_pass "[Effort] 12 · [UI] operator navigation"
|
|
363
|
-
_et_pass "[
|
|
364
|
-
_et_pass "[Effort 12] 4 · module tables"
|
|
337
|
+
_et_pass "[E12.4] module tables"
|
|
365
338
|
exit "$_et_rc"
|
|
366
339
|
fi
|
|
@@ -6,15 +6,19 @@
|
|
|
6
6
|
# errors: strict — an HTTP error is rc 1 with the API message on stderr; jq is required for JSON
|
|
7
7
|
_fg_api_base() { printf '%s' "${CCKIT_FORGE_API:-https://api.github.com}"; }
|
|
8
8
|
|
|
9
|
-
# _fg_curl <method> <path> <body-or-empty> [accept] [headers-file]: one request. The
|
|
10
|
-
# rc 1 on HTTP >= 400 (the API's message on stderr) or a transport failure. <path>
|
|
9
|
+
# _fg_curl <method> <path> <body-or-empty> [accept] [headers-file] [extra-headers]: one request. The
|
|
10
|
+
# body on stdout, rc 1 on HTTP >= 400 (the API's message on stderr) or a transport failure. <path>
|
|
11
|
+
# may be a full URL. [extra-headers] is newline-separated `Name: value` lines.
|
|
11
12
|
_fg_curl() {
|
|
12
13
|
# `rpath`, not `path`: in zsh `path` is the array tied to PATH, and a local by that name hides
|
|
13
14
|
# every command from the function (the delegation brief's zsh gotcha).
|
|
14
|
-
local method="$1" rpath="$2" body="${3:-}" accept="${4:-application/vnd.github+json}" hdr="${5:-}" token out code url
|
|
15
|
+
local method="$1" rpath="$2" body="${3:-}" accept="${4:-application/vnd.github+json}" hdr="${5:-}" xh="${6:-}" token out code url line
|
|
15
16
|
token="$(forge_token)" || { echo "cckit: no forge token (GH_TOKEN, GITHUB_TOKEN, or gh auth login)" >&2; return 1; }
|
|
16
17
|
case "$rpath" in http://*|https://*) url="$rpath" ;; *) url="$(_fg_api_base)/${rpath#/}" ;; esac
|
|
17
18
|
set -- -sS -X "$method" -H "Authorization: Bearer $token" -H "Accept: $accept" -w '\n%{http_code}'
|
|
19
|
+
while IFS= read -r line; do [ -n "$line" ] && set -- "$@" -H "$line"; done <<EOF
|
|
20
|
+
$xh
|
|
21
|
+
EOF
|
|
18
22
|
[ -n "$hdr" ] && set -- "$@" -D "$hdr"
|
|
19
23
|
if [ -n "$body" ]; then set -- "$@" -H "Content-Type: application/json" --data-binary "$body"; fi
|
|
20
24
|
out="$(curl "$@" "$url")" || return 1
|
|
@@ -47,12 +51,13 @@ forge_graphql() {
|
|
|
47
51
|
# forge_rest <endpoint> [gh api flags…]: the `gh api` argument form over curl, so a call site moves
|
|
48
52
|
# with its arguments unchanged. Understood: -X|--method, -f|--raw-field k=v (string), -F|--field k=v
|
|
49
53
|
# (true|false|null|integer typed, @file reads the file, k[]=v appends), -q|--jq <filter> (applied
|
|
50
|
-
# with jq -r, per page), --paginate (follows Link rel=next), -H|--header 'Name: value'
|
|
54
|
+
# with jq -r, per page), --paginate (follows Link rel=next), -H|--header 'Name: value' (Accept
|
|
55
|
+
# replaces the default; any other header is sent as given),
|
|
51
56
|
# --input <file|-> (a raw JSON body), --silent. Fields go to the query string on GET and DELETE and
|
|
52
57
|
# to a JSON body otherwise; fields with no method mean POST. `graphql` as the endpoint posts the
|
|
53
58
|
# query= and variables as forge_graphql does. rc 1 on an HTTP error with nothing on stdout.
|
|
54
59
|
forge_rest() {
|
|
55
|
-
local ep="" method="" filter="" paginate=0 accept="application/vnd.github+json" input="" silent=0
|
|
60
|
+
local ep="" method="" filter="" paginate=0 accept="application/vnd.github+json" input="" silent=0 xh=""
|
|
56
61
|
local body='{}' has_field=0 q="" k v raw typed arr
|
|
57
62
|
while [ $# -gt 0 ]; do
|
|
58
63
|
case "$1" in
|
|
@@ -60,7 +65,13 @@ forge_rest() {
|
|
|
60
65
|
-q|--jq) filter="$2"; shift 2 ;;
|
|
61
66
|
--paginate) paginate=1; shift ;;
|
|
62
67
|
--silent) silent=1; shift ;;
|
|
63
|
-
-H|--header)
|
|
68
|
+
-H|--header)
|
|
69
|
+
case "$2" in
|
|
70
|
+
[Aa]ccept:*) accept="$(printf '%s' "${2#*:}" | sed 's/^ *//')" ;;
|
|
71
|
+
*:*) xh="$xh${xh:+
|
|
72
|
+
}$2" ;;
|
|
73
|
+
esac
|
|
74
|
+
shift 2 ;;
|
|
64
75
|
--input) input="$2"; shift 2 ;;
|
|
65
76
|
-f|--raw-field|-F|--field)
|
|
66
77
|
raw="$2"; k="${raw%%=*}"; v="${raw#*=}"; has_field=1
|
|
@@ -118,7 +129,7 @@ forge_rest() {
|
|
|
118
129
|
fi
|
|
119
130
|
hdr="$(mktemp)"; local frc=0
|
|
120
131
|
while :; do
|
|
121
|
-
out="$(_fg_curl "$method" "$url" "$send" "$accept" "$hdr")" || { rm -f "$hdr"; return 1; }
|
|
132
|
+
out="$(_fg_curl "$method" "$url" "$send" "$accept" "$hdr" "$xh")" || { rm -f "$hdr"; return 1; }
|
|
122
133
|
if [ "$silent" != 1 ]; then
|
|
123
134
|
# A --jq that fails (a non-JSON 200 body) is a failed read, rc 1, not an empty answer.
|
|
124
135
|
if [ -n "$filter" ]; then printf '%s\n' "$out" | jq -r "$filter" || frc=1; else printf '%s\n' "$out"; fi
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# gh-board-add-test.sh — the board add when the item is already on the board (#590). A Projects v2
|
|
4
|
+
# board with GitHub's auto-add workflow puts every new issue and PR on the board within seconds of
|
|
5
|
+
# its creation, so the kit's REST add answers 422 "Content already exists in this project" — where
|
|
6
|
+
# GraphQL's addProjectV2ItemById returned the existing item. The add must read that card back, fall
|
|
7
|
+
# back to GraphQL when it cannot, and `cckit new` must then go on to set the card's fields.
|
|
8
|
+
# Hermetic: the shared forge shim (test-forge-shim.sh) over a curl stand-in; a throwaway repo.
|
|
9
|
+
# Run: bash scripts/lib/gh-board-add-test.sh
|
|
10
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
11
|
+
set -u
|
|
12
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
13
|
+
# shellcheck source=/dev/null
|
|
14
|
+
. "$LIB/test-env.sh" && test_env_seal
|
|
15
|
+
unset CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT CCKIT_GRAPHQL
|
|
16
|
+
fail=0
|
|
17
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
18
|
+
has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> '$2' lacks '$3'"; fail=1 ;; esac; }
|
|
19
|
+
command -v jq >/dev/null 2>&1 || { echo "gh-board-add-test: jq required — skipping"; exit 0; }
|
|
20
|
+
command -v git >/dev/null 2>&1 || { echo "gh-board-add-test: git required — skipping"; exit 0; }
|
|
21
|
+
|
|
22
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
23
|
+
# shellcheck source=/dev/null
|
|
24
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
|
|
25
|
+
export GH_TOKEN=test-token CCKIT_FORGE=github GH_LOG="$tmp/gh.log" GH_N="$tmp/n"
|
|
26
|
+
|
|
27
|
+
# Org board acme #3. POST items answers as GH_ADD_MODE says: exists = the documented 422 for content
|
|
28
|
+
# already on the board · forbidden = 403 · ok = 201 with a new item. GET items lists issue 42, PR 7
|
|
29
|
+
# and issue 50 (the number the shim gives the first created issue) unless GH_ITEMS_EMPTY=1.
|
|
30
|
+
cat > "$tmp/fixture.sh" <<'SH'
|
|
31
|
+
case "$method $ep" in
|
|
32
|
+
"GET orgs/acme/projectsV2/3")
|
|
33
|
+
out='{"id":11,"node_id":"PVT_rest","number":3,"title":"Board"}' ;;
|
|
34
|
+
"GET orgs/acme/projectsV2/3/fields")
|
|
35
|
+
out='[{"id":101,"node_id":"PVTSSF_status","name":"Status","data_type":"single_select","options":[{"id":"opt_todo","name":{"raw":"Todo","html":"Todo"}}]}]' ;;
|
|
36
|
+
"GET orgs/acme/projectsV2/3/items")
|
|
37
|
+
if [ "${GH_ITEMS_EMPTY:-0}" = 1 ]; then out='[]'; else
|
|
38
|
+
out='[{"id":502,"node_id":"PVTI_other","content_type":"Issue","content":{"number":42,"repository":{"full_name":"acme/other"}}},
|
|
39
|
+
{"id":501,"node_id":"PVTI_a","content_type":"Issue","content":{"number":42,"repository":{"full_name":"acme/app"}}},
|
|
40
|
+
{"id":503,"node_id":"PVTI_pr","content_type":"PullRequest","content":{"number":7,"repository":{"full_name":"acme/app"}}},
|
|
41
|
+
{"id":550,"node_id":"PVTI_new50","content_type":"Issue","content":{"number":50,"repository":{"full_name":"acme/app"}}}]'; fi ;;
|
|
42
|
+
"POST orgs/acme/projectsV2/3/items")
|
|
43
|
+
case "${GH_ADD_MODE:-exists}" in
|
|
44
|
+
exists) code=422; out='{"message":"Content already exists in this project","documentation_url":"https://docs.github.com/rest/projects/items#add-item-to-organization-owned-project","status":"422"}' ;;
|
|
45
|
+
forbidden) code=403; out='{"message":"Resource not accessible by integration","status":"403"}' ;;
|
|
46
|
+
*) code=201; out='{"id":777,"node_id":"PVTI_made","content_type":"Issue"}' ;;
|
|
47
|
+
esac ;;
|
|
48
|
+
"PATCH orgs/acme/projectsV2/3/items/"*)
|
|
49
|
+
out="{\"id\":${ep##*/},\"node_id\":\"PVTI_x\"}" ;;
|
|
50
|
+
esac
|
|
51
|
+
SH
|
|
52
|
+
export GH_FIXTURE="$tmp/fixture.sh"
|
|
53
|
+
export GH_GRAPHQL='{"data":{"addProjectV2ItemById":{"item":{"id":"PVTI_gql"}}}}'
|
|
54
|
+
|
|
55
|
+
add() { # <snippet> — run gh-project.sh functions against the org board, over the shim
|
|
56
|
+
: > "$GH_LOG"
|
|
57
|
+
PATH="$tmp/bin:$PATH" KIT_CONFIG=/nonexistent KIT_REPO=acme/app KIT_OWNER=acme KIT_PROJECT_NUMBER=3 \
|
|
58
|
+
KIT_PROJECT_OWNER_TYPE=organization PROJECT_ID=PVT_rest bash -c "source '$LIB/gh-project.sh'; $1" 2>"$tmp/add.err"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# ── the item is already on the board: REST 422 → the existing card ───────────────────────────────
|
|
62
|
+
got="$(add 'project_add_item I_42 acme/app 42 Issue')"
|
|
63
|
+
t "422 exists: prints the existing card as <id>:<node id>" "$got" "501:PVTI_a"
|
|
64
|
+
has "422 exists: the POST was tried first" "$(sed -n 1p "$GH_LOG")" "POST orgs/acme/projectsV2/3/items"
|
|
65
|
+
has "422 exists: then the board's items were read" "$(sed -n 2p "$GH_LOG")" "GET orgs/acme/projectsV2/3/items"
|
|
66
|
+
t "422 exists: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
67
|
+
t "422 exists: nothing on stderr" "$(cat "$tmp/add.err")" ""
|
|
68
|
+
|
|
69
|
+
got="$(add 'project_add_item PR_7 acme/app 7')"
|
|
70
|
+
t "422 exists, a PR: the PR's card, not an issue's" "$got" "503:PVTI_pr"
|
|
71
|
+
|
|
72
|
+
# ── 422 but the card cannot be read back: the idempotent GraphQL add decides ──────────────────────
|
|
73
|
+
got="$(add 'GH_ITEMS_EMPTY=1; export GH_ITEMS_EMPTY; project_add_item I_42 acme/app 42 Issue')"
|
|
74
|
+
t "422, card not listed: GraphQL's item" "$got" "PVTI_gql"
|
|
75
|
+
has "422, card not listed: GraphQL adds by the content node id" "$(cat "$GH_LOG")" '"content":"I_42"'
|
|
76
|
+
has "422, card not listed: one fallback note" "$(cat "$tmp/add.err")" "board add item: REST could not serve it, falling back to GraphQL"
|
|
77
|
+
|
|
78
|
+
# ── any other REST failure of the add: GraphQL too (an item missing from the board strands the rest)
|
|
79
|
+
got="$(add 'GH_ADD_MODE=forbidden; export GH_ADD_MODE; project_add_item I_42 acme/app 42 Issue')"
|
|
80
|
+
t "REST 403 on add: GraphQL's item" "$got" "PVTI_gql"
|
|
81
|
+
has "REST 403 on add: the API's answer is still reported" "$(cat "$tmp/add.err")" "GitHub answered 403"
|
|
82
|
+
t "REST 403 on add: one GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "1"
|
|
83
|
+
|
|
84
|
+
# A cloud session: no GraphQL, so the skip notice and rc 0, never a GraphQL call.
|
|
85
|
+
got="$(add 'GH_ADD_MODE=forbidden; export GH_ADD_MODE; CLAUDE_CODE_REMOTE=true; project_add_item I_42 acme/app 42 Issue; echo rc=$?')"
|
|
86
|
+
t "cloud, REST 403 on add: rc 0, no item" "$got" "rc=0"
|
|
87
|
+
t "cloud, REST 403 on add: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
88
|
+
|
|
89
|
+
# A fresh add still prints the new card.
|
|
90
|
+
got="$(add 'GH_ADD_MODE=ok; export GH_ADD_MODE; project_add_item I_42 acme/app 42 Issue')"
|
|
91
|
+
t "201: the new card" "$got" "777:PVTI_made"
|
|
92
|
+
|
|
93
|
+
# ── cckit new on an auto-add board: on the board, no warning, its Status set on the existing card ─
|
|
94
|
+
git init -q --bare "$tmp/remote.git"
|
|
95
|
+
git clone -q "$tmp/remote.git" "$tmp/work" 2>/dev/null
|
|
96
|
+
cd "$tmp/work" || exit 1
|
|
97
|
+
git config user.email t@t; git config user.name t
|
|
98
|
+
git checkout -q -b develop; git commit -q --allow-empty -m init; git push -q origin develop
|
|
99
|
+
export PATH="$tmp/bin:$PATH" KIT_CONFIG=/nonexistent KIT_REPO=acme/app KIT_OWNER=acme KIT_PROJECT_NUMBER=3 \
|
|
100
|
+
KIT_PROJECT_OWNER_TYPE=organization KIT_BASE_BRANCH=develop KIT_PROJECTS_V2=true KIT_WT_INSTALL=0
|
|
101
|
+
export GH_REPO_LABELS='[{"name":"kind:task"},{"name":"priority:p2"},{"name":"role:tech-lead"}]'
|
|
102
|
+
export PROJECT_ID=PVT_rest STATUS_FIELD_ID=PVTSSF_status STATUS_OPT_TODO=opt_todo
|
|
103
|
+
unset GH_ADD_MODE GH_ITEMS_EMPTY
|
|
104
|
+
# shellcheck source=/dev/null
|
|
105
|
+
. "$LIB/gh-project.sh"
|
|
106
|
+
# shellcheck source=/dev/null
|
|
107
|
+
. "$LIB/kit-task-ops.sh"
|
|
108
|
+
load_project_ids() { :; } # the ids are exported above; no captured file in the throwaway repo
|
|
109
|
+
: > "$GH_LOG"
|
|
110
|
+
num="$(kto_task_new "Add a thing" tech-lead task p2 "" "" "" "Body." 2>"$tmp/new.err" | tail -1)"
|
|
111
|
+
t "new: the new issue's number" "$num" "50"
|
|
112
|
+
t "new: no 'NOT added to the board' warning" "$(grep -c 'NOT added' "$tmp/new.err")" "0"
|
|
113
|
+
has "new: the board add was tried over REST" "$(cat "$GH_LOG")" 'POST orgs/acme/projectsV2/3/items {"type":"Issue","owner":"acme","repo":"app","number":50}'
|
|
114
|
+
has "new: the Status is set on the existing card" "$(cat "$GH_LOG")" 'PATCH orgs/acme/projectsV2/3/items/550 {"fields":[{"id":101,"value":"opt_todo"}]}'
|
|
115
|
+
t "new: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
116
|
+
|
|
117
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (gh-board-add)" || echo "gh-board-add: FAILURES"
|
|
118
|
+
exit "$fail"
|
|
@@ -131,5 +131,120 @@ for rsh in bash zsh; do
|
|
|
131
131
|
|| echo "ok: [$rsh] role_option_id evaluates nothing from its argument"
|
|
132
132
|
done
|
|
133
133
|
|
|
134
|
+
# ── the board over REST first, GraphQL as the fallback (E546.7) ────────────────────────────────
|
|
135
|
+
# A fixture answers the Projects v2 REST endpoints of org board acme #3 in the documented shapes
|
|
136
|
+
# (docs.github.com/en/rest/projects): integer field and item ids, node ids beside them, option and
|
|
137
|
+
# iteration ids as strings, option names as {raw, html}. GH_BOARD_PATCH_CODE makes the PATCH answer
|
|
138
|
+
# that HTTP code. No request leaves the shim.
|
|
139
|
+
cat > "$tmp/board-fixture.sh" <<'SH'
|
|
140
|
+
case "$method $ep" in
|
|
141
|
+
"GET orgs/acme/projectsV2/3")
|
|
142
|
+
out='{"id":11,"node_id":"PVT_rest","number":3,"title":"Board"}' ;;
|
|
143
|
+
"GET orgs/acme/projectsV2/3/fields")
|
|
144
|
+
out='[{"id":101,"node_id":"PVTSSF_status","name":"Status","data_type":"single_select","options":[{"id":"opt_todo","name":{"raw":"Todo","html":"Todo"}},{"id":"opt_done","name":{"raw":"Done","html":"Done"}}]},
|
|
145
|
+
{"id":102,"node_id":"PVTIF_iter","name":"Iteration","data_type":"iteration","configuration":{"iterations":[{"id":"it_1","title":{"raw":"Iteration 1","html":"Iteration 1"},"start_date":"2026-11-01","duration":14,"completed":false}]}},
|
|
146
|
+
{"id":103,"node_id":"PVTF_plan","name":"Plan Link","data_type":"text"}]' ;;
|
|
147
|
+
"GET orgs/acme/projectsV2/3/items")
|
|
148
|
+
out='[{"id":502,"node_id":"PVTI_other","content_type":"Issue","content":{"number":42,"repository":{"full_name":"acme/other"}}},
|
|
149
|
+
{"id":501,"node_id":"PVTI_a","content_type":"Issue","content":{"number":42,"repository":{"full_name":"acme/app"}}}]' ;;
|
|
150
|
+
"POST orgs/acme/projectsV2/3/items")
|
|
151
|
+
code=201; out='{"id":777,"node_id":"PVTI_new","content_type":"Issue"}' ;;
|
|
152
|
+
"PATCH orgs/acme/projectsV2/3/items/"*)
|
|
153
|
+
code="${GH_BOARD_PATCH_CODE:-200}"
|
|
154
|
+
if [ "$code" = 200 ]; then out="{\"id\":${ep##*/},\"node_id\":\"PVTI_a\"}"; else out='{"message":"Resource not accessible"}'; fi ;;
|
|
155
|
+
esac
|
|
156
|
+
SH
|
|
157
|
+
export GH_HDR_LOG="$tmp/hdr.log"
|
|
158
|
+
board() { # <snippet> — run gh-project.sh functions against the org board, over the shim
|
|
159
|
+
: > "$GH_LOG"; : > "$GH_HDR_LOG"
|
|
160
|
+
PATH="$tmp/bin:$PATH" GH_FIXTURE="$tmp/board-fixture.sh" KIT_CONFIG=/nonexistent \
|
|
161
|
+
KIT_REPO=acme/app KIT_OWNER=acme KIT_PROJECT_NUMBER=3 KIT_PROJECT_OWNER_TYPE=organization \
|
|
162
|
+
PROJECT_ID=PVT_rest bash -c "source '$LIB/gh-project.sh'; $1" 2>"$tmp/board.err"
|
|
163
|
+
}
|
|
164
|
+
export GH_GRAPHQL='{"data":{"repository":{"issue":{"projectItems":{"nodes":[{"id":"PVTI_gql","project":{"number":3}}]}}}}}'
|
|
165
|
+
|
|
166
|
+
got="$(board 'project_find_item_by_issue 42')"
|
|
167
|
+
t "REST find: the card of acme/app#42, as <id>:<node id>" "$got" "501:PVTI_a"
|
|
168
|
+
has "REST find: reads the board's items over REST" "$(cat "$GH_LOG")" "GET orgs/acme/projectsV2/3/items?per_page=100"
|
|
169
|
+
t "REST find: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
170
|
+
has "REST find: sends the documented API version" "$(cat "$GH_HDR_LOG")" "X-GitHub-Api-Version: 2026-03-10"
|
|
171
|
+
t "REST find: no fallback note" "$(grep -c 'falling back' "$tmp/board.err")" "0"
|
|
172
|
+
|
|
173
|
+
board 'project_set_single_select 501:PVTI_a PVTSSF_status opt_done; echo rc=$?' > "$tmp/out"
|
|
174
|
+
t "REST Status: rc 0" "$(cat "$tmp/out")" "rc=0"
|
|
175
|
+
has "REST Status: PATCH the item with the field's integer id and the option id" "$(cat "$GH_LOG")" \
|
|
176
|
+
'PATCH orgs/acme/projectsV2/3/items/501 {"fields":[{"id":101,"value":"opt_done"}]}'
|
|
177
|
+
t "REST Status: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
178
|
+
|
|
179
|
+
board 'project_set_iteration 501:PVTI_a PVTIF_iter it_1' >/dev/null
|
|
180
|
+
has "REST Iteration: PATCH with the iteration id" "$(cat "$GH_LOG")" \
|
|
181
|
+
'PATCH orgs/acme/projectsV2/3/items/501 {"fields":[{"id":102,"value":"it_1"}]}'
|
|
182
|
+
board 'project_set_text 501:PVTI_a PVTF_plan https://x/plan' >/dev/null
|
|
183
|
+
has "REST text: PATCH with the text" "$(cat "$GH_LOG")" \
|
|
184
|
+
'PATCH orgs/acme/projectsV2/3/items/501 {"fields":[{"id":103,"value":"https://x/plan"}]}'
|
|
185
|
+
|
|
186
|
+
got="$(board 'project_add_item I_42 acme/app 42')"
|
|
187
|
+
t "REST add: prints the new item as <id>:<node id>" "$got" "777:PVTI_new"
|
|
188
|
+
has "REST add: POST items by owner, repo and number" "$(cat "$GH_LOG")" \
|
|
189
|
+
'POST orgs/acme/projectsV2/3/items {"type":"Issue","owner":"acme","repo":"app","number":42}'
|
|
190
|
+
board 'project_add_item PR_7 acme/app 7' >/dev/null
|
|
191
|
+
has "REST add: a PR_ node id adds a PullRequest" "$(cat "$GH_LOG")" '"type":"PullRequest"'
|
|
192
|
+
|
|
193
|
+
got="$(board 'PROJECT_ENV=/nonexistent/ids.env; unset PROJECT_ID; load_project_ids; echo "$PROJECT_ID $STATUS_FIELD_ID $STATUS_FIELD_NUM $STATUS_OPT_DONE $ITERATION_ITER_ITERATION_1 $PLAN_LINK_FIELD_ID"')"
|
|
194
|
+
t "REST ids: load_project_ids reads the ids over REST with no captured file" "$got" \
|
|
195
|
+
"PVT_rest PVTSSF_status 101 opt_done it_1 PVTF_plan"
|
|
196
|
+
has "REST ids: says the ids came over REST" "$(cat "$tmp/board.err")" "board ids read over REST"
|
|
197
|
+
|
|
198
|
+
# An unknown option is not sent over REST: the GraphQL fallback decides.
|
|
199
|
+
board 'project_set_single_select 501:PVTI_a PVTSSF_status opt_missing' >/dev/null
|
|
200
|
+
t "REST Status: an option REST does not list is not PATCHed" "$(grep -c '^PATCH' "$GH_LOG")" "0"
|
|
201
|
+
has "REST Status: ... and goes to GraphQL" "$(cat "$GH_LOG")" '"option":"opt_missing"'
|
|
202
|
+
|
|
203
|
+
# The fallback: REST answers 404 → one note, then GraphQL with the node id.
|
|
204
|
+
export GH_FAIL_EP='orgs/*'
|
|
205
|
+
got="$(board 'project_find_item_by_issue 42')"
|
|
206
|
+
t "fallback find: GraphQL's item after a REST 404" "$got" "PVTI_gql"
|
|
207
|
+
has "fallback find: REST was tried first" "$(sed -n 1p "$GH_LOG")" "GET orgs/acme/projectsV2/3/items"
|
|
208
|
+
t "fallback find: then one GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "1"
|
|
209
|
+
t "fallback find: one stderr note" "$(grep -c 'board find item: REST could not serve it, falling back to GraphQL' "$tmp/board.err")" "1"
|
|
210
|
+
board 'project_set_single_select 501:PVTI_a PVTSSF_status opt_done; echo rc=$?' > "$tmp/out"
|
|
211
|
+
t "fallback Status: rc 0" "$(cat "$tmp/out")" "rc=0"
|
|
212
|
+
has "fallback Status: GraphQL gets the item's node id, not the REST id" "$(cat "$GH_LOG")" '"item":"PVTI_a"'
|
|
213
|
+
t "fallback Status: one note" "$(grep -c 'falling back to GraphQL' "$tmp/board.err")" "1"
|
|
214
|
+
got="$(board 'project_add_item I_42 acme/app 42')"
|
|
215
|
+
has "fallback add: GraphQL adds by the content node id" "$(cat "$GH_LOG")" '"content":"I_42"'
|
|
216
|
+
# A cloud session: REST failed and GraphQL is unavailable → the skip notice, rc 0, no GraphQL.
|
|
217
|
+
board 'CLAUDE_CODE_REMOTE=true; project_set_single_select 501:PVTI_a PVTSSF_status opt_done; echo rc=$?' > "$tmp/out"
|
|
218
|
+
t "cloud, REST 404: rc 0" "$(cat "$tmp/out")" "rc=0"
|
|
219
|
+
t "cloud, REST 404: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
220
|
+
has "cloud, REST 404: the skip notice" "$(cat "$tmp/board.err")" "board step skipped (GraphQL unavailable"
|
|
221
|
+
unset GH_FAIL_EP
|
|
222
|
+
|
|
223
|
+
# A cloud session where REST works: the card moves.
|
|
224
|
+
board 'CLAUDE_CODE_REMOTE=true; project_set_single_select 501:PVTI_a PVTSSF_status opt_done; echo rc=$?' > "$tmp/out"
|
|
225
|
+
t "cloud: Status moves over REST" "$(grep -c '^PATCH orgs/acme/projectsV2/3/items/501 ' "$GH_LOG"):$(grep -c '^POST graphql' "$GH_LOG")" "1:0"
|
|
226
|
+
|
|
227
|
+
# A hard REST error (403) is reported, not retried over GraphQL.
|
|
228
|
+
board 'GH_BOARD_PATCH_CODE=403; export GH_BOARD_PATCH_CODE; project_set_single_select 501:PVTI_a PVTSSF_status opt_done; echo rc=$?' > "$tmp/out"
|
|
229
|
+
t "REST 403: rc 1" "$(cat "$tmp/out")" "rc=1"
|
|
230
|
+
t "REST 403: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
231
|
+
has "REST 403: the API's answer on stderr" "$(cat "$tmp/board.err")" "GitHub answered 403"
|
|
232
|
+
|
|
233
|
+
# A GraphQL item handle (a node id) skips REST, which needs the integer id.
|
|
234
|
+
board 'project_set_single_select PVTI_gql PVTSSF_status opt_done' >/dev/null
|
|
235
|
+
t "node-id item: no REST PATCH" "$(grep -c '^PATCH' "$GH_LOG")" "0"
|
|
236
|
+
has "node-id item: GraphQL with the node id" "$(cat "$GH_LOG")" '"item":"PVTI_gql"'
|
|
237
|
+
|
|
238
|
+
# capture-project-ids.sh reads the board over REST and writes the same file.
|
|
239
|
+
printf '%s' '{"github":{"projectsV2":true,"owner":"acme","projectNumber":3,"projectOwnerType":"organization"}}' > "$tmp/cfg.json"
|
|
240
|
+
: > "$GH_LOG"
|
|
241
|
+
GH_FIXTURE="$tmp/board-fixture.sh" KIT_CONFIG="$tmp/cfg.json" PATH="$tmp/bin:$PATH" \
|
|
242
|
+
bash "$tmp/scripts/capture-project-ids.sh" >/dev/null 2>&1
|
|
243
|
+
t "REST capture: rc 0" "$?" "0"
|
|
244
|
+
t "REST capture: no GraphQL call" "$(grep -c '^POST graphql' "$GH_LOG")" "0"
|
|
245
|
+
has "REST capture: PROJECT_ID is the node id" "$(cat "$tmp/scripts/.project-ids.env" 2>/dev/null)" "PROJECT_ID=PVT_rest"
|
|
246
|
+
has "REST capture: the Status option" "$(cat "$tmp/scripts/.project-ids.env" 2>/dev/null)" "STATUS_OPT_DONE=opt_done"
|
|
247
|
+
unset GH_HDR_LOG
|
|
248
|
+
|
|
134
249
|
[ "$fail" -eq 0 ] && echo "ALL OK (gh-project)" || echo "gh-project: FAILURES"
|
|
135
250
|
exit "$fail"
|