@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
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
# Family 1 of kit-engine-boundary.md (rule #1/#2): one bash home for the op, consumed by the
|
|
5
5
|
# kit-task-start skill, scripts/orchestrate.sh, and `kit task start`. No second implementation.
|
|
6
6
|
#
|
|
7
|
-
# wt_start <issue-number> [slug-override]
|
|
7
|
+
# wt_start [--force] <issue-number> [slug-override]
|
|
8
|
+
# Refuses (rc 1, before any fetch / branch / worktree) when another LIVE session already holds
|
|
9
|
+
# the issue's claim in <git-common-dir>/kit-sessions (session-registry.sh). `--force` or
|
|
10
|
+
# KIT_FORCE=1 starts anyway and takes the claim over.
|
|
8
11
|
# stdout: "<worktree-path>|<branch>|<issue-number>" (one line, machine-readable)
|
|
9
12
|
# stderr: human progress
|
|
10
13
|
# returns: 0 on success (created or reused), 1 on failure
|
|
@@ -12,6 +15,40 @@
|
|
|
12
15
|
# Requires: gh, jq, git, scripts/lib/gh-project.sh (board update). bash 3.2 compatible.
|
|
13
16
|
# errors: strict — rc 1 on failure; a half-made worktree is never reported as ready
|
|
14
17
|
|
|
18
|
+
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
19
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
20
|
+
_ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
|
|
21
|
+
# shellcheck source=/dev/null
|
|
22
|
+
[ -f "$_ghr_lib" ] && . "$_ghr_lib"
|
|
23
|
+
unset _ghr_lib
|
|
24
|
+
fi
|
|
25
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
26
|
+
|
|
27
|
+
# The claims registry (#384). Guarded: a project scaffolded before session-registry.sh shipped has
|
|
28
|
+
# worktree-start.sh without it, and there wt_start runs with no claim check rather than failing.
|
|
29
|
+
if ! command -v sreg_claim >/dev/null 2>&1; then
|
|
30
|
+
_sr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/session-registry.sh"
|
|
31
|
+
# shellcheck source=/dev/null
|
|
32
|
+
[ -f "$_sr_lib" ] && . "$_sr_lib"
|
|
33
|
+
unset _sr_lib
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# The closed kind: vocabulary (kinds.sh). The issue's `kind:` label becomes the branch prefix, so it
|
|
37
|
+
# is mapped through the set: a label outside it (kind:bug, kind:docs, a typo) would otherwise produce
|
|
38
|
+
# a branch the hygiene hook rejects as non-conventional.
|
|
39
|
+
if ! command -v kit_kind_branch >/dev/null 2>&1; then
|
|
40
|
+
_wtk_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/kinds.sh"
|
|
41
|
+
# shellcheck source=/dev/null
|
|
42
|
+
[ -f "$_wtk_lib" ] && . "$_wtk_lib"
|
|
43
|
+
unset _wtk_lib
|
|
44
|
+
fi
|
|
45
|
+
# _wt_kind_prefix <kind> — the branch prefix for a kind label value. With kinds.sh loaded: the value
|
|
46
|
+
# itself when it is in the closed set, else `task` plus a warning on stderr. Without kinds.sh (a
|
|
47
|
+
# project scaffolded before it shipped) the value passes through unchanged, as it always did.
|
|
48
|
+
_wt_kind_prefix() {
|
|
49
|
+
if command -v kit_kind_branch >/dev/null 2>&1; then kit_kind_branch "${1:-}"; else printf '%s\n' "${1:-task}"; fi
|
|
50
|
+
}
|
|
51
|
+
|
|
15
52
|
WT_START_REPO="${WT_START_REPO:-${KIT_REPO:-}}"
|
|
16
53
|
|
|
17
54
|
# _wt_set_port <app-env-file> <port> <issue-num> — append a per-worktree dev PORT to an app's
|
|
@@ -22,7 +59,8 @@ WT_START_REPO="${WT_START_REPO:-${KIT_REPO:-}}"
|
|
|
22
59
|
# file. A script like `next dev -p ${PORT:-3003}` is expanded by the npm-script shell, which never
|
|
23
60
|
# reads .env.local, so the value is INERT for it and every worktree falls back to the same default.
|
|
24
61
|
# cckit therefore does not RELY on it: everything cckit launches itself passes the port explicitly
|
|
25
|
-
# (scripts/lib/qa-lane.sh
|
|
62
|
+
# (scripts/lib/qa-lane.sh exports each port env var the project declared in `qa.ports`, set to that
|
|
63
|
+
# lane's port, into the command it launches). Treat the .env.local write as
|
|
26
64
|
# a convenience for apps that do read it — and if you start a dev server by hand in a worktree,
|
|
27
65
|
# check which port you actually got.
|
|
28
66
|
_wt_set_port() {
|
|
@@ -46,6 +84,16 @@ _wt_set_port() {
|
|
|
46
84
|
# State lives beside the event log under the git-common-dir, so it is worktree-durable and shared by
|
|
47
85
|
# every checkout. Each line: <issue>\t<slot>\t<worktree-path>. A slot whose worktree is gone is
|
|
48
86
|
# reclaimed on the next call, which is what keeps the 40 slots from leaking away over a long project.
|
|
87
|
+
# _wt_num_hash <key> — <key> itself when it is a number, else a number derived from it. The slot
|
|
88
|
+
# ledger is keyed by issue number; a light task (#450) is keyed by its id (`t3f9a`), and the hashed
|
|
89
|
+
# fallbacks below do arithmetic on the key.
|
|
90
|
+
_wt_num_hash() {
|
|
91
|
+
case "$1" in
|
|
92
|
+
''|*[!0-9]*) printf '%s' "$1" | cksum | cut -d' ' -f1 ;;
|
|
93
|
+
*) printf '%s' "$1" ;;
|
|
94
|
+
esac
|
|
95
|
+
}
|
|
96
|
+
|
|
49
97
|
_wt_slots_file() {
|
|
50
98
|
local gcd
|
|
51
99
|
gcd="$(git -C "${1:-.}" rev-parse --git-common-dir 2>/dev/null)" || return 1
|
|
@@ -59,34 +107,46 @@ _wt_slots_file() {
|
|
|
59
107
|
# very defect the slot ledger exists to remove. The reclaim rewrite races worse than the append:
|
|
60
108
|
# it `mv`s a snapshot over the ledger, silently dropping any row another process added in between.
|
|
61
109
|
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
110
|
+
# The lock primitive is the shell's own noclobber redirection: `set -C; : > file` opens with
|
|
111
|
+
# O_CREAT|O_EXCL, which the kernel makes exclusive, and no external tool is involved. A stock macOS
|
|
112
|
+
# has no flock(1) and this file targets bash 3.2.
|
|
113
|
+
#
|
|
114
|
+
# It was `mkdir` until #449. `mkdir` is exclusive only when the binary makes ONE mkdir(2) call and
|
|
115
|
+
# reports its EEXIST. uutils coreutils 0.10.0 (the `mkdir` of Ubuntu 26.04, and of GitHub's
|
|
116
|
+
# `ubuntu-latest` runner) calls statx first and exits 0 for the loser of a race: 8 processes running
|
|
117
|
+
# `mkdir <same path>` at once all "succeeded" in 183 of 200 rounds. Two `cckit start` runs then held
|
|
118
|
+
# this lock together and were given the same slot.
|
|
65
119
|
_WT_LOCK_WAIT="${_WT_LOCK_WAIT:-10}" # seconds to wait for a held lock before giving up
|
|
66
120
|
|
|
67
|
-
#
|
|
121
|
+
# _wt_lock_try <lockfile> — ONE attempt: 0 when this call created the lock, 1 when it exists. The
|
|
122
|
+
# subshell keeps noclobber out of the caller's shell. Never replace this with an external command
|
|
123
|
+
# without racing it first (scripts/lib/worktree-ports-test.sh section 7 does).
|
|
124
|
+
_wt_lock_try() { ( set -C; : > "$1" ) 2>/dev/null; }
|
|
125
|
+
|
|
126
|
+
# _wt_lock <lockfile> — 0 when the lock is held, 1 when it is not. A caller that fails to lock
|
|
68
127
|
# proceeds ANYWAY: an unserialized allocation can collide, but a `cckit start` that refuses to run
|
|
69
128
|
# cannot be worked around. Degrade, don't block.
|
|
70
129
|
#
|
|
71
|
-
# A lock
|
|
130
|
+
# A lock older than a minute is treated as abandoned and broken, so a process killed
|
|
72
131
|
# mid-allocation cannot wedge every future start. The age floor is well above _WT_LOCK_WAIT, so a
|
|
73
|
-
# slow-but-live holder is never stolen from.
|
|
132
|
+
# slow-but-live holder is never stolen from. `rm -rf` because a cckit from before #449 leaves a
|
|
133
|
+
# lock DIRECTORY at the same path; either kind blocks the other, so mixed versions still exclude.
|
|
74
134
|
_wt_lock() {
|
|
75
135
|
local d="$1" tries=0 max
|
|
76
136
|
max=$(( _WT_LOCK_WAIT * 10 ))
|
|
77
137
|
while [[ "$tries" -lt "$max" ]]; do
|
|
78
|
-
|
|
138
|
+
_wt_lock_try "$d" && return 0
|
|
79
139
|
sleep 0.1 2>/dev/null || sleep 1
|
|
80
140
|
tries=$(( tries + 1 ))
|
|
81
141
|
done
|
|
82
142
|
if [[ -n "$(find "$d" -maxdepth 0 -mmin +1 2>/dev/null)" ]]; then
|
|
83
143
|
rm -rf "$d" 2>/dev/null
|
|
84
|
-
|
|
144
|
+
_wt_lock_try "$d" && { echo "warn: broke an abandoned port-slot lock ($d)" >&2; return 0; }
|
|
85
145
|
fi
|
|
86
146
|
return 1
|
|
87
147
|
}
|
|
88
148
|
|
|
89
|
-
_wt_unlock() {
|
|
149
|
+
_wt_unlock() { rm -rf "$1" 2>/dev/null; }
|
|
90
150
|
|
|
91
151
|
# _wt_slot_alloc <ledger> <issue-num> <worktree> — the ledger transaction: reclaim dead rows,
|
|
92
152
|
# return the issue's existing allocation if it has one, else take the lowest free slot and append
|
|
@@ -116,7 +176,7 @@ _wt_slot_alloc() {
|
|
|
116
176
|
i=$(( i + 1 ))
|
|
117
177
|
done
|
|
118
178
|
echo "[#$num] warn: all 40 dev-port slots are held — falling back to a hashed port (collisions possible); run cckit gc" >&2
|
|
119
|
-
printf '%s' $(( num % 40 ))
|
|
179
|
+
printf '%s' $(( $(_wt_num_hash "$num") % 40 ))
|
|
120
180
|
}
|
|
121
181
|
|
|
122
182
|
# _wt_slot_for <root> <issue-num> <worktree> — echo this issue's slot (0-39), allocating on first
|
|
@@ -125,8 +185,10 @@ _wt_slot_alloc() {
|
|
|
125
185
|
# a warning) only when every slot is genuinely held.
|
|
126
186
|
_wt_slot_for() {
|
|
127
187
|
local root="$1" num="$2" wt="$3" f lock out locked=0
|
|
128
|
-
f="$(_wt_slots_file "$root")" || { printf '%s' $(( num % 40 )); return 0; }
|
|
129
|
-
|
|
188
|
+
f="$(_wt_slots_file "$root")" || { printf '%s' $(( $(_wt_num_hash "$num") % 40 )); return 0; }
|
|
189
|
+
# `>>`, not `>`: this line runs BEFORE the lock, so a truncating create could empty a ledger that
|
|
190
|
+
# another process created and wrote to between the test and the redirection.
|
|
191
|
+
[[ -f "$f" ]] || : >> "$f" 2>/dev/null || { printf '%s' $(( $(_wt_num_hash "$num") % 40 )); return 0; }
|
|
130
192
|
|
|
131
193
|
lock="$f.lock"
|
|
132
194
|
if _wt_lock "$lock"; then locked=1; else
|
|
@@ -137,6 +199,22 @@ _wt_slot_for() {
|
|
|
137
199
|
printf '%s' "$out"
|
|
138
200
|
}
|
|
139
201
|
|
|
202
|
+
# wt_port_slot <root> <issue-num> <worktree> — the PUBLIC reader of the slot ledger: echo the slot
|
|
203
|
+
# (0-39) this issue holds, allocating one on first call. Same row `cckit start` uses, so a caller
|
|
204
|
+
# that launches something for an issue's worktree (the QA lane, qa-lane.sh) lands on the port block
|
|
205
|
+
# that worktree already owns instead of deriving a second one.
|
|
206
|
+
wt_port_slot() { _wt_slot_for "$1" "$2" "$3"; }
|
|
207
|
+
|
|
208
|
+
# wt_port_stride <config-file> — the distance between one slot's port block and the next:
|
|
209
|
+
# `worktree.devPortStride`, default 10. One reader, so wt_assign_ports and the QA lane cannot
|
|
210
|
+
# disagree about where the next block starts.
|
|
211
|
+
wt_port_stride() {
|
|
212
|
+
local stride=""
|
|
213
|
+
stride="$(jq -r '.worktree.devPortStride // empty' "${1:-}" 2>/dev/null)"
|
|
214
|
+
[[ "$stride" =~ ^[0-9]+$ && "$stride" -gt 0 ]] || stride=10
|
|
215
|
+
printf '%s' "$stride"
|
|
216
|
+
}
|
|
217
|
+
|
|
140
218
|
wt_assign_ports() {
|
|
141
219
|
# `apppath`, not `path`: under zsh `path` is tied to PATH (special array); a bare `path` local
|
|
142
220
|
# would clobber the command search path on assignment. A namespaced name is inert.
|
|
@@ -159,8 +237,7 @@ wt_assign_ports() {
|
|
|
159
237
|
# different worktrees. Real example (bases 3001/3003/3004, n=3): worktree offset k+1's admin port
|
|
160
238
|
# (3004+3k) IS worktree offset k's api port. Configurable as `worktree.devPortStride`; the default
|
|
161
239
|
# leaves room for up to 10 services per project.
|
|
162
|
-
stride="$(
|
|
163
|
-
[[ "$stride" =~ ^[0-9]+$ && "$stride" -gt 0 ]] || stride=10
|
|
240
|
+
stride="$(wt_port_stride "$cfg")"
|
|
164
241
|
|
|
165
242
|
# The invariant that keeps blocks disjoint: every base must sit inside ONE stride-wide window.
|
|
166
243
|
# Warn rather than fail — the ports still work, they just stop being collision-proof, and a
|
|
@@ -171,7 +248,7 @@ wt_assign_ports() {
|
|
|
171
248
|
fi
|
|
172
249
|
|
|
173
250
|
offset="$(_wt_slot_for "$root" "$num" "$wt")"
|
|
174
|
-
[[ "$offset" =~ ^[0-9]+$ ]] || offset=$(( num % 40 ))
|
|
251
|
+
[[ "$offset" =~ ^[0-9]+$ ]] || offset=$(( $(_wt_num_hash "$num") % 40 ))
|
|
175
252
|
i=0
|
|
176
253
|
while [[ "$i" -lt "$n" ]]; do
|
|
177
254
|
apppath="$(jq -r ".[$i].path // empty" <<<"$ports")"
|
|
@@ -207,7 +284,7 @@ _wt_json_has() {
|
|
|
207
284
|
if command -v jq >/dev/null 2>&1; then
|
|
208
285
|
jq -e "$filter" "$file" >/dev/null 2>&1
|
|
209
286
|
else
|
|
210
|
-
tr -d ' \n\t' < "$file" 2>/dev/null
|
|
287
|
+
grep -qE "$re" <<<"$(tr -d ' \n\t' < "$file" 2>/dev/null)"
|
|
211
288
|
fi
|
|
212
289
|
}
|
|
213
290
|
|
|
@@ -414,7 +491,7 @@ wt_bootstrap() {
|
|
|
414
491
|
# • no LIVE session owns it (kit-sessions registry: no live pid sitting in that dir)
|
|
415
492
|
|
|
416
493
|
# _wt_mtime <path> — file mtime as epoch seconds (BSD stat, then GNU stat). Picks the oldest tree.
|
|
417
|
-
_wt_mtime() { stat -
|
|
494
|
+
_wt_mtime() { stat -c %Y "$1" 2>/dev/null || stat -f %m "$1" 2>/dev/null; }
|
|
418
495
|
|
|
419
496
|
# _wt_list <root> — emit one "<path>\t<branch-or-->\t<locked:0|1>" line per worktree (porcelain).
|
|
420
497
|
_wt_list() {
|
|
@@ -448,7 +525,8 @@ _wt_is_clean() {
|
|
|
448
525
|
}
|
|
449
526
|
|
|
450
527
|
# _wt_session_owns <root> <path> — true when a LIVE Claude session sits in <path> (or a subdir),
|
|
451
|
-
# per the kit-sessions registry (.git/kit-sessions/*.json
|
|
528
|
+
# per the kit-sessions registry (.git/kit-sessions/*.json — wt_start writes one claim per issue
|
|
529
|
+
# through session-registry.sh, with `cwd` set to the worktree). A dead
|
|
452
530
|
# pid is not an owner. No registry → no known live owner (returns false).
|
|
453
531
|
_wt_session_owns() {
|
|
454
532
|
local root="$1" wt_path="$2" common reg f opid ocwd
|
|
@@ -491,7 +569,7 @@ _wt_pool_find() {
|
|
|
491
569
|
# mutates). Shows branch / merged-into-develop? / clean? / live-session? / overall reusable?.
|
|
492
570
|
wt_pool_status() {
|
|
493
571
|
local root wtdir wt_path branch locked merged clean owned reusable any=0
|
|
494
|
-
root="$(git worktree list --porcelain | awk '/^worktree /{print $2;
|
|
572
|
+
root="$(git worktree list --porcelain | awk '/^worktree / && !hit {print $2; hit=1}')"
|
|
495
573
|
[[ -n "$root" ]] || { echo "wt_pool_status: not in a git repo" >&2; return 1; }
|
|
496
574
|
wtdir="$root/.claude/worktrees/"
|
|
497
575
|
git -C "$root" fetch origin "${KIT_BASE_BRANCH:-main}" --quiet 2>/dev/null || true
|
|
@@ -513,20 +591,56 @@ wt_pool_status() {
|
|
|
513
591
|
[[ "$any" == "1" ]] || echo "(no pooled worktrees under $wtdir)"
|
|
514
592
|
}
|
|
515
593
|
|
|
594
|
+
# _wt_claim_desc <tsv-row> — one human line for a claim row from sreg_issue_claim.
|
|
595
|
+
_wt_claim_desc() {
|
|
596
|
+
local c_issue c_branch c_wt c_pid c_host c_started
|
|
597
|
+
IFS=$'\t' read -r c_issue c_branch c_wt c_pid c_host c_started <<EOF
|
|
598
|
+
$1
|
|
599
|
+
EOF
|
|
600
|
+
printf 'pid %s on %s, worktree %s' "$c_pid" "$c_host" "$c_wt"
|
|
601
|
+
}
|
|
602
|
+
|
|
516
603
|
wt_start() {
|
|
517
|
-
local num="
|
|
604
|
+
local num="" slug_override="" root meta title kind slug branch wt reused cand
|
|
605
|
+
local force="${KIT_FORCE:-0}" _arg _claim _claimed="" _crc
|
|
606
|
+
for _arg in "$@"; do
|
|
607
|
+
case "$_arg" in
|
|
608
|
+
--force) force=1 ;;
|
|
609
|
+
-*) echo "wt_start: unknown flag '$_arg' (usage: start [--force] <issue> [slug])" >&2; return 1 ;;
|
|
610
|
+
*) if [[ -z "$num" ]]; then num="$_arg"; elif [[ -z "$slug_override" ]]; then slug_override="$_arg"; fi ;;
|
|
611
|
+
esac
|
|
612
|
+
done
|
|
518
613
|
[[ -n "$num" ]] || { echo "wt_start: issue number required" >&2; return 1; }
|
|
519
614
|
|
|
520
|
-
root="$(git worktree list --porcelain | awk '/^worktree /{print $2;
|
|
615
|
+
root="$(git worktree list --porcelain | awk '/^worktree / && !hit {print $2; hit=1}')"
|
|
521
616
|
[[ -n "$root" ]] || { echo "wt_start: not in a git repo" >&2; return 1; }
|
|
522
617
|
|
|
523
|
-
#
|
|
524
|
-
#
|
|
618
|
+
# Claim check (#384) — BEFORE the issue read, the fetch and `git worktree add`, so a refusal
|
|
619
|
+
# makes no network call, no branch and no worktree. A claim this session already holds (same
|
|
620
|
+
# session pid, or the caller stands inside the claimed worktree) is not a collision: re-running
|
|
621
|
+
# start stays the no-op it always was.
|
|
622
|
+
if command -v sreg_issue_claim >/dev/null 2>&1 && _claim="$(sreg_issue_claim "$root" "$num")" \
|
|
623
|
+
&& ! sreg_claim_mine "$root" "$num"; then
|
|
624
|
+
if [[ "$force" != "1" ]]; then
|
|
625
|
+
echo "[#$num] refused: a live session already claims this issue — $(_wt_claim_desc "$_claim")" >&2
|
|
626
|
+
echo "[#$num] see 'cckit claims'; 'cckit start --force $num' (or KIT_FORCE=1) starts anyway and takes the claim." >&2
|
|
627
|
+
return 1
|
|
628
|
+
fi
|
|
629
|
+
echo "[#$num] ⚠ --force: taking over the claim of a live session — $(_wt_claim_desc "$_claim")" >&2
|
|
630
|
+
fi
|
|
631
|
+
|
|
632
|
+
# The board helpers load lazily, further down: Status is otherwise set server-side by built-in
|
|
633
|
+
# automations (Item closed→Done, PR merged→Done), and In Progress is the one write wt_start owns.
|
|
525
634
|
|
|
635
|
+
if cckit_gh_rest; then
|
|
636
|
+
meta="$(gh_rest_issue_json "$WT_START_REPO" "$num" 2>/dev/null)" || { echo "[#$num] issue not found" >&2; return 1; }
|
|
637
|
+
else
|
|
526
638
|
meta="$(gh issue view "$num" --repo "$WT_START_REPO" --json title,labels 2>/dev/null)" \
|
|
527
639
|
|| { echo "[#$num] issue not found" >&2; return 1; }
|
|
640
|
+
fi
|
|
528
641
|
title="$(echo "$meta" | jq -r '.title')"
|
|
529
642
|
kind="$(echo "$meta" | jq -r '([.labels[].name | select(startswith("kind:"))][0] // "kind:task") | sub("^kind:";"")')"
|
|
643
|
+
kind="$(_wt_kind_prefix "$kind")"
|
|
530
644
|
if [[ -n "$slug_override" ]]; then
|
|
531
645
|
slug="$slug_override"
|
|
532
646
|
else
|
|
@@ -539,8 +653,26 @@ wt_start() {
|
|
|
539
653
|
branch="$kind/$num-$slug"
|
|
540
654
|
wt="$root/.claude/worktrees/${kind}+${num}-${slug}"
|
|
541
655
|
|
|
656
|
+
# Take the claim now that the worktree path is known, still before the fetch. rc 3 = another
|
|
657
|
+
# session claimed the issue between the check above and here. An unwritable registry only warns:
|
|
658
|
+
# the registry is a guard, not a precondition for working.
|
|
659
|
+
if command -v sreg_claim >/dev/null 2>&1; then
|
|
660
|
+
# _claimed marks a claim THIS call writes (none before, or one taken over by force), so a
|
|
661
|
+
# failed `worktree add` below releases only that — never a claim the session already held.
|
|
662
|
+
sreg_claim_mine "$root" "$num" || _claimed="1"
|
|
663
|
+
# `&& … ||` so a caller running under `set -e` (bin/cckit) reaches the refusal message.
|
|
664
|
+
sreg_claim "$root" "$num" "$branch" "$wt" "$force" && _crc=0 || _crc=$?
|
|
665
|
+
if [[ "$_crc" -eq 3 ]]; then
|
|
666
|
+
echo "[#$num] refused: another session claimed this issue just now — see 'cckit claims'." >&2
|
|
667
|
+
return 1
|
|
668
|
+
elif [[ "$_crc" -ne 0 ]]; then
|
|
669
|
+
_claimed=""
|
|
670
|
+
echo "[#$num] ⚠ could not record the session claim; continuing without one." >&2
|
|
671
|
+
fi
|
|
672
|
+
fi
|
|
673
|
+
|
|
542
674
|
git -C "$root" fetch origin "${KIT_BASE_BRANCH:-main}" --quiet
|
|
543
|
-
if
|
|
675
|
+
if grep -q "/${kind}+${num}-${slug}$" <<<"$(git -C "$root" worktree list --porcelain)"; then
|
|
544
676
|
echo "[#$num] reusing worktree $wt" >&2
|
|
545
677
|
else
|
|
546
678
|
reused=""
|
|
@@ -562,7 +694,8 @@ wt_start() {
|
|
|
562
694
|
fi
|
|
563
695
|
if [[ -z "$reused" ]]; then
|
|
564
696
|
git -C "$root" worktree add -B "$branch" "$wt" origin/${KIT_BASE_BRANCH:-main} >/dev/null 2>&1 \
|
|
565
|
-
|| {
|
|
697
|
+
|| { if [[ -n "$_claimed" ]]; then sreg_release "$root" "$num" 2>/dev/null || true; fi
|
|
698
|
+
echo "[#$num] worktree add failed (branch $branch may exist elsewhere)" >&2; return 1; }
|
|
566
699
|
echo "[#$num] created worktree $wt (branch $branch)" >&2
|
|
567
700
|
fi
|
|
568
701
|
fi
|
|
@@ -578,14 +711,18 @@ wt_start() {
|
|
|
578
711
|
# transitions server-side (Item added→Todo, PR linked→In Review, closed/merged→Done) — but GitHub
|
|
579
712
|
# has no "branch started" trigger, so the kit owns In Progress. Cheap now: an O(1) issue.projectItems
|
|
580
713
|
# lookup on the org board, not a full-board scan. Best-effort — a board hiccup never fails the start.
|
|
581
|
-
if
|
|
714
|
+
if cckit_gh_rest; then
|
|
715
|
+
command -v cckit_board_skipped >/dev/null 2>&1 && cckit_board_skipped
|
|
716
|
+
elif source "$root/scripts/lib/gh-project.sh" 2>/dev/null; then
|
|
582
717
|
[[ -n "${STATUS_FIELD_ID:-}" ]] || load_project_ids >/dev/null 2>&1 || true
|
|
583
|
-
#
|
|
584
|
-
#
|
|
718
|
+
# Board precheck (#124, #384): an issue ALREADY In Progress or In Review may belong to someone
|
|
719
|
+
# the local claims registry cannot see (a teammate's machine). Warn only — wt_start writes In
|
|
720
|
+
# Progress itself and nothing resets it when a session dies, so refusing on board Status would
|
|
721
|
+
# lock out every restart after a crash. The refusal is the live claim, checked at the top.
|
|
585
722
|
if command -v project_issue_status >/dev/null 2>&1; then
|
|
586
723
|
local _prev_status; _prev_status="$(project_issue_status "$num" 2>/dev/null || true)"
|
|
587
|
-
[[ "$_prev_status" == "In Progress" ]] \
|
|
588
|
-
&& echo "[#$num] ⚠ already
|
|
724
|
+
[[ "$_prev_status" == "In Progress" || "$_prev_status" == "In Review" ]] \
|
|
725
|
+
&& echo "[#$num] ⚠ already $_prev_status on the board — another session may own this issue; continuing." >&2
|
|
589
726
|
fi
|
|
590
727
|
item="$(project_find_item_by_issue "$num" 2>/dev/null)"
|
|
591
728
|
if [[ -z "$item" ]]; then
|
|
@@ -83,6 +83,22 @@ run_zsh "worktree-start.sh :: wt_assign_ports" \
|
|
|
83
83
|
run_zsh "kit-events.sh :: emit_event" \
|
|
84
84
|
"cd '$ROOT'; source scripts/lib/kit-events.sh; emit_event test op '{}' >/dev/null 2>&1"
|
|
85
85
|
|
|
86
|
+
# qa-lane.sh (#295) — five sibling libs resolved from one `${BASH_SOURCE[0]:-$0}` dir, and two
|
|
87
|
+
# `while read` loops fed by heredocs. BEHAVIOURAL: a probe table that collapsed to one row, or lost
|
|
88
|
+
# its port, would still return 0, so the case compares the rows it builds.
|
|
89
|
+
qa_tmp="$(mktemp -d)"
|
|
90
|
+
printf '%s' '{"qa":{"readiness":[{"env":"WEB_PORT","path":"/"},{"env":"API_PORT","path":"health"}]}}' > "$qa_tmp/cfg.json"
|
|
91
|
+
printf 'WEB_PORT=3010\nAPI_PORT=4010\n' > "$qa_tmp/ports"
|
|
92
|
+
run_zsh "qa-lane.sh :: siblings load and one probe row per service" \
|
|
93
|
+
"cd '$ROOT'; unset -f kit_state_dir wt_port_slot emit_event wt_issue_number 2>/dev/null; source scripts/lib/qa-lane.sh; command -v wt_port_slot >/dev/null 2>&1 && command -v kit_state_dir >/dev/null 2>&1 && command -v emit_event >/dev/null 2>&1 && [ \"\$(qa_probe_urls '$qa_tmp/cfg.json' '$qa_tmp/ports' | cut -f2 | tr '\n' ' ')\" = 'http://localhost:3010/ http://localhost:4010/health ' ]"
|
|
94
|
+
# The route parser (#297) is a sed -E + grep -E pipeline with the pattern held in a variable. It
|
|
95
|
+
# must read a declared line, and skip a template placeholder, the same way under zsh.
|
|
96
|
+
printf '%s\n' 'intro' '- **QA route:** `/orders/42?tab=items`' > "$qa_tmp/body.md"
|
|
97
|
+
printf '%s\n' 'QA route: <path>' > "$qa_tmp/blank.md"
|
|
98
|
+
run_zsh "qa-lane.sh :: a declared QA route line parses under zsh" \
|
|
99
|
+
"cd '$ROOT'; source scripts/lib/qa-lane.sh; [ \"\$(qa_route_declared < '$qa_tmp/body.md')\" = '/orders/42?tab=items' ] && ! qa_route_declared < '$qa_tmp/blank.md' >/dev/null && qa_route_valid /a/b && ! qa_route_valid 'a b'"
|
|
100
|
+
rm -rf "$qa_tmp"
|
|
101
|
+
|
|
86
102
|
# effort.sh :: effort_snapshot_subs — the work-record collapse (#339). `for sha in $shas` relied on
|
|
87
103
|
# the shell word-splitting an unquoted expansion. bash splits on IFS; zsh does not, so the loop ran
|
|
88
104
|
# ONCE with every SHA as a single argument, `git rev-parse --short` failed, and the run still printed
|
|
@@ -135,11 +151,11 @@ rm -rf "$snap_tmp"
|
|
|
135
151
|
# Match a `local` declaration listing a bare `path` word, or a bare `g()` function definition. The
|
|
136
152
|
# fixed files use namespaced names (wtpath / apppath / logpath / _kit_cfg_get); a plain word here
|
|
137
153
|
# would be the regression. Comments are stripped first so the explanatory notes don't trip it.
|
|
138
|
-
for f in kit-config.sh kit-gc.sh worktree-start.sh kit-events.sh; do
|
|
154
|
+
for f in kit-config.sh kit-gc.sh worktree-start.sh kit-events.sh session-registry.sh; do
|
|
139
155
|
code="$(sed 's/#.*$//' "$LIB/$f")"
|
|
140
|
-
if
|
|
156
|
+
if grep -qE '\blocal\b[^=]*\bpath\b' <<<"$code"; then
|
|
141
157
|
bad "$f still declares a bare \`local … path …\`"
|
|
142
|
-
elif
|
|
158
|
+
elif grep -qE '(^|[^_[:alnum:]])g\(\)' <<<"$code"; then
|
|
143
159
|
bad "$f still defines a bare \`g()\`"
|
|
144
160
|
else
|
|
145
161
|
ok "$f — no bare reserved-name local (static guard)"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# marketing-walkthrough-test.sh — the Marketing docs' sequence, run through bin/cckit (#487).
|
|
4
|
+
#
|
|
5
|
+
# cckit init --profile marketing --yes -> cckit task new -> cckit task start
|
|
6
|
+
# -> cckit task finish --all -> cckit status
|
|
7
|
+
#
|
|
8
|
+
# in a project that already has a commit and an `origin`. A reader who followed the docs pages hit
|
|
9
|
+
# eight defects on this path; each assertion below is one of them:
|
|
10
|
+
# 1. the base branch written to the config is one the repository has, and a run with no
|
|
11
|
+
# confirmation says what it left undone (through bin/cckit, which used to hand init cckit's
|
|
12
|
+
# own config and with it cckit's own base branch);
|
|
13
|
+
# 2. the cckit files are committed on the base branch and pushed, so the task's folder has them;
|
|
14
|
+
# 3. `cckit status` shows the light task, in the report and in --llm;
|
|
15
|
+
# 6. the next steps of a light-task project name no label or milestone script;
|
|
16
|
+
# 7. `.cckit/` and `.claude/worktrees/` are gitignored;
|
|
17
|
+
# 8. no shipped command, skill or template holds an absolute home-directory path.
|
|
18
|
+
# (4 and 5 — the instruction file and the plain-language rule — are in init-content-test.sh.)
|
|
19
|
+
#
|
|
20
|
+
# Hermetic: HOME is a temp dir, `gh` is a stub that logs every call, "GitHub" is a bare repository
|
|
21
|
+
# in the temp dir. No network, no real repository.
|
|
22
|
+
# Run: bash scripts/marketing-walkthrough-test.sh
|
|
23
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
24
|
+
set -u
|
|
25
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
26
|
+
# shellcheck source=/dev/null
|
|
27
|
+
. "$ROOT/scripts/lib/test-env.sh" && test_env_seal
|
|
28
|
+
CCKIT="$ROOT/bin/cckit"
|
|
29
|
+
fail=0
|
|
30
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
31
|
+
has() { if grep -qF -- "$3" <<<"$2"; then echo "ok: $1"; else echo "FAIL: $1 -> '$3' not in output:"; printf '%s\n' "$2" | tail -20; fail=1; fi; }
|
|
32
|
+
hasnt() { if grep -qF -- "$3" <<<"$2"; then echo "FAIL: $1 -> '$3' found in output"; fail=1; else echo "ok: $1"; fi; }
|
|
33
|
+
|
|
34
|
+
for dep in jq git perl; do
|
|
35
|
+
command -v "$dep" >/dev/null 2>&1 || { echo "marketing-walkthrough-test: $dep absent — skipping (dependency-light gate)"; exit 0; }
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
39
|
+
tmp="$(cd "$tmp" && pwd -P)"
|
|
40
|
+
export HOME="$tmp/home"; mkdir -p "$HOME"
|
|
41
|
+
printf '[user]\n\tname = Test Person\n\temail = test@example.com\n' > "$HOME/.gitconfig"
|
|
42
|
+
export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
|
|
43
|
+
|
|
44
|
+
mkdir -p "$tmp/stubs"
|
|
45
|
+
cat > "$tmp/stubs/gh" <<'STUB'
|
|
46
|
+
#!/usr/bin/env bash
|
|
47
|
+
# Logs every call. Reads answer "nothing there yet"; writes succeed.
|
|
48
|
+
printf '%s\n' "$*" >> "$GH_LOG"
|
|
49
|
+
case "${1:-} ${2:-}" in
|
|
50
|
+
"auth status") exit 0 ;;
|
|
51
|
+
"config get") echo https; exit 0 ;;
|
|
52
|
+
"api user") echo tester; exit 0 ;;
|
|
53
|
+
"repo view") exit 1 ;;
|
|
54
|
+
"label list") exit 0 ;;
|
|
55
|
+
"label create") exit 0 ;;
|
|
56
|
+
"pr list") exit 0 ;;
|
|
57
|
+
"pr create") echo "https://github.com/tester/site/pull/1"; exit 0 ;;
|
|
58
|
+
"issue list") echo '[]'; exit 0 ;;
|
|
59
|
+
"api graphql") exit 1 ;;
|
|
60
|
+
esac
|
|
61
|
+
if [ "${1:-}" = "api" ]; then
|
|
62
|
+
case " $* " in
|
|
63
|
+
*"/protection "*) case " $* " in *" -X PUT "*) cat >/dev/null; echo '{}'; exit 0 ;; esac
|
|
64
|
+
echo "gh: Branch not protected (HTTP 404)" >&2; exit 1 ;;
|
|
65
|
+
*"/milestones"*) exit 0 ;;
|
|
66
|
+
*" -X PATCH "*) exit 0 ;;
|
|
67
|
+
*) echo false; exit 0 ;;
|
|
68
|
+
esac
|
|
69
|
+
fi
|
|
70
|
+
exit 1
|
|
71
|
+
STUB
|
|
72
|
+
chmod +x "$tmp/stubs/gh"
|
|
73
|
+
export PATH="$tmp/stubs:$PATH"
|
|
74
|
+
export KIT_INIT_PREFLIGHT=0 KIT_INIT_TTY=0 KIT_ASCII=1 NO_COLOR=1 KIT_WT_INSTALL=0
|
|
75
|
+
unset KIT_CONFIG KIT_BASE_BRANCH 2>/dev/null || true
|
|
76
|
+
|
|
77
|
+
# new_project <dir> — a project with one commit on `main` and an empty bare `origin`.
|
|
78
|
+
new_project() {
|
|
79
|
+
mkdir -p "$1"; git init -q --bare "$1.git"
|
|
80
|
+
git -C "$1" init -q; git -C "$1" symbolic-ref HEAD refs/heads/main
|
|
81
|
+
echo "# Site" > "$1/README.md"; git -C "$1" add -A; git -C "$1" commit -q -m first
|
|
82
|
+
git -C "$1" remote add origin "$1.git"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# ── a run with no terminal and no --yes ─────────────────────────────────────────────────────────
|
|
86
|
+
q="$tmp/quiet"; new_project "$q"
|
|
87
|
+
out="$(cd "$q" && "$CCKIT" init --profile marketing --owner-login tester --repo tester/quiet 2>&1 < /dev/null)"
|
|
88
|
+
t "no --yes: rc 0" "$?" "0"
|
|
89
|
+
t "no --yes: the base branch is the repository's, not cckit's own" "$(jq -r .github.baseBranch "$q/.claude/kit.config.json")" "main"
|
|
90
|
+
has "no --yes: says the setup did not run" "$out" "Git and GitHub setup: not run"
|
|
91
|
+
has "no --yes: says the cckit files are not committed, with the command" "$out" "To commit them on 'main' and push: cckit init --yes"
|
|
92
|
+
hasnt "no --yes: no label or milestone script in the next steps" "$out" "setup-labels.sh"
|
|
93
|
+
t "no --yes: .cckit/ is gitignored" "$(grep -cxF '.cckit/' "$q/.gitignore")" "1"
|
|
94
|
+
t "no --yes: .claude/worktrees/ is gitignored" "$(grep -cxF '.claude/worktrees/' "$q/.gitignore")" "1"
|
|
95
|
+
t "no --yes: the labels come from this project's config" \
|
|
96
|
+
"$(cd "$q" && KIT_LABELS_LIST=1 bash "$ROOT/scripts/setup-labels.sh" 2>/dev/null | grep -c '^kind:post ')" "1"
|
|
97
|
+
# The second run a reader makes: the same command with --yes commits the files that are there.
|
|
98
|
+
out="$(cd "$q" && "$CCKIT" init --yes 2>&1 < /dev/null)"; t "then --yes: rc 0" "$?" "0"
|
|
99
|
+
has "then --yes: the cckit files are committed" "$out" "[done ] cckit files commit"
|
|
100
|
+
t "then --yes: the working tree is clean" "$(git -C "$q" status --porcelain)" ""
|
|
101
|
+
t "then --yes: origin has them" "$(git -C "$q.git" ls-tree -r --name-only main -- CLAUDE.md .claude/kit.config.json | tr '\n' ' ')" ".claude/kit.config.json CLAUDE.md "
|
|
102
|
+
|
|
103
|
+
# ── the walkthrough ─────────────────────────────────────────────────────────────────────────────
|
|
104
|
+
p="$tmp/site"; new_project "$p"; cd "$p" || exit 1
|
|
105
|
+
out="$("$CCKIT" init --profile marketing --yes --owner-login tester --repo tester/site 2>&1 < /dev/null)"
|
|
106
|
+
t "init --yes: rc 0" "$?" "0"
|
|
107
|
+
has "init: the plan lists the cckit files commit before anything runs" "$out" "Save the cckit files as one commit on 'main'"
|
|
108
|
+
has "init: the commit is made" "$out" "[done ] cckit files commit"
|
|
109
|
+
has "init: nothing failed" "$out" "0 failed"
|
|
110
|
+
t "init: the working tree is clean" "$(git status --porcelain)" ""
|
|
111
|
+
t "init: the commit is on origin's base branch" "$(git -C "$p.git" log -1 --format=%s main)" "chore: add the cckit project files"
|
|
112
|
+
t "init: no ignored file was committed" "$(git ls-files .claude/settings.local.json .claude/kit.manifest.json .cckit | wc -l | tr -d ' ')" "0"
|
|
113
|
+
h0="$(git rev-parse HEAD)"
|
|
114
|
+
out="$("$CCKIT" init --yes 2>&1 < /dev/null)"
|
|
115
|
+
t "init again: rc 0 and no new commit" "$?:$(git rev-parse HEAD)" "0:$h0"
|
|
116
|
+
has "init again: the commit step is skipped" "$out" "[skipped] cckit files commit — already committed"
|
|
117
|
+
|
|
118
|
+
out="$("$CCKIT" task new --kind post "Spring newsletter" 2>&1)"; t "task new: rc 0" "$?" "0"
|
|
119
|
+
id="$(printf '%s\n' "$out" | sed -n 's/^✓ task \([a-z0-9]*\) .*/\1/p')"
|
|
120
|
+
has "task new: prints the id" "$out" "✓ task $id · Spring newsletter"
|
|
121
|
+
|
|
122
|
+
out="$("$CCKIT" task start "$id" 2>&1)"; t "task start: rc 0" "$?" "0"
|
|
123
|
+
wt="$(printf '%s\n' "$out" | tail -1 | cut -d'|' -f1)"
|
|
124
|
+
t "task start: the task's folder has CLAUDE.md" "$([ -f "$wt/CLAUDE.md" ] && echo yes || echo no)" "yes"
|
|
125
|
+
t "task start: the task's folder has the cckit config" "$([ -f "$wt/.claude/kit.config.json" ] && echo yes || echo no)" "yes"
|
|
126
|
+
t "task start: the task's folder has the rules" "$([ -f "$wt/.claude/rules/plain-language.md" ] && echo yes || echo no)" "yes"
|
|
127
|
+
t "task start: the worktree does not show as untracked" "$(git status --porcelain)" ""
|
|
128
|
+
|
|
129
|
+
echo "Dear reader" > "$wt/newsletter.md"
|
|
130
|
+
out="$(cd "$wt" && "$CCKIT" task finish "$id" "First draft of the spring newsletter" --all 2>&1)"; t "task finish: rc 0" "$?" "0"
|
|
131
|
+
has "task finish: prints the review link" "$out" "✓ https://github.com/tester/site/pull/1"
|
|
132
|
+
t "task finish: the new file is on the task's branch on origin" \
|
|
133
|
+
"$(git -C "$p.git" ls-tree -r --name-only "light/$id-spring-newsletter" -- newsletter.md)" "newsletter.md"
|
|
134
|
+
|
|
135
|
+
: > "$GH_LOG"
|
|
136
|
+
out="$("$CCKIT" status 2>&1)"; t "status: rc 0" "$?" "0"
|
|
137
|
+
has "status: has the light-task section" "$out" "## Light tasks"
|
|
138
|
+
has "status: counts the task as waiting for review" "$out" "review: 1 doing: 0 todo: 0 draft: 0"
|
|
139
|
+
has "status: lists the task" "$out" "| \`$id\` | **review** | Spring newsletter |"
|
|
140
|
+
js="$("$CCKIT" status --llm 2>/dev/null)"
|
|
141
|
+
t "status --llm: the task is in attention" "$(printf '%s' "$js" | jq -r '.light_tasks.attention[0] | .id + " " + .state')" "$id review"
|
|
142
|
+
t "status --llm: the count" "$(printf '%s' "$js" | jq -r '.light_tasks.counts.review')" "1"
|
|
143
|
+
t "status: no gh call names the task" "$(grep -c -e "$id" -e 'light/' "$GH_LOG" | tr -d ' ')" "0"
|
|
144
|
+
|
|
145
|
+
# ── 8. no absolute home-directory path in what cckit ships ──────────────────────────────────────
|
|
146
|
+
hits="$(grep -rlE '/(Users|home)/[a-z][a-z0-9_-]+/' "$ROOT/commands" "$ROOT/skills" "$ROOT/templates" 2>/dev/null | sed "s#^$ROOT/##" | tr '\n' ' ')"
|
|
147
|
+
t "no command, skill or template holds a home-directory path" "$hits" ""
|
|
148
|
+
has "kit-update reads the plugin version through the documented variable" \
|
|
149
|
+
"$(cat "$ROOT/commands/kit-update.md")" '"${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json"'
|
|
150
|
+
|
|
151
|
+
[ "$fail" -eq 0 ] && echo "marketing-walkthrough-test: PASS" || echo "marketing-walkthrough-test: FAIL"
|
|
152
|
+
exit "$fail"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# night-grant-test.sh — the night grant parser, picker and allowlist preflight, offline.
|
|
3
|
+
set -u
|
|
4
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
5
|
+
command -v jq >/dev/null 2>&1 || { echo "night-grant-test: jq required — skipping"; exit 0; }
|
|
6
|
+
bash "$ROOT/scripts/night-grant.sh" --selftest || exit 1
|
|
7
|
+
|
|
8
|
+
# ── the docs contract: night mode is launchable and documented outside this checkout ──────────
|
|
9
|
+
fails=0
|
|
10
|
+
t() { # <label> <want> <got>
|
|
11
|
+
if [ "$2" = "$3" ]; then printf ' ok %s\n' "$1"
|
|
12
|
+
else printf ' FAIL %s\n want: %s\n got: %s\n' "$1" "$2" "$3"; fails=$((fails + 1)); fi
|
|
13
|
+
}
|
|
14
|
+
SKILL="$ROOT/skills/kit-autopilot/SKILL.md"
|
|
15
|
+
# A consuming project has no scripts/ checkout: every night script path in the skill must start at
|
|
16
|
+
# the plugin root, as every other plugin-direct skill's paths do.
|
|
17
|
+
# shellcheck disable=SC2016
|
|
18
|
+
bare="$(grep -oE '.{0,22}scripts/night-(grant\.sh|run\.mjs)' "$SKILL" \
|
|
19
|
+
| grep -vcF '${CLAUDE_PLUGIN_ROOT}/scripts/night-')"
|
|
20
|
+
t "skill: no night script path without the plugin root" 0 "$bare"
|
|
21
|
+
# shellcheck disable=SC2016
|
|
22
|
+
t "skill: it names the grant reader under the plugin root" 1 \
|
|
23
|
+
"$(grep -cF 'bash "${CLAUDE_PLUGIN_ROOT}/scripts/night-grant.sh" read' "$SKILL")"
|
|
24
|
+
t "skill: it documents the WIP-limit interaction" yes \
|
|
25
|
+
"$(grep -q 'effort.wipLimit' "$SKILL" && grep -q -- '--force' "$SKILL" && echo yes || echo no)"
|
|
26
|
+
t "skill: it does not demand an approval marker nothing writes" 0 \
|
|
27
|
+
"$(grep -ciE 'grill|## Assumed' "$SKILL")"
|
|
28
|
+
t "schema: night declares its five keys" '["floors","gate","grantors","neverWaivable","refuseLabels"]' \
|
|
29
|
+
"$(jq -c '.properties.night.properties | keys' "$ROOT/kit.config.schema.json" 2>/dev/null)"
|
|
30
|
+
for doc in README.md AGENTS.md docs-site/src/content/docs/config-and-permissions.mdx \
|
|
31
|
+
docs-site/src/content/docs/skills.mdx docs-site/src/content/docs/development/run-unattended.mdx; do
|
|
32
|
+
t "docs: $doc covers night mode" yes "$(grep -qi 'night mode' "$ROOT/$doc" && echo yes || echo no)"
|
|
33
|
+
done
|
|
34
|
+
t "docs: the config page documents who may grant" yes \
|
|
35
|
+
"$(grep -q 'night.grantors' "$ROOT/docs-site/src/content/docs/config-and-permissions.mdx" && echo yes || echo no)"
|
|
36
|
+
[ "$fails" -eq 0 ] || { printf 'night-grant docs contract FAILED (%s)\n' "$fails"; exit 1; }
|
|
37
|
+
printf 'night-grant docs contract OK\n'
|