@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,408 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# benchmark/checkpoint.sh — recorded benchmark checkpoints, one file per release version (#452).
|
|
3
|
+
#
|
|
4
|
+
# A checkpoint is one scored retrieval run, kept. A release has one run file,
|
|
5
|
+
# benchmarks/runs/<X.Y.Z>.json, holding every checkpoint taken while that version was being built:
|
|
6
|
+
# { "schema": 1, "version": "X.Y.Z", "checkpoints": [ { "n": 1, … }, { "n": 2, … } ] }
|
|
7
|
+
# The format is specified in benchmarks/runs/README.md.
|
|
8
|
+
#
|
|
9
|
+
# Usage:
|
|
10
|
+
# checkpoint.sh record <X.Y.Z> [--from <run.json>]… [--passes <N>] [--model <name>]
|
|
11
|
+
# [--commit <sha>] [--ref <name>] [--date <YYYY-MM-DD>] [--note <text>]
|
|
12
|
+
# [--verbs <timings.json>]
|
|
13
|
+
# Append a checkpoint to benchmarks/runs/<X.Y.Z>.json. Without --from it runs the benchmark
|
|
14
|
+
# (run.sh --json) --passes times (default 1). Each --from is one pass already run: the JSON
|
|
15
|
+
# `cckit bench run --json` printed. Passes are summed, so score = answers right / answers asked.
|
|
16
|
+
# --verbs attaches a per-verb measurement already taken (the JSON verb-timings.sh --json
|
|
17
|
+
# printed) as the checkpoint's `verbs`: wall milliseconds and gh calls per verb.
|
|
18
|
+
# Rewrites the results page when benchmark.config.json names one in `resultsPage`.
|
|
19
|
+
# checkpoint.sh list [--json]
|
|
20
|
+
# Every recorded checkpoint, oldest first.
|
|
21
|
+
# checkpoint.sh check <X.Y.Z>
|
|
22
|
+
# The release gate. The version's last checkpoint is compared with the checkpoint recorded
|
|
23
|
+
# before it over the questions BOTH asked (matched by set file + id). Exit 0 when it scores at
|
|
24
|
+
# least as high on those, or when the two share no question (a new baseline); exit 1 when the
|
|
25
|
+
# version has no checkpoint, or it scores lower on the shared questions; exit 2 on a usage
|
|
26
|
+
# error or a run file that is not a checkpoint file.
|
|
27
|
+
# checkpoint.sh page [--out <file>] [--check]
|
|
28
|
+
# Print the results page (markdown) built from the run files; --out writes it; --check exits 1
|
|
29
|
+
# when the file on disk differs from what the run files produce.
|
|
30
|
+
#
|
|
31
|
+
# Env: BENCH_DIR (the benchmarks dir; default ./benchmarks).
|
|
32
|
+
set -uo pipefail
|
|
33
|
+
|
|
34
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
35
|
+
# shellcheck source=/dev/null
|
|
36
|
+
. "$SCRIPT_DIR/lib/bench-common.sh"
|
|
37
|
+
|
|
38
|
+
command -v jq >/dev/null 2>&1 || { echo "checkpoint.sh: jq is required" >&2; exit 2; }
|
|
39
|
+
|
|
40
|
+
DIR="$(bench_dir)"
|
|
41
|
+
RUNS="$DIR/runs"
|
|
42
|
+
PROJECT_ROOT="$(cd "$DIR/.." 2>/dev/null && pwd)"
|
|
43
|
+
|
|
44
|
+
usage() { sed -n '2,31p' "$0" | sed 's/^# \{0,1\}//'; }
|
|
45
|
+
|
|
46
|
+
# A flag that takes a value, given as the last argument, has none: refuse it. Without this check
|
|
47
|
+
# `shift 2` fails on one remaining argument, shifts nothing, and the parse loop never ends.
|
|
48
|
+
need_value() { [ "$2" -ge 2 ] || { echo "checkpoint $1: $3 needs a value" >&2; return 2; }; }
|
|
49
|
+
|
|
50
|
+
is_version() { grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' <<<"$1"; }
|
|
51
|
+
|
|
52
|
+
# Recorded versions, oldest first (numeric per field: 0.10.0 sorts after 0.9.0).
|
|
53
|
+
cp_versions() {
|
|
54
|
+
local f v
|
|
55
|
+
[ -d "$RUNS" ] || return 0
|
|
56
|
+
for f in "$RUNS"/*.json; do
|
|
57
|
+
[ -e "$f" ] || continue
|
|
58
|
+
v="$(basename "$f" .json)"
|
|
59
|
+
is_version "$v" && printf '%s\n' "$v"
|
|
60
|
+
done | sort -t. -k1,1n -k2,2n -k3,3n
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# One JSON array of every checkpoint, oldest first, each tagged with its version. Returns 2, with
|
|
64
|
+
# the file named on stderr, when a run file is not a checkpoint file.
|
|
65
|
+
cp_all() {
|
|
66
|
+
local v files=()
|
|
67
|
+
while IFS= read -r v; do [ -n "$v" ] && files+=("$RUNS/$v.json"); done < <(cp_versions)
|
|
68
|
+
[ "${#files[@]}" -gt 0 ] || { printf '[]'; return 0; }
|
|
69
|
+
# One unreadable file would make every verdict, list and page silently empty: name it and stop.
|
|
70
|
+
for v in "${files[@]}"; do
|
|
71
|
+
jq -e 'type == "object" and (.checkpoints | type == "array")' "$v" >/dev/null 2>&1 \
|
|
72
|
+
|| { echo "checkpoint.sh: $v is not a checkpoint file (invalid JSON, or no .checkpoints array)" >&2; return 2; }
|
|
73
|
+
done
|
|
74
|
+
jq -s -c '[ .[] | .version as $v | (.checkpoints // [])[] | . + {version: $v} ]' "${files[@]}"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# ---- record ----------------------------------------------------------------
|
|
78
|
+
cmd_record() {
|
|
79
|
+
local version="" passes=1 model="" commit="" ref="" date_s="" note="" verbs="" froms=() tmp i f
|
|
80
|
+
while [ "$#" -gt 0 ]; do
|
|
81
|
+
case "$1" in
|
|
82
|
+
--from|--passes|--model|--commit|--ref|--date|--note|--verbs) need_value record "$#" "$1" || return 2 ;;
|
|
83
|
+
-h|--help) usage; return 0 ;;
|
|
84
|
+
esac
|
|
85
|
+
case "$1" in
|
|
86
|
+
--from) froms+=("${2:-}"); shift 2 ;;
|
|
87
|
+
--from=*) froms+=("${1#*=}"); shift ;;
|
|
88
|
+
--passes) passes="${2:-}"; shift 2 ;;
|
|
89
|
+
--passes=*) passes="${1#*=}"; shift ;;
|
|
90
|
+
--model) model="${2:-}"; shift 2 ;;
|
|
91
|
+
--model=*) model="${1#*=}"; shift ;;
|
|
92
|
+
--commit) commit="${2:-}"; shift 2 ;;
|
|
93
|
+
--commit=*) commit="${1#*=}"; shift ;;
|
|
94
|
+
--ref) ref="${2:-}"; shift 2 ;;
|
|
95
|
+
--ref=*) ref="${1#*=}"; shift ;;
|
|
96
|
+
--date) date_s="${2:-}"; shift 2 ;;
|
|
97
|
+
--date=*) date_s="${1#*=}"; shift ;;
|
|
98
|
+
--note) note="${2:-}"; shift 2 ;;
|
|
99
|
+
--note=*) note="${1#*=}"; shift ;;
|
|
100
|
+
--verbs) verbs="${2:-}"; shift 2 ;;
|
|
101
|
+
--verbs=*) verbs="${1#*=}"; shift ;;
|
|
102
|
+
-*) echo "checkpoint record: unknown flag '$1'" >&2; return 2 ;;
|
|
103
|
+
*) if [ -z "$version" ]; then version="$1"; shift
|
|
104
|
+
else echo "checkpoint record: unexpected argument '$1'" >&2; return 2; fi ;;
|
|
105
|
+
esac
|
|
106
|
+
done
|
|
107
|
+
is_version "$version" || { echo "checkpoint record: version must be X.Y.Z (got '${version}')" >&2; return 2; }
|
|
108
|
+
grep -Eq '^[1-9][0-9]*$' <<<"$passes" || { echo "checkpoint record: --passes must be a positive integer" >&2; return 2; }
|
|
109
|
+
|
|
110
|
+
cp_all >/dev/null || return 2 # an unreadable run file is reported before anything is run or written
|
|
111
|
+
|
|
112
|
+
# A measurement to attach is validated before anything is run: every row needs the five fields
|
|
113
|
+
# the page prints, as a string and four non-negative numbers.
|
|
114
|
+
if [ -n "$verbs" ]; then
|
|
115
|
+
[ -f "$verbs" ] || { echo "checkpoint record: no such verb timings file: $verbs" >&2; return 2; }
|
|
116
|
+
jq -e '(.verbs | type == "array") and (.verbs | length) > 0
|
|
117
|
+
and ([ .verbs[] | (.verb | type == "string")
|
|
118
|
+
and ([.runs, .min_ms, .median_ms, .gh_calls] | all(type == "number" and . >= 0)) ] | all)' \
|
|
119
|
+
"$verbs" >/dev/null 2>&1 \
|
|
120
|
+
|| { echo "checkpoint record: $verbs is not a verb timings file (.verbs rows need verb, runs, min_ms, median_ms, gh_calls)" >&2; return 2; }
|
|
121
|
+
fi
|
|
122
|
+
|
|
123
|
+
tmp="$(mktemp -d)" || return 2
|
|
124
|
+
# shellcheck disable=SC2064
|
|
125
|
+
trap "rm -rf '$tmp'" EXIT
|
|
126
|
+
|
|
127
|
+
if [ "${#froms[@]}" -gt 0 ]; then
|
|
128
|
+
i=0
|
|
129
|
+
for f in "${froms[@]}"; do
|
|
130
|
+
[ -f "$f" ] || { echo "checkpoint record: no such run file: $f" >&2; return 2; }
|
|
131
|
+
jq -e 'type == "object" and (.results | type == "array")' "$f" >/dev/null 2>&1 \
|
|
132
|
+
|| { echo "checkpoint record: $f is not a run (no .results array)" >&2; return 2; }
|
|
133
|
+
i=$((i+1)); cp "$f" "$tmp/pass-$i.json"
|
|
134
|
+
done
|
|
135
|
+
else
|
|
136
|
+
i=0
|
|
137
|
+
while [ "$i" -lt "$passes" ]; do
|
|
138
|
+
i=$((i+1))
|
|
139
|
+
echo "checkpoint record: pass $i of $passes" >&2
|
|
140
|
+
# run.sh exits 1 when any question failed; that is a score, not an error here.
|
|
141
|
+
bash "$SCRIPT_DIR/run.sh" --json > "$tmp/pass-$i.json" 2>"$tmp/pass-$i.err"
|
|
142
|
+
jq -e '.results | type == "array"' "$tmp/pass-$i.json" >/dev/null 2>&1 \
|
|
143
|
+
|| { echo "checkpoint record: pass $i produced no run JSON" >&2; cat "$tmp/pass-$i.err" >&2; return 2; }
|
|
144
|
+
done
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
# Question text, looked up by set file + id, so the page can show what was asked.
|
|
148
|
+
local qmap="$tmp/questions.json" setf
|
|
149
|
+
printf '{}' > "$qmap"
|
|
150
|
+
for setf in "$DIR"/*.jsonl; do
|
|
151
|
+
[ -e "$setf" ] || continue
|
|
152
|
+
bench_records "$setf" | jq -s -c --arg set "$(basename "$setf")" \
|
|
153
|
+
'[ .[] | select(.id != null) | {key: ($set + "|" + (.id|tostring)), value: (.q // .claim // "")} ] | from_entries' \
|
|
154
|
+
> "$tmp/one.json" 2>/dev/null || continue
|
|
155
|
+
jq -s -c '.[0] + .[1]' "$qmap" "$tmp/one.json" > "$tmp/merged.json" && mv "$tmp/merged.json" "$qmap"
|
|
156
|
+
done
|
|
157
|
+
|
|
158
|
+
# Defaults that describe where the run came from.
|
|
159
|
+
[ -n "$date_s" ] || date_s="$(date +%Y-%m-%d)"
|
|
160
|
+
[ -n "$commit" ] || commit="$(git -C "$PROJECT_ROOT" rev-parse --short HEAD 2>/dev/null || true)"
|
|
161
|
+
[ -n "$ref" ] || ref="$(git -C "$PROJECT_ROOT" branch --show-current 2>/dev/null || true)"
|
|
162
|
+
[ -n "$model" ] || model="$(jq -r '.model // empty' "$tmp/pass-1.json" 2>/dev/null)"
|
|
163
|
+
[ -n "$model" ] || model="${BENCH_MODEL:-${BENCH_BACKEND:-claude}}"
|
|
164
|
+
|
|
165
|
+
local out="$RUNS/$version.json" existing="$tmp/existing.json"
|
|
166
|
+
mkdir -p "$RUNS"
|
|
167
|
+
if [ -f "$out" ]; then
|
|
168
|
+
jq -e '.checkpoints | type == "array"' "$out" >/dev/null 2>&1 \
|
|
169
|
+
|| { echo "checkpoint record: $out is not a checkpoint file (no .checkpoints array)" >&2; return 2; }
|
|
170
|
+
cp "$out" "$existing"
|
|
171
|
+
else
|
|
172
|
+
jq -n --arg v "$version" '{schema: 1, version: $v, checkpoints: []}' > "$existing"
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
local vfile="$tmp/verbs.json"
|
|
176
|
+
if [ -n "$verbs" ]; then
|
|
177
|
+
jq -c '[ .verbs[] | {verb, runs, min_ms, median_ms, gh_calls} + (if (.exit // 0) != 0 then {exit} else {} end) ]' "$verbs" > "$vfile" || return 2
|
|
178
|
+
else
|
|
179
|
+
printf 'null' > "$vfile"
|
|
180
|
+
fi
|
|
181
|
+
|
|
182
|
+
jq -s --slurpfile ex "$existing" --slurpfile q "$qmap" --slurpfile vb "$vfile" \
|
|
183
|
+
--arg date "$date_s" --arg commit "$commit" --arg ref "$ref" --arg model "$model" --arg note "$note" '
|
|
184
|
+
. as $passes
|
|
185
|
+
| [ $passes[] | select(.dry == true) ] as $dry
|
|
186
|
+
| if ($dry | length) > 0 then error("a --dry run has no scores to record") else . end
|
|
187
|
+
# run.sh stores an empty answer only when the model backend failed (a real answer is a path or
|
|
188
|
+
# NONE). Such a run measures the backend, not the docs, and an empty answer passes the abstain tier.
|
|
189
|
+
| ( [ $passes[].results[] | select((.got // "") == "") ] | length ) as $noanswer
|
|
190
|
+
| if $noanswer > 0 then error("\($noanswer) answer(s) are empty: the model backend returned nothing, so there is no score to record") else . end
|
|
191
|
+
# One row per question, in the order the first pass asked them.
|
|
192
|
+
| ( [ $passes[].results[] ] | group_by(.set + "|" + (.id|tostring)) ) as $groups
|
|
193
|
+
| ( [ $passes[0].results[] | .set + "|" + (.id|tostring) ] ) as $order
|
|
194
|
+
| ( $groups | map({ key: (.[0].set + "|" + (.[0].id|tostring)), value: . }) | from_entries ) as $by
|
|
195
|
+
| [ $order[] | $by[.] as $g
|
|
196
|
+
| { set: $g[0].set, tier: $g[0].tier, id: $g[0].id,
|
|
197
|
+
q: ($q[0][ $g[0].set + "|" + ($g[0].id|tostring) ] // ""),
|
|
198
|
+
expect: $g[0].expect,
|
|
199
|
+
got: ( ([ $g[] | select(.pass | not) | .got ] | first) // $g[-1].got ),
|
|
200
|
+
passed: ([ $g[] | select(.pass) ] | length),
|
|
201
|
+
asked: ($g | length),
|
|
202
|
+
latency_ms: (([ $g[] | .latency_ms // 0 ] | add) / ($g | length) | floor) }
|
|
203
|
+
| . + { pass: (.passed == .asked) } ] as $results
|
|
204
|
+
| ( [ $results[].asked ] | add // 0 ) as $total
|
|
205
|
+
| ( [ $results[].passed ] | add // 0 ) as $pass
|
|
206
|
+
| if $total == 0 then error("the run has no results") else . end
|
|
207
|
+
| $ex[0] as $file
|
|
208
|
+
| $file
|
|
209
|
+
| .schema = 1
|
|
210
|
+
| .checkpoints += [ {
|
|
211
|
+
n: (($file.checkpoints | length) + 1),
|
|
212
|
+
date: $date, ref: $ref, commit: $commit, model: $model,
|
|
213
|
+
passes: ($passes | length),
|
|
214
|
+
questions: ($results | length),
|
|
215
|
+
total: $total, pass: $pass,
|
|
216
|
+
score_pct: (($pass * 100 / $total) | floor),
|
|
217
|
+
tiers: ( $results | group_by(.tier)
|
|
218
|
+
| map({ key: .[0].tier, value: { total: ([.[].asked] | add), pass: ([.[].passed] | add) } })
|
|
219
|
+
| from_entries ),
|
|
220
|
+
note: $note,
|
|
221
|
+
results: $results }
|
|
222
|
+
+ (if $vb[0] != null then { verbs: $vb[0] } else {} end) ]
|
|
223
|
+
' "$tmp"/pass-*.json > "$tmp/new.json" || { echo "checkpoint record: could not build the checkpoint" >&2; return 2; }
|
|
224
|
+
|
|
225
|
+
mv "$tmp/new.json" "$out"
|
|
226
|
+
jq -r '.checkpoints[-1] | "recorded checkpoint \(.n) of '"$version"': \(.pass)/\(.total) (\(.score_pct)%) · \(.passes) pass(es) · \(.model) · \(.ref)@\(.commit)" + (if .verbs then " · \(.verbs | length) verb timings" else "" end)' "$out"
|
|
227
|
+
echo " file: $out"
|
|
228
|
+
|
|
229
|
+
local page; page="$(cp_page_path)"
|
|
230
|
+
if [ -n "$page" ]; then
|
|
231
|
+
cmd_page --out "$page" && echo " page: $page"
|
|
232
|
+
fi
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
# ---- list ------------------------------------------------------------------
|
|
236
|
+
cmd_list() {
|
|
237
|
+
local json=0 all
|
|
238
|
+
for a in "$@"; do case "$a" in --json|--llm) json=1 ;; *) echo "checkpoint list: unknown arg '$a'" >&2; return 2 ;; esac; done
|
|
239
|
+
all="$(cp_all)" || return 2
|
|
240
|
+
if [ "$json" -eq 1 ]; then
|
|
241
|
+
printf '%s' "$all" | jq -c '[ .[] | del(.results) ]'
|
|
242
|
+
return 0
|
|
243
|
+
fi
|
|
244
|
+
if [ "$(printf '%s' "$all" | jq 'length')" -eq 0 ]; then
|
|
245
|
+
echo "no recorded checkpoints in $RUNS"; return 0
|
|
246
|
+
fi
|
|
247
|
+
printf '%s' "$all" | jq -r '.[] | "\(.version) #\(.n) \(.date) \(.pass)/\(.total) (\(.score_pct)%) \(.passes) pass(es) \(.model) \(.ref)@\(.commit)"'
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
# ---- check (the release gate) ----------------------------------------------
|
|
251
|
+
# Two checkpoints are compared over the questions BOTH asked, matched by set file + id (#452). The
|
|
252
|
+
# question set grows between checkpoints (18 to 55 in 0.10.0), and a whole-run fraction would read
|
|
253
|
+
# 54 of 55 as lower than 18 of 18 although no question got worse. On the shared questions the scores
|
|
254
|
+
# compare as fractions (answers right / answers asked, cross-multiplied), so a different number of
|
|
255
|
+
# passes still compares and integer-percent rounding never decides a release. Two checkpoints that
|
|
256
|
+
# share no question cannot be compared: the newer one is a new baseline and passes.
|
|
257
|
+
cmd_check() {
|
|
258
|
+
local version="${1:-}" all
|
|
259
|
+
is_version "$version" || { echo "checkpoint check: version must be X.Y.Z (got '${version}')" >&2; return 2; }
|
|
260
|
+
all="$(cp_all)" || return 2
|
|
261
|
+
if [ ! -f "$RUNS/$version.json" ] || [ "$(jq '(.checkpoints // []) | length' "$RUNS/$version.json" 2>/dev/null || echo 0)" -eq 0 ]; then
|
|
262
|
+
echo "benchmark check: no recorded checkpoint for $version (expected $RUNS/$version.json)"
|
|
263
|
+
echo " record one: cckit bench checkpoint $version"
|
|
264
|
+
return 1
|
|
265
|
+
fi
|
|
266
|
+
local verdict line
|
|
267
|
+
line="$(printf '%s' "$all" | jq -r --arg v "$version" '
|
|
268
|
+
def key: .set + "|" + (.id | tostring);
|
|
269
|
+
def bykey(c): [ (c.results // [])[] | { key: key, value: . } ] | from_entries;
|
|
270
|
+
def lbl(c): "\(c.version) checkpoint \(c.n): \(c.pass)/\(c.total) (\(c.score_pct)%)";
|
|
271
|
+
. as $a
|
|
272
|
+
| ( [ range(0; length) | select($a[.].version == $v) ] | last ) as $idx
|
|
273
|
+
| $a[$idx] as $cur
|
|
274
|
+
| ( if $idx > 0 then $a[$idx - 1] else null end ) as $prev
|
|
275
|
+
| if $prev == null then "ok\tbenchmark check: " + lbl($cur) + " — no earlier checkpoint to compare against"
|
|
276
|
+
else
|
|
277
|
+
bykey($cur) as $c | bykey($prev) as $p
|
|
278
|
+
| [ $c | keys_unsorted[] | select($p[.] != null) ] as $shared
|
|
279
|
+
| ( ($c | length) - ($shared | length) ) as $new
|
|
280
|
+
| ( ($p | length) - ($shared | length) ) as $gone
|
|
281
|
+
| "\($new) new, \($gone) removed" as $delta
|
|
282
|
+
| if ($shared | length) == 0
|
|
283
|
+
then "ok\tbenchmark check: " + lbl($cur) + " — new baseline: it shares no question with "
|
|
284
|
+
+ lbl($prev) + " (\($delta))"
|
|
285
|
+
else
|
|
286
|
+
( [ $shared[] | $c[.].passed ] | add ) as $cp | ( [ $shared[] | $c[.].asked ] | add ) as $ct
|
|
287
|
+
| ( [ $shared[] | $p[.].passed ] | add ) as $pp | ( [ $shared[] | $p[.].asked ] | add ) as $pt
|
|
288
|
+
| [ $shared[] | select($p[.].pass and ($c[.].pass | not)) | $c[.] | "\(.set) \(.id)" ] as $worse
|
|
289
|
+
| "on the \($shared | length) question(s) both asked (\($cp)/\($ct) now, \($pp)/\($pt) before); \($delta)" as $on
|
|
290
|
+
| ( if ($worse | length) > 0 then "\n right before, missed now: " + ($worse | join(", ")) else "" end ) as $tail
|
|
291
|
+
| if ($cp * $pt) < ($pp * $ct)
|
|
292
|
+
then "low\tbenchmark check: " + lbl($cur) + " is lower than " + lbl($prev) + " " + $on + $tail
|
|
293
|
+
else "ok\tbenchmark check: " + lbl($cur) + " — not lower than " + lbl($prev) + " " + $on + $tail
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
')"
|
|
298
|
+
verdict="${line%% *}"
|
|
299
|
+
printf '%s\n' "${line#* }"
|
|
300
|
+
[ "$verdict" = "ok" ]
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
# ---- page ------------------------------------------------------------------
|
|
304
|
+
# The results page named by benchmark.config.json `resultsPage` (relative to the project root).
|
|
305
|
+
cp_page_path() {
|
|
306
|
+
local cfg rel
|
|
307
|
+
cfg="$(bench_config)"
|
|
308
|
+
[ -n "$cfg" ] || return 0
|
|
309
|
+
rel="$(jq -r '.resultsPage // empty' "$cfg" 2>/dev/null)"
|
|
310
|
+
[ -n "$rel" ] || return 0
|
|
311
|
+
case "$rel" in /*) printf '%s' "$rel" ;; *) printf '%s' "$PROJECT_ROOT/$rel" ;; esac
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
cp_render_page() {
|
|
315
|
+
local all
|
|
316
|
+
all="$(cp_all)" || return 2
|
|
317
|
+
printf '%s' "$all" | jq -r '
|
|
318
|
+
def cell: tostring | gsub("[\r\n]+"; " ") | gsub("\\|"; "\\|") | gsub("<"; "<") | gsub("\\{"; "{");
|
|
319
|
+
def code: tostring | gsub("[\r\n]+"; " ") | gsub("`"; "") | gsub("\\|"; "\\|") | .[0:120] | "`" + . + "`";
|
|
320
|
+
def docs: if type == "array" then map(code) | join(" or ") else code end;
|
|
321
|
+
def tier(c; t): if c.tiers[t] then "\(c.tiers[t].pass)/\(c.tiers[t].total)" else "—" end;
|
|
322
|
+
def vkey: split(".") | map(tonumber);
|
|
323
|
+
. as $all
|
|
324
|
+
| "---",
|
|
325
|
+
"title: Benchmark results",
|
|
326
|
+
"description: The documentation benchmark score recorded at every checkpoint of every release.",
|
|
327
|
+
"---",
|
|
328
|
+
"",
|
|
329
|
+
"<!-- Generated from benchmarks/runs/*.json by `cckit bench page`. Do not edit by hand: scripts/check.sh fails when this page differs from the run files. -->",
|
|
330
|
+
"",
|
|
331
|
+
"Each release records the [documentation benchmark](/benchmark/) as one or more checkpoints: a run, the fixes it showed were needed, then another run. A release is refused when its last checkpoint scores lower than the checkpoint recorded before it, counted over the questions both checkpoints asked ([How cckit itself is released](/releasing-cckit/#the-benchmark-check)).",
|
|
332
|
+
"",
|
|
333
|
+
"Score is answers right out of answers asked. A checkpoint with more than one pass asks every question that many times.",
|
|
334
|
+
"",
|
|
335
|
+
( if ($all | length) == 0 then "No checkpoint has been recorded yet." else
|
|
336
|
+
( [ $all[].version ] | unique | sort_by(vkey) | reverse | .[] ) as $v
|
|
337
|
+
| [ $all[] | select(.version == $v) ] as $cps
|
|
338
|
+
| "## " + $v,
|
|
339
|
+
"",
|
|
340
|
+
"| Checkpoint | Date | Commit | Model | Passes | Score | Retrieval | Adversarial | Abstain |",
|
|
341
|
+
"| --- | --- | --- | --- | --- | --- | --- | --- | --- |",
|
|
342
|
+
( $cps[] | "| \(.n) | \(.date | cell) | \(((.ref // "") + "@" + (.commit // "")) | code) | \(.model | cell) | \(.passes) | **\(.pass)/\(.total)** (\(.score_pct)%) | \(tier(.; "retrieval")) | \(tier(.; "adversarial")) | \(tier(.; "abstain")) |" ),
|
|
343
|
+
"",
|
|
344
|
+
( $cps[]
|
|
345
|
+
| . as $c
|
|
346
|
+
| [ $c.results[] | select(.pass | not) ] as $missed
|
|
347
|
+
| ( if ($c.note // "") != "" then "Checkpoint \($c.n) note: \($c.note | cell)", "" else empty end ),
|
|
348
|
+
( if ($missed | length) == 0 then "Checkpoint \($c.n): no missed questions.", ""
|
|
349
|
+
else
|
|
350
|
+
"Checkpoint \($c.n) missed \($missed | length) of \($c.questions) questions:",
|
|
351
|
+
"",
|
|
352
|
+
"| Question | Tier | Expected | Answered | Right |",
|
|
353
|
+
"| --- | --- | --- | --- | --- |",
|
|
354
|
+
( $missed[] | "| \(.id | code) \(.q // "" | cell) | \(.tier | cell) | \(.expect | docs) | \(.got | code) | \(.passed)/\(.asked) |" ),
|
|
355
|
+
""
|
|
356
|
+
end ),
|
|
357
|
+
( if (($c.verbs // []) | length) == 0 then empty
|
|
358
|
+
else
|
|
359
|
+
"Checkpoint \($c.n) verb timings: wall time of each read-only verb and the number of times it ran `gh`.",
|
|
360
|
+
"",
|
|
361
|
+
"| Verb | Runs | Min ms | Median ms | gh calls |",
|
|
362
|
+
"| --- | --- | --- | --- | --- |",
|
|
363
|
+
( $c.verbs[] | "| \("cckit " + .verb | code)\(if (.exit // 0) != 0 then " (exit \(.exit))" else "" end) | \(.runs) | \(.min_ms) | \(.median_ms) | \(.gh_calls) |" ),
|
|
364
|
+
""
|
|
365
|
+
end ) )
|
|
366
|
+
end )
|
|
367
|
+
'
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
cmd_page() {
|
|
371
|
+
local out="" check=0
|
|
372
|
+
while [ "$#" -gt 0 ]; do
|
|
373
|
+
case "$1" in
|
|
374
|
+
--out) need_value page "$#" "$1" || return 2; out="$2"; shift 2 ;;
|
|
375
|
+
--out=*) out="${1#*=}"; shift ;;
|
|
376
|
+
--check) check=1; shift ;;
|
|
377
|
+
*) echo "checkpoint page: unknown arg '$1'" >&2; return 2 ;;
|
|
378
|
+
esac
|
|
379
|
+
done
|
|
380
|
+
[ -n "$out" ] || [ "$check" -eq 0 ] || out="$(cp_page_path)"
|
|
381
|
+
if [ "$check" -eq 1 ]; then
|
|
382
|
+
[ -n "$out" ] || { echo "checkpoint page --check: no page configured (benchmark.config.json resultsPage) and no --out" >&2; return 2; }
|
|
383
|
+
local want
|
|
384
|
+
want="$(cp_render_page)" || return 2
|
|
385
|
+
if [ -f "$out" ] && [ "$want" = "$(cat "$out")" ]; then
|
|
386
|
+
echo "benchmark results page is current: $out"; return 0
|
|
387
|
+
fi
|
|
388
|
+
echo "benchmark results page is stale: $out" >&2
|
|
389
|
+
echo " regenerate: cckit bench page --out $out" >&2
|
|
390
|
+
return 1
|
|
391
|
+
fi
|
|
392
|
+
if [ -n "$out" ]; then
|
|
393
|
+
mkdir -p "$(dirname "$out")"
|
|
394
|
+
cp_render_page > "$out.tmp.$$" && mv "$out.tmp.$$" "$out" || { rm -f "$out.tmp.$$"; return 2; }
|
|
395
|
+
else
|
|
396
|
+
cp_render_page
|
|
397
|
+
fi
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
sub="${1:-}"; [ "$#" -gt 0 ] && shift
|
|
401
|
+
case "$sub" in
|
|
402
|
+
record) cmd_record "$@" ;;
|
|
403
|
+
list) cmd_list "$@" ;;
|
|
404
|
+
check) cmd_check "$@" ;;
|
|
405
|
+
page) cmd_page "$@" ;;
|
|
406
|
+
-h|--help|"") usage; [ -n "$sub" ] && exit 0 || exit 2 ;;
|
|
407
|
+
*) echo "checkpoint.sh: unknown subcommand '$sub' (record|list|check|page)" >&2; exit 2 ;;
|
|
408
|
+
esac
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# benchmark/lib/model.sh — the pluggable model backend for the benchmark harness.
|
|
3
3
|
#
|
|
4
|
-
#
|
|
4
|
+
# Three entry points, all cascade-shaped so the backend is swappable with NO hard dependency on a
|
|
5
5
|
# specific provider:
|
|
6
|
-
# bench_ask
|
|
7
|
-
#
|
|
6
|
+
# bench_ask "<question>" -> prints ONE repo-relative doc path, or "NONE"
|
|
7
|
+
# bench_answer "<question>" -> prints the model's full answer from the docs
|
|
8
|
+
# bench_judge "<claim>" "<answer>" "<must>" -> prints a score in [0,1]
|
|
8
9
|
#
|
|
9
10
|
# Backend selection (first that applies wins), driven by env so a project overrides without editing:
|
|
10
11
|
# BENCH_BACKEND=mock deterministic, offline (tests + --dry); never calls a model
|
|
@@ -61,13 +62,15 @@ _bench_complete() {
|
|
|
61
62
|
bench_timeout "$BENCH_TIMEOUT_SECS" curl -sS "$url" \
|
|
62
63
|
-H 'Content-Type: application/json' \
|
|
63
64
|
${BENCH_API_KEY:+-H "Authorization: Bearer $BENCH_API_KEY"} \
|
|
64
|
-
-d "$body" 2>/dev/null \
|
|
65
|
+
-d "$body" </dev/null 2>/dev/null \
|
|
65
66
|
| jq -r '.choices[0].message.content // empty' 2>/dev/null ;;
|
|
66
67
|
claude|*)
|
|
67
68
|
command -v claude >/dev/null 2>&1 || { return 1; }
|
|
68
69
|
# Headless one-shot. `-p` prints the final answer and exits; the model may use its tools to
|
|
69
70
|
# grep the repo, which is exactly the retrieval behavior we want to measure.
|
|
70
|
-
|
|
71
|
+
# stdin is /dev/null on purpose: the runners call this inside `while read … done < <(records)`,
|
|
72
|
+
# and a child that inherits that stdin drains it, so every set stopped after its first record.
|
|
73
|
+
bench_timeout "$BENCH_TIMEOUT_SECS" claude -p "$prompt" </dev/null 2>/dev/null ;;
|
|
71
74
|
esac
|
|
72
75
|
}
|
|
73
76
|
|
|
@@ -90,6 +93,25 @@ If no document genuinely answers it, reply with exactly: NONE"
|
|
|
90
93
|
printf '%s' "$out"
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
# ---- bench_answer ----------------------------------------------------------
|
|
97
|
+
# Ask the model to ANSWER a question from the docs — the whole answer, every line of it. The quality
|
|
98
|
+
# tier grades this text. bench_ask is the wrong call there: it returns one path, and a path covers
|
|
99
|
+
# none of a rubric's points. $2 = knowledge dir (for the prompt). Prints nothing when the backend
|
|
100
|
+
# fails or times out; the caller scores an empty answer 0.
|
|
101
|
+
bench_answer() {
|
|
102
|
+
local question="$1" kdir="${2:-knowledge}" prompt
|
|
103
|
+
prompt="You are answering a question about this project from its own documentation.
|
|
104
|
+
|
|
105
|
+
QUESTION:
|
|
106
|
+
$question
|
|
107
|
+
|
|
108
|
+
Read the documents under '$kdir/' and answer from what they state. Give the complete answer: every
|
|
109
|
+
condition, default, exit code and command the documents give for it. Do not add anything they do not
|
|
110
|
+
state. End with one line naming the document(s) you used, as repo-relative paths. If the documents
|
|
111
|
+
do not cover the question, say so."
|
|
112
|
+
_bench_complete "$prompt" || return 1
|
|
113
|
+
}
|
|
114
|
+
|
|
93
115
|
# ---- bench_judge -----------------------------------------------------------
|
|
94
116
|
# Score a claim-style answer against a `must` rubric (newline-separated points). The rubric de-biases
|
|
95
117
|
# the judge: it scores coverage of the required points, not vibes. Prints a float in [0,1].
|
|
@@ -110,7 +132,10 @@ $must
|
|
|
110
132
|
Reply with ONLY a number between 0 and 1 (e.g. 0.75) = the fraction of required points the answer
|
|
111
133
|
correctly covers. No words."
|
|
112
134
|
out="$(_bench_complete "$prompt")" || { printf '0'; return 0; }
|
|
113
|
-
|
|
135
|
+
# BENCH_JUDGE_RAW=<file> keeps the judge's reply as it came back, before the number is cut out of
|
|
136
|
+
# it: a score that looks wrong can then be told apart from a reply that was parsed wrong.
|
|
137
|
+
[ -z "${BENCH_JUDGE_RAW:-}" ] || printf '%s\n' "$out" > "$BENCH_JUDGE_RAW"
|
|
138
|
+
score="$(printf '%s' "$out" | grep -oE '0(\.[0-9]+)?|1(\.0+)?' | sed -n 1p)"
|
|
114
139
|
[ -n "$score" ] || score="0"
|
|
115
140
|
printf '%s' "$score"
|
|
116
141
|
}
|
|
@@ -35,13 +35,28 @@ DIR="$(bench_dir)"
|
|
|
35
35
|
[ -n "$OUT" ] || OUT="$DIR/RESULTS.md"
|
|
36
36
|
DRYFLAG=""; [ "$DRY" -eq 1 ] && DRYFLAG="--dry"
|
|
37
37
|
|
|
38
|
+
# tier_json <script> — one tier's --json summary, or {} when the tier printed no usable JSON.
|
|
39
|
+
# The exit code is deliberately NOT the signal: run.sh exits 1 whenever a record failed and still
|
|
40
|
+
# prints its full summary, so `$(run … || echo '{}')` captured two documents and every
|
|
41
|
+
# `jq -r '.x // 0'` below printed two lines — "33\n0%" in the headline (#252).
|
|
42
|
+
tier_json() {
|
|
43
|
+
local out
|
|
44
|
+
# shellcheck disable=SC2086 # DRYFLAG is empty or one flag; it must word-split away when empty
|
|
45
|
+
out="$(bash "$1" $DRYFLAG --json 2>/dev/null)"
|
|
46
|
+
if [ "$(printf '%s' "$out" | jq -s 'length == 1 and (.[0] | type == "object")' 2>/dev/null)" = "true" ]; then
|
|
47
|
+
printf '%s' "$out"
|
|
48
|
+
else
|
|
49
|
+
printf '{}'
|
|
50
|
+
fi
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
# Gather the two tier summaries (retrieval+abstain+adversarial in one, quality separately).
|
|
39
54
|
if [ "$STDIN" -eq 1 ]; then
|
|
40
55
|
RET_JSON="$(cat)"
|
|
41
56
|
QUAL_JSON='{"kind":"quality-run","dry":true,"count":0,"mean":0,"results":[]}'
|
|
42
57
|
else
|
|
43
|
-
RET_JSON="$(
|
|
44
|
-
QUAL_JSON="$(
|
|
58
|
+
RET_JSON="$(tier_json "$SCRIPT_DIR/run.sh")"
|
|
59
|
+
QUAL_JSON="$(tier_json "$SCRIPT_DIR/run-quality.sh")"
|
|
45
60
|
fi
|
|
46
61
|
|
|
47
62
|
# Pull the numbers with safe defaults (a tier may be absent).
|
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
# benchmark/run-quality.sh — the quality judge tier.
|
|
3
3
|
#
|
|
4
4
|
# Beyond "did the agent find the doc", this measures "was the answer correct + complete". For each
|
|
5
|
-
# claim-style record the model answers headlessly (
|
|
6
|
-
# scores that answer 0..1 against the record's `must` rubric. The rubric de-biases the judge: it
|
|
5
|
+
# claim-style record the model answers headlessly (bench_answer: a full answer, not a path), then a
|
|
6
|
+
# judge scores that answer 0..1 against the record's `must` rubric. The rubric de-biases the judge: it
|
|
7
7
|
# grades coverage of the required points, not tone. The tier score is the mean.
|
|
8
8
|
#
|
|
9
9
|
# Usage:
|
|
10
|
-
# benchmark/run-quality.sh [--set <file>] [--dir <benchmarks>] [--dry] [--json]
|
|
10
|
+
# benchmark/run-quality.sh [--set <file>] [--dir <benchmarks>] [--dry] [--json] [--answers <dir>]
|
|
11
11
|
#
|
|
12
|
-
# --dry
|
|
13
|
-
# --set
|
|
14
|
-
#
|
|
12
|
+
# --dry validate every record has a claim + a non-empty `must` rubric; call NO model; exit 0.
|
|
13
|
+
# --set run one quality set; else every tier:"quality" set in benchmark.config.json (or
|
|
14
|
+
# every *quality*.jsonl in the dir).
|
|
15
|
+
# --answers keep each graded answer as <dir>/<id>.txt and the judge's reply to it as
|
|
16
|
+
# <dir>/<id>.judge.txt, to read why a claim scored what it did.
|
|
17
|
+
#
|
|
18
|
+
# A record may carry extra keys (`source`: the page its rubric was written from). Only `claim` and
|
|
19
|
+
# `must` are read here.
|
|
15
20
|
set -uo pipefail
|
|
16
21
|
|
|
17
22
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
@@ -20,7 +25,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
20
25
|
# shellcheck source=/dev/null
|
|
21
26
|
. "$SCRIPT_DIR/lib/model.sh"
|
|
22
27
|
|
|
23
|
-
DRY=0; JSON=0; ONE_SET=""
|
|
28
|
+
DRY=0; JSON=0; ONE_SET=""; ANSWERS_DIR=""
|
|
24
29
|
while [ "$#" -gt 0 ]; do
|
|
25
30
|
case "$1" in
|
|
26
31
|
--dry) DRY=1; shift ;;
|
|
@@ -29,7 +34,11 @@ while [ "$#" -gt 0 ]; do
|
|
|
29
34
|
--set=*) ONE_SET="${1#*=}"; shift ;;
|
|
30
35
|
--dir) BENCH_DIR="$2"; export BENCH_DIR; shift 2 ;;
|
|
31
36
|
--dir=*) BENCH_DIR="${1#*=}"; export BENCH_DIR; shift ;;
|
|
32
|
-
|
|
37
|
+
--answers) [ "$#" -ge 2 ] || { echo "run-quality.sh: --answers needs a directory" >&2; exit 2; }
|
|
38
|
+
ANSWERS_DIR="$2"; shift 2 ;;
|
|
39
|
+
--answers=*) ANSWERS_DIR="${1#*=}"; shift
|
|
40
|
+
[ -n "$ANSWERS_DIR" ] || { echo "run-quality.sh: --answers needs a directory" >&2; exit 2; } ;;
|
|
41
|
+
-h|--help) sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
33
42
|
*) echo "run-quality.sh: unknown arg '$1'" >&2; exit 2 ;;
|
|
34
43
|
esac
|
|
35
44
|
done
|
|
@@ -53,6 +62,11 @@ fi
|
|
|
53
62
|
|
|
54
63
|
[ "${#SETS[@]}" -ge 1 ] || { echo "run-quality.sh: no quality sets found in $DIR" >&2; exit 2; }
|
|
55
64
|
|
|
65
|
+
if [ -n "$ANSWERS_DIR" ] && [ "$DRY" -eq 0 ]; then
|
|
66
|
+
mkdir -p "$ANSWERS_DIR" 2>/dev/null \
|
|
67
|
+
|| { echo "run-quality.sh: cannot create the --answers directory: $ANSWERS_DIR" >&2; exit 2; }
|
|
68
|
+
fi
|
|
69
|
+
|
|
56
70
|
N=0; SUM="0"; FAILN=0
|
|
57
71
|
RESULTS_JSON="[]"
|
|
58
72
|
|
|
@@ -71,8 +85,20 @@ for file in "${SETS[@]}"; do
|
|
|
71
85
|
continue
|
|
72
86
|
fi
|
|
73
87
|
|
|
74
|
-
answer="$(
|
|
75
|
-
|
|
88
|
+
answer="$(bench_answer "$claim" "$KDIR")"
|
|
89
|
+
if [ -n "$ANSWERS_DIR" ]; then
|
|
90
|
+
# A reply left by an earlier run into the same directory is not this run's: drop it first, so
|
|
91
|
+
# a claim that reaches no judge now is not read next to a stale <id>.judge.txt.
|
|
92
|
+
rm -f "$ANSWERS_DIR/$id.judge.txt"
|
|
93
|
+
printf '%s\n' "$answer" > "$ANSWERS_DIR/$id.txt"
|
|
94
|
+
fi
|
|
95
|
+
# No answer (backend failed or timed out) covers no point. Do not spend a judge call on it.
|
|
96
|
+
if [ -n "$answer" ]; then
|
|
97
|
+
[ -z "$ANSWERS_DIR" ] || export BENCH_JUDGE_RAW="$ANSWERS_DIR/$id.judge.txt"
|
|
98
|
+
score="$(bench_judge "$claim" "$answer" "$must")"
|
|
99
|
+
else
|
|
100
|
+
score="0"
|
|
101
|
+
fi
|
|
76
102
|
N=$((N+1))
|
|
77
103
|
SUM="$(awk -v a="$SUM" -v b="$score" 'BEGIN{printf "%.4f", a+b}')"
|
|
78
104
|
RESULTS_JSON="$(printf '%s' "$RESULTS_JSON" | jq -c \
|