@jeiemgi/cckit 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +15 -4
- package/README.md +25 -3
- package/bin/cckit +91 -8
- package/cckit.config.json +1 -1
- package/kit.config.schema.json +43 -2
- package/package.json +1 -1
- package/scripts/autopilot-test.sh +68 -0
- package/scripts/autopilot.sh +16 -10
- package/scripts/check.sh +14 -1
- package/scripts/copilot-loop-test.sh +3 -0
- package/scripts/guard-raw-git-ops-test.sh +73 -0
- package/scripts/init.sh +68 -8
- package/scripts/lib/agent-profile-test.sh +151 -0
- package/scripts/lib/agent-profile.sh +195 -0
- package/scripts/lib/agent-resolve-test.sh +156 -0
- package/scripts/lib/agent-resolve.sh +177 -0
- package/scripts/lib/branch-owner-test.sh +99 -0
- package/scripts/lib/branch-owner.sh +194 -0
- package/scripts/lib/captain-test.sh +86 -0
- package/scripts/lib/captain.sh +142 -7
- package/scripts/lib/contribute-root-test.sh +40 -0
- package/scripts/lib/contribute-root.sh +22 -0
- package/scripts/lib/effort-metrics.sh +14 -1
- package/scripts/lib/effort-ops-test.sh +54 -2
- package/scripts/lib/effort-ops.sh +243 -23
- package/scripts/lib/effort-parity-test.sh +5 -3
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +49 -15
- package/scripts/lib/gh-project.sh +14 -0
- package/scripts/lib/gh-rest-test.sh +301 -0
- package/scripts/lib/gh-rest.sh +289 -0
- package/scripts/lib/hook-refresh-test.sh +65 -0
- package/scripts/lib/hook-refresh.sh +62 -0
- package/scripts/lib/kit-config.sh +6 -0
- package/scripts/lib/kit-gc-test.sh +178 -1
- package/scripts/lib/kit-gc.sh +251 -55
- package/scripts/lib/kit-task-ops-test.sh +15 -0
- package/scripts/lib/kit-task-ops.sh +231 -58
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +129 -0
- package/scripts/lib/kto-task-pr-test.sh +59 -0
- package/scripts/lib/orchestration-runtime-test.sh +142 -0
- package/scripts/lib/orchestration-runtime.sh +171 -0
- package/scripts/lib/review-stage-test.sh +241 -0
- package/scripts/lib/review-stage.sh +259 -0
- package/scripts/lib/stage-receipt-test.sh +252 -0
- package/scripts/lib/stage-receipt.sh +442 -0
- package/scripts/lib/test-env-test.sh +25 -0
- package/scripts/lib/test-env.sh +33 -0
- package/scripts/lib/worker-brief-test.sh +120 -0
- package/scripts/lib/worker-brief.sh +185 -0
- package/scripts/lib/worktree-issue.sh +14 -0
- package/scripts/lib/worktree-ports-test.sh +146 -0
- package/scripts/lib/worktree-start.sh +153 -8
- package/scripts/lib/zsh-safety-test.sh +67 -0
- package/scripts/orchestrate.sh +124 -22
- package/scripts/portable-test.sh +22 -1
- package/scripts/review-lint-baseline.txt +28 -0
- package/scripts/review-lint-test.sh +271 -0
- package/scripts/review-lint.sh +259 -0
- package/scripts/review-rules.conf +55 -0
- package/scripts/setup-labels.sh +21 -1
- package/scripts/skill-frontmatter-baseline.txt +24 -0
- package/scripts/skill-frontmatter-lint-test.sh +156 -0
- package/scripts/skill-frontmatter-lint.sh +182 -0
- package/scripts/task-sync.sh +8 -0
- package/scripts/test.sh +10 -1
- package/skills/kit-autopilot/SKILL.md +13 -1
- package/skills/kit-cleanup/SKILL.md +5 -3
- package/skills/kit-contribute/SKILL.md +6 -5
- package/skills/kit-effort-close/SKILL.md +8 -3
- package/skills/kit-effort-pr/SKILL.md +16 -95
- package/skills/kit-gc/SKILL.md +15 -10
- package/skills/kit-security-sweep/SKILL.md +4 -6
- package/skills/kit-ship/SKILL.md +1 -1
- package/skills/kit-task-pr/SKILL.md +2 -0
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +193 -0
- package/templates/rules/branch-naming.md +6 -0
- package/templates/rules/effort-model.md +3 -0
- package/templates/rules/naming-and-ids.md +4 -1
- package/templates/settings/settings.json.tmpl +4 -2
|
@@ -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
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# gh-rest-test.sh — the lifecycle verbs work without GraphQL (#396). In rest mode, cckit pr, merge,
|
|
4
|
+
# close, new, effort new, effort pr and effort close send only `gh api repos/…` calls — never
|
|
5
|
+
# `gh api graphql`, `gh pr …` or `gh issue …` — and every board step is skipped with one notice.
|
|
6
|
+
# The default transport is unchanged. Hermetic: a stubbed gh that answers like the REST API (it
|
|
7
|
+
# applies --jq with the real jq), a throwaway repo and a bare remote.
|
|
8
|
+
# Run: bash scripts/lib/gh-rest-test.sh
|
|
9
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
10
|
+
set -u
|
|
11
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
12
|
+
# shellcheck source=/dev/null
|
|
13
|
+
. "$LIB/test-env.sh" && test_env_seal
|
|
14
|
+
unset CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT
|
|
15
|
+
fail=0
|
|
16
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
17
|
+
tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
|
|
18
|
+
command -v jq >/dev/null 2>&1 || { echo "gh-rest-test: jq required" >&2; exit 1; }
|
|
19
|
+
command -v git >/dev/null 2>&1 || { echo "gh-rest-test: git required" >&2; exit 1; }
|
|
20
|
+
|
|
21
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
22
|
+
export GH_LOG="$tmp/gh.log" GH_N="$tmp/n" GH_CLOSED="" GH_HEAD="fix/9-x" GH_BASE="develop" GH_MERGEABLE="true"
|
|
23
|
+
export GH_TITLE="Fix the thing" GH_LABELS='[{"name":"kind:fix"},{"name":"role:tech-lead"}]'
|
|
24
|
+
: > "$GH_LOG"
|
|
25
|
+
|
|
26
|
+
# rest_only <log> <label> — every gh call in <log> is `gh api` on a repos/ endpoint; none is graphql,
|
|
27
|
+
# `gh pr …` or `gh issue …`. (The stub logs one call per line: newlines in a body become \036.)
|
|
28
|
+
rest_only() {
|
|
29
|
+
local bad
|
|
30
|
+
bad="$(grep -vE '^api (-[^ ]+ [^ ]+ )*repos/' "$1" | head -3)"
|
|
31
|
+
if [ -n "$bad" ]; then echo "FAIL: $2 — non-REST gh calls: $bad"; fail=1; else echo "ok: $2"; fi
|
|
32
|
+
if grep -q graphql "$1"; then echo "FAIL: $2 — a graphql call was made"; fail=1; fi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
mkdir -p "$tmp/bin"
|
|
36
|
+
cat > "$tmp/bin/gh" <<'SH'
|
|
37
|
+
#!/usr/bin/env bash
|
|
38
|
+
# A REST-shaped gh: logs every call; `gh api <endpoint>` answers a fixture, through --jq when given.
|
|
39
|
+
{ printf '%s' "$*" | tr '\n' '\036'; echo; } >> "$GH_LOG"
|
|
40
|
+
if [ "$1" != api ]; then # the default (graphql) transport's subcommands
|
|
41
|
+
case "$1 $2" in
|
|
42
|
+
"issue view") printf '{"state":"OPEN","title":"%s","labels":%s,"milestone":{"title":"M1"},"body":"","projectItems":[]}\n' "$GH_TITLE" "$GH_LABELS" ;;
|
|
43
|
+
"issue create") echo "https://github.com/o/r/issues/50" ;;
|
|
44
|
+
"pr create") echo "https://github.com/o/r/pull/7" ;;
|
|
45
|
+
"pr view") printf '{"mergeable":"MERGEABLE","mergeStateStatus":"CLEAN","baseRefName":"%s","headRefName":"%s"}\n' "$GH_BASE" "$GH_HEAD" ;;
|
|
46
|
+
esac
|
|
47
|
+
exit 0
|
|
48
|
+
fi
|
|
49
|
+
shift; ep="$1"; shift
|
|
50
|
+
method=""; jqx=""; fields=""; accept=""
|
|
51
|
+
while [ $# -gt 0 ]; do
|
|
52
|
+
case "$1" in
|
|
53
|
+
-X|--method) method="$2"; shift 2 ;;
|
|
54
|
+
--jq|-q) jqx="$2"; shift 2 ;;
|
|
55
|
+
-f|-F|--raw-field|--field) fields=1; shift 2 ;;
|
|
56
|
+
-H|--header) accept="$2"; shift 2 ;;
|
|
57
|
+
*) shift ;;
|
|
58
|
+
esac
|
|
59
|
+
done
|
|
60
|
+
[ -n "$method" ] || { [ -n "$fields" ] && method=POST || method=GET; }
|
|
61
|
+
# GH_FAIL_EP=<glob>: that endpoint fails the way real gh does — the error JSON on stdout (--jq is
|
|
62
|
+
# not applied), a message on stderr, rc 1.
|
|
63
|
+
case "$ep" in ${GH_FAIL_EP:-//never//})
|
|
64
|
+
printf '{"message":"Not Found","documentation_url":"https://docs.github.com/rest","status":"404"}'
|
|
65
|
+
echo "gh: Not Found (HTTP 404)" >&2; exit 1 ;;
|
|
66
|
+
esac
|
|
67
|
+
next() { n=$(( $(cat "$GH_N" 2>/dev/null || echo 49) + 1 )); echo "$n" > "$GH_N"; echo "$n"; }
|
|
68
|
+
state_of() { case " $GH_CLOSED " in *" $1 "*) echo closed ;; *) echo open ;; esac; }
|
|
69
|
+
json='{}'
|
|
70
|
+
case "$method $ep" in
|
|
71
|
+
"GET repos/o/r/milestones") json='[{"number":2,"title":"M0"},{"number":3,"title":"M1"}]' ;;
|
|
72
|
+
"POST repos/o/r/issues") n="$(next)"; json="{\"number\":$n,\"html_url\":\"https://github.com/o/r/issues/$n\",\"user\":{\"login\":\"me\"}}" ;;
|
|
73
|
+
"GET repos/o/r/issues") json='[{"number":99,"title":"[Effort] 99 · demo effort"},{"number":5,"title":"PR","pull_request":{}}]' ;;
|
|
74
|
+
"GET repos/o/r/issues/"*/sub_issues) json='[{"number":101,"state":"closed"},{"number":102,"state":"closed"}]' ;;
|
|
75
|
+
"GET repos/o/r/issues/"*/timeline)
|
|
76
|
+
sub="${ep#repos/o/r/issues/}"; sub="${sub%/timeline}"
|
|
77
|
+
json="[{\"event\":\"cross-referenced\",\"source\":{\"issue\":{\"number\":6$sub,\"body\":\"mentions #$sub\",\"repository_url\":\"https://api.github.com/repos/o/r\",\"pull_request\":{\"merged_at\":\"2026-01-01\"}}}},
|
|
78
|
+
{\"event\":\"cross-referenced\",\"source\":{\"issue\":{\"number\":5$sub,\"body\":\"Closes #$sub\",\"repository_url\":\"https://api.github.com/repos/o/r\",\"pull_request\":{\"merged_at\":\"2026-01-01\"}}}}]" ;;
|
|
79
|
+
"GET repos/o/r/issues/"*)
|
|
80
|
+
n="${ep##*/}"
|
|
81
|
+
json="{\"number\":$n,\"title\":\"$GH_TITLE\",\"state\":\"$(state_of "$n")\",\"body\":\"## Goal\\nship it\",\"labels\":$GH_LABELS,\"milestone\":{\"number\":3,\"title\":\"M1\"},\"user\":{\"login\":\"me\"}}" ;;
|
|
82
|
+
"POST repos/o/r/pulls") json='{"number":7,"html_url":"https://github.com/o/r/pull/7","user":{"login":"me"}}' ;;
|
|
83
|
+
"GET repos/o/r/pulls") json="[{\"number\":9,\"head\":{\"ref\":\"$GH_HEAD\"},\"state\":\"open\",\"merged_at\":null}]" ;;
|
|
84
|
+
"GET repos/o/r/pulls/"*)
|
|
85
|
+
n="${ep##*/}"
|
|
86
|
+
case "$accept" in *diff*) printf 'diff --git a/src/app.ts b/src/app.ts\n+app\n'; exit 0 ;; esac
|
|
87
|
+
json="{\"number\":$n,\"title\":\"feat: sub $n\",\"mergeable\":$GH_MERGEABLE,\"mergeable_state\":\"clean\",\"base\":{\"ref\":\"$GH_BASE\"},\"head\":{\"ref\":\"$GH_HEAD\"},\"body\":\"Closes #42\\nFixes #43\\nsee #44\",\"state\":\"open\",\"merged_at\":null,\"merge_commit_sha\":\"abc1234def\"}" ;;
|
|
88
|
+
"PUT repos/o/r/pulls/"*/merge) json='{"merged":true}' ;;
|
|
89
|
+
esac
|
|
90
|
+
if [ -n "$jqx" ]; then printf '%s' "$json" | jq -r -c "$jqx"; else printf '%s\n' "$json"; fi
|
|
91
|
+
SH
|
|
92
|
+
chmod +x "$tmp/bin/gh"
|
|
93
|
+
export PATH="$tmp/bin:$PATH" KIT_REPO="o/r" EFFORT_REPO="o/r" KIT_BASE_BRANCH="develop" KIT_WT_INSTALL=0
|
|
94
|
+
unset KIT_CONFIG
|
|
95
|
+
|
|
96
|
+
# shellcheck source=/dev/null
|
|
97
|
+
. "$LIB/gh-rest.sh"
|
|
98
|
+
|
|
99
|
+
# ── the chooser ───────────────────────────────────────────────────────────────────────────────────
|
|
100
|
+
t "default transport is graphql" "$(cckit_gh_transport)" "graphql"
|
|
101
|
+
t "a cloud session defaults to rest" "$(CLAUDE_CODE_REMOTE=true cckit_gh_transport)" "rest"
|
|
102
|
+
t "CCKIT_GH_TRANSPORT=graphql wins in the cloud" "$(CLAUDE_CODE_REMOTE=true CCKIT_GH_TRANSPORT=graphql cckit_gh_transport)" "graphql"
|
|
103
|
+
t "CCKIT_GH_TRANSPORT=rest forces rest locally" "$(CCKIT_GH_TRANSPORT=rest cckit_gh_transport)" "rest"
|
|
104
|
+
t "an unknown value falls to the default" "$(CCKIT_GH_TRANSPORT=soap cckit_gh_transport 2>/dev/null)" "graphql"
|
|
105
|
+
tc <(CCKIT_GH_TRANSPORT=soap cckit_gh_transport 2>&1 >/dev/null) "must be rest or graphql" "an unknown value warns"
|
|
106
|
+
|
|
107
|
+
# ── pure helpers ──────────────────────────────────────────────────────────────────────────────────
|
|
108
|
+
t "closing refs are read from a PR body" \
|
|
109
|
+
"$(printf 'Closes #42\nfixes #43 and resolves #7\nsee #44\nCloses #42\n' | gh_rest_closing_refs | tr '\n' ' ')" "7 42 43 "
|
|
110
|
+
|
|
111
|
+
# ── board steps in rest mode ──────────────────────────────────────────────────────────────────────
|
|
112
|
+
: > "$GH_LOG"
|
|
113
|
+
out="$(CCKIT_GH_TRANSPORT=rest bash -c '
|
|
114
|
+
. "$1/gh-project.sh"
|
|
115
|
+
load_project_ids; echo "rc=$?"
|
|
116
|
+
project_add_item NODE; echo "rc=$?"
|
|
117
|
+
project_set_single_select I F O; echo "rc=$?"
|
|
118
|
+
project_set_text I F T; echo "rc=$?"
|
|
119
|
+
project_find_item_by_issue 5; echo "rc=$?"
|
|
120
|
+
project_issue_status 5; echo "rc=$?"' _ "$LIB" 2>"$tmp/board.err")"
|
|
121
|
+
t "every board function returns 0 in rest mode" "$(printf '%s' "$out" | grep -c '^rc=0$')" "6"
|
|
122
|
+
t "the board functions print nothing on stdout" "$(printf '%s' "$out" | grep -vc '^rc=')" "0"
|
|
123
|
+
t "the notice is printed once" "$(grep -c 'board step skipped' "$tmp/board.err")" "1"
|
|
124
|
+
tc "$tmp/board.err" "^cckit: board step skipped \(GraphQL unavailable; the project's built-in workflows move the card\)$" "the notice wording"
|
|
125
|
+
t "no gh call is made for the board" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
126
|
+
|
|
127
|
+
# ── the task verbs ────────────────────────────────────────────────────────────────────────────────
|
|
128
|
+
git init -q --bare "$tmp/remote.git"
|
|
129
|
+
git clone -q "$tmp/remote.git" "$tmp/work" 2>/dev/null
|
|
130
|
+
cd "$tmp/work" || exit 1
|
|
131
|
+
git config user.email t@t; git config user.name t
|
|
132
|
+
git checkout -q -b develop; git commit -q --allow-empty -m init; git push -q origin develop
|
|
133
|
+
# shellcheck source=/dev/null
|
|
134
|
+
. "$LIB/gh-project.sh"
|
|
135
|
+
# shellcheck source=/dev/null
|
|
136
|
+
. "$LIB/kit-task-ops.sh"
|
|
137
|
+
export KIT_PROJECTS_V2=true CCKIT_GH_TRANSPORT=rest
|
|
138
|
+
|
|
139
|
+
# cckit pr
|
|
140
|
+
git checkout -q -b fix/42-the-thing
|
|
141
|
+
echo x > a.txt; git add a.txt; git commit -q -m wip
|
|
142
|
+
: > "$GH_LOG"
|
|
143
|
+
unset _CCKIT_BOARD_NOTICE_DONE; kto_task_pr 42 "Did the thing." >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
144
|
+
t "pr: rc 0 over REST" "$rc" "0"
|
|
145
|
+
rest_only "$GH_LOG" "pr: only REST calls"
|
|
146
|
+
tc "$GH_LOG" '^api repos/o/r/issues/42 ' "pr: reads the issue over REST"
|
|
147
|
+
tc "$GH_LOG" '^api repos/o/r/pulls -X POST .*-f title=fix: Fix the thing -f head=fix/42-the-thing -f base=develop' "pr: opens the PR with POST pulls"
|
|
148
|
+
tc "$GH_LOG" '^api repos/o/r/issues/7 -X PATCH -f labels\[\]=kind:fix -f labels\[\]=role:tech-lead -f assignees\[\]=me -F milestone=3' "pr: labels, assignee and milestone in one PATCH"
|
|
149
|
+
tc "$tmp/out" 'https://github.com/o/r/pull/7' "pr: prints the PR url"
|
|
150
|
+
t "pr: the board notice is printed once" "$(grep -c 'board step skipped' "$tmp/err")" "1"
|
|
151
|
+
|
|
152
|
+
# cckit new
|
|
153
|
+
: > "$GH_LOG"
|
|
154
|
+
unset _CCKIT_BOARD_NOTICE_DONE; num="$(kto_task_new "Add a thing" tech-lead task p2 M1 "" "" "Body." 2>"$tmp/err" | tail -1)"; rc=$?
|
|
155
|
+
t "new: rc 0 over REST" "$rc" "0"
|
|
156
|
+
rest_only "$GH_LOG" "new: only REST calls"
|
|
157
|
+
tc "$GH_LOG" '^api repos/o/r/issues -X POST -f title=Add a thing .*-f labels\[\]=kind:task -f labels\[\]=priority:p2 -f labels\[\]=role:tech-lead -F milestone=3' "new: POST issues with labels and the milestone number"
|
|
158
|
+
tc "$GH_LOG" "^api repos/o/r/issues/$num/assignees -X POST -f assignees\[\]=me" "new: assigns the issue to its author"
|
|
159
|
+
t "new: echoes the new number" "$num" "50"
|
|
160
|
+
t "new: no 'NOT added to the board' warning" "$(grep -c 'NOT added' "$tmp/err")" "0"
|
|
161
|
+
t "new: the board notice is printed once" "$(grep -c 'board step skipped' "$tmp/err")" "1"
|
|
162
|
+
|
|
163
|
+
# cckit close
|
|
164
|
+
: > "$GH_LOG"
|
|
165
|
+
unset _CCKIT_BOARD_NOTICE_DONE; kto_task_close 5 "Shipped." >/dev/null 2>"$tmp/err"; rc=$?
|
|
166
|
+
t "close: rc 0 over REST" "$rc" "0"
|
|
167
|
+
rest_only "$GH_LOG" "close: only REST calls"
|
|
168
|
+
tc "$GH_LOG" '^api repos/o/r/issues/5/comments -X POST -f body=Shipped\.$' "close: posts the summary"
|
|
169
|
+
tc "$GH_LOG" '^api repos/o/r/issues/5 -X PATCH -f state=closed -f state_reason=completed$' "close: state_reason completed"
|
|
170
|
+
: > "$GH_LOG"
|
|
171
|
+
kto_task_close 6 "Not worth it." --reason not-planned >/dev/null 2>&1
|
|
172
|
+
tc "$GH_LOG" '^api repos/o/r/issues/6 -X PATCH -f state=closed -f state_reason=not_planned$' "close: not-planned maps to not_planned"
|
|
173
|
+
: > "$GH_LOG"
|
|
174
|
+
kto_task_close 7 "Same work." --duplicate-of 4 >/dev/null 2>&1
|
|
175
|
+
tc "$GH_LOG" '^api repos/o/r/issues/7 -X PATCH -f state=closed -f state_reason=duplicate$' "close: duplicate maps to state_reason duplicate"
|
|
176
|
+
tc "$GH_LOG" 'issues/7/comments -X POST -f body=Same work\..*Duplicate of #4\.$' "close: the comment links the original"
|
|
177
|
+
: > "$GH_LOG"; GH_CLOSED="8"
|
|
178
|
+
kto_task_close 8 "x" >/dev/null 2>&1; rc=$?
|
|
179
|
+
t "close: an already-closed issue is fine" "$rc" "0"
|
|
180
|
+
t "close: it is not closed again" "$(grep -c 'PATCH' "$GH_LOG")" "0"
|
|
181
|
+
GH_CLOSED=""
|
|
182
|
+
|
|
183
|
+
# cckit merge — from the PR's worktree, as in the default-mode suite
|
|
184
|
+
git checkout -q develop
|
|
185
|
+
wt="$tmp/work/.claude/worktrees/fix+9-x"
|
|
186
|
+
git worktree add -q -b fix/9-x "$wt" develop
|
|
187
|
+
git -C "$wt" commit -q --allow-empty -m "the fix"
|
|
188
|
+
git -C "$wt" push -q origin fix/9-x
|
|
189
|
+
: > "$GH_LOG"; GH_CLOSED="43"
|
|
190
|
+
unset _CCKIT_BOARD_NOTICE_DONE; ( cd "$wt" && kto_task_pr_merge ) >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
191
|
+
t "merge: rc 0 over REST" "$rc" "0"
|
|
192
|
+
rest_only "$GH_LOG" "merge: only REST calls"
|
|
193
|
+
tc "$GH_LOG" '^api repos/o/r/pulls -X GET -f head=o:fix/9-x -f state=open' "merge: finds the open PR for the branch"
|
|
194
|
+
tc "$GH_LOG" '^api repos/o/r/pulls/9/merge -X PUT -f merge_method=squash$' "merge: squash-merges with PUT pulls/9/merge"
|
|
195
|
+
tc "$GH_LOG" '^api repos/o/r/issues/42 -X PATCH -f state=closed -f state_reason=completed$' "merge: closes the linked open issue"
|
|
196
|
+
t "merge: an already-closed linked issue is left" "$(grep -c 'issues/43 -X PATCH' "$GH_LOG")" "0"
|
|
197
|
+
t "merge: a bare mention is not a closing ref" "$(grep -c 'issues/44' "$GH_LOG")" "0"
|
|
198
|
+
t "merge: the worktree is removed" "$([ -d "$wt" ] && echo present || echo gone)" "gone"
|
|
199
|
+
t "merge: the local branch is deleted" "$(git branch --list fix/9-x | wc -l | tr -d ' ')" "0"
|
|
200
|
+
t "merge: the remote branch is kept" "$(git ls-remote --heads origin fix/9-x | wc -l | tr -d ' ')" "1"
|
|
201
|
+
tc "$tmp/out" 'remote branch fix/9-x kept' "merge: says why the remote branch stays"
|
|
202
|
+
: > "$GH_LOG"; GH_HEAD="fix/10-x"
|
|
203
|
+
kto_task_pr_merge 10 --rebase >/dev/null 2>&1
|
|
204
|
+
tc "$GH_LOG" '^api repos/o/r/pulls/10/merge -X PUT -f merge_method=rebase$' "merge: --rebase reaches merge_method"
|
|
205
|
+
: > "$GH_LOG"; GH_MERGEABLE="false"; GH_HEAD="fix/11-x"
|
|
206
|
+
kto_task_pr_merge 11 >/dev/null 2>&1; rc=$?
|
|
207
|
+
t "merge: a conflicting PR from the base is refused" "$rc" "1"
|
|
208
|
+
t "merge: nothing merged on a conflict" "$(grep -c '/merge' "$GH_LOG")" "0"
|
|
209
|
+
GH_MERGEABLE="true"; GH_CLOSED=""; GH_HEAD="fix/9-x"
|
|
210
|
+
|
|
211
|
+
# ── the default transport is unchanged ────────────────────────────────────────────────────────────
|
|
212
|
+
: > "$GH_LOG"
|
|
213
|
+
CLAUDE_CODE_REMOTE=true CCKIT_GH_TRANSPORT=graphql KIT_PROJECTS_V2=false kto_task_close 12 "Done." >/dev/null 2>&1
|
|
214
|
+
tc "$GH_LOG" '^issue close 12 --repo o/r --reason completed --comment Done\.$' "graphql: close still uses gh issue close"
|
|
215
|
+
t "graphql: no REST close" "$(grep -c '^api ' "$GH_LOG")" "0"
|
|
216
|
+
|
|
217
|
+
# ── the effort verbs ──────────────────────────────────────────────────────────────────────────────
|
|
218
|
+
# shellcheck source=/dev/null
|
|
219
|
+
. "$LIB/effort.sh" 2>/dev/null
|
|
220
|
+
# shellcheck source=/dev/null
|
|
221
|
+
. "$LIB/effort-ops.sh"
|
|
222
|
+
GH_TITLE="[Effort] 99 · demo effort"; GH_LABELS='[{"name":"role:tech-lead"},{"name":"kind:task"}]'
|
|
223
|
+
export KIT_BASE_BRANCH="main"
|
|
224
|
+
|
|
225
|
+
# cckit effort new
|
|
226
|
+
: > "$GH_LOG"
|
|
227
|
+
unset _CCKIT_BOARD_NOTICE_DONE; parent="$(effort_new --flow Core "demo effort" "first sub" "second sub" 2>"$tmp/err")"; rc=$?
|
|
228
|
+
t "effort new: rc 0 over REST" "$rc" "0"
|
|
229
|
+
rest_only "$GH_LOG" "effort new: only REST calls"
|
|
230
|
+
tc "$GH_LOG" '^api repos/o/r/labels -X POST -f name=effort ' "effort new: ensures labels over REST"
|
|
231
|
+
tc "$GH_LOG" "^api repos/o/r/issues -X POST -f title=\[Effort\] · \[Core\] demo effort .*-f labels\[\]=effort" "effort new: POST issues for the parent"
|
|
232
|
+
tc "$GH_LOG" "^api repos/o/r/issues/$parent -X PATCH -f title=\[Effort\] $parent · \[Core\] demo effort$" "effort new: renames the parent with its number"
|
|
233
|
+
tc "$GH_LOG" "^api repos/o/r/issues/$parent/labels -X POST -f labels\[\]=slug:demo-effort$" "effort new: adds the slug label"
|
|
234
|
+
t "effort new: parent + 2 subs created" "$(grep -c '^api repos/o/r/issues -X POST' "$GH_LOG")" "3"
|
|
235
|
+
t "effort new: 2 sub-issues linked" "$(grep -c 'sub_issues' "$GH_LOG")" "2"
|
|
236
|
+
|
|
237
|
+
# cckit effort pr + effort close
|
|
238
|
+
git checkout -q -b main; git push -q origin main
|
|
239
|
+
cd "$tmp/work" || exit 1
|
|
240
|
+
effort_start 99 demo >/dev/null 2>&1
|
|
241
|
+
ewt="$tmp/work/.claude/worktrees/effort+99-demo"
|
|
242
|
+
cd "$ewt" || exit 1
|
|
243
|
+
echo work > file.txt; git add file.txt; git commit -q -m "feat: do the thing (#101)"
|
|
244
|
+
: > "$GH_LOG"
|
|
245
|
+
unset _CCKIT_BOARD_NOTICE_DONE; effort_pr 99 --summary "SUMMARY" >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
246
|
+
t "effort pr: rc 0 over REST" "$rc" "0"
|
|
247
|
+
rest_only "$GH_LOG" "effort pr: only REST calls"
|
|
248
|
+
tc "$GH_LOG" '^api repos/o/r/pulls -X POST -f title=\[#99\] .*-f head=effort/99-demo -f base=main' "effort pr: POST pulls effort/99 → main"
|
|
249
|
+
tc "$GH_LOG" '^api repos/o/r/issues/7 -X PATCH -f labels\[\]=role:tech-lead -f labels\[\]=kind:task .*-F milestone=3' "effort pr: inherits labels + milestone"
|
|
250
|
+
t "effort pr: the board notice is printed once" "$(grep -c 'board step skipped' "$tmp/err")" "1"
|
|
251
|
+
|
|
252
|
+
: > "$GH_LOG"; GH_HEAD="effort/99-demo"; GH_BASE="main"
|
|
253
|
+
unset _CCKIT_BOARD_NOTICE_DONE; close_out="$(effort_close 99 2>&1)"; rc=$?
|
|
254
|
+
cd "$tmp/work" || exit 1
|
|
255
|
+
t "effort close: rc 0 over REST" "$rc" "0"
|
|
256
|
+
rest_only "$GH_LOG" "effort close: only REST calls"
|
|
257
|
+
tc "$GH_LOG" '^api repos/o/r/pulls/9/merge -X PUT -f merge_method=squash$' "effort close: squash-merges over REST"
|
|
258
|
+
tc "$GH_LOG" '^api repos/o/r/issues/101 -X PATCH -f state=closed -f state_reason=completed$' "effort close: closes sub #101"
|
|
259
|
+
tc "$GH_LOG" '^api repos/o/r/issues/99 -X PATCH -f state=closed -f state_reason=completed$' "effort close: closes the parent"
|
|
260
|
+
case "$close_out" in *"remote branch effort/99-demo kept"*) echo "ok: effort close: says why the remote branch stays" ;; *) echo "FAIL: effort close: no remote-branch notice: $close_out"; fail=1 ;; esac
|
|
261
|
+
t "effort close: the board notice is printed once" "$(printf '%s\n' "$close_out" | grep -c 'board step skipped')" "1"
|
|
262
|
+
t "effort close: the local branch is deleted" "$(git branch --list effort/99-demo | wc -l | tr -d ' ')" "0"
|
|
263
|
+
|
|
264
|
+
# wave-style close: no effort branch, the subs shipped as their own merged PRs
|
|
265
|
+
: > "$GH_LOG"
|
|
266
|
+
unset _CCKIT_BOARD_NOTICE_DONE; close_out="$(effort_close 77 2>&1)"; rc=$?
|
|
267
|
+
t "wave close: rc 0 over REST" "$rc" "0"
|
|
268
|
+
rest_only "$GH_LOG" "wave close: only REST calls"
|
|
269
|
+
tc "$GH_LOG" '^api repos/o/r/issues/101/timeline ' "wave close: finds the closing PR in the sub's timeline"
|
|
270
|
+
tc "$GH_LOG" '^api repos/o/r/pulls/5101 -H Accept: application/vnd.github.v3.diff$' "wave close: snapshots the closing PR's diff (not the mention)"
|
|
271
|
+
tc "$GH_LOG" '^api repos/o/r/issues/77 -X PATCH -f state=closed -f state_reason=completed$' "wave close: closes the parent"
|
|
272
|
+
t "wave close: rows match the graphql shape" \
|
|
273
|
+
"$(gh_rest_wave_rows o/r 77 | head -1)" "101|CLOSED|5101|abc1234def|feat: sub 5101"
|
|
274
|
+
|
|
275
|
+
# ── a failed REST read is no data, never the error body ───────────────────────────────────────────
|
|
276
|
+
export GH_FAIL_EP="repos/o/r/issues/404"
|
|
277
|
+
t "failed read: issue state is empty" "$(gh_rest_issue_state o/r 404 2>/dev/null)" ""
|
|
278
|
+
gh_rest_issue_state o/r 404 >/dev/null 2>&1; rc=$?
|
|
279
|
+
t "failed read: issue state returns non-zero" "$rc" "1"
|
|
280
|
+
t "failed read: issue json is empty" "$(gh_rest_issue_json o/r 404 2>/dev/null)" ""
|
|
281
|
+
export GH_FAIL_EP="repos/o/r/issues/404/timeline"
|
|
282
|
+
t "failed read: closing PRs are empty" "$(gh_rest_issue_closing_prs o/r 404 2>/dev/null)" ""
|
|
283
|
+
export GH_FAIL_EP="repos/o/r/pulls"
|
|
284
|
+
t "failed read: no PR for the head" "$(gh_rest_pr_for_head o/r fix/1-x 2>/dev/null)" ""
|
|
285
|
+
export GH_FAIL_EP="repos/o/r/issues/*/sub_issues"
|
|
286
|
+
t "failed read: no sub-issue numbers" "$(gh_rest_sub_issue_numbers o/r 1 2>/dev/null)" ""
|
|
287
|
+
export GH_FAIL_EP="repos/o/r/issues/102/timeline"
|
|
288
|
+
t "failed read: a sub whose timeline fails has no PR" \
|
|
289
|
+
"$(gh_rest_wave_rows o/r 77 2>/dev/null | sed -n 2p)" "102|CLOSED|||"
|
|
290
|
+
: > "$GH_LOG"
|
|
291
|
+
effort_close 77 >/dev/null 2>&1; rc=$?
|
|
292
|
+
t "failed read: wave close refuses" "$rc" "1"
|
|
293
|
+
t "failed read: wave close leaves the parent open" "$(grep -c 'issues/77 -X PATCH' "$GH_LOG")" "0"
|
|
294
|
+
export GH_FAIL_EP="repos/o/r/issues/88"
|
|
295
|
+
effort_start 88 >/dev/null 2>&1
|
|
296
|
+
t "failed read: effort start falls back to the effort slug" \
|
|
297
|
+
"$(git branch --list 'effort/88-*' | tr -d ' *+')" "effort/88-effort"
|
|
298
|
+
unset GH_FAIL_EP
|
|
299
|
+
|
|
300
|
+
[ "$fail" -eq 0 ] && echo "gh-rest: all passed" || echo "gh-rest: FAILURES"
|
|
301
|
+
exit "$fail"
|