@jeiemgi/cckit 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +136 -127
- package/README.md +66 -43
- package/bin/cckit +151 -181
- package/cckit.config.json +1 -4
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot-run-test.sh +20 -12
- package/scripts/autopilot-run.sh +9 -1
- package/scripts/autopilot-test.sh +29 -13
- package/scripts/autopilot.sh +4 -4
- package/scripts/benchmark/verb-timings-test.sh +4 -0
- package/scripts/benchmark/verb-timings.sh +16 -5
- package/scripts/capture-project-ids.sh +23 -1
- package/scripts/check.sh +25 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/contribute.sh +8 -3
- package/scripts/copilot-loop-test.sh +66 -81
- package/scripts/exec-targets-test.sh +20 -0
- package/scripts/force-push-fence-test.sh +44 -0
- package/scripts/force-push-fence.baseline +1 -0
- package/scripts/force-push-fence.sh +51 -0
- package/scripts/forge-fence-test.sh +69 -0
- package/scripts/forge-fence.baseline +2 -0
- package/scripts/forge-fence.sh +76 -0
- package/scripts/forge-report-test.sh +100 -0
- package/scripts/forge-report.sh +176 -0
- package/scripts/init-guided-test.sh +94 -82
- package/scripts/init.sh +12 -7
- package/scripts/install-test.sh +26 -0
- package/scripts/install.sh +7 -0
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +60 -12
- package/scripts/kit-doctor.sh +170 -77
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +15 -8
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +37 -8
- package/scripts/lib/content-kinds-gc-test.sh +22 -21
- package/scripts/lib/copilot-test.sh +20 -11
- package/scripts/lib/copilot.sh +19 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +5 -3
- package/scripts/lib/effort-metrics-test.sh +7 -12
- package/scripts/lib/effort-metrics.sh +17 -46
- package/scripts/lib/effort-ops-test.sh +261 -167
- package/scripts/lib/effort-ops.sh +449 -171
- package/scripts/lib/effort-parity-test.sh +57 -62
- package/scripts/lib/effort-plan-test.sh +56 -54
- package/scripts/lib/effort-plan.sh +14 -7
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +34 -14
- package/scripts/lib/effort-slug.sh +13 -13
- package/scripts/lib/effort.sh +58 -80
- package/scripts/lib/forge-github.sh +260 -0
- package/scripts/lib/forge-none.sh +24 -0
- package/scripts/lib/forge-test.sh +186 -0
- package/scripts/lib/forge.sh +133 -0
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +151 -31
- package/scripts/lib/gh-project.sh +139 -11
- package/scripts/lib/gh-rest-test.sh +63 -118
- package/scripts/lib/gh-rest.sh +275 -52
- package/scripts/lib/git-core-test.sh +128 -0
- package/scripts/lib/grill-record-test.sh +49 -0
- package/scripts/lib/grill-record.sh +88 -0
- package/scripts/lib/handoff.sh +1 -1
- package/scripts/lib/init-github.sh +38 -13
- package/scripts/lib/kinds-test.sh +13 -16
- package/scripts/lib/kit-brief-test.sh +51 -10
- package/scripts/lib/kit-brief.sh +103 -18
- package/scripts/lib/kit-gc-test.sh +90 -109
- package/scripts/lib/kit-gc.sh +19 -22
- package/scripts/lib/kit-hotfix.sh +18 -16
- package/scripts/lib/kit-interview.sh +6 -0
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +7 -7
- package/scripts/lib/kit-msg.sh +3 -3
- package/scripts/lib/kit-status.sh +19 -14
- package/scripts/lib/kit-task-ops-test.sh +20 -1
- package/scripts/lib/kit-task-ops.sh +177 -94
- package/scripts/lib/kto-hotfix-test.sh +53 -58
- package/scripts/lib/kto-task-close-test.sh +28 -27
- package/scripts/lib/kto-task-new-test.sh +55 -48
- package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
- package/scripts/lib/kto-task-pr-test.sh +30 -34
- package/scripts/lib/light-task-run-test.sh +19 -15
- package/scripts/lib/light-task-test.sh +34 -29
- package/scripts/lib/light-task.sh +24 -13
- package/scripts/lib/loose-issues.sh +65 -0
- package/scripts/lib/naming-test.sh +112 -0
- package/scripts/lib/naming-verbs-test.sh +126 -0
- package/scripts/lib/naming.sh +172 -0
- package/scripts/lib/next-test.sh +27 -22
- package/scripts/lib/next.sh +13 -7
- package/scripts/lib/orchestration-runtime-test.sh +11 -8
- package/scripts/lib/plan-machine.sh +22 -16
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +63 -74
- package/scripts/lib/pr-evidence.sh +15 -12
- package/scripts/lib/qa-lane-test.sh +59 -27
- package/scripts/lib/qa-lane.sh +14 -6
- package/scripts/lib/review-page-test.sh +34 -25
- package/scripts/lib/review-page.sh +10 -4
- package/scripts/lib/spec-lint-test.sh +63 -0
- package/scripts/lib/spec-lint.sh +95 -0
- package/scripts/lib/sprint-test.sh +96 -0
- package/scripts/lib/sprint.sh +216 -0
- package/scripts/lib/stage-receipt-test.sh +169 -19
- package/scripts/lib/stage-receipt.sh +195 -10
- package/scripts/lib/test-forge-shim.sh +115 -0
- package/scripts/lib/verbs.sh +105 -0
- package/scripts/lib/verbs.tsv +92 -0
- package/scripts/lib/version-bump-test.sh +20 -0
- package/scripts/lib/version-bump.sh +4 -2
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-issue-test.sh +24 -19
- package/scripts/lib/worktree-issue.sh +10 -10
- package/scripts/lib/worktree-start-test.sh +13 -16
- package/scripts/lib/worktree-start.sh +57 -7
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/marketing-walkthrough-test.sh +25 -30
- package/scripts/night-grant.sh +14 -8
- package/scripts/night-run.mjs +1 -1
- package/scripts/orchestrate-test.sh +27 -31
- package/scripts/orchestrate.sh +9 -3
- package/scripts/portable-test.sh +37 -36
- package/scripts/publish.sh +9 -3
- package/scripts/setup-labels.sh +23 -12
- package/scripts/setup-milestones.sh +8 -2
- package/scripts/status-test.sh +39 -33
- package/scripts/status.sh +12 -6
- package/scripts/task-sync-test.sh +75 -32
- package/scripts/task-sync.sh +97 -6
- package/scripts/terms-check-test.sh +191 -0
- package/scripts/terms-check.sh +242 -0
- package/scripts/verbs-gen.sh +43 -0
- package/scripts/verbs-help-test.sh +61 -0
- package/scripts/verbs-ratchet-test.sh +69 -0
- package/scripts/verbs-ratchet.sh +34 -0
- package/scripts/verbs-test.sh +120 -0
- package/scripts/verbs.baseline +5 -0
- package/skills/kit-add/SKILL.md +2 -1
- package/skills/kit-advisor/SKILL.md +75 -0
- package/skills/kit-advisor/references/close.md +53 -0
- package/skills/kit-advisor/references/grill.md +69 -0
- package/skills/kit-advisor/references/orchestrate.md +56 -0
- package/skills/kit-advisor/references/plan.md +64 -0
- package/skills/kit-advisor/references/review.md +47 -0
- package/skills/kit-advisor/references/step-report.md +61 -0
- package/skills/kit-annotate/SKILL.md +1 -0
- package/skills/kit-autopilot/SKILL.md +2 -1
- package/skills/kit-cleanup/SKILL.md +3 -2
- package/skills/kit-contribute/SKILL.md +1 -0
- package/skills/kit-customize/SKILL.md +1 -0
- package/skills/kit-dev/SKILL.md +1 -0
- package/skills/kit-digest/SKILL.md +1 -0
- package/skills/kit-docs-writer/SKILL.md +4 -3
- package/skills/kit-effort-close/SKILL.md +18 -9
- package/skills/kit-effort-new/SKILL.md +12 -8
- package/skills/kit-effort-pr/SKILL.md +8 -7
- package/skills/kit-effort-start/SKILL.md +1 -0
- package/skills/kit-gc/SKILL.md +1 -0
- package/skills/kit-next/SKILL.md +8 -7
- package/skills/kit-onboard/SKILL.md +1 -0
- package/skills/kit-page/SKILL.md +1 -0
- package/skills/kit-plan-next/SKILL.md +11 -11
- package/skills/kit-security-sweep/SKILL.md +1 -0
- package/skills/kit-ship/SKILL.md +1 -0
- package/skills/kit-status/SKILL.md +6 -5
- package/skills/kit-task-close/SKILL.md +1 -0
- package/skills/kit-task-new/SKILL.md +1 -0
- package/skills/kit-task-pr/SKILL.md +1 -0
- package/skills/kit-task-pr-auto/SKILL.md +2 -1
- package/skills/kit-task-pr-merge/SKILL.md +4 -3
- package/skills/kit-task-start/SKILL.md +1 -0
- package/skills/kit-task-sync/SKILL.md +3 -0
- package/skills/kit-ux-audit/SKILL.md +1 -0
- package/skills/routing.yaml +124 -0
- package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
- package/templates/instructions.md.tmpl +3 -3
- package/templates/rules/authoring.md +7 -3
- package/templates/rules/delegation-brief.md +4 -0
- package/templates/rules/effort-model.md +34 -31
- package/templates/rules/gate-and-review.md +1 -1
- package/templates/rules/merge-safety.md +9 -7
- package/templates/rules/naming-and-ids.md +20 -24
- package/templates/rules/plan-next.md +5 -5
- package/templates/skills/campaign/SKILL.md +2 -2
- package/scripts/lib/engine-adapter.sh +0 -93
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
# effort branch (#376). An effort/* HEAD is refused — its PR merges with `cckit effort close` (#379).
|
|
5
5
|
# A flag taken as the PR number used to "merge" (gh pr merge --help exits 0) and then run the branch
|
|
6
6
|
# cleanup on the base branch; a conflicting PR merged from the hub would rebase + force-push it.
|
|
7
|
-
# Hermetic:
|
|
7
|
+
# Hermetic: the forge shim (REST over a curl stand-in; the merge is PUT repos/o/r/pulls/<n>/merge
|
|
8
|
+
# {"merge_method":…}), throwaway repo + bare remote. Run: bash scripts/lib/kto-task-pr-merge-test.sh
|
|
8
9
|
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
9
10
|
set -u
|
|
10
11
|
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
@@ -14,25 +15,14 @@ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]'
|
|
|
14
15
|
command -v jq >/dev/null 2>&1 || { echo "kto-task-pr-merge-test: jq required" >&2; exit 1; }
|
|
15
16
|
|
|
16
17
|
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
17
|
-
export GH_LOG="$tmp/gh.log" GH_MERGEABLE="
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
echo "$*" >> "$GH_LOG"
|
|
22
|
-
case "$1 $2" in
|
|
23
|
-
"pr view") case "$*" in
|
|
24
|
-
*closingIssuesReferences*) [ -n "${GH_CLOSING:-}" ] && printf '%s\n' $GH_CLOSING; exit 0 ;;
|
|
25
|
-
*"--json body"*) exit 0 ;;
|
|
26
|
-
esac
|
|
27
|
-
printf '{"mergeable":"%s","mergeStateStatus":"CLEAN","baseRefName":"%s","headRefName":"%s"}\n' \
|
|
28
|
-
"$GH_MERGEABLE" "${GH_BASE:-develop}" "${GH_HEAD:-}" ;;
|
|
29
|
-
"issue view") [ -n "${GH_ISSUE_STATE:-}" ] && echo "$GH_ISSUE_STATE"; exit 0 ;;
|
|
30
|
-
*) exit 0 ;;
|
|
31
|
-
esac
|
|
32
|
-
SH
|
|
33
|
-
chmod +x "$tmp/bin/gh"
|
|
18
|
+
export GH_LOG="$tmp/gh.log" GH_MERGEABLE="true" GH_BASE="develop" GH_HEAD="" GH_CLOSED=""; : > "$GH_LOG"
|
|
19
|
+
# shellcheck source=/dev/null
|
|
20
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
|
|
21
|
+
export GH_TOKEN=test-token CCKIT_FORGE=github
|
|
34
22
|
export PATH="$tmp/bin:$PATH" KIT_REPO="o/r" KIT_BASE_BRANCH="develop" KIT_PROJECTS_V2="false"
|
|
35
|
-
unset KIT_CONFIG
|
|
23
|
+
unset KIT_CONFIG CLAUDE_CODE_REMOTE
|
|
24
|
+
# merged <n> — how many times PR <n> was merged (PUT pulls/<n>/merge); merged "" counts every merge.
|
|
25
|
+
merged() { grep -c "^PUT repos/o/r/pulls/$1${1:+/}.*merge " "$GH_LOG"; }
|
|
36
26
|
|
|
37
27
|
git init -q --bare "$tmp/remote.git"
|
|
38
28
|
git clone -q "$tmp/remote.git" "$tmp/work" 2>/dev/null
|
|
@@ -45,48 +35,48 @@ git checkout -q -b develop; git commit -q --allow-empty -m init; git push -q ori
|
|
|
45
35
|
|
|
46
36
|
kto_task_pr_merge --help >/dev/null 2>&1; rc=$?
|
|
47
37
|
t "a flag is refused as a PR number (rc 2)" "$rc" "2"
|
|
48
|
-
t "nothing was merged on a refused flag" "$(
|
|
49
|
-
t "the dispatcher answers --help with usage" "$("$ROOT/bin/cckit" merge --help | cut -c1-18)" "cckit merge [<pr>]"
|
|
38
|
+
t "nothing was merged on a refused flag" "$(merged "")" "0"
|
|
39
|
+
t "the dispatcher answers --help with usage" "$("$ROOT/bin/cckit" merge --help | sed -n 1p | cut -c1-18)" "cckit merge [<pr>]"
|
|
50
40
|
# #376: a bad flag, or a second PR number, is refused with usage and merges nothing
|
|
51
41
|
kto_task_pr_merge 7 --fast >/dev/null 2>"$tmp/errf"; rc=$?
|
|
52
42
|
t "an unknown flag is refused (rc 2)" "$rc" "2"
|
|
53
43
|
t "the refusal prints the usage" "$(grep -c 'usage: cckit merge \[<pr>\] \[--squash|--merge|--rebase\]' "$tmp/errf")" "1"
|
|
54
44
|
kto_task_pr_merge 7 8 >/dev/null 2>&1; rc=$?
|
|
55
45
|
t "two PR numbers are refused (rc 2)" "$rc" "2"
|
|
56
|
-
t "nothing was merged on a refused
|
|
46
|
+
t "nothing was merged on a refused number" "$(merged "")" "0"
|
|
57
47
|
|
|
58
48
|
: > "$GH_LOG"; GH_HEAD="fix/7-x"
|
|
59
49
|
kto_task_pr_merge 7 >/dev/null 2>&1
|
|
60
|
-
t "a numeric PR merges" "$(
|
|
61
|
-
t "the default method is still squash" "$(grep -c '
|
|
62
|
-
# #376: --merge (a merge commit) and --rebase reach
|
|
50
|
+
t "a numeric PR merges" "$(merged 7)" "1"
|
|
51
|
+
t "the default method is still squash" "$(grep -c '^PUT repos/o/r/pulls/7/merge {"merge_method":"squash"}$' "$GH_LOG")" "1"
|
|
52
|
+
# #376: --merge (a merge commit) and --rebase reach the merge_method unchanged
|
|
63
53
|
: > "$GH_LOG"; GH_HEAD="fix/10-x"
|
|
64
54
|
kto_task_pr_merge 10 --merge >/dev/null 2>&1; rc=$?
|
|
65
55
|
t "--merge succeeds" "$rc" "0"
|
|
66
|
-
t "--merge asks GitHub for a merge commit" "$(grep -c '
|
|
56
|
+
t "--merge asks GitHub for a merge commit" "$(grep -c '^PUT repos/o/r/pulls/10/merge {"merge_method":"merge"}$' "$GH_LOG")" "1"
|
|
67
57
|
: > "$GH_LOG"; GH_HEAD="fix/13-x"
|
|
68
58
|
kto_task_pr_merge --rebase 13 >/dev/null 2>&1; rc=$?
|
|
69
59
|
t "--rebase succeeds (flag before the number)" "$rc" "0"
|
|
70
|
-
t "--rebase asks GitHub for a rebase merge" "$(grep -c '
|
|
60
|
+
t "--rebase asks GitHub for a rebase merge" "$(grep -c '^PUT repos/o/r/pulls/13/merge {"merge_method":"rebase"}$' "$GH_LOG")" "1"
|
|
71
61
|
t "merging from the base branch keeps it" "$(git branch --list develop | tr -d ' *')" "develop"
|
|
72
62
|
t "and keeps it on origin" "$(git ls-remote --heads origin develop | wc -l | tr -d ' ')" "1"
|
|
73
63
|
|
|
74
|
-
: > "$GH_LOG"; GH_MERGEABLE="
|
|
64
|
+
: > "$GH_LOG"; GH_MERGEABLE="false"; GH_HEAD="fix/8-x"
|
|
75
65
|
before="$(git rev-parse develop)"
|
|
76
66
|
kto_task_pr_merge 8 >/dev/null 2>&1; rc=$?
|
|
77
67
|
t "a conflicting PR from the base branch is refused" "$rc" "1"
|
|
78
68
|
t "the base branch was not rebased" "$(git rev-parse develop)" "$before"
|
|
79
|
-
t "nothing was merged on a conflict refusal" "$(
|
|
69
|
+
t "nothing was merged on a conflict refusal" "$(merged "")" "0"
|
|
80
70
|
|
|
81
71
|
# ── #371: merged from the PR's OWN worktree, the cleanup still finishes ─────────────────────────
|
|
82
|
-
: > "$GH_LOG"; GH_MERGEABLE="
|
|
72
|
+
: > "$GH_LOG"; GH_MERGEABLE="true"; GH_HEAD="fix/9-x"
|
|
83
73
|
wt="$tmp/work/.claude/worktrees/fix+9-x"
|
|
84
74
|
git worktree add -q -b fix/9-x "$wt" develop
|
|
85
75
|
git -C "$wt" commit -q --allow-empty -m "the fix"
|
|
86
76
|
git -C "$wt" push -q origin fix/9-x
|
|
87
77
|
( cd "$wt" && kto_task_pr_merge 9 ) >/dev/null 2>"$tmp/err9"; rc=$?
|
|
88
78
|
t "merge from inside its worktree exits 0" "$rc" "0"
|
|
89
|
-
t "the PR was merged" "$(
|
|
79
|
+
t "the PR was merged" "$(merged 9)" "1"
|
|
90
80
|
t "its worktree is removed" "$([ -d "$wt" ] && echo present || echo gone)" "gone"
|
|
91
81
|
t "its local branch is deleted" "$(git branch --list fix/9-x | wc -l | tr -d ' ')" "0"
|
|
92
82
|
t "its remote branch is deleted" "$(git ls-remote --heads origin fix/9-x | wc -l | tr -d ' ')" "0"
|
|
@@ -110,7 +100,7 @@ git -C "$tmp/gh-side" push -q origin effort/5-e
|
|
|
110
100
|
: > "$GH_LOG"; GH_BASE="effort/5-e"; GH_HEAD="sub/5a-x"
|
|
111
101
|
( cd "$swt" && kto_task_pr_merge 11 --merge ) >/dev/null 2>&1; rc=$?
|
|
112
102
|
t "a sub PR into an effort branch merges (rc 0)" "$rc" "0"
|
|
113
|
-
t "with a merge commit" "$(grep -c '
|
|
103
|
+
t "with a merge commit" "$(grep -c '^PUT repos/o/r/pulls/11/merge {"merge_method":"merge"}$' "$GH_LOG")" "1"
|
|
114
104
|
t "the sub worktree is removed" "$([ -d "$swt" ] && echo present || echo gone)" "gone"
|
|
115
105
|
t "the sub branch is deleted" "$(git branch --list sub/5a-x | wc -l | tr -d ' ')" "0"
|
|
116
106
|
t "the effort branch survives" "$(git branch --list effort/5-e | tr -d ' *+')" "effort/5-e"
|
|
@@ -134,30 +124,76 @@ t "effort/5-e is still on origin" "$(git ls-remote --heads origin
|
|
|
134
124
|
# The effort worktree lives under the main checkout here; keep it out of `git status` so the main
|
|
135
125
|
# checkout reads clean.
|
|
136
126
|
echo ".claude/" >> "$tmp/work/.git/info/exclude"
|
|
137
|
-
# A caller that left IFS NUL-polluted made `for n in $issues` pass "
|
|
138
|
-
|
|
127
|
+
# A caller that left IFS NUL-polluted made `for n in $issues` pass "42\n43" as ONE issue number.
|
|
128
|
+
# The shim's PR body reads `Closes #42 / Fixes #43 / see #44`; both are open (GH_CLOSED is empty).
|
|
129
|
+
: > "$GH_LOG"; GH_BASE="develop"; GH_HEAD="fix/20-x"
|
|
139
130
|
( IFS=$'\0'; kto_task_pr_merge 20 ) >/dev/null 2>&1; rc=$?
|
|
140
131
|
t "merge under IFS=\$'\\0' exits 0" "$rc" "0"
|
|
141
|
-
t "issue
|
|
142
|
-
t "issue
|
|
143
|
-
t "exactly two issue close calls" "$(grep -c '^
|
|
144
|
-
|
|
132
|
+
t "issue 42 is closed on its own" "$(grep -c '^PATCH repos/o/r/issues/42 {"state":"closed"' "$GH_LOG")" "1"
|
|
133
|
+
t "issue 43 is closed on its own" "$(grep -c '^PATCH repos/o/r/issues/43 {"state":"closed"' "$GH_LOG")" "1"
|
|
134
|
+
t "exactly two issue close calls" "$(grep -c '^PATCH repos/o/r/issues/[0-9]* {"state":"closed"' "$GH_LOG")" "2"
|
|
135
|
+
t "a bare mention (#44) is not closed" "$(grep -c 'issues/44' "$GH_LOG")" "0"
|
|
145
136
|
|
|
146
137
|
# ── #379: an effort/* head is refused — the squash would destroy the per-sub trace ───────────────
|
|
147
138
|
: > "$GH_LOG"; GH_BASE="develop"; GH_HEAD="effort/5-e"
|
|
148
139
|
kto_task_pr_merge 14 >/dev/null 2>"$tmp/err14"; rc=$?
|
|
149
140
|
t "an effort head is refused (rc 1)" "$rc" "1"
|
|
150
141
|
t "the refusal names cckit effort close 5" "$(grep -c 'cckit effort close 5' "$tmp/err14")" "1"
|
|
151
|
-
t "nothing was merged on the effort refusal" "$(
|
|
142
|
+
t "nothing was merged on the effort refusal" "$(merged "")" "0"
|
|
152
143
|
t "the refused effort branch survives" "$(git branch --list effort/5-e | tr -d ' *+')" "effort/5-e"
|
|
153
144
|
( cd "$ewt" && kto_task_pr_merge ) >/dev/null 2>&1; rc=$?
|
|
154
145
|
t "refused from the effort worktree too (rc 1)" "$rc" "1"
|
|
155
|
-
t "still nothing merged" "$(
|
|
146
|
+
t "still nothing merged" "$(merged "")" "0"
|
|
156
147
|
: > "$GH_LOG"
|
|
157
148
|
KIT_FORCE=1 kto_task_pr_merge 14 >/dev/null 2>"$tmp/err14f"; rc=$?
|
|
158
149
|
t "KIT_FORCE=1 merges the effort head (rc 0)" "$rc" "0"
|
|
159
150
|
t "KIT_FORCE=1 warns about the lost trace" "$(grep -c 'KIT_FORCE=1' "$tmp/err14f")" "1"
|
|
160
|
-
t "KIT_FORCE=1 reaches
|
|
151
|
+
t "KIT_FORCE=1 reaches the merge" "$(merged 14)" "1"
|
|
152
|
+
t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
|
|
153
|
+
|
|
154
|
+
# ── #592: a CONFLICTING PR is brought onto its base by merge and pushed plain, never rebased ─────
|
|
155
|
+
git checkout -q develop
|
|
156
|
+
GH_BASE="develop"; GH_MERGEABLE="false"; GH_HEAD="fix/30-x"
|
|
157
|
+
cwt="$tmp/work/.claude/worktrees/fix+30-x"
|
|
158
|
+
git worktree add -q -b fix/30-x "$cwt" develop
|
|
159
|
+
git -C "$cwt" commit -q --allow-empty -m "branch work"
|
|
160
|
+
git -C "$cwt" push -q origin fix/30-x
|
|
161
|
+
own="$(git -C "$cwt" rev-parse HEAD)"
|
|
162
|
+
git clone -q "$tmp/remote.git" "$tmp/gh-side2" 2>/dev/null
|
|
163
|
+
git -C "$tmp/gh-side2" checkout -q develop
|
|
164
|
+
git -C "$tmp/gh-side2" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "base moved"
|
|
165
|
+
git -C "$tmp/gh-side2" push -q origin develop
|
|
166
|
+
basetip="$(git -C "$tmp/gh-side2" rev-parse HEAD)"
|
|
167
|
+
# a fake git on PATH records every push so the test can assert none carries --force*
|
|
168
|
+
mkdir -p "$tmp/gitwrap"; real_git="$(command -v git)"
|
|
169
|
+
printf '#!/usr/bin/env bash\ncase "$*" in *push*--delete*) ;; *push*) echo "$*" >> "%s/git-pushes.log"; "%s" rev-parse HEAD > "%s/pushed-head" ;; esac\nexec "%s" "$@"\n' "$tmp" "$real_git" "$tmp" "$real_git" > "$tmp/gitwrap/git"
|
|
170
|
+
chmod +x "$tmp/gitwrap/git"; : > "$tmp/git-pushes.log"
|
|
171
|
+
: > "$GH_LOG"
|
|
172
|
+
( cd "$cwt" && PATH="$tmp/gitwrap:$PATH" kto_task_pr_merge 30 ) >/dev/null 2>"$tmp/err30"; rc=$?
|
|
173
|
+
t "a conflicting PR from its own worktree merges (rc 0)" "$rc" "0"
|
|
174
|
+
t "the PR was merged" "$(merged 30)" "1"
|
|
175
|
+
t "origin/develop was merged into the branch, then pushed" "$(git -C "$tmp/remote.git" merge-base --is-ancestor "$basetip" "$(cat "$tmp/pushed-head")" 2>/dev/null && echo yes || echo no)" "yes"
|
|
176
|
+
t "the branch's own commit was kept, not rewritten" "$(git -C "$tmp/remote.git" merge-base --is-ancestor "$own" "$(cat "$tmp/pushed-head")" 2>/dev/null && echo yes || echo no)" "yes"
|
|
177
|
+
t "the push was plain" "$(grep -c 'push origin fix/30-x$' "$tmp/git-pushes.log")" "1"
|
|
178
|
+
t "no push carried --force or --force-with-lease" "$(grep -cE -- '--force|[[:space:]]-f([[:space:]]|$)' "$tmp/git-pushes.log")" "0"
|
|
179
|
+
|
|
180
|
+
# a merge that conflicts is aborted and the user is told to resolve it with a merge
|
|
181
|
+
git checkout -q develop
|
|
182
|
+
git pull -q origin develop 2>/dev/null
|
|
183
|
+
cwt2="$tmp/work/.claude/worktrees/fix+31-x"
|
|
184
|
+
git worktree add -q -b fix/31-x "$cwt2" develop
|
|
185
|
+
echo mine > "$cwt2/clash.txt"; git -C "$cwt2" add clash.txt; git -C "$cwt2" commit -q -m "mine"
|
|
186
|
+
git -C "$cwt2" push -q origin fix/31-x
|
|
187
|
+
echo theirs > "$tmp/gh-side2/clash.txt"; git -C "$tmp/gh-side2" pull -q origin develop 2>/dev/null
|
|
188
|
+
git -C "$tmp/gh-side2" add clash.txt; git -C "$tmp/gh-side2" -c user.email=t@t -c user.name=t commit -q -m "theirs"
|
|
189
|
+
git -C "$tmp/gh-side2" push -q origin develop
|
|
190
|
+
: > "$GH_LOG"; GH_HEAD="fix/31-x"
|
|
191
|
+
( cd "$cwt2" && kto_task_pr_merge 31 ) >/dev/null 2>"$tmp/err31"; rc=$?
|
|
192
|
+
t "a textual conflict is refused (rc 1)" "$rc" "1"
|
|
193
|
+
t "nothing was merged" "$(merged "")" "0"
|
|
194
|
+
t "the merge was aborted (no MERGE_HEAD)" "$(git -C "$cwt2" rev-parse -q --verify MERGE_HEAD >/dev/null && echo present || echo gone)" "gone"
|
|
195
|
+
t "the user is told to merge the base in" "$(grep -c 'git merge origin/develop' "$tmp/err31")" "1"
|
|
196
|
+
t "the branch on origin was not rewritten" "$(git ls-remote origin fix/31-x | cut -f1)" "$(git -C "$cwt2" rev-parse HEAD)"
|
|
161
197
|
|
|
162
198
|
[ "$fail" -eq 0 ] && echo "kto-task-pr-merge: all passed" || echo "kto-task-pr-merge: FAILURES"
|
|
163
199
|
exit "$fail"
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# kto-task-pr-test.sh — kto_task_pr end to end against
|
|
2
|
+
# kto-task-pr-test.sh — kto_task_pr end to end against the forge shim and a bare remote (#361, E537):
|
|
3
3
|
# it commits tracked changes only (never an untracked .env.local), and it honours
|
|
4
|
-
# pr.titleStyle + pr.orchestratorSection when it opens the PR.
|
|
4
|
+
# pr.titleStyle + pr.orchestratorSection when it opens the PR over REST (POST repos/o/r/pulls).
|
|
5
5
|
# Run: bash scripts/lib/kto-task-pr-test.sh
|
|
6
6
|
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
7
7
|
set -u
|
|
8
8
|
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
9
9
|
fail=0
|
|
10
10
|
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
11
|
-
tc() { if grep -qE "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in
|
|
11
|
+
tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
|
|
12
12
|
command -v jq >/dev/null 2>&1 || { echo "kto-task-pr-test: jq required" >&2; exit 1; }
|
|
13
13
|
|
|
14
14
|
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
15
15
|
export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"issue view") echo '{"title":"Fix the thing","labels":[{"name":"kind:fix"},{"name":"role:tech-lead"}],"milestone":null}' ;;
|
|
22
|
-
"pr create") echo "https://github.com/o/r/pull/7" ;;
|
|
23
|
-
*) exit 0 ;;
|
|
24
|
-
esac
|
|
25
|
-
SH
|
|
26
|
-
chmod +x "$tmp/bin/gh"
|
|
27
|
-
export PATH="$tmp/bin:$PATH" KIT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_PROJECTS_V2="false"
|
|
16
|
+
# shellcheck source=/dev/null
|
|
17
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
|
|
18
|
+
export PATH="$tmp/bin:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
|
|
19
|
+
export KIT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_PROJECTS_V2="false"
|
|
20
|
+
export GH_TITLE="Fix the thing" GH_LABELS='[{"name":"kind:fix"},{"name":"role:tech-lead"}]'
|
|
28
21
|
unset KIT_CONFIG
|
|
22
|
+
# The PR is opened with ONE POST on repos/o/r/pulls; its JSON body is the log line's third field.
|
|
23
|
+
PR_POST='^POST repos/o/r/pulls \{'
|
|
29
24
|
|
|
30
25
|
git init -q --bare "$tmp/remote.git"
|
|
31
26
|
git clone -q "$tmp/remote.git" "$tmp/work" 2>/dev/null
|
|
@@ -46,13 +41,14 @@ t "the tracked change is committed" "$(git show --name-only --format= HE
|
|
|
46
41
|
t "the untracked .env.local is not" "$(git ls-files .env.local)" ""
|
|
47
42
|
t ".env.local is still on disk" "$(cat .env.local)" "SECRET=x"
|
|
48
43
|
grep -q '.env.local' "$tmp/err" && echo "ok: the untracked file is reported" || { echo "FAIL: untracked file not reported"; fail=1; }
|
|
49
|
-
tc "$GH_LOG"
|
|
50
|
-
tc "$GH_LOG"
|
|
51
|
-
tc "$GH_LOG"
|
|
44
|
+
tc "$GH_LOG" "${PR_POST}\"title\":\"Fix the thing\"," "issue-title: the PR title is the issue title"
|
|
45
|
+
tc "$GH_LOG" "${PR_POST}.*\"body\":\"## For the orchestrator\\\\n" "orchestratorSection: the body opens with the section"
|
|
46
|
+
tc "$GH_LOG" "${PR_POST}.*## For the orchestrator\\\\n\\\\n#42 · Fix the thing\\\\n" "orchestratorSection: id + title line"
|
|
47
|
+
t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
|
|
52
48
|
|
|
53
49
|
: > "$GH_LOG"; git checkout -q -b fix/43-other
|
|
54
50
|
KIT_PR_TITLE_STYLE=conventional kto_task_pr 43 "Other." >/dev/null 2>&1
|
|
55
|
-
tc "$GH_LOG"
|
|
51
|
+
tc "$GH_LOG" "${PR_POST}\"title\":\"fix: Fix the thing \\[#43\\]\"," "conventional (default): a Conventional Commits title + the [#N] token"
|
|
56
52
|
grep -q 'For the orchestrator' "$GH_LOG" && { echo "FAIL: section present with the switch off"; fail=1; } || echo "ok: no section with the switch off"
|
|
57
53
|
|
|
58
54
|
# --base (#391): an explicit base wins over the configured one; the flag is never a positional.
|
|
@@ -60,37 +56,37 @@ grep -q 'For the orchestrator' "$GH_LOG" && { echo "FAIL: section present with t
|
|
|
60
56
|
echo three > tracked.txt
|
|
61
57
|
kto_task_pr 44 "Release." --base release >/dev/null 2>&1
|
|
62
58
|
t "--base: rc 0" "$?" "0"
|
|
63
|
-
tc "$GH_LOG"
|
|
64
|
-
t "--base is not taken as the commit message" "$(git log -1 --format=%s)" "fix: Fix the thing"
|
|
59
|
+
tc "$GH_LOG" "${PR_POST}.*\"head\":\"task/44-release\",\"base\":\"release\"," "--base: the PR targets the given base"
|
|
60
|
+
t "--base is not taken as the commit message" "$(git log -1 --format=%s)" "fix: Fix the thing [#44]"
|
|
65
61
|
: > "$GH_LOG"
|
|
66
62
|
kto_task_pr 44 "Release." >/dev/null 2>&1
|
|
67
|
-
tc "$GH_LOG"
|
|
63
|
+
tc "$GH_LOG" "${PR_POST}.*\"head\":\"task/44-release\",\"base\":\"main\"," "no --base: the PR targets the configured base"
|
|
68
64
|
: > "$GH_LOG"
|
|
69
65
|
kto_task_pr --base=release 44 "Release." >/dev/null 2>&1
|
|
70
|
-
tc "$GH_LOG"
|
|
66
|
+
tc "$GH_LOG" "${PR_POST}.*\"head\":\"task/44-release\",\"base\":\"release\"," "--base=<branch> before the positionals"
|
|
71
67
|
: > "$GH_LOG"
|
|
72
68
|
kto_task_pr 44 "Release." "custom subject" --base release >/dev/null 2>&1
|
|
73
|
-
tc "$GH_LOG"
|
|
69
|
+
tc "$GH_LOG" "${PR_POST}.*\"base\":\"release\"," "--base after an explicit commit message"
|
|
74
70
|
|
|
75
71
|
: > "$GH_LOG"; git checkout -q -b task/45-no-value
|
|
76
72
|
echo four > tracked.txt
|
|
77
73
|
kto_task_pr 45 "No value." --base >/dev/null 2>"$tmp/err"
|
|
78
74
|
t "--base with no value: rc 2" "$?" "2"
|
|
79
75
|
tc "$tmp/err" '[-]-base needs a branch' "--base with no value: says what is missing"
|
|
80
|
-
t "--base with no value: no
|
|
76
|
+
t "--base with no value: no forge request" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
81
77
|
t "--base with no value: nothing pushed" "$(git ls-remote --heads origin task/45-no-value | wc -l | tr -d ' ')" "0"
|
|
82
78
|
t "--base with no value: nothing committed" "$(git status --porcelain --untracked-files=no | wc -l | tr -d ' ')" "1"
|
|
83
79
|
kto_task_pr 45 "No value." --base= >/dev/null 2>&1
|
|
84
80
|
t "--base= (empty): rc 2" "$?" "2"
|
|
85
81
|
|
|
86
|
-
# the dispatcher: `cckit pr --help` prints the usage and reaches neither
|
|
82
|
+
# the dispatcher: `cckit pr --help` prints the usage and reaches neither the forge nor the remote.
|
|
87
83
|
: > "$GH_LOG"
|
|
88
84
|
out="$("$LIB/../../bin/cckit" pr --help 2>/dev/null)"
|
|
89
85
|
t "cckit pr --help: rc 0" "$?" "0"
|
|
90
86
|
case "$out" in *'[--base <branch>]'*) echo "ok: cckit pr --help shows --base" ;; *) echo "FAIL: cckit pr --help -> '$out'"; fail=1 ;; esac
|
|
91
|
-
t "cckit pr --help: no
|
|
92
|
-
grep -qE '
|
|
93
|
-
&& echo "ok: the usage
|
|
87
|
+
t "cckit pr --help: no forge request" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
88
|
+
grep -qE '^pr .* cckit pr <issue> "<summary>" .*\[--base <branch>\]' "$LIB/verbs.tsv" \
|
|
89
|
+
&& echo "ok: the verb table's pr usage shows --base" || { echo "FAIL: the verb table's pr usage lacks --base"; fail=1; }
|
|
94
90
|
|
|
95
91
|
# --base (#360): the flag wins over the configured integration branch, and the PR's target reaches a
|
|
96
92
|
# git pre-push hook as KIT_PR_BASE.
|
|
@@ -104,26 +100,26 @@ export KIT_BASE_BRANCH="develop" # what load_kit_config exported from
|
|
|
104
100
|
echo three > tracked.txt
|
|
105
101
|
kto_task_pr 44 "Hot." --base main >/dev/null 2>&1
|
|
106
102
|
t "--base: kto_task_pr succeeds" "$?" "0"
|
|
107
|
-
tc "$GH_LOG"
|
|
103
|
+
tc "$GH_LOG" "${PR_POST}.*\"base\":\"main\"," "--base main: the PR targets main, not the configured develop"
|
|
108
104
|
t "--base main: the pre-push hook sees it" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=main"
|
|
109
|
-
t "--base is not taken as the commit msg" "$(git log -1 --format=%s)" "fix: Fix the thing"
|
|
105
|
+
t "--base is not taken as the commit msg" "$(git log -1 --format=%s)" "fix: Fix the thing [#44]"
|
|
110
106
|
|
|
111
107
|
: > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/45-eq
|
|
112
108
|
echo four > tracked.txt
|
|
113
109
|
kto_task_pr --base=main 45 "Eq." "fix: custom msg" >/dev/null 2>&1
|
|
114
|
-
tc "$GH_LOG"
|
|
110
|
+
tc "$GH_LOG" "${PR_POST}.*\"base\":\"main\"," "--base=main before the positionals works too"
|
|
115
111
|
t "the commit message positional survives" "$(git log -1 --format=%s)" "fix: custom msg"
|
|
116
112
|
|
|
117
113
|
: > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/46-default
|
|
118
114
|
echo five > tracked.txt
|
|
119
115
|
kto_task_pr 46 "Default." >/dev/null 2>&1
|
|
120
|
-
tc "$GH_LOG"
|
|
116
|
+
tc "$GH_LOG" "${PR_POST}.*\"base\":\"develop\"," "no --base: the configured integration branch"
|
|
121
117
|
t "no --base: the hook gets the integration branch" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=develop"
|
|
122
118
|
|
|
123
119
|
: > "$GH_LOG"; git checkout -q -b fix/47-bad
|
|
124
120
|
kto_task_pr 47 "Bad." --base >/dev/null 2>"$tmp/err"
|
|
125
121
|
t "--base with no value is refused" "$?" "2"
|
|
126
|
-
t "…before any
|
|
122
|
+
t "…before any forge request" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
127
123
|
|
|
128
124
|
[ "$fail" -eq 0 ] && echo "kto-task-pr: all passed" || echo "kto-task-pr: FAILURES"
|
|
129
125
|
exit "$fail"
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
# built from the task record, finish, the review link.
|
|
5
5
|
#
|
|
6
6
|
# Hermetic, in the style of scripts/autopilot-run-test.sh: `claude` and `codex` are one stub script
|
|
7
|
-
# on PATH whose behaviour STUB_MODE selects,
|
|
7
|
+
# on PATH whose behaviour STUB_MODE selects, the forge is the shared shim (test-forge-shim.sh) that
|
|
8
|
+
# logs every REST request, origin is a bare
|
|
8
9
|
# repository in the temp dir. It proves what cckit decides around the agent process (which steps
|
|
9
10
|
# run, what opens a review, the exit code); it does not prove a real agent does the task.
|
|
10
11
|
#
|
|
@@ -70,16 +71,17 @@ STUB
|
|
|
70
71
|
chmod +x "$tmp/bin/agent-stub"
|
|
71
72
|
cp "$tmp/bin/agent-stub" "$tmp/bin/claude"; cp "$tmp/bin/agent-stub" "$tmp/bin/codex"
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
# The forge shim answers the REST API over a curl stand-in and logs every request; `GET pulls?head=…`
|
|
75
|
+
# (the open-review lookup, GH_OPEN_URL) and `POST pulls` (#77) come from this fixture.
|
|
76
|
+
# shellcheck source=/dev/null
|
|
77
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
|
|
78
|
+
export GH_FIXTURE="$tmp/fixture.sh" GH_TOKEN=test-token CCKIT_FORGE=github
|
|
79
|
+
cat > "$GH_FIXTURE" <<'SH'
|
|
80
|
+
case "$method $ep" in
|
|
81
|
+
"GET repos/o/r/pulls") case "$path" in *head=*) out="[$( [ -n "${GH_OPEN_URL:-}" ] && printf '{"number":77,"html_url":"%s"}' "$GH_OPEN_URL" )]" ;; esac ;;
|
|
82
|
+
"POST repos/o/r/pulls") out='{"number":77,"html_url":"https://github.com/o/r/pull/77","user":{"login":"me"}}' ;;
|
|
80
83
|
esac
|
|
81
84
|
SH
|
|
82
|
-
chmod +x "$tmp/bin/gh"
|
|
83
85
|
export PATH="$tmp/bin:$PATH" KIT_WT_INSTALL=0 KIT_STATE_DIR="$tmp/state"
|
|
84
86
|
|
|
85
87
|
git init -q --bare "$tmp/remote.git"
|
|
@@ -95,7 +97,8 @@ printf '.claude/worktrees/\n.cckit/\n' > .gitignore
|
|
|
95
97
|
git add -A; git commit -q -m init; git branch -M develop; git push -q origin develop 2>/dev/null
|
|
96
98
|
W="$tmp/work"
|
|
97
99
|
|
|
98
|
-
creates() { grep -c '^
|
|
100
|
+
creates() { grep -c '^POST repos/o/r/pulls ' "$GH_LOG" || true; }
|
|
101
|
+
create() { grep '^POST repos/o/r/pulls ' "$GH_LOG"; }
|
|
99
102
|
rounds() { cat "$tmp/rounds" 2>/dev/null || echo 0; }
|
|
100
103
|
state() { "$CCKIT" task list --all --llm | jq -r --arg id "$1" '.[] | select(.id == $id) | .state'; }
|
|
101
104
|
|
|
@@ -120,11 +123,12 @@ has "the objective carries the task title" "$(cat "$tmp/claude.prompt")" "Do thi
|
|
|
120
123
|
has "the objective carries the task notes" "$(cat "$tmp/claude.prompt")" "Three sections: hero, menu, contact."
|
|
121
124
|
has "the objective names the task record" "$(cat "$tmp/claude.prompt")" "tasks/$A.md"
|
|
122
125
|
hasnt "a task that is not a page task is not told to use page-design" "$(cat "$tmp/claude.prompt")" "page-design"
|
|
123
|
-
hasnt "and its review has no design section" "$(
|
|
124
|
-
hasnt "and no open-the-page item" "$(
|
|
126
|
+
hasnt "and its review has no design section" "$(create)" "## Design"
|
|
127
|
+
hasnt "and no open-the-page item" "$(create)" "Open the page"
|
|
125
128
|
t "exactly one review was opened" "$(creates)" "1"
|
|
126
|
-
has "the review targets the base branch from the task branch" "$(
|
|
127
|
-
has "its title ends in the task id" "$(
|
|
129
|
+
has "the review targets the base branch from the task branch" "$(create)" "\"head\":\"$BR\",\"base\":\"develop\","
|
|
130
|
+
has "its title ends in the task id" "$(create)" "\"title\":\"feat: Landing page for a bakery [$A]\","
|
|
131
|
+
t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
|
|
128
132
|
t "the pushed branch says the task is done" "$(git --git-dir="$tmp/remote.git" show "$BR:tasks/$A.md" | sed -n 3p)" "status: done"
|
|
129
133
|
t "a file the agent left uncommitted is in the review" "$(git --git-dir="$tmp/remote.git" show "$BR:made.txt")" "made in round 1"
|
|
130
134
|
t "the draft moved off the starting checkout" "$([ -f "$W/tasks/$A.md" ] && echo left || echo moved)" "moved"
|
|
@@ -185,7 +189,7 @@ D="$("$CCKIT" task new "Contact form" --llm | jq -r .id)"
|
|
|
185
189
|
has "and says there is no gate" "$(cat "$tmp/none.err")" "gate: none"
|
|
186
190
|
|
|
187
191
|
# ── page tasks (#504) ───────────────────────────────────────────────────────────────────────────
|
|
188
|
-
body() {
|
|
192
|
+
body() { create | tail -n 1; }
|
|
189
193
|
sfile() { printf '%s/state/autopilot/light_%s-%s.json' "$tmp" "$1" "$2"; }
|
|
190
194
|
|
|
191
195
|
# kind `page`: the objective names the skill, the run records skills, the review lists exactly the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# shellcheck shell=bash
|
|
3
|
-
# light-task-test.sh — `cckit task <new|list|next|start|finish|share>` end to end (#450),
|
|
4
|
-
#
|
|
3
|
+
# light-task-test.sh — `cckit task <new|list|next|start|finish|share>` end to end (#450, E537), over
|
|
4
|
+
# the forge shim, a throwaway repo and a bare remote. Covers every verb in human and `--llm` form, the
|
|
5
5
|
# derived states (draft → doing → review → done; shared), the move of a draft onto its branch, the pull
|
|
6
6
|
# request `finish` opens (no `Closes`, title ending in the task id), the gc protection of a live
|
|
7
7
|
# `light/<id>-<slug>` branch and its release once the task is done on the base branch, a second
|
|
@@ -22,26 +22,30 @@ hasnt() { case "$2" in *"$3"*) echo "FAIL: $1 -> '[$2]' has '[$3]'"; fail=1 ;; *
|
|
|
22
22
|
command -v jq >/dev/null 2>&1 || { echo "light-task-test: jq required" >&2; exit 1; }
|
|
23
23
|
|
|
24
24
|
tmp="$(cd "$(mktemp -d)" && pwd -P)"; trap 'rm -rf "$tmp"' EXIT
|
|
25
|
-
export GH_LOG="$tmp/gh.log" GH_OPEN_URL="" GH_PR_INDEX=""
|
|
25
|
+
export GH_LOG="$tmp/gh.log" GH_OPEN_URL="" GH_PR_INDEX="[]"
|
|
26
26
|
: > "$GH_LOG"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*) [ -n "$
|
|
27
|
+
# shellcheck source=/dev/null
|
|
28
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
|
|
29
|
+
# The pull-request fixtures the shim does not know: `GET pulls?head=…` answers the open-PR lookup
|
|
30
|
+
# (GH_OPEN_URL, empty = none), a bare `GET pulls` answers gc's PR index (GH_PR_INDEX, a JSON array),
|
|
31
|
+
# and `POST pulls` opens #77 — or answers 500 with GH_CREATE_FAIL=1.
|
|
32
|
+
export GH_FIXTURE="$tmp/fixture.sh"
|
|
33
|
+
cat > "$GH_FIXTURE" <<'SH'
|
|
34
|
+
case "$method $ep" in
|
|
35
|
+
"GET repos/o/r/pulls")
|
|
36
|
+
case "$path" in
|
|
37
|
+
*head=*) out="[$( [ -n "${GH_OPEN_URL:-}" ] && printf '{"number":77,"html_url":"%s"}' "$GH_OPEN_URL" )]" ;;
|
|
38
|
+
*) out="${GH_PR_INDEX:-[]}" ;;
|
|
38
39
|
esac ;;
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
"POST repos/o/r/pulls")
|
|
41
|
+
if [ -n "${GH_CREATE_FAIL:-}" ]; then out='{"message":"boom"}'; code=500
|
|
42
|
+
else out='{"number":77,"html_url":"https://github.com/o/r/pull/77","user":{"login":"me"}}'; fi ;;
|
|
43
|
+
"GET repos/o/r/issues/"*) echo "issue lookups are not expected for a light task" >&2; out='{"message":"Not Found"}'; code=404 ;;
|
|
42
44
|
esac
|
|
43
45
|
SH
|
|
44
|
-
|
|
46
|
+
export GH_TOKEN=test-token CCKIT_FORGE=github
|
|
47
|
+
# The PR a verb opens: ONE POST on repos/o/r/pulls; its JSON body is the log line's third field.
|
|
48
|
+
pr_post() { grep '^POST repos/o/r/pulls ' "$GH_LOG"; }
|
|
45
49
|
export PATH="$tmp/bin:$PATH" KIT_WT_INSTALL=0
|
|
46
50
|
|
|
47
51
|
git init -q --bare "$tmp/remote.git"
|
|
@@ -126,7 +130,7 @@ out="$("$CCKIT" gc 2>/dev/null)"
|
|
|
126
130
|
has "cckit gc keeps a started task (no commit beyond base would otherwise read LANDED)" \
|
|
127
131
|
"$(printf '%s\n' "$out" | grep " light/$B-")" "PROTECTED: light task $B still OPEN"
|
|
128
132
|
hasnt "cckit gc offers no light branch for deletion" "$(printf '%s\n' "$out" | grep 'light/')" "> LANDED"
|
|
129
|
-
t "gc never asked GitHub about an issue for a light branch" "$(grep -c '^
|
|
133
|
+
t "gc never asked GitHub about an issue for a light branch" "$(grep -c '^GET repos/o/r/issues/' "$GH_LOG")" "0"
|
|
130
134
|
out="$(cd "$W" && KIT_TASKS_SOURCE=nosuch bash -c '. "$1/worktree-issue.sh"; wt_task_state t3f9a light/t3f9a-x; wt_protected_reason light/t3f9a-x' _ "$LIB")"
|
|
131
135
|
t "a source that cannot be read is unknown, and unknown is kept" "$out" "unknown
|
|
132
136
|
light task t3f9a state unknown"
|
|
@@ -141,16 +145,17 @@ t "the work is committed with the task" "$(git -C "$WT" show --stat --format= HE
|
|
|
141
145
|
has "a new file is reported, not committed" "$(cat "$tmp/fin.err")" "new-post.txt"
|
|
142
146
|
t "the new file stays untracked without --all" "$(git -C "$WT" ls-files new-post.txt | grep -c .)" "0"
|
|
143
147
|
t "the pushed branch carries the done mark" "$(git --git-dir="$tmp/remote.git" show "$BR:tasks/$A.md" | sed -n 3p)" "status: done"
|
|
144
|
-
create="$(
|
|
145
|
-
has "the PR targets the base branch" "$create" "
|
|
146
|
-
has "the PR title is a Conventional Commit subject ending in the task id" "$create" "
|
|
148
|
+
create="$(pr_post)"
|
|
149
|
+
has "the PR targets the base branch" "$create" "\"head\":\"$BR\",\"base\":\"develop\","
|
|
150
|
+
has "the PR title is a Conventional Commit subject ending in the task id" "$create" "\"title\":\"feat: Write the spring newsletter [$A]\","
|
|
147
151
|
has "the PR body names the task" "$create" "\`$A\` · Write the spring newsletter"
|
|
148
152
|
hasnt "the PR body has no Closes line" "$create" "Closes #"
|
|
153
|
+
t "no gh subcommand ran in finish" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
|
|
149
154
|
t "list shows the task in review" "$("$CCKIT" task list --llm | jq -r --arg id "$A" '.[] | select(.id == $id) | .state')" "review"
|
|
150
155
|
: > "$GH_LOG"
|
|
151
156
|
out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" task done "$A" "again" --all --llm)"
|
|
152
157
|
t "done is finish; --llm reports the url" "$(printf '%s' "$out" | jq -r '[.verb, .ok, .url] | join(" ")')" "task finish true https://github.com/o/r/pull/77"
|
|
153
|
-
t "an open PR is reported, not re-created" "$(grep -c
|
|
158
|
+
t "an open PR is reported, not re-created" "$(pr_post | grep -c .)" "0"
|
|
154
159
|
t "--all commits new files" "$(git -C "$WT" ls-files new-post.txt | grep -c .)" "1"
|
|
155
160
|
"$CCKIT" task finish "$B" >/dev/null 2>&1; t "finish without a summary is a usage error" "$?" "2"
|
|
156
161
|
"$CCKIT" task finish zz9 "x" >/dev/null 2>&1; t "finish refuses an unknown task" "$?" "1"
|
|
@@ -174,8 +179,8 @@ has "plain language: start says how to send it for review" "$(cat "$tmp/start-pl
|
|
|
174
179
|
hasnt "the default wording's finish hint does not add --all" "$(cat "$tmp/start.err")" "<summary>\" --all"
|
|
175
180
|
hasnt "plain language: start does not say 'created worktree'" "$(cat "$tmp/start-plain.err")" "created worktree"
|
|
176
181
|
hasnt "plain language: start does not name the branch" "$(cat "$tmp/start-plain.err")" "(branch "
|
|
177
|
-
create="$(
|
|
178
|
-
has "a conventional summary becomes the PR title, with the id" "$create" "
|
|
182
|
+
create="$(pr_post)"
|
|
183
|
+
has "a conventional summary becomes the PR title, with the id" "$create" "\"title\":\"fix: launch posts scheduled [$B]\","
|
|
179
184
|
has "content body: names the task" "$create" "\`$B\` · "
|
|
180
185
|
has "content body: review checklist" "$create" "Read the draft from start to finish"
|
|
181
186
|
has "content body: says what approving does" "$create" "Approving and merging this pull request marks the task done"
|
|
@@ -216,7 +221,7 @@ t "share prints the PR url" "$out" "✓ https://github.com/o/r/pull/77"
|
|
|
216
221
|
SB="$(git for-each-ref --format='%(refname:short)' 'refs/heads/light/share-*')"
|
|
217
222
|
t "the share branch carries both tasks and nothing else" "$(git diff --name-only origin/develop "$SB" | sort | tr '\n' ' ')" \
|
|
218
223
|
"$(printf 'tasks/%s.md\ntasks/%s.md\n' "$C" "$D" | sort | tr '\n' ' ')"
|
|
219
|
-
has "the share PR title counts the tasks" "$(
|
|
224
|
+
has "the share PR title counts the tasks" "$(pr_post)" "\"title\":\"chore(tasks): add 2 tasks [share-"
|
|
220
225
|
t "share leaves the checkout clean" "$(git status --porcelain)" ""
|
|
221
226
|
t "shared tasks stay listed, as shared, on the share branch" "$("$CCKIT" task list --llm | jq -r --arg id "$C" '.[] | select(.id == $id) | .state + " " + .branch')" "shared $SB"
|
|
222
227
|
t "next does not offer a shared task" "$("$CCKIT" task next --llm | jq -r --arg c "$C" --arg d "$D" 'if . == null then "none" elif .id == $c or .id == $d then "shared" else "other" end')" "none"
|
|
@@ -226,7 +231,7 @@ has "the refusal names the share branch" "$out" "share pull request ($SB)"
|
|
|
226
231
|
: > "$GH_LOG"
|
|
227
232
|
out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" task share 2>/dev/null)"
|
|
228
233
|
t "share with no new drafts reports the open share PR" "$out" "✓ https://github.com/o/r/pull/77"
|
|
229
|
-
t "and does not create a second one" "$(grep -c
|
|
234
|
+
t "and does not create a second one" "$(pr_post | grep -c .)" "0"
|
|
230
235
|
# The share PR merges: the tasks are todo, and a share with nothing pending is a no-op.
|
|
231
236
|
( cd "$tmp/merger" && git fetch -q origin && git checkout -q develop && git pull -q origin develop \
|
|
232
237
|
&& git merge -q --squash "origin/$SB" >/dev/null 2>&1 && git commit -q -m "chore(tasks): add 2 tasks (#78)" \
|
|
@@ -241,7 +246,7 @@ t "the task of a failed share is still listed" "$("$CCKIT" task list --llm | jq
|
|
|
241
246
|
: > "$GH_LOG"
|
|
242
247
|
out="$("$CCKIT" task share --llm)"
|
|
243
248
|
t "re-running share opens the PR for the pending branch" "$(printf '%s' "$out" | jq -r '[.verb, .ok, .url] | join(" ")')" "task share true https://github.com/o/r/pull/77"
|
|
244
|
-
has "the retried PR lists the pending task" "$(
|
|
249
|
+
has "the retried PR lists the pending task" "$(pr_post)" "\`$G\`"
|
|
245
250
|
out="$(cd "$WTB" && GH_CREATE_FAIL=1 "$CCKIT" task finish "fix: launch posts scheduled" 2>&1)"; t "finish exits 1 when the PR cannot be opened" "$?" "1"
|
|
246
251
|
has "finish says the branch is pushed and how to retry" "$out" "the branch is pushed; run the same command again to retry"
|
|
247
252
|
t "the share branch is not a task" "$(. "$LIB/kit-config.sh" && load_kit_config && . "$LIB/worktree-issue.sh" && wt_protected_reason "$SB" o/r)" ""
|
|
@@ -277,7 +282,7 @@ has "…and names the command that starts the task" "$want" "start: cckit task s
|
|
|
277
282
|
t "cckit next --llm is the light task object" "$(KIT_TASK_FETCH=0 "$CCKIT" next --llm 2>/dev/null | jq -r 'has("start")')" "true"
|
|
278
283
|
: > "$GH_LOG"
|
|
279
284
|
KIT_TASK_FETCH=0 "$CCKIT" next >/dev/null 2>&1
|
|
280
|
-
t "the light next makes no
|
|
285
|
+
t "the light next makes no forge request" "$(grep -c . "$GH_LOG" | tr -d ' ')" "0"
|
|
281
286
|
jq '.tasks.default = "sometimes"' cckit.config.json > c.tmp && mv c.tmp cckit.config.json
|
|
282
287
|
out="$("$CCKIT" task default 2>"$tmp/default.err")"
|
|
283
288
|
t "an unknown tasks.default reads as issues" "$out" "issues"
|