@jeiemgi/cckit 0.8.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 +505 -35
- package/SECURITY.md +5 -0
- package/bin/cckit +189 -20
- 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/guard-raw-git-ops-test.sh +8 -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 +188 -35
- package/scripts/lib/effort-ops-test.sh +217 -7
- package/scripts/lib/effort-ops.sh +281 -49
- 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-slug.sh +16 -2
- package/scripts/lib/effort.sh +67 -12
- package/scripts/lib/errors-header-test.sh +1 -1
- package/scripts/lib/gh-project-test.sh +35 -1
- package/scripts/lib/gh-project.sh +37 -16
- package/scripts/lib/gh-rest-test.sh +330 -0
- package/scripts/lib/gh-rest.sh +304 -0
- 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 +244 -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 +362 -89
- package/scripts/lib/kto-hotfix-test.sh +232 -0
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-new-test.sh +95 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +97 -6
- 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/test-env-test.sh +3 -3
- package/scripts/lib/test-env.sh +7 -4
- 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 +93 -9
- package/scripts/lib/worktree-ports-test.sh +57 -4
- package/scripts/lib/worktree-start-test.sh +197 -0
- package/scripts/lib/worktree-start.sh +169 -32
- 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 +27 -14
- 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
|
@@ -28,6 +28,24 @@ if ! command -v effort_slug_resolve >/dev/null 2>&1; then
|
|
|
28
28
|
unset _eo_dir
|
|
29
29
|
fi
|
|
30
30
|
|
|
31
|
+
# The closed kind: vocabulary (KIT_KINDS / kit_kind_valid) — what `effort new --kind` accepts.
|
|
32
|
+
if ! command -v kit_kind_valid >/dev/null 2>&1; then
|
|
33
|
+
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
34
|
+
# shellcheck source=/dev/null
|
|
35
|
+
[ -f "$_eo_dir/kinds.sh" ] && . "$_eo_dir/kinds.sh"
|
|
36
|
+
unset _eo_dir
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# The GitHub transport switch (#396): in rest mode the lifecycle calls below are `gh api repos/…`.
|
|
40
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
41
|
+
_eo_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
42
|
+
# shellcheck source=/dev/null
|
|
43
|
+
[ -f "$_eo_dir/gh-rest.sh" ] && . "$_eo_dir/gh-rest.sh"
|
|
44
|
+
unset _eo_dir
|
|
45
|
+
fi
|
|
46
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
47
|
+
command -v cckit_board_skipped >/dev/null 2>&1 || cckit_board_skipped() { return 1; }
|
|
48
|
+
|
|
31
49
|
_eff_repo() { printf '%s' "${EFFORT_REPO:-${KIT_REPO:-}}"; }
|
|
32
50
|
_eff_base() { printf '%s' "${KIT_BASE_BRANCH:-main}"; }
|
|
33
51
|
_eff_need() { command -v "$1" >/dev/null 2>&1 || { echo "effort: $1 is required" >&2; return 1; }; }
|
|
@@ -96,6 +114,7 @@ _eff_relations_add() {
|
|
|
96
114
|
# before `gh issue create --label` uses it (which fails hard on a missing label, #153). Idempotent:
|
|
97
115
|
# creating an existing label is a silent no-op.
|
|
98
116
|
_eff_ensure_label() {
|
|
117
|
+
if cckit_gh_rest; then gh_rest_label_create "$(_eff_repo)" "$1" "$2" "$3"; return 0; fi
|
|
99
118
|
gh label create "$1" --repo "$(_eff_repo)" --color "$2" \
|
|
100
119
|
--description "$3" >/dev/null 2>&1 || true
|
|
101
120
|
}
|
|
@@ -106,6 +125,7 @@ _eff_ensure_label() {
|
|
|
106
125
|
_eff_board_add() {
|
|
107
126
|
local n="$1" role="${2:-}" repo node item ropt
|
|
108
127
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
128
|
+
cckit_board_skipped && return 0
|
|
109
129
|
command -v project_add_item >/dev/null 2>&1 || return 0
|
|
110
130
|
repo="$(_eff_repo)"
|
|
111
131
|
node="$(gh api "repos/$repo/issues/$n" --jq .node_id 2>/dev/null)" || return 0
|
|
@@ -113,8 +133,8 @@ _eff_board_add() {
|
|
|
113
133
|
[ -n "$item" ] || return 0
|
|
114
134
|
[ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_TODO:-}" ] \
|
|
115
135
|
&& project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_TODO" 2>/dev/null || true
|
|
116
|
-
if [ -n "$role" ] && command -v role_option_id >/dev/null 2>&1; then
|
|
117
|
-
ropt="$(role_option_id "$role"
|
|
136
|
+
if [ -n "$role" ] && [ -n "${ROLE_FIELD_ID:-}" ] && command -v role_option_id >/dev/null 2>&1; then
|
|
137
|
+
ropt="$(role_option_id "$role" || echo "")"
|
|
118
138
|
[ -n "$ropt" ] && [ -n "${ROLE_FIELD_ID:-}" ] \
|
|
119
139
|
&& project_set_single_select "$item" "$ROLE_FIELD_ID" "$ropt" 2>/dev/null || true
|
|
120
140
|
fi
|
|
@@ -134,7 +154,7 @@ effort_new() {
|
|
|
134
154
|
local repo; repo="$(_eff_repo)"
|
|
135
155
|
[ -n "$repo" ] || { echo "effort_new: no repo (KIT_REPO/EFFORT_REPO unset — run in a kit project)" >&2; return 1; }
|
|
136
156
|
|
|
137
|
-
local flow="" role="" priority="p1" goal="" scope="" for_agents="" verification="" depends_on="" milestone="" explicit_slug=""
|
|
157
|
+
local flow="" role="" priority="p1" goal="" scope="" for_agents="" verification="" depends_on="" milestone="" explicit_slug="" kind="task"
|
|
138
158
|
# Flags are position-INDEPENDENT: recognized --flag [value] pairs are consumed wherever they occur
|
|
139
159
|
# (before the title, between subs, or after them) and the remaining positionals are collected as the
|
|
140
160
|
# title (first) + sub specs (rest). Previously the parser broke at the first positional, so any flag
|
|
@@ -154,8 +174,8 @@ effort_new() {
|
|
|
154
174
|
--milestone) milestone="${2:-}"; shift 2 ;;
|
|
155
175
|
--slug) explicit_slug="${2:-}"; shift 2 ;;
|
|
156
176
|
--slug=*) explicit_slug="${1#*=}"; shift ;;
|
|
157
|
-
--
|
|
158
|
-
--
|
|
177
|
+
--kind) kind="${2:-}"; shift 2 ;;
|
|
178
|
+
--kind=*) kind="${1#*=}"; shift ;;
|
|
159
179
|
--) shift; while [ $# -gt 0 ]; do pos+=("$1"); shift; done ;;
|
|
160
180
|
--*) echo "effort_new: unknown flag $1" >&2; return 1 ;;
|
|
161
181
|
*) pos+=("$1"); shift ;;
|
|
@@ -163,15 +183,13 @@ effort_new() {
|
|
|
163
183
|
done
|
|
164
184
|
set -- "${pos[@]+"${pos[@]}"}"
|
|
165
185
|
|
|
166
|
-
#
|
|
167
|
-
#
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
''|*[!0-9]*) echo "effort_new: --par must be 'seq', 'wide', or a positive integer (got '$par')" >&2; return 1 ;;
|
|
172
|
-
*) : ;;
|
|
173
|
-
esac
|
|
186
|
+
# --kind picks the kind:<k> label on the parent and every sub (default task). It is validated
|
|
187
|
+
# against the closed set (kinds.sh) before anything is created: `cckit start` turns the label into
|
|
188
|
+
# the branch prefix, so a value outside the set would yield a branch the hygiene hook rejects.
|
|
189
|
+
if command -v kit_kind_label_valid >/dev/null 2>&1 && ! kit_kind_label_valid "$kind"; then
|
|
190
|
+
echo "effort_new: --kind must be one of: $KIT_KINDS $KIT_CONTENT_KINDS (got '$kind')" >&2; return 1
|
|
174
191
|
fi
|
|
192
|
+
[ -n "$kind" ] || { echo "effort_new: --kind needs a value" >&2; return 1; }
|
|
175
193
|
|
|
176
194
|
local name="${1:-}"; shift || true
|
|
177
195
|
[ -n "$name" ] || { echo 'effort_new: usage: effort_new [flags] "<name>" [<sub spec> …]' >&2; return 1; }
|
|
@@ -212,7 +230,7 @@ effort_new() {
|
|
|
212
230
|
# Every kit-defined label is ensured before use — `gh issue create --label` fails hard on a
|
|
213
231
|
# missing label, which aborted the whole parent create on repos without the ctx:* set (#153).
|
|
214
232
|
_eff_ensure_label "$ctx" bfd4f2 "effort session weight"
|
|
215
|
-
_eff_ensure_label "kind
|
|
233
|
+
_eff_ensure_label "kind:$kind" d4c5f9 "kit issue kind"
|
|
216
234
|
_eff_ensure_label "priority:$priority" e99695 "kit priority"
|
|
217
235
|
# `effort` is what marks the parent AS an effort, and it is the label `effort_plan` queries
|
|
218
236
|
# (`gh issue list --label effort`, effort-plan.sh). It was read and never written: the label did
|
|
@@ -220,7 +238,7 @@ effort_new() {
|
|
|
220
238
|
# every effort ever created here. A label something reads and nothing writes is the same defect
|
|
221
239
|
# as one something writes and nothing reads — see rules/naming-and-ids.md § Labels.
|
|
222
240
|
_eff_ensure_label "effort" 5319e7 "an effort parent issue"
|
|
223
|
-
local labels="effort,$ctx,kind
|
|
241
|
+
local labels="effort,$ctx,kind:$kind,priority:$priority"
|
|
224
242
|
if [ -n "$role" ]; then
|
|
225
243
|
_eff_ensure_label "role:$role" 0e8a16 "kit role lane"
|
|
226
244
|
labels="$labels,role:$role"
|
|
@@ -230,21 +248,26 @@ effort_new() {
|
|
|
230
248
|
_eff_ensure_label "flow:$flow_lc" 1d76db "kit flow lane"
|
|
231
249
|
labels="$labels,flow:$flow_lc"
|
|
232
250
|
fi
|
|
233
|
-
if [ -n "$par" ]; then
|
|
234
|
-
_eff_ensure_label "par:$par" c5def5 "effort parallelism hint"
|
|
235
|
-
labels="$labels,par:$par"
|
|
236
|
-
fi
|
|
237
251
|
|
|
238
252
|
local url num slug
|
|
253
|
+
if cckit_gh_rest; then
|
|
254
|
+
url="$(gh_rest_issue_create "$repo" "[Effort] · ${flow_tag}${name}" "$body" "$labels" "$milestone" 0)" \
|
|
255
|
+
|| { echo "effort_new: failed to create the parent issue" >&2; return 1; }
|
|
256
|
+
else
|
|
239
257
|
url="$(gh issue create --repo "$repo" --title "[Effort] · ${flow_tag}${name}" --body "$body" \
|
|
240
258
|
--label "$labels" ${milestone:+--milestone "$milestone"})" \
|
|
241
259
|
|| { echo "effort_new: failed to create the parent issue" >&2; return 1; }
|
|
260
|
+
fi
|
|
242
261
|
num="${url##*/}"
|
|
243
|
-
|
|
262
|
+
if cckit_gh_rest; then gh_rest_issue_edit_title "$repo" "$num" "[Effort] $num · ${flow_tag}${name}" >/dev/null 2>&1
|
|
263
|
+
else gh issue edit "$num" --repo "$repo" --title "[Effort] $num · ${flow_tag}${name}" >/dev/null 2>&1; fi
|
|
244
264
|
# The human handle (#93): explicit --slug if given, else derived from the title (number/flow peeled).
|
|
245
265
|
if [ -n "$explicit_slug" ]; then slug="$(_eff_slug "$explicit_slug")"
|
|
246
266
|
else slug="$(_eff_title_slug "[Effort] $num · ${flow_tag}${name}")"; fi
|
|
247
|
-
if [ -n "$slug" ]; then
|
|
267
|
+
if [ -n "$slug" ] && cckit_gh_rest; then
|
|
268
|
+
gh_rest_label_create "$repo" "slug:$slug" ededed "effort slug handle"
|
|
269
|
+
gh_rest_issue_add_labels "$repo" "$num" "slug:$slug" >/dev/null 2>&1 || true
|
|
270
|
+
elif [ -n "$slug" ]; then
|
|
248
271
|
gh label create "slug:$slug" --repo "$repo" --color ededed \
|
|
249
272
|
--description "effort slug handle" >/dev/null 2>&1 || true # idempotent: ok if it exists
|
|
250
273
|
gh issue edit "$num" --repo "$repo" --add-label "slug:$slug" >/dev/null 2>&1 || true
|
|
@@ -269,11 +292,16 @@ effort_new() {
|
|
|
269
292
|
sub_name="${spec%% :: *}"
|
|
270
293
|
sub_desc="${spec#* :: }"; [ "$sub_desc" = "$spec" ] && sub_desc=""
|
|
271
294
|
sub_title="[Effort $num] $i · $sub_name"
|
|
272
|
-
local sub_labels="kind
|
|
295
|
+
local sub_labels="kind:$kind,priority:$priority"
|
|
273
296
|
[ -n "$role" ] && sub_labels="$sub_labels,role:$role"
|
|
297
|
+
if cckit_gh_rest; then
|
|
298
|
+
child="$(gh_rest_issue_create "$repo" "$sub_title" \
|
|
299
|
+
"$(printf '%s\n\nSub-issue of #%s (effort).' "$sub_desc" "$num")" "$sub_labels" "$milestone" 0)" || continue
|
|
300
|
+
else
|
|
274
301
|
child="$(gh issue create --repo "$repo" --title "$sub_title" \
|
|
275
302
|
--body "$(printf '%s\n\nSub-issue of #%s (effort).' "$sub_desc" "$num")" \
|
|
276
303
|
--label "$sub_labels" ${milestone:+--milestone "$milestone"})" || continue
|
|
304
|
+
fi
|
|
277
305
|
child_num="${child##*/}"
|
|
278
306
|
effort_link_sub "$num" "$child_num" || true
|
|
279
307
|
_eff_board_add "$child_num" "$role" || true
|
|
@@ -291,6 +319,17 @@ _eo_source_effort() {
|
|
|
291
319
|
[ -f "$d/effort.sh" ] && . "$d/effort.sh"
|
|
292
320
|
}
|
|
293
321
|
|
|
322
|
+
# _eff_issue_body <repo> <n> / _eff_issue_set_body <repo> <n> <body> — read and replace an issue
|
|
323
|
+
# body on the chosen transport (#396). A failed read returns non-zero, never an empty body.
|
|
324
|
+
_eff_issue_body() {
|
|
325
|
+
if cckit_gh_rest; then gh api "repos/$1/issues/$2" --jq '.body // ""'
|
|
326
|
+
else gh issue view "$2" --repo "$1" --json body --jq .body; fi
|
|
327
|
+
}
|
|
328
|
+
_eff_issue_set_body() {
|
|
329
|
+
if cckit_gh_rest; then gh_rest_issue_set_body "$1" "$2" "$3"
|
|
330
|
+
else gh issue edit "$2" --repo "$1" --body "$3"; fi
|
|
331
|
+
}
|
|
332
|
+
|
|
294
333
|
# _eff_blockers <issue> — echo the issue's CURRENT blocked_by numbers, one per line. Empty when the
|
|
295
334
|
# issue has no edges or the API call fails (the caller treats that as "no known edge").
|
|
296
335
|
_eff_blockers() {
|
|
@@ -401,13 +440,13 @@ effort_chain() {
|
|
|
401
440
|
|
|
402
441
|
# A FAILED read is not an empty body: writing the composed body after a failed fetch would
|
|
403
442
|
# wipe the issue. Only a successful read is edited.
|
|
404
|
-
if ! body="$(
|
|
443
|
+
if ! body="$(_eff_issue_body "$repo" "$next" 2>/dev/null)"; then
|
|
405
444
|
echo " ✗ could not read #$next's body — 'Depends on #$prev' not recorded" >&2; rc=1
|
|
406
|
-
elif
|
|
445
|
+
elif grep -qE "^[[:space:]]*- Depends on #${prev}[[:space:]]*$" <<<"$body"; then
|
|
407
446
|
echo " · #$next already records 'Depends on #$prev'" >&2
|
|
408
447
|
else
|
|
409
448
|
newbody="$(_eff_relations_add "$body" "$prev")"
|
|
410
|
-
|
|
449
|
+
_eff_issue_set_body "$repo" "$next" "$newbody" >/dev/null 2>&1 \
|
|
411
450
|
&& echo " ✓ #$next records 'Depends on #$prev'" >&2 \
|
|
412
451
|
|| { echo " ✗ could not update #$next's body" >&2; rc=1; }
|
|
413
452
|
fi
|
|
@@ -611,7 +650,7 @@ effort_start() {
|
|
|
611
650
|
[ -n "$raw" ] || { echo "effort_start: <slug|effort issue #> required" >&2; return 1; }
|
|
612
651
|
num="$(effort_slug_resolve "$raw")" || { echo "effort_start: could not resolve '$raw' to an effort" >&2; return 1; }
|
|
613
652
|
repo="$(_eff_repo)"; base="$(_eff_base)"
|
|
614
|
-
root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree /{print $2;
|
|
653
|
+
root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree / && !hit {print $2; hit=1}')"
|
|
615
654
|
[ -n "$root" ] || { echo "effort_start: not in a git repo" >&2; return 1; }
|
|
616
655
|
|
|
617
656
|
# WIP gate (#244) — BEFORE the fetch, the branch, the worktree and the bootstrap, so a refusal
|
|
@@ -620,8 +659,22 @@ effort_start() {
|
|
|
620
659
|
|
|
621
660
|
if [ -n "$slug_override" ]; then slug="$(_eff_slug "$slug_override")"
|
|
622
661
|
else
|
|
623
|
-
|
|
624
|
-
|
|
662
|
+
# A soft read (#330): the slug has a fallback, so a failed gh must not end the op — and under
|
|
663
|
+
# `set -e` a bare failed assignment did exactly that, rc 1 with no output. Failed is told apart
|
|
664
|
+
# from empty by gh's exit code, and said on stderr.
|
|
665
|
+
local title_rc=0
|
|
666
|
+
if cckit_gh_rest; then title="$(gh api "repos/$repo/issues/$num" --jq .title 2>/dev/null)" || title_rc=$?
|
|
667
|
+
else title="$(gh issue view "$num" --repo "$repo" --json title -q .title 2>/dev/null)" || title_rc=$?; fi
|
|
668
|
+
slug=""
|
|
669
|
+
if [ "$title_rc" -ne 0 ]; then
|
|
670
|
+
title=""
|
|
671
|
+
# An effort already started keeps its branch: a re-start during an outage must land on
|
|
672
|
+
# effort/<N>-<its slug>, not cut a second branch named after the fallback.
|
|
673
|
+
slug="$(git -C "$root" for-each-ref --format='%(refname:short)' "refs/heads/effort/$num-*" 2>/dev/null | sed -n 1p)"
|
|
674
|
+
slug="${slug#effort/"$num"-}"
|
|
675
|
+
echo "effort_start: could not read the title of issue #$num from GitHub (gh exited $title_rc) — continuing with the slug '${slug:-effort}'. To choose the slug: effort start $num <slug>" >&2
|
|
676
|
+
fi
|
|
677
|
+
[ -n "$slug" ] || slug="$(_eff_title_slug "${title:-effort}")"; [ -n "$slug" ] || slug="effort"
|
|
625
678
|
fi
|
|
626
679
|
# Worktree dir follows the kind+N-slug convention (branch-naming.md) so kit-gc's issue-open
|
|
627
680
|
# protection recognizes it by DIRECTORY name too — matching the kit-effort-start skill (#119).
|
|
@@ -642,6 +695,13 @@ effort_start() {
|
|
|
642
695
|
local from="origin/$base"; git -C "$root" rev-parse --verify --quiet "$from" >/dev/null 2>&1 || from="$base"
|
|
643
696
|
git -C "$root" worktree add -b "$branch" "$wt" "$from" >/dev/null 2>&1 \
|
|
644
697
|
|| { echo "effort_start: failed to create worktree for $branch" >&2; return 1; }
|
|
698
|
+
# Stamp the effort's start (#453): `effort close` subtracts it for build_seconds. Only here,
|
|
699
|
+
# where the branch is created — a re-start of an effort begun earlier would stamp a start that
|
|
700
|
+
# is too late, and capture falls back to the branch's oldest commit instead. Best-effort.
|
|
701
|
+
_eo_source_metrics
|
|
702
|
+
if command -v record_effort_start >/dev/null 2>&1; then
|
|
703
|
+
( cd "$root" && record_effort_start "$num" ) >/dev/null 2>&1 || true
|
|
704
|
+
fi
|
|
645
705
|
fi
|
|
646
706
|
|
|
647
707
|
# Bootstrap the worktree for local dev: copy gitignored env, assign a per-worktree dev port, and
|
|
@@ -660,7 +720,7 @@ effort_pr() {
|
|
|
660
720
|
# [--for-agents A|--for-agents-file F] [--message M] [--title T]. SUMMARY / FOR_AGENTS / COMMIT_MSG env are
|
|
661
721
|
# honoured as fallbacks.
|
|
662
722
|
_eff_need gh || return 1
|
|
663
|
-
local raw="" summary="${SUMMARY:-}" for_agents="${FOR_AGENTS:-}" msg="${COMMIT_MSG:-}" title_override=""
|
|
723
|
+
local raw="" summary="${SUMMARY:-}" for_agents="${FOR_AGENTS:-}" msg="${COMMIT_MSG:-}" title_override="" ctype=""
|
|
664
724
|
while [ $# -gt 0 ]; do
|
|
665
725
|
case "$1" in
|
|
666
726
|
--summary) summary="${2:-}"; shift 2 ;;
|
|
@@ -669,6 +729,7 @@ effort_pr() {
|
|
|
669
729
|
--for-agents-file) for_agents="$(cat "${2:-/dev/null}")"; shift 2 ;;
|
|
670
730
|
--message|-m) msg="${2:-}"; shift 2 ;;
|
|
671
731
|
--title) title_override="${2:-}"; shift 2 ;;
|
|
732
|
+
--type) ctype="${2:-}"; shift 2 ;;
|
|
672
733
|
*) [ -z "$raw" ] && raw="$1"; shift ;;
|
|
673
734
|
esac
|
|
674
735
|
done
|
|
@@ -684,11 +745,12 @@ effort_pr() {
|
|
|
684
745
|
case "$branch" in effort/"$num"-*) : ;; *) echo "effort_pr: current branch ($branch) is not effort/$num-…" >&2; return 1 ;; esac
|
|
685
746
|
|
|
686
747
|
# Parent metadata: the PR inherits its labels + milestone, and the role names the title.
|
|
687
|
-
meta="$(
|
|
748
|
+
if cckit_gh_rest; then meta="$(gh_rest_issue_json "$repo" "$num" 2>/dev/null)"
|
|
749
|
+
else meta="$(gh issue view "$num" --repo "$repo" --json title,labels,milestone 2>/dev/null)"; fi
|
|
688
750
|
title="$(printf '%s' "$meta" | jq -r '.title // ""' 2>/dev/null)"
|
|
689
751
|
labels="$(printf '%s' "$meta" | jq -r '[.labels[]?.name] | join(",")' 2>/dev/null)"
|
|
690
752
|
milestone="$(printf '%s' "$meta" | jq -r '.milestone.title // ""' 2>/dev/null)"
|
|
691
|
-
role="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^role://p' |
|
|
753
|
+
role="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^role://p' | sed -n 1p)"
|
|
692
754
|
role_disp=""
|
|
693
755
|
if [ -n "$role" ] && command -v role_display >/dev/null 2>&1; then
|
|
694
756
|
role_disp="$(role_display "$role" 2>/dev/null || true)"
|
|
@@ -719,15 +781,31 @@ effort_pr() {
|
|
|
719
781
|
|
|
720
782
|
# ONE shared composer (effort.sh) so every surface titles identically, then the mandatory-[#N]
|
|
721
783
|
# check before we ever call gh — refuse rather than open an id-less PR (#121).
|
|
722
|
-
# --title
|
|
723
|
-
|
|
724
|
-
pr_title="${title_override:-$(effort_pr_title "$num" "${name:-effort}" "$role_disp")}"
|
|
784
|
+
# --title replaces the composed title; it must still carry the [#N] id, checked below.
|
|
785
|
+
pr_title="${title_override:-$(effort_pr_title "$num" "${name:-effort}" "$labels" "$ctype" "$role_disp")}"
|
|
725
786
|
effort_pr_title_check "$pr_title" "$num" || { echo "effort_pr: refusing to open a PR without the [#$num] effort id" >&2; return 1; }
|
|
787
|
+
# #237: under pr.titleStyle = conventional (the default) the title becomes the squash commit the
|
|
788
|
+
# commitlint gate checks, so a title that gate rejects — composed (a bad --type) or passed with
|
|
789
|
+
# --title — is refused here, before gh. issue-title repos run no such gate and skip the check.
|
|
790
|
+
if [ "${KIT_PR_TITLE_STYLE:-conventional}" != "issue-title" ]; then
|
|
791
|
+
if ! command -v commitlint_check >/dev/null 2>&1; then
|
|
792
|
+
local _cl_dir; _cl_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)"
|
|
793
|
+
# shellcheck source=/dev/null
|
|
794
|
+
[ -f "$_cl_dir/commitlint.sh" ] && . "$_cl_dir/commitlint.sh"
|
|
795
|
+
fi
|
|
796
|
+
if command -v commitlint_check >/dev/null 2>&1; then
|
|
797
|
+
commitlint_check "$pr_title" || { echo "effort_pr: refusing to open a PR whose title is not a Conventional Commit subject (pass --type <type> or --title, or set pr.titleStyle to issue-title)" >&2; return 1; }
|
|
798
|
+
else
|
|
799
|
+
echo "effort_pr: commitlint.sh not found — the PR title was not checked against Conventional Commits" >&2
|
|
800
|
+
fi
|
|
801
|
+
fi
|
|
726
802
|
body="$(_eff_pr_body "$num" "$summary" "$for_agents" "$role")"
|
|
727
803
|
|
|
728
804
|
# Four explicit forms, not ${x:+--flag "$x"}: that idiom word-splits under zsh, and this file is
|
|
729
805
|
# sourced from zsh too.
|
|
730
|
-
if
|
|
806
|
+
if cckit_gh_rest; then
|
|
807
|
+
url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$pr_title" "$body" "$labels" "$milestone")" || return 1
|
|
808
|
+
elif [ -n "$labels" ] && [ -n "$milestone" ]; then
|
|
731
809
|
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" --title "$pr_title" --body "$body" \
|
|
732
810
|
--label "$labels" --milestone "$milestone" --assignee "@me")" || return 1
|
|
733
811
|
elif [ -n "$labels" ]; then
|
|
@@ -752,6 +830,16 @@ _eff_pr_body() {
|
|
|
752
830
|
if [ -n "$role" ] && command -v role_signature >/dev/null 2>&1; then
|
|
753
831
|
sig="$(role_signature "$role" 2>/dev/null || true)"
|
|
754
832
|
fi
|
|
833
|
+
# pr.bodyStyle = content (KIT_PR_BODY_STYLE, #418): draft-and-review wording for content work.
|
|
834
|
+
# `Closes #N`, the Summary and the For agents block are the same in both styles.
|
|
835
|
+
if [ "${KIT_PR_BODY_STYLE:-code}" = "content" ]; then
|
|
836
|
+
printf '## For the orchestrator\n\nEffort #%s — one PR for the whole effort. Review: the summary below and the changed files.\n\nCloses #%s\n\n' "$num" "$num"
|
|
837
|
+
printf '## Summary\n\n%s\n\n' "${summary:-_(no summary given — pass --summary)_}"
|
|
838
|
+
printf '## For agents\n\n%s\n\n' "${for_agents:-See #$num for the goal, scope, and entry points.}"
|
|
839
|
+
printf '## Review\n\n- [ ] Every piece the summary lists is in the changed files\n- [ ] Facts, names, numbers and links are checked\n- [ ] The voice matches the brand guide\n- [ ] Only the files for this work changed\n- [ ] Labels + milestone match the parent issue\n'
|
|
840
|
+
[ -n "$sig" ] && printf '\n%s\n' "$sig"
|
|
841
|
+
return 0
|
|
842
|
+
fi
|
|
755
843
|
printf '## For the orchestrator\n\nEffort #%s — one PR for the whole effort. Review: the summary below + the diff.\n\nCloses #%s\n\n' "$num" "$num"
|
|
756
844
|
printf '## Summary\n\n%s\n\n' "${summary:-_(no summary given — pass --summary)_}"
|
|
757
845
|
printf '## For agents\n\n%s\n\n' "${for_agents:-See #$num for the goal, scope, and entry points.}"
|
|
@@ -765,10 +853,11 @@ _eff_pr_body() {
|
|
|
765
853
|
_eff_pr_board() {
|
|
766
854
|
local num="$1" url="$2" role="${3:-}" repo pr_num node item ropt parent
|
|
767
855
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
856
|
+
cckit_board_skipped && return 0
|
|
768
857
|
_eo_source_board
|
|
769
858
|
command -v project_add_item >/dev/null 2>&1 || return 0
|
|
770
859
|
repo="$(_eff_repo)"; pr_num="${url##*/}"
|
|
771
|
-
node="$(gh api "repos/$repo/pulls/$pr_num" --jq .node_id 2>/dev/null)"
|
|
860
|
+
node="$(gh api "repos/$repo/pulls/$pr_num" --jq .node_id 2>/dev/null)" || node=""
|
|
772
861
|
item=""
|
|
773
862
|
[ -n "$node" ] && item="$(project_add_item "$node" 2>/dev/null || true)"
|
|
774
863
|
if [ -z "$item" ]; then
|
|
@@ -778,7 +867,7 @@ _eff_pr_board() {
|
|
|
778
867
|
project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_IN_REVIEW" >/dev/null 2>&1 || true
|
|
779
868
|
fi
|
|
780
869
|
if [ -n "$role" ] && [ -n "${ROLE_FIELD_ID:-}" ] && command -v role_option_id >/dev/null 2>&1; then
|
|
781
|
-
ropt="$(role_option_id "$role"
|
|
870
|
+
ropt="$(role_option_id "$role" || true)"
|
|
782
871
|
[ -n "$ropt" ] && { project_set_single_select "$item" "$ROLE_FIELD_ID" "$ropt" >/dev/null 2>&1 || true; }
|
|
783
872
|
fi
|
|
784
873
|
fi
|
|
@@ -815,6 +904,7 @@ _eo_source_gc() {
|
|
|
815
904
|
# gh-project.sh or ids file degrades to a no-op (the board steps below are themselves guarded).
|
|
816
905
|
_eo_source_board() {
|
|
817
906
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
907
|
+
cckit_board_skipped && return 0
|
|
818
908
|
if ! command -v project_find_item_by_issue >/dev/null 2>&1; then
|
|
819
909
|
local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
820
910
|
# shellcheck source=/dev/null
|
|
@@ -826,12 +916,19 @@ _eo_source_board() {
|
|
|
826
916
|
return 0
|
|
827
917
|
}
|
|
828
918
|
|
|
919
|
+
# _eo_issue_close_completed <repo> <n> — close as completed on the chosen transport (#396), quietly.
|
|
920
|
+
_eo_issue_close_completed() {
|
|
921
|
+
if cckit_gh_rest; then gh_rest_issue_close "$1" "$2" completed >/dev/null 2>&1
|
|
922
|
+
else gh issue close "$2" --repo "$1" --reason completed >/dev/null 2>&1; fi
|
|
923
|
+
}
|
|
924
|
+
|
|
829
925
|
# _eo_board_done <issue #> — set the board Status=Done for one issue. Guarded like _eff_board_add:
|
|
830
926
|
# a no-op unless Projects v2 is on AND the board helpers + field ids are loaded. Best-effort — a
|
|
831
927
|
# board hiccup never fails the close (the merge already landed).
|
|
832
928
|
_eo_board_done() {
|
|
833
929
|
local n="$1" item
|
|
834
930
|
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
931
|
+
cckit_board_skipped && return 0
|
|
835
932
|
command -v project_find_item_by_issue >/dev/null 2>&1 || return 0
|
|
836
933
|
[ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_DONE:-}" ] || return 0
|
|
837
934
|
item="$(project_find_item_by_issue "$n" 2>/dev/null)" || return 0
|
|
@@ -843,19 +940,36 @@ _eo_board_done() {
|
|
|
843
940
|
|
|
844
941
|
# Kit-managed paths (the kit ⇄ project sync surface): a change here that is not contributed
|
|
845
942
|
# upstream (/kit-contribute) is a latent regression the next /kit-update can clobber. One place —
|
|
846
|
-
# effort_close's drift check greps against this (was inlined in the kit-effort-close skill, #148)
|
|
847
|
-
|
|
943
|
+
# effort_close's drift check greps against this (was inlined in the kit-effort-close skill, #148),
|
|
944
|
+
# and so does the task-merge drift check in the kit-task-pr-merge skill.
|
|
945
|
+
# .claude/rules/ is matched by BASENAME, not as a directory (#218): init.sh writes a rule only from
|
|
946
|
+
# templates/rules/<name>.md, so any other file there is the project's own and no /kit-update can
|
|
947
|
+
# touch it. The list is the templates/rules basenames; effort-ops-test.sh fails when they differ.
|
|
948
|
+
_EO_KIT_MANAGED_RE='^(scripts/(lib/|kit$|kit-)|\.claude/(skills|hooks|lib|agents)/|\.claude/rules/(authoring|branch-naming|code-retrieval|communication-style|delegation-brief|design-routing|effort-model|gate-and-review|issue-lifecycle|knowledge-base|mempalace|merge-safety|naming-and-ids|plain-language|plan-next|plan-output-format|react-annotate|review-pages|risk-tiered-review|shared-checkout|skill-gaps|task-management)\.md$)'
|
|
848
949
|
|
|
849
950
|
# _eo_knowledge_ingest <num> <trace_dir> <root> — optional post-close knowledge-ingest hook. Runs a
|
|
850
951
|
# project-configured command (github/effort.knowledgeIngestHook, or KIT_EFFORT_KNOWLEDGE_HOOK) with
|
|
851
952
|
# the effort number + trace dir, so a project can fold the closed effort's work record into its
|
|
852
953
|
# knowledge base. Config-gated: a NO-OP when unset or the hook file is missing/not executable — the
|
|
853
954
|
# kit ships no default hook. Best-effort — a hook failure never fails the close.
|
|
955
|
+
#
|
|
956
|
+
# The config is read AFTER the close removed the effort worktree, and bin/cckit exports KIT_CONFIG as
|
|
957
|
+
# the copy inside that worktree (#518). So a KIT_CONFIG that no longer exists falls back to the main
|
|
958
|
+
# checkout's config; when that is missing too the close says so — a config that vanished is not the
|
|
959
|
+
# same as a project with no hook. The hook's stdout + stderr go to stderr, like the pre-close hook's.
|
|
854
960
|
_eo_knowledge_ingest() {
|
|
855
961
|
local num="$1" trace="$2" root="$3" hook="" cfg
|
|
856
962
|
hook="${KIT_EFFORT_KNOWLEDGE_HOOK:-}"
|
|
857
963
|
if [ -z "$hook" ]; then
|
|
858
|
-
cfg="${KIT_CONFIG:-}"
|
|
964
|
+
cfg="${KIT_CONFIG:-}"
|
|
965
|
+
if [ -z "$cfg" ] || [ ! -f "$cfg" ]; then
|
|
966
|
+
if [ -f "$root/cckit.config.json" ]; then cfg="$root/cckit.config.json"
|
|
967
|
+
elif [ -f "$root/.claude/kit.config.json" ]; then cfg="$root/.claude/kit.config.json"
|
|
968
|
+
elif [ -n "$cfg" ]; then
|
|
969
|
+
echo "effort_close: project config '$cfg' went away with the worktree and the main checkout has none — post-close hook not read" >&2
|
|
970
|
+
return 0
|
|
971
|
+
fi
|
|
972
|
+
fi
|
|
859
973
|
[ -f "$cfg" ] && command -v jq >/dev/null 2>&1 \
|
|
860
974
|
&& hook="$(jq -r '.effort.knowledgeIngestHook // empty' "$cfg" 2>/dev/null)"
|
|
861
975
|
fi
|
|
@@ -865,7 +979,69 @@ _eo_knowledge_ingest() {
|
|
|
865
979
|
echo " → knowledge-ingest hook: $hook $num" >&2
|
|
866
980
|
# Run it from the main checkout (#371): the close has just removed the worktree it was invoked from,
|
|
867
981
|
# so the inherited cwd no longer exists and a hook's relative paths / bare git calls would fail.
|
|
868
|
-
( cd "${root:-/}" && "$hook" "$num" "$trace" )
|
|
982
|
+
( cd "${root:-/}" && "$hook" "$num" "$trace" ) 1>&2 || echo "effort_close: knowledge-ingest hook failed (non-fatal)" >&2
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
# _eo_dependent_prs <branch> — pure selector (#358): `gh pr list --json number,baseRefName` on stdin,
|
|
986
|
+
# the numbers of the PRs whose base is exactly <branch> on stdout, one per line. Empty stdin prints
|
|
987
|
+
# nothing; input that is not a JSON array is rc 1, so the caller can tell "none" from "unreadable".
|
|
988
|
+
_eo_dependent_prs() {
|
|
989
|
+
jq -r --arg b "$1" 'if type == "array" then .[] | select(.baseRefName == $b) | .number else error("not a list") end' 2>/dev/null
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
# _eo_retarget_dependents <repo> <branch> <base> — re-target every open PR based on <branch> to
|
|
993
|
+
# <base> (#358). GitHub closes a PR, unmerged, the moment its base branch is deleted, and the squash
|
|
994
|
+
# below deletes <branch>. rc 1 when the list cannot be read or an edit fails: the caller refuses the
|
|
995
|
+
# close, because either one means a PR would be closed by the delete.
|
|
996
|
+
_eo_retarget_dependents() {
|
|
997
|
+
local repo="$1" branch="$2" base="$3" json deps dep
|
|
998
|
+
json="$(gh pr list --repo "$repo" --base "$branch" --state open --limit 200 --json number,baseRefName 2>/dev/null)" \
|
|
999
|
+
&& deps="$(printf '%s' "$json" | _eo_dependent_prs "$branch")" \
|
|
1000
|
+
|| { echo "effort_close: could not list the open PRs based on $branch — deleting it would close any that exist. Rerun when 'gh pr list --base $branch' works (nothing was merged)" >&2; return 1; }
|
|
1001
|
+
while IFS= read -r dep; do
|
|
1002
|
+
[ -n "$dep" ] || continue
|
|
1003
|
+
gh pr edit "$dep" --repo "$repo" --base "$base" >/dev/null 2>&1 \
|
|
1004
|
+
|| { echo "effort_close: PR $dep is based on $branch and could not be re-targeted to $base — deleting the branch would close it. Run 'gh pr edit $dep --base $base', then rerun (nothing was merged)" >&2; return 1; }
|
|
1005
|
+
echo " ↻ PR $dep re-targeted to $base" >&2
|
|
1006
|
+
done <<EOF_DEPS
|
|
1007
|
+
$deps
|
|
1008
|
+
EOF_DEPS
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
# _eo_pre_close_hook <num> <repo> <root> <cwd> [<subs>] — optional project gate that runs BEFORE the
|
|
1012
|
+
# close writes anything (#380). Runs a project-configured command (effort.preCloseHook, or
|
|
1013
|
+
# KIT_EFFORT_PRE_CLOSE_HOOK) as `<hook> <effort#> <sub#…>` with cwd = <cwd> (the effort worktree; the
|
|
1014
|
+
# checkout the close was run from on the wave path). <subs> is a newline-separated sub list; when
|
|
1015
|
+
# omitted the native sub-issues are read from GitHub. Returns 1 — the caller refuses the close —
|
|
1016
|
+
# when the hook exits non-zero, or is configured but not executable: a gate that cannot run must not
|
|
1017
|
+
# pass. The hook's stdout + stderr go to stderr. KIT_FORCE=1 skips the hook and says so. A NO-OP
|
|
1018
|
+
# (rc 0, no GitHub read) when no hook is configured — the kit ships no default hook.
|
|
1019
|
+
_eo_pre_close_hook() {
|
|
1020
|
+
local num="$1" repo="$2" root="$3" cwd="$4" subs="${5:-}" hook="" cfg sub rc
|
|
1021
|
+
hook="${KIT_EFFORT_PRE_CLOSE_HOOK:-}"
|
|
1022
|
+
if [ -z "$hook" ]; then
|
|
1023
|
+
cfg="${KIT_CONFIG:-}"; [ -n "$cfg" ] || { [ -f "$root/cckit.config.json" ] && cfg="$root/cckit.config.json" || cfg="$root/.claude/kit.config.json"; }
|
|
1024
|
+
[ -f "$cfg" ] && command -v jq >/dev/null 2>&1 \
|
|
1025
|
+
&& hook="$(jq -r '.effort.preCloseHook // empty' "$cfg" 2>/dev/null)"
|
|
1026
|
+
fi
|
|
1027
|
+
[ -n "$hook" ] || return 0
|
|
1028
|
+
case "$hook" in /*) : ;; *) hook="$root/$hook" ;; esac # resolve a relative hook against the root
|
|
1029
|
+
if [ "${KIT_FORCE:-0}" = "1" ]; then
|
|
1030
|
+
echo "effort_close: pre-close hook '$hook' skipped (KIT_FORCE=1)" >&2; return 0
|
|
1031
|
+
fi
|
|
1032
|
+
[ -x "$hook" ] || { echo "effort_close: pre-close hook '$hook' is configured but not executable — refusing to close #$num (nothing was written). Fix effort.preCloseHook, or set KIT_FORCE=1 to skip it." >&2; return 1; }
|
|
1033
|
+
[ "$#" -ge 5 ] || subs="$(gh api "repos/$repo/issues/$num/sub_issues" --jq '.[].number' 2>/dev/null)"
|
|
1034
|
+
set -- "$num"
|
|
1035
|
+
while IFS= read -r sub; do
|
|
1036
|
+
[ -n "$sub" ] && set -- "$@" "$sub"
|
|
1037
|
+
done <<EOF_SUBS
|
|
1038
|
+
$subs
|
|
1039
|
+
EOF_SUBS
|
|
1040
|
+
echo " → pre-close hook: $hook $*" >&2
|
|
1041
|
+
( cd "${cwd:-.}" && "$hook" "$@" ) 1>&2; rc=$?
|
|
1042
|
+
[ "$rc" -eq 0 ] && return 0
|
|
1043
|
+
echo "effort_close: pre-close hook exited $rc — refusing to close #$num (nothing was written). Fix what it reports, or set KIT_FORCE=1 to skip it." >&2
|
|
1044
|
+
return 1
|
|
869
1045
|
}
|
|
870
1046
|
|
|
871
1047
|
# effort_close <N> — the SINGLE close implementation (#148): the /kit-effort-close skill is a thin
|
|
@@ -888,16 +1064,20 @@ effort_close() {
|
|
|
888
1064
|
# just the wrong cwd — keep the instruction. If it exists NOWHERE, this is a WAVE-style
|
|
889
1065
|
# effort (#164): the subs shipped as individual task PRs squash-merged straight to base, so
|
|
890
1066
|
# there is no branch to run from — close via the merged sub PRs instead.
|
|
891
|
-
if git branch --list "effort/$num-*" 2>/dev/null
|
|
892
|
-
|| git ls-remote --heads origin "effort/$num-*" 2>/dev/null
|
|
1067
|
+
if [ -n "$(git branch --list "effort/$num-*" 2>/dev/null)" ] \
|
|
1068
|
+
|| [ -n "$(git ls-remote --heads origin "effort/$num-*" 2>/dev/null)" ]; then
|
|
893
1069
|
echo "effort_close: run from the effort/$num-… branch" >&2; return 1
|
|
894
1070
|
fi
|
|
895
1071
|
_eo_close_wave "$num" "$repo" "$base"; return $? ;;
|
|
896
1072
|
esac
|
|
897
|
-
root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree /{print $2;
|
|
1073
|
+
root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree / && !hit {print $2; hit=1}')"
|
|
898
1074
|
self_wt="$(git rev-parse --show-toplevel 2>/dev/null)"
|
|
899
1075
|
_eo_source_metrics
|
|
900
1076
|
|
|
1077
|
+
# (pre) optional project gate (effort.preCloseHook, #380) — before the snapshot, so a refusal
|
|
1078
|
+
# writes nothing: no trace, no metrics row, no merge.
|
|
1079
|
+
_eo_pre_close_hook "$num" "$repo" "$root" "$self_wt" || return 1
|
|
1080
|
+
|
|
901
1081
|
# (a) snapshot the per-sub-issue diffs while the unsquashed history still exists (echoes the trace dir).
|
|
902
1082
|
trace_dir="$(effort_snapshot_subs "$num" "origin/$base" 2>/dev/null)"
|
|
903
1083
|
|
|
@@ -915,6 +1095,41 @@ effort_close() {
|
|
|
915
1095
|
fi
|
|
916
1096
|
fi
|
|
917
1097
|
|
|
1098
|
+
# (a2) refuse a conflicting PR before anything is written (#394). The capture below appends a
|
|
1099
|
+
# records.jsonl row and consumes the effort's start marker, so a merge that fails after it leaves a
|
|
1100
|
+
# row the retry duplicates with build_seconds null. UNKNOWN (GitHub still computing) proceeds.
|
|
1101
|
+
local rest_pr="" mergeable
|
|
1102
|
+
if cckit_gh_rest; then
|
|
1103
|
+
# Same refusal as the graphql branch below (#330): a failed read, or no open PR, must stop here.
|
|
1104
|
+
# Carrying on let the capture write its row and consume the start marker before the merge failed.
|
|
1105
|
+
local rest_meta=""
|
|
1106
|
+
rest_pr="$(gh_rest_pr_for_head "$repo" "$branch" 2>/dev/null)" || rest_pr=""
|
|
1107
|
+
[ -n "$rest_pr" ] && rest_meta="$(gh_rest_pr_json "$repo" "$rest_pr" 2>/dev/null)" || rest_meta=""
|
|
1108
|
+
[ -n "$rest_meta" ] || {
|
|
1109
|
+
echo "effort_close: could not read the PR for $branch from GitHub (gh failed: no PR, or the API is unavailable) — rerun when it answers (nothing was written)" >&2
|
|
1110
|
+
return 1
|
|
1111
|
+
}
|
|
1112
|
+
mergeable="$(printf '%s' "$rest_meta" | jq -r .mergeable)"
|
|
1113
|
+
else
|
|
1114
|
+
# A failed read is not "mergeable" (#330). Under `set -e` this bare assignment ended the close
|
|
1115
|
+
# with rc 1 and no output; refusing by name keeps the nothing-written guarantee this step is for.
|
|
1116
|
+
mergeable="$(gh pr view "$branch" --repo "$repo" --json mergeable -q .mergeable 2>/dev/null)" || {
|
|
1117
|
+
echo "effort_close: could not read the PR for $branch from GitHub (gh failed: no PR, or the API is unavailable) — rerun when it answers (nothing was written)" >&2
|
|
1118
|
+
return 1
|
|
1119
|
+
}
|
|
1120
|
+
fi
|
|
1121
|
+
if [ "$mergeable" = "CONFLICTING" ]; then
|
|
1122
|
+
echo "effort_close: the PR for $branch conflicts with $base — merge or rebase $base into it, then rerun (nothing was written)" >&2
|
|
1123
|
+
return 1
|
|
1124
|
+
fi
|
|
1125
|
+
|
|
1126
|
+
# (a3) re-target the open PRs based on this branch before the squash deletes it (#358). Here, not
|
|
1127
|
+
# next to the merge, for the same reason as the conflict check: a refusal after the capture leaves
|
|
1128
|
+
# a records.jsonl row the retry duplicates. Skipped over REST, where the remote branch is kept.
|
|
1129
|
+
if ! cckit_gh_rest; then
|
|
1130
|
+
_eo_retarget_dependents "$repo" "$branch" "$base" || return 1
|
|
1131
|
+
fi
|
|
1132
|
+
|
|
918
1133
|
# (b) capture effort metrics PRE-squash (needs the live-branch diff + commit signals).
|
|
919
1134
|
command -v capture_effort_metrics >/dev/null 2>&1 && capture_effort_metrics "$num" "origin/$base" || true
|
|
920
1135
|
|
|
@@ -923,10 +1138,18 @@ effort_close() {
|
|
|
923
1138
|
kit_touched="$(git diff --name-only "origin/$base"...HEAD 2>/dev/null \
|
|
924
1139
|
| grep -E "$_EO_KIT_MANAGED_RE" | sort -u || true)"
|
|
925
1140
|
|
|
926
|
-
# (c) squash-merge the effort PR.
|
|
1141
|
+
# (c) squash-merge the effort PR. Over REST the remote branch stays: the cloud proxy rejects branch
|
|
1142
|
+
# deletion (#396).
|
|
1143
|
+
if cckit_gh_rest; then
|
|
1144
|
+
{ [ -n "$rest_pr" ] && gh_rest_pr_merge "$repo" "$rest_pr" squash >/dev/null 2>&1; } \
|
|
1145
|
+
|| { echo "effort_close: could not squash-merge the PR for $branch (open? mergeable?)" >&2; return 1; }
|
|
1146
|
+
echo " ✓ merged $branch" >&2
|
|
1147
|
+
echo " (remote branch $branch kept — branch deletion is unavailable here; delete it on GitHub)" >&2
|
|
1148
|
+
else
|
|
927
1149
|
gh pr merge "$branch" --repo "$repo" --squash --delete-branch >/dev/null 2>&1 \
|
|
928
1150
|
|| { echo "effort_close: could not squash-merge the PR for $branch (open? mergeable?)" >&2; return 1; }
|
|
929
1151
|
echo " ✓ merged $branch" >&2
|
|
1152
|
+
fi
|
|
930
1153
|
|
|
931
1154
|
# (d) judge + sync the metrics (judge reads the durable trace dir; sync no-ops when the engine is off).
|
|
932
1155
|
command -v judge_effort_metrics >/dev/null 2>&1 && judge_effort_metrics "$num" "origin/$base" || true
|
|
@@ -939,10 +1162,10 @@ effort_close() {
|
|
|
939
1162
|
local sub
|
|
940
1163
|
while IFS= read -r sub; do
|
|
941
1164
|
[ -n "$sub" ] || continue
|
|
942
|
-
|
|
1165
|
+
_eo_issue_close_completed "$repo" "$sub" && echo " ✓ closed sub #$sub" >&2
|
|
943
1166
|
_eo_board_done "$sub"
|
|
944
1167
|
done < <(gh api "repos/$repo/issues/$num/sub_issues" --jq '.[].number' 2>/dev/null)
|
|
945
|
-
|
|
1168
|
+
_eo_issue_close_completed "$repo" "$num" && echo " ✓ closed effort #$num" >&2
|
|
946
1169
|
_eo_board_done "$num"
|
|
947
1170
|
|
|
948
1171
|
# (f) GC: switch the main checkout to base, remove the effort worktree, delete the local branch,
|
|
@@ -1000,11 +1223,14 @@ _eo_kit_sync_warn() {
|
|
|
1000
1223
|
# merged PR diffs in the trace are the work record.
|
|
1001
1224
|
_eo_close_wave() {
|
|
1002
1225
|
local num="$1" repo="$2" base="$3" root rows bad trace_dir kit_touched sub
|
|
1003
|
-
root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree /{print $2;
|
|
1226
|
+
root="$(git worktree list --porcelain 2>/dev/null | awk '/^worktree / && !hit {print $2; hit=1}')"
|
|
1004
1227
|
_eo_source_metrics
|
|
1005
1228
|
|
|
1006
1229
|
# (a) read every sub + the merged PR that closed it, one "sub|state|pr|merge-oid|title" line each
|
|
1007
1230
|
# (title LAST so a stray "|" in it can't shift the fields awk/read split on).
|
|
1231
|
+
if cckit_gh_rest; then
|
|
1232
|
+
rows="$(gh_rest_wave_rows "$repo" "$num" 2>/dev/null)"
|
|
1233
|
+
else
|
|
1008
1234
|
rows="$(gh api graphql -f query='
|
|
1009
1235
|
query($o:String!,$r:String!,$n:Int!){ repository(owner:$o,name:$r){ issue(number:$n){
|
|
1010
1236
|
subIssues(first:50){ nodes { number state
|
|
@@ -1013,6 +1239,7 @@ _eo_close_wave() {
|
|
|
1013
1239
|
.data.repository.issue.subIssues.nodes[]
|
|
1014
1240
|
| (((.closedByPullRequestsReferences.nodes // []) | map(select(.merged)) | .[0]) // null) as $pr
|
|
1015
1241
|
| "\(.number)|\(.state)|\($pr.number // "")|\($pr.mergeCommit.oid // "")|\($pr.title // "")"' 2>/dev/null)"
|
|
1242
|
+
fi
|
|
1016
1243
|
[ -n "$rows" ] || { echo "effort_close: no effort/$num-… branch and no readable sub-issues — nothing to close (wave-style needs merged subs, #164)" >&2; return 1; }
|
|
1017
1244
|
|
|
1018
1245
|
# (b) every sub must be CLOSED with a merged closing PR — otherwise the effort is not done.
|
|
@@ -1024,6 +1251,11 @@ _eo_close_wave() {
|
|
|
1024
1251
|
return 1
|
|
1025
1252
|
fi
|
|
1026
1253
|
|
|
1254
|
+
# (pre) the same optional project gate as the branch path (#380), before the trace is written.
|
|
1255
|
+
# There is no effort worktree here, so it runs from the checkout the close was invoked in.
|
|
1256
|
+
_eo_pre_close_hook "$num" "$repo" "$root" "$(git rev-parse --show-toplevel 2>/dev/null)" \
|
|
1257
|
+
"$(printf '%s\n' "$rows" | cut -d'|' -f1)" || return 1
|
|
1258
|
+
|
|
1027
1259
|
# (c) the work trace, from the merged sub PR diffs (the record the per-sub squashes left behind).
|
|
1028
1260
|
# Same refuse-without-trace backstop as the branch path (#120) — KIT_FORCE=1 overrides.
|
|
1029
1261
|
trace_dir="$(effort_snapshot_merged_subs "$num" "$rows" 2>/dev/null)"
|
|
@@ -1049,7 +1281,7 @@ _eo_close_wave() {
|
|
|
1049
1281
|
for sub in $(printf '%s\n' "$rows" | cut -d'|' -f1); do
|
|
1050
1282
|
_eo_board_done "$sub"
|
|
1051
1283
|
done
|
|
1052
|
-
|
|
1284
|
+
_eo_issue_close_completed "$repo" "$num" && echo " ✓ closed effort #$num" >&2
|
|
1053
1285
|
_eo_board_done "$num"
|
|
1054
1286
|
|
|
1055
1287
|
# (g) GC: the sub branches/worktrees were GC'd by their own merges — just prune stragglers.
|