@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,343 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# integration-install-test.sh — covers the shared installer runner (E303.3),
|
|
4
|
+
# scripts/lib/integration-install.sh: candidate order, the ~/.local/bin lookup, the no-op second
|
|
5
|
+
# run, KIT_DRY_RUN, the consent gate and the wire command.
|
|
6
|
+
#
|
|
7
|
+
# Hermetic: the package managers are STUBS on a sealed PATH (a dir of symlinks to the handful of
|
|
8
|
+
# real tools the runner needs, plus the stub dir), HOME is a throwaway dir, and consent lives in a
|
|
9
|
+
# throwaway state dir — so no real uv/pipx/npm on this machine is ever reached and nothing is
|
|
10
|
+
# installed. Run: bash scripts/lib/integration-install-test.sh
|
|
11
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
12
|
+
set -u
|
|
13
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
14
|
+
# shellcheck source=/dev/null
|
|
15
|
+
. "$ROOT/scripts/lib/test-env.sh" && test_env_seal
|
|
16
|
+
LIB="$ROOT/scripts/lib"
|
|
17
|
+
fail=0
|
|
18
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
19
|
+
rc() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> rc '$2' want '$3'"; fail=1; fi; }
|
|
20
|
+
has() { if grep -qF -- "$3" <<<"$2"; then echo "ok: $1"; else echo "FAIL: $1 -> '$3' not in: $2"; fail=1; fi; }
|
|
21
|
+
hasnt() { if grep -qF -- "$3" <<<"$2"; then echo "FAIL: $1 -> '$3' found in: $2"; fail=1; else echo "ok: $1"; fi; }
|
|
22
|
+
|
|
23
|
+
command -v jq >/dev/null 2>&1 || { echo "integration-install-test: jq absent — skipping (dependency-light gate)"; exit 0; }
|
|
24
|
+
|
|
25
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
26
|
+
tmp="$(cd "$tmp" && pwd -P)"
|
|
27
|
+
|
|
28
|
+
# ── the sealed PATH: real tools the runner needs, and nothing that is a package manager ────────
|
|
29
|
+
sealed="$tmp/sealed"; mkdir -p "$sealed"
|
|
30
|
+
for tool in sh bash jq git grep sed awk sort cat mkdir rm dirname basename chmod ls pwd env tr head find cp; do
|
|
31
|
+
src="$(command -v "$tool" 2>/dev/null)" || continue
|
|
32
|
+
case "$src" in /*) ln -s "$src" "$sealed/$tool" ;; esac
|
|
33
|
+
done
|
|
34
|
+
stubs="$tmp/stubs"; mkdir -p "$stubs"
|
|
35
|
+
log="$tmp/calls.log"; : > "$log"
|
|
36
|
+
|
|
37
|
+
# stub <manager> <works|fails|lies> — every stub appends its argv to the call log.
|
|
38
|
+
# works: drops the tool into $HOME/.local/bin (off PATH, where uv and pipx put it) and exits 0
|
|
39
|
+
# fails: exits 1 lies: exits 0 but installs nothing
|
|
40
|
+
stub() {
|
|
41
|
+
{
|
|
42
|
+
printf '#!/bin/sh\n'
|
|
43
|
+
printf 'echo "%s $*" >> "%s"\n' "$1" "$log"
|
|
44
|
+
case "$2" in
|
|
45
|
+
works) printf 'mkdir -p "$HOME/.local/bin"\n'
|
|
46
|
+
printf 'printf "#!/bin/sh\\necho \\"fixture-tool \\$* in \\$(pwd -P)\\" >> %s\\n" > "$HOME/.local/bin/fixture-tool"\n' "$log"
|
|
47
|
+
printf 'chmod +x "$HOME/.local/bin/fixture-tool"\n' ;;
|
|
48
|
+
fails) printf 'exit 1\n' ;;
|
|
49
|
+
lies) printf 'exit 0\n' ;;
|
|
50
|
+
esac
|
|
51
|
+
} > "$stubs/$1"
|
|
52
|
+
chmod +x "$stubs/$1"
|
|
53
|
+
}
|
|
54
|
+
unstub() { rm -f "$stubs"/*; }
|
|
55
|
+
|
|
56
|
+
fx="$tmp/integrations"; mkdir -p "$fx"
|
|
57
|
+
cp "$ROOT/integrations/integration.schema.json" "$fx/"
|
|
58
|
+
cat > "$fx/fixture-tool.json" <<'JSON'
|
|
59
|
+
{
|
|
60
|
+
"id": "fixture-tool",
|
|
61
|
+
"label": "Fixture Tool",
|
|
62
|
+
"summary": "A tool that exists only in this test.",
|
|
63
|
+
"config": { "key": "codeGraph.provider", "value": "fixture-graph" },
|
|
64
|
+
"detect": { "run": "fixture-tool --version" },
|
|
65
|
+
"install": [
|
|
66
|
+
{ "manager": "npm", "run": "npm install -g fixture-tool" },
|
|
67
|
+
{ "manager": "pnpm", "run": "pnpm add -g fixture-tool" },
|
|
68
|
+
{ "manager": "pipx", "run": "pipx install fixture-tool" },
|
|
69
|
+
{ "manager": "uv", "run": "uv tool install fixture-tool" }
|
|
70
|
+
],
|
|
71
|
+
"wire": {
|
|
72
|
+
"run": "fixture-tool init",
|
|
73
|
+
"declined": { "--no-statusline": "cckit owns the statusline.", "--no-hooks": "cckit owns the hooks." }
|
|
74
|
+
},
|
|
75
|
+
"verify": { "run": "fixture-tool check" },
|
|
76
|
+
"docs": "https://example.invalid/fixture-tool#readme",
|
|
77
|
+
"attribution": {
|
|
78
|
+
"author": "Example Org", "homepage": "https://example.invalid/fixture-tool",
|
|
79
|
+
"affiliated": false, "notice": "cckit is not affiliated with Example Org."
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
JSON
|
|
83
|
+
desc="$fx/fixture-tool.json"
|
|
84
|
+
proj="$tmp/proj"; mkdir -p "$proj"
|
|
85
|
+
|
|
86
|
+
# run <home> <shell-snippet> -> the snippet with the lib sourced, on the sealed PATH, with HOME and
|
|
87
|
+
# the state dir pointed at throwaway dirs. stdout = the runner's stdout; stderr is kept in $tmp/err.
|
|
88
|
+
run() {
|
|
89
|
+
local home="$1"; shift
|
|
90
|
+
mkdir -p "$home"
|
|
91
|
+
( PATH="$stubs:$sealed"; HOME="$home"; export PATH HOME
|
|
92
|
+
export KIT_INTEGRATIONS_DIR="$fx" KIT_STATE_DIR="$home/state"
|
|
93
|
+
# shellcheck source=/dev/null
|
|
94
|
+
. "$LIB/integration-install.sh"
|
|
95
|
+
eval "$*" ) 2> "$tmp/err"
|
|
96
|
+
}
|
|
97
|
+
# calls -> the package-manager invocations, in order. wired -> the tool's own `init` invocations.
|
|
98
|
+
# (The installed fixture tool logs too, every time detect.run probes it; those are not counted.)
|
|
99
|
+
calls() { grep -E '^(npm|pnpm|pipx|uv|npx) ' "$log" | tr '\n' '|'; }
|
|
100
|
+
wired() { grep -E '^fixture-tool init' "$log" | tr '\n' '|'; }
|
|
101
|
+
|
|
102
|
+
# ── 1. no consent: nothing installs, and the exit code does not change ─────────────────────────
|
|
103
|
+
stub npm works; stub pipx works; stub uv works
|
|
104
|
+
h="$tmp/h1"
|
|
105
|
+
out="$(run "$h" "integration_install '$desc' '$proj'")"; r=$?
|
|
106
|
+
rc "no consent -> rc 0" "$r" "0"
|
|
107
|
+
t "no consent -> status" "$out" "no-consent"
|
|
108
|
+
t "no consent -> no manager was called" "$(calls)" ""
|
|
109
|
+
t "no consent -> no binary" "$(ls "$h/.local/bin" 2>/dev/null)" ""
|
|
110
|
+
has "no consent -> stderr names the consent file" "$(cat "$tmp/err")" "$h/state/consent"
|
|
111
|
+
# KIT_ASSUME_YES is not consent.
|
|
112
|
+
out="$(run "$h" "KIT_ASSUME_YES=1 integration_install '$desc' '$proj'")"
|
|
113
|
+
t "KIT_ASSUME_YES is not consent" "$out|$(calls)" "no-consent|"
|
|
114
|
+
|
|
115
|
+
# ── 2. consent is one line in the state dir kit_state_dir resolves ─────────────────────────────
|
|
116
|
+
run "$h" "integration_consent_has fixture-tool '$proj'"; rc "consent absent -> rc 1" "$?" "1"
|
|
117
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"; rc "record consent -> rc 0" "$?" "0"
|
|
118
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"; rc "record twice -> rc 0" "$?" "0"
|
|
119
|
+
t "consent file holds one line" "$(cat "$h/state/consent")" "install:fixture-tool"
|
|
120
|
+
run "$h" "integration_consent_has fixture-tool '$proj'"; rc "consent recorded -> rc 0" "$?" "0"
|
|
121
|
+
run "$h" "integration_consent_has fixture '$proj'"; rc "a prefix of a recorded id is not consent" "$?" "1"
|
|
122
|
+
run "$h" "integration_consent_record '../x' '$proj'"; rc "an id that is no id is refused" "$?" "1"
|
|
123
|
+
# Without the override the file is <repo>/.cckit/consent, the same from a subdirectory.
|
|
124
|
+
if command -v git >/dev/null 2>&1; then
|
|
125
|
+
grepo="$tmp/grepo"; mkdir -p "$grepo/pkg/deep"; git -C "$grepo" init -q 2>/dev/null
|
|
126
|
+
got="$(run "$tmp/h-git" "unset KIT_STATE_DIR; integration_consent_record fixture-tool '$grepo/pkg/deep' && integration_consent_file '$grepo'")"
|
|
127
|
+
t "consent resolves through kit_state_dir" "$got" "$grepo/.cckit/consent"
|
|
128
|
+
t "recorded from a subdirectory, stored at the repo root" "$(cat "$grepo/.cckit/consent" 2>/dev/null)" "install:fixture-tool"
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
# ── 3. candidates are tried in descriptor order; the first that works wins ─────────────────────
|
|
132
|
+
# npm is first and fails, pnpm is not on the machine, pipx works, uv would work but is never tried.
|
|
133
|
+
unstub; stub npm fails; stub pipx works; stub uv works; : > "$log"
|
|
134
|
+
out="$(run "$h" "integration_install '$desc' '$proj'")"; r=$?
|
|
135
|
+
rc "install -> rc 0" "$r" "0"
|
|
136
|
+
t "install -> status names the winner" "$out" "installed pipx"
|
|
137
|
+
t "order: npm, then pipx; pnpm skipped (absent); uv never run" "$(calls)" "npm install -g fixture-tool|pipx install fixture-tool|"
|
|
138
|
+
# the binary landed in ~/.local/bin, which is NOT on PATH — it is still resolved
|
|
139
|
+
t "binary off PATH is resolved" "$(run "$h" "integration_bin '$desc'")" "$h/.local/bin/fixture-tool"
|
|
140
|
+
run "$h" "integration_detect '$desc'"; rc "detect sees the off-PATH binary" "$?" "0"
|
|
141
|
+
run "$h" "command -v fixture-tool >/dev/null 2>&1"; rc "(it really is off PATH)" "$?" "1"
|
|
142
|
+
|
|
143
|
+
# ── 4. a second run is a no-op ─────────────────────────────────────────────────────────────────
|
|
144
|
+
: > "$log"
|
|
145
|
+
out="$(run "$h" "integration_install '$desc' '$proj'")"; r=$?
|
|
146
|
+
t "second run -> present, rc 0" "$out|$r" "present|0"
|
|
147
|
+
t "second run -> no manager was called" "$(calls)" ""
|
|
148
|
+
|
|
149
|
+
# ── 5. the first candidate wins when it works ──────────────────────────────────────────────────
|
|
150
|
+
unstub; stub npm works; stub pipx works; : > "$log"; h="$tmp/h5"
|
|
151
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
152
|
+
out="$(run "$h" "integration_install '$desc' '$proj'")"
|
|
153
|
+
t "first candidate works -> it alone runs" "$out|$(calls)" "installed npm|npm install -g fixture-tool|"
|
|
154
|
+
|
|
155
|
+
# ── 6. a candidate that exits 0 without installing is not trusted ──────────────────────────────
|
|
156
|
+
unstub; stub npm lies; stub uv works; : > "$log"; h="$tmp/h6"
|
|
157
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
158
|
+
out="$(run "$h" "integration_install '$desc' '$proj'")"
|
|
159
|
+
t "exit 0 with no binary -> next candidate" "$out|$(calls)" "installed uv|npm install -g fixture-tool|uv tool install fixture-tool|"
|
|
160
|
+
# ... unless the descriptor says the candidate leaves no binary (npx)
|
|
161
|
+
mkdir -p "$tmp/npx"; cp "$fx/integration.schema.json" "$tmp/npx/"
|
|
162
|
+
jq '.install = [{"manager":"npx","run":"npx -y fixture-tool","resident":false}]' "$desc" > "$tmp/npx/fixture-tool.json"
|
|
163
|
+
unstub; stub npx lies; : > "$log"; h="$tmp/h6b"
|
|
164
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
165
|
+
out="$(run "$h" "KIT_INTEGRATIONS_DIR='$tmp/npx' integration_install '$tmp/npx/fixture-tool.json' '$proj'")"
|
|
166
|
+
t "resident:false -> the exit code is the evidence" "$out" "installed npx"
|
|
167
|
+
|
|
168
|
+
# ── 7. every candidate fails, or none is on the machine -> failed, rc 1 ────────────────────────
|
|
169
|
+
unstub; stub npm fails; stub pipx lies; : > "$log"; h="$tmp/h7"
|
|
170
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
171
|
+
out="$(run "$h" "integration_install '$desc' '$proj'")"; r=$?
|
|
172
|
+
t "all candidates fail -> failed, rc 1" "$out|$r" "failed|1"
|
|
173
|
+
has "all candidates fail -> the manual command is named" "$(cat "$tmp/err")" "npm install -g fixture-tool"
|
|
174
|
+
unstub; : > "$log"
|
|
175
|
+
out="$(run "$h" "integration_install '$desc' '$proj'")"; r=$?
|
|
176
|
+
t "no manager on PATH -> failed, rc 1" "$out|$r" "failed|1"
|
|
177
|
+
has "no manager on PATH -> the managers are named" "$(cat "$tmp/err")" "npm, pnpm, pipx, uv"
|
|
178
|
+
|
|
179
|
+
# ── 7b. bootstrap: with NO candidate manager on the machine, a candidate's `bootstrap` brings one ──
|
|
180
|
+
# brew is a stub whose `install pipx` puts a working pipx on PATH. The bootstrap sits on the THIRD
|
|
181
|
+
# candidate: it is the absence of every manager, not the position, that triggers it.
|
|
182
|
+
mkdir -p "$tmp/boot"; cp "$fx/integration.schema.json" "$tmp/boot/"
|
|
183
|
+
jq '.install[2].bootstrap = {"manager":"brew","run":"brew install pipx"}' "$desc" > "$tmp/boot/fixture-tool.json"
|
|
184
|
+
bdesc="$tmp/boot/fixture-tool.json"
|
|
185
|
+
stub pipx works; mv "$stubs/pipx" "$tmp/pipx.real"
|
|
186
|
+
brew_stub() {
|
|
187
|
+
{ printf '#!/bin/sh\necho "brew $*" >> "%s"\n' "$log"
|
|
188
|
+
printf 'cp "%s" "%s/pipx"\n' "$tmp/pipx.real" "$stubs"; } > "$stubs/brew"; chmod +x "$stubs/brew"
|
|
189
|
+
}
|
|
190
|
+
bcalls() { grep -E '^(brew|npm|pnpm|pipx|uv) ' "$log" | tr '\n' '|'; }
|
|
191
|
+
unstub; brew_stub; : > "$log"; h="$tmp/h7b"
|
|
192
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
193
|
+
out="$(run "$h" "KIT_INTEGRATIONS_DIR='$tmp/boot' integration_install '$bdesc' '$proj'")"
|
|
194
|
+
t "no manager on PATH -> bootstrap, then the candidate it enabled" "$out|$(bcalls)" "installed pipx|brew install pipx|pipx install fixture-tool|"
|
|
195
|
+
# a machine that already holds ANY listed manager is never bootstrapped
|
|
196
|
+
unstub; brew_stub; stub uv works; : > "$log"; h="$tmp/h7c"
|
|
197
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
198
|
+
out="$(run "$h" "KIT_INTEGRATIONS_DIR='$tmp/boot' integration_install '$bdesc' '$proj'")"
|
|
199
|
+
t "a manager is already there -> no bootstrap" "$out|$(bcalls)" "installed uv|uv tool install fixture-tool|"
|
|
200
|
+
# the two gates come first: no consent and dry-run never run the bootstrap
|
|
201
|
+
unstub; brew_stub; : > "$log"
|
|
202
|
+
out="$(run "$tmp/h7d" "KIT_INTEGRATIONS_DIR='$tmp/boot' integration_install '$bdesc' '$proj'")"
|
|
203
|
+
t "bootstrap is behind the consent gate" "$out|$(bcalls)" "no-consent|"
|
|
204
|
+
out="$(run "$tmp/h7d" "KIT_INTEGRATIONS_DIR='$tmp/boot' KIT_DRY_RUN=1 integration_install '$bdesc' '$proj'")"
|
|
205
|
+
t "bootstrap is behind the dry-run gate" "$out|$(bcalls)" "dry-run|"
|
|
206
|
+
has "dry-run plan names the bootstrap" "$(cat "$tmp/err")" "bootstrap, because none of those managers is on PATH: brew install pipx (needs brew)"
|
|
207
|
+
# the bootstrap's own manager is absent -> nothing to try, the plain failure
|
|
208
|
+
unstub; : > "$log"; h="$tmp/h7e"
|
|
209
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
210
|
+
out="$(run "$h" "KIT_INTEGRATIONS_DIR='$tmp/boot' integration_install '$bdesc' '$proj'")"; r=$?
|
|
211
|
+
t "no manager and no brew -> failed, rc 1" "$out|$r|$(bcalls)" "failed|1|"
|
|
212
|
+
|
|
213
|
+
# ── 7c. detect.bin names the binary when detect.run does not start with it ─────────────────────
|
|
214
|
+
mkdir -p "$tmp/dbin"; cp "$fx/integration.schema.json" "$tmp/dbin/"
|
|
215
|
+
jq '.detect = {"run":"command -v fixture-tool","bin":"fixture-tool"}' "$desc" > "$tmp/dbin/fixture-tool.json"
|
|
216
|
+
h="$tmp/h1" # h1: the tool was installed into ~/.local/bin by section 3
|
|
217
|
+
t "detect.bin -> the binary is resolved off PATH" "$(run "$h" "integration_bin '$tmp/dbin/fixture-tool.json'")" "$h/.local/bin/fixture-tool"
|
|
218
|
+
run "$h" "integration_detect '$tmp/dbin/fixture-tool.json'"; rc "a 'command -v' probe sees the off-PATH binary" "$?" "0"
|
|
219
|
+
run "$tmp/h7e" "integration_detect '$tmp/dbin/fixture-tool.json'"; rc "a 'command -v' probe on a machine without the tool -> rc 1" "$?" "1"
|
|
220
|
+
# The probe's own exit code never leaks: `command -v <missing>` is 1 under bash-as-sh and 127 under
|
|
221
|
+
# dash (Linux /bin/sh), and a detect.run that names a missing binary is 127 under both.
|
|
222
|
+
jq '.detect = {"run":"fixture-absent-tool --version"}' "$desc" > "$tmp/dbin/absent.json"
|
|
223
|
+
run "$tmp/h7e" "integration_detect '$tmp/dbin/absent.json'"; rc "a detect.run that exits 127 -> rc 1" "$?" "1"
|
|
224
|
+
|
|
225
|
+
# ── 8. KIT_DRY_RUN prints the plan and runs nothing ────────────────────────────────────────────
|
|
226
|
+
unstub; stub npm works; stub uv works; : > "$log"; h="$tmp/h8"
|
|
227
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
228
|
+
out="$(run "$h" "KIT_DRY_RUN=1 integration_install '$desc' '$proj'")"; r=$?
|
|
229
|
+
plan="$(cat "$tmp/err")"
|
|
230
|
+
t "dry-run -> status, rc 0" "$out|$r" "dry-run|0"
|
|
231
|
+
t "dry-run -> no manager was called" "$(calls)" ""
|
|
232
|
+
t "dry-run -> no binary" "$(ls "$h/.local/bin" 2>/dev/null)" ""
|
|
233
|
+
has "dry-run plan lists candidate 1" "$plan" "1. npm install -g fixture-tool (npm is available)"
|
|
234
|
+
has "dry-run plan marks an absent manager" "$plan" "2. pnpm add -g fixture-tool (skipped: pnpm is not on PATH)"
|
|
235
|
+
has "dry-run plan lists candidate 4" "$plan" "4. uv tool install fixture-tool (uv is available)"
|
|
236
|
+
has "dry-run plan shows the wire command" "$plan" "fixture-tool init --no-statusline --no-hooks"
|
|
237
|
+
# dry-run wins over a missing consent record too, and says the record is missing
|
|
238
|
+
out="$(run "$tmp/h8b" "KIT_DRY_RUN=1 integration_install '$desc' '$proj'")"
|
|
239
|
+
t "dry-run without consent -> still a plan, nothing run" "$out|$(calls)" "dry-run|"
|
|
240
|
+
has "dry-run without consent -> says so" "$(cat "$tmp/err")" "consent: NOT recorded"
|
|
241
|
+
t "plan on stdout matches" "$(run "$h" "integration_install_plan '$desc' '$proj'" | sed -n 1p)" "fixture-tool: not installed. Candidates, tried in this order until one works:"
|
|
242
|
+
|
|
243
|
+
# ── 9. the wire command: `declined` becomes flags, reasons stay out ────────────────────────────
|
|
244
|
+
t "declined map is rendered into flags, in descriptor order" "$(run "$h" "integration_wire_command '$desc'")" "fixture-tool init --no-statusline --no-hooks"
|
|
245
|
+
jq 'del(.wire.declined)' "$desc" > "$tmp/nodecl.json"
|
|
246
|
+
t "no declined map -> the bare command" "$(run "$h" "integration_wire_command '$tmp/nodecl.json'")" "fixture-tool init"
|
|
247
|
+
jq 'del(.wire)' "$desc" > "$tmp/nowire.json"
|
|
248
|
+
run "$h" "integration_wire_command '$tmp/nowire.json'" >/dev/null; rc "no wire step -> rc 1" "$?" "1"
|
|
249
|
+
hasnt "the reasons never reach the command line" "$(run "$h" "integration_wire_command '$desc'")" "owns"
|
|
250
|
+
|
|
251
|
+
# wire runs in the project dir, with the off-PATH binary, under the same two gates
|
|
252
|
+
h="$tmp/h1"; : > "$log" # h1: consent recorded, tool installed by pipx into ~/.local/bin
|
|
253
|
+
out="$(run "$h" "KIT_DRY_RUN=1 integration_wire '$desc' '$proj'")"
|
|
254
|
+
t "wire dry-run -> nothing run" "$out|$(wired)" "dry-run|"
|
|
255
|
+
has "wire dry-run -> prints the command" "$(cat "$tmp/err")" "fixture-tool init --no-statusline --no-hooks"
|
|
256
|
+
out="$(run "$h" "integration_wire '$desc' '$proj'")"; r=$?
|
|
257
|
+
t "wire -> wired, rc 0" "$out|$r" "wired|0"
|
|
258
|
+
t "wire ran the rendered command in the project dir" "$(wired)" "fixture-tool init --no-statusline --no-hooks in $proj|"
|
|
259
|
+
: > "$log"; rm -f "$h/state/consent"
|
|
260
|
+
out="$(run "$h" "integration_wire '$desc' '$proj'")"; r=$?
|
|
261
|
+
t "wire without consent -> nothing run, rc 0" "$out|$r|$(wired)" "no-consent|0|"
|
|
262
|
+
mkdir -p "$tmp/nw"; cp "$fx/integration.schema.json" "$tmp/nw/"; cp "$tmp/nowire.json" "$tmp/nw/fixture-tool.json"
|
|
263
|
+
out="$(run "$h" "KIT_INTEGRATIONS_DIR='$tmp/nw' integration_wire '$tmp/nw/fixture-tool.json' '$proj'")"
|
|
264
|
+
t "descriptor with no wire step -> none" "$out" "none"
|
|
265
|
+
|
|
266
|
+
# ── 10. an invalid descriptor is refused before anything runs ──────────────────────────────────
|
|
267
|
+
mkdir -p "$tmp/bad"; cp "$fx/integration.schema.json" "$tmp/bad/"
|
|
268
|
+
jq 'del(.verify)' "$desc" > "$tmp/bad/fixture-tool.json"
|
|
269
|
+
unstub; stub npm works; : > "$log"; h="$tmp/h10"
|
|
270
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
271
|
+
out="$(run "$h" "KIT_INTEGRATIONS_DIR='$tmp/bad' integration_install '$tmp/bad/fixture-tool.json' '$proj'")"; r=$?
|
|
272
|
+
t "invalid descriptor -> failed, rc 1, nothing run" "$out|$r|$(calls)" "failed|1|"
|
|
273
|
+
has "invalid descriptor -> the field is named" "$(cat "$tmp/err")" "verify: required field is missing"
|
|
274
|
+
|
|
275
|
+
# ── 11. safe under `set -euo pipefail`, the way kit-doctor.sh runs ─────────────────────────────
|
|
276
|
+
unstub; stub npm fails; stub uv works; : > "$log"; h="$tmp/h11"
|
|
277
|
+
run "$h" "integration_consent_record fixture-tool '$proj'"
|
|
278
|
+
out="$(PATH="$stubs:$sealed" HOME="$h" KIT_INTEGRATIONS_DIR="$fx" KIT_STATE_DIR="$h/state" \
|
|
279
|
+
bash -c "set -euo pipefail; . '$LIB/integration-install.sh'; s=\"\$(integration_install '$desc' '$proj')\"; echo \"got:\$s\"" 2>/dev/null)"
|
|
280
|
+
t "strict mode: a failing candidate does not abort the caller" "$out" "got:installed uv"
|
|
281
|
+
|
|
282
|
+
# ── 12. the CLI form ───────────────────────────────────────────────────────────────────────────
|
|
283
|
+
cli() { local home="$1"; shift
|
|
284
|
+
PATH="$stubs:$sealed" HOME="$home" KIT_INTEGRATIONS_DIR="$fx" KIT_STATE_DIR="$home/state" bash "$LIB/integration-install.sh" "$@" 2>/dev/null; }
|
|
285
|
+
unstub; stub pipx works; : > "$log"; h="$tmp/h12"; mkdir -p "$h"
|
|
286
|
+
t "--install without consent" "$(cli "$h" --install fixture-tool "$proj")" "no-consent"
|
|
287
|
+
cli "$h" --consent fixture-tool "$proj"; rc "--consent -> rc 0" "$?" "0"
|
|
288
|
+
has "--plan names the candidates" "$(cli "$h" --plan fixture-tool "$proj")" "3. pipx install fixture-tool (pipx is available)"
|
|
289
|
+
t "--install by id" "$(cli "$h" --install fixture-tool "$proj")" "installed pipx"
|
|
290
|
+
t "--wire-command" "$(cli "$h" --wire-command fixture-tool)" "fixture-tool init --no-statusline --no-hooks"
|
|
291
|
+
t "--wire" "$(cli "$h" --wire fixture-tool "$proj")" "wired"
|
|
292
|
+
cli "$h" --install nope >/dev/null; rc "unknown id -> rc 1" "$?" "1"
|
|
293
|
+
cli "$h" --bogus >/dev/null; rc "unknown flag -> rc 2" "$?" "2"
|
|
294
|
+
|
|
295
|
+
# ── 13. the same runner under zsh (scripts/lib is sourced from zsh too) ────────────────────────
|
|
296
|
+
if command -v zsh >/dev/null 2>&1; then
|
|
297
|
+
zbin="$(command -v zsh)"
|
|
298
|
+
unstub; stub npm fails; stub pipx works; stub uv works; : > "$log"; h="$tmp/h13"; mkdir -p "$h"
|
|
299
|
+
out="$(PATH="$stubs:$sealed" HOME="$h" KIT_INTEGRATIONS_DIR="$fx" KIT_STATE_DIR="$h/state" \
|
|
300
|
+
"$zbin" -fc "source '$LIB/integration-install.sh'; integration_install '$desc' '$proj'; integration_consent_record fixture-tool '$proj' && integration_install '$desc' '$proj' && integration_install '$desc' '$proj' && integration_wire_command '$desc'" 2>/dev/null | tr '\n' '|')"
|
|
301
|
+
t "zsh: no-consent, install in order, no-op, wire command" "$out" "no-consent|installed pipx|present|fixture-tool init --no-statusline --no-hooks|"
|
|
302
|
+
t "zsh: order of calls" "$(calls)" "npm install -g fixture-tool|pipx install fixture-tool|"
|
|
303
|
+
fi
|
|
304
|
+
|
|
305
|
+
# ── 14. the shipped Graft descriptor through the runner (E303.10) ──────────────────────────────
|
|
306
|
+
# shellcheck source=/dev/null
|
|
307
|
+
. "$LIB/integration-install.sh"
|
|
308
|
+
gr="$ROOT/integrations/graft.json"
|
|
309
|
+
gwire="$(integration_wire_command "$gr")"
|
|
310
|
+
t "graft: the wire command" "$gwire" "graft init --agents claude --no-statusline --no-global"
|
|
311
|
+
# No verb runs the wire step yet, so afterInstall hands the user the same command. It must not drift.
|
|
312
|
+
has "graft: afterInstall carries the wire command" "$(jq -r '.afterInstall' "$gr")" "'$gwire'"
|
|
313
|
+
has "graft: the dry-run form is the wire command plus --dry-run" "$(jq -r '.wire.dryRun' "$gr")" "$gwire --dry-run"
|
|
314
|
+
unstub; stub npm works; stub pnpm works; h="$tmp/h14"; mkdir -p "$h"
|
|
315
|
+
plan="$(PATH="$stubs:$sealed" HOME="$h" KIT_STATE_DIR="$h/state" bash "$LIB/integration-install.sh" --plan graft "$proj" 2>/dev/null)"
|
|
316
|
+
has "graft plan: npm is candidate 1" "$plan" "1. npm install -g @nanonets/graft"
|
|
317
|
+
has "graft plan: pnpm is candidate 2" "$plan" "2. pnpm add -g @nanonets/graft"
|
|
318
|
+
has "graft plan: names the wire command" "$plan" "wire (in $proj): $gwire"
|
|
319
|
+
|
|
320
|
+
# The hook-merge test behind `wire.kept.hooks`, against the REAL graft binary. Opt-in
|
|
321
|
+
# (GRAFT_MERGE_TEST=1) and skipped when graft is absent: it runs a third-party tool, which the
|
|
322
|
+
# gate must not depend on. HOME is a throwaway dir, so --no-global is checked rather than trusted.
|
|
323
|
+
if [ "${GRAFT_MERGE_TEST:-}" = "1" ] && command -v graft >/dev/null 2>&1; then
|
|
324
|
+
gm="$tmp/graft-merge"; gh_home="$tmp/graft-home"; mkdir -p "$gm/.claude" "$gm/src" "$gh_home/.claude"
|
|
325
|
+
printf 'export function hello(n: string) { return greet(n) }\nfunction greet(n: string) { return "hi " + n }\n' > "$gm/src/a.ts"
|
|
326
|
+
hk='{"hooks":[{"type":"command","command":"bash .claude/hooks/kit-mail-check.sh"}]}'
|
|
327
|
+
jq -n --argjson h "$hk" '{hooks: {SessionStart: [$h], UserPromptSubmit: [$h], PostToolUse: [$h + {matcher: "Bash"}], Stop: [$h]}}' > "$gm/.claude/settings.json"
|
|
328
|
+
printf '{"keep":true}\n' > "$gh_home/.claude/settings.json"
|
|
329
|
+
before="$(jq -cS '[.hooks[][0]]' "$gm/.claude/settings.json")"
|
|
330
|
+
( cd "$gm" && git init -q && HOME="$gh_home" DO_NOT_TRACK=1 sh -c "$gwire" ) >/dev/null 2>&1; rc "graft init (real binary) -> rc 0" "$?" "0"
|
|
331
|
+
t "graft init: the four existing hook entries survive, first in their event" "$(jq -cS '[.hooks[][0]]' "$gm/.claude/settings.json")" "$before"
|
|
332
|
+
t "graft init: it added its own hooks" "$(jq -r '[.hooks[][] | .hooks[].command | select(test("graft-hooks"))] | length > 0' "$gm/.claude/settings.json")" "true"
|
|
333
|
+
t "graft init --no-statusline: no statusLine key" "$(jq -r 'has("statusLine")' "$gm/.claude/settings.json")" "false"
|
|
334
|
+
t "graft init --no-global: the user-level settings are untouched" "$(cat "$gh_home/.claude/settings.json")" '{"keep":true}'
|
|
335
|
+
t "graft init --no-global: no user-level ~/.claude.json" "$([ -e "$gh_home/.claude.json" ] && echo made || echo none)" "none"
|
|
336
|
+
once="$(cat "$gm/.claude/settings.json")"
|
|
337
|
+
( cd "$gm" && HOME="$gh_home" DO_NOT_TRACK=1 sh -c "$gwire" ) >/dev/null 2>&1
|
|
338
|
+
t "graft init twice: settings.json identical" "$(cat "$gm/.claude/settings.json")" "$once"
|
|
339
|
+
else
|
|
340
|
+
echo "skip: graft hook-merge test (set GRAFT_MERGE_TEST=1 with graft on PATH to run it)"
|
|
341
|
+
fi
|
|
342
|
+
|
|
343
|
+
[ "$fail" = "0" ] && echo "ALL OK" || { echo "SOME FAILED"; exit 1; }
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# integration-install.sh — the ONE installer runner for an integration descriptor (E303.3).
|
|
3
|
+
#
|
|
4
|
+
# integrations.sh reads and checks a descriptor; this file ACTS on one: it walks the descriptor's
|
|
5
|
+
# ordered `install` candidates, finds the binary afterwards, and runs the optional `wire` step.
|
|
6
|
+
# It replaced the per-tool copies of that walk (scripts/kit-doctor.sh calls it for every enabled
|
|
7
|
+
# descriptor) and holds no tool-specific code — every command it runs comes from the descriptor.
|
|
8
|
+
#
|
|
9
|
+
# Four rules, in the order integration_install applies them:
|
|
10
|
+
# 1. Already installed (the descriptor's `detect.run` exits 0) -> nothing runs. A second run is
|
|
11
|
+
# a no-op.
|
|
12
|
+
# 2. KIT_DRY_RUN set -> the plan is printed, nothing runs.
|
|
13
|
+
# 3. No recorded consent for this integration in this repo -> nothing runs, rc 0. Consent is one
|
|
14
|
+
# `install:<id>` line in the `consent` file of the state dir kit_state_dir resolves (.cckit/,
|
|
15
|
+
# shared by every worktree of the repo). KIT_ASSUME_YES is NOT consent.
|
|
16
|
+
# 4. Candidates are tried in descriptor order. One whose `manager` is not on PATH is skipped.
|
|
17
|
+
# The first whose command exits 0 AND leaves the tool detectable wins; the rest never run.
|
|
18
|
+
# When NO candidate's manager is on PATH, each candidate's optional `bootstrap` is tried in
|
|
19
|
+
# the same order (`brew install uv`); the first that puts a manager on PATH lets the walk
|
|
20
|
+
# run. A machine that already holds any listed manager is never bootstrapped.
|
|
21
|
+
#
|
|
22
|
+
# uv and pipx drop binaries into ~/.local/bin, which is often not on PATH in the session that ran
|
|
23
|
+
# the install. Every detect / install / wire command therefore runs with `$HOME/.local/bin`
|
|
24
|
+
# appended to PATH (appended: a binary already on PATH wins), and integration_bin resolves there.
|
|
25
|
+
#
|
|
26
|
+
# Source it: source scripts/lib/integration-install.sh
|
|
27
|
+
# integration_consent_file [dir] the consent file for the repo at dir (not created)
|
|
28
|
+
# integration_consent_has <id> [dir] rc 0 when `install:<id>` is recorded
|
|
29
|
+
# integration_consent_record <id> [dir] record it (idempotent); rc 1 when it cannot be written
|
|
30
|
+
# integration_bin <file> path of the tool's binary (detect.bin, else the first
|
|
31
|
+
# word of detect.run): PATH, then ~/.local/bin; rc 1 when
|
|
32
|
+
# it is in neither
|
|
33
|
+
# integration_detect <file> rc 0 when detect.run exits 0, else rc 1
|
|
34
|
+
# integration_install_plan <file> [dir] the plan on stdout; runs nothing
|
|
35
|
+
# integration_install <file> [dir] one status line on stdout, progress on stderr:
|
|
36
|
+
# present | dry-run | no-consent | installed <manager>
|
|
37
|
+
# (all rc 0) or failed (rc 1)
|
|
38
|
+
# integration_wire_command <file> `wire.run` + every flag in `wire.declined`; rc 1 when the
|
|
39
|
+
# descriptor has no wire step
|
|
40
|
+
# integration_wire <file> [dir] run it in dir, under the same dry-run + consent rules:
|
|
41
|
+
# none | dry-run | no-consent | wired (rc 0) | failed (rc 1)
|
|
42
|
+
# CLI: integration-install.sh --plan <id|file> [dir]
|
|
43
|
+
# integration-install.sh --install <id|file> [dir]
|
|
44
|
+
# integration-install.sh --wire <id|file> [dir]
|
|
45
|
+
# integration-install.sh --wire-command <id|file>
|
|
46
|
+
# integration-install.sh --consent <id> [dir]
|
|
47
|
+
# Requires: jq. bash 3.2 + zsh compatible; safe to source under `set -euo pipefail`.
|
|
48
|
+
# errors: best-effort — a failed candidate falls through to the next; rc 1 only when the
|
|
49
|
+
# descriptor is invalid or no candidate left the tool installed. Declining (dry-run, no consent)
|
|
50
|
+
# is rc 0.
|
|
51
|
+
|
|
52
|
+
_kit_ii_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
53
|
+
# shellcheck source=/dev/null
|
|
54
|
+
. "$_kit_ii_dir/kit-cli.sh" # kit_is_main, kit_say, kit_warn
|
|
55
|
+
# shellcheck source=/dev/null
|
|
56
|
+
. "$_kit_ii_dir/integrations.sh" # integration_validate, integration_file
|
|
57
|
+
# shellcheck source=/dev/null
|
|
58
|
+
. "$_kit_ii_dir/kit-state.sh" # kit_state_file
|
|
59
|
+
|
|
60
|
+
_kit_ii_id_ok() { grep -qE '^[a-z][a-z0-9]*(-[a-z0-9]+)*$' <<<"${1:-}"; }
|
|
61
|
+
|
|
62
|
+
# _kit_ii_sh <dir> <command> -> run one descriptor command in dir with ~/.local/bin appended to
|
|
63
|
+
# PATH. stdin is /dev/null so an installer can neither block on a prompt nor eat the caller's
|
|
64
|
+
# stdin; stdout goes to stderr so the caller's stdout stays the one status line.
|
|
65
|
+
_kit_ii_sh() {
|
|
66
|
+
( cd "$1" 2>/dev/null && PATH="$PATH:$HOME/.local/bin" sh -c "$2" ) </dev/null >&2
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# ── consent ────────────────────────────────────────────────────────────────────────────────────
|
|
70
|
+
integration_consent_file() {
|
|
71
|
+
local d="${1:-$PWD}"
|
|
72
|
+
( cd "$d" 2>/dev/null && kit_state_file consent )
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
integration_consent_has() {
|
|
76
|
+
local id="${1:-}" f
|
|
77
|
+
_kit_ii_id_ok "$id" || return 1
|
|
78
|
+
f="$(integration_consent_file "${2:-$PWD}")" || return 1
|
|
79
|
+
[ -f "$f" ] || return 1
|
|
80
|
+
grep -qxF -- "install:$id" "$f" 2>/dev/null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
integration_consent_record() {
|
|
84
|
+
local id="${1:-}" d="${2:-$PWD}" f
|
|
85
|
+
_kit_ii_id_ok "$id" || { kit_warn "integration consent: '$id' is not an integration id"; return 1; }
|
|
86
|
+
if integration_consent_has "$id" "$d"; then return 0; fi
|
|
87
|
+
f="$(integration_consent_file "$d")" || return 1
|
|
88
|
+
mkdir -p "$(dirname "$f")" 2>/dev/null || { kit_warn "integration consent: cannot create $(dirname "$f")"; return 1; }
|
|
89
|
+
printf 'install:%s\n' "$id" >> "$f" 2>/dev/null || { kit_warn "integration consent: cannot write $f"; return 1; }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# ── detect ─────────────────────────────────────────────────────────────────────────────────────
|
|
93
|
+
integration_bin() {
|
|
94
|
+
local f="${1:-}" name
|
|
95
|
+
[ -f "$f" ] || return 1
|
|
96
|
+
name="$(jq -r '.detect.bin // (.detect.run | split(" ")[0]) // ""' "$f" 2>/dev/null)" || return 1
|
|
97
|
+
[ -n "$name" ] || return 1
|
|
98
|
+
if command -v "$name" >/dev/null 2>&1; then command -v "$name"; return 0; fi
|
|
99
|
+
if [ -x "$HOME/.local/bin/$name" ]; then printf '%s\n' "$HOME/.local/bin/$name"; return 0; fi
|
|
100
|
+
return 1
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
integration_detect() {
|
|
104
|
+
local f="${1:-}" cmd
|
|
105
|
+
[ -f "$f" ] || return 1
|
|
106
|
+
cmd="$(jq -r '.detect.run // ""' "$f" 2>/dev/null)" || return 1
|
|
107
|
+
[ -n "$cmd" ] || return 1
|
|
108
|
+
# Normalized to 0/1: the probe's own code differs by shell (`command -v <missing>` is 1 under
|
|
109
|
+
# bash-as-sh, 127 under dash) and a caller should not have to know which sh ran it.
|
|
110
|
+
_kit_ii_sh "${2:-$PWD}" "$cmd" >/dev/null 2>&1 || return 1
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# ── install ────────────────────────────────────────────────────────────────────────────────────
|
|
114
|
+
# integration_install_plan <file> [dir] -> what integration_install would do, on stdout.
|
|
115
|
+
integration_install_plan() {
|
|
116
|
+
local f="${1:-}" d="${2:-$PWD}" id n i mgr run have wire
|
|
117
|
+
[ -f "$f" ] || return 1
|
|
118
|
+
id="$(jq -r '.id' "$f")"
|
|
119
|
+
if integration_detect "$f" "$d"; then
|
|
120
|
+
printf '%s: already installed (%s) — nothing to do\n' "$id" "$(integration_bin "$f" || jq -r '.detect.run' "$f")"
|
|
121
|
+
else
|
|
122
|
+
printf '%s: not installed. Candidates, tried in this order until one works:\n' "$id"
|
|
123
|
+
n="$(jq '.install | length' "$f")"; i=0
|
|
124
|
+
while [ "$i" -lt "$n" ]; do
|
|
125
|
+
mgr="$(jq -r --argjson i "$i" '.install[$i].manager' "$f")"
|
|
126
|
+
run="$(jq -r --argjson i "$i" '.install[$i].run' "$f")"
|
|
127
|
+
have="skipped: $mgr is not on PATH"; command -v "$mgr" >/dev/null 2>&1 && have="$mgr is available"
|
|
128
|
+
printf ' %s. %s (%s)\n' "$((i + 1))" "$run" "$have"
|
|
129
|
+
i=$((i + 1))
|
|
130
|
+
done
|
|
131
|
+
if ! _kit_ii_any_manager "$f"; then
|
|
132
|
+
jq -r '.install[] | select(.bootstrap != null)
|
|
133
|
+
| " bootstrap, because none of those managers is on PATH: \(.bootstrap.run) (needs \(.bootstrap.manager))"' "$f"
|
|
134
|
+
fi
|
|
135
|
+
if integration_consent_has "$id" "$d"; then printf ' consent: recorded in %s\n' "$(integration_consent_file "$d")"
|
|
136
|
+
else printf ' consent: NOT recorded in %s — nothing installs without it\n' "$(integration_consent_file "$d")"; fi
|
|
137
|
+
fi
|
|
138
|
+
if wire="$(integration_wire_command "$f")"; then printf ' wire (in %s): %s\n' "$d" "$wire"; fi
|
|
139
|
+
return 0
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
# _kit_ii_any_manager <file> -> rc 0 when at least one install candidate's manager is on PATH.
|
|
143
|
+
_kit_ii_any_manager() {
|
|
144
|
+
local m
|
|
145
|
+
for m in $(jq -r '.install[].manager' "$1" 2>/dev/null); do
|
|
146
|
+
if command -v "$m" >/dev/null 2>&1; then return 0; fi
|
|
147
|
+
done
|
|
148
|
+
return 1
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# _kit_ii_bootstrap <file> <dir> -> with no candidate manager on PATH, run the candidates'
|
|
152
|
+
# `bootstrap` commands in descriptor order until one puts a manager on PATH. rc 0 when a manager
|
|
153
|
+
# is then available. Only integration_install calls it, past the dry-run and consent gates.
|
|
154
|
+
_kit_ii_bootstrap() {
|
|
155
|
+
local f="$1" d="$2" id n i bmgr brun
|
|
156
|
+
id="$(jq -r '.id' "$f")"
|
|
157
|
+
n="$(jq '.install | length' "$f")"; i=0
|
|
158
|
+
while [ "$i" -lt "$n" ]; do
|
|
159
|
+
bmgr="$(jq -r --argjson i "$i" '.install[$i].bootstrap.manager // ""' "$f")"
|
|
160
|
+
brun="$(jq -r --argjson i "$i" '.install[$i].bootstrap.run // ""' "$f")"
|
|
161
|
+
i=$((i + 1))
|
|
162
|
+
[ -n "$bmgr" ] && [ -n "$brun" ] || continue
|
|
163
|
+
command -v "$bmgr" >/dev/null 2>&1 || continue
|
|
164
|
+
kit_say "integration $id: no installer on this machine — bootstrapping with $bmgr — $brun"
|
|
165
|
+
_kit_ii_sh "$d" "$brun" 2>/dev/null || true
|
|
166
|
+
if _kit_ii_any_manager "$f"; then return 0; fi
|
|
167
|
+
done
|
|
168
|
+
return 1
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
# integration_install <file> [dir] -> one status line on stdout (see the header).
|
|
172
|
+
integration_install() {
|
|
173
|
+
local f="${1:-}" d="${2:-$PWD}" id n i mgr run resident tried=0
|
|
174
|
+
if ! integration_validate "$f"; then printf 'failed\n'; return 1; fi
|
|
175
|
+
id="$(jq -r '.id' "$f")"
|
|
176
|
+
if integration_detect "$f" "$d"; then printf 'present\n'; return 0; fi
|
|
177
|
+
if [ -n "${KIT_DRY_RUN:-}" ]; then
|
|
178
|
+
integration_install_plan "$f" "$d" >&2
|
|
179
|
+
printf 'dry-run\n'; return 0
|
|
180
|
+
fi
|
|
181
|
+
if ! integration_consent_has "$id" "$d"; then
|
|
182
|
+
kit_say "integration $id: not installed — no consent recorded in $(integration_consent_file "$d")"
|
|
183
|
+
printf 'no-consent\n'; return 0
|
|
184
|
+
fi
|
|
185
|
+
if ! _kit_ii_any_manager "$f"; then _kit_ii_bootstrap "$f" "$d" || true; fi
|
|
186
|
+
n="$(jq '.install | length' "$f")"; i=0
|
|
187
|
+
while [ "$i" -lt "$n" ]; do
|
|
188
|
+
mgr="$(jq -r --argjson i "$i" '.install[$i].manager' "$f")"
|
|
189
|
+
run="$(jq -r --argjson i "$i" '.install[$i].run' "$f")"
|
|
190
|
+
resident="$(jq -r --argjson i "$i" '.install[$i] | if has("resident") then .resident else true end' "$f")"
|
|
191
|
+
i=$((i + 1))
|
|
192
|
+
command -v "$mgr" >/dev/null 2>&1 || continue
|
|
193
|
+
tried=$((tried + 1))
|
|
194
|
+
kit_say "integration $id: installing with $mgr — $run"
|
|
195
|
+
if _kit_ii_sh "$d" "$run" 2>/dev/null; then
|
|
196
|
+
# A candidate marked resident:false (npx) leaves no binary to detect; its exit code is the
|
|
197
|
+
# only evidence there is.
|
|
198
|
+
if [ "$resident" = "false" ] || integration_detect "$f" "$d"; then
|
|
199
|
+
printf 'installed %s\n' "$mgr"; return 0
|
|
200
|
+
fi
|
|
201
|
+
kit_say "integration $id: $mgr exited 0 but the tool is still not detected — trying the next candidate"
|
|
202
|
+
else
|
|
203
|
+
kit_say "integration $id: $mgr failed — trying the next candidate"
|
|
204
|
+
fi
|
|
205
|
+
done
|
|
206
|
+
if [ "$tried" -eq 0 ]; then
|
|
207
|
+
kit_say "integration $id: none of its installers is on PATH ($(jq -r '[.install[].manager] | join(", ")' "$f"))"
|
|
208
|
+
else
|
|
209
|
+
kit_say "integration $id: no candidate left the tool installed. Install it by hand: $(jq -r '.install[0].run' "$f")"
|
|
210
|
+
fi
|
|
211
|
+
printf 'failed\n'; return 1
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
# ── wire ───────────────────────────────────────────────────────────────────────────────────────
|
|
215
|
+
# integration_wire_command <file> -> `wire.run` followed by every key of `wire.declined`, in the
|
|
216
|
+
# order the descriptor writes them. The keys are the flags that turn a tool feature OFF; the
|
|
217
|
+
# values are the reasons, for the reader, and never reach the command line.
|
|
218
|
+
integration_wire_command() {
|
|
219
|
+
local f="${1:-}"
|
|
220
|
+
[ -f "$f" ] || return 1
|
|
221
|
+
jq -er 'select(.wire.run != null) | [.wire.run] + ((.wire.declined // {}) | keys_unsorted) | join(" ")' "$f" 2>/dev/null || return 1
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# integration_wire <file> [dir] -> run the wire step in dir. Not gated on detect: the step writes
|
|
225
|
+
# into the project, so whether a re-run is a no-op is the tool's contract, not this runner's.
|
|
226
|
+
integration_wire() {
|
|
227
|
+
local f="${1:-}" d="${2:-$PWD}" id cmd
|
|
228
|
+
if ! integration_validate "$f"; then printf 'failed\n'; return 1; fi
|
|
229
|
+
id="$(jq -r '.id' "$f")"
|
|
230
|
+
if ! cmd="$(integration_wire_command "$f")"; then printf 'none\n'; return 0; fi
|
|
231
|
+
if [ -n "${KIT_DRY_RUN:-}" ]; then
|
|
232
|
+
kit_say "integration $id: would run in $d — $cmd"
|
|
233
|
+
printf 'dry-run\n'; return 0
|
|
234
|
+
fi
|
|
235
|
+
if ! integration_consent_has "$id" "$d"; then
|
|
236
|
+
kit_say "integration $id: not wired — no consent recorded in $(integration_consent_file "$d")"
|
|
237
|
+
printf 'no-consent\n'; return 0
|
|
238
|
+
fi
|
|
239
|
+
kit_say "integration $id: wiring in $d — $cmd"
|
|
240
|
+
if _kit_ii_sh "$d" "$cmd"; then printf 'wired\n'; return 0; fi
|
|
241
|
+
kit_say "integration $id: the wire command failed"
|
|
242
|
+
printf 'failed\n'; return 1
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
_kit_ii_main() {
|
|
246
|
+
local f
|
|
247
|
+
case "${1:-}" in
|
|
248
|
+
--plan) f="$(_kit_ig_arg "${2:-}")" || return 1; integration_install_plan "$f" "${3:-$PWD}" ;;
|
|
249
|
+
--install) f="$(_kit_ig_arg "${2:-}")" || return 1; integration_install "$f" "${3:-$PWD}" ;;
|
|
250
|
+
--wire) f="$(_kit_ig_arg "${2:-}")" || return 1; integration_wire "$f" "${3:-$PWD}" ;;
|
|
251
|
+
--wire-command) f="$(_kit_ig_arg "${2:-}")" || return 1; integration_wire_command "$f" ;;
|
|
252
|
+
--consent) integration_consent_record "${2:-}" "${3:-$PWD}" ;;
|
|
253
|
+
*) kit_warn "usage: integration-install.sh --plan|--install|--wire <id|file> [dir] | --wire-command <id|file> | --consent <id> [dir]"; return 2 ;;
|
|
254
|
+
esac
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if kit_is_main; then _kit_ii_main "$@"; fi
|