rungate 0.2.0 → 0.3.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.
Files changed (282) hide show
  1. package/bin/rungate.ts +70 -0
  2. package/lib/aes-calculator.ts +66 -0
  3. package/lib/agent-audit.ts +139 -0
  4. package/lib/agent-brief-validation.ts +359 -0
  5. package/lib/agents-md-refs.ts +90 -0
  6. package/lib/bash-file-read.ts +197 -0
  7. package/lib/behavioral-cache.ts +78 -0
  8. package/lib/branch-cleanup.ts +234 -0
  9. package/lib/brief-context-parser.ts +35 -0
  10. package/lib/canary.ts +117 -0
  11. package/lib/check-registry.ts +226 -0
  12. package/lib/ci-checkout.ts +400 -0
  13. package/lib/cli-commands.ts +137 -0
  14. package/lib/compliance-backfill.ts +220 -0
  15. package/lib/compliance-report.ts +504 -0
  16. package/lib/compliance.ts +361 -0
  17. package/lib/config-loader.ts +255 -0
  18. package/lib/conformity.ts +1818 -131
  19. package/lib/container-provenance.ts +230 -0
  20. package/lib/create-brief.ts +150 -0
  21. package/lib/create-sc.ts +272 -0
  22. package/lib/deep-merge.ts +69 -0
  23. package/lib/dev-liveness.ts +214 -0
  24. package/lib/directive-extractor.ts +210 -0
  25. package/lib/distribution-standing.ts +113 -0
  26. package/lib/doc-hygiene.ts +238 -0
  27. package/lib/eval-criteria.ts +6 -0
  28. package/lib/evidence-portability.ts +123 -0
  29. package/lib/evidence-prevalidator.ts +390 -0
  30. package/lib/evidence-required.ts +150 -0
  31. package/lib/evidence-satisfiability.ts +288 -0
  32. package/lib/frontmatter.ts +163 -0
  33. package/lib/gap-scanner.ts +348 -0
  34. package/lib/gate-enforcement.ts +366 -0
  35. package/lib/generators/agent-briefs.ts +136 -0
  36. package/lib/generators/agents-md.ts +506 -0
  37. package/lib/generators/code-map.ts +60 -0
  38. package/lib/generators/types.ts +184 -0
  39. package/lib/git-ref-normalizer.ts +107 -0
  40. package/lib/github.ts +539 -0
  41. package/lib/harness-identity.ts +63 -0
  42. package/lib/hill-climb.ts +164 -0
  43. package/lib/instruction-effectiveness.ts +131 -0
  44. package/lib/issue-closure-audit.ts +225 -0
  45. package/lib/issue-create-override.ts +343 -0
  46. package/lib/js-top-level-code.ts +250 -0
  47. package/lib/liveness-contradiction.ts +149 -0
  48. package/lib/organize.ts +505 -0
  49. package/lib/paths.ts +197 -6
  50. package/lib/post-fix-verify.ts +157 -0
  51. package/lib/prior-branch.ts +489 -0
  52. package/lib/project-state-shape.ts +166 -0
  53. package/lib/promote-outputs.ts +156 -0
  54. package/lib/prove-label-gate.ts +35 -0
  55. package/lib/reachability.ts +302 -0
  56. package/lib/release-preflight.ts +186 -0
  57. package/lib/rule-health-pipeline.ts +264 -0
  58. package/lib/rule-health-trend.ts +161 -0
  59. package/lib/rule-provenance.ts +149 -0
  60. package/lib/rule-registry.ts +128 -0
  61. package/lib/rungate-schema.ts +114 -4
  62. package/lib/sc-claim-forms.ts +179 -0
  63. package/lib/sc-cover.ts +150 -0
  64. package/lib/sc-guard.ts +157 -0
  65. package/lib/sc-ids.ts +344 -0
  66. package/lib/scaffold/defaults.ts +165 -0
  67. package/lib/scaffold/managed-workflow.ts +370 -0
  68. package/lib/scaffold/owned-files.ts +265 -0
  69. package/lib/scaffold/steps.ts +2680 -0
  70. package/lib/scanner.ts +701 -0
  71. package/lib/screenshot-upload.ts +73 -0
  72. package/lib/secret-patterns.ts +112 -0
  73. package/lib/security-verdict.ts +616 -0
  74. package/lib/signal-phrases.ts +1 -0
  75. package/lib/spec-change-conformity.ts +80 -0
  76. package/lib/spec-files.ts +62 -0
  77. package/lib/spec-registry.ts +133 -0
  78. package/lib/spec-updater.ts +96 -0
  79. package/lib/stale-cleanup.ts +224 -0
  80. package/lib/stale-issue-scanner.ts +36 -0
  81. package/lib/strip-js-comments.ts +269 -0
  82. package/lib/suite-measurement.ts +228 -0
  83. package/lib/task-completion-checks.ts +177 -0
  84. package/lib/test-suite-lock.ts +1136 -0
  85. package/lib/transcript-checker.ts +1140 -0
  86. package/lib/validators/spec-validators.ts +171 -0
  87. package/lib/verdict-capture.ts +73 -0
  88. package/lib/verified-push.ts +358 -0
  89. package/lib/workflow-security.ts +174 -0
  90. package/lib/worktree-cleanup.ts +250 -0
  91. package/lib/worktree-collect.ts +283 -0
  92. package/lib/worktree-isolation.ts +82 -0
  93. package/package.json +36 -3
  94. package/prompts/ac-adversary.md +14 -2
  95. package/prompts/aditi.md +5 -0
  96. package/prompts/blast-radius.md +5 -0
  97. package/prompts/container-verify.md +5 -0
  98. package/prompts/discovery.md +4 -0
  99. package/prompts/environment.md +5 -0
  100. package/prompts/evidence-hierarchy.md +5 -0
  101. package/prompts/evidence-validator.md +11 -0
  102. package/prompts/marcus.md +5 -0
  103. package/prompts/prevention.md +5 -0
  104. package/prompts/prove-reproducer.md +12 -0
  105. package/prompts/quinn-decision-tree.md +5 -0
  106. package/prompts/quinn-ui-brief.md +5 -0
  107. package/prompts/quinn.md +5 -0
  108. package/prompts/rca.md +5 -0
  109. package/prompts/read-before-write.md +4 -0
  110. package/prompts/regression.md +5 -0
  111. package/prompts/serena.md +5 -0
  112. package/scripts/audit-specs.ts +464 -0
  113. package/scripts/convert-spec.ts +293 -0
  114. package/scripts/create-sc.ts +92 -0
  115. package/scripts/create-spec.ts +166 -0
  116. package/scripts/extract-constraints.ts +4 -3
  117. package/scripts/generate-code-map.ts +1 -1
  118. package/scripts/scaffold-project.ts +138 -1426
  119. package/scripts/sync-spec-tests.ts +211 -126
  120. package/.claude/agents/aditi.md +0 -47
  121. package/.claude/agents/marcus.md +0 -50
  122. package/.claude/agents/quinn.md +0 -58
  123. package/.claude/agents/rook.md +0 -47
  124. package/.claude/agents/serena.md +0 -46
  125. package/.claude/rungate.json +0 -11
  126. package/.fallowrc.json +0 -28
  127. package/.github/copilot-instructions.md +0 -20
  128. package/.rungate/conformity-findings.json +0 -648
  129. package/AGENTS.md +0 -106
  130. package/CODE-MAP.md +0 -50
  131. package/HARNESS.md +0 -88
  132. package/bun.lock +0 -26
  133. package/bunfig.toml +0 -2
  134. package/config/brief-policies.json +0 -28
  135. package/config/ceremony-profiles.json +0 -212
  136. package/config/consumer-cascade-map.json +0 -24
  137. package/config/doc-cascade-map.json +0 -24
  138. package/config/eval.json +0 -84
  139. package/config/profiles/account-plan.yaml +0 -36
  140. package/config/profiles/campaign.yaml +0 -94
  141. package/config/prove-evidence.schema.json +0 -65
  142. package/config/spec-policies.json +0 -36
  143. package/config/workflow-schema.json +0 -281
  144. package/gates/SCHEMA-GUIDE.md +0 -121
  145. package/gates/ac-quality.test.ts +0 -106
  146. package/gates/adversarial.test.ts +0 -274
  147. package/gates/brief-assembler.test.ts +0 -429
  148. package/gates/brief-assembler.ts +0 -334
  149. package/gates/bunfig.toml +0 -2
  150. package/gates/chain.test.ts +0 -91
  151. package/gates/e2e-smoke.test.ts +0 -234
  152. package/gates/error-classifier.test.ts +0 -249
  153. package/gates/error-classifier.ts +0 -89
  154. package/gates/orchestrator.test.ts +0 -950
  155. package/gates/orchestrator.ts +0 -569
  156. package/gates/preload.ts +0 -77
  157. package/gates/prompts/ac-adversary.md +0 -20
  158. package/gates/prompts/evidence-validator.md +0 -22
  159. package/gates/prompts/prove-reproducer.md +0 -53
  160. package/gates/prove.test.ts +0 -164
  161. package/gates/run-gate.ts +0 -936
  162. package/gates/schema-parity.test.ts +0 -197
  163. package/gates/schema.ts +0 -362
  164. package/gates/self-heal.test.ts +0 -511
  165. package/gates/self-heal.ts +0 -121
  166. package/gates/ship-orchestrator.test.ts +0 -379
  167. package/gates/ship-orchestrator.ts +0 -363
  168. package/gates/test-fixtures/broken-no-environments.json +0 -60
  169. package/gates/test-fixtures/valid-standard.json +0 -54
  170. package/gates/test-utils.ts +0 -43
  171. package/gates/witness.ts +0 -220
  172. package/gates/workflow.test.ts +0 -1053
  173. package/hooks/AgentBriefGuard.hook.ts +0 -586
  174. package/hooks/AgentVerdictCapture.hook.ts +0 -134
  175. package/hooks/AutoVerifyGate.hook.ts +0 -76
  176. package/hooks/GateEnforcement.hook.ts +0 -273
  177. package/hooks/IssueCloseGuard.hook.ts +0 -116
  178. package/hooks/MergeGuard.hook.ts +0 -55
  179. package/hooks/StaleTTLCleanup.hook.ts +0 -133
  180. package/hooks/VerifyPhaseLock.hook.ts +0 -81
  181. package/hooks/WorkflowStateGuard.hook.ts +0 -37
  182. package/hooks/lib/agentDetection.ts +0 -70
  183. package/hooks/lib/findWorkflow.ts +0 -101
  184. package/hooks/lib/parseStdin.ts +0 -37
  185. package/hooks/lib/paths.ts +0 -111
  186. package/hooks/lib/utils.ts +0 -81
  187. package/reference/migration-manifest.json +0 -554
  188. package/reference/prompts/agent-aditi.md +0 -38
  189. package/reference/prompts/agent-marcus.md +0 -38
  190. package/reference/prompts/agent-quinn.md +0 -38
  191. package/reference/prompts/agent-rook.md +0 -37
  192. package/reference/prompts/agent-serena.md +0 -37
  193. package/reference/prompts/council-skill.md +0 -170
  194. package/reference/prompts/goal-skill.md +0 -235
  195. package/reference/prompts/prove-skill.md +0 -283
  196. package/reference/prompts/quinn-standard.md +0 -246
  197. package/reference/prompts/ship-convergence.md +0 -65
  198. package/reference/prompts/ship-escalation.md +0 -43
  199. package/reference/prompts/ship-iteration.md +0 -382
  200. package/reference/prompts/ship-pending-patches.md +0 -246
  201. package/reference/prompts/ship-reference.md +0 -250
  202. package/reference/prompts/ship-skill.md +0 -347
  203. package/reference/prompts/ship-templates.md +0 -215
  204. package/reference/scripts/batch-status.sh +0 -68
  205. package/reference/scripts/chain-compat-check.sh +0 -67
  206. package/reference/scripts/context-audit.sh +0 -314
  207. package/reference/scripts/dead-export-check.sh +0 -61
  208. package/reference/scripts/generate-qc-tables.sh +0 -92
  209. package/reference/scripts/harness-init.sh +0 -111
  210. package/reference/scripts/pai-054-baseline-check.sh +0 -40
  211. package/reference/scripts/prove-smoke-test.sh +0 -112
  212. package/reference/scripts/setup-keychain-salt.sh +0 -12
  213. package/reference/scripts/skill-optimizer-friday.sh +0 -88
  214. package/reference/scripts/skill-qc-test.sh +0 -351
  215. package/reference/scripts/skill-synthesize-tonight.sh +0 -66
  216. package/reference/specs/HARNESS-EXTRACTION-SPEC.md +0 -263
  217. package/reference/specs/harness-v3-bash-deletion-plan.md +0 -65
  218. package/reference/specs/harness-v3-migration-plan.md +0 -188
  219. package/scripts/decision-reconcile.sh +0 -74
  220. package/scripts/decision-reconcile.ts +0 -152
  221. package/scripts/git-hooks/pre-commit +0 -76
  222. package/scripts/git-hooks/pre-push +0 -271
  223. package/scripts/harness-skill-check.sh +0 -52
  224. package/scripts/lib/gap-emit.sh +0 -65
  225. package/scripts/lib/jq-update.sh +0 -30
  226. package/scripts/lib/resolve-slug.sh +0 -30
  227. package/scripts/lib/verify-spec-compliance.sh +0 -102
  228. package/scripts/prove-backfill.sh +0 -87
  229. package/scripts/scaffold-rungate-config.ts +0 -91
  230. package/scripts/self-containment-check.sh +0 -109
  231. package/scripts/skill-qc-validator.sh +0 -402
  232. package/scripts/slug-resolver.sh +0 -14
  233. package/specs/BOOTSTRAP-DATA-FLOW-SPEC.md +0 -2493
  234. package/specs/BOOTSTRAP-TEST-PLAN.md +0 -571
  235. package/specs/HARNESS-GATES.md +0 -256
  236. package/specs/HARNESS-SKILL-CHAIN.md +0 -286
  237. package/specs/HARNESS-SKILL-CONTRACT.md +0 -93
  238. package/specs/HARNESS-STANDARD.md +0 -488
  239. package/specs/SPEC-TEMPLATE.md +0 -53
  240. package/specs/bootstrap-data-flow.png +0 -0
  241. package/specs/harness-automation-matrix.md +0 -314
  242. package/specs/harness-automation-matrix.rules.json +0 -64
  243. package/test/anti.test.ts +0 -80
  244. package/test/contract-negative.test.ts +0 -86
  245. package/test/contract.test.ts +0 -158
  246. package/test/external-deps.test.ts +0 -48
  247. package/test/fixtures/golden-project/.env.example +0 -3
  248. package/test/fixtures/golden-project/Makefile +0 -7
  249. package/test/fixtures/golden-project/docs/adr/ADR-001-framework.md +0 -23
  250. package/test/fixtures/golden-project/docs/setup-guide.md +0 -10
  251. package/test/fixtures/golden-project/package.json +0 -10
  252. package/test/fixtures/golden-project/specs/api-spec.md +0 -20
  253. package/test/fixtures/golden-project/src/auth.ts +0 -8
  254. package/test/fixtures/golden-project/src/db.ts +0 -11
  255. package/test/fixtures/golden-project/src/index.ts +0 -19
  256. package/test/fixtures/golden-project/src/utils/format.ts +0 -3
  257. package/test/fixtures/golden-project/test/auth.test.ts +0 -15
  258. package/test/fixtures/golden-project/tsconfig.json +0 -12
  259. package/test/meta-sc-coverage.test.ts +0 -159
  260. package/test/phase-0.test.ts +0 -846
  261. package/test/phase-1.test.ts +0 -617
  262. package/test/phase-2.test.ts +0 -620
  263. package/test/phase-3.test.ts +0 -99
  264. package/test/scaffold-conformity.test.ts +0 -8
  265. package/test/schema-canary.test.ts +0 -51
  266. package/test/spec-compliance-auto.test.ts +0 -64
  267. package/test/spec-compliance.test.ts +0 -295
  268. package/test/spec-discovery.test.ts +0 -68
  269. package/test/spec-drift.test.ts +0 -5
  270. package/test/structure.test.ts +0 -165
  271. package/test/unit/agent-brief-guard-ship.test.ts +0 -293
  272. package/test/unit/extract-constraints.test.ts +0 -145
  273. package/test/unit/issue-close-guard.test.ts +0 -204
  274. package/test/unit/scaffold-project.test.ts +0 -417
  275. package/test/unit/skill-cooccurrence.test.ts +0 -177
  276. package/test/unit/skill-sequence-logger.test.ts +0 -244
  277. package/test/unit/workflow-state-guard.test.ts +0 -95
  278. package/workflows/batch-ship.js +0 -295
  279. package/workflows/council.js +0 -481
  280. package/workflows/prove.js +0 -560
  281. package/workflows/ship.js +0 -789
  282. package/workflows/verify.js +0 -236
@@ -1,402 +0,0 @@
1
- #!/usr/bin/env bash
2
- # skill-qc-validator.sh — Data-driven QC validator
3
- # Reads check definitions from skill-qc-checks.json, runs them generically.
4
- # The script never hardcodes skill names — all skill-specific logic lives in the JSON config.
5
- #
6
- # Usage: skill-qc-validator.sh --skill SKILL --issue NUM --slug SLUG [--repo REPO] [--project-root PATH]
7
- set -u
8
-
9
- # ─── Arg parsing ───────────────────────────────────────────────
10
- SKILL="" ISSUE="" SLUG="" REPO="hornjason/pai-config" PROJECT_ROOT="$HOME/.claude"
11
-
12
- while [[ $# -gt 0 ]]; do
13
- case "$1" in
14
- --skill) SKILL="$2"; shift 2 ;;
15
- --issue) ISSUE="$2"; shift 2 ;;
16
- --slug) SLUG="$2"; shift 2 ;;
17
- --repo) REPO="$2"; shift 2 ;;
18
- --project-root) PROJECT_ROOT="$2"; shift 2 ;;
19
- *) echo "Unknown arg: $1" >&2; exit 1 ;;
20
- esac
21
- done
22
-
23
- if [[ -z "$SKILL" || -z "$ISSUE" || -z "$SLUG" ]]; then
24
- echo "Usage: skill-qc-validator.sh --skill SKILL --issue NUM --slug SLUG [--repo REPO] [--project-root PATH]" >&2
25
- exit 1
26
- fi
27
-
28
- WORK_DIR="${RUNGATE_WORK_DIR:-$HOME/.rungate}/$SLUG"
29
-
30
- # Auto-detect repo from workflow-state.json if not explicitly provided
31
- if [[ "$REPO" == "hornjason/pai-config" && -f "$WORK_DIR/workflow-state.json" ]]; then
32
- DETECTED_REPO=$(jq -r '.issueRepo // .repo // empty' "$WORK_DIR/workflow-state.json" 2>/dev/null)
33
- if [[ -n "$DETECTED_REPO" ]]; then
34
- REPO="$DETECTED_REPO"
35
- fi
36
- fi
37
-
38
- CONFIG="$(cd "$(dirname "$0")/.." && pwd)/schemas/skill-qc-checks.json"
39
-
40
- # Fallback: try home dir
41
- if [[ ! -f "$CONFIG" ]]; then
42
- CONFIG="$HOME/.claude/schemas/skill-qc-checks.json"
43
- fi
44
-
45
- [[ -f "$CONFIG" ]] || { echo "ERROR: Config not found: $CONFIG" >&2; exit 1; }
46
- command -v jq >/dev/null 2>&1 || { echo "ERROR: jq is required" >&2; exit 1; }
47
-
48
- # ─── Temp dir for jq filter files ──────────────────────────────
49
- QC_TMPDIR=$(mktemp -d)
50
- trap 'rm -rf "$QC_TMPDIR"' EXIT
51
-
52
- # ─── Counters ──────────────────────────────────────────────────
53
- PASS_COUNT=0
54
- FAIL_COUNT=0
55
- SKIP_COUNT=0
56
- WARN_COUNT=0
57
-
58
- # ─── Variable substitution in command strings ──────────────────
59
- subst_vars() {
60
- local s="$1"
61
- s="${s//\$ISSUE/$ISSUE}"
62
- s="${s//\$SLUG/$SLUG}"
63
- s="${s//\$REPO/$REPO}"
64
- s="${s//\$WORK_DIR/$WORK_DIR}"
65
- s="${s//\$PROJECT_ROOT/$PROJECT_ROOT}"
66
- printf '%s' "$s"
67
- }
68
-
69
- # ─── Run jq filter from string (avoids shell quoting issues) ──
70
- run_jq_filter() {
71
- local filter="$1" file="$2"
72
- printf '%s\n' "$filter" > "$QC_TMPDIR/jqf"
73
- jq -rf "$QC_TMPDIR/jqf" "$file" 2>/dev/null
74
- }
75
-
76
- # ─── Result recording ─────────────────────────────────────────
77
- do_result() {
78
- local status="$1" id="$2" desc="$3" sev="$4" detail="$5"
79
-
80
- # WARN severity always prints WARN regardless of pass/fail
81
- if [[ "$sev" == "WARN" ]]; then
82
- if [[ -n "$detail" ]]; then
83
- printf "%-4s WARN %s -- %s\n" "$id" "$desc" "$detail"
84
- else
85
- printf "%-4s WARN %s\n" "$id" "$desc"
86
- fi
87
- WARN_COUNT=$((WARN_COUNT + 1))
88
- return
89
- fi
90
-
91
- if [[ "$status" == "PASS" ]]; then
92
- printf "%-4s PASS %s\n" "$id" "$desc"
93
- PASS_COUNT=$((PASS_COUNT + 1))
94
- else
95
- if [[ -n "$detail" ]]; then
96
- printf "%-4s FAIL %s -- %s\n" "$id" "$desc" "$detail"
97
- else
98
- printf "%-4s FAIL %s\n" "$id" "$desc"
99
- fi
100
- FAIL_COUNT=$((FAIL_COUNT + 1))
101
- fi
102
- }
103
-
104
- do_skip() {
105
- local id="$1" desc="$2"
106
- printf "%-4s SKIP %s\n" "$id" "$desc"
107
- SKIP_COUNT=$((SKIP_COUNT + 1))
108
- }
109
-
110
- # ─── Expect evaluation for command-type checks ────────────────
111
- eval_expect() {
112
- local op="$1" value="$2" raw_output="$3" exit_code="$4"
113
- local trimmed
114
- trimmed=$(printf '%s' "$raw_output" | tail -1 | tr -d '[:space:]')
115
-
116
- case "$op" in
117
- exit-0)
118
- [[ "$exit_code" -eq 0 ]]
119
- ;;
120
- non-empty)
121
- [[ -n "$trimmed" ]]
122
- ;;
123
- contains)
124
- printf '%s' "$raw_output" | grep -qF "$value"
125
- ;;
126
- ">=")
127
- local num="${trimmed:-0}"
128
- # Ensure numeric
129
- [[ "$num" =~ ^-?[0-9]+$ ]] || num=0
130
- [[ "$num" -ge "${value:-0}" ]] 2>/dev/null
131
- ;;
132
- "==")
133
- [[ "$trimmed" == "$value" ]]
134
- ;;
135
- "!=")
136
- [[ "$trimmed" != "$value" ]]
137
- ;;
138
- *)
139
- return 1
140
- ;;
141
- esac
142
- }
143
-
144
- # ─── Verify checks exist for this skill ───────────────────────
145
- check_count=$(jq "[.checks[] | select(.skill == \"$SKILL\")] | length" "$CONFIG")
146
- if [[ "$check_count" -eq 0 ]]; then
147
- echo "No checks found for skill: $SKILL" >&2
148
- exit 1
149
- fi
150
-
151
- echo "=== Skill QC: $SKILL ($check_count checks) ==="
152
-
153
- # ─── Main loop: process each check ────────────────────────────
154
- while IFS= read -r check || [[ -n "$check" ]]; do
155
- id=$(jq -r '.id' <<< "$check")
156
- desc=$(jq -r '.description' <<< "$check")
157
- chk_type=$(jq -r '.type' <<< "$check")
158
- severity=$(jq -r '.severity // "FAIL"' <<< "$check")
159
-
160
- # ── Skip gate-runner checks when called from within a gate (prevents recursion) ──
161
- chk_cmd=$(jq -r '.command // empty' <<< "$check")
162
- if [[ -n "${GATE_RUNNER_ACTIVE:-}" && "$chk_cmd" == *"gate-runner.sh"* ]]; then
163
- do_skip "$id" "$desc (gate-runner recursion guard)"
164
- continue
165
- fi
166
-
167
- # ── Evaluate skipWhen ──
168
- skip_kind=$(jq -r '.skipWhen | type' <<< "$check")
169
- if [[ "$skip_kind" == "object" ]]; then
170
- skip_cmd=$(jq -r '.skipWhen.command // empty' <<< "$check")
171
- if [[ -n "$skip_cmd" ]]; then
172
- skip_cmd=$(subst_vars "$skip_cmd")
173
- if eval "$skip_cmd" 2>/dev/null; then
174
- do_skip "$id" "$desc"
175
- continue
176
- fi
177
- fi
178
- fi
179
-
180
- # ── Run check by type ──
181
- case "$chk_type" in
182
-
183
- command)
184
- cmd=$(jq -r '.command' <<< "$check")
185
- cmd=$(subst_vars "$cmd")
186
- op=$(jq -r '.expect.op' <<< "$check")
187
- value=$(jq -r '.expect.value // empty' <<< "$check")
188
-
189
- raw_output=$(eval "$cmd" 2>/dev/null)
190
- cmd_exit=$?
191
-
192
- if eval_expect "$op" "$value" "$raw_output" "$cmd_exit"; then
193
- do_result "PASS" "$id" "$desc" "$severity" ""
194
- else
195
- # Build detail from output
196
- detail_line=$(printf '%s' "$raw_output" | tail -1 | tr -d '[:space:]')
197
- case "$op" in
198
- ">="| "=="|"!=") do_result "FAIL" "$id" "$desc" "$severity" "got $detail_line" ;;
199
- contains) do_result "FAIL" "$id" "$desc" "$severity" "output missing expected string" ;;
200
- non-empty) do_result "FAIL" "$id" "$desc" "$severity" "empty output" ;;
201
- exit-0) do_result "FAIL" "$id" "$desc" "$severity" "exit code $cmd_exit" ;;
202
- *) do_result "FAIL" "$id" "$desc" "$severity" "" ;;
203
- esac
204
- fi
205
- ;;
206
-
207
- jq)
208
- source_name=$(jq -r '.source' <<< "$check")
209
- query=$(jq -r '.query' <<< "$check")
210
- op=$(jq -r '.expect.op' <<< "$check")
211
- value=$(jq -r '.expect.value // empty' <<< "$check")
212
- source_file="$WORK_DIR/$source_name"
213
-
214
- if [[ ! -f "$source_file" ]]; then
215
- do_result "FAIL" "$id" "$desc" "$severity" "source file not found: $source_name"
216
- continue
217
- fi
218
-
219
- result=$(run_jq_filter "$query" "$source_file")
220
-
221
- case "$op" in
222
- not-null)
223
- if [[ "$result" != "null" && -n "$result" ]]; then
224
- do_result "PASS" "$id" "$desc" "$severity" ""
225
- else
226
- do_result "FAIL" "$id" "$desc" "$severity" "got null"
227
- fi
228
- ;;
229
- length-gte)
230
- result_clean=$(printf '%s' "$result" | tr -d '[:space:]')
231
- if [[ ${#result_clean} -ge ${value:-0} ]]; then
232
- do_result "PASS" "$id" "$desc" "$severity" ""
233
- else
234
- do_result "FAIL" "$id" "$desc" "$severity" "length ${#result_clean} < $value"
235
- fi
236
- ;;
237
- *)
238
- do_result "FAIL" "$id" "$desc" "$severity" "unknown jq op: $op"
239
- ;;
240
- esac
241
- ;;
242
-
243
- jq-count)
244
- source_name=$(jq -r '.source' <<< "$check")
245
- query=$(jq -r '.query' <<< "$check")
246
- op=$(jq -r '.expect.op' <<< "$check")
247
- value=$(jq -r '.expect.value // empty' <<< "$check")
248
- source_file="$WORK_DIR/$source_name"
249
-
250
- if [[ ! -f "$source_file" ]]; then
251
- do_result "FAIL" "$id" "$desc" "$severity" "source file not found: $source_name"
252
- continue
253
- fi
254
-
255
- count=$(run_jq_filter "$query | length" "$source_file")
256
- count="${count:-0}"
257
- [[ "$count" =~ ^[0-9]+$ ]] || count=0
258
-
259
- if eval_expect "$op" "$value" "$count" "0"; then
260
- do_result "PASS" "$id" "$desc" "$severity" ""
261
- else
262
- do_result "FAIL" "$id" "$desc" "$severity" "count=$count"
263
- fi
264
- ;;
265
-
266
- jq-each)
267
- source_name=$(jq -r '.source' <<< "$check")
268
- query=$(jq -r '.query' <<< "$check")
269
- test_kind=$(jq -r '.test' <<< "$check")
270
- source_file="$WORK_DIR/$source_name"
271
-
272
- if [[ ! -f "$source_file" ]]; then
273
- do_result "FAIL" "$id" "$desc" "$severity" "source file not found: $source_name"
274
- continue
275
- fi
276
-
277
- elements=$(run_jq_filter "$query" "$source_file")
278
-
279
- if [[ -z "$elements" ]]; then
280
- do_result "FAIL" "$id" "$desc" "$severity" "no elements returned by query"
281
- continue
282
- fi
283
-
284
- all_pass=true
285
- fail_detail=""
286
-
287
- while IFS= read -r elem; do
288
- [[ -z "$elem" ]] && continue
289
-
290
- if [[ "$elem" == "null" ]]; then
291
- all_pass=false
292
- fail_detail="null or missing field"
293
- break
294
- fi
295
-
296
- case "$test_kind" in
297
- file-exists)
298
- # Resolve relative paths against WORK_DIR
299
- check_path="$elem"
300
- if [[ "$check_path" != /* ]]; then
301
- check_path="$WORK_DIR/$check_path"
302
- fi
303
- if [[ ! -f "$check_path" ]]; then
304
- all_pass=false
305
- fail_detail="file not found: $elem"
306
- break
307
- fi
308
- ;;
309
- in-enum)
310
- found=false
311
- while IFS= read -r enum_val; do
312
- if [[ "$elem" == "$enum_val" ]]; then
313
- found=true
314
- break
315
- fi
316
- done < <(jq -r '.enum[]' <<< "$check")
317
- if ! $found; then
318
- all_pass=false
319
- fail_detail="'$elem' not in allowed enum"
320
- break
321
- fi
322
- ;;
323
- *)
324
- all_pass=false
325
- fail_detail="unknown test type: $test_kind"
326
- break
327
- ;;
328
- esac
329
- done <<< "$elements"
330
-
331
- if $all_pass; then
332
- do_result "PASS" "$id" "$desc" "$severity" ""
333
- else
334
- do_result "FAIL" "$id" "$desc" "$severity" "$fail_detail"
335
- fi
336
- ;;
337
-
338
- computed)
339
- source_name=$(jq -r '.source' <<< "$check")
340
- jq_test=$(jq -r '.jq_test' <<< "$check")
341
- source_file="$WORK_DIR/$source_name"
342
-
343
- if [[ ! -f "$source_file" ]]; then
344
- do_result "FAIL" "$id" "$desc" "$severity" "source file not found: $source_name"
345
- continue
346
- fi
347
-
348
- result=$(run_jq_filter "$jq_test" "$source_file")
349
-
350
- if [[ -z "$result" ]]; then
351
- do_result "FAIL" "$id" "$desc" "$severity" "jq evaluation failed"
352
- elif [[ "$result" == "PASS" ]]; then
353
- do_result "PASS" "$id" "$desc" "$severity" ""
354
- else
355
- do_result "FAIL" "$id" "$desc" "$severity" "computed: $result"
356
- fi
357
- ;;
358
-
359
- grep)
360
- source_name=$(jq -r '.source' <<< "$check")
361
- pattern=$(jq -r '.pattern' <<< "$check")
362
- op=$(jq -r '.expect.op' <<< "$check")
363
- value=$(jq -r '.expect.value // empty' <<< "$check")
364
- source_file="$WORK_DIR/$source_name"
365
-
366
- if [[ ! -f "$source_file" ]]; then
367
- do_result "FAIL" "$id" "$desc" "$severity" "source file not found: $source_name"
368
- continue
369
- fi
370
-
371
- pattern=$(subst_vars "$pattern")
372
- count=$(grep -c "$pattern" "$source_file" 2>/dev/null || echo "0")
373
-
374
- if eval_expect "$op" "$value" "$count" "0"; then
375
- do_result "PASS" "$id" "$desc" "$severity" ""
376
- else
377
- do_result "FAIL" "$id" "$desc" "$severity" "matches=$count"
378
- fi
379
- ;;
380
-
381
- file-exists)
382
- path=$(jq -r '.path' <<< "$check")
383
- path=$(subst_vars "$path")
384
-
385
- if [[ -f "$path" ]]; then
386
- do_result "PASS" "$id" "$desc" "$severity" ""
387
- else
388
- do_result "FAIL" "$id" "$desc" "$severity" "not found: $path"
389
- fi
390
- ;;
391
-
392
- *)
393
- do_result "FAIL" "$id" "$desc" "$severity" "unknown check type: $chk_type"
394
- ;;
395
- esac
396
-
397
- done < <(jq -c ".checks[] | select(.skill == \"$SKILL\")" "$CONFIG")
398
-
399
- # ─── Summary ──────────────────────────────────────────────────
400
- echo ""
401
- echo "$SKILL QC: $PASS_COUNT pass, $FAIL_COUNT fail, $SKIP_COUNT skip, $WARN_COUNT warn"
402
- [[ $FAIL_COUNT -eq 0 ]]
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env bash
2
- # slug-resolver.sh — Maps repo identifier to short slug. Deterministic — no LLM judgment.
3
- # Usage: bash slug-resolver.sh <repo-identifier>
4
- # Input: "hornjason/pai-config" or "hornjason/asaCommandCenter" or full git URL
5
- # Output: short name (e.g., "pai", "ddb")
6
- # Thin caller — mapping logic lives in scripts/lib/resolve-slug.sh
7
- set -euo pipefail
8
-
9
- REPO="${1:?Usage: slug-resolver.sh <repo-identifier>}"
10
-
11
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
12
- source "$SCRIPT_DIR/lib/resolve-slug.sh"
13
-
14
- resolve_slug_from_repo "$REPO"