@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
|
@@ -211,6 +211,111 @@ if [ -n "${CAP_TEST_INNER:-}" ]; then
|
|
|
211
211
|
rm -f "$rc1" "$rc2" "$rc3" "$rc4"
|
|
212
212
|
fi
|
|
213
213
|
|
|
214
|
+
# ── the QA gate (#300) ───────────────────────────────────────────────────────────────────────
|
|
215
|
+
# cap_classify <mergeable> <mss> <checks> <review> <qa> <qa-required>. Requirement OFF: no existing
|
|
216
|
+
# verdict moves, whatever the qa token says short of a recorded fail.
|
|
217
|
+
( KIT_CAPTAIN_REQUIRE_QA=; KIT_CAPTAIN_QA_LABELS=; KIT_CAPTAIN_REQUIRE_REVIEW=0; KIT_CAPTAIN_REQUIRE_CHECKS=0
|
|
218
|
+
eq "qa off: no verdict still CLEAN" "$(cap_classify MERGEABLE CLEAN PASS NONE NONE)" "CLEAN"
|
|
219
|
+
eq "qa off (explicit 0): still CLEAN" "$(cap_classify MERGEABLE CLEAN PASS NONE NONE 0)" "CLEAN"
|
|
220
|
+
eq "qa off: a pass is still CLEAN" "$(cap_classify MERGEABLE CLEAN PASS PASS PASS 0)" "CLEAN"
|
|
221
|
+
eq "qa off: failing checks unchanged" "$(cap_classify MERGEABLE CLEAN FAIL NONE NONE 0)" "CHECKS_FAILING"
|
|
222
|
+
eq "qa off: draft unchanged" "$(cap_classify MERGEABLE DRAFT PASS NONE NONE 0)" "DRAFT"
|
|
223
|
+
eq "qa off: conflict unchanged" "$(cap_classify CONFLICTING DIRTY PASS NONE NONE 0)" "CONFLICTING"
|
|
224
|
+
eq "qa off: blocked unchanged" "$(cap_classify UNKNOWN BLOCKED PASS NONE NONE 0)" "BLOCKED"
|
|
225
|
+
eq "qa off: review fail unchanged" "$(cap_classify MERGEABLE CLEAN PASS FAIL NONE 0)" "REVIEW_FAILING" ) || fail=1
|
|
226
|
+
# Requirement ON: a MERGEABLE/CLEAN PR with no qa receipt for its head is QA_MISSING -> verify.
|
|
227
|
+
eq "qa on: no verdict is QA_MISSING" "$(cap_classify MERGEABLE CLEAN PASS PASS NONE 1)" "QA_MISSING"
|
|
228
|
+
eq "qa on: unstable is QA_MISSING too" "$(cap_classify MERGEABLE UNSTABLE PASS PASS NONE 1)" "QA_MISSING"
|
|
229
|
+
eq "qa on: a pass merges" "$(cap_classify MERGEABLE CLEAN PASS PASS PASS 1)" "CLEAN"
|
|
230
|
+
eq "QA_MISSING -> verify" "$(cap_action QA_MISSING)" "verify"
|
|
231
|
+
eq "QA_FAILING -> fix" "$(cap_action QA_FAILING)" "fix"
|
|
232
|
+
# The flag argument is what decides; omitted, the env stands in for it.
|
|
233
|
+
( KIT_CAPTAIN_REQUIRE_QA=1
|
|
234
|
+
eq "qa on by env, 5-arg call" "$(cap_classify MERGEABLE CLEAN PASS PASS NONE)" "QA_MISSING"
|
|
235
|
+
eq "an explicit 0 beats the env" "$(cap_classify MERGEABLE CLEAN PASS PASS NONE 0)" "CLEAN" ) || fail=1
|
|
236
|
+
# A recorded fail is evidence: it blocks with the requirement off as well as on.
|
|
237
|
+
eq "qa fail blocks when not required" "$(cap_classify MERGEABLE CLEAN PASS PASS FAIL 0)" "QA_FAILING"
|
|
238
|
+
eq "qa fail blocks when required" "$(cap_classify MERGEABLE CLEAN PASS PASS FAIL 1)" "QA_FAILING"
|
|
239
|
+
# Only the would-be-CLEAN verdict changes; red CI, a conflict and a draft keep their own answers.
|
|
240
|
+
eq "qa on: failing checks outrank" "$(cap_classify MERGEABLE CLEAN FAIL PASS NONE 1)" "CHECKS_FAILING"
|
|
241
|
+
eq "qa on: pending checks outrank" "$(cap_classify MERGEABLE CLEAN PENDING PASS NONE 1)" "CHECKS_PENDING"
|
|
242
|
+
eq "qa on: a conflict outranks a qa fail" "$(cap_classify CONFLICTING DIRTY PASS PASS FAIL 1)" "CONFLICTING"
|
|
243
|
+
eq "qa on: a draft outranks" "$(cap_classify MERGEABLE DRAFT PASS PASS NONE 1)" "DRAFT"
|
|
244
|
+
# Order against the review gate. rs_needs_dispatch keys the reviewer on REVIEW_MISSING, so a PR
|
|
245
|
+
# that is both unreviewed and un-QA'd must read REVIEW_MISSING or its reviewer never runs.
|
|
246
|
+
( KIT_CAPTAIN_REQUIRE_REVIEW=1
|
|
247
|
+
eq "unreviewed + un-QA'd reads REVIEW_MISSING" "$(cap_classify MERGEABLE CLEAN PASS NONE NONE 1)" "REVIEW_MISSING"
|
|
248
|
+
eq "reviewed + un-QA'd reads QA_MISSING" "$(cap_classify MERGEABLE CLEAN PASS PASS NONE 1)" "QA_MISSING" ) || fail=1
|
|
249
|
+
( KIT_CAPTAIN_REQUIRE_CHECKS=1
|
|
250
|
+
eq "no checks + un-QA'd reads CHECKS_MISSING" "$(cap_classify MERGEABLE CLEAN NONE PASS NONE 1)" "CHECKS_MISSING" ) || fail=1
|
|
251
|
+
|
|
252
|
+
# cap_qa_summary: the qa receipt read against the PR's head. A pass recorded on an older head is
|
|
253
|
+
# NONE, which the classifier above turns into QA_MISSING.
|
|
254
|
+
if command -v jq >/dev/null 2>&1; then
|
|
255
|
+
eq "qa: pass on this head" "$(printf '{"gate":"pass","head_sha":"abc"}' | cap_qa_summary abc)" "PASS"
|
|
256
|
+
eq "qa: annotated fail on this head" "$(printf '{"gate":"fail — the save button is dead","head_sha":"abc"}' | cap_qa_summary abc)" "FAIL"
|
|
257
|
+
eq "qa: a pass on an older head" "$(printf '{"gate":"pass","head_sha":"abc"}' | cap_qa_summary def)" "NONE"
|
|
258
|
+
eq "qa: a fail on an older head" "$(printf '{"gate":"fail","head_sha":"abc"}' | cap_qa_summary def)" "NONE"
|
|
259
|
+
eq "qa: no receipt" "$(printf '' | cap_qa_summary abc)" "NONE"
|
|
260
|
+
# Unlike the review summary, no head to compare is NONE: an uncheckable verdict is not fresh.
|
|
261
|
+
eq "qa: no head to compare" "$(printf '{"gate":"pass","head_sha":"abc"}' | cap_qa_summary)" "NONE"
|
|
262
|
+
eq "an older-head pass still reads QA_MISSING" \
|
|
263
|
+
"$(cap_classify MERGEABLE CLEAN PASS PASS "$(printf '{"gate":"pass","head_sha":"abc"}' | cap_qa_summary def)" 1)" "QA_MISSING"
|
|
264
|
+
fi
|
|
265
|
+
|
|
266
|
+
# The same reading over a receipt written the way `cckit qa verdict` writes one (sr_record, stage
|
|
267
|
+
# qa, head_sha last), so the token is proved against the stored shape and not a hand-built object.
|
|
268
|
+
if command -v jq >/dev/null 2>&1 && command -v sr_record >/dev/null 2>&1; then
|
|
269
|
+
qst="$(mktemp -d)"
|
|
270
|
+
( KIT_STATE_DIR="$qst"; CCKIT_RECEIPT_REMOTE=0; export KIT_STATE_DIR CCKIT_RECEIPT_REMOTE
|
|
271
|
+
eq "stored qa: nothing recorded" "$(sr_latest 4242 qa 2>/dev/null | cap_qa_summary abc)" "NONE"
|
|
272
|
+
printf 'outcome: pr-open\nurl: -\ngate: pass\nblocker: none\nnext stage: none\n' \
|
|
273
|
+
| sr_record 4242 qa 1 "" "" "cckit qa verdict" "read-only" abc >/dev/null 2>&1
|
|
274
|
+
eq "stored qa: pass on its head" "$(sr_latest 4242 qa 2>/dev/null | cap_qa_summary abc)" "PASS"
|
|
275
|
+
eq "stored qa: stale after a push" "$(sr_latest 4242 qa 2>/dev/null | cap_qa_summary def)" "NONE"
|
|
276
|
+
printf 'outcome: blocked\nurl: -\ngate: fail — the save button is dead\nblocker: the save button is dead\nnext stage: build\n' \
|
|
277
|
+
| sr_record 4242 qa 2 "" "" "cckit qa verdict" "read-only" def >/dev/null 2>&1
|
|
278
|
+
eq "stored qa: a later fail wins" "$(sr_latest 4242 qa 2>/dev/null | cap_qa_summary def)" "FAIL"
|
|
279
|
+
exit "$fail" ) || fail=1
|
|
280
|
+
rm -rf "$qst"
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
# cap_qa_required: every PR, or only the PRs carrying a listed label.
|
|
284
|
+
( KIT_CAPTAIN_REQUIRE_QA=; KIT_CAPTAIN_QA_LABELS=
|
|
285
|
+
eq "qa required: off by default" "$(cap_qa_required "flow:ui kind:task")" "0" ) || fail=1
|
|
286
|
+
( KIT_CAPTAIN_REQUIRE_QA=1; KIT_CAPTAIN_QA_LABELS=
|
|
287
|
+
eq "qa required: on for every PR" "$(cap_qa_required "")" "1" ) || fail=1
|
|
288
|
+
( KIT_CAPTAIN_REQUIRE_QA=; KIT_CAPTAIN_QA_LABELS="flow:ui needs-qa"
|
|
289
|
+
eq "qa required: a listed label" "$(cap_qa_required "kind:task flow:ui")" "1"
|
|
290
|
+
eq "qa required: the second label" "$(cap_qa_required "needs-qa")" "1"
|
|
291
|
+
eq "qa required: no listed label" "$(cap_qa_required "kind:task flow:core")" "0"
|
|
292
|
+
eq "qa required: no partial match" "$(cap_qa_required "flow:ui-kit")" "0"
|
|
293
|
+
eq "qa required: no labels at all" "$(cap_qa_required "")" "0" ) || fail=1
|
|
294
|
+
|
|
295
|
+
# The config bridge: requireQa is true, false or a list of labels; env wins.
|
|
296
|
+
if command -v jq >/dev/null 2>&1; then
|
|
297
|
+
qabridge() {
|
|
298
|
+
( KIT_CONFIG="$1"; KIT_CAPTAIN_FLOORS=; KIT_CAPTAIN_EXTRA_GLOBS=; KIT_CAPTAIN_REQUIRE_CHECKS=
|
|
299
|
+
KIT_CAPTAIN_REQUIRE_REVIEW=; KIT_CAPTAIN_REQUIRE_QA="$2"; KIT_CAPTAIN_QA_LABELS="$3"
|
|
300
|
+
_cap_load_policy_config
|
|
301
|
+
printf '%s|%s|%s' "${KIT_CAPTAIN_REQUIRE_QA:-unset}" "${KIT_CAPTAIN_QA_LABELS:-none}" "$(cap_qa_required "flow:ui")" )
|
|
302
|
+
}
|
|
303
|
+
q1="$(mktemp)"; printf '{"captain":{"mergePolicy":{"requireQa":true}}}' > "$q1"
|
|
304
|
+
q2="$(mktemp)"; printf '{"captain":{"mergePolicy":{"requireQa":false}}}' > "$q2"
|
|
305
|
+
q3="$(mktemp)"; printf '{"captain":{"mergePolicy":{"requireQa":["flow:ui","needs-qa"]}}}' > "$q3"
|
|
306
|
+
q4="$(mktemp)"; printf '{"qa":{"command":"pnpm dev"}}' > "$q4"
|
|
307
|
+
eq "bridge: requireQa true" "$(qabridge "$q1" "" "")" "1|none|1"
|
|
308
|
+
eq "bridge: requireQa false" "$(qabridge "$q2" "" "")" "0|none|0"
|
|
309
|
+
eq "bridge: requireQa label list" "$(qabridge "$q3" "" "")" "unset|flow:ui needs-qa|1"
|
|
310
|
+
# Declaring a QA stack is not the opt-in: the gate stays off until requireQa says otherwise.
|
|
311
|
+
eq "bridge: qa.command alone is off" "$(qabridge "$q4" "" "")" "unset|none|0"
|
|
312
|
+
eq "bridge: env 0 beats config true" "$(qabridge "$q1" "0" "")" "0|none|0"
|
|
313
|
+
eq "bridge: env 0 beats a label list" "$(qabridge "$q3" "0" "")" "0|none|0"
|
|
314
|
+
eq "bridge: env 1 beats config false" "$(qabridge "$q2" "1" "")" "1|none|1"
|
|
315
|
+
eq "bridge: env labels beat config" "$(qabridge "$q1" "" "kind:bug")" "unset|kind:bug|0"
|
|
316
|
+
rm -f "$q1" "$q2" "$q3" "$q4"
|
|
317
|
+
fi
|
|
318
|
+
|
|
214
319
|
if [ "$fail" -eq 0 ]; then echo "PASS($CAP_TEST_INNER): captain gate policy"; fi
|
|
215
320
|
exit "$fail"
|
|
216
321
|
fi
|
package/scripts/lib/captain.sh
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Autopilot has two halves. `orchestrate`/`autopilot` LAUNCH the per-issue flows; the captain CLOSES
|
|
6
6
|
# them — it inspects each PR, decides (CLEAN / CONFLICTING / CHECKS_FAILING / CHECKS_PENDING /
|
|
7
|
-
# CHECKS_MISSING / DRAFT / BLOCKED), merges what is ready, and lets the freshly-merged issues unblock
|
|
7
|
+
# CHECKS_MISSING / REVIEW_* / QA_* / DRAFT / BLOCKED), merges what is ready, and lets the freshly-merged issues unblock
|
|
8
8
|
# the next wave. This is the half that used to be left to the driving agent; now it is a script the
|
|
9
9
|
# agent (or `cckit watch`) runs in a loop.
|
|
10
10
|
#
|
|
@@ -97,7 +97,38 @@ cap_review_summary() {
|
|
|
97
97
|
|| echo NONE
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
#
|
|
100
|
+
# cap_qa_summary <head-sha> — collapse a `qa` receipt (stdin, the one `cckit qa verdict` writes) to
|
|
101
|
+
# FAIL / PASS / NONE. Same reading as cap_review_summary, with one difference: an EMPTY head is
|
|
102
|
+
# NONE, not "skip the check". qa_verdict_state reads a verdict nobody can compare against a commit
|
|
103
|
+
# as stale, and every qa receipt carries head_sha (qa_verdict refuses to record without one), so
|
|
104
|
+
# there is no head-less legacy receipt to stay readable for.
|
|
105
|
+
cap_qa_summary() {
|
|
106
|
+
local head="${1:-}"
|
|
107
|
+
[ -n "$head" ] || { cat >/dev/null; echo NONE; return 0; }
|
|
108
|
+
cap_review_summary "$head"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# cap_qa_required <labels-space> — echo 1 when a PR carrying <labels> must have a QA pass, else 0.
|
|
112
|
+
# Pure: reads two env values the config bridge fills (env wins over config, as everywhere here).
|
|
113
|
+
# KIT_CAPTAIN_REQUIRE_QA=1 every PR needs one
|
|
114
|
+
# KIT_CAPTAIN_QA_LABELS="a b" a PR carrying ANY of these labels needs one
|
|
115
|
+
# The label list is the per-flow opt-in: effort PRs inherit the parent's labels, so `flow:ui` there
|
|
116
|
+
# requires QA for that thread and leaves every other PR alone; a per-PR label works the same way.
|
|
117
|
+
# Labels arrive space-joined (captain_gate), so a label whose name contains a space cannot be listed.
|
|
118
|
+
cap_qa_required() {
|
|
119
|
+
local labels="${1:-}" l
|
|
120
|
+
case "${KIT_CAPTAIN_REQUIRE_QA:-0}" in 1|true|yes|on) echo 1; return 0 ;; esac
|
|
121
|
+
while IFS= read -r l; do
|
|
122
|
+
[ -n "$l" ] || continue
|
|
123
|
+
case " $labels " in *" $l "*) echo 1; return 0 ;; esac
|
|
124
|
+
done <<EOF
|
|
125
|
+
$(printf '%s' "${KIT_CAPTAIN_QA_LABELS:-}" | tr ' ' '\n')
|
|
126
|
+
EOF
|
|
127
|
+
echo 0
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# cap_classify <mergeable> <mergeStateStatus> <checksSummary> [<review>] [<qa>] [<qa-required>] —
|
|
131
|
+
# pure verdict for one PR.
|
|
101
132
|
# mergeable: MERGEABLE|CONFLICTING|UNKNOWN · mss: CLEAN|DIRTY|DRAFT|BLOCKED|BEHIND|UNSTABLE|…
|
|
102
133
|
#
|
|
103
134
|
# CHECKS_MISSING — "the exit criteria could not be observed". An EMPTY statusCheckRollup collapses to
|
|
@@ -123,8 +154,17 @@ cap_review_summary() {
|
|
|
123
154
|
# Required when review.command is configured (running a reviewer IS the opt-in) or when
|
|
124
155
|
# KIT_CAPTAIN_REQUIRE_REVIEW=1 / captain.mergePolicy.requireReview:true says so; env wins, as it
|
|
125
156
|
# does for checks. Off in both, captain_pass prints the advisory naming the key instead.
|
|
157
|
+
#
|
|
158
|
+
# QA_FAILING / QA_MISSING (#300) are the same pair for the human QA verdict (`cckit qa verdict`): a
|
|
159
|
+
# recorded fail on this head always blocks, a missing or stale pass blocks only when QA is required
|
|
160
|
+
# for this PR. <qa-required> is 1/0 from cap_qa_required, because the requirement can depend on the
|
|
161
|
+
# PR's labels; omitted, it falls back to KIT_CAPTAIN_REQUIRE_QA. Default off.
|
|
162
|
+
#
|
|
163
|
+
# QA_MISSING is tested AFTER REVIEW_MISSING and that order is load-bearing: rs_needs_dispatch keys
|
|
164
|
+
# the reviewer dispatch on REVIEW_MISSING, so a PR that is both unreviewed and un-QA'd must read
|
|
165
|
+
# REVIEW_MISSING or its reviewer never runs. It also puts the agent review ahead of the human one.
|
|
126
166
|
cap_classify() {
|
|
127
|
-
local mergeable="$1" mss="$2" checks="$3" review="${4:-NONE}" require review_req
|
|
167
|
+
local mergeable="$1" mss="$2" checks="$3" review="${4:-NONE}" qa="${5:-NONE}" qa_req="${6:-}" require review_req
|
|
128
168
|
case "$mss" in DRAFT) echo DRAFT; return 0 ;; esac
|
|
129
169
|
case "$mergeable" in CONFLICTING) echo CONFLICTING; return 0 ;; esac
|
|
130
170
|
case "$mss" in DIRTY) echo CONFLICTING; return 0 ;; esac
|
|
@@ -135,9 +175,12 @@ cap_classify() {
|
|
|
135
175
|
# A recorded failing review outranks the requirement flag: the reviewer ran and said no. This sits
|
|
136
176
|
# AFTER the check verdicts because a PR with red CI will be rewritten before the review matters.
|
|
137
177
|
case "$review" in FAIL) echo REVIEW_FAILING; return 0 ;; esac
|
|
178
|
+
case "$qa" in FAIL) echo QA_FAILING; return 0 ;; esac
|
|
138
179
|
# Literal case patterns only (a variable in a case pattern matches literally under zsh).
|
|
139
180
|
case "${KIT_CAPTAIN_REQUIRE_CHECKS:-0}" in 1|true|yes|on) require=1 ;; *) require=0 ;; esac
|
|
140
181
|
case "${KIT_CAPTAIN_REQUIRE_REVIEW:-0}" in 1|true|yes|on) review_req=1 ;; *) review_req=0 ;; esac
|
|
182
|
+
[ -n "$qa_req" ] || qa_req="${KIT_CAPTAIN_REQUIRE_QA:-0}"
|
|
183
|
+
case "$qa_req" in 1|true|yes|on) qa_req=1 ;; *) qa_req=0 ;; esac
|
|
141
184
|
case "$mergeable" in
|
|
142
185
|
MERGEABLE)
|
|
143
186
|
# passing or no required checks, and not draft/dirty/conflicting -> ready.
|
|
@@ -145,6 +188,7 @@ cap_classify() {
|
|
|
145
188
|
CLEAN|UNSTABLE|HAS_HOOKS|"")
|
|
146
189
|
if [ "$require" = "1" ] && [ "$checks" = "NONE" ]; then echo CHECKS_MISSING; return 0; fi
|
|
147
190
|
if [ "$review_req" = "1" ] && [ "$review" = "NONE" ]; then echo REVIEW_MISSING; return 0; fi
|
|
191
|
+
if [ "$qa_req" = "1" ] && [ "$qa" != "PASS" ]; then echo QA_MISSING; return 0; fi
|
|
148
192
|
echo CLEAN; return 0 ;;
|
|
149
193
|
esac
|
|
150
194
|
echo BLOCKED; return 0 ;;
|
|
@@ -165,6 +209,8 @@ cap_action() {
|
|
|
165
209
|
CHECKS_MISSING) echo verify ;;
|
|
166
210
|
REVIEW_FAILING) echo fix ;;
|
|
167
211
|
REVIEW_MISSING) echo verify ;;
|
|
212
|
+
QA_FAILING) echo fix ;;
|
|
213
|
+
QA_MISSING) echo verify ;;
|
|
168
214
|
DRAFT) echo wait ;;
|
|
169
215
|
HELD) echo hold ;;
|
|
170
216
|
*) echo skip ;;
|
|
@@ -277,7 +323,18 @@ _cap_load_policy_config() {
|
|
|
277
323
|
fi ;;
|
|
278
324
|
esac
|
|
279
325
|
fi
|
|
326
|
+
# QA requirement (#300). requireQa is `true` (every PR), `false`, or a list of label names (only
|
|
327
|
+
# PRs carrying one of them). Either env value being set means the env decides and the key is not
|
|
328
|
+
# read, so KIT_CAPTAIN_REQUIRE_QA=0 switches a configured label list off for one invocation.
|
|
329
|
+
if [ -z "${KIT_CAPTAIN_REQUIRE_QA:-}" ] && [ -z "${KIT_CAPTAIN_QA_LABELS:-}" ]; then
|
|
330
|
+
case "$(_cap_cfg_bool "$cfg" requireQa)" in
|
|
331
|
+
true) KIT_CAPTAIN_REQUIRE_QA=1 ;; false) KIT_CAPTAIN_REQUIRE_QA=0 ;;
|
|
332
|
+
*) KIT_CAPTAIN_QA_LABELS="$(jq -r '.captain.mergePolicy.requireQa
|
|
333
|
+
| if type == "array" then map(select(type == "string")) | join(" ") else "" end' "$cfg" 2>/dev/null || echo "")" ;;
|
|
334
|
+
esac
|
|
335
|
+
fi
|
|
280
336
|
export KIT_CAPTAIN_FLOORS KIT_CAPTAIN_EXTRA_GLOBS KIT_CAPTAIN_REQUIRE_CHECKS KIT_CAPTAIN_REQUIRE_REVIEW
|
|
337
|
+
export KIT_CAPTAIN_REQUIRE_QA KIT_CAPTAIN_QA_LABELS
|
|
281
338
|
}
|
|
282
339
|
|
|
283
340
|
# _cap_issue_of_branch <branch> — issue number a flow branch encodes (task/47-x, fix/9-y, effort/12-z).
|
|
@@ -294,12 +351,12 @@ _cap_issue_of_branch() {
|
|
|
294
351
|
}
|
|
295
352
|
|
|
296
353
|
# captain_gate <pr#> — fetch + classify one PR. Echoes
|
|
297
|
-
# "pr<TAB>issue<TAB>state<TAB>action<TAB>title<TAB>reason<TAB>checks". A CLEAN PR that trips a policy
|
|
354
|
+
# "pr<TAB>issue<TAB>state<TAB>action<TAB>title<TAB>reason<TAB>checks<TAB>head<TAB>qa". A CLEAN PR that trips a policy
|
|
298
355
|
# floor (cap_policy_floor) is downgraded to HELD/hold so the captain never auto-merges it; `reason`
|
|
299
356
|
# carries the floor that tripped (empty otherwise). `checks` is the raw rollup token (FAIL/PENDING/
|
|
300
357
|
# PASS/NONE) — REPORTED, not re-decided, so captain_pass can say when a merge rests on NONE.
|
|
301
358
|
captain_gate() {
|
|
302
|
-
local repo="$CAPTAIN_REPO" pr="$1" j mergeable mss checks review head issue state action title branch files labels reason
|
|
359
|
+
local repo="$CAPTAIN_REPO" pr="$1" j mergeable mss checks review qa head issue state action title branch files labels reason
|
|
303
360
|
j="$(gh pr view "$pr" --repo "$repo" --json number,title,headRefName,headRefOid,mergeable,mergeStateStatus,statusCheckRollup,files,labels 2>/dev/null)" \
|
|
304
361
|
|| { echo "captain: cannot read PR #$pr" >&2; return 1; }
|
|
305
362
|
mergeable="$(printf '%s' "$j" | jq -r '.mergeable // "UNKNOWN"')"
|
|
@@ -319,7 +376,14 @@ captain_gate() {
|
|
|
319
376
|
review="$(sr_latest "$issue" review 2>/dev/null | cap_review_summary "$head")"
|
|
320
377
|
[ -n "$review" ] || review=NONE
|
|
321
378
|
fi
|
|
322
|
-
state
|
|
379
|
+
# The QA verdict is the same kind of local state: the `qa` receipt `cckit qa verdict` wrote for
|
|
380
|
+
# this lane, read against the PR's head so a pass on an older commit is absent, not a pass.
|
|
381
|
+
qa=NONE
|
|
382
|
+
if [ -n "$issue" ] && command -v sr_latest >/dev/null 2>&1; then
|
|
383
|
+
qa="$(sr_latest "$issue" qa 2>/dev/null | cap_qa_summary "$head")"
|
|
384
|
+
[ -n "$qa" ] || qa=NONE
|
|
385
|
+
fi
|
|
386
|
+
state="$(cap_classify "$mergeable" "$mss" "$checks" "$review" "$qa" "$(cap_qa_required "$labels")")"
|
|
323
387
|
action="$(cap_action "$state")"
|
|
324
388
|
reason=""
|
|
325
389
|
# Policy floor: only a would-be merge is at risk, so gate only the CLEAN/merge verdict.
|
|
@@ -327,7 +391,7 @@ captain_gate() {
|
|
|
327
391
|
reason="$(cap_policy_floor "$files" "$labels")"
|
|
328
392
|
[ -n "$reason" ] && { state="HELD"; action="hold"; }
|
|
329
393
|
fi
|
|
330
|
-
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$pr" "${issue:-—}" "$state" "$action" "$title" "$reason" "$checks" "$head"
|
|
394
|
+
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$pr" "${issue:-—}" "$state" "$action" "$title" "$reason" "$checks" "$head" "$qa"
|
|
331
395
|
}
|
|
332
396
|
|
|
333
397
|
# _cap_open_prs [effort] — open PR numbers, optionally only those whose branch-issue is a sub of <effort>.
|
|
@@ -365,9 +429,12 @@ captain_pass() {
|
|
|
365
429
|
CAPTAIN_MERGED=0
|
|
366
430
|
_cap_load_policy_config # bridge captain.mergePolicy from config into the floor env (env wins)
|
|
367
431
|
|
|
368
|
-
local prs pr row state action issue issue_num title reason checks head merged_any=0 unproven=0 unreviewed=0
|
|
432
|
+
local prs pr row state action issue issue_num title reason checks head qa merged_any=0 unproven=0 unreviewed=0 unqa=0 qa_stack=0
|
|
369
433
|
prs="$(_cap_open_prs "$effort")"
|
|
370
434
|
[ -n "$prs" ] || { echo "captain: no open PRs in scope"; return 0; }
|
|
435
|
+
# A project that declared a QA stack (`qa.command`) is the only one the un-QA'd advisory speaks to.
|
|
436
|
+
[ -n "$CAPTAIN_CFG" ] && [ -f "$CAPTAIN_CFG" ] \
|
|
437
|
+
&& [ -n "$(jq -r '.qa.command // ""' "$CAPTAIN_CFG" 2>/dev/null)" ] && qa_stack=1
|
|
371
438
|
|
|
372
439
|
# The braces matter: redirections are processed left to right, so `: > "$f" 2>/dev/null` attempts
|
|
373
440
|
# the redirect BEFORE the suppression applies and the shell reports the failure anyway. Wrapping
|
|
@@ -384,6 +451,7 @@ captain_pass() {
|
|
|
384
451
|
reason="$(printf '%s' "$row" | cut -f6)"
|
|
385
452
|
checks="$(printf '%s' "$row" | cut -f7)"
|
|
386
453
|
head="$(printf '%s' "$row" | cut -f8)"
|
|
454
|
+
qa="$(printf '%s' "$row" | cut -f9)"
|
|
387
455
|
# Field 2 is a DISPLAY field carrying `—` for a PR whose branch encodes no issue. rs_issue_num
|
|
388
456
|
# is what everything keying storage off it goes through — see its comment for why.
|
|
389
457
|
issue_num="$issue"
|
|
@@ -401,6 +469,9 @@ captain_pass() {
|
|
|
401
469
|
&& rv="$(sr_latest "$issue_num" review 2>/dev/null | cap_review_summary "$head")"
|
|
402
470
|
[ "${rv:-NONE}" = "NONE" ] && unreviewed=$((unreviewed + 1))
|
|
403
471
|
fi
|
|
472
|
+
# And for QA: a would-be merge with no pass on this head, in a project that has a QA stack.
|
|
473
|
+
# A required PR never gets here (QA_MISSING -> verify), so this self-silences too.
|
|
474
|
+
if [ "$action" = "merge" ] && [ "$qa_stack" = "1" ] && [ "$qa" != "PASS" ]; then unqa=$((unqa + 1)); fi
|
|
404
475
|
# Review stage (#346). Dispatch runs INSIDE this pass, before the merge decision is acted on,
|
|
405
476
|
# so a PR the captain would merge gets a reviewer first. A fresh dispatch never unblocks the
|
|
406
477
|
# same pass: the receipt it writes is read by the gate on the NEXT pass, which is correct —
|
|
@@ -456,6 +527,14 @@ captain_pass() {
|
|
|
456
527
|
printf ' REVIEW_MISSING -> verify, and the captain will not merge them.\n'
|
|
457
528
|
fi
|
|
458
529
|
|
|
530
|
+
if [ "$unqa" -gt 0 ]; then
|
|
531
|
+
printf 'captain: %s PR(s) read CLEAN with NO QA pass recorded for their head.\n' "$unqa"
|
|
532
|
+
printf ' hold them for one: captain.mergePolicy.requireQa:true in your kit config, or a\n'
|
|
533
|
+
printf ' list of labels (["flow:ui"]) to require it only for PRs carrying one (or\n'
|
|
534
|
+
printf ' KIT_CAPTAIN_REQUIRE_QA=1). Those PRs then read QA_MISSING -> verify until\n'
|
|
535
|
+
printf ' `cckit qa verdict pass` is recorded against the current head.\n'
|
|
536
|
+
fi
|
|
537
|
+
|
|
459
538
|
# advance: after merges, the newly-unblocked work shows up as the next wave.
|
|
460
539
|
if [ "$merged_any" -gt 0 ]; then
|
|
461
540
|
echo "captain: merged $merged_any — next unblocked wave:"
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# codex-hooks-test.sh — the .codex/hooks.json merge (E257.5, #262): cckit's registrations go in, the
|
|
4
|
+
# user's stay, a second run changes nothing, and a file that is not a hooks.json is refused untouched.
|
|
5
|
+
# Run under bash and zsh. Run: bash scripts/lib/codex-hooks-test.sh
|
|
6
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
7
|
+
set -u
|
|
8
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
9
|
+
ROOT="$(cd "$LIB/../.." && pwd)"
|
|
10
|
+
command -v jq >/dev/null 2>&1 || { echo "codex-hooks-test: jq required" >&2; exit 1; }
|
|
11
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
12
|
+
|
|
13
|
+
cat > "$tmp/body.sh" <<'BODY'
|
|
14
|
+
fail=0
|
|
15
|
+
t() { if [ "$2" = "$3" ]; then echo "ok($SH): $1"; else echo "FAIL($SH): $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
16
|
+
. "$LIB/codex-hooks.sh"
|
|
17
|
+
TPL="$ROOT/templates/codex/hooks.json.tmpl"
|
|
18
|
+
w="$tmp/$SH"; mkdir -p "$w"
|
|
19
|
+
|
|
20
|
+
# --- the command string ------------------------------------------------------------------------
|
|
21
|
+
t "command is checkout-relative" "$(codex_hooks_command kit-mail-check.sh)" \
|
|
22
|
+
'bash "$(git rev-parse --show-toplevel)/.codex/hooks/kit-mail-check.sh"'
|
|
23
|
+
t "template is valid JSON" "$(jq -e . "$TPL" >/dev/null 2>&1 && echo yes || echo no)" "yes"
|
|
24
|
+
t "template commands are all checkout-relative" \
|
|
25
|
+
"$(jq -r '.hooks[][].hooks[].command' "$TPL" | grep -vc '^bash "\$(git rev-parse --show-toplevel)/\.codex/hooks/[a-z_-]*\.sh"$')" "0"
|
|
26
|
+
t "template registers the five events" "$(jq -r '.hooks | keys | join(" ")' "$TPL")" \
|
|
27
|
+
"PostToolUse PreToolUse SessionStart Stop UserPromptSubmit"
|
|
28
|
+
t "template: every registered script has a hook template" \
|
|
29
|
+
"$(jq -r '.hooks[][].hooks[].command' "$TPL" | sed 's|.*/\.codex/hooks/||; s|"$||' | sort -u | while IFS= read -r s; do [ -f "$ROOT/templates/hooks/$s.tmpl" ] || echo "$s"; done | tr '\n' ' ')" ""
|
|
30
|
+
|
|
31
|
+
# --- create ------------------------------------------------------------------------------------
|
|
32
|
+
t "no file: created" "$(codex_hooks_merge "$w/a.json" "$TPL")" "created"
|
|
33
|
+
t "created file equals template" "$(jq -S . "$w/a.json")" "$(jq -S . "$TPL")"
|
|
34
|
+
before="$(cat "$w/a.json")"; touch -t 200001010000 "$w/a.json"; stamp="$(ls -l "$w/a.json")"
|
|
35
|
+
t "second run: unchanged" "$(codex_hooks_merge "$w/a.json" "$TPL")" "unchanged"
|
|
36
|
+
t "unchanged run did not rewrite the file" "$(ls -l "$w/a.json")" "$stamp"
|
|
37
|
+
t "unchanged run kept the bytes" "$(cat "$w/a.json")" "$before"
|
|
38
|
+
|
|
39
|
+
# --- merge into a user's file ------------------------------------------------------------------
|
|
40
|
+
cat > "$w/u.json" <<'JSON'
|
|
41
|
+
{
|
|
42
|
+
"note": "mine",
|
|
43
|
+
"hooks": {
|
|
44
|
+
"PreToolUse": [
|
|
45
|
+
{ "matcher": "Bash", "hooks": [ { "type": "command", "command": "/usr/bin/python3 my_policy.py", "timeout": 30, "statusMessage": "mine" } ] }
|
|
46
|
+
],
|
|
47
|
+
"SubagentStop": [ { "hooks": [ { "type": "command", "command": "echo done" } ] } ]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
JSON
|
|
51
|
+
t "user file: merged" "$(codex_hooks_merge "$w/u.json" "$TPL")" "merged"
|
|
52
|
+
t "user's handler kept, first" "$(jq -r '.hooks.PreToolUse[0].hooks[0].command' "$w/u.json")" "/usr/bin/python3 my_policy.py"
|
|
53
|
+
t "user's handler fields kept" "$(jq -r '.hooks.PreToolUse[0].hooks[0].statusMessage' "$w/u.json")" "mine"
|
|
54
|
+
t "user's other event kept" "$(jq -r '.hooks.SubagentStop[0].hooks[0].command' "$w/u.json")" "echo done"
|
|
55
|
+
t "unknown top-level key kept" "$(jq -r '.note' "$w/u.json")" "mine"
|
|
56
|
+
t "kit guards appended" "$(jq '.hooks.PreToolUse | length' "$w/u.json")" "3"
|
|
57
|
+
t "registered: commit guard" "$(codex_hooks_registered "$w/u.json" guard-base-branch-commit.sh && echo yes || echo no)" "yes"
|
|
58
|
+
t "registered: mail" "$(codex_hooks_registered "$w/u.json" kit-mail-check.sh && echo yes || echo no)" "yes"
|
|
59
|
+
t "not registered: unknown" "$(codex_hooks_registered "$w/u.json" nope.sh && echo yes || echo no)" "no"
|
|
60
|
+
t "not registered: no file" "$(codex_hooks_registered "$w/absent.json" kit-mail-check.sh && echo yes || echo no)" "no"
|
|
61
|
+
t "merge twice: unchanged" "$(codex_hooks_merge "$w/u.json" "$TPL")" "unchanged"
|
|
62
|
+
t "no duplicate mail handler" "$(jq '[.hooks.Stop[].hooks[].command] | length' "$w/u.json")" "1"
|
|
63
|
+
|
|
64
|
+
# A handler the user already registered themselves (in their own group) is not registered twice.
|
|
65
|
+
jq -n --arg c "$(codex_hooks_command kit-mail-check.sh)" \
|
|
66
|
+
'{hooks:{Stop:[{hooks:[{type:"command",command:$c,timeout:99}]}]}}' > "$w/own.json"
|
|
67
|
+
codex_hooks_merge "$w/own.json" "$TPL" >/dev/null
|
|
68
|
+
t "existing registration not duplicated" "$(jq '[.hooks.Stop[].hooks[]] | length' "$w/own.json")" "1"
|
|
69
|
+
t "existing registration keeps its timeout" "$(jq '.hooks.Stop[0].hooks[0].timeout' "$w/own.json")" "99"
|
|
70
|
+
|
|
71
|
+
# --- an opt-in fragment ------------------------------------------------------------------------
|
|
72
|
+
codex_hooks_fragment PreToolUse Bash prepush_gate.sh 120 > "$w/frag.json"
|
|
73
|
+
t "fragment: matcher + timeout" "$(jq -c '.hooks.PreToolUse[0] | [.matcher, .hooks[0].timeout]' "$w/frag.json")" '["Bash",120]'
|
|
74
|
+
t "fragment: no matcher key when empty" \
|
|
75
|
+
"$(codex_hooks_fragment SessionStart "" kit-local-status.sh 10 | jq -c '.hooks.SessionStart[0] | has("matcher")')" "false"
|
|
76
|
+
t "fragment merges" "$(codex_hooks_merge "$w/a.json" "$w/frag.json")" "merged"
|
|
77
|
+
t "fragment registered" "$(codex_hooks_registered "$w/a.json" prepush_gate.sh && echo yes || echo no)" "yes"
|
|
78
|
+
|
|
79
|
+
# --- refusals leave the file alone -------------------------------------------------------------
|
|
80
|
+
printf 'not json {\n' > "$w/bad.json"
|
|
81
|
+
codex_hooks_merge "$w/bad.json" "$TPL" >/dev/null 2>&1; t "invalid JSON refused (rc)" "$?" "1"
|
|
82
|
+
t "invalid JSON left untouched" "$(cat "$w/bad.json")" "not json {"
|
|
83
|
+
printf '[1,2]\n' > "$w/arr.json"
|
|
84
|
+
codex_hooks_merge "$w/arr.json" "$TPL" >/dev/null 2>&1; t "non-object refused (rc)" "$?" "1"
|
|
85
|
+
t "non-object left untouched" "$(cat "$w/arr.json")" "[1,2]"
|
|
86
|
+
printf '{"hooks":[]}\n' > "$w/h.json"
|
|
87
|
+
codex_hooks_merge "$w/h.json" "$TPL" >/dev/null 2>&1; t "hooks-as-array refused (rc)" "$?" "1"
|
|
88
|
+
t "no temp file left behind" "$(ls "$w" | grep -c '\.tmp$')" "0"
|
|
89
|
+
[ "$fail" -eq 0 ] && echo "ALL OK($SH)"
|
|
90
|
+
exit "$fail"
|
|
91
|
+
BODY
|
|
92
|
+
|
|
93
|
+
rc=0
|
|
94
|
+
SH=bash LIB="$LIB" ROOT="$ROOT" tmp="$tmp" bash "$tmp/body.sh" || rc=1
|
|
95
|
+
if command -v zsh >/dev/null 2>&1; then
|
|
96
|
+
SH=zsh LIB="$LIB" ROOT="$ROOT" tmp="$tmp" zsh "$tmp/body.sh" || rc=1
|
|
97
|
+
else
|
|
98
|
+
echo "skip: zsh not installed"
|
|
99
|
+
fi
|
|
100
|
+
exit "$rc"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# codex-hooks.sh — register cckit's hooks in a project's `.codex/hooks.json` (E257.5, #262).
|
|
4
|
+
#
|
|
5
|
+
# Codex reads project hooks from `<repo>/.codex/hooks.json`: event -> matcher group -> handlers, the
|
|
6
|
+
# same three levels as Claude Code's settings. The file is the PROJECT's: a user may already keep
|
|
7
|
+
# their own hooks there, and Codex ties a hook's trust to its definition, so a rewrite that changes
|
|
8
|
+
# nothing still must not touch the file.
|
|
9
|
+
#
|
|
10
|
+
# codex_hooks_command <script> the command string that runs .codex/hooks/<script>
|
|
11
|
+
# codex_hooks_fragment <event> <matcher> <script> <timeout>
|
|
12
|
+
# one registration as a hooks.json document ("" = no matcher)
|
|
13
|
+
# codex_hooks_merge <dest> <src> merge every handler of <src> into <dest>; prints
|
|
14
|
+
# created | merged | unchanged
|
|
15
|
+
# codex_hooks_registered <file> <script> rc 0 when <file> registers .codex/hooks/<script>
|
|
16
|
+
#
|
|
17
|
+
# The command is relative to the checkout (`git rev-parse --show-toplevel`, the form the Codex hook
|
|
18
|
+
# docs use), never an absolute path: hooks.json is tracked, so it has to work in every clone and
|
|
19
|
+
# every worktree.
|
|
20
|
+
#
|
|
21
|
+
# Merge rule: a handler is added only when no handler of the same event already runs the same
|
|
22
|
+
# command. Everything else in <dest> — the user's handlers, their order, unknown keys — is kept.
|
|
23
|
+
# Requires jq. bash 3.2 + zsh compatible.
|
|
24
|
+
# errors: strict — a <dest> or <src> that is not a JSON object is refused (rc 1) and left untouched
|
|
25
|
+
|
|
26
|
+
codex_hooks_command() {
|
|
27
|
+
# The $(...) is literal text for Codex's shell to expand at hook time, not ours.
|
|
28
|
+
# shellcheck disable=SC2016
|
|
29
|
+
printf 'bash "$(git rev-parse --show-toplevel)/.codex/hooks/%s"\n' "${1:-}"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
codex_hooks_fragment() {
|
|
33
|
+
local event="${1:-}" matcher="${2:-}" script="${3:-}" timeout="${4:-10}"
|
|
34
|
+
[ -n "$event" ] && [ -n "$script" ] || { echo "codex_hooks_fragment: <event> <matcher> <script> [timeout] required" >&2; return 1; }
|
|
35
|
+
jq -n --arg e "$event" --arg m "$matcher" --arg c "$(codex_hooks_command "$script")" --argjson t "$timeout" \
|
|
36
|
+
'{hooks: {($e): [ (if $m == "" then {} else {matcher: $m} end) + {hooks: [{type: "command", command: $c, timeout: $t}]} ]}}'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
codex_hooks_merge() {
|
|
40
|
+
local dest="${1:-}" src="${2:-}" have merged
|
|
41
|
+
[ -n "$dest" ] && [ -f "$src" ] || { echo "codex_hooks_merge: <dest> <src> required" >&2; return 1; }
|
|
42
|
+
command -v jq >/dev/null 2>&1 || { echo "codex_hooks_merge: jq required" >&2; return 1; }
|
|
43
|
+
jq -e 'type == "object" and ((.hooks // {}) | type == "object")' "$src" >/dev/null 2>&1 \
|
|
44
|
+
|| { echo "codex_hooks_merge: $src is not a hooks.json object" >&2; return 1; }
|
|
45
|
+
if [ -f "$dest" ]; then
|
|
46
|
+
have="$(jq -c 'if type == "object" and ((.hooks // {}) | type == "object") then . else error("not a hooks.json object") end' "$dest" 2>/dev/null)" \
|
|
47
|
+
|| { echo "codex_hooks_merge: $dest is not a JSON hooks.json object — left untouched" >&2; return 1; }
|
|
48
|
+
else
|
|
49
|
+
have='{}'
|
|
50
|
+
fi
|
|
51
|
+
merged="$(printf '%s\n' "$have" | jq -c --slurpfile src "$src" '
|
|
52
|
+
reduce (($src[0].hooks // {}) | to_entries[]) as $ev (.;
|
|
53
|
+
reduce ($ev.value[]) as $g (.;
|
|
54
|
+
([ (.hooks[$ev.key] // [])[] | (.hooks // [])[] | (.command // empty) ]) as $seen
|
|
55
|
+
| ($g | .hooks = [ (.hooks // [])[] | select((.command // "") as $c | ($seen | index($c)) == null) ]) as $new
|
|
56
|
+
| if ($new.hooks | length) > 0 then .hooks[$ev.key] = ((.hooks[$ev.key] // []) + [$new]) else . end))')" \
|
|
57
|
+
|| { echo "codex_hooks_merge: could not merge $src into $dest — left untouched" >&2; return 1; }
|
|
58
|
+
if [ -f "$dest" ] && [ "$merged" = "$have" ]; then echo unchanged; return 0; fi
|
|
59
|
+
mkdir -p "$(dirname "$dest")" || return 1
|
|
60
|
+
printf '%s\n' "$merged" | jq . > "$dest.tmp" && mv "$dest.tmp" "$dest" || { rm -f "$dest.tmp"; return 1; }
|
|
61
|
+
if [ "$have" = '{}' ]; then echo created; else echo merged; fi
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
codex_hooks_registered() {
|
|
65
|
+
local file="${1:-}" want
|
|
66
|
+
[ -f "$file" ] || return 1
|
|
67
|
+
want="$(codex_hooks_command "${2:-}")"
|
|
68
|
+
jq -e --arg c "$want" '[ (.hooks // {})[]?[]? | (.hooks // [])[]? | .command ] | index($c) != null' "$file" >/dev/null 2>&1
|
|
69
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# content-kinds-gc-test.sh — a live branch of every content kind keeps its gc protection (#417).
|
|
4
|
+
#
|
|
5
|
+
# A content kind (post, campaign, brand, research) is a `kind:` label value that maps onto a branch
|
|
6
|
+
# prefix of the closed set. This test follows one issue of each kind from the label to the gc
|
|
7
|
+
# report: the branch `cckit start` would cut parses to the issue number, and while that issue is
|
|
8
|
+
# OPEN `cckit gc` reports the branch PROTECTED — even when the branch's own PR has MERGED, the case
|
|
9
|
+
# in which an unprotected branch is offered as SAFE to delete.
|
|
10
|
+
# Hermetic: a throwaway git repo under mktemp, gh stubbed on PATH, no network.
|
|
11
|
+
# Run: bash scripts/lib/content-kinds-gc-test.sh
|
|
12
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
13
|
+
set -u
|
|
14
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
15
|
+
LIB="$ROOT/scripts/lib"
|
|
16
|
+
fail=0
|
|
17
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
18
|
+
command -v git >/dev/null 2>&1 || { echo "content-kinds-gc-test: git required" >&2; exit 1; }
|
|
19
|
+
|
|
20
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
21
|
+
# shellcheck source=/dev/null
|
|
22
|
+
source "$LIB/kinds.sh"
|
|
23
|
+
# shellcheck source=/dev/null
|
|
24
|
+
source "$LIB/worktree-issue.sh"
|
|
25
|
+
# shellcheck source=/dev/null
|
|
26
|
+
source "$LIB/worktree-start.sh"
|
|
27
|
+
|
|
28
|
+
cd "$tmp" || exit 1
|
|
29
|
+
git init -q repo
|
|
30
|
+
cd repo || exit 1
|
|
31
|
+
git config user.email t@t; git config user.name t
|
|
32
|
+
echo base > base.txt; git add base.txt; git commit -q -m init
|
|
33
|
+
|
|
34
|
+
# One issue per content kind: 41 post · 42 campaign · 43 brand · 44 research. Issue 45 is CLOSED,
|
|
35
|
+
# the control: its branch must NOT be protected, or the assertions below prove nothing.
|
|
36
|
+
n=41; branches=""; pr_rows=""
|
|
37
|
+
for k in $KIT_CONTENT_KINDS; do
|
|
38
|
+
prefix="$(_wt_kind_prefix "$k" 2>/dev/null)"
|
|
39
|
+
kit_kind_valid "$prefix"; t "kind:$k starts on a prefix of the closed set ($prefix/)" "$?" "0"
|
|
40
|
+
b="$prefix/$n-$k-piece"
|
|
41
|
+
t "branch $b parses to issue $n" "$(wt_issue_number "$b")" "$n"
|
|
42
|
+
git branch "$b" >/dev/null 2>&1
|
|
43
|
+
branches="$branches $b"
|
|
44
|
+
pr_rows="$pr_rows$b PR#$((n + 100)) MERGED
|
|
45
|
+
"
|
|
46
|
+
n=$((n + 1))
|
|
47
|
+
done
|
|
48
|
+
t "four content kinds were exercised" "$(printf '%s\n' $branches | grep -c .)" "4"
|
|
49
|
+
git branch task/45-closed-piece >/dev/null 2>&1
|
|
50
|
+
pr_rows="${pr_rows}task/45-closed-piece PR#145 MERGED
|
|
51
|
+
"
|
|
52
|
+
|
|
53
|
+
stub="$tmp/ghbin"; mkdir -p "$stub"
|
|
54
|
+
printf '%s' "$pr_rows" > "$tmp/pr-rows"
|
|
55
|
+
cat > "$stub/gh" <<'SH'
|
|
56
|
+
#!/usr/bin/env bash
|
|
57
|
+
case "$1 $2" in
|
|
58
|
+
"pr list") cat "$PR_ROWS" ;;
|
|
59
|
+
"issue view") case "$3" in 45) echo "closed" ;; *) echo "open" ;; esac ;;
|
|
60
|
+
*) : ;;
|
|
61
|
+
esac
|
|
62
|
+
SH
|
|
63
|
+
chmod +x "$stub/gh"
|
|
64
|
+
export PR_ROWS="$tmp/pr-rows"
|
|
65
|
+
|
|
66
|
+
for b in $branches; do
|
|
67
|
+
reason="$(PATH="$stub:$PATH" wt_protected_reason "$b" "o/r")"
|
|
68
|
+
t "wt_protected_reason keeps $b" "$reason" "issue #$(wt_issue_number "$b") still OPEN"
|
|
69
|
+
done
|
|
70
|
+
t "the closed issue's branch is not protected" "$(PATH="$stub:$PATH" wt_protected_reason task/45-closed-piece "o/r")" ""
|
|
71
|
+
|
|
72
|
+
# The gc report itself: each live content branch is in the protected bucket, none in the safe one.
|
|
73
|
+
# shellcheck source=/dev/null
|
|
74
|
+
source "$LIB/kit-gc.sh"
|
|
75
|
+
analysis="$(PATH="$stub:$PATH" KIT_GC_REPO="o/r" kit_gc_analyze 2>/dev/null)"
|
|
76
|
+
for b in $branches; do
|
|
77
|
+
row="$(printf '%s\n' "$analysis" | grep -F "$b" | sed -n 1p)"
|
|
78
|
+
case "$row" in
|
|
79
|
+
*PROTECTED*|*"still OPEN"*) echo "ok: gc reports $b as protected" ;;
|
|
80
|
+
*) echo "FAIL: gc does not protect $b -> '$row'"; fail=1 ;;
|
|
81
|
+
esac
|
|
82
|
+
case "$row" in *SAFE*) echo "FAIL: gc offers $b as SAFE -> '$row'"; fail=1 ;; esac
|
|
83
|
+
done
|
|
84
|
+
row="$(printf '%s\n' "$analysis" | grep -F "task/45-closed-piece" | sed -n 1p)"
|
|
85
|
+
case "$row" in *SAFE*) echo "ok: the control branch (closed issue, merged PR) is SAFE" ;; *) echo "FAIL: control branch not SAFE -> '$row'"; fail=1 ;; esac
|
|
86
|
+
|
|
87
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (content kinds gc)" || echo "content kinds gc: FAILURES"
|
|
88
|
+
exit "$fail"
|