@jeiemgi/cckit 0.9.0 → 0.10.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 +169 -21
- package/README.md +491 -35
- package/SECURITY.md +5 -0
- package/bin/cckit +182 -17
- package/cckit.config.json +1 -1
- package/commands/kit-doctor.md +13 -5
- package/commands/kit-export-project.md +0 -2
- package/commands/kit-export-training.md +6 -9
- package/commands/kit-init.md +43 -13
- package/commands/kit-routines.md +1 -1
- package/commands/kit-update.md +11 -6
- package/databases/supabase/guide.html +106 -0
- package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
- package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
- package/databases/supabase.json +70 -0
- package/integrations/emil-design-eng.json +41 -0
- package/integrations/graft.json +81 -0
- package/integrations/impeccable.json +42 -0
- package/integrations/integration.schema.json +215 -0
- package/integrations/lavish.json +43 -0
- package/integrations/mempalace.json +28 -0
- package/integrations/mlx-lm.json +32 -0
- package/integrations/web-design-guidelines.json +42 -0
- package/kit.config.schema.json +183 -5
- package/package.json +4 -1
- package/profiles/automation.json +7 -1
- package/profiles/content.json +10 -2
- package/profiles/marketing.json +57 -0
- package/profiles/minimal.json +7 -1
- package/profiles/research.json +7 -1
- package/profiles/software.json +7 -1
- package/recipes/nextjs-shadcn.json +49 -0
- package/scripts/agent-skills-external.txt +45 -0
- package/scripts/agent-skills-lint-test.sh +131 -0
- package/scripts/agent-skills-lint.sh +115 -0
- package/scripts/agent-template-lint-test.sh +42 -0
- package/scripts/agent-template-lint.sh +58 -0
- package/scripts/annotate-setup.sh +1 -1
- package/scripts/autopilot-run-test.sh +338 -0
- package/scripts/autopilot-run.sh +448 -0
- package/scripts/autopilot-test.sh +8 -0
- package/scripts/autopilot.sh +10 -1
- package/scripts/benchmark/benchmark-test.sh +85 -0
- package/scripts/benchmark/checkpoint-test.sh +314 -0
- package/scripts/benchmark/checkpoint.sh +408 -0
- package/scripts/benchmark/lib/model.sh +31 -6
- package/scripts/benchmark/report.sh +17 -2
- package/scripts/benchmark/run-quality.sh +36 -10
- package/scripts/benchmark/verb-timings-test.sh +124 -0
- package/scripts/benchmark/verb-timings.sh +149 -0
- package/scripts/check.sh +29 -19
- package/scripts/content-skills-test.sh +144 -0
- package/scripts/copilot-loop-test.sh +25 -0
- package/scripts/database-supabase-test.sh +121 -0
- package/scripts/docs-marketing-words-test.sh +73 -0
- package/scripts/docs-record-tables-test.sh +72 -0
- package/scripts/hook-adapter-test.sh +193 -0
- package/scripts/init-content-test.sh +225 -0
- package/scripts/init-guided-test.sh +474 -0
- package/scripts/init-recipes-test.sh +104 -0
- package/scripts/init-upgrade-test.sh +341 -2
- package/scripts/init.sh +746 -95
- package/scripts/instruction-budget-baseline.txt +8 -0
- package/scripts/instruction-budget-lint-test.sh +166 -0
- package/scripts/instruction-budget-lint.sh +219 -0
- package/scripts/integrations-check-test.sh +200 -0
- package/scripts/integrations-check.sh +157 -0
- package/scripts/kit-add-test.sh +214 -0
- package/scripts/kit-add.sh +305 -5
- package/scripts/kit-adopt-test.sh +16 -0
- package/scripts/kit-adopt.sh +3 -2
- package/scripts/kit-digest.sh +2 -2
- package/scripts/kit-doctor-test.sh +293 -0
- package/scripts/kit-doctor.sh +272 -140
- package/scripts/kit-export-project-test.sh +3 -3
- package/scripts/kit-remove-test.sh +19 -0
- package/scripts/kit-routines.sh +2 -2
- package/scripts/kit-self-update.sh +1 -1
- package/scripts/kit-version-check-test.sh +4 -0
- package/scripts/kit-version-check.sh +4 -2
- package/scripts/knowledge-lint.sh +4 -4
- package/scripts/leak-fence-test.sh +89 -0
- package/scripts/lib/adapter-select-test.sh +136 -0
- package/scripts/lib/adapter-select.sh +158 -0
- package/scripts/lib/agent-def-test.sh +69 -0
- package/scripts/lib/agent-def.sh +106 -0
- package/scripts/lib/agent-launch-test.sh +212 -0
- package/scripts/lib/agent-launch.sh +335 -0
- package/scripts/lib/board-view-test.sh +11 -0
- package/scripts/lib/board-view.sh +42 -26
- package/scripts/lib/branch-owner-test.sh +26 -0
- package/scripts/lib/branch-owner.sh +16 -9
- package/scripts/lib/captain-test.sh +105 -0
- package/scripts/lib/captain.sh +87 -8
- package/scripts/lib/codex-hooks-test.sh +100 -0
- package/scripts/lib/codex-hooks.sh +69 -0
- package/scripts/lib/commitlint.sh +1 -1
- package/scripts/lib/content-kinds-gc-test.sh +88 -0
- package/scripts/lib/copilot-test.sh +70 -4
- package/scripts/lib/copilot.sh +66 -14
- package/scripts/lib/effort-dispatch-test.sh +3 -3
- package/scripts/lib/effort-metrics-test.sh +178 -1
- package/scripts/lib/effort-metrics.sh +175 -35
- package/scripts/lib/effort-ops-test.sh +205 -7
- package/scripts/lib/effort-ops.sh +198 -43
- package/scripts/lib/effort-parity-test.sh +49 -13
- package/scripts/lib/effort-plan-test.sh +337 -0
- package/scripts/lib/effort-plan.sh +200 -23
- package/scripts/lib/effort.sh +56 -11
- package/scripts/lib/errors-header-test.sh +1 -1
- package/scripts/lib/gh-project-test.sh +35 -1
- package/scripts/lib/gh-project.sh +23 -16
- package/scripts/lib/gh-rest-test.sh +32 -3
- package/scripts/lib/gh-rest.sh +17 -2
- package/scripts/lib/hook-refresh.sh +1 -1
- package/scripts/lib/init-github.sh +412 -0
- package/scripts/lib/init-guide.sh +630 -0
- package/scripts/lib/integration-install-test.sh +343 -0
- package/scripts/lib/integration-install.sh +257 -0
- package/scripts/lib/integrations-test.sh +366 -0
- package/scripts/lib/integrations.sh +244 -0
- package/scripts/lib/kinds-test.sh +125 -0
- package/scripts/lib/kinds.sh +66 -0
- package/scripts/lib/kit-brief-test.sh +22 -3
- package/scripts/lib/kit-brief.sh +45 -5
- package/scripts/lib/kit-config-resolve.sh +2 -2
- package/scripts/lib/kit-config-test.sh +64 -1
- package/scripts/lib/kit-config.sh +37 -1
- package/scripts/lib/kit-events.sh +7 -0
- package/scripts/lib/kit-gc-test.sh +173 -1
- package/scripts/lib/kit-gc.sh +226 -37
- package/scripts/lib/kit-hotfix.sh +216 -0
- package/scripts/lib/kit-interview-test.sh +93 -0
- package/scripts/lib/kit-interview.sh +117 -8
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +3 -3
- package/scripts/lib/kit-local.sh +2 -2
- package/scripts/lib/kit-manifest.sh +33 -1
- package/scripts/lib/kit-profile-test.sh +3 -3
- package/scripts/lib/kit-status-test.sh +112 -4
- package/scripts/lib/kit-status.sh +246 -16
- package/scripts/lib/kit-task-ops-test.sh +37 -0
- package/scripts/lib/kit-task-ops.sh +175 -31
- package/scripts/lib/kto-hotfix-test.sh +232 -0
- package/scripts/lib/kto-task-close-test.sh +1 -1
- package/scripts/lib/kto-task-new-test.sh +95 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +37 -3
- package/scripts/lib/kto-task-pr-test.sh +70 -0
- package/scripts/lib/leak-fence.sh +89 -0
- package/scripts/lib/light-task-run-test.sh +255 -0
- package/scripts/lib/light-task-test.sh +309 -0
- package/scripts/lib/light-task.sh +706 -0
- package/scripts/lib/next-test.sh +99 -0
- package/scripts/lib/next.sh +9 -3
- package/scripts/lib/orchestration-runtime-test.sh +72 -0
- package/scripts/lib/orchestration-runtime.sh +57 -5
- package/scripts/lib/plan-machine-test.sh +15 -2
- package/scripts/lib/plan-machine.sh +20 -7
- package/scripts/lib/plan-next-test.sh +1 -1
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +3 -3
- package/scripts/lib/pr-evidence.sh +1 -1
- package/scripts/lib/qa-lane-test.sh +626 -0
- package/scripts/lib/qa-lane.sh +1357 -0
- package/scripts/lib/qa-lanes-test.sh +175 -0
- package/scripts/lib/react-detect.sh +1 -1
- package/scripts/lib/render-test.sh +1 -1
- package/scripts/lib/review-page-test.sh +318 -0
- package/scripts/lib/review-page.sh +369 -0
- package/scripts/lib/review-stage-test.sh +62 -11
- package/scripts/lib/review-stage.sh +42 -60
- package/scripts/lib/role-identity-test.sh +65 -0
- package/scripts/lib/role-identity.sh +25 -2
- package/scripts/lib/secret-guard.sh +3 -3
- package/scripts/lib/session-registry-test.sh +111 -0
- package/scripts/lib/session-registry.sh +233 -0
- package/scripts/lib/stage-receipt-test.sh +14 -1
- package/scripts/lib/stage-receipt.sh +13 -8
- package/scripts/lib/task-source-file.sh +309 -0
- package/scripts/lib/task-source.sh +130 -0
- package/scripts/lib/upgrade-report-test.sh +120 -0
- package/scripts/lib/upgrade-report.sh +138 -0
- package/scripts/lib/version-bump.sh +3 -3
- package/scripts/lib/wave-result-test.sh +80 -0
- package/scripts/lib/wave-result.sh +127 -0
- package/scripts/lib/worker-brief-test.sh +5 -0
- package/scripts/lib/worker-brief.sh +2 -2
- package/scripts/lib/worktree-issue-test.sh +30 -1
- package/scripts/lib/worktree-issue.sh +82 -12
- package/scripts/lib/worktree-ports-test.sh +57 -4
- package/scripts/lib/worktree-start-test.sh +197 -0
- package/scripts/lib/worktree-start.sh +153 -31
- package/scripts/lib/zsh-safety-test.sh +19 -3
- package/scripts/marketing-walkthrough-test.sh +152 -0
- package/scripts/night-grant-test.sh +37 -0
- package/scripts/night-grant.sh +448 -0
- package/scripts/night-run-test.sh +8 -0
- package/scripts/night-run.mjs +275 -0
- package/scripts/night-run.test.mjs +324 -0
- package/scripts/orchestrate-test.sh +190 -0
- package/scripts/orchestrate.sh +79 -8
- package/scripts/portable-test.sh +11 -2
- package/scripts/publish.sh +28 -3
- package/scripts/review-lint-test.sh +7 -7
- package/scripts/review-lint.sh +2 -2
- package/scripts/review-rules.conf +8 -0
- package/scripts/rule-recipes-test.sh +96 -0
- package/scripts/self-install-test.sh +39 -9
- package/scripts/setup-labels.sh +18 -1
- package/scripts/setup-milestones.sh +1 -1
- package/scripts/showcase.sh +1 -1
- package/scripts/skill-frontmatter-lint-test.sh +4 -4
- package/scripts/skill-frontmatter-lint.sh +1 -1
- package/scripts/status-test.sh +113 -2
- package/scripts/status.sh +16 -3
- package/scripts/task-sync-test.sh +154 -0
- package/scripts/task-sync.sh +243 -32
- package/scripts/test-runner-test.sh +158 -0
- package/scripts/test.sh +131 -23
- package/scripts/update-path-test.sh +279 -0
- package/scripts/ux-ds-audit.sh +1 -1
- package/scripts/ux-graph-scan.sh +6 -6
- package/scripts/wave-worker.sh +54 -0
- package/skills/kit-add/SKILL.md +77 -0
- package/skills/kit-autopilot/SKILL.md +123 -12
- package/skills/kit-cleanup/SKILL.md +5 -2
- package/skills/kit-contribute/SKILL.md +4 -4
- package/skills/kit-docs-writer/SKILL.md +16 -6
- package/skills/kit-effort-close/SKILL.md +17 -8
- package/skills/kit-effort-new/SKILL.md +15 -9
- package/skills/kit-effort-pr/SKILL.md +15 -7
- package/skills/kit-effort-start/SKILL.md +5 -2
- package/skills/kit-gc/SKILL.md +5 -2
- package/skills/kit-next/SKILL.md +5 -1
- package/skills/kit-onboard/SKILL.md +3 -3
- package/skills/kit-page/SKILL.md +93 -0
- package/skills/kit-plan-next/SKILL.md +8 -4
- package/skills/kit-security-sweep/SKILL.md +1 -3
- package/skills/kit-ship/SKILL.md +2 -3
- package/skills/kit-status/SKILL.md +35 -4
- package/skills/kit-task-new/SKILL.md +3 -3
- package/skills/kit-task-pr/SKILL.md +7 -2
- package/skills/kit-task-pr-merge/SKILL.md +7 -2
- package/skills/kit-task-start/SKILL.md +7 -7
- package/skills/kit-task-sync/SKILL.md +19 -3
- package/skills/kit-ux-audit/SKILL.md +3 -2
- package/templates/agents/auto-dev.md +5 -4
- package/templates/agents/backend.md +1 -1
- package/templates/agents/designer.md +2 -0
- package/templates/agents/devops.md +1 -1
- package/templates/agents/editor.md +9 -1
- package/templates/agents/frontend.md +1 -1
- package/templates/agents/local-delegate.md +1 -1
- package/templates/agents/pm.md +5 -5
- package/templates/agents/tech-lead.md +1 -1
- package/templates/benchmarks/SCHEMA.md +9 -3
- package/templates/codex/hooks.json.tmpl +89 -0
- package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +12 -12
- package/templates/hooks/mempal_followup.sh.tmpl +2 -2
- package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
- package/templates/hooks/prepush_gate.sh.tmpl +4 -2
- package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
- package/templates/instructions.md.tmpl +174 -0
- package/templates/kit.config.json.tmpl +3 -3
- package/templates/knowledge-INDEX.md.tmpl +1 -1
- package/templates/lib/kit-sigil.sh.tmpl +1 -1
- package/templates/rules/authoring.md +106 -0
- package/templates/rules/branch-naming.md +40 -4
- package/templates/rules/code-retrieval.md +63 -0
- package/templates/rules/delegation-brief.md +0 -3
- package/templates/rules/design-routing.md +3 -3
- package/templates/rules/effort-model.md +14 -10
- package/templates/rules/gate-and-review.md +94 -0
- package/templates/rules/issue-lifecycle.md +88 -0
- package/templates/rules/knowledge-base.md +1 -1
- package/templates/rules/mempalace.md +1 -1
- package/templates/rules/merge-safety.md +108 -0
- package/templates/rules/naming-and-ids.md +23 -17
- package/templates/rules/plain-language.md +59 -0
- package/templates/rules/plan-next.md +9 -11
- package/templates/rules/react-annotate.md +6 -0
- package/templates/rules/review-pages.md +49 -0
- package/templates/rules/risk-tiered-review.md +13 -4
- package/templates/rules/shared-checkout.md +106 -0
- package/templates/rules/skill-gaps.md +2 -7
- package/templates/rules/task-management.md +13 -1
- package/templates/skills/brand-voice/SKILL.md +91 -0
- package/templates/skills/brand-voice/references/voice-template.md +61 -0
- package/templates/skills/campaign/SKILL.md +123 -0
- package/templates/skills/campaign/references/plan-template.md +55 -0
- package/templates/skills/concrete/SKILL.md +2 -2
- package/templates/skills/copywriting/SKILL.md +8 -1
- package/templates/skills/feature-build-refine/SKILL.md +2 -4
- package/templates/skills/morning-briefing/SKILL.md +2 -2
- package/templates/skills/page-design/SKILL.md +145 -0
- package/templates/skills/page-design/add.json +5 -0
- package/templates/skills/page-design/references/design-file-template.md +40 -0
- package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
- package/templates/skills/page-design/references/minimum-rules.md +42 -0
- package/templates/skills/speckit/SKILL.md +4 -5
- package/templates/skills/supabase-patterns/SKILL.md +1 -1
- package/commands/kit-add.md +0 -42
- package/templates/CLAUDE.md.tmpl +0 -106
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
# kto_labels_role <labels-csv> echo the role slug from a labels CSV (role:<slug>)
|
|
18
18
|
# kto_labels_kind <labels-csv> echo the kind slug from a labels CSV (kind:<slug>)
|
|
19
19
|
# kto_compose_pr_body <num> <summary> <role-slug> echo a PR body from the template
|
|
20
|
+
# kto_pr_body_style echo content|code (pr.bodyStyle, #418)
|
|
20
21
|
# kto_compose_issue_body <user-body> <plan> <blocked> <role-slug> echo an issue body
|
|
21
22
|
# kto_closing_issue_numbers <pr-num> echo the issue #s a merged PR closes
|
|
22
|
-
# kto_task_pr <num> <summary> [commit-msg]
|
|
23
|
-
# kto_task_pr_merge [pr-num] [--squash|--merge|--rebase] merge (squash default) + close issues + GC + update the PR base
|
|
23
|
+
# kto_task_pr <num> <summary> [commit-msg] [--base <branch>] commit+push+open PR (board → In Review)
|
|
24
|
+
# kto_task_pr_merge [pr-num] [--squash|--merge|--rebase] merge (squash default) + close issues + GC + update the PR base; refuses an effort/* head
|
|
24
25
|
# kto_task_new <title> <role> <kind> <prio> [ms] [plan] [blocked] <body> create issue + board fields (ms may be empty)
|
|
25
26
|
# kto_task_close <num> <summary> [pr-num] [--reason R] [--duplicate-of N] [--superseded-by N] close + reason + board → Done
|
|
26
27
|
# errors: mixed — git/gh ops propagate; board + label side effects are best-effort
|
|
@@ -48,6 +49,17 @@ if ! type cckit_gh_rest >/dev/null 2>&1; then
|
|
|
48
49
|
unset _kto_self
|
|
49
50
|
fi
|
|
50
51
|
type cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
52
|
+
|
|
53
|
+
# The kind vocabulary (kinds.sh): kto_pr_title takes the commit type from kit_kind_commit_type.
|
|
54
|
+
if ! type kit_kind_commit_type >/dev/null 2>&1; then
|
|
55
|
+
if [ -n "${BASH_SOURCE:-}" ]; then _kto_self="${BASH_SOURCE[0]}"
|
|
56
|
+
elif [ -n "${ZSH_VERSION:-}" ]; then eval '_kto_self="${(%):-%x}"'
|
|
57
|
+
else _kto_self="$0"; fi
|
|
58
|
+
_kto_self="$(cd "$(dirname "$_kto_self")" 2>/dev/null && pwd)/kinds.sh"
|
|
59
|
+
# shellcheck source=kinds.sh
|
|
60
|
+
[ -f "$_kto_self" ] && . "$_kto_self"
|
|
61
|
+
unset _kto_self
|
|
62
|
+
fi
|
|
51
63
|
type cckit_board_skipped >/dev/null 2>&1 || cckit_board_skipped() { return 1; }
|
|
52
64
|
|
|
53
65
|
kto_repo() {
|
|
@@ -55,7 +67,9 @@ kto_repo() {
|
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
# The base branch a PR targets / pr-merge returns to (portable: KIT_BASE_BRANCH, default develop).
|
|
70
|
+
# Args: [override] — a non-empty override wins over the configured base (#391: `cckit pr --base`).
|
|
58
71
|
kto_base_branch() {
|
|
72
|
+
if [[ -n "${1:-}" ]]; then printf '%s' "$1"; return 0; fi
|
|
59
73
|
printf '%s' "${KIT_BASE_BRANCH:-main}"
|
|
60
74
|
}
|
|
61
75
|
|
|
@@ -73,17 +87,17 @@ kto_board_enabled() {
|
|
|
73
87
|
# Parse the issue number from a `<kind>/<N>-<slug>` branch (e.g. feat/173-x -> 173). Empty if none.
|
|
74
88
|
kto_branch_issue_number() {
|
|
75
89
|
local branch="${1:-$(git rev-parse --abbrev-ref HEAD 2>/dev/null)}"
|
|
76
|
-
printf '%s' "$branch" | grep -oE '/[0-9]+-' |
|
|
90
|
+
printf '%s' "$branch" | grep -oE '/[0-9]+-' | sed -n 1p | tr -d '/-'
|
|
77
91
|
}
|
|
78
92
|
|
|
79
93
|
# Echo the role slug from a comma-separated labels list (role:<slug>). Empty if absent.
|
|
80
94
|
kto_labels_role() {
|
|
81
|
-
printf '%s' "$1" | tr ',' '\n' | grep '^role:' |
|
|
95
|
+
printf '%s' "$1" | tr ',' '\n' | grep '^role:' | sed -n 1p | cut -d: -f2
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
# Echo the kind slug from a comma-separated labels list (kind:<slug>). Empty if absent.
|
|
85
99
|
kto_labels_kind() {
|
|
86
|
-
printf '%s' "$1" | tr ',' '\n' | grep '^kind:' |
|
|
100
|
+
printf '%s' "$1" | tr ',' '\n' | grep '^kind:' | sed -n 1p | cut -d: -f2
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
# Compose the PR title as a Conventional Commit subject. Because PRs are squash-merged, this title
|
|
@@ -114,17 +128,18 @@ kto_pr_title() {
|
|
|
114
128
|
fi
|
|
115
129
|
# 2) Derive the type from the kind:/bug label.
|
|
116
130
|
kind="$(kto_labels_kind "$labels")"
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
# The kind -> type map is kinds.sh's (kit_kind_commit_type): a content kind (post, campaign,
|
|
132
|
+
# brand, research) titles as `docs`, kind:task and anything unknown as `feat`.
|
|
133
|
+
if command -v kit_kind_commit_type >/dev/null 2>&1; then
|
|
134
|
+
ctype="$(kit_kind_commit_type "$kind")"
|
|
135
|
+
else
|
|
136
|
+
case "$kind" in
|
|
137
|
+
feat|chore|docs|ci|test|perf|refactor) ctype="$kind" ;;
|
|
138
|
+
fix|bug) ctype=fix ;;
|
|
139
|
+
post|campaign|brand|research) ctype=docs ;;
|
|
140
|
+
*) ctype=feat ;;
|
|
141
|
+
esac
|
|
142
|
+
fi
|
|
128
143
|
case ",$labels," in *,bug,*) ctype=fix ;; esac # a plain `bug` label → fix
|
|
129
144
|
# 3) Strip "[Effort N] M · " (the "· " consumed here as a literal — byte-wise match is portable
|
|
130
145
|
# across BSD/GNU sed + locales; a negated class over the multibyte middot is not) and then a
|
|
@@ -137,14 +152,67 @@ kto_pr_title() {
|
|
|
137
152
|
printf '%s: %s' "$ctype" "$desc"
|
|
138
153
|
}
|
|
139
154
|
|
|
155
|
+
# kto_pr_body_style — `content` or `code`: which wording a generated PR body uses (#418).
|
|
156
|
+
# pr.bodyStyle in the config (KIT_PR_BODY_STYLE); anything but `content` is `code`. The content and
|
|
157
|
+
# marketing profiles set `content`. Shared by `cckit pr`, `cckit effort pr` and `cckit task finish`.
|
|
158
|
+
kto_pr_body_style() {
|
|
159
|
+
if [ "${KIT_PR_BODY_STYLE:-code}" = "content" ]; then printf 'content'; else printf 'code'; fi
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
# kto_content_review_checklist — the review checklist of a content-style PR body, one item per
|
|
163
|
+
# line. The same four lines in every body the kit writes for content work.
|
|
164
|
+
kto_content_review_checklist() {
|
|
165
|
+
printf '%s\n' \
|
|
166
|
+
'- [ ] Read the draft from start to finish' \
|
|
167
|
+
'- [ ] Facts, names, numbers and links are checked' \
|
|
168
|
+
'- [ ] The voice matches the brand guide' \
|
|
169
|
+
'- [ ] Only the files for this piece changed'
|
|
170
|
+
}
|
|
171
|
+
|
|
140
172
|
# Compose a PR body from the kit-task-pr template. Args: <num> <summary> <role-slug> [issue-title]
|
|
141
173
|
# pr.orchestratorSection = true (KIT_PR_ORCHESTRATOR_SECTION) prepends a 2-line
|
|
142
174
|
# `## For the orchestrator` section: the issue id + title, then what to review.
|
|
175
|
+
# pr.bodyStyle = content swaps the code wording (diff, reproduced manually) for draft-and-review
|
|
176
|
+
# wording; `Closes #N`, the summary and the signature are the same in both.
|
|
143
177
|
kto_compose_pr_body() {
|
|
144
|
-
local num="$1" summary="$2" role="$3" title="${4:-}" sig=""
|
|
178
|
+
local num="$1" summary="$2" role="$3" title="${4:-}" sig="" style
|
|
179
|
+
style="$(kto_pr_body_style)"
|
|
145
180
|
if type role_signature >/dev/null 2>&1; then sig="$(role_signature "$role")"; fi
|
|
146
181
|
if [ "${KIT_PR_ORCHESTRATOR_SECTION:-false}" = "true" ]; then
|
|
147
|
-
|
|
182
|
+
if [ "$style" = "content" ]; then
|
|
183
|
+
printf '## For the orchestrator\n\n#%s%s\nReview: the summary below and the changed files.\n\n' "$num" "${title:+ · $title}"
|
|
184
|
+
else
|
|
185
|
+
printf '## For the orchestrator\n\n#%s%s\nReview: the summary below and the diff.\n\n' "$num" "${title:+ · $title}"
|
|
186
|
+
fi
|
|
187
|
+
fi
|
|
188
|
+
if [ "$style" = "content" ]; then
|
|
189
|
+
cat <<EOF
|
|
190
|
+
## Closes
|
|
191
|
+
|
|
192
|
+
Closes #$num
|
|
193
|
+
|
|
194
|
+
## Summary
|
|
195
|
+
|
|
196
|
+
$summary
|
|
197
|
+
|
|
198
|
+
## Review
|
|
199
|
+
|
|
200
|
+
$(kto_content_review_checklist)
|
|
201
|
+
|
|
202
|
+
## Notes for the reviewer
|
|
203
|
+
|
|
204
|
+
—
|
|
205
|
+
|
|
206
|
+
## Not in this piece
|
|
207
|
+
|
|
208
|
+
—
|
|
209
|
+
|
|
210
|
+
$sig
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
<sub>· \`claude-kit\` · kit-task-pr</sub>
|
|
214
|
+
EOF
|
|
215
|
+
return 0
|
|
148
216
|
fi
|
|
149
217
|
cat <<EOF
|
|
150
218
|
## Closes
|
|
@@ -209,21 +277,50 @@ kto_closing_issue_numbers() {
|
|
|
209
277
|
# --- the four ops (network; not exercised by the self-test) --------------------------------------
|
|
210
278
|
|
|
211
279
|
# Map a role slug to the board's Role single-select option id (uses gh-project's role_option_id,
|
|
212
|
-
# which takes a display name — translate slug -> display via role_display).
|
|
280
|
+
# which takes a display name — translate slug -> display via role_display). A slug role_display
|
|
281
|
+
# does not list is passed as-is (#378): role_option_id normalizes it to the same ROLE_OPT_<NAME>.
|
|
213
282
|
_kto_role_option_for_slug() {
|
|
214
283
|
local slug="$1" disp=""
|
|
284
|
+
[[ -z "$slug" ]] && return 0
|
|
215
285
|
if type role_display >/dev/null 2>&1; then disp="$(role_display "$slug")"; fi
|
|
216
|
-
[[ -z "$disp" ]] &&
|
|
286
|
+
[[ -z "$disp" ]] && disp="$slug"
|
|
217
287
|
if type role_option_id >/dev/null 2>&1; then role_option_id "$disp"; fi
|
|
218
288
|
}
|
|
219
289
|
|
|
220
290
|
# kit task pr — commit current changes (role identity in a Co-authored-by TRAILER, never the
|
|
221
291
|
# author field — Vercel rejects unknown author emails), push, open the PR with the issue's
|
|
222
292
|
# labels/milestone, add it to the board In Review, and move the issue to In Review.
|
|
223
|
-
# Args: <issue-num> <summary> [commit-msg]
|
|
293
|
+
# Args: <issue-num> <summary> [commit-msg] [--base <branch>]
|
|
294
|
+
#
|
|
295
|
+
# --base (#391) targets a branch other than the configured base — a release PR develop -> main.
|
|
296
|
+
# load_kit_config re-exports KIT_BASE_BRANCH from the config, so an env override cannot do this.
|
|
297
|
+
# The flag is parsed out before the positionals are read, anywhere on the line, and a missing value
|
|
298
|
+
# returns 2 before the commit and the push. The target is exported to the push as KIT_PR_BASE (set
|
|
299
|
+
# with or without the flag), so a project's git pre-push hook can compare against the branch the PR
|
|
300
|
+
# targets (#360).
|
|
224
301
|
kto_task_pr() {
|
|
225
302
|
# Default-safe reads: callers (scripts/kit) may run under `set -u`.
|
|
226
|
-
local num="
|
|
303
|
+
local num="" summary="" commit_msg="" base_override="" _pos=0
|
|
304
|
+
while [ "$#" -gt 0 ]; do
|
|
305
|
+
case "$1" in
|
|
306
|
+
--base)
|
|
307
|
+
if [ "$#" -lt 2 ] || [ -z "$2" ]; then
|
|
308
|
+
echo "✗ kto_task_pr: --base needs a branch — usage: cckit pr <issue> \"<summary>\" [--base <branch>]" >&2; return 2
|
|
309
|
+
fi
|
|
310
|
+
base_override="$2"; shift 2 ;;
|
|
311
|
+
--base=*)
|
|
312
|
+
base_override="${1#--base=}"
|
|
313
|
+
if [ -z "$base_override" ]; then
|
|
314
|
+
echo "✗ kto_task_pr: --base needs a branch — usage: cckit pr <issue> \"<summary>\" [--base <branch>]" >&2; return 2
|
|
315
|
+
fi
|
|
316
|
+
shift ;;
|
|
317
|
+
*)
|
|
318
|
+
_pos=$((_pos + 1))
|
|
319
|
+
case "$_pos" in 1) num="$1" ;; 2) summary="$1" ;; 3) commit_msg="$1" ;; esac
|
|
320
|
+
shift ;;
|
|
321
|
+
esac
|
|
322
|
+
done
|
|
323
|
+
local base; base="$(kto_base_branch "$base_override")"
|
|
227
324
|
local repo branch meta title labels milestone role author="" url pr_num pr_node item role_opt issue_item
|
|
228
325
|
repo="$(kto_repo)"
|
|
229
326
|
branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
@@ -258,14 +355,14 @@ kto_task_pr() {
|
|
|
258
355
|
fi
|
|
259
356
|
fi
|
|
260
357
|
|
|
261
|
-
git push -u origin "$branch" || return 1
|
|
358
|
+
KIT_PR_BASE="$base" git push -u origin "$branch" || return 1
|
|
262
359
|
|
|
263
360
|
if cckit_gh_rest; then
|
|
264
|
-
url=$(gh_rest_pr_create "$repo" "$
|
|
361
|
+
url=$(gh_rest_pr_create "$repo" "$base" "$branch" "$pr_title" \
|
|
265
362
|
"$(kto_compose_pr_body "$num" "$summary" "$role" "$title")" "$labels" "$milestone") || return 1
|
|
266
363
|
else
|
|
267
364
|
url=$(gh pr create --repo "$repo" \
|
|
268
|
-
--base "$
|
|
365
|
+
--base "$base" --head "$branch" \
|
|
269
366
|
--title "$pr_title" \
|
|
270
367
|
--body "$(kto_compose_pr_body "$num" "$summary" "$role" "$title")" \
|
|
271
368
|
--label "$labels" \
|
|
@@ -317,7 +414,7 @@ kto_task_pr_merge() {
|
|
|
317
414
|
esac
|
|
318
415
|
done
|
|
319
416
|
|
|
320
|
-
local repo branch base pr_num meta merge_state pr_base head issues n state wt main_wt base_wt common
|
|
417
|
+
local repo branch base pr_num meta merge_state pr_base head issues n state wt main_wt base_wt common effort_n
|
|
321
418
|
repo="$(kto_repo)"
|
|
322
419
|
base="$(kto_base_branch)"
|
|
323
420
|
branch="$(git rev-parse --abbrev-ref HEAD)"
|
|
@@ -341,6 +438,20 @@ kto_task_pr_merge() {
|
|
|
341
438
|
echo "→ PR #$pr_num: $head → $pr_base ($method)"
|
|
342
439
|
echo " mergeable=$merge_state status=$(printf '%s' "$meta" | jq -r '.mergeStateStatus // ""')"
|
|
343
440
|
|
|
441
|
+
# An effort's PR merges with `cckit effort close` (#379): that op snapshots each sub-issue's diff
|
|
442
|
+
# before the squash destroys the per-sub commits. Refused before the rebase and the merge, so a
|
|
443
|
+
# refusal writes nothing. KIT_FORCE=1 merges anyway.
|
|
444
|
+
if [[ "$head" == effort/* ]]; then
|
|
445
|
+
effort_n="${head#effort/}"; effort_n="${effort_n%%-*}"
|
|
446
|
+
if [[ "${KIT_FORCE:-0}" == "1" ]]; then
|
|
447
|
+
echo "⚠ KIT_FORCE=1: merging effort branch $head with cckit merge — no per-sub trace snapshot is taken (cckit effort close $effort_n takes it)" >&2
|
|
448
|
+
else
|
|
449
|
+
echo "✗ PR #$pr_num is an effort branch ($head) — merge it with: cckit effort close $effort_n" >&2
|
|
450
|
+
echo " cckit merge would skip the per-sub trace snapshot effort close takes before the squash. KIT_FORCE=1 merges anyway." >&2
|
|
451
|
+
return 1
|
|
452
|
+
fi
|
|
453
|
+
fi
|
|
454
|
+
|
|
344
455
|
# Branches that are never rebased, force-pushed or deleted here: the repo base, the PR's base
|
|
345
456
|
# (it may be an effort branch), and the release branches (#366).
|
|
346
457
|
_kto_protected() { case "$1" in "$base"|"$pr_base"|main|master|develop|HEAD) return 0 ;; esac; return 1; }
|
|
@@ -374,7 +485,10 @@ kto_task_pr_merge() {
|
|
|
374
485
|
|
|
375
486
|
# Close linked issues (replaces issue-close-on-merge.yml; native auto-close only fires on main).
|
|
376
487
|
issues="$(kto_closing_issue_numbers "$pr_num")"
|
|
377
|
-
for n in $issues
|
|
488
|
+
# Read line by line on fd 3, not `for n in $issues` (#379): word-splitting follows the caller's
|
|
489
|
+
# IFS, and a NUL-polluted IFS passed "1020\n1021" to gh as one issue number.
|
|
490
|
+
while IFS= read -r n <&3; do
|
|
491
|
+
[[ "$n" =~ ^[0-9]+$ ]] || continue
|
|
378
492
|
if cckit_gh_rest; then state=$(gh_rest_issue_state "$repo" "$n" 2>/dev/null)
|
|
379
493
|
else state=$(gh issue view "$n" --repo "$repo" --json state --jq .state 2>/dev/null); fi
|
|
380
494
|
if [[ "$state" == "OPEN" ]] && cckit_gh_rest; then
|
|
@@ -388,7 +502,9 @@ kto_task_pr_merge() {
|
|
|
388
502
|
elif [[ -n "$state" ]]; then
|
|
389
503
|
echo " issue #$n already $state — skipped"
|
|
390
504
|
fi
|
|
391
|
-
done
|
|
505
|
+
done 3<<EOF
|
|
506
|
+
$issues
|
|
507
|
+
EOF
|
|
392
508
|
|
|
393
509
|
# Clean up FROM the main checkout (#371): run from the PR's own worktree, removing it deletes our
|
|
394
510
|
# cwd. Main checkout = parent of the shared git dir; fall back to the first `worktree list` entry.
|
|
@@ -397,7 +513,7 @@ kto_task_pr_merge() {
|
|
|
397
513
|
common="$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)"
|
|
398
514
|
main_wt=""
|
|
399
515
|
[[ -n "$common" && "$(basename "$common")" == ".git" ]] && main_wt="$(dirname "$common")"
|
|
400
|
-
[[ -n "$main_wt" ]] || main_wt=$(git worktree list --porcelain | awk '/^worktree /{print $2;
|
|
516
|
+
[[ -n "$main_wt" ]] || main_wt=$(git worktree list --porcelain | awk '/^worktree / && !hit {print $2; hit=1}')
|
|
401
517
|
cd "$main_wt" || { echo "✗ cannot reach the main checkout $main_wt for cleanup" >&2; return 1; }
|
|
402
518
|
|
|
403
519
|
if [[ -n "$wt" && "$wt" != "$main_wt" ]] && ! _kto_protected "$head"; then
|
|
@@ -433,9 +549,36 @@ kto_task_pr_merge() {
|
|
|
433
549
|
fi
|
|
434
550
|
}
|
|
435
551
|
|
|
552
|
+
# _kto_existing_labels <repo> <comma-labels> — the subset of <comma-labels> the repo has, comma-joined
|
|
553
|
+
# on stdout; each one it lacks is named in a warning on stderr (#387). `gh issue create --label`
|
|
554
|
+
# aborts on an unknown label before any issue exists, and the REST endpoint creates the label
|
|
555
|
+
# instead, so both transports are filtered here: the issue is filed, no label is invented. Names
|
|
556
|
+
# match case-insensitively, as GitHub's do. A label list that cannot be read filters nothing.
|
|
557
|
+
_kto_existing_labels() {
|
|
558
|
+
local repo="$1" want="$2" have l keep=""
|
|
559
|
+
if cckit_gh_rest; then
|
|
560
|
+
have="$(gh_rest_label_names "$repo")" || { printf '%s' "$want"; return 0; }
|
|
561
|
+
else
|
|
562
|
+
have="$(gh label list --repo "$repo" --limit 1000 --json name --jq '.[].name' 2>/dev/null)" \
|
|
563
|
+
|| { printf '%s' "$want"; return 0; }
|
|
564
|
+
fi
|
|
565
|
+
while IFS= read -r l; do
|
|
566
|
+
[[ -n "$l" ]] || continue
|
|
567
|
+
if grep -qixF -- "$l" <<<"$have"; then
|
|
568
|
+
keep="${keep:+$keep,}$l"
|
|
569
|
+
else
|
|
570
|
+
echo "⚠ label '$l' not found in $repo — issue created without it (scripts/setup-labels.sh provisions the kit's labels)" >&2
|
|
571
|
+
fi
|
|
572
|
+
done <<EOF
|
|
573
|
+
$(printf '%s\n' "$want" | tr ',' '\n')
|
|
574
|
+
EOF
|
|
575
|
+
printf '%s' "$keep"
|
|
576
|
+
}
|
|
577
|
+
|
|
436
578
|
# kit task new — create a GitHub issue with labels + milestone, add it to the board, set Role +
|
|
437
579
|
# Status(Todo) + Plan Link. Inputs are passed (the caller does the AskUserQuestion). No invented
|
|
438
|
-
# values
|
|
580
|
+
# values: a label the repo does not have is dropped with a warning, never created, and the issue is
|
|
581
|
+
# still filed (#387). Non-zero only when the issue itself was not created.
|
|
439
582
|
# Args: <title> <role-display-or-slug> <kind> <priority> [milestone|""] [plan-link] [blocked-by] <body>
|
|
440
583
|
kto_task_new() {
|
|
441
584
|
local title="${1:-}" role="${2:-}" kind="${3:-}" prio="${4:-}" milestone="${5:-}" plan="${6:-}" blocked="${7:-}" body_user="${8:-}"
|
|
@@ -449,13 +592,14 @@ kto_task_new() {
|
|
|
449
592
|
role_slug="$(printf '%s' "$role" | tr 'A-Z ' 'a-z-')"
|
|
450
593
|
labels="kind:${kind},priority:${prio},role:${role_slug}"
|
|
451
594
|
body="$(kto_compose_issue_body "$body_user" "$plan" "$blocked" "$role_slug")"
|
|
595
|
+
labels="$(_kto_existing_labels "$repo" "$labels")"
|
|
452
596
|
|
|
453
597
|
if cckit_gh_rest; then
|
|
454
598
|
url=$(gh_rest_issue_create "$repo" "$title" "$body" "$labels" "$milestone") || return 1
|
|
455
599
|
else
|
|
456
600
|
url=$(gh issue create --repo "$repo" \
|
|
457
601
|
--title "$title" --body "$body" \
|
|
458
|
-
|
|
602
|
+
${labels:+--label} ${labels:+"$labels"} ${milestone:+--milestone "$milestone"} --assignee "@me") || return 1
|
|
459
603
|
fi
|
|
460
604
|
num=$(basename "$url")
|
|
461
605
|
echo "✓ $url"
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# kto-hotfix-test.sh — `cckit hotfix <pr|sha> [--base B]` end to end (#360), against a stubbed gh, a
|
|
4
|
+
# throwaway repo and a bare remote: the worktree is cut from origin/<base>, the branch carries
|
|
5
|
+
# exactly the source commit's diff, the push exports KIT_PR_BASE, and the PR targets <base> with
|
|
6
|
+
# `Cherry-pick of #N` in its body. Covers both transports, a merge-commit source, a re-run, and the
|
|
7
|
+
# rebase-merged multi-commit PR (every commit carried), a squash of a multi-commit PR (one commit), a
|
|
8
|
+
# refusal reported as `--llm` JSON, and the refusals (unmerged PR, unknown sha, missing base,
|
|
9
|
+
# conflict).
|
|
10
|
+
# Run: bash scripts/lib/kto-hotfix-test.sh
|
|
11
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
12
|
+
set -u
|
|
13
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
14
|
+
CCKIT="$(cd "$LIB/../.." && pwd)/bin/cckit"
|
|
15
|
+
# shellcheck source=/dev/null
|
|
16
|
+
. "$LIB/test-env.sh" && test_env_seal
|
|
17
|
+
unset CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT
|
|
18
|
+
fail=0
|
|
19
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
20
|
+
tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
|
|
21
|
+
tn() { if grep -qE -- "$2" "$1"; then echo "FAIL: $3 (/$2/ in $1)"; fail=1; else echo "ok: $3"; fi; }
|
|
22
|
+
command -v jq >/dev/null 2>&1 || { echo "kto-hotfix-test: jq required" >&2; exit 1; }
|
|
23
|
+
|
|
24
|
+
tmp="$(cd "$(mktemp -d)" && pwd -P)"; trap 'rm -rf "$tmp"' EXIT
|
|
25
|
+
export GH_LOG="$tmp/gh.log" GH_SHA="" GH_STATE="MERGED" GH_OPEN_URL="" GH_SUBJECTS="wip"
|
|
26
|
+
: > "$GH_LOG"
|
|
27
|
+
mkdir -p "$tmp/bin"
|
|
28
|
+
# A gh that logs one call per line (newlines in a body become \036) and answers both transports.
|
|
29
|
+
cat > "$tmp/bin/gh" <<'SH'
|
|
30
|
+
#!/usr/bin/env bash
|
|
31
|
+
{ printf '%s' "$*" | tr '\n' '\036'; echo; } >> "$GH_LOG"
|
|
32
|
+
jqx=""; prev=""; for a in "$@"; do [ "$prev" = "--jq" ] && jqx="$a"; prev="$a"; done
|
|
33
|
+
out() { if [ -n "$jqx" ]; then printf '%s' "$1" | jq -r -c "$jqx"; else printf '%s\n' "$1"; fi; }
|
|
34
|
+
merged="null"; [ "$GH_STATE" = "MERGED" ] && merged='"2026-10-30T00:00:00Z"'
|
|
35
|
+
# GH_SUBJECTS: the PR's own commit subjects, one per line, oldest first.
|
|
36
|
+
commits="$(printf '%s\n' "$GH_SUBJECTS" | jq -R -s -c '[split("\n")[] | select(length > 0)]')"
|
|
37
|
+
case "$1 $2" in
|
|
38
|
+
"pr view")
|
|
39
|
+
if [ "$GH_STATE" = "MERGED" ]; then mc="{\"oid\":\"$GH_SHA\"}"; else mc="null"; fi
|
|
40
|
+
out "{\"title\":\"fix: the thing [#11]\",\"state\":\"$GH_STATE\",\"mergeCommit\":$mc,\"commits\":$(printf '%s' "$commits" | jq -c '[.[] | {messageHeadline: .}]')}" ;;
|
|
41
|
+
"pr list") out "[$( [ -n "$GH_OPEN_URL" ] && printf '{"url":"%s"}' "$GH_OPEN_URL" )]" ;;
|
|
42
|
+
"pr create") echo "https://github.com/o/r/pull/77" ;;
|
|
43
|
+
"api repos/o/r/pulls")
|
|
44
|
+
case " $* " in
|
|
45
|
+
*" POST "*) out '{"number":77,"html_url":"https://github.com/o/r/pull/77","user":{"login":"me"}}' ;;
|
|
46
|
+
*) out "[]" ;;
|
|
47
|
+
esac ;;
|
|
48
|
+
"api repos/o/r/pulls/"*"/commits")
|
|
49
|
+
out "$(printf '%s' "$commits" | jq -c '[.[] | {commit: {message: (. + "\n\nbody text")}}]')" ;;
|
|
50
|
+
"api repos/o/r/pulls/"*)
|
|
51
|
+
out "{\"title\":\"fix: the thing [#11]\",\"mergeable\":null,\"mergeable_state\":\"unknown\",\"base\":{\"ref\":\"develop\"},\"head\":{\"ref\":\"fix/11-x\"},\"body\":\"\",\"state\":\"closed\",\"merged_at\":$merged,\"merge_commit_sha\":\"$GH_SHA\"}" ;;
|
|
52
|
+
*) exit 0 ;;
|
|
53
|
+
esac
|
|
54
|
+
SH
|
|
55
|
+
chmod +x "$tmp/bin/gh"
|
|
56
|
+
export PATH="$tmp/bin:$PATH" KIT_WT_INSTALL=0
|
|
57
|
+
|
|
58
|
+
# The fixture: `main` (the release branch) one commit behind `develop`, which carries the fix as a
|
|
59
|
+
# squash commit `… (#12)`, a later unrelated commit, and a true merge commit.
|
|
60
|
+
git init -q --bare "$tmp/remote.git"
|
|
61
|
+
git clone -q "$tmp/remote.git" "$tmp/work" 2>/dev/null
|
|
62
|
+
cd "$tmp/work" || exit 1
|
|
63
|
+
git config user.email t@t; git config user.name t
|
|
64
|
+
cat > cckit.config.json <<'JSON'
|
|
65
|
+
{"kitVersion":"0.0.0","project":{"name":"x","slug":"x","owner":"o","language":"en"},"profile":"p",
|
|
66
|
+
"github":{"repo":"o/r","owner":"o","baseBranch":"develop","projectsV2":false}}
|
|
67
|
+
JSON
|
|
68
|
+
printf 'a\nb\nc\n' > app.txt
|
|
69
|
+
git add -A; git commit -q -m init; git branch -M main; git push -q origin main
|
|
70
|
+
git checkout -q -b develop
|
|
71
|
+
printf 'a\nB\nc\n' > app.txt; git commit -q -am "fix: the thing (#12)"; SRC="$(git rev-parse HEAD)"
|
|
72
|
+
echo other > other.txt; git add other.txt; git commit -q -m "feat: unrelated (#13)"
|
|
73
|
+
git checkout -q -b side HEAD~1; echo side > side.txt; git add side.txt; git commit -q -m "side work"
|
|
74
|
+
git checkout -q develop; git merge -q --no-ff side -m "Merge pull request #14 from o/side"
|
|
75
|
+
MERGE="$(git rev-parse HEAD)"
|
|
76
|
+
printf 'a\nB\nc\nd\n' > app.txt; git commit -q -am "feat: conflicts with a main-only edit (#15)"; CONF="$(git rev-parse HEAD)"
|
|
77
|
+
# PR 20 as a REBASE merge leaves it: its two commits on develop, subjects unchanged, no merge commit.
|
|
78
|
+
echo one > r1.txt; git add r1.txt; git commit -q -m "fix: rebased part one"
|
|
79
|
+
echo two > r2.txt; git add r2.txt; git commit -q -m "fix: rebased part two"; REB="$(git rev-parse HEAD)"
|
|
80
|
+
git push -q origin develop
|
|
81
|
+
cat > .git/hooks/pre-push <<SH
|
|
82
|
+
#!/usr/bin/env bash
|
|
83
|
+
echo "KIT_PR_BASE=\${KIT_PR_BASE:-}" >> "$tmp/prepush.log"
|
|
84
|
+
SH
|
|
85
|
+
chmod +x .git/hooks/pre-push
|
|
86
|
+
: > "$tmp/prepush.log"
|
|
87
|
+
|
|
88
|
+
# Drop the hotfix branch everywhere, so the next case starts from nothing.
|
|
89
|
+
reset_hotfix() {
|
|
90
|
+
git worktree remove --force "$wt"; git branch -q -D fix/12-hotfix-main
|
|
91
|
+
git push -q origin :fix/12-hotfix-main 2>/dev/null; : > "$tmp/prepush.log"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
# ── <sha> --base main ────────────────────────────────────────────────────────────────────────────
|
|
95
|
+
out="$("$CCKIT" hotfix "$SRC" --base main 2>"$tmp/err")"; rc=$?
|
|
96
|
+
t "hotfix <sha> --base main succeeds" "$rc" "0"
|
|
97
|
+
wt="$tmp/work/.claude/worktrees/fix+12-hotfix-main"
|
|
98
|
+
t "the worktree exists" "$([ -d "$wt" ] && echo yes || echo no)" "yes"
|
|
99
|
+
t "its branch is fix/12-hotfix-main" "$(git -C "$wt" rev-parse --abbrev-ref HEAD 2>/dev/null)" "fix/12-hotfix-main"
|
|
100
|
+
t "the branch is cut from origin/main" "$(git merge-base origin/main fix/12-hotfix-main)" "$(git rev-parse origin/main)"
|
|
101
|
+
t "one commit on top of origin/main" "$(git rev-list --count origin/main..fix/12-hotfix-main)" "1"
|
|
102
|
+
t "the branch diff equals the source commit's" "$(git diff origin/main fix/12-hotfix-main)" "$(git diff "$SRC~1" "$SRC")"
|
|
103
|
+
t "the unrelated develop commit is not carried" "$(git ls-tree --name-only fix/12-hotfix-main | grep -c '^other.txt$')" "0"
|
|
104
|
+
tc <(git log -1 --format=%B fix/12-hotfix-main) "cherry picked from commit $SRC" "cherry-pick -x records the source"
|
|
105
|
+
t "the branch reached the remote" "$(git -C "$tmp/remote.git" rev-parse fix/12-hotfix-main 2>/dev/null)" "$(git rev-parse fix/12-hotfix-main)"
|
|
106
|
+
t "the pre-push hook sees KIT_PR_BASE=main" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=main"
|
|
107
|
+
tc "$GH_LOG" '^pr create .*--base main --head fix/12-hotfix-main ' "the PR targets main from the hotfix branch"
|
|
108
|
+
tc "$GH_LOG" '--title fix: the thing --body ' "titled after the source, squash suffix dropped"
|
|
109
|
+
tc "$GH_LOG" 'Cherry-pick of #12' "the body says Cherry-pick of #12"
|
|
110
|
+
tn "$GH_LOG" 'Closes #' "the body closes no issue"
|
|
111
|
+
t "stdout ends with the PR url" "$(printf '%s\n' "$out" | tail -1)" "✓ https://github.com/o/r/pull/77"
|
|
112
|
+
|
|
113
|
+
# ── re-run: nothing is picked twice, and an open PR is reported, not re-created ──────────────────
|
|
114
|
+
: > "$GH_LOG"
|
|
115
|
+
out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" hotfix "$SRC" --base main 2>/dev/null)"; rc=$?
|
|
116
|
+
t "a re-run succeeds" "$rc" "0"
|
|
117
|
+
t "…and does not pick the commit twice" "$(git rev-list --count origin/main..fix/12-hotfix-main)" "1"
|
|
118
|
+
tn "$GH_LOG" '^pr create' "…and opens no second PR"
|
|
119
|
+
t "…and still reports the url" "$(printf '%s\n' "$out" | tail -1)" "✓ https://github.com/o/r/pull/77"
|
|
120
|
+
|
|
121
|
+
# ── <pr>: the merge commit and title come from GitHub; main is the default base ─────────────────
|
|
122
|
+
reset_hotfix
|
|
123
|
+
: > "$GH_LOG"
|
|
124
|
+
out="$(GH_SHA="$SRC" "$CCKIT" hotfix 12 2>"$tmp/err")"; rc=$?
|
|
125
|
+
t "hotfix <pr> succeeds (default base main)" "$rc" "0"
|
|
126
|
+
tc "$GH_LOG" '^pr view 12 ' "the source PR is read from GitHub"
|
|
127
|
+
t "the branch diff equals the source commit's" "$(git diff origin/main fix/12-hotfix-main)" "$(git diff "$SRC~1" "$SRC")"
|
|
128
|
+
tc "$GH_LOG" '^pr create .*--base main .*--title fix: the thing \[#11\] ' "titled after the source PR"
|
|
129
|
+
tc "$GH_LOG" 'Cherry-pick of #12' "the body says Cherry-pick of #12"
|
|
130
|
+
|
|
131
|
+
# --llm: one JSON object carrying the url and the worktree
|
|
132
|
+
reset_hotfix
|
|
133
|
+
js="$(GH_SHA="$SRC" "$CCKIT" hotfix '#12' --llm 2>/dev/null)"
|
|
134
|
+
t "--llm: ok + url" "$(printf '%s' "$js" | jq -r '"\(.ok) \(.url)"' 2>/dev/null)" "true https://github.com/o/r/pull/77"
|
|
135
|
+
t "--llm: the worktree path" "$(printf '%s' "$js" | jq -r .worktree 2>/dev/null)" "$wt"
|
|
136
|
+
|
|
137
|
+
# --llm on a refusal: still one JSON object, ok false, the reason in `detail`
|
|
138
|
+
js="$(GH_STATE="OPEN" "$CCKIT" hotfix 99 --llm 2>/dev/null)"; rc=$?
|
|
139
|
+
t "--llm: a refusal exits 1" "$rc" "1"
|
|
140
|
+
t "--llm: a refusal reports ok false" "$(printf '%s' "$js" | jq -r '"\(.verb) \(.ok)"' 2>/dev/null)" "hotfix false"
|
|
141
|
+
t "--llm: …and carries the reason" "$(printf '%s' "$js" | jq -r .detail 2>/dev/null | grep -c 'not merged')" "1"
|
|
142
|
+
|
|
143
|
+
# ── REST transport: only `gh api repos/…` calls ──────────────────────────────────────────────────
|
|
144
|
+
reset_hotfix
|
|
145
|
+
: > "$GH_LOG"
|
|
146
|
+
GH_SHA="$SRC" CCKIT_GH_TRANSPORT=rest "$CCKIT" hotfix 12 >/dev/null 2>"$tmp/err"; rc=$?
|
|
147
|
+
t "rest: hotfix <pr> succeeds" "$rc" "0"
|
|
148
|
+
tn "$GH_LOG" '^(pr|issue) |graphql' "rest: no gh pr/issue/graphql call"
|
|
149
|
+
tc "$GH_LOG" '^api repos/o/r/pulls -X POST .*base=main' "rest: the PR is created against main"
|
|
150
|
+
tc "$GH_LOG" 'Cherry-pick of #12' "rest: the body says Cherry-pick of #12"
|
|
151
|
+
t "rest: the branch diff equals the source's" "$(git diff origin/main fix/12-hotfix-main)" "$(git diff "$SRC~1" "$SRC")"
|
|
152
|
+
|
|
153
|
+
# ── a merge commit is picked against its first parent ────────────────────────────────────────────
|
|
154
|
+
: > "$GH_LOG"
|
|
155
|
+
"$CCKIT" hotfix "$MERGE" --base main >/dev/null 2>"$tmp/err"; rc=$?
|
|
156
|
+
t "a merge-commit source succeeds" "$rc" "0"
|
|
157
|
+
t "…carrying the merged side's diff" "$(git diff origin/main fix/14-hotfix-main)" "$(git diff "$MERGE~1" "$MERGE")"
|
|
158
|
+
tc "$GH_LOG" 'Cherry-pick of #14' "…and the PR number from the merge subject"
|
|
159
|
+
|
|
160
|
+
# ── a rebase-merged PR: GitHub names only its LAST commit, every one of its commits is carried ───
|
|
161
|
+
for tr in graphql rest; do
|
|
162
|
+
: > "$GH_LOG"
|
|
163
|
+
GH_SHA="$REB" GH_SUBJECTS="$(printf 'fix: rebased part one\nfix: rebased part two')" CCKIT_GH_TRANSPORT="$tr" \
|
|
164
|
+
"$CCKIT" hotfix 20 >/dev/null 2>"$tmp/err"; rc=$?
|
|
165
|
+
t "$tr: a rebase-merged PR succeeds" "$rc" "0"
|
|
166
|
+
t "$tr: …carrying both of its commits" "$(git rev-list --count origin/main..fix/20-hotfix-main 2>/dev/null)" "2"
|
|
167
|
+
t "$tr: …whose diff is the whole PR's" "$(git diff origin/main fix/20-hotfix-main)" "$(git diff "$REB~2" "$REB")"
|
|
168
|
+
tc "$tmp/err" 'rebase-merged: carrying its 2 commits' "$tr: …and says so"
|
|
169
|
+
tc "$GH_LOG" "Source commits.*$(git rev-parse "$REB~1").*$REB" "$tr: the body lists both source commits"
|
|
170
|
+
git worktree remove --force "$tmp/work/.claude/worktrees/fix+20-hotfix-main"; git branch -q -D fix/20-hotfix-main
|
|
171
|
+
git push -q origin :fix/20-hotfix-main 2>/dev/null
|
|
172
|
+
done
|
|
173
|
+
# A SQUASH of a multi-commit PR is one commit carrying all of it: the subjects under it are not the PR's.
|
|
174
|
+
reset_hotfix
|
|
175
|
+
: > "$GH_LOG"
|
|
176
|
+
GH_SHA="$SRC" GH_SUBJECTS="$(printf 'wip one\nwip two')" "$CCKIT" hotfix 12 >/dev/null 2>"$tmp/err"; rc=$?
|
|
177
|
+
t "a squashed two-commit PR succeeds" "$rc" "0"
|
|
178
|
+
t "…as the one squash commit" "$(git rev-list --count origin/main..fix/12-hotfix-main)" "1"
|
|
179
|
+
tn "$tmp/err" 'rebase-merged' "…and is not taken for a rebase merge"
|
|
180
|
+
# A PR whose commits cannot be read is refused, not guessed at.
|
|
181
|
+
GH_SHA="$SRC" GH_SUBJECTS="" "$CCKIT" hotfix 12 >/dev/null 2>"$tmp/err"; rc=$?
|
|
182
|
+
t "unreadable PR commits are refused" "$rc" "1"
|
|
183
|
+
tc "$tmp/err" 'cannot read the commits' "…and says why"
|
|
184
|
+
|
|
185
|
+
# ── a commit with no PR in its subject: named by sha ─────────────────────────────────────────────
|
|
186
|
+
: > "$GH_LOG"
|
|
187
|
+
SIDE="$(git rev-parse side)"
|
|
188
|
+
"$CCKIT" hotfix "$SIDE" --base main >/dev/null 2>"$tmp/err"; rc=$?
|
|
189
|
+
t "a commit with no (#N) succeeds" "$rc" "0"
|
|
190
|
+
short="$(git rev-parse --short=7 "$SIDE")"
|
|
191
|
+
t "…on a branch named by sha" "$(git rev-parse --verify --quiet "fix/hotfix-$short-main" >/dev/null && echo yes || echo no)" "yes"
|
|
192
|
+
tc "$GH_LOG" "Cherry-pick of $SIDE" "…and the body names the commit"
|
|
193
|
+
|
|
194
|
+
# ── refusals: nothing is created ─────────────────────────────────────────────────────────────────
|
|
195
|
+
: > "$GH_LOG"
|
|
196
|
+
GH_STATE="OPEN" "$CCKIT" hotfix 99 >/dev/null 2>"$tmp/err"; rc=$?
|
|
197
|
+
t "an unmerged PR is refused" "$rc" "1"
|
|
198
|
+
tc "$tmp/err" 'not merged' "…and says why"
|
|
199
|
+
t "…with no branch made" "$(git branch --list 'fix/99-*' | wc -l | tr -d ' ')" "0"
|
|
200
|
+
"$CCKIT" hotfix deadbeefdeadbeef --base main >/dev/null 2>"$tmp/err"; rc=$?
|
|
201
|
+
t "an unknown sha is refused" "$rc" "1"
|
|
202
|
+
tc "$tmp/err" 'is not a commit' "…and says why"
|
|
203
|
+
"$CCKIT" hotfix "$SRC" --base nope >/dev/null 2>"$tmp/err"; rc=$?
|
|
204
|
+
t "a base missing on origin is refused" "$rc" "1"
|
|
205
|
+
tc "$tmp/err" "origin has no branch 'nope'" "…and says why"
|
|
206
|
+
t "…with no branch made" "$(git branch --list 'fix/12-hotfix-nope' | wc -l | tr -d ' ')" "0"
|
|
207
|
+
"$CCKIT" hotfix >/dev/null 2>"$tmp/err"; rc=$?
|
|
208
|
+
t "no source is a usage error" "$rc" "2"
|
|
209
|
+
"$CCKIT" hotfix "$SRC" --base >/dev/null 2>"$tmp/err"; rc=$?
|
|
210
|
+
t "--base with no value is a usage error" "$rc" "2"
|
|
211
|
+
tn "$GH_LOG" '^pr create|-X POST' "no refusal opened a PR"
|
|
212
|
+
|
|
213
|
+
# ── a conflict stops before the push and says how to continue ────────────────────────────────────
|
|
214
|
+
git checkout -q -b rel-edit origin/main; printf 'a\nb\nc\nZ\n' > app.txt; git commit -q -am "main-only edit"
|
|
215
|
+
git push -q origin rel-edit:rel; git checkout -q develop
|
|
216
|
+
: > "$GH_LOG"; : > "$tmp/prepush.log"
|
|
217
|
+
"$CCKIT" hotfix "$CONF" --base rel >/dev/null 2>"$tmp/err"; rc=$?
|
|
218
|
+
t "a conflicting pick fails" "$rc" "1"
|
|
219
|
+
tc "$tmp/err" 'cherry-pick --continue' "…telling you how to continue"
|
|
220
|
+
t "…without pushing" "$(wc -l < "$tmp/prepush.log" | tr -d ' ')" "0"
|
|
221
|
+
tn "$GH_LOG" '^pr create' "…and without opening a PR"
|
|
222
|
+
"$CCKIT" hotfix "$CONF" --base rel >/dev/null 2>"$tmp/err"; rc=$?
|
|
223
|
+
t "a re-run mid-conflict is refused" "$rc" "1"
|
|
224
|
+
cwt="$tmp/work/.claude/worktrees/fix+15-hotfix-rel"
|
|
225
|
+
printf 'a\nB\nc\nZ\nd\n' > "$cwt/app.txt"; git -C "$cwt" add app.txt
|
|
226
|
+
GIT_EDITOR=true git -C "$cwt" cherry-pick --continue >/dev/null 2>&1
|
|
227
|
+
"$CCKIT" hotfix "$CONF" --base rel >/dev/null 2>"$tmp/err"; rc=$?
|
|
228
|
+
t "after --continue the re-run finishes" "$rc" "0"
|
|
229
|
+
tc "$GH_LOG" '^pr create .*--base rel ' "…opening the PR against the chosen base"
|
|
230
|
+
|
|
231
|
+
[ "$fail" -eq 0 ] && echo "kto-hotfix: all passed" || echo "kto-hotfix: FAILURES"
|
|
232
|
+
exit "$fail"
|
|
@@ -35,7 +35,7 @@ project_find_item_by_issue() { echo "ITEM-$1"; }
|
|
|
35
35
|
project_set_single_select() { echo "$*" >> "$BOARD_LOG"; }
|
|
36
36
|
|
|
37
37
|
run() { : > "$GH_LOG"; : > "$BOARD_LOG"; kto_task_close "$@" >/dev/null 2>"$tmp/err"; echo $?; }
|
|
38
|
-
closed() { grep -E '^issue close ' "$GH_LOG" |
|
|
38
|
+
closed() { grep -E '^issue close ' "$GH_LOG" | sed -n 1p; }
|
|
39
39
|
|
|
40
40
|
t "default close succeeds" "$(run 5 "Shipped in #9.")" 0
|
|
41
41
|
tc "$GH_LOG" '^issue close 5 --repo o/r --reason completed --comment Shipped in #9\.$' "default reason is completed, with the summary"
|