@jeiemgi/cckit 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +169 -21
- package/README.md +491 -35
- package/SECURITY.md +5 -0
- package/bin/cckit +182 -17
- package/cckit.config.json +1 -1
- package/commands/kit-doctor.md +13 -5
- package/commands/kit-export-project.md +0 -2
- package/commands/kit-export-training.md +6 -9
- package/commands/kit-init.md +43 -13
- package/commands/kit-routines.md +1 -1
- package/commands/kit-update.md +11 -6
- package/databases/supabase/guide.html +106 -0
- package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
- package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
- package/databases/supabase.json +70 -0
- package/integrations/emil-design-eng.json +41 -0
- package/integrations/graft.json +81 -0
- package/integrations/impeccable.json +42 -0
- package/integrations/integration.schema.json +215 -0
- package/integrations/lavish.json +43 -0
- package/integrations/mempalace.json +28 -0
- package/integrations/mlx-lm.json +32 -0
- package/integrations/web-design-guidelines.json +42 -0
- package/kit.config.schema.json +183 -5
- package/package.json +4 -1
- package/profiles/automation.json +7 -1
- package/profiles/content.json +10 -2
- package/profiles/marketing.json +57 -0
- package/profiles/minimal.json +7 -1
- package/profiles/research.json +7 -1
- package/profiles/software.json +7 -1
- package/recipes/nextjs-shadcn.json +49 -0
- package/scripts/agent-skills-external.txt +45 -0
- package/scripts/agent-skills-lint-test.sh +131 -0
- package/scripts/agent-skills-lint.sh +115 -0
- package/scripts/agent-template-lint-test.sh +42 -0
- package/scripts/agent-template-lint.sh +58 -0
- package/scripts/annotate-setup.sh +1 -1
- package/scripts/autopilot-run-test.sh +338 -0
- package/scripts/autopilot-run.sh +448 -0
- package/scripts/autopilot-test.sh +8 -0
- package/scripts/autopilot.sh +10 -1
- package/scripts/benchmark/benchmark-test.sh +85 -0
- package/scripts/benchmark/checkpoint-test.sh +314 -0
- package/scripts/benchmark/checkpoint.sh +408 -0
- package/scripts/benchmark/lib/model.sh +31 -6
- package/scripts/benchmark/report.sh +17 -2
- package/scripts/benchmark/run-quality.sh +36 -10
- package/scripts/benchmark/verb-timings-test.sh +124 -0
- package/scripts/benchmark/verb-timings.sh +149 -0
- package/scripts/check.sh +29 -19
- package/scripts/content-skills-test.sh +144 -0
- package/scripts/copilot-loop-test.sh +25 -0
- package/scripts/database-supabase-test.sh +121 -0
- package/scripts/docs-marketing-words-test.sh +73 -0
- package/scripts/docs-record-tables-test.sh +72 -0
- package/scripts/hook-adapter-test.sh +193 -0
- package/scripts/init-content-test.sh +225 -0
- package/scripts/init-guided-test.sh +474 -0
- package/scripts/init-recipes-test.sh +104 -0
- package/scripts/init-upgrade-test.sh +341 -2
- package/scripts/init.sh +746 -95
- package/scripts/instruction-budget-baseline.txt +8 -0
- package/scripts/instruction-budget-lint-test.sh +166 -0
- package/scripts/instruction-budget-lint.sh +219 -0
- package/scripts/integrations-check-test.sh +200 -0
- package/scripts/integrations-check.sh +157 -0
- package/scripts/kit-add-test.sh +214 -0
- package/scripts/kit-add.sh +305 -5
- package/scripts/kit-adopt-test.sh +16 -0
- package/scripts/kit-adopt.sh +3 -2
- package/scripts/kit-digest.sh +2 -2
- package/scripts/kit-doctor-test.sh +293 -0
- package/scripts/kit-doctor.sh +272 -140
- package/scripts/kit-export-project-test.sh +3 -3
- package/scripts/kit-remove-test.sh +19 -0
- package/scripts/kit-routines.sh +2 -2
- package/scripts/kit-self-update.sh +1 -1
- package/scripts/kit-version-check-test.sh +4 -0
- package/scripts/kit-version-check.sh +4 -2
- package/scripts/knowledge-lint.sh +4 -4
- package/scripts/leak-fence-test.sh +89 -0
- package/scripts/lib/adapter-select-test.sh +136 -0
- package/scripts/lib/adapter-select.sh +158 -0
- package/scripts/lib/agent-def-test.sh +69 -0
- package/scripts/lib/agent-def.sh +106 -0
- package/scripts/lib/agent-launch-test.sh +212 -0
- package/scripts/lib/agent-launch.sh +335 -0
- package/scripts/lib/board-view-test.sh +11 -0
- package/scripts/lib/board-view.sh +42 -26
- package/scripts/lib/branch-owner-test.sh +26 -0
- package/scripts/lib/branch-owner.sh +16 -9
- package/scripts/lib/captain-test.sh +105 -0
- package/scripts/lib/captain.sh +87 -8
- package/scripts/lib/codex-hooks-test.sh +100 -0
- package/scripts/lib/codex-hooks.sh +69 -0
- package/scripts/lib/commitlint.sh +1 -1
- package/scripts/lib/content-kinds-gc-test.sh +88 -0
- package/scripts/lib/copilot-test.sh +70 -4
- package/scripts/lib/copilot.sh +66 -14
- package/scripts/lib/effort-dispatch-test.sh +3 -3
- package/scripts/lib/effort-metrics-test.sh +178 -1
- package/scripts/lib/effort-metrics.sh +175 -35
- package/scripts/lib/effort-ops-test.sh +205 -7
- package/scripts/lib/effort-ops.sh +198 -43
- package/scripts/lib/effort-parity-test.sh +49 -13
- package/scripts/lib/effort-plan-test.sh +337 -0
- package/scripts/lib/effort-plan.sh +200 -23
- package/scripts/lib/effort.sh +56 -11
- package/scripts/lib/errors-header-test.sh +1 -1
- package/scripts/lib/gh-project-test.sh +35 -1
- package/scripts/lib/gh-project.sh +23 -16
- package/scripts/lib/gh-rest-test.sh +32 -3
- package/scripts/lib/gh-rest.sh +17 -2
- package/scripts/lib/hook-refresh.sh +1 -1
- package/scripts/lib/init-github.sh +412 -0
- package/scripts/lib/init-guide.sh +630 -0
- package/scripts/lib/integration-install-test.sh +343 -0
- package/scripts/lib/integration-install.sh +257 -0
- package/scripts/lib/integrations-test.sh +366 -0
- package/scripts/lib/integrations.sh +244 -0
- package/scripts/lib/kinds-test.sh +125 -0
- package/scripts/lib/kinds.sh +66 -0
- package/scripts/lib/kit-brief-test.sh +22 -3
- package/scripts/lib/kit-brief.sh +45 -5
- package/scripts/lib/kit-config-resolve.sh +2 -2
- package/scripts/lib/kit-config-test.sh +64 -1
- package/scripts/lib/kit-config.sh +37 -1
- package/scripts/lib/kit-events.sh +7 -0
- package/scripts/lib/kit-gc-test.sh +173 -1
- package/scripts/lib/kit-gc.sh +226 -37
- package/scripts/lib/kit-hotfix.sh +216 -0
- package/scripts/lib/kit-interview-test.sh +93 -0
- package/scripts/lib/kit-interview.sh +117 -8
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +3 -3
- package/scripts/lib/kit-local.sh +2 -2
- package/scripts/lib/kit-manifest.sh +33 -1
- package/scripts/lib/kit-profile-test.sh +3 -3
- package/scripts/lib/kit-status-test.sh +112 -4
- package/scripts/lib/kit-status.sh +246 -16
- package/scripts/lib/kit-task-ops-test.sh +37 -0
- package/scripts/lib/kit-task-ops.sh +175 -31
- package/scripts/lib/kto-hotfix-test.sh +232 -0
- package/scripts/lib/kto-task-close-test.sh +1 -1
- package/scripts/lib/kto-task-new-test.sh +95 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +37 -3
- package/scripts/lib/kto-task-pr-test.sh +70 -0
- package/scripts/lib/leak-fence.sh +89 -0
- package/scripts/lib/light-task-run-test.sh +255 -0
- package/scripts/lib/light-task-test.sh +309 -0
- package/scripts/lib/light-task.sh +706 -0
- package/scripts/lib/next-test.sh +99 -0
- package/scripts/lib/next.sh +9 -3
- package/scripts/lib/orchestration-runtime-test.sh +72 -0
- package/scripts/lib/orchestration-runtime.sh +57 -5
- package/scripts/lib/plan-machine-test.sh +15 -2
- package/scripts/lib/plan-machine.sh +20 -7
- package/scripts/lib/plan-next-test.sh +1 -1
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +3 -3
- package/scripts/lib/pr-evidence.sh +1 -1
- package/scripts/lib/qa-lane-test.sh +626 -0
- package/scripts/lib/qa-lane.sh +1357 -0
- package/scripts/lib/qa-lanes-test.sh +175 -0
- package/scripts/lib/react-detect.sh +1 -1
- package/scripts/lib/render-test.sh +1 -1
- package/scripts/lib/review-page-test.sh +318 -0
- package/scripts/lib/review-page.sh +369 -0
- package/scripts/lib/review-stage-test.sh +62 -11
- package/scripts/lib/review-stage.sh +42 -60
- package/scripts/lib/role-identity-test.sh +65 -0
- package/scripts/lib/role-identity.sh +25 -2
- package/scripts/lib/secret-guard.sh +3 -3
- package/scripts/lib/session-registry-test.sh +111 -0
- package/scripts/lib/session-registry.sh +233 -0
- package/scripts/lib/stage-receipt-test.sh +14 -1
- package/scripts/lib/stage-receipt.sh +13 -8
- package/scripts/lib/task-source-file.sh +309 -0
- package/scripts/lib/task-source.sh +130 -0
- package/scripts/lib/upgrade-report-test.sh +120 -0
- package/scripts/lib/upgrade-report.sh +138 -0
- package/scripts/lib/version-bump.sh +3 -3
- package/scripts/lib/wave-result-test.sh +80 -0
- package/scripts/lib/wave-result.sh +127 -0
- package/scripts/lib/worker-brief-test.sh +5 -0
- package/scripts/lib/worker-brief.sh +2 -2
- package/scripts/lib/worktree-issue-test.sh +30 -1
- package/scripts/lib/worktree-issue.sh +82 -12
- package/scripts/lib/worktree-ports-test.sh +57 -4
- package/scripts/lib/worktree-start-test.sh +197 -0
- package/scripts/lib/worktree-start.sh +153 -31
- package/scripts/lib/zsh-safety-test.sh +19 -3
- package/scripts/marketing-walkthrough-test.sh +152 -0
- package/scripts/night-grant-test.sh +37 -0
- package/scripts/night-grant.sh +448 -0
- package/scripts/night-run-test.sh +8 -0
- package/scripts/night-run.mjs +275 -0
- package/scripts/night-run.test.mjs +324 -0
- package/scripts/orchestrate-test.sh +190 -0
- package/scripts/orchestrate.sh +79 -8
- package/scripts/portable-test.sh +11 -2
- package/scripts/publish.sh +28 -3
- package/scripts/review-lint-test.sh +7 -7
- package/scripts/review-lint.sh +2 -2
- package/scripts/review-rules.conf +8 -0
- package/scripts/rule-recipes-test.sh +96 -0
- package/scripts/self-install-test.sh +39 -9
- package/scripts/setup-labels.sh +18 -1
- package/scripts/setup-milestones.sh +1 -1
- package/scripts/showcase.sh +1 -1
- package/scripts/skill-frontmatter-lint-test.sh +4 -4
- package/scripts/skill-frontmatter-lint.sh +1 -1
- package/scripts/status-test.sh +113 -2
- package/scripts/status.sh +16 -3
- package/scripts/task-sync-test.sh +154 -0
- package/scripts/task-sync.sh +243 -32
- package/scripts/test-runner-test.sh +158 -0
- package/scripts/test.sh +131 -23
- package/scripts/update-path-test.sh +279 -0
- package/scripts/ux-ds-audit.sh +1 -1
- package/scripts/ux-graph-scan.sh +6 -6
- package/scripts/wave-worker.sh +54 -0
- package/skills/kit-add/SKILL.md +77 -0
- package/skills/kit-autopilot/SKILL.md +123 -12
- package/skills/kit-cleanup/SKILL.md +5 -2
- package/skills/kit-contribute/SKILL.md +4 -4
- package/skills/kit-docs-writer/SKILL.md +16 -6
- package/skills/kit-effort-close/SKILL.md +17 -8
- package/skills/kit-effort-new/SKILL.md +15 -9
- package/skills/kit-effort-pr/SKILL.md +15 -7
- package/skills/kit-effort-start/SKILL.md +5 -2
- package/skills/kit-gc/SKILL.md +5 -2
- package/skills/kit-next/SKILL.md +5 -1
- package/skills/kit-onboard/SKILL.md +3 -3
- package/skills/kit-page/SKILL.md +93 -0
- package/skills/kit-plan-next/SKILL.md +8 -4
- package/skills/kit-security-sweep/SKILL.md +1 -3
- package/skills/kit-ship/SKILL.md +2 -3
- package/skills/kit-status/SKILL.md +35 -4
- package/skills/kit-task-new/SKILL.md +3 -3
- package/skills/kit-task-pr/SKILL.md +7 -2
- package/skills/kit-task-pr-merge/SKILL.md +7 -2
- package/skills/kit-task-start/SKILL.md +7 -7
- package/skills/kit-task-sync/SKILL.md +19 -3
- package/skills/kit-ux-audit/SKILL.md +3 -2
- package/templates/agents/auto-dev.md +5 -4
- package/templates/agents/backend.md +1 -1
- package/templates/agents/designer.md +2 -0
- package/templates/agents/devops.md +1 -1
- package/templates/agents/editor.md +9 -1
- package/templates/agents/frontend.md +1 -1
- package/templates/agents/local-delegate.md +1 -1
- package/templates/agents/pm.md +5 -5
- package/templates/agents/tech-lead.md +1 -1
- package/templates/benchmarks/SCHEMA.md +9 -3
- package/templates/codex/hooks.json.tmpl +89 -0
- package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +12 -12
- package/templates/hooks/mempal_followup.sh.tmpl +2 -2
- package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
- package/templates/hooks/prepush_gate.sh.tmpl +4 -2
- package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
- package/templates/instructions.md.tmpl +174 -0
- package/templates/kit.config.json.tmpl +3 -3
- package/templates/knowledge-INDEX.md.tmpl +1 -1
- package/templates/lib/kit-sigil.sh.tmpl +1 -1
- package/templates/rules/authoring.md +106 -0
- package/templates/rules/branch-naming.md +40 -4
- package/templates/rules/code-retrieval.md +63 -0
- package/templates/rules/delegation-brief.md +0 -3
- package/templates/rules/design-routing.md +3 -3
- package/templates/rules/effort-model.md +14 -10
- package/templates/rules/gate-and-review.md +94 -0
- package/templates/rules/issue-lifecycle.md +88 -0
- package/templates/rules/knowledge-base.md +1 -1
- package/templates/rules/mempalace.md +1 -1
- package/templates/rules/merge-safety.md +108 -0
- package/templates/rules/naming-and-ids.md +23 -17
- package/templates/rules/plain-language.md +59 -0
- package/templates/rules/plan-next.md +9 -11
- package/templates/rules/react-annotate.md +6 -0
- package/templates/rules/review-pages.md +49 -0
- package/templates/rules/risk-tiered-review.md +13 -4
- package/templates/rules/shared-checkout.md +106 -0
- package/templates/rules/skill-gaps.md +2 -7
- package/templates/rules/task-management.md +13 -1
- package/templates/skills/brand-voice/SKILL.md +91 -0
- package/templates/skills/brand-voice/references/voice-template.md +61 -0
- package/templates/skills/campaign/SKILL.md +123 -0
- package/templates/skills/campaign/references/plan-template.md +55 -0
- package/templates/skills/concrete/SKILL.md +2 -2
- package/templates/skills/copywriting/SKILL.md +8 -1
- package/templates/skills/feature-build-refine/SKILL.md +2 -4
- package/templates/skills/morning-briefing/SKILL.md +2 -2
- package/templates/skills/page-design/SKILL.md +145 -0
- package/templates/skills/page-design/add.json +5 -0
- package/templates/skills/page-design/references/design-file-template.md +40 -0
- package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
- package/templates/skills/page-design/references/minimum-rules.md +42 -0
- package/templates/skills/speckit/SKILL.md +4 -5
- package/templates/skills/supabase-patterns/SKILL.md +1 -1
- package/commands/kit-add.md +0 -42
- package/templates/CLAUDE.md.tmpl +0 -106
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# database-supabase-test.sh — the setup test of the Supabase database option (#456).
|
|
4
|
+
#
|
|
5
|
+
# A database option is offered by `cckit init` only while this file exists (databases/supabase.json
|
|
6
|
+
# names it as its `test`). It proves that following the option produces a correct setup:
|
|
7
|
+
# - the env file has the variable names the descriptor declares, with placeholders, not values;
|
|
8
|
+
# - the client code the option adds reads exactly those names;
|
|
9
|
+
# - the env file is ignored by git, and a value already in it is neither changed nor printed;
|
|
10
|
+
# - applying it twice changes nothing the second time.
|
|
11
|
+
# Offline by default: `pnpm` is a stub that records the packages in package.json.
|
|
12
|
+
#
|
|
13
|
+
# The build half is networked and opt-in, so the default run stays offline:
|
|
14
|
+
# INIT_E2E_NETWORK=1 bash scripts/database-supabase-test.sh
|
|
15
|
+
# runs the shipped recipe (create-next-app, shadcn) with the real pnpm in a scratch folder
|
|
16
|
+
# (INIT_E2E_DIR, default a temp dir), applies this option, installs the kit with --no-github, and
|
|
17
|
+
# requires `pnpm build` to pass with the placeholder env values.
|
|
18
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
19
|
+
set -u
|
|
20
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
21
|
+
E2E="${INIT_E2E_NETWORK:-0}"; E2E_DIR="${INIT_E2E_DIR:-}"
|
|
22
|
+
# shellcheck source=/dev/null
|
|
23
|
+
. "$ROOT/scripts/lib/test-env.sh" && test_env_seal
|
|
24
|
+
fail=0
|
|
25
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
26
|
+
has() { if grep -qF -- "$3" <<<"$2"; then echo "ok: $1"; else echo "FAIL: $1 -> '$3' not in: $2"; fail=1; fi; }
|
|
27
|
+
hasnt() { if grep -qF -- "$3" <<<"$2"; then echo "FAIL: $1 -> '$3' found"; fail=1; else echo "ok: $1"; fi; }
|
|
28
|
+
yes_if() { if eval "$2"; then echo "ok: $1"; else echo "FAIL: $1 -> not true: $2"; fail=1; fi; }
|
|
29
|
+
|
|
30
|
+
command -v jq >/dev/null 2>&1 || { echo "database-supabase-test: jq absent — skipping (dependency-light gate)"; exit 0; }
|
|
31
|
+
|
|
32
|
+
# shellcheck source=/dev/null
|
|
33
|
+
. "$ROOT/scripts/lib/init-guide.sh"
|
|
34
|
+
DB="$ROOT/databases/supabase.json"
|
|
35
|
+
ENV_FILE="$(jq -r .envFile "$DB")"
|
|
36
|
+
NAMES="$(jq -r '.env[].name' "$DB")"
|
|
37
|
+
|
|
38
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
39
|
+
tmp="$(cd "$tmp" && pwd -P)"
|
|
40
|
+
real_path="$PATH"
|
|
41
|
+
mkdir -p "$tmp/stubs"
|
|
42
|
+
cat > "$tmp/stubs/pnpm" <<'STUB'
|
|
43
|
+
#!/usr/bin/env bash
|
|
44
|
+
[ "${1:-}" = "add" ] || exit 1
|
|
45
|
+
shift
|
|
46
|
+
for p in "$@"; do jq --arg p "$p" '.dependencies[$p] = "0.0.0-stub"' package.json > package.json.tmp && mv package.json.tmp package.json; done
|
|
47
|
+
STUB
|
|
48
|
+
chmod +x "$tmp/stubs/pnpm"
|
|
49
|
+
export PATH="$tmp/stubs:$PATH"
|
|
50
|
+
|
|
51
|
+
t "the option is valid" "$(database_validate "$DB" 2>&1; echo "rc=$?")" "rc=0"
|
|
52
|
+
t "the option is offered" "$(database_offered "$DB"; echo "rc=$?")" "rc=0"
|
|
53
|
+
|
|
54
|
+
# ── a Next.js project the option is applied to ──────────────────────────────────────────────────
|
|
55
|
+
p="$tmp/app"; mkdir -p "$p"
|
|
56
|
+
printf '{"name":"app","dependencies":{"next":"1.0.0"}}\n' > "$p/package.json"
|
|
57
|
+
t "stack is detected from package.json" "$(database_stack_for "$DB" "$p")" "nextjs"
|
|
58
|
+
t "a project without the framework has no stack" "$(mkdir -p "$tmp/other" && echo '{"dependencies":{}}' > "$tmp/other/package.json" && database_stack_for "$DB" "$tmp/other"; echo "rc=$?")" "rc=1"
|
|
59
|
+
|
|
60
|
+
out="$(database_apply "$DB" nextjs "$p" 2>&1)"
|
|
61
|
+
for n in $NAMES; do
|
|
62
|
+
yes_if "env file names $n" 'grep -q "^$n=" "$p/$ENV_FILE"'
|
|
63
|
+
ph="$(jq -r --arg n "$n" '.env[] | select(.name == $n) | .placeholder' "$DB")"
|
|
64
|
+
t "$n holds the descriptor's placeholder" "$(sed -n "s/^$n=//p" "$p/$ENV_FILE")" "$ph"
|
|
65
|
+
yes_if "the client code reads $n" 'grep -rq "process\.env\.$n" "$p/lib/supabase"'
|
|
66
|
+
done
|
|
67
|
+
t "the env file has no variable the descriptor does not declare" \
|
|
68
|
+
"$(grep -E '^[A-Z_]+=' "$p/$ENV_FILE" | cut -d= -f1 | sort | tr '\n' ' ')" "$(printf '%s\n' "$NAMES" | sort | tr '\n' ' ')"
|
|
69
|
+
for f in $(jq -r '.stacks.nextjs.files[].to' "$DB"); do
|
|
70
|
+
yes_if "the option adds $f" '[ -f "$p/$f" ]'
|
|
71
|
+
done
|
|
72
|
+
for pk in $(jq -r '.stacks.nextjs.packages[]' "$DB"); do
|
|
73
|
+
yes_if "package $pk is a dependency" 'jq -e --arg p "$pk" ".dependencies | has(\$p)" "$p/package.json" >/dev/null'
|
|
74
|
+
done
|
|
75
|
+
yes_if "the env file is ignored" 'grep -qxF "$ENV_FILE" "$p/.gitignore"'
|
|
76
|
+
has "every step is reported" "$out" "[done ] $ENV_FILE"
|
|
77
|
+
|
|
78
|
+
# ── idempotent, and a value the user typed is neither changed nor shown ─────────────────────────
|
|
79
|
+
first="$(echo "$NAMES" | sed -n 1p)"
|
|
80
|
+
sed "s#^$first=.*#$first=https://typed-by-the-user.example#" "$p/$ENV_FILE" > "$p/$ENV_FILE.tmp" && mv "$p/$ENV_FILE.tmp" "$p/$ENV_FILE"
|
|
81
|
+
before="$(cd "$p" && find . -type f -print0 | sort -z | xargs -0 cksum)"
|
|
82
|
+
out="$(database_apply "$DB" nextjs "$p" 2>&1)"
|
|
83
|
+
t "second apply changes no file" "$(cd "$p" && find . -type f -print0 | sort -z | xargs -0 cksum)" "$before"
|
|
84
|
+
hasnt "second apply reports nothing done" "$out" "[done"
|
|
85
|
+
hasnt "a value in the env file never reaches the output" "$out" "typed-by-the-user"
|
|
86
|
+
hasnt "the printed steps carry no value from the env file" "$(database_steps "$DB" "$p")" "typed-by-the-user"
|
|
87
|
+
t "the user's value is still there" "$(sed -n "s/^$first=//p" "$p/$ENV_FILE")" "https://typed-by-the-user.example"
|
|
88
|
+
|
|
89
|
+
# In a git repository, an ignore rule from the framework's own .gitignore is enough.
|
|
90
|
+
if command -v git >/dev/null 2>&1; then
|
|
91
|
+
g="$tmp/gitapp"; mkdir -p "$g"; git -C "$g" init -q
|
|
92
|
+
printf '{"name":"app","dependencies":{"next":"1.0.0"}}\n' > "$g/package.json"; printf '.env*\n' > "$g/.gitignore"
|
|
93
|
+
out="$(database_apply "$DB" nextjs "$g" 2>&1)"
|
|
94
|
+
has "an existing .env* rule is enough" "$out" "[skipped] .gitignore"
|
|
95
|
+
t "git ignores the env file" "$(git -C "$g" check-ignore "$ENV_FILE")" "$ENV_FILE"
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# ── opt-in: the real thing, networked ───────────────────────────────────────────────────────────
|
|
99
|
+
if [ "$E2E" = "1" ]; then
|
|
100
|
+
export PATH="$real_path"
|
|
101
|
+
work="${E2E_DIR:-$tmp/e2e}"; mkdir -p "$work"; proj="$work/shop"
|
|
102
|
+
[ ! -e "$proj" ] || { echo "FAIL: $proj already exists — remove it first"; exit 1; }
|
|
103
|
+
echo "── networked: cckit init $proj --recipe nextjs-shadcn --database supabase --no-github"
|
|
104
|
+
( cd "$work" && KIT_INIT_PREFLIGHT=0 KIT_INIT_BROWSER=0 KIT_INIT_TTY=0 CLAUDE_PLUGIN_ROOT="$ROOT" \
|
|
105
|
+
bash "$ROOT/scripts/init.sh" "$proj" --recipe nextjs-shadcn --database supabase --no-github )
|
|
106
|
+
t "networked: init rc" "$?" "0"
|
|
107
|
+
yes_if "networked: a Next.js app" 'jq -e ".dependencies | has(\"next\")" "$proj/package.json" >/dev/null'
|
|
108
|
+
yes_if "networked: shadcn/ui configured" '[ -f "$proj/components.json" ] && [ -f "$proj/components/ui/button.tsx" ] && [ -f "$proj/components/ui/card.tsx" ]'
|
|
109
|
+
yes_if "networked: Supabase client wired" '[ -f "$proj/lib/supabase/client.ts" ] && jq -e ".dependencies | has(\"@supabase/ssr\")" "$proj/package.json" >/dev/null'
|
|
110
|
+
yes_if "networked: the kit is installed" '[ -f "$proj/.claude/kit.config.json" ]'
|
|
111
|
+
yes_if "networked: no git repository (--no-github)" '[ ! -e "$proj/.git" ]'
|
|
112
|
+
for n in $NAMES; do yes_if "networked: $ENV_FILE names $n" 'grep -q "^$n=" "$proj/$ENV_FILE"'; done
|
|
113
|
+
echo "── networked: pnpm build (placeholder env values)"
|
|
114
|
+
( cd "$proj" && pnpm build )
|
|
115
|
+
t "networked: pnpm build rc" "$?" "0"
|
|
116
|
+
else
|
|
117
|
+
echo "skip: the networked build check (set INIT_E2E_NETWORK=1 to run it)"
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
[ "$fail" -eq 0 ] && echo "database-supabase-test: PASS" || echo "database-supabase-test: FAIL"
|
|
121
|
+
exit "$fail"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# docs-marketing-words-test.sh — two checks on the docs site's source (E426).
|
|
3
|
+
#
|
|
4
|
+
# 1. The Marketing word check. docs-site/src/integrations/marketing-words.mjs fails `astro build`
|
|
5
|
+
# when a page under marketing/ or <lang>/marketing/ says "worktree", "branch" or "PR"; the
|
|
6
|
+
# glossary page words-you-will-hear is the one exemption. Run here against fixtures, then
|
|
7
|
+
# against the real pages.
|
|
8
|
+
# 2. The old test address. Before cckit.dev the site was served from a vercel.app address. No
|
|
9
|
+
# docs page, component, style or config value may link or redirect to it.
|
|
10
|
+
#
|
|
11
|
+
# Network-free; fixtures under mktemp. Part 1 needs node and is skipped without it.
|
|
12
|
+
# Run: bash scripts/docs-marketing-words-test.sh
|
|
13
|
+
set -uo pipefail
|
|
14
|
+
ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
|
|
15
|
+
CHECK="$ROOT/docs-site/src/integrations/marketing-words.mjs"
|
|
16
|
+
|
|
17
|
+
fail=0
|
|
18
|
+
t() { # t <label> <got> <want>
|
|
19
|
+
if [ "$2" != "$3" ]; then echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; else echo "ok: $1"; fi
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT
|
|
23
|
+
|
|
24
|
+
# ── 1. the Marketing word check ─────────────────────────────────────────────────────────────────
|
|
25
|
+
if command -v node >/dev/null 2>&1; then
|
|
26
|
+
docs="$work/docs"
|
|
27
|
+
mkdir -p "$docs/marketing" "$docs/es/marketing" "$docs/tutorials"
|
|
28
|
+
printf 'Ask for a review of your draft.\n' > "$docs/marketing/index.mdx"
|
|
29
|
+
printf 'El borrador pasa a revision.\n' > "$docs/es/marketing/index.mdx"
|
|
30
|
+
# The glossary may use all three words; so may any page outside Marketing.
|
|
31
|
+
printf 'A draft is a branch. A review is a PR. A worktree is a folder.\n' > "$docs/marketing/words-you-will-hear.mdx"
|
|
32
|
+
printf 'Un borrador es un branch; la revision es un PR.\n' > "$docs/es/marketing/words-you-will-hear.mdx"
|
|
33
|
+
printf 'cckit start makes a worktree and a branch, then a PR.\n' > "$docs/tutorials/index.mdx"
|
|
34
|
+
|
|
35
|
+
out="$(node "$CHECK" "$docs" 2>&1)"; rc=$?
|
|
36
|
+
t "clean pages pass" "$rc" "0"
|
|
37
|
+
t "clean pages print nothing" "$out" ""
|
|
38
|
+
|
|
39
|
+
# A lowercase "pr" inside a word or a URL slug is not the word PR.
|
|
40
|
+
printf 'See [the tutorial](/development/issue-to-merged-pr/) to approve and improve.\n' > "$docs/marketing/slug.mdx"
|
|
41
|
+
out="$(node "$CHECK" "$docs" 2>&1)"; rc=$?
|
|
42
|
+
t "a pr slug and 'approve' are not hits" "$rc" "0"
|
|
43
|
+
|
|
44
|
+
printf 'line one\nOpen a PR from your branch.\n' > "$docs/marketing/bad.mdx"
|
|
45
|
+
printf 'Claude crea un worktree.\n' > "$docs/es/marketing/bad.mdx"
|
|
46
|
+
out="$(node "$CHECK" "$docs" 2>&1)"; rc=$?
|
|
47
|
+
t "banned words fail" "$rc" "1"
|
|
48
|
+
n="$(printf '%s\n' "$out" | grep -c 'marketing/bad.mdx:2: PR$')"
|
|
49
|
+
t "reports file:line: PR" "$n" "1"
|
|
50
|
+
n="$(printf '%s\n' "$out" | grep -c 'marketing/bad.mdx:2: branch$')"
|
|
51
|
+
t "reports file:line: branch" "$n" "1"
|
|
52
|
+
n="$(printf '%s\n' "$out" | grep -c 'es/marketing/bad.mdx:1: worktree$')"
|
|
53
|
+
t "checks the Spanish pages" "$n" "1"
|
|
54
|
+
n="$(printf '%s\n' "$out" | grep -c 'words-you-will-hear\|tutorials/')"
|
|
55
|
+
t "glossary and non-Marketing pages are exempt" "$n" "0"
|
|
56
|
+
|
|
57
|
+
out="$(node "$CHECK" 2>&1)"; rc=$?
|
|
58
|
+
t "the real Marketing pages pass (${out:-clean})" "$rc" "0"
|
|
59
|
+
else
|
|
60
|
+
echo "SKIP: node not available — Marketing word check not run"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# ── 2. nothing links or redirects to the old test address ───────────────────────────────────────
|
|
64
|
+
# Lines that are comments are skipped: a comment may name the old address to say it is retired.
|
|
65
|
+
hits="$(grep -rnE 'vercel\.app' "$ROOT/docs-site/src" "$ROOT/docs-site/public" \
|
|
66
|
+
"$ROOT/docs-site/astro.config.mjs" "$ROOT/docs-site/vercel.json" 2>/dev/null \
|
|
67
|
+
| grep -vE '^[^:]+:[0-9]+:[[:space:]]*(//|/\*|\*|#|\{/\*)' || true)"
|
|
68
|
+
t "no vercel.app address in the docs site (${hits:-none})" "$hits" ""
|
|
69
|
+
grep -q 'vercel\.app' "$ROOT/README.md" && readme=1 || readme=0
|
|
70
|
+
t "no vercel.app address in README.md" "$readme" "0"
|
|
71
|
+
|
|
72
|
+
[ "$fail" -eq 0 ] && echo "docs-marketing-words-test: all ok"
|
|
73
|
+
exit "$fail"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# docs-record-tables-test.sh — the docs site's record-card transform (#494).
|
|
3
|
+
#
|
|
4
|
+
# docs-site/src/lib/rehype-record-tables.mjs turns a Markdown table with three or more columns and a
|
|
5
|
+
# cell longer than 60 characters into a list of record cards. Checked here on hand-built trees:
|
|
6
|
+
# which tables convert, which stay tables, and what a card holds.
|
|
7
|
+
#
|
|
8
|
+
# Network-free. Needs node; skipped without it.
|
|
9
|
+
# Run: bash scripts/docs-record-tables-test.sh
|
|
10
|
+
set -uo pipefail
|
|
11
|
+
ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
|
|
12
|
+
PLUGIN="$ROOT/docs-site/src/lib/rehype-record-tables.mjs"
|
|
13
|
+
|
|
14
|
+
if ! command -v node >/dev/null 2>&1; then echo "skip: node not found"; exit 0; fi
|
|
15
|
+
|
|
16
|
+
work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT
|
|
17
|
+
cat > "$work/run.mjs" <<'JS'
|
|
18
|
+
const { default: plugin } = await import(process.argv[2]);
|
|
19
|
+
const T = (value) => ({ type: 'text', value });
|
|
20
|
+
const E = (tagName, children, properties = {}) => ({ type: 'element', tagName, properties, children });
|
|
21
|
+
const table = (head, rows, properties) =>
|
|
22
|
+
E('table', [
|
|
23
|
+
E('thead', [E('tr', head.map((h) => E('th', [T(h)])))]),
|
|
24
|
+
E('tbody', rows.map((r) => E('tr', r.map((c) => E('td', [T(c)]))))),
|
|
25
|
+
], properties);
|
|
26
|
+
const LONG = 'A read-only report at the start of each session: stale branches and leftover worktrees.';
|
|
27
|
+
const run = (node, wrap) => {
|
|
28
|
+
const tree = { type: 'root', children: [wrap ? wrap(node) : node] };
|
|
29
|
+
plugin()(tree);
|
|
30
|
+
return tree.children[0];
|
|
31
|
+
};
|
|
32
|
+
const flat = (n) => (n.type === 'text' ? n.value : (n.children || []).map(flat).join('|'));
|
|
33
|
+
let fail = 0;
|
|
34
|
+
const t = (label, got, want) => {
|
|
35
|
+
if (got !== want) { console.log(`FAIL: ${label} -> got '[${got}]' want '[${want}]'`); fail = 1; }
|
|
36
|
+
else console.log(`ok: ${label}`);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let out = run(table(['Event', 'Hook', 'What it does'], [['SessionStart', 'repo-hygiene.sh', LONG]]));
|
|
40
|
+
t('three columns with a long cell become records', out.tagName, 'ul');
|
|
41
|
+
t('the list carries the records class', out.properties.className[0], 'cckit-records');
|
|
42
|
+
t('one card per row', String(out.children.length), '1');
|
|
43
|
+
t('first cell is the title, its header the kicker, the rest labelled lines',
|
|
44
|
+
flat(out), `Event|SessionStart|Hook|repo-hygiene.sh|What it does|${LONG}`);
|
|
45
|
+
|
|
46
|
+
out = run(table(['Event', 'Hook', 'What it does'], [['SessionStart', 'repo-hygiene.sh', 'Short.']]));
|
|
47
|
+
t('three columns, short cells: stays a table', out.tagName, 'table');
|
|
48
|
+
|
|
49
|
+
out = run(table(['Flag', 'Effect'], [['--dry-run', LONG]]));
|
|
50
|
+
t('two columns: stays a table', out.tagName, 'table');
|
|
51
|
+
|
|
52
|
+
out = run(table(['Event', 'Hook', 'What it does'], [['a', 'b', LONG]], { className: ['legend'] }));
|
|
53
|
+
t('a table with its own class is left alone', out.tagName, 'table');
|
|
54
|
+
|
|
55
|
+
out = run(table(['Event', 'Hook', 'What it does'], [['a', 'b', LONG]]),
|
|
56
|
+
(n) => E('div', [n], { dataTable: 'grid' }));
|
|
57
|
+
t('a table inside data-table="grid" is left alone', out.children[0].tagName, 'table');
|
|
58
|
+
|
|
59
|
+
out = run(table(['Event', 'Hook', 'What it does'], [['a', 'b', LONG]]),
|
|
60
|
+
(n) => ({ type: 'mdxJsxFlowElement', name: 'div', attributes: [], children: [n] }));
|
|
61
|
+
t('a table inside an MDX wrapper is converted', out.children[0].tagName, 'ul');
|
|
62
|
+
|
|
63
|
+
out = run(table(['#', 'Bucket', 'What it reports'], [['1', 'Local undone work', LONG], ['2', 'PRs', 'x']]));
|
|
64
|
+
t('an index column is folded into the title',
|
|
65
|
+
flat(out.children[0]), `Bucket|1|Local undone work|What it reports|${LONG}`);
|
|
66
|
+
|
|
67
|
+
out = run(table(['Verb', 'Purpose', 'LLM mode'], [['cckit sync', LONG, '']]));
|
|
68
|
+
t('an empty cell makes no line', flat(out), `Verb|cckit sync|Purpose|${LONG}`);
|
|
69
|
+
|
|
70
|
+
process.exit(fail);
|
|
71
|
+
JS
|
|
72
|
+
node "$work/run.mjs" "$PLUGIN"
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# hook-adapter-test.sh — one set of hook scripts, two runtimes (E257.5, #262).
|
|
3
|
+
#
|
|
4
|
+
# Initializes a throwaway project with BOTH adapters, then drives each installed hook twice: once
|
|
5
|
+
# with the event JSON Claude Code sends (through .claude/hooks/, CLAUDE_PROJECT_DIR set) and once
|
|
6
|
+
# with the event JSON Codex sends (through the command registered in .codex/hooks.json, run from the
|
|
7
|
+
# session cwd with no CLAUDE_PROJECT_DIR). Asserts the same behavior on both:
|
|
8
|
+
# - a base-branch commit is blocked with a reason; a worktree commit passes
|
|
9
|
+
# - a raw `gh pr merge` is blocked; the pre-push gate reads either config location
|
|
10
|
+
# - ordinary mail never blocks Stop; steer mail blocks Stop once and never twice
|
|
11
|
+
# - in the combined install each message is delivered exactly once, whichever runtime asks first
|
|
12
|
+
#
|
|
13
|
+
# WHAT THIS IS NOT: the event JSON here is written from each runtime's hook documentation, not
|
|
14
|
+
# captured from a live session, and no agent process runs. It proves the scripts handle both
|
|
15
|
+
# documented shapes; it does not prove Codex fires the hooks or honours exit 2 (agent-compatibility
|
|
16
|
+
# .mdx records that as unverified).
|
|
17
|
+
# Run: bash scripts/hook-adapter-test.sh
|
|
18
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
19
|
+
set -u
|
|
20
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
21
|
+
fail=0
|
|
22
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
23
|
+
has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> '[$2]' lacks '[$3]'"; fail=1 ;; esac; }
|
|
24
|
+
command -v jq >/dev/null 2>&1 || { echo "SKIP: jq not available"; exit 0; }
|
|
25
|
+
command -v git >/dev/null 2>&1 || { echo "SKIP: git not available"; exit 0; }
|
|
26
|
+
# shellcheck source=/dev/null
|
|
27
|
+
. "$ROOT/scripts/lib/codex-hooks.sh"
|
|
28
|
+
|
|
29
|
+
tmp="$(cd "$(mktemp -d)" && pwd -P)"; trap 'rm -rf "$tmp"' EXIT
|
|
30
|
+
export KIT_MAIL_DIR="$tmp/mail"
|
|
31
|
+
# The mail hook calls `cckit`; give it this checkout's, not whatever is installed on the machine.
|
|
32
|
+
mkdir -p "$tmp/bin"
|
|
33
|
+
printf '#!/usr/bin/env bash\nexec "%s/bin/cckit" "$@"\n' "$ROOT" > "$tmp/bin/cckit"; chmod +x "$tmp/bin/cckit"
|
|
34
|
+
PATH="$tmp/bin:$PATH"; export PATH
|
|
35
|
+
|
|
36
|
+
P="$tmp/proj"; W="$tmp/wt"
|
|
37
|
+
mkdir -p "$P" && git -C "$P" init -q -b main \
|
|
38
|
+
&& git -C "$P" config user.email kit-test@example.com && git -C "$P" config user.name kit-test \
|
|
39
|
+
&& git -C "$P" remote add origin git@github.com:example/fx.git # the mailbox is keyed by the remote slug
|
|
40
|
+
KIT_INIT_PREFLIGHT=0 KIT_BASE_BRANCH=main CLAUDE_PLUGIN_ROOT="$ROOT" bash "$ROOT/scripts/init.sh" \
|
|
41
|
+
--profile minimal --adapter both --target "$P" --repo example/fx --owner-login example >/dev/null 2>&1 </dev/null \
|
|
42
|
+
|| { echo "FAIL: init --adapter both exited non-zero"; exit 1; }
|
|
43
|
+
git -C "$P" add -A >/dev/null 2>&1 && git -C "$P" commit -q -m scaffold >/dev/null 2>&1
|
|
44
|
+
git -C "$P" worktree add -q -b feat/1-x "$W" main >/dev/null 2>&1 || { echo "FAIL: could not add the worktree"; exit 1; }
|
|
45
|
+
|
|
46
|
+
# ── event JSON, per runtime (documented fields) ────────────────────────────────────────────────
|
|
47
|
+
ev() { # ev <claude|codex> <event> <cwd> [command | argv-json] -> the event document on stdout
|
|
48
|
+
local rt="$1" e="$2" cwd="$3" cmd="${4:-}" tool='{}'
|
|
49
|
+
if [ -n "$cmd" ]; then
|
|
50
|
+
case "$cmd" in
|
|
51
|
+
'['*) tool="$(jq -cn --argjson c "$cmd" '{tool_name:"Bash",tool_input:{command:$c}}')" ;;
|
|
52
|
+
*) tool="$(jq -cn --arg c "$cmd" '{tool_name:"Bash",tool_input:{command:$c}}')" ;;
|
|
53
|
+
esac
|
|
54
|
+
fi
|
|
55
|
+
if [ "$rt" = claude ]; then
|
|
56
|
+
jq -cn --arg e "$e" --arg d "$cwd" --argjson t "$tool" \
|
|
57
|
+
'{session_id:"s1",transcript_path:"/tmp/t.jsonl",cwd:$d,permission_mode:"default",hook_event_name:$e} + $t
|
|
58
|
+
+ (if $e == "Stop" then {stop_hook_active:false} else {} end)'
|
|
59
|
+
else
|
|
60
|
+
jq -cn --arg e "$e" --arg d "$cwd" --argjson t "$tool" \
|
|
61
|
+
'{session_id:"s1",transcript_path:null,cwd:$d,hook_event_name:$e,model:"m",turn_id:"t1"} + $t
|
|
62
|
+
+ (if ($t | has("tool_name")) then {tool_use_id:"u1"} else {} end)
|
|
63
|
+
+ (if $e == "Stop" then {stop_hook_active:false,last_assistant_message:"done"} else {} end)'
|
|
64
|
+
fi
|
|
65
|
+
}
|
|
66
|
+
# fire <claude|codex> <script> <event> <cwd> [command] -> runs the hook the way that runtime would.
|
|
67
|
+
# Sets OUT (stdout), ERR (stderr), RC.
|
|
68
|
+
fire() {
|
|
69
|
+
local rt="$1" script="$2" e="$3" cwd="$4" cmd="${5:-}" doc
|
|
70
|
+
doc="$(ev "$rt" "$e" "$cwd" "$cmd")"
|
|
71
|
+
if [ "$rt" = claude ]; then
|
|
72
|
+
OUT="$(cd "$cwd" && printf '%s' "$doc" | CLAUDE_PROJECT_DIR="$P" bash "$P/.claude/hooks/$script" 2>"$tmp/err")"; RC=$?
|
|
73
|
+
else
|
|
74
|
+
# Codex: the REGISTERED command string, from the session cwd, with no Claude variable.
|
|
75
|
+
OUT="$(cd "$cwd" && printf '%s' "$doc" | env -u CLAUDE_PROJECT_DIR bash -c "$(codex_hooks_command "$script")" 2>"$tmp/err")"; RC=$?
|
|
76
|
+
fi
|
|
77
|
+
ERR="$(cat "$tmp/err")"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# ── registration ───────────────────────────────────────────────────────────────────────────────
|
|
81
|
+
HJ="$P/.codex/hooks.json"
|
|
82
|
+
t "codex: hooks.json written" "$([ -f "$HJ" ] && echo yes || echo no)" "yes"
|
|
83
|
+
t "codex: no absolute machine path" "$(grep -rlF "$tmp" "$P/.codex" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
84
|
+
t "codex: no command starts at / or ~" "$(jq -r '.hooks[][].hooks[].command' "$HJ" | grep -cE '(^|[" ])(/|~)')" "0"
|
|
85
|
+
t "codex: every registered script is installed in the worktree" \
|
|
86
|
+
"$(jq -r '.hooks[][].hooks[].command' "$HJ" | sed 's|.*/\.codex/hooks/||; s|"$||' | sort -u | while IFS= read -r s; do [ -x "$W/.codex/hooks/$s" ] || echo "$s"; done | tr '\n' ' ')" ""
|
|
87
|
+
t "codex: guards on PreToolUse Bash" "$(jq -r '[.hooks.PreToolUse[] | select(.matcher == "Bash")] | length' "$HJ")" "2"
|
|
88
|
+
t "codex: mail on four events" "$(jq -r --arg c "$(codex_hooks_command kit-mail-check.sh)" '[.hooks | to_entries[] | select([.value[].hooks[].command] | index($c)) | .key] | sort | join(" ")' "$HJ")" \
|
|
89
|
+
"PostToolUse SessionStart Stop UserPromptSubmit"
|
|
90
|
+
# shellcheck disable=SC2016
|
|
91
|
+
MAILCMD='bash "$CLAUDE_PROJECT_DIR/.claude/hooks/kit-mail-check.sh"'
|
|
92
|
+
# The mail registrations of a settings file: {event: [groups running the mail command]}.
|
|
93
|
+
MAILSEL='[.hooks | to_entries[] | {(.key): [.value[] | select([.hooks[].command] | index($c))]} | select(.[] | length > 0)] | add'
|
|
94
|
+
t "claude: mail hook installed" "$([ -x "$P/.claude/hooks/kit-mail-check.sh" ] && echo yes || echo no)" "yes"
|
|
95
|
+
t "claude: mail wired on four events (tracked settings.json)" \
|
|
96
|
+
"$(jq -r --arg c "$MAILCMD" '[.hooks | to_entries[] | select([.value[].hooks[].command] | index($c)) | .key] | sort | join(" ")' "$P/.claude/settings.json")" \
|
|
97
|
+
"PostToolUse SessionStart Stop UserPromptSubmit"
|
|
98
|
+
t "claude: generated mail entries equal cckit's own .claude/settings.json" \
|
|
99
|
+
"$(jq -cS --arg c "$MAILCMD" "$MAILSEL" "$P/.claude/settings.json")" \
|
|
100
|
+
"$(jq -cS --arg c "$MAILCMD" "$MAILSEL" "$ROOT/.claude/settings.json")"
|
|
101
|
+
t "both: one mail script, two installs, same bytes" \
|
|
102
|
+
"$(cmp -s "$P/.claude/hooks/kit-mail-check.sh" "$P/.codex/hooks/kit-mail-check.sh" && echo same || echo differs)" "same"
|
|
103
|
+
|
|
104
|
+
# ── base-branch commit guard ───────────────────────────────────────────────────────────────────
|
|
105
|
+
for rt in claude codex; do
|
|
106
|
+
fire "$rt" guard-base-branch-commit.sh PreToolUse "$P" 'git commit -m x'
|
|
107
|
+
t "$rt: base-branch commit blocked (exit 2)" "$RC" "2"
|
|
108
|
+
has "$rt: the block carries a reason" "$ERR" "BLOCKED: direct commit to 'main'"
|
|
109
|
+
fire "$rt" guard-base-branch-commit.sh PreToolUse "$W" 'git commit -m x'
|
|
110
|
+
t "$rt: worktree commit passes" "$RC" "0"
|
|
111
|
+
fire "$rt" guard-base-branch-commit.sh PreToolUse "$P" "git -C $W commit -m x"
|
|
112
|
+
t "$rt: git -C <worktree> commit passes" "$RC" "0"
|
|
113
|
+
fire "$rt" guard-base-branch-commit.sh PreToolUse "$P" "cd $W && git commit -m x"
|
|
114
|
+
t "$rt: cd <worktree> && commit passes" "$RC" "0"
|
|
115
|
+
fire "$rt" guard-base-branch-commit.sh PreToolUse "$W" "git -C $P commit -m x"
|
|
116
|
+
t "$rt: git -C <base checkout> commit blocked" "$RC" "2"
|
|
117
|
+
fire "$rt" guard-base-branch-commit.sh PreToolUse "$P" 'git log --oneline'
|
|
118
|
+
t "$rt: a non-commit passes" "$RC" "0"
|
|
119
|
+
fire "$rt" guard-raw-git-ops.sh PreToolUse "$P" 'gh pr merge 3 --squash'
|
|
120
|
+
t "$rt: raw gh pr merge blocked (exit 2)" "$RC" "2"
|
|
121
|
+
has "$rt: raw-git block names the verb" "$ERR" "cckit merge"
|
|
122
|
+
fire "$rt" guard-raw-git-ops.sh PreToolUse "$P" 'gh pr view 3'
|
|
123
|
+
t "$rt: read-only gh passes" "$RC" "0"
|
|
124
|
+
fire "$rt" repo-hygiene.sh SessionStart "$W"
|
|
125
|
+
t "$rt: repo-hygiene never fails the session" "$RC" "0"
|
|
126
|
+
fire "$rt" kit_version_check.sh SessionStart "$W"
|
|
127
|
+
t "$rt: version check never fails the session" "$RC" "0"
|
|
128
|
+
done
|
|
129
|
+
# An argv-array command (a shell tool may send one) is still read.
|
|
130
|
+
fire codex guard-base-branch-commit.sh PreToolUse "$P" '["bash","-lc","git commit -m x"]'
|
|
131
|
+
t "codex: argv-array command blocked on the base branch" "$RC" "2"
|
|
132
|
+
fire codex guard-raw-git-ops.sh PreToolUse "$P" '["bash","-lc","gh pr merge 3"]'
|
|
133
|
+
t "codex: argv-array raw merge blocked" "$RC" "2"
|
|
134
|
+
# The event cwd beats CLAUDE_PROJECT_DIR (always the main checkout): a session sitting in a worktree
|
|
135
|
+
# commits without naming a directory, and is not false-blocked.
|
|
136
|
+
OUT="$(cd "$W" && ev claude PreToolUse "$W" 'git commit -m x' | CLAUDE_PROJECT_DIR="$P" bash "$P/.claude/hooks/guard-base-branch-commit.sh" 2>/dev/null)"
|
|
137
|
+
t "claude: event cwd wins over CLAUDE_PROJECT_DIR" "$?" "0"
|
|
138
|
+
|
|
139
|
+
# ── pre-push gate: either config location ──────────────────────────────────────────────────────
|
|
140
|
+
GATE="$ROOT/templates/hooks/prepush_gate.sh.tmpl"
|
|
141
|
+
gate() { # gate <runtime> <dir> <command> -> the .continue value
|
|
142
|
+
( cd "$2" && ev "$1" PreToolUse "$2" "$3" | bash "$GATE" 2>/dev/null ) | jq -r '.continue'
|
|
143
|
+
}
|
|
144
|
+
cx="$tmp/codex-only"; mkdir -p "$cx"
|
|
145
|
+
printf '{"adapters":["codex"],"prePush":{"enabled":true,"command":"false"}}\n' > "$cx/cckit.config.json"
|
|
146
|
+
cl="$tmp/claude-only"; mkdir -p "$cl/.claude"
|
|
147
|
+
printf '{"prePush":{"enabled":true,"command":"false"}}\n' > "$cl/.claude/kit.config.json"
|
|
148
|
+
t "codex-only: failing check stops the push (root config)" "$(gate codex "$cx" 'git push origin x')" "false"
|
|
149
|
+
t "claude: failing check stops the push" "$(gate claude "$cl" 'git push origin x')" "false"
|
|
150
|
+
t "codex-only: a non-push passes" "$(gate codex "$cx" 'git status')" "true"
|
|
151
|
+
t "codex-only: argv-array push is gated" "$(gate codex "$cx" '["bash","-lc","git push origin x"]')" "false"
|
|
152
|
+
printf '{"adapters":["codex"],"prePush":{"enabled":true,"command":"true"}}\n' > "$cx/cckit.config.json"
|
|
153
|
+
t "codex-only: passing check lets the push through" "$(gate codex "$cx" 'git push origin x')" "true"
|
|
154
|
+
|
|
155
|
+
# ── session mail ───────────────────────────────────────────────────────────────────────────────
|
|
156
|
+
send() { ( cd "$P" && cckit msg send "$@" >/dev/null 2>&1 ); }
|
|
157
|
+
ctx() { printf '%s' "$OUT" | jq -r '.hookSpecificOutput.additionalContext // empty' 2>/dev/null; }
|
|
158
|
+
|
|
159
|
+
for first in claude codex; do
|
|
160
|
+
if [ "$first" = claude ]; then second=codex; else second=claude; fi
|
|
161
|
+
# ordinary mail: never blocks Stop, delivered once
|
|
162
|
+
send feat/1-x "note for $first"
|
|
163
|
+
fire "$first" kit-mail-check.sh Stop "$W"; t "$first first: ordinary mail does not block Stop" "$OUT" ""
|
|
164
|
+
fire "$second" kit-mail-check.sh Stop "$W"; t "$second second: ordinary mail does not block Stop" "$OUT" ""
|
|
165
|
+
fire "$first" kit-mail-check.sh PostToolUse "$W" 'ls'
|
|
166
|
+
has "$first first: ordinary mail delivered between tool calls" "$(ctx)" "note for $first"
|
|
167
|
+
t "$first first: delivery names its event" "$(printf '%s' "$OUT" | jq -r '.hookSpecificOutput.hookEventName')" "PostToolUse"
|
|
168
|
+
fire "$second" kit-mail-check.sh PostToolUse "$W" 'ls'
|
|
169
|
+
t "$second second: the same message is not delivered again" "$OUT" ""
|
|
170
|
+
fire "$second" kit-mail-check.sh UserPromptSubmit "$W"
|
|
171
|
+
t "$second second: nor on the next prompt" "$OUT" ""
|
|
172
|
+
|
|
173
|
+
# steer mail: blocks Stop once, never twice, in either runtime
|
|
174
|
+
send feat/1-x --steer "steer for $first"
|
|
175
|
+
fire "$first" kit-mail-check.sh Stop "$W"
|
|
176
|
+
t "$first first: steer blocks Stop" "$(printf '%s' "$OUT" | jq -r '.decision')" "block"
|
|
177
|
+
has "$first first: the block reason is the mail" "$(printf '%s' "$OUT" | jq -r '.reason')" "steer for $first"
|
|
178
|
+
fire "$first" kit-mail-check.sh Stop "$W"; t "$first first: the second Stop is not blocked" "$OUT" ""
|
|
179
|
+
fire "$second" kit-mail-check.sh Stop "$W"; t "$second second: Stop is not blocked by the same steer" "$OUT" ""
|
|
180
|
+
fire "$second" kit-mail-check.sh SessionStart "$W"; t "$second second: steer is not re-delivered at start" "$OUT" ""
|
|
181
|
+
done
|
|
182
|
+
# cold start + next prompt deliver in both, and the session in the main checkout is a different mailbox
|
|
183
|
+
for rt in claude codex; do
|
|
184
|
+
send feat/1-x "cold $rt"
|
|
185
|
+
fire "$rt" kit-mail-check.sh SessionStart "$P"; t "$rt: another branch's mail is not delivered here" "$OUT" ""
|
|
186
|
+
fire "$rt" kit-mail-check.sh SessionStart "$W"; has "$rt: SessionStart delivers" "$(ctx)" "cold $rt"
|
|
187
|
+
send feat/1-x "prompt $rt"
|
|
188
|
+
fire "$rt" kit-mail-check.sh UserPromptSubmit "$W"; has "$rt: UserPromptSubmit delivers" "$(ctx)" "prompt $rt"
|
|
189
|
+
done
|
|
190
|
+
t "nothing left unread" "$(find "$KIT_MAIL_DIR" -path '*/new/*' -type f | wc -l | tr -d ' ')" "0"
|
|
191
|
+
|
|
192
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (hook-adapter)"
|
|
193
|
+
exit "$fail"
|