@jeiemgi/cckit 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +169 -21
- package/README.md +505 -35
- package/SECURITY.md +5 -0
- package/bin/cckit +189 -20
- package/cckit.config.json +1 -1
- package/commands/kit-doctor.md +13 -5
- package/commands/kit-export-project.md +0 -2
- package/commands/kit-export-training.md +6 -9
- package/commands/kit-init.md +43 -13
- package/commands/kit-routines.md +1 -1
- package/commands/kit-update.md +11 -6
- package/databases/supabase/guide.html +106 -0
- package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
- package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
- package/databases/supabase.json +70 -0
- package/integrations/emil-design-eng.json +41 -0
- package/integrations/graft.json +81 -0
- package/integrations/impeccable.json +42 -0
- package/integrations/integration.schema.json +215 -0
- package/integrations/lavish.json +43 -0
- package/integrations/mempalace.json +28 -0
- package/integrations/mlx-lm.json +32 -0
- package/integrations/web-design-guidelines.json +42 -0
- package/kit.config.schema.json +183 -5
- package/package.json +4 -1
- package/profiles/automation.json +7 -1
- package/profiles/content.json +10 -2
- package/profiles/marketing.json +57 -0
- package/profiles/minimal.json +7 -1
- package/profiles/research.json +7 -1
- package/profiles/software.json +7 -1
- package/recipes/nextjs-shadcn.json +49 -0
- package/scripts/agent-skills-external.txt +45 -0
- package/scripts/agent-skills-lint-test.sh +131 -0
- package/scripts/agent-skills-lint.sh +115 -0
- package/scripts/agent-template-lint-test.sh +42 -0
- package/scripts/agent-template-lint.sh +58 -0
- package/scripts/annotate-setup.sh +1 -1
- package/scripts/autopilot-run-test.sh +338 -0
- package/scripts/autopilot-run.sh +448 -0
- package/scripts/autopilot-test.sh +8 -0
- package/scripts/autopilot.sh +10 -1
- package/scripts/benchmark/benchmark-test.sh +85 -0
- package/scripts/benchmark/checkpoint-test.sh +314 -0
- package/scripts/benchmark/checkpoint.sh +408 -0
- package/scripts/benchmark/lib/model.sh +31 -6
- package/scripts/benchmark/report.sh +17 -2
- package/scripts/benchmark/run-quality.sh +36 -10
- package/scripts/benchmark/verb-timings-test.sh +124 -0
- package/scripts/benchmark/verb-timings.sh +149 -0
- package/scripts/check.sh +29 -19
- package/scripts/content-skills-test.sh +144 -0
- package/scripts/copilot-loop-test.sh +25 -0
- package/scripts/database-supabase-test.sh +121 -0
- package/scripts/docs-marketing-words-test.sh +73 -0
- package/scripts/docs-record-tables-test.sh +72 -0
- package/scripts/guard-raw-git-ops-test.sh +8 -0
- package/scripts/hook-adapter-test.sh +193 -0
- package/scripts/init-content-test.sh +225 -0
- package/scripts/init-guided-test.sh +474 -0
- package/scripts/init-recipes-test.sh +104 -0
- package/scripts/init-upgrade-test.sh +341 -2
- package/scripts/init.sh +746 -95
- package/scripts/instruction-budget-baseline.txt +8 -0
- package/scripts/instruction-budget-lint-test.sh +166 -0
- package/scripts/instruction-budget-lint.sh +219 -0
- package/scripts/integrations-check-test.sh +200 -0
- package/scripts/integrations-check.sh +157 -0
- package/scripts/kit-add-test.sh +214 -0
- package/scripts/kit-add.sh +305 -5
- package/scripts/kit-adopt-test.sh +16 -0
- package/scripts/kit-adopt.sh +3 -2
- package/scripts/kit-digest.sh +2 -2
- package/scripts/kit-doctor-test.sh +293 -0
- package/scripts/kit-doctor.sh +272 -140
- package/scripts/kit-export-project-test.sh +3 -3
- package/scripts/kit-remove-test.sh +19 -0
- package/scripts/kit-routines.sh +2 -2
- package/scripts/kit-self-update.sh +1 -1
- package/scripts/kit-version-check-test.sh +4 -0
- package/scripts/kit-version-check.sh +4 -2
- package/scripts/knowledge-lint.sh +4 -4
- package/scripts/leak-fence-test.sh +89 -0
- package/scripts/lib/adapter-select-test.sh +136 -0
- package/scripts/lib/adapter-select.sh +158 -0
- package/scripts/lib/agent-def-test.sh +69 -0
- package/scripts/lib/agent-def.sh +106 -0
- package/scripts/lib/agent-launch-test.sh +212 -0
- package/scripts/lib/agent-launch.sh +335 -0
- package/scripts/lib/board-view-test.sh +11 -0
- package/scripts/lib/board-view.sh +42 -26
- package/scripts/lib/branch-owner-test.sh +26 -0
- package/scripts/lib/branch-owner.sh +16 -9
- package/scripts/lib/captain-test.sh +105 -0
- package/scripts/lib/captain.sh +87 -8
- package/scripts/lib/codex-hooks-test.sh +100 -0
- package/scripts/lib/codex-hooks.sh +69 -0
- package/scripts/lib/commitlint.sh +1 -1
- package/scripts/lib/content-kinds-gc-test.sh +88 -0
- package/scripts/lib/copilot-test.sh +70 -4
- package/scripts/lib/copilot.sh +66 -14
- package/scripts/lib/effort-dispatch-test.sh +3 -3
- package/scripts/lib/effort-metrics-test.sh +178 -1
- package/scripts/lib/effort-metrics.sh +188 -35
- package/scripts/lib/effort-ops-test.sh +217 -7
- package/scripts/lib/effort-ops.sh +281 -49
- package/scripts/lib/effort-parity-test.sh +49 -13
- package/scripts/lib/effort-plan-test.sh +337 -0
- package/scripts/lib/effort-plan.sh +200 -23
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +67 -12
- package/scripts/lib/errors-header-test.sh +1 -1
- package/scripts/lib/gh-project-test.sh +35 -1
- package/scripts/lib/gh-project.sh +37 -16
- package/scripts/lib/gh-rest-test.sh +330 -0
- package/scripts/lib/gh-rest.sh +304 -0
- package/scripts/lib/hook-refresh.sh +1 -1
- package/scripts/lib/init-github.sh +412 -0
- package/scripts/lib/init-guide.sh +630 -0
- package/scripts/lib/integration-install-test.sh +343 -0
- package/scripts/lib/integration-install.sh +257 -0
- package/scripts/lib/integrations-test.sh +366 -0
- package/scripts/lib/integrations.sh +244 -0
- package/scripts/lib/kinds-test.sh +125 -0
- package/scripts/lib/kinds.sh +66 -0
- package/scripts/lib/kit-brief-test.sh +22 -3
- package/scripts/lib/kit-brief.sh +45 -5
- package/scripts/lib/kit-config-resolve.sh +2 -2
- package/scripts/lib/kit-config-test.sh +64 -1
- package/scripts/lib/kit-config.sh +37 -1
- package/scripts/lib/kit-events.sh +7 -0
- package/scripts/lib/kit-gc-test.sh +173 -1
- package/scripts/lib/kit-gc.sh +244 -37
- package/scripts/lib/kit-hotfix.sh +216 -0
- package/scripts/lib/kit-interview-test.sh +93 -0
- package/scripts/lib/kit-interview.sh +117 -8
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +3 -3
- package/scripts/lib/kit-local.sh +2 -2
- package/scripts/lib/kit-manifest.sh +33 -1
- package/scripts/lib/kit-profile-test.sh +3 -3
- package/scripts/lib/kit-status-test.sh +112 -4
- package/scripts/lib/kit-status.sh +246 -16
- package/scripts/lib/kit-task-ops-test.sh +37 -0
- package/scripts/lib/kit-task-ops.sh +362 -89
- package/scripts/lib/kto-hotfix-test.sh +232 -0
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-new-test.sh +95 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +97 -6
- package/scripts/lib/kto-task-pr-test.sh +70 -0
- package/scripts/lib/leak-fence.sh +89 -0
- package/scripts/lib/light-task-run-test.sh +255 -0
- package/scripts/lib/light-task-test.sh +309 -0
- package/scripts/lib/light-task.sh +706 -0
- package/scripts/lib/next-test.sh +99 -0
- package/scripts/lib/next.sh +9 -3
- package/scripts/lib/orchestration-runtime-test.sh +72 -0
- package/scripts/lib/orchestration-runtime.sh +57 -5
- package/scripts/lib/plan-machine-test.sh +15 -2
- package/scripts/lib/plan-machine.sh +20 -7
- package/scripts/lib/plan-next-test.sh +1 -1
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +3 -3
- package/scripts/lib/pr-evidence.sh +1 -1
- package/scripts/lib/qa-lane-test.sh +626 -0
- package/scripts/lib/qa-lane.sh +1357 -0
- package/scripts/lib/qa-lanes-test.sh +175 -0
- package/scripts/lib/react-detect.sh +1 -1
- package/scripts/lib/render-test.sh +1 -1
- package/scripts/lib/review-page-test.sh +318 -0
- package/scripts/lib/review-page.sh +369 -0
- package/scripts/lib/review-stage-test.sh +62 -11
- package/scripts/lib/review-stage.sh +42 -60
- package/scripts/lib/role-identity-test.sh +65 -0
- package/scripts/lib/role-identity.sh +25 -2
- package/scripts/lib/secret-guard.sh +3 -3
- package/scripts/lib/session-registry-test.sh +111 -0
- package/scripts/lib/session-registry.sh +233 -0
- package/scripts/lib/stage-receipt-test.sh +14 -1
- package/scripts/lib/stage-receipt.sh +13 -8
- package/scripts/lib/task-source-file.sh +309 -0
- package/scripts/lib/task-source.sh +130 -0
- package/scripts/lib/test-env-test.sh +3 -3
- package/scripts/lib/test-env.sh +7 -4
- package/scripts/lib/upgrade-report-test.sh +120 -0
- package/scripts/lib/upgrade-report.sh +138 -0
- package/scripts/lib/version-bump.sh +3 -3
- package/scripts/lib/wave-result-test.sh +80 -0
- package/scripts/lib/wave-result.sh +127 -0
- package/scripts/lib/worker-brief-test.sh +5 -0
- package/scripts/lib/worker-brief.sh +2 -2
- package/scripts/lib/worktree-issue-test.sh +30 -1
- package/scripts/lib/worktree-issue.sh +93 -9
- package/scripts/lib/worktree-ports-test.sh +57 -4
- package/scripts/lib/worktree-start-test.sh +197 -0
- package/scripts/lib/worktree-start.sh +169 -32
- package/scripts/lib/zsh-safety-test.sh +19 -3
- package/scripts/marketing-walkthrough-test.sh +152 -0
- package/scripts/night-grant-test.sh +37 -0
- package/scripts/night-grant.sh +448 -0
- package/scripts/night-run-test.sh +8 -0
- package/scripts/night-run.mjs +275 -0
- package/scripts/night-run.test.mjs +324 -0
- package/scripts/orchestrate-test.sh +190 -0
- package/scripts/orchestrate.sh +79 -8
- package/scripts/portable-test.sh +11 -2
- package/scripts/publish.sh +28 -3
- package/scripts/review-lint-test.sh +7 -7
- package/scripts/review-lint.sh +2 -2
- package/scripts/review-rules.conf +8 -0
- package/scripts/rule-recipes-test.sh +96 -0
- package/scripts/self-install-test.sh +39 -9
- package/scripts/setup-labels.sh +18 -1
- package/scripts/setup-milestones.sh +1 -1
- package/scripts/showcase.sh +1 -1
- package/scripts/skill-frontmatter-lint-test.sh +4 -4
- package/scripts/skill-frontmatter-lint.sh +1 -1
- package/scripts/status-test.sh +113 -2
- package/scripts/status.sh +16 -3
- package/scripts/task-sync-test.sh +154 -0
- package/scripts/task-sync.sh +243 -32
- package/scripts/test-runner-test.sh +158 -0
- package/scripts/test.sh +131 -23
- package/scripts/update-path-test.sh +279 -0
- package/scripts/ux-ds-audit.sh +1 -1
- package/scripts/ux-graph-scan.sh +6 -6
- package/scripts/wave-worker.sh +54 -0
- package/skills/kit-add/SKILL.md +77 -0
- package/skills/kit-autopilot/SKILL.md +123 -12
- package/skills/kit-cleanup/SKILL.md +5 -2
- package/skills/kit-contribute/SKILL.md +4 -4
- package/skills/kit-docs-writer/SKILL.md +16 -6
- package/skills/kit-effort-close/SKILL.md +17 -8
- package/skills/kit-effort-new/SKILL.md +15 -9
- package/skills/kit-effort-pr/SKILL.md +15 -7
- package/skills/kit-effort-start/SKILL.md +5 -2
- package/skills/kit-gc/SKILL.md +5 -2
- package/skills/kit-next/SKILL.md +5 -1
- package/skills/kit-onboard/SKILL.md +3 -3
- package/skills/kit-page/SKILL.md +93 -0
- package/skills/kit-plan-next/SKILL.md +8 -4
- package/skills/kit-security-sweep/SKILL.md +1 -3
- package/skills/kit-ship/SKILL.md +2 -3
- package/skills/kit-status/SKILL.md +35 -4
- package/skills/kit-task-new/SKILL.md +3 -3
- package/skills/kit-task-pr/SKILL.md +7 -2
- package/skills/kit-task-pr-merge/SKILL.md +7 -2
- package/skills/kit-task-start/SKILL.md +7 -7
- package/skills/kit-task-sync/SKILL.md +19 -3
- package/skills/kit-ux-audit/SKILL.md +3 -2
- package/templates/agents/auto-dev.md +5 -4
- package/templates/agents/backend.md +1 -1
- package/templates/agents/designer.md +2 -0
- package/templates/agents/devops.md +1 -1
- package/templates/agents/editor.md +9 -1
- package/templates/agents/frontend.md +1 -1
- package/templates/agents/local-delegate.md +1 -1
- package/templates/agents/pm.md +5 -5
- package/templates/agents/tech-lead.md +1 -1
- package/templates/benchmarks/SCHEMA.md +9 -3
- package/templates/codex/hooks.json.tmpl +89 -0
- package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +27 -14
- package/templates/hooks/mempal_followup.sh.tmpl +2 -2
- package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
- package/templates/hooks/prepush_gate.sh.tmpl +4 -2
- package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
- package/templates/instructions.md.tmpl +174 -0
- package/templates/kit.config.json.tmpl +3 -3
- package/templates/knowledge-INDEX.md.tmpl +1 -1
- package/templates/lib/kit-sigil.sh.tmpl +1 -1
- package/templates/rules/authoring.md +106 -0
- package/templates/rules/branch-naming.md +40 -4
- package/templates/rules/code-retrieval.md +63 -0
- package/templates/rules/delegation-brief.md +0 -3
- package/templates/rules/design-routing.md +3 -3
- package/templates/rules/effort-model.md +14 -10
- package/templates/rules/gate-and-review.md +94 -0
- package/templates/rules/issue-lifecycle.md +88 -0
- package/templates/rules/knowledge-base.md +1 -1
- package/templates/rules/mempalace.md +1 -1
- package/templates/rules/merge-safety.md +108 -0
- package/templates/rules/naming-and-ids.md +23 -17
- package/templates/rules/plain-language.md +59 -0
- package/templates/rules/plan-next.md +9 -11
- package/templates/rules/react-annotate.md +6 -0
- package/templates/rules/review-pages.md +49 -0
- package/templates/rules/risk-tiered-review.md +13 -4
- package/templates/rules/shared-checkout.md +106 -0
- package/templates/rules/skill-gaps.md +2 -7
- package/templates/rules/task-management.md +13 -1
- package/templates/skills/brand-voice/SKILL.md +91 -0
- package/templates/skills/brand-voice/references/voice-template.md +61 -0
- package/templates/skills/campaign/SKILL.md +123 -0
- package/templates/skills/campaign/references/plan-template.md +55 -0
- package/templates/skills/concrete/SKILL.md +2 -2
- package/templates/skills/copywriting/SKILL.md +8 -1
- package/templates/skills/feature-build-refine/SKILL.md +2 -4
- package/templates/skills/morning-briefing/SKILL.md +2 -2
- package/templates/skills/page-design/SKILL.md +145 -0
- package/templates/skills/page-design/add.json +5 -0
- package/templates/skills/page-design/references/design-file-template.md +40 -0
- package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
- package/templates/skills/page-design/references/minimum-rules.md +42 -0
- package/templates/skills/speckit/SKILL.md +4 -5
- package/templates/skills/supabase-patterns/SKILL.md +1 -1
- package/commands/kit-add.md +0 -42
- package/templates/CLAUDE.md.tmpl +0 -106
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# integrations-test.sh — covers the integration descriptor format (E303.1): the schema in
|
|
4
|
+
# integrations/integration.schema.json, the validator and the applicability check in
|
|
5
|
+
# scripts/lib/integrations.sh, and the two files that have to know the registry exists
|
|
6
|
+
# (kit.config.schema.json, package.json). Hermetic: fixture descriptors and repos live in a
|
|
7
|
+
# throwaway dir. Run: bash scripts/lib/integrations-test.sh
|
|
8
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
9
|
+
set -u
|
|
10
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
11
|
+
# shellcheck source=/dev/null
|
|
12
|
+
. "$ROOT/scripts/lib/test-env.sh" && test_env_seal
|
|
13
|
+
LIB="$ROOT/scripts/lib"
|
|
14
|
+
fail=0
|
|
15
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
16
|
+
rc() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> rc '$2' want '$3'"; fail=1; fi; }
|
|
17
|
+
has() { if grep -qF -- "$3" <<<"$2"; then echo "ok: $1"; else echo "FAIL: $1 -> '$3' not in: $2"; fail=1; fi; }
|
|
18
|
+
|
|
19
|
+
command -v jq >/dev/null 2>&1 || { echo "integrations-test: jq absent — skipping (dependency-light gate)"; exit 0; }
|
|
20
|
+
|
|
21
|
+
# shellcheck source=/dev/null
|
|
22
|
+
. "$LIB/integrations.sh"
|
|
23
|
+
|
|
24
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
25
|
+
fx="$tmp/integrations"; mkdir -p "$fx"
|
|
26
|
+
cp "$ROOT/integrations/integration.schema.json" "$fx/"
|
|
27
|
+
|
|
28
|
+
# The fixture carries every field the issue names: label, the config key that turns it on, a
|
|
29
|
+
# detect command, ORDERED install candidates, a verify command, a docs link, an attribution block
|
|
30
|
+
# with affiliated:false, and the applicability predicate.
|
|
31
|
+
cat > "$fx/fixture-tool.json" <<'JSON'
|
|
32
|
+
{
|
|
33
|
+
"id": "fixture-tool",
|
|
34
|
+
"label": "Fixture Tool",
|
|
35
|
+
"summary": "A tool that exists only in this test.",
|
|
36
|
+
"config": { "key": "codeGraph.provider", "value": "fixture-tool-provider" },
|
|
37
|
+
"appliesWhen": { "anyExtension": [".ts", ".tsx", ".R"], "note": "No shell grammar." },
|
|
38
|
+
"detect": { "run": "fixture-tool --version" },
|
|
39
|
+
"install": [
|
|
40
|
+
{ "manager": "npm", "run": "npm install -g fixture-tool" },
|
|
41
|
+
{ "manager": "pnpm", "run": "pnpm add -g fixture-tool" },
|
|
42
|
+
{ "manager": "curl", "run": "curl -fsSL https://example.invalid/install.sh | sh", "note": "last resort" }
|
|
43
|
+
],
|
|
44
|
+
"wire": {
|
|
45
|
+
"run": "fixture-tool init",
|
|
46
|
+
"declined": { "--no-statusline": "cckit owns the statusline." }
|
|
47
|
+
},
|
|
48
|
+
"verify": { "run": "fixture-tool check" },
|
|
49
|
+
"uninstall": "fixture-tool uninstall -y",
|
|
50
|
+
"docs": "https://example.invalid/fixture-tool#readme",
|
|
51
|
+
"attribution": {
|
|
52
|
+
"author": "Example Org",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"homepage": "https://example.invalid/fixture-tool",
|
|
55
|
+
"affiliated": false,
|
|
56
|
+
"notice": "cckit is not affiliated with Example Org."
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
JSON
|
|
60
|
+
good="$fx/fixture-tool.json"
|
|
61
|
+
|
|
62
|
+
# ── 1. the valid descriptor validates ──────────────────────────────────────────────────────────
|
|
63
|
+
out="$(integration_validate "$good" 2>&1)"; r=$?
|
|
64
|
+
rc "valid descriptor -> rc 0" "$r" "0"
|
|
65
|
+
t "valid descriptor -> no diagnostics" "$out" ""
|
|
66
|
+
t "install candidates keep descriptor order" "$(jq -r '[.install[].manager] | join(",")' "$good")" "npm,pnpm,curl"
|
|
67
|
+
t "attribution carries affiliated:false" "$(jq -r '.attribution.affiliated' "$good")" "false"
|
|
68
|
+
|
|
69
|
+
# ── 2. a descriptor missing each required field is rejected BY NAME ────────────────────────────
|
|
70
|
+
# mutate <jq-filter> -> writes the mutated fixture under the SAME file name (the id must keep
|
|
71
|
+
# matching the file stem, or that unrelated error would mask the one under test).
|
|
72
|
+
mdir="$tmp/mut"; mkdir -p "$mdir"; cp "$fx/integration.schema.json" "$mdir/"
|
|
73
|
+
mutate() { jq "$1" "$good" > "$mdir/fixture-tool.json"; }
|
|
74
|
+
missing() { # <name reported> <jq del() path>
|
|
75
|
+
local name="$1" out r
|
|
76
|
+
mutate "del($2)"
|
|
77
|
+
out="$(KIT_INTEGRATIONS_DIR="$mdir" integration_validate "$mdir/fixture-tool.json" 2>&1)"; r=$?
|
|
78
|
+
rc "missing $name -> rc 1" "$r" "1"
|
|
79
|
+
has "missing $name -> named" "$out" "$name: required field is missing"
|
|
80
|
+
}
|
|
81
|
+
missing "id" ".id"
|
|
82
|
+
missing "label" ".label"
|
|
83
|
+
missing "summary" ".summary"
|
|
84
|
+
missing "config" ".config"
|
|
85
|
+
missing "config.key" ".config.key"
|
|
86
|
+
missing "detect" ".detect"
|
|
87
|
+
missing "detect.run" ".detect.run"
|
|
88
|
+
missing "install" ".install"
|
|
89
|
+
missing "install[1].manager" ".install[1].manager"
|
|
90
|
+
missing "install[0].run" ".install[0].run"
|
|
91
|
+
missing "verify" ".verify"
|
|
92
|
+
missing "verify.run" ".verify.run"
|
|
93
|
+
missing "docs" ".docs"
|
|
94
|
+
missing "attribution" ".attribution"
|
|
95
|
+
missing "attribution.author" ".attribution.author"
|
|
96
|
+
missing "attribution.homepage" ".attribution.homepage"
|
|
97
|
+
missing "attribution.affiliated" ".attribution.affiliated"
|
|
98
|
+
missing "attribution.notice" ".attribution.notice"
|
|
99
|
+
missing "wire.run" ".wire.run"
|
|
100
|
+
|
|
101
|
+
# ── 3. wrong shapes are rejected too, each with the field named ────────────────────────────────
|
|
102
|
+
rejects() { # <label> <jq mutation> <expected diagnostic substring>
|
|
103
|
+
local out r
|
|
104
|
+
mutate "$2"
|
|
105
|
+
out="$(KIT_INTEGRATIONS_DIR="$mdir" integration_validate "$mdir/fixture-tool.json" 2>&1)"; r=$?
|
|
106
|
+
rc "$1 -> rc 1" "$r" "1"
|
|
107
|
+
has "$1 -> diagnostic" "$out" "$3"
|
|
108
|
+
}
|
|
109
|
+
rejects "empty install list" '.install = []' "install: needs at least 1 item"
|
|
110
|
+
rejects "unknown install manager" '.install[0].manager = "apt"' "install[0].manager: must be one of"
|
|
111
|
+
rejects "affiliated as a string" '.attribution.affiliated = "no"' "attribution.affiliated: expected boolean, got string"
|
|
112
|
+
rejects "empty label" '.label = ""' "label: must not be empty"
|
|
113
|
+
rejects "extension without a dot" '.appliesWhen.anyExtension = ["ts"]' "appliesWhen.anyExtension[0]: does not match"
|
|
114
|
+
rejects "empty extension list" '.appliesWhen.anyExtension = []' "appliesWhen.anyExtension: needs at least 1 item"
|
|
115
|
+
rejects "unknown top-level field" '.lable = "typo"' "lable: unknown field"
|
|
116
|
+
rejects "config key that is no path" '.config.key = "codeGraph"' "config.key: does not match"
|
|
117
|
+
rejects "config key named after the vendor" '.config.key = "fixtureTool.enabled"' "config.key: names the tool"
|
|
118
|
+
rejects "id that is not the file name" '.id = "other-tool"' "id: 'other-tool' must match the file name 'fixture-tool'"
|
|
119
|
+
rejects "docs that is not a URL" '.docs = "see the readme"' "docs: does not match"
|
|
120
|
+
rejects "platform os outside the list" '.appliesWhen.platform = {"os":"Plan9"}' "appliesWhen.platform.os: must be one of"
|
|
121
|
+
rejects "unknown platform field" '.appliesWhen.platform = {"cpu":"arm64"}' "appliesWhen.platform.cpu: unknown field"
|
|
122
|
+
rejects "bootstrap without a command" '.install[0].bootstrap = {"manager":"brew"}' "install[0].bootstrap.run: required field is missing"
|
|
123
|
+
rejects "bootstrap by an unknown manager" '.install[0].bootstrap = {"manager":"apt","run":"apt install npm"}' "install[0].bootstrap.manager: must be one of"
|
|
124
|
+
rejects "empty detect.bin" '.detect.bin = ""' "detect.bin: must not be empty"
|
|
125
|
+
rejects "empty afterInstall" '.afterInstall = ""' "afterInstall: must not be empty"
|
|
126
|
+
rejects "empty alsoWrites" '.alsoWrites = []' "alsoWrites"
|
|
127
|
+
rejects "alsoWrites that is not a list" '.alsoWrites = "skills-lock.json"' "alsoWrites"
|
|
128
|
+
|
|
129
|
+
printf '{ not json' > "$mdir/fixture-tool.json"
|
|
130
|
+
out="$(integration_validate "$mdir/fixture-tool.json" 2>&1)"; r=$?
|
|
131
|
+
rc "invalid JSON -> rc 1" "$r" "1"
|
|
132
|
+
has "invalid JSON -> said so" "$out" "not valid JSON"
|
|
133
|
+
out="$(integration_validate "$tmp/nope.json" 2>&1)"; r=$?
|
|
134
|
+
rc "absent file -> rc 1" "$r" "1"
|
|
135
|
+
|
|
136
|
+
# ── 4. the registry: list, look up, validate all ───────────────────────────────────────────────
|
|
137
|
+
export KIT_INTEGRATIONS_DIR="$fx"
|
|
138
|
+
t "list names descriptors, never the schema" "$(integrations_list | tr '\n' ' ')" "fixture-tool "
|
|
139
|
+
t "lookup by id returns the file" "$(integration_file fixture-tool)" "$good"
|
|
140
|
+
integration_file nope >/dev/null 2>&1; rc "unknown id -> rc 1" "$?" "1"
|
|
141
|
+
integration_file ../etc/passwd >/dev/null 2>&1; rc "id that climbs out of the dir -> rc 1" "$?" "1"
|
|
142
|
+
integrations_validate_all >/dev/null 2>&1; rc "validate-all over a clean dir -> rc 0" "$?" "0"
|
|
143
|
+
jq 'del(.verify)' "$good" > "$fx/broken.json"
|
|
144
|
+
out="$(integrations_validate_all 2>&1)"; r=$?
|
|
145
|
+
rc "validate-all with one bad descriptor -> rc 1" "$r" "1"
|
|
146
|
+
has "validate-all names the descriptor and the field" "$out" "broken: verify: required field is missing"
|
|
147
|
+
rm -f "$fx/broken.json"
|
|
148
|
+
|
|
149
|
+
# ── 5. applicability: offered only where the tool can work ─────────────────────────────────────
|
|
150
|
+
repo="$tmp/repo"; mkdir -p "$repo/scripts/lib"
|
|
151
|
+
printf 'echo hi\n' > "$repo/scripts/lib/a.sh"; printf 'echo hi\n' > "$repo/run.sh"
|
|
152
|
+
integration_applies "$good" "$repo"; rc "repo holding only .sh files -> does not apply" "$?" "1"
|
|
153
|
+
printf 'x\n' > "$repo/notes.ts.bak"; printf 'x\n' > "$repo/.ts"; printf 'x\n' > "$repo/r.r"
|
|
154
|
+
integration_applies "$good" "$repo"; rc "look-alike names (.ts.bak, a bare .ts, wrong case) -> still does not apply" "$?" "1"
|
|
155
|
+
mkdir -p "$repo/node_modules/dep"; printf 'x\n' > "$repo/node_modules/dep/index.ts"
|
|
156
|
+
integration_applies "$good" "$repo"; rc "a .ts file only under node_modules -> does not apply" "$?" "1"
|
|
157
|
+
mkdir -p "$repo/src"; printf 'export {}\n' > "$repo/src/app.ts"
|
|
158
|
+
integration_applies "$good" "$repo"; rc "a .ts file added -> applies" "$?" "0"
|
|
159
|
+
|
|
160
|
+
# Inside a git work tree the file list is git's, so an ignored file does not make the tool apply.
|
|
161
|
+
if command -v git >/dev/null 2>&1; then
|
|
162
|
+
grepo="$tmp/grepo"; mkdir -p "$grepo/dist"
|
|
163
|
+
git -C "$grepo" init -q 2>/dev/null
|
|
164
|
+
printf 'echo hi\n' > "$grepo/run.sh"; printf 'dist/\n' > "$grepo/.gitignore"
|
|
165
|
+
printf 'x\n' > "$grepo/dist/out.ts"
|
|
166
|
+
integration_applies "$good" "$grepo"; rc "git repo: a gitignored .ts file -> does not apply" "$?" "1"
|
|
167
|
+
printf 'x\n' > "$grepo/untracked.tsx"
|
|
168
|
+
integration_applies "$good" "$grepo"; rc "git repo: an untracked, unignored .tsx file -> applies" "$?" "0"
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
# No predicate = language-agnostic (the two migrating installers): applies everywhere.
|
|
172
|
+
jq 'del(.appliesWhen)' "$good" > "$tmp/agnostic.json"
|
|
173
|
+
integration_applies "$tmp/agnostic.json" "$repo/scripts"; rc "no appliesWhen -> applies anywhere" "$?" "0"
|
|
174
|
+
integration_applies "$good" "$tmp/does-not-exist"; rc "absent dir -> does not apply" "$?" "1"
|
|
175
|
+
|
|
176
|
+
# The second kind of condition judges the MACHINE: `platform` is compared to `uname` verbatim. A
|
|
177
|
+
# stub `uname` first on PATH makes this the same on every host.
|
|
178
|
+
ubin="$tmp/ubin"; mkdir -p "$ubin"
|
|
179
|
+
printf '#!/bin/sh\ncase "${1:-}" in -m) echo "$FAKE_ARCH" ;; *) echo "$FAKE_OS" ;; esac\n' > "$ubin/uname"; chmod +x "$ubin/uname"
|
|
180
|
+
on_machine() { FAKE_OS="$1" FAKE_ARCH="$2" PATH="$ubin:$PATH" integration_applies "$3" "$4"; }
|
|
181
|
+
jq 'del(.appliesWhen) | .appliesWhen = {"platform":{"os":"Darwin","arch":"arm64"}}' "$good" > "$tmp/plat.json"
|
|
182
|
+
on_machine Darwin arm64 "$tmp/plat.json" "$repo/scripts"; rc "platform matches -> applies, whatever the repo holds" "$?" "0"
|
|
183
|
+
on_machine Darwin x86_64 "$tmp/plat.json" "$repo"; rc "wrong arch -> does not apply" "$?" "1"
|
|
184
|
+
on_machine Linux arm64 "$tmp/plat.json" "$repo"; rc "wrong os -> does not apply" "$?" "1"
|
|
185
|
+
jq '.appliesWhen = {"platform":{"os":"Linux"}}' "$good" > "$tmp/os-only.json"
|
|
186
|
+
on_machine Linux aarch64 "$tmp/os-only.json" "$repo"; rc "os alone, arch unstated -> any arch applies" "$?" "0"
|
|
187
|
+
# Both kinds present: every one must hold.
|
|
188
|
+
jq '.appliesWhen.platform = {"os":"Darwin","arch":"arm64"}' "$good" > "$tmp/both.json"
|
|
189
|
+
on_machine Darwin arm64 "$tmp/both.json" "$repo"; rc "platform + extension both hold -> applies" "$?" "0"
|
|
190
|
+
on_machine Darwin arm64 "$tmp/both.json" "$repo/scripts"; rc "platform holds, no listed extension -> does not apply" "$?" "1"
|
|
191
|
+
on_machine Darwin x86_64 "$tmp/both.json" "$repo"; rc "extension holds, wrong platform -> does not apply" "$?" "1"
|
|
192
|
+
t "the conditions in words: extensions" "$(integration_applies_needs "$good")" "at least one file ending in: .ts .tsx .R"
|
|
193
|
+
t "the conditions in words: platform" "$(integration_applies_needs "$tmp/plat.json")" "a Darwin arm64 machine"
|
|
194
|
+
t "the conditions in words: both" "$(integration_applies_needs "$tmp/both.json")" "a Darwin arm64 machine, and at least one file ending in: .ts .tsx .R"
|
|
195
|
+
t "the conditions in words: none" "$(integration_applies_needs "$tmp/agnostic.json")" ""
|
|
196
|
+
|
|
197
|
+
# ── 6. the config key that turns it on ─────────────────────────────────────────────────────────
|
|
198
|
+
t "config key is read from the descriptor" "$(integration_config_key "$good")" "codeGraph.provider"
|
|
199
|
+
printf '{"codeGraph":{"provider":"fixture-tool-provider"}}' > "$tmp/on.json"
|
|
200
|
+
printf '{"codeGraph":{"provider":"none"}}' > "$tmp/off.json"
|
|
201
|
+
printf '{"codeGraph":"oops"}' > "$tmp/odd.json"
|
|
202
|
+
printf '{}' > "$tmp/unset.json"
|
|
203
|
+
integration_enabled "$good" "$tmp/on.json"; rc "key holds the descriptor's value -> enabled" "$?" "0"
|
|
204
|
+
integration_enabled "$good" "$tmp/off.json"; rc "key holds another value -> not enabled" "$?" "1"
|
|
205
|
+
integration_enabled "$good" "$tmp/unset.json"; rc "key unset -> not enabled" "$?" "1"
|
|
206
|
+
integration_enabled "$good" "$tmp/odd.json"; rc "key path runs through a non-object -> not enabled" "$?" "1"
|
|
207
|
+
integration_enabled "$good" "$tmp/nope.json"; rc "no config file -> not enabled" "$?" "1"
|
|
208
|
+
# No `value` in the descriptor = a boolean switch (memory.enabled / local.enabled).
|
|
209
|
+
jq '.config = {"key":"memory.enabled"}' "$good" > "$tmp/bool.json"
|
|
210
|
+
printf '{"memory":{"enabled":true}}' > "$tmp/mem-on.json"
|
|
211
|
+
printf '{"memory":{"enabled":false}}' > "$tmp/mem-off.json"
|
|
212
|
+
integration_enabled "$tmp/bool.json" "$tmp/mem-on.json"; rc "boolean key true -> enabled" "$?" "0"
|
|
213
|
+
integration_enabled "$tmp/bool.json" "$tmp/mem-off.json"; rc "boolean key false -> not enabled" "$?" "1"
|
|
214
|
+
# `config.default: true` (#451) = on wherever the config does not hold the key; only an explicit
|
|
215
|
+
# other value turns it off. No config file is still "not enabled": there is no project to be on in.
|
|
216
|
+
jq '.config = {"key":"memory.enabled","default":true}' "$good" > "$tmp/defon.json"
|
|
217
|
+
# Validated under the fixture's own file name: the id must match the stem.
|
|
218
|
+
mkdir -p "$tmp/defon" "$tmp/defbad"; cp "$tmp/defon.json" "$tmp/defon/fixture-tool.json"
|
|
219
|
+
integration_validate "$tmp/defon/fixture-tool.json" >/dev/null 2>&1; rc "config.default is a valid field" "$?" "0"
|
|
220
|
+
integration_enabled "$tmp/defon.json" "$tmp/unset.json"; rc "default-on, key unset -> enabled" "$?" "0"
|
|
221
|
+
integration_enabled "$tmp/defon.json" "$tmp/mem-on.json"; rc "default-on, key true -> enabled" "$?" "0"
|
|
222
|
+
integration_enabled "$tmp/defon.json" "$tmp/mem-off.json"; rc "default-on, key false -> not enabled" "$?" "1"
|
|
223
|
+
integration_enabled "$tmp/defon.json" "$tmp/nope.json"; rc "default-on, no config file -> not enabled" "$?" "1"
|
|
224
|
+
integration_default_on "$tmp/defon.json"; rc "integration_default_on: a default-on descriptor" "$?" "0"
|
|
225
|
+
integration_default_on "$tmp/bool.json"; rc "integration_default_on: an opt-in descriptor" "$?" "1"
|
|
226
|
+
integration_explicit "$tmp/defon.json" "$tmp/unset.json"; rc "integration_explicit: key absent" "$?" "1"
|
|
227
|
+
integration_explicit "$tmp/defon.json" "$tmp/mem-off.json"; rc "integration_explicit: key present and false" "$?" "0"
|
|
228
|
+
jq '.config = {"key":"memory.enabled","default":"yes"}' "$good" > "$tmp/defbad/fixture-tool.json"
|
|
229
|
+
has "config.default must be a boolean" "$(integration_validate "$tmp/defbad/fixture-tool.json" 2>&1)" "config.default: expected boolean"
|
|
230
|
+
lav="$ROOT/integrations/lavish.json"
|
|
231
|
+
integration_validate "$lav" >/dev/null 2>&1; rc "lavish validates" "$?" "0"
|
|
232
|
+
t "lavish: turned off by reviewPages.enabled" "$(integration_config_key "$lav")" "reviewPages.enabled"
|
|
233
|
+
integration_default_on "$lav"; rc "lavish: on by default" "$?" "0"
|
|
234
|
+
t "lavish: ships the review-pages rule" "$(jq -c '.rules' "$lav")" '["review-pages"]'
|
|
235
|
+
t "lavish: its rule template exists" "$([ -f "$ROOT/templates/rules/review-pages.md" ] && echo yes || echo no)" "yes"
|
|
236
|
+
|
|
237
|
+
# ── 7. the CLI form other scripts call ─────────────────────────────────────────────────────────
|
|
238
|
+
t "--list" "$(bash "$LIB/integrations.sh" --list)" "fixture-tool"
|
|
239
|
+
bash "$LIB/integrations.sh" --validate >/dev/null 2>&1; rc "--validate (all) -> rc 0" "$?" "0"
|
|
240
|
+
bash "$LIB/integrations.sh" --validate fixture-tool >/dev/null 2>&1; rc "--validate <id> -> rc 0" "$?" "0"
|
|
241
|
+
bash "$LIB/integrations.sh" --applies fixture-tool "$repo" >/dev/null 2>&1; rc "--applies on a .ts repo -> rc 0" "$?" "0"
|
|
242
|
+
bash "$LIB/integrations.sh" --applies fixture-tool "$repo/scripts" >/dev/null 2>&1; rc "--applies on a .sh-only dir -> rc 1" "$?" "1"
|
|
243
|
+
bash "$LIB/integrations.sh" --bogus >/dev/null 2>&1; rc "unknown flag -> rc 2" "$?" "2"
|
|
244
|
+
|
|
245
|
+
# ── 8. the same functions under zsh (scripts/lib is sourced from zsh too) ──────────────────────
|
|
246
|
+
if command -v zsh >/dev/null 2>&1; then
|
|
247
|
+
zsh -fc "source '$LIB/integrations.sh'; integration_validate '$good' && integration_applies '$good' '$repo' && [ \"\$(integrations_list)\" = fixture-tool ]" >/dev/null 2>&1
|
|
248
|
+
rc "zsh: source + validate + applies + list" "$?" "0"
|
|
249
|
+
zsh -fc "source '$LIB/integrations.sh'; integration_applies '$good' '$repo/scripts'" >/dev/null 2>&1
|
|
250
|
+
rc "zsh: .sh-only dir does not apply" "$?" "1"
|
|
251
|
+
fi
|
|
252
|
+
unset KIT_INTEGRATIONS_DIR
|
|
253
|
+
|
|
254
|
+
# ── 9. what actually ships ─────────────────────────────────────────────────────────────────────
|
|
255
|
+
jq -e . "$ROOT/integrations/integration.schema.json" >/dev/null 2>&1; rc "integration.schema.json is valid JSON" "$?" "0"
|
|
256
|
+
out="$(integrations_validate_all 2>&1)"; r=$?
|
|
257
|
+
rc "every shipped descriptor validates${out:+ ($out)}" "$r" "0"
|
|
258
|
+
jq -e . "$ROOT/kit.config.schema.json" >/dev/null 2>&1; rc "kit.config.schema.json is valid JSON" "$?" "0"
|
|
259
|
+
t "kit.config.schema.json declares codeGraph.provider" \
|
|
260
|
+
"$(jq -r '.properties.codeGraph.properties.provider.type // "absent"' "$ROOT/kit.config.schema.json")" "string"
|
|
261
|
+
# Every key a shipped descriptor turns on needs a row in the config schema (E303 "For agents").
|
|
262
|
+
for id in $(integrations_list); do
|
|
263
|
+
top="$(integration_config_key "$(integration_file "$id")" | cut -d. -f1)"
|
|
264
|
+
t "config schema has a property for $id's key ($top)" \
|
|
265
|
+
"$(jq -r --arg k "$top" '.properties | has($k)' "$ROOT/kit.config.schema.json")" "true"
|
|
266
|
+
done
|
|
267
|
+
|
|
268
|
+
# The two tools that used to be hardcoded in scripts/kit-doctor.sh (E303.4), one unit test each.
|
|
269
|
+
# They are unlike on purpose: the format has to carry both shapes.
|
|
270
|
+
t "shipped descriptors" "$(integrations_list | tr '\n' ' ')" "emil-design-eng graft impeccable lavish mempalace mlx-lm web-design-guidelines "
|
|
271
|
+
mp="$ROOT/integrations/mempalace.json"; mlx="$ROOT/integrations/mlx-lm.json"
|
|
272
|
+
integration_validate "$mp" >/dev/null 2>&1; rc "mempalace validates" "$?" "0"
|
|
273
|
+
t "mempalace: turned on by memory.enabled" "$(integration_config_key "$mp")" "memory.enabled"
|
|
274
|
+
t "mempalace: pipx first, uv second" "$(jq -r '[.install[].run] | join(" | ")' "$mp")" "pipx install mempalace | uv tool install mempalace"
|
|
275
|
+
t "mempalace: bootstrap brings pipx, the FIRST candidate's manager" "$(jq -r '.install[0].bootstrap | "\(.manager): \(.run)"' "$mp")" "brew: brew install pipx"
|
|
276
|
+
t "mempalace: no applicability condition" "$(jq -r 'has("appliesWhen")' "$mp")" "false"
|
|
277
|
+
on_machine Linux x86_64 "$mp" "$repo/scripts"; rc "mempalace applies on any machine and repo" "$?" "0"
|
|
278
|
+
t "mempalace: not affiliated" "$(jq -r '.attribution.affiliated' "$mp")" "false"
|
|
279
|
+
integration_validate "$mlx" >/dev/null 2>&1; rc "mlx-lm validates" "$?" "0"
|
|
280
|
+
t "mlx-lm: turned on by local.enabled" "$(integration_config_key "$mlx")" "local.enabled"
|
|
281
|
+
t "mlx-lm: uv first, pipx second" "$(jq -r '[.install[].run] | join(" | ")' "$mlx")" "uv tool install mlx-lm | pipx install mlx-lm"
|
|
282
|
+
t "mlx-lm: bootstrap is brew install uv" "$(jq -r '.install[0].bootstrap | "\(.manager): \(.run)"' "$mlx")" "brew: brew install uv"
|
|
283
|
+
on_machine Darwin arm64 "$mlx" "$repo/scripts"; rc "mlx-lm applies on Apple silicon" "$?" "0"
|
|
284
|
+
on_machine Darwin x86_64 "$mlx" "$repo"; rc "mlx-lm does not apply on an Intel Mac" "$?" "1"
|
|
285
|
+
on_machine Linux aarch64 "$mlx" "$repo"; rc "mlx-lm does not apply on Linux" "$?" "1"
|
|
286
|
+
t "mlx-lm: not affiliated" "$(jq -r '.attribution.affiliated' "$mlx")" "false"
|
|
287
|
+
# Neither descriptor may fall back to plain pip: Homebrew's Python is externally managed (PEP 668).
|
|
288
|
+
t "no shipped candidate is a plain pip install" \
|
|
289
|
+
"$(jq -r '.install[].run, (.install[].bootstrap.run // empty)' "$mp" "$mlx" | grep -cE '(^| )pip3? install' )" "0"
|
|
290
|
+
|
|
291
|
+
# Graft (E303.10): the first descriptor that judges the REPO (anyExtension), wires into it, and
|
|
292
|
+
# ships a rule. The wire flags below are the ones the hook-merge test ran with.
|
|
293
|
+
gr="$ROOT/integrations/graft.json"
|
|
294
|
+
integration_validate "$gr" >/dev/null 2>&1; rc "graft validates" "$?" "0"
|
|
295
|
+
t "graft: turned on by codeGraph.provider" "$(integration_config_key "$gr")" "codeGraph.provider"
|
|
296
|
+
t "graft: ON value names the provider" "$(jq -r '.config.value' "$gr")" "graft"
|
|
297
|
+
t "graft: npm before pnpm" "$(jq -r '[.install[].manager] | join(" ")' "$gr")" "npm pnpm"
|
|
298
|
+
t "graft: every candidate leaves a binary (the wire step needs one)" "$(jq -r '[.install[] | select(.resident == false)] | length' "$gr")" "0"
|
|
299
|
+
t "graft: wire flags decline the statusline and every out-of-repo write" \
|
|
300
|
+
"$(jq -r '.wire.declined | keys_unsorted | join(" ")' "$gr")" "--no-statusline --no-global"
|
|
301
|
+
t "graft: hooks are NOT declined" "$(jq -r '.wire.declined | has("--no-hooks")' "$gr")" "false"
|
|
302
|
+
has "graft: the hook decision records its test" "$(jq -r '.wire.kept.hooks' "$gr")" "All four entries survived"
|
|
303
|
+
t "graft: never auto-runs the LLM build" "$(jq -r '.build.deep.auto' "$gr")" "false"
|
|
304
|
+
t "graft: not affiliated" "$(jq -r '.attribution.affiliated' "$gr")" "false"
|
|
305
|
+
on_machine Darwin arm64 "$gr" "$repo/scripts"; rc "graft does not apply to a .sh-only repo" "$?" "1"
|
|
306
|
+
on_machine Linux x86_64 "$gr" "$repo"; rc "graft applies once a .ts file exists" "$?" "0"
|
|
307
|
+
# Every rule a descriptor ships must exist as a template, or `cckit add` would write nothing.
|
|
308
|
+
for id in $(integrations_list); do
|
|
309
|
+
for r in $(jq -r '.rules // [] | .[]' "$(integration_file "$id")"); do
|
|
310
|
+
t "$id: rule template $r exists" "$([ -f "$ROOT/templates/rules/$r.md" ] && echo yes || echo no)" "yes"
|
|
311
|
+
done
|
|
312
|
+
done
|
|
313
|
+
t "graft: ships the code-retrieval rule" "$(jq -c '.rules' "$gr")" '["code-retrieval"]'
|
|
314
|
+
rule="$ROOT/templates/rules/code-retrieval.md"
|
|
315
|
+
# `cckit add` copies the rule verbatim, so it must hold nothing init.sh would have to resolve.
|
|
316
|
+
t "code-retrieval: no template variable or IF block" "$(grep -cE '\{\{|<!-- /?IF:' "$rule")" "0"
|
|
317
|
+
t "code-retrieval: names no machine-specific search tool" "$(grep -ciE '(^|[^a-z])fff([^a-z]|$)' "$rule")" "0"
|
|
318
|
+
for verb in 'graft ask' 'graft grep' 'graft skeleton' 'graft callers' 'graft map' 'graft blast --base'; do
|
|
319
|
+
has "code-retrieval routes: $verb" "$(cat "$rule")" "$verb"
|
|
320
|
+
done
|
|
321
|
+
has "code-retrieval: the fallback is silent" "$(cat "$rule")" "Fall back to Grep/Glob silently"
|
|
322
|
+
has "code-retrieval: the vendor numbers are attributed" "$(cat "$rule")" "cckit has not reproduced them"
|
|
323
|
+
bad="$(jq '.rules = ["Not A Rule"]' "$gr" > "$tmp/graft.json"; integration_validate "$tmp/graft.json" 2>&1)"
|
|
324
|
+
has "a rule name outside the grammar is refused" "$bad" "rules[0]"
|
|
325
|
+
bad="$(jq '.wire.kept = "yes"' "$gr" > "$tmp/graft.json"; integration_validate "$tmp/graft.json" 2>&1)"
|
|
326
|
+
has "wire.kept must be an object" "$bad" "wire.kept: expected object"
|
|
327
|
+
|
|
328
|
+
t "kit.config.schema.json declares local.enabled" \
|
|
329
|
+
"$(jq -r '.properties.local.properties.enabled.type // "absent"' "$ROOT/kit.config.schema.json")" "boolean"
|
|
330
|
+
# The three design skills `page-design` coordinates (#504). A skill is files, not a binary: detect
|
|
331
|
+
# and verify are file checks in the project and in ~/.claude/skills, and each is off until added.
|
|
332
|
+
for id in impeccable emil-design-eng web-design-guidelines; do
|
|
333
|
+
d="$ROOT/integrations/$id.json"
|
|
334
|
+
integration_validate "$d" >/dev/null 2>&1; rc "$id validates" "$?" "0"
|
|
335
|
+
integration_default_on "$d"; rc "$id: off until added" "$?" "1"
|
|
336
|
+
t "$id: ON value names the skill" "$(jq -r '.config.value' "$d")" "$id"
|
|
337
|
+
t "$id: detect is a file check for the skill" "$(jq -r '.detect.run' "$d")" \
|
|
338
|
+
"test -f .claude/skills/$id/SKILL.md || test -f \"\$HOME/.claude/skills/$id/SKILL.md\""
|
|
339
|
+
t "$id: verify is the same check" "$(jq -r '.verify.run' "$d")" "$(jq -r '.detect.run' "$d")"
|
|
340
|
+
t "$id: one npx candidate" "$(jq -r '[.install[].manager] | join(" ")' "$d")" "npx"
|
|
341
|
+
t "$id: names a licence" "$(jq -r '.attribution.license | length > 0' "$d")" "true"
|
|
342
|
+
t "$id: not affiliated" "$(jq -r '.attribution.affiliated' "$d")" "false"
|
|
343
|
+
t "$id: the install note dates the one run on record" "$(jq -r '.install[0].note | test("One run is on record, on 2026-11-13")' "$d")" "true"
|
|
344
|
+
t "$id: alsoWrites names what that run wrote besides the skill" "$(jq -r '.alsoWrites | length > 0' "$d")" "true"
|
|
345
|
+
done
|
|
346
|
+
t "the three design keys are three capabilities" \
|
|
347
|
+
"$(for id in impeccable emil-design-eng web-design-guidelines; do integration_config_key "$ROOT/integrations/$id.json"; done | tr '\n' ' ')" \
|
|
348
|
+
"designDirection.provider designMotion.provider designAudit.provider "
|
|
349
|
+
t "impeccable: the add text names the binary download" "$(jq -r '.why | test("downloaded once into ~/.impeccable/bin/")' "$ROOT/integrations/impeccable.json")" "true"
|
|
350
|
+
t "impeccable: the add text names the catalogue fetch" "$(jq -r '.why | test("impeccable.style catalogue")' "$ROOT/integrations/impeccable.json")" "true"
|
|
351
|
+
t "impeccable: installs into the project, for Claude Code" "$(jq -r '.install[0].run' "$ROOT/integrations/impeccable.json")" "npx -y impeccable install --providers=claude --scope=project"
|
|
352
|
+
t "emil-design-eng: one skill, not the pack" "$(jq -r '.install[0].run' "$ROOT/integrations/emil-design-eng.json")" "npx -y skills@latest add emilkowalski/skills --skill emil-design-eng -a claude-code -y"
|
|
353
|
+
t "web-design-guidelines: one skill" "$(jq -r '.install[0].run' "$ROOT/integrations/web-design-guidelines.json")" "npx -y skills@latest add vercel-labs/agent-skills --skill web-design-guidelines -a claude-code -y"
|
|
354
|
+
t "web-design-guidelines: the licence line says where MIT is stated" "$(jq -r '.attribution.notice | test("holds no LICENSE file")' "$ROOT/integrations/web-design-guidelines.json")" "true"
|
|
355
|
+
# A skill in the project is detected with no tool on PATH; a project without it is not.
|
|
356
|
+
sk="$(mktemp -d)"
|
|
357
|
+
( cd "$sk" && HOME="$sk/home" sh -c "$(jq -r '.detect.run' "$ROOT/integrations/impeccable.json")" ); rc "impeccable: not detected in an empty project" "$?" "1"
|
|
358
|
+
mkdir -p "$sk/.claude/skills/impeccable"; : > "$sk/.claude/skills/impeccable/SKILL.md"
|
|
359
|
+
( cd "$sk" && HOME="$sk/home" sh -c "$(jq -r '.detect.run' "$ROOT/integrations/impeccable.json")" ); rc "impeccable: detected from the project's skill file" "$?" "0"
|
|
360
|
+
rm -rf "$sk"
|
|
361
|
+
|
|
362
|
+
t "package.json ships integrations/ in the npm tarball" \
|
|
363
|
+
"$(jq -r '.files | index("integrations") != null' "$ROOT/package.json")" "true"
|
|
364
|
+
|
|
365
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (integrations)" || echo "integrations: FAILURES"
|
|
366
|
+
exit "$fail"
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# integrations.sh — the integration registry: one JSON descriptor per optional third-party tool
|
|
3
|
+
# in integrations/ at the plugin root, beside modules/ and interview/ (E303.1).
|
|
4
|
+
#
|
|
5
|
+
# A descriptor is DATA: label, the config key that turns the tool on, a detect command, ordered
|
|
6
|
+
# install candidates, a verify command, a docs link, an attribution block, and an optional
|
|
7
|
+
# applicability predicate. This file reads and checks that data. It installs nothing and writes
|
|
8
|
+
# nothing — the runner that acts on a descriptor is a separate lib.
|
|
9
|
+
#
|
|
10
|
+
# Source it: source scripts/lib/integrations.sh
|
|
11
|
+
# integrations_dir where descriptors live ($KIT_INTEGRATIONS_DIR overrides)
|
|
12
|
+
# integrations_list descriptor ids, sorted, one per line
|
|
13
|
+
# integration_file <id> path of one descriptor; rc 1 when there is none
|
|
14
|
+
# integration_validate <file> rc 0, or rc 1 with one `<id>: <field>: <problem>` line
|
|
15
|
+
# per problem on stderr
|
|
16
|
+
# integrations_validate_all validate every descriptor; rc 1 if any fails
|
|
17
|
+
# integration_applies <file> [dir] rc 0 when the tool can work on the repo at dir, on this
|
|
18
|
+
# machine
|
|
19
|
+
# integration_applies_needs <file> the descriptor's conditions in words, for a decline message
|
|
20
|
+
# integration_config_key <file> the dotted config key that turns it on
|
|
21
|
+
# integration_enabled <file> [config] rc 0 when that key holds the descriptor's ON value, or
|
|
22
|
+
# is absent and the descriptor is on by default
|
|
23
|
+
# integration_default_on <file> rc 0 when the descriptor sets `config.default: true`
|
|
24
|
+
# integration_explicit <file> [config] rc 0 when the config holds the key at all
|
|
25
|
+
# CLI: integrations.sh --list
|
|
26
|
+
# integrations.sh --validate [id|file]
|
|
27
|
+
# integrations.sh --applies <id|file> [dir]
|
|
28
|
+
# Requires: jq. bash 3.2 + zsh compatible.
|
|
29
|
+
# errors: pure — reads descriptors and the repo's file list; rc reports the answer, nothing is written
|
|
30
|
+
|
|
31
|
+
_kit_ig_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
32
|
+
# shellcheck source=/dev/null
|
|
33
|
+
. "$_kit_ig_dir/kit-cli.sh" # kit_is_main, kit_warn
|
|
34
|
+
# shellcheck source=/dev/null
|
|
35
|
+
. "$_kit_ig_dir/config-path.sh" # kit_config_path
|
|
36
|
+
|
|
37
|
+
_kit_ig_schema_name="integration.schema.json"
|
|
38
|
+
|
|
39
|
+
_kit_ig_require() { command -v jq >/dev/null 2>&1 || { kit_warn "integrations: jq is required"; return 1; }; }
|
|
40
|
+
|
|
41
|
+
# integrations_dir -> the descriptor directory. Plugin root = two levels up from scripts/lib/.
|
|
42
|
+
integrations_dir() {
|
|
43
|
+
if [ -n "${KIT_INTEGRATIONS_DIR:-}" ]; then printf '%s\n' "$KIT_INTEGRATIONS_DIR"; return 0; fi
|
|
44
|
+
if [ -n "${KIT_PLUGIN_ROOT:-}" ]; then printf '%s/integrations\n' "$KIT_PLUGIN_ROOT"; return 0; fi
|
|
45
|
+
if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then printf '%s/integrations\n' "$CLAUDE_PLUGIN_ROOT"; return 0; fi
|
|
46
|
+
printf '%s/integrations\n' "$(CDPATH='' cd -- "$_kit_ig_dir/../.." && pwd)"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# integrations_list -> ids, sorted. The schema lives in the same dir and is not a descriptor.
|
|
50
|
+
# `find`, not a glob: an unmatched glob is an error under zsh, and an empty registry is valid.
|
|
51
|
+
integrations_list() {
|
|
52
|
+
local d; d="$(integrations_dir)"
|
|
53
|
+
[ -d "$d" ] || return 0
|
|
54
|
+
find "$d" -maxdepth 1 -type f -name '*.json' ! -name "$_kit_ig_schema_name" 2>/dev/null \
|
|
55
|
+
| sed -e 's#.*/##' -e 's#\.json$##' | sort
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# integration_file <id> -> path. The id is checked against the id grammar first, so an argument
|
|
59
|
+
# like `../x` can never resolve to a file outside the registry.
|
|
60
|
+
integration_file() {
|
|
61
|
+
local id="${1:-}" f
|
|
62
|
+
grep -qE '^[a-z][a-z0-9]*(-[a-z0-9]+)*$' <<<"$id" || return 1
|
|
63
|
+
f="$(integrations_dir)/$id.json"
|
|
64
|
+
[ -f "$f" ] || return 1
|
|
65
|
+
printf '%s\n' "$f"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# The schema checker. integration.schema.json is the one statement of the format; this walks a
|
|
69
|
+
# descriptor against it instead of restating the required fields in bash. It implements the
|
|
70
|
+
# keywords the schema uses and no others (the schema's own description lists them).
|
|
71
|
+
# shellcheck disable=SC2016
|
|
72
|
+
_kit_ig_check_jq='
|
|
73
|
+
def at($p; $k): if $p == "" then $k else "\($p).\($k)" end;
|
|
74
|
+
def chk($s; $p):
|
|
75
|
+
. as $v | ($v | type) as $vt
|
|
76
|
+
| (if ($s | has("type")) and $vt != $s.type
|
|
77
|
+
then "\(if $p == "" then "(descriptor)" else $p end): expected \($s.type), got \($vt)" else empty end),
|
|
78
|
+
(if ($s | has("enum")) and (any($s.enum[]; . == $v) | not)
|
|
79
|
+
then "\($p): must be one of \($s.enum | map(tostring) | join(", "))" else empty end),
|
|
80
|
+
(if $vt == "string" then
|
|
81
|
+
(if ($s | has("minLength")) and ($v | length) < $s.minLength then "\($p): must not be empty" else empty end),
|
|
82
|
+
(if ($s | has("pattern")) and ($v | test($s.pattern) | not) then "\($p): does not match \($s.pattern)" else empty end)
|
|
83
|
+
elif $vt == "array" then
|
|
84
|
+
(if ($s | has("minItems")) and ($v | length) < $s.minItems
|
|
85
|
+
then "\($p): needs at least \($s.minItems) item(s)" else empty end),
|
|
86
|
+
(if ($s | has("items")) then ($v | to_entries[] | .key as $i | .value | chk($s.items; "\($p)[\($i)]")) else empty end)
|
|
87
|
+
elif $vt == "object" and ($s.type // "") == "object" then
|
|
88
|
+
(($s.required // [])[] | . as $k | select($v | has($k) | not) | "\(at($p; $k)): required field is missing"),
|
|
89
|
+
(($s.properties // {}) | to_entries[] | .key as $k | .value as $sub
|
|
90
|
+
| select($v | has($k)) | $v[$k] | chk($sub; at($p; $k))),
|
|
91
|
+
(if $s.additionalProperties == false
|
|
92
|
+
then ($v | keys[] | . as $k | select(($s.properties // {}) | has($k) | not) | "\(at($p; $k)): unknown field")
|
|
93
|
+
else empty end)
|
|
94
|
+
else empty end);
|
|
95
|
+
chk($schema[0]; ""),
|
|
96
|
+
# Two rules the schema cannot express.
|
|
97
|
+
(if (.id | type) == "string" and .id != $stem
|
|
98
|
+
then "id: \($q)\(.id)\($q) must match the file name \($q)\($stem)\($q)" else empty end),
|
|
99
|
+
(if (.id | type) == "string" and (.config.key? | type) == "string"
|
|
100
|
+
and ((.id | ascii_downcase | gsub("[^a-z0-9]"; "")) as $vendor
|
|
101
|
+
| any(.config.key | ascii_downcase | split(".")[]; . == $vendor))
|
|
102
|
+
then "config.key: names the tool (\(.config.key)) — name the capability, e.g. <capability>.provider" else empty end)
|
|
103
|
+
'
|
|
104
|
+
|
|
105
|
+
# integration_validate <file> -> rc 0 clean; rc 1 with one line per problem on stderr.
|
|
106
|
+
integration_validate() {
|
|
107
|
+
_kit_ig_require || return 1
|
|
108
|
+
local f="${1:-}" stem schema out
|
|
109
|
+
[ -n "$f" ] && [ -f "$f" ] || { kit_warn "integrations: no descriptor at '${f}'"; return 1; }
|
|
110
|
+
stem="$(basename "$f" .json)"
|
|
111
|
+
schema="$(integrations_dir)/$_kit_ig_schema_name"
|
|
112
|
+
[ -f "$schema" ] || { kit_warn "integrations: schema not found ($schema)"; return 1; }
|
|
113
|
+
jq -e . "$f" >/dev/null 2>&1 || { printf '%s: not valid JSON\n' "$stem" >&2; return 1; }
|
|
114
|
+
jq -e 'type == "object"' "$f" >/dev/null 2>&1 || { printf '%s: (descriptor): expected object\n' "$stem" >&2; return 1; }
|
|
115
|
+
out="$(jq -r --slurpfile schema "$schema" --arg stem "$stem" --arg q "'" "$_kit_ig_check_jq" "$f" 2>&1)" || {
|
|
116
|
+
printf '%s: validator failed: %s\n' "$stem" "$out" >&2; return 1; }
|
|
117
|
+
[ -z "$out" ] && return 0
|
|
118
|
+
printf '%s\n' "$out" | sed "s#^#$stem: #" >&2
|
|
119
|
+
return 1
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# integrations_validate_all -> rc 0 when every descriptor is clean (an empty registry is clean).
|
|
123
|
+
integrations_validate_all() {
|
|
124
|
+
local id bad=0
|
|
125
|
+
for id in $(integrations_list); do
|
|
126
|
+
integration_validate "$(integrations_dir)/$id.json" || bad=1
|
|
127
|
+
done
|
|
128
|
+
return "$bad"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# _kit_ig_repo_files <dir> -> the files a tool would see, one per line. Inside a git work tree
|
|
132
|
+
# that is git's own list (tracked + untracked, minus ignored), so build output and dependencies
|
|
133
|
+
# never make a tool look applicable. Outside one, every file except .git/ and node_modules/.
|
|
134
|
+
_kit_ig_repo_files() {
|
|
135
|
+
local d="$1"
|
|
136
|
+
if git -C "$d" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
137
|
+
git -C "$d" ls-files -co --exclude-standard 2>/dev/null
|
|
138
|
+
else
|
|
139
|
+
find "$d" -type f ! -path '*/.git/*' ! -path '*/node_modules/*' 2>/dev/null
|
|
140
|
+
fi
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# integration_applies <file> [dir] -> rc 0 when the tool can work on the repo at dir, on this
|
|
144
|
+
# machine. No `appliesWhen` = applies anywhere. Two kinds of condition; every one present must hold:
|
|
145
|
+
# platform `os` / `arch` equal `uname -s` / `uname -m` verbatim (the machine, not the repo)
|
|
146
|
+
# anyExtension at least one file ends in a listed extension (case-sensitive; a dotfile named
|
|
147
|
+
# exactly `.ts` has no extension)
|
|
148
|
+
# rc 1 otherwise, including an absent dir when the repo is what is being judged.
|
|
149
|
+
integration_applies() {
|
|
150
|
+
_kit_ig_require || return 1
|
|
151
|
+
local f="${1:-}" d="${2:-$PWD}" exts want_os want_arch
|
|
152
|
+
[ -f "$f" ] || return 1
|
|
153
|
+
want_os="$(jq -r '.appliesWhen.platform.os // ""' "$f" 2>/dev/null)" || return 1
|
|
154
|
+
want_arch="$(jq -r '.appliesWhen.platform.arch // ""' "$f" 2>/dev/null)" || return 1
|
|
155
|
+
if [ -n "$want_os" ] && [ "$(uname -s 2>/dev/null)" != "$want_os" ]; then return 1; fi
|
|
156
|
+
if [ -n "$want_arch" ] && [ "$(uname -m 2>/dev/null)" != "$want_arch" ]; then return 1; fi
|
|
157
|
+
exts="$(jq -r '.appliesWhen.anyExtension // [] | join(" ")' "$f" 2>/dev/null)" || return 1
|
|
158
|
+
[ -n "$exts" ] || return 0
|
|
159
|
+
[ -d "$d" ] || return 1
|
|
160
|
+
# The whole list is read (no early exit): closing the pipe early would SIGPIPE the lister and
|
|
161
|
+
# turn a match into a failure for a caller running under `pipefail`.
|
|
162
|
+
_kit_ig_repo_files "$d" | awk -v exts="$exts" '
|
|
163
|
+
BEGIN { n = split(exts, a, " "); for (i = 1; i <= n; i++) want[a[i]] = 1 }
|
|
164
|
+
{ b = $0; sub(/.*\//, "", b); i = match(b, /\.[^.]*$/); if (i > 1 && (substr(b, i) in want)) found = 1 }
|
|
165
|
+
END { exit(found ? 0 : 1) }'
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# integration_applies_needs <file> -> what the descriptor requires, in words, on one line. Empty
|
|
169
|
+
# when it has no `appliesWhen`. The one wording every decline message uses.
|
|
170
|
+
integration_applies_needs() {
|
|
171
|
+
_kit_ig_require || return 1
|
|
172
|
+
[ -f "${1:-}" ] || return 1
|
|
173
|
+
jq -r '(.appliesWhen // {}) as $a
|
|
174
|
+
| [ (($a.platform // {}) | [.os // empty, .arch // empty] | select(length > 0)
|
|
175
|
+
| "a " + join(" ") + " machine"),
|
|
176
|
+
(($a.anyExtension // []) | select(length > 0)
|
|
177
|
+
| "at least one file ending in: " + join(" ")) ]
|
|
178
|
+
| join(", and ")' "$1" 2>/dev/null
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
# integration_config_key <file> -> the dotted key, e.g. codeGraph.provider
|
|
182
|
+
integration_config_key() {
|
|
183
|
+
_kit_ig_require || return 1
|
|
184
|
+
jq -er '.config.key' "${1:-}" 2>/dev/null
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
# integration_enabled <file> [config] -> rc 0 when the project config holds the descriptor's ON
|
|
188
|
+
# value at its key (`config.value`, or boolean true when the descriptor names none). Another value
|
|
189
|
+
# or no config file at all is rc 1. An unset key is rc 1 too — off is the default, never an error —
|
|
190
|
+
# unless the descriptor sets `config.default: true`, which makes the unset key ON.
|
|
191
|
+
integration_enabled() {
|
|
192
|
+
_kit_ig_require || return 1
|
|
193
|
+
local f="${1:-}" cfg="${2:-}"
|
|
194
|
+
[ -f "$f" ] || return 1
|
|
195
|
+
[ -n "$cfg" ] || cfg="$(kit_config_path 2>/dev/null)" || return 1
|
|
196
|
+
[ -n "$cfg" ] && [ -f "$cfg" ] || return 1
|
|
197
|
+
jq -e --slurpfile d "$f" '
|
|
198
|
+
($d[0].config) as $c
|
|
199
|
+
| (if ($c | has("value")) then $c.value else true end) as $on
|
|
200
|
+
| (try getpath($c.key | split(".")) catch null) as $v
|
|
201
|
+
| if $v == null then ($c.default == true) else $v == $on end' "$cfg" >/dev/null 2>&1
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
# integration_default_on <file> -> rc 0 when the descriptor is on by default (`config.default`
|
|
205
|
+
# is true): on wherever the config does not hold its key.
|
|
206
|
+
integration_default_on() {
|
|
207
|
+
_kit_ig_require || return 1
|
|
208
|
+
[ -f "${1:-}" ] || return 1
|
|
209
|
+
jq -e '.config.default == true' "$1" >/dev/null 2>&1
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
# integration_explicit <file> [config] -> rc 0 when the project config HOLDS the descriptor's key,
|
|
213
|
+
# whatever its value. rc 1 for an absent key or no config: the difference between a project that
|
|
214
|
+
# chose the tool and one that only inherits a default.
|
|
215
|
+
integration_explicit() {
|
|
216
|
+
_kit_ig_require || return 1
|
|
217
|
+
local f="${1:-}" cfg="${2:-}"
|
|
218
|
+
[ -f "$f" ] || return 1
|
|
219
|
+
[ -n "$cfg" ] || cfg="$(kit_config_path 2>/dev/null)" || return 1
|
|
220
|
+
[ -n "$cfg" ] && [ -f "$cfg" ] || return 1
|
|
221
|
+
jq -e --slurpfile d "$f" '(try getpath($d[0].config.key | split(".")) catch null) != null' "$cfg" >/dev/null 2>&1
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# _kit_ig_arg <id|file> -> a descriptor path from either form.
|
|
225
|
+
_kit_ig_arg() {
|
|
226
|
+
if [ -f "${1:-}" ]; then printf '%s\n' "$1"; return 0; fi
|
|
227
|
+
integration_file "${1:-}" || { kit_warn "integrations: no integration '${1:-}'"; return 1; }
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
_kit_ig_main() {
|
|
231
|
+
local f
|
|
232
|
+
case "${1:-}" in
|
|
233
|
+
--list) integrations_list ;;
|
|
234
|
+
--validate)
|
|
235
|
+
if [ -n "${2:-}" ]; then f="$(_kit_ig_arg "$2")" || return 1; integration_validate "$f"
|
|
236
|
+
else integrations_validate_all; fi ;;
|
|
237
|
+
--applies)
|
|
238
|
+
f="$(_kit_ig_arg "${2:-}")" || return 1
|
|
239
|
+
integration_applies "$f" "${3:-$PWD}" ;;
|
|
240
|
+
*) kit_warn "usage: integrations.sh --list | --validate [id|file] | --applies <id|file> [dir]"; return 2 ;;
|
|
241
|
+
esac
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if kit_is_main; then _kit_ig_main "$@"; fi
|