@jeiemgi/cckit 0.10.0 → 0.12.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 +136 -127
- package/README.md +66 -43
- package/bin/cckit +151 -181
- package/cckit.config.json +1 -4
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot-run-test.sh +20 -12
- package/scripts/autopilot-run.sh +9 -1
- package/scripts/autopilot-test.sh +29 -13
- package/scripts/autopilot.sh +4 -4
- package/scripts/benchmark/verb-timings-test.sh +4 -0
- package/scripts/benchmark/verb-timings.sh +16 -5
- package/scripts/capture-project-ids.sh +23 -1
- package/scripts/check.sh +25 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/contribute.sh +8 -3
- package/scripts/copilot-loop-test.sh +66 -81
- package/scripts/exec-targets-test.sh +20 -0
- package/scripts/force-push-fence-test.sh +44 -0
- package/scripts/force-push-fence.baseline +1 -0
- package/scripts/force-push-fence.sh +51 -0
- package/scripts/forge-fence-test.sh +69 -0
- package/scripts/forge-fence.baseline +2 -0
- package/scripts/forge-fence.sh +76 -0
- package/scripts/forge-report-test.sh +100 -0
- package/scripts/forge-report.sh +176 -0
- package/scripts/init-guided-test.sh +94 -82
- package/scripts/init.sh +12 -7
- package/scripts/install-test.sh +26 -0
- package/scripts/install.sh +7 -0
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +60 -12
- package/scripts/kit-doctor.sh +170 -77
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +15 -8
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +37 -8
- package/scripts/lib/content-kinds-gc-test.sh +22 -21
- package/scripts/lib/copilot-test.sh +20 -11
- package/scripts/lib/copilot.sh +19 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +5 -3
- package/scripts/lib/effort-metrics-test.sh +7 -12
- package/scripts/lib/effort-metrics.sh +17 -46
- package/scripts/lib/effort-ops-test.sh +261 -167
- package/scripts/lib/effort-ops.sh +449 -171
- package/scripts/lib/effort-parity-test.sh +57 -62
- package/scripts/lib/effort-plan-test.sh +56 -54
- package/scripts/lib/effort-plan.sh +14 -7
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +34 -14
- package/scripts/lib/effort-slug.sh +13 -13
- package/scripts/lib/effort.sh +58 -80
- package/scripts/lib/forge-github.sh +260 -0
- package/scripts/lib/forge-none.sh +24 -0
- package/scripts/lib/forge-test.sh +186 -0
- package/scripts/lib/forge.sh +133 -0
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +151 -31
- package/scripts/lib/gh-project.sh +139 -11
- package/scripts/lib/gh-rest-test.sh +63 -118
- package/scripts/lib/gh-rest.sh +275 -52
- package/scripts/lib/git-core-test.sh +128 -0
- package/scripts/lib/grill-record-test.sh +49 -0
- package/scripts/lib/grill-record.sh +88 -0
- package/scripts/lib/handoff.sh +1 -1
- package/scripts/lib/init-github.sh +38 -13
- package/scripts/lib/kinds-test.sh +13 -16
- package/scripts/lib/kit-brief-test.sh +51 -10
- package/scripts/lib/kit-brief.sh +103 -18
- package/scripts/lib/kit-gc-test.sh +90 -109
- package/scripts/lib/kit-gc.sh +19 -22
- package/scripts/lib/kit-hotfix.sh +18 -16
- package/scripts/lib/kit-interview.sh +6 -0
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +7 -7
- package/scripts/lib/kit-msg.sh +3 -3
- package/scripts/lib/kit-status.sh +19 -14
- package/scripts/lib/kit-task-ops-test.sh +20 -1
- package/scripts/lib/kit-task-ops.sh +177 -94
- package/scripts/lib/kto-hotfix-test.sh +53 -58
- package/scripts/lib/kto-task-close-test.sh +28 -27
- package/scripts/lib/kto-task-new-test.sh +55 -48
- package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
- package/scripts/lib/kto-task-pr-test.sh +30 -34
- package/scripts/lib/light-task-run-test.sh +19 -15
- package/scripts/lib/light-task-test.sh +34 -29
- package/scripts/lib/light-task.sh +24 -13
- package/scripts/lib/loose-issues.sh +65 -0
- package/scripts/lib/naming-test.sh +112 -0
- package/scripts/lib/naming-verbs-test.sh +126 -0
- package/scripts/lib/naming.sh +172 -0
- package/scripts/lib/next-test.sh +27 -22
- package/scripts/lib/next.sh +13 -7
- package/scripts/lib/orchestration-runtime-test.sh +11 -8
- package/scripts/lib/plan-machine.sh +22 -16
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +63 -74
- package/scripts/lib/pr-evidence.sh +15 -12
- package/scripts/lib/qa-lane-test.sh +59 -27
- package/scripts/lib/qa-lane.sh +14 -6
- package/scripts/lib/review-page-test.sh +34 -25
- package/scripts/lib/review-page.sh +10 -4
- package/scripts/lib/spec-lint-test.sh +63 -0
- package/scripts/lib/spec-lint.sh +95 -0
- package/scripts/lib/sprint-test.sh +96 -0
- package/scripts/lib/sprint.sh +216 -0
- package/scripts/lib/stage-receipt-test.sh +169 -19
- package/scripts/lib/stage-receipt.sh +195 -10
- package/scripts/lib/test-forge-shim.sh +115 -0
- package/scripts/lib/verbs.sh +105 -0
- package/scripts/lib/verbs.tsv +92 -0
- package/scripts/lib/version-bump-test.sh +20 -0
- package/scripts/lib/version-bump.sh +4 -2
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-issue-test.sh +24 -19
- package/scripts/lib/worktree-issue.sh +10 -10
- package/scripts/lib/worktree-start-test.sh +13 -16
- package/scripts/lib/worktree-start.sh +57 -7
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/marketing-walkthrough-test.sh +25 -30
- package/scripts/night-grant.sh +14 -8
- package/scripts/night-run.mjs +1 -1
- package/scripts/orchestrate-test.sh +27 -31
- package/scripts/orchestrate.sh +9 -3
- package/scripts/portable-test.sh +37 -36
- package/scripts/publish.sh +9 -3
- package/scripts/setup-labels.sh +23 -12
- package/scripts/setup-milestones.sh +8 -2
- package/scripts/status-test.sh +39 -33
- package/scripts/status.sh +12 -6
- package/scripts/task-sync-test.sh +75 -32
- package/scripts/task-sync.sh +97 -6
- package/scripts/terms-check-test.sh +191 -0
- package/scripts/terms-check.sh +242 -0
- package/scripts/verbs-gen.sh +43 -0
- package/scripts/verbs-help-test.sh +61 -0
- package/scripts/verbs-ratchet-test.sh +69 -0
- package/scripts/verbs-ratchet.sh +34 -0
- package/scripts/verbs-test.sh +120 -0
- package/scripts/verbs.baseline +5 -0
- package/skills/kit-add/SKILL.md +2 -1
- package/skills/kit-advisor/SKILL.md +75 -0
- package/skills/kit-advisor/references/close.md +53 -0
- package/skills/kit-advisor/references/grill.md +69 -0
- package/skills/kit-advisor/references/orchestrate.md +56 -0
- package/skills/kit-advisor/references/plan.md +64 -0
- package/skills/kit-advisor/references/review.md +47 -0
- package/skills/kit-advisor/references/step-report.md +61 -0
- package/skills/kit-annotate/SKILL.md +1 -0
- package/skills/kit-autopilot/SKILL.md +2 -1
- package/skills/kit-cleanup/SKILL.md +3 -2
- package/skills/kit-contribute/SKILL.md +1 -0
- package/skills/kit-customize/SKILL.md +1 -0
- package/skills/kit-dev/SKILL.md +1 -0
- package/skills/kit-digest/SKILL.md +1 -0
- package/skills/kit-docs-writer/SKILL.md +4 -3
- package/skills/kit-effort-close/SKILL.md +18 -9
- package/skills/kit-effort-new/SKILL.md +12 -8
- package/skills/kit-effort-pr/SKILL.md +8 -7
- package/skills/kit-effort-start/SKILL.md +1 -0
- package/skills/kit-gc/SKILL.md +1 -0
- package/skills/kit-next/SKILL.md +8 -7
- package/skills/kit-onboard/SKILL.md +1 -0
- package/skills/kit-page/SKILL.md +1 -0
- package/skills/kit-plan-next/SKILL.md +11 -11
- package/skills/kit-security-sweep/SKILL.md +1 -0
- package/skills/kit-ship/SKILL.md +1 -0
- package/skills/kit-status/SKILL.md +6 -5
- package/skills/kit-task-close/SKILL.md +1 -0
- package/skills/kit-task-new/SKILL.md +1 -0
- package/skills/kit-task-pr/SKILL.md +1 -0
- package/skills/kit-task-pr-auto/SKILL.md +2 -1
- package/skills/kit-task-pr-merge/SKILL.md +4 -3
- package/skills/kit-task-start/SKILL.md +1 -0
- package/skills/kit-task-sync/SKILL.md +3 -0
- package/skills/kit-ux-audit/SKILL.md +1 -0
- package/skills/routing.yaml +124 -0
- package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
- package/templates/instructions.md.tmpl +3 -3
- package/templates/rules/authoring.md +7 -3
- package/templates/rules/delegation-brief.md +4 -0
- package/templates/rules/effort-model.md +34 -31
- package/templates/rules/gate-and-review.md +1 -1
- package/templates/rules/merge-safety.md +9 -7
- package/templates/rules/naming-and-ids.md +20 -24
- package/templates/rules/plan-next.md +5 -5
- package/templates/skills/campaign/SKILL.md +2 -2
- package/scripts/lib/engine-adapter.sh +0 -93
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# forge-fence-test.sh — E537.5: the fence fails the gate when a file outside the forge layer calls
|
|
4
|
+
# gh or names api.github.com, passes at or under the baseline, names the offenders, and --write
|
|
5
|
+
# records the current counts. Fixture tree under mktemp -d; the real tree is at its baseline.
|
|
6
|
+
# Run: bash scripts/forge-fence-test.sh
|
|
7
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
8
|
+
set -u
|
|
9
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
10
|
+
fail=0
|
|
11
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
12
|
+
F="$ROOT/scripts/forge-fence.sh"
|
|
13
|
+
|
|
14
|
+
fx="$(mktemp -d)"; trap 'rm -rf "$fx"' EXIT
|
|
15
|
+
mkdir -p "$fx/bin" "$fx/scripts/lib"
|
|
16
|
+
cp "$ROOT/scripts/forge-report.sh" "$fx/scripts/forge-report.sh"
|
|
17
|
+
cat > "$fx/bin/cckit" <<'CCKIT'
|
|
18
|
+
#!/usr/bin/env bash
|
|
19
|
+
LIB="$ROOT/scripts/lib"
|
|
20
|
+
cmd="${1:-}"; shift || true
|
|
21
|
+
case "$cmd" in
|
|
22
|
+
a) source "$LIB/clean.sh"; clean_run ;;
|
|
23
|
+
esac
|
|
24
|
+
CCKIT
|
|
25
|
+
printf 'clean_run() { git status; forge_rest repos/o/r; }\n' > "$fx/scripts/lib/clean.sh"
|
|
26
|
+
printf 'forge_rest() { curl -sS "https://api.github.com/$1"; }\ngh auth token\n' > "$fx/scripts/lib/forge-github.sh"
|
|
27
|
+
printf 'gh_rest_issue_json() { forge_rest "repos/$1/issues/$2"; }\n' > "$fx/scripts/lib/gh-rest.sh"
|
|
28
|
+
printf 'gh api never-counted\n' > "$fx/scripts/lib/noise-test.sh"
|
|
29
|
+
|
|
30
|
+
printf 'gh=0\napi=0\n' > "$fx/scripts/forge-fence.baseline"
|
|
31
|
+
out="$(bash "$F" --root "$fx")"; rc=$?
|
|
32
|
+
t "a clean tree passes at baseline 0" "$rc" "0"
|
|
33
|
+
t "the pass line carries both counts" "$(printf '%s' "$out" | grep -c '^ok forge fence: gh 0/0 · api 0/0')" "1"
|
|
34
|
+
|
|
35
|
+
printf 'read_it() { gh issue view "$1" --json title; }\n' > "$fx/scripts/lib/stray.sh"
|
|
36
|
+
out="$(bash "$F" --root "$fx")"; rc=$?
|
|
37
|
+
t "a gh call outside the layer fails" "$rc" "1"
|
|
38
|
+
t "the offender is named" "$(printf '%s' "$out" | grep -c ' scripts/lib/stray.sh')" "1"
|
|
39
|
+
t "the message says what to call instead" "$(printf '%s' "$out" | grep -c 'Call the layer (forge_\*, gh_rest_\*) instead')" "1"
|
|
40
|
+
|
|
41
|
+
rm "$fx/scripts/lib/stray.sh"
|
|
42
|
+
printf 'fetch() { curl -sS https://api.github.com/repos/o/r; }\n' > "$fx/scripts/lib/direct.sh"
|
|
43
|
+
out="$(bash "$F" --root "$fx")"; rc=$?
|
|
44
|
+
t "a curl to the API outside the layer fails" "$rc" "1"
|
|
45
|
+
t "the api offender is named" "$(printf '%s' "$out" | grep -c ' scripts/lib/direct.sh')" "1"
|
|
46
|
+
printf '# a comment that names api.github.com is not a call\nx=1\n' > "$fx/scripts/lib/direct.sh"
|
|
47
|
+
bash "$F" --root "$fx" >/dev/null; t "a comment naming the host is not a call" "$?" "0"
|
|
48
|
+
rm "$fx/scripts/lib/direct.sh"
|
|
49
|
+
|
|
50
|
+
printf 'read_it() { gh issue view "$1"; }\n' > "$fx/scripts/lib/stray.sh"
|
|
51
|
+
printf 'gh=1\napi=0\n' > "$fx/scripts/forge-fence.baseline"
|
|
52
|
+
bash "$F" --root "$fx" >/dev/null; t "at the baseline passes" "$?" "0"
|
|
53
|
+
rm "$fx/scripts/lib/stray.sh"
|
|
54
|
+
out="$(bash "$F" --root "$fx")"
|
|
55
|
+
t "under the baseline passes and asks for the ratchet" "$(printf '%s' "$out" | grep -c 'ratchet it: scripts/forge-fence.sh --write')" "1"
|
|
56
|
+
bash "$F" --root "$fx" --write >/dev/null
|
|
57
|
+
t "--write records the current counts" "$(tr '\n' ' ' < "$fx/scripts/forge-fence.baseline")" "gh=0 api=0 "
|
|
58
|
+
|
|
59
|
+
rm "$fx/scripts/forge-fence.baseline"
|
|
60
|
+
bash "$F" --root "$fx" >/dev/null 2>&1; t "no baseline is rc 1" "$?" "1"
|
|
61
|
+
printf 'gh=x\n' > "$fx/scripts/forge-fence.baseline"
|
|
62
|
+
bash "$F" --root "$fx" >/dev/null 2>&1; t "a malformed baseline is rc 1" "$?" "1"
|
|
63
|
+
|
|
64
|
+
# The real tree is at its baseline.
|
|
65
|
+
bash "$F" >/dev/null; t "the repository passes its own fence" "$?" "0"
|
|
66
|
+
t "the repository's baseline is 0/0" "$(tr '\n' ' ' < "$ROOT/scripts/forge-fence.baseline")" "gh=0 api=0 "
|
|
67
|
+
|
|
68
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (forge-fence)"
|
|
69
|
+
exit "$fail"
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# forge-fence.sh — E537.5: the gate fails when a file outside the forge layer calls gh or the GitHub
|
|
3
|
+
# API. The layer is scripts/lib/forge.sh, scripts/lib/forge-*.sh and scripts/lib/gh-rest.sh; every
|
|
4
|
+
# other non-test file under bin/, scripts/ and scripts/lib/ (test doubles, scripts/lib/test-*.sh, are
|
|
5
|
+
# not code) reaches GitHub through forge_* / gh_rest_*.
|
|
6
|
+
#
|
|
7
|
+
# scripts/forge-fence.sh rc 0 when the count is at or under the baseline, 1 over it
|
|
8
|
+
# scripts/forge-fence.sh --root <dir> fence another checkout
|
|
9
|
+
# scripts/forge-fence.sh --write write the current count into the baseline (a ratchet moves
|
|
10
|
+
# down on its own; raising it is a decision, made here on purpose)
|
|
11
|
+
#
|
|
12
|
+
# Two counts, each a ratchet against scripts/forge-fence.baseline (`gh=<n>` and `api=<n>` lines):
|
|
13
|
+
# gh files outside the layer with a gh line, as scripts/forge-report.sh --ratchet counts them
|
|
14
|
+
# (a gh <subcommand> in command position, a `gh "$…"` form, or a `command -v gh` probe)
|
|
15
|
+
# api files outside the layer whose non-comment lines name api.github.com (a curl to the API)
|
|
16
|
+
# The baseline starts at 0 for both (the count left after E537.3). A new offender fails the gate and
|
|
17
|
+
# is named with its lines; the fix is to call the layer.
|
|
18
|
+
# errors: strict — set -e; a missing report script or baseline exits 1
|
|
19
|
+
set -euo pipefail
|
|
20
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
21
|
+
write=0
|
|
22
|
+
while [ $# -gt 0 ]; do
|
|
23
|
+
case "$1" in
|
|
24
|
+
--root) ROOT="$(cd "${2:?--root needs a directory}" && pwd)"; shift 2 ;;
|
|
25
|
+
--write) write=1; shift ;;
|
|
26
|
+
-h|--help) sed -n '2,18p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
27
|
+
*) echo "forge-fence: unknown argument '$1'" >&2; exit 2 ;;
|
|
28
|
+
esac
|
|
29
|
+
done
|
|
30
|
+
report="$ROOT/scripts/forge-report.sh"
|
|
31
|
+
baseline="$ROOT/scripts/forge-fence.baseline"
|
|
32
|
+
[ -f "$report" ] || { echo "forge-fence: $report is missing" >&2; exit 1; }
|
|
33
|
+
|
|
34
|
+
is_layer() { case "$1" in scripts/lib/forge.sh|scripts/lib/forge-*.sh|scripts/lib/gh-rest.sh) return 0 ;; *) return 1 ;; esac; }
|
|
35
|
+
|
|
36
|
+
# gh: the report's own file table (its GH_RE), minus the layer.
|
|
37
|
+
gh_files="$(bash "$report" --root "$ROOT" --files | awk 'NR > 1 && $2 > 0 {print $1}' | while IFS= read -r f; do is_layer "$f" || printf '%s\n' "$f"; done)"
|
|
38
|
+
gh_n="$(printf '%s\n' "$gh_files" | sed '/^$/d' | wc -l | tr -d ' ')"
|
|
39
|
+
|
|
40
|
+
# api: a non-comment line naming the API host, outside the layer.
|
|
41
|
+
api_files="$(cd "$ROOT" && { for f in bin/*; do [ -f "$f" ] && echo "$f"; done; for f in scripts/*.sh scripts/lib/*.sh; do [ -f "$f" ] && echo "$f"; done; } \
|
|
42
|
+
| grep -vE -- '-test\.sh$|^scripts/lib/test-[a-z-]+\.sh$' | sort -u | while IFS= read -r f; do
|
|
43
|
+
is_layer "$f" && continue
|
|
44
|
+
case "$f" in scripts/forge-fence.sh|scripts/forge-report.sh) continue ;; esac
|
|
45
|
+
body="$(grep -vE '^[[:space:]]*#' "$f" || true)"
|
|
46
|
+
if grep -q 'api\.github\.com' <<<"$body"; then printf '%s\n' "$f"; fi
|
|
47
|
+
done)"
|
|
48
|
+
api_n="$(printf '%s\n' "$api_files" | sed '/^$/d' | wc -l | tr -d ' ')"
|
|
49
|
+
|
|
50
|
+
if [ "$write" = 1 ]; then
|
|
51
|
+
printf 'gh=%s\napi=%s\n' "$gh_n" "$api_n" > "$baseline"
|
|
52
|
+
echo "forge-fence: baseline written — gh=$gh_n api=$api_n"
|
|
53
|
+
exit 0
|
|
54
|
+
fi
|
|
55
|
+
[ -f "$baseline" ] || { echo "forge-fence: no baseline at $baseline (run: scripts/forge-fence.sh --write)" >&2; exit 1; }
|
|
56
|
+
gh_max="$(sed -n 's/^gh=//p' "$baseline" | sed -n 1p)"; api_max="$(sed -n 's/^api=//p' "$baseline" | sed -n 1p)"
|
|
57
|
+
case "$gh_max$api_max" in *[!0-9]*|'') echo "forge-fence: the baseline must hold gh=<n> and api=<n>" >&2; exit 1 ;; esac
|
|
58
|
+
|
|
59
|
+
fail=0
|
|
60
|
+
if [ "$gh_n" -gt "$gh_max" ]; then
|
|
61
|
+
fail=1
|
|
62
|
+
echo "x forge fence: $gh_n file(s) outside the forge layer call gh (baseline $gh_max). Call the layer (forge_*, gh_rest_*) instead:"
|
|
63
|
+
printf '%s\n' "$gh_files" | sed '/^$/d' | sed 's/^/ /'
|
|
64
|
+
fi
|
|
65
|
+
if [ "$api_n" -gt "$api_max" ]; then
|
|
66
|
+
fail=1
|
|
67
|
+
echo "x forge fence: $api_n file(s) outside the forge layer name api.github.com (baseline $api_max). Call forge_rest instead:"
|
|
68
|
+
printf '%s\n' "$api_files" | sed '/^$/d' | sed 's/^/ /'
|
|
69
|
+
fi
|
|
70
|
+
if [ "$fail" = 0 ]; then
|
|
71
|
+
echo "ok forge fence: gh $gh_n/$gh_max · api $api_n/$api_max files outside the layer"
|
|
72
|
+
if [ "$gh_n" -lt "$gh_max" ] || [ "$api_n" -lt "$api_max" ]; then
|
|
73
|
+
echo " the count went down — ratchet it: scripts/forge-fence.sh --write"
|
|
74
|
+
fi
|
|
75
|
+
fi
|
|
76
|
+
exit "$fail"
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# forge-report-test.sh — E537.1: forge-report.sh counts gh and git lines per file, classes each file,
|
|
4
|
+
# says per verb whether it needs a forge (following exec/source transitively), and prints the ratchet
|
|
5
|
+
# (files outside the forge layer that call gh). Fixture under its own mktemp -d; no port.
|
|
6
|
+
# Run: bash scripts/forge-report-test.sh
|
|
7
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
8
|
+
set -u
|
|
9
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
10
|
+
fail=0
|
|
11
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
12
|
+
R="$ROOT/scripts/forge-report.sh"
|
|
13
|
+
|
|
14
|
+
fx="$(mktemp -d)"; trap 'rm -rf "$fx"' EXIT
|
|
15
|
+
mkdir -p "$fx/bin" "$fx/scripts/lib"
|
|
16
|
+
cat > "$fx/bin/cckit" <<'CCKIT'
|
|
17
|
+
#!/usr/bin/env bash
|
|
18
|
+
LIB="$ROOT/scripts/lib"
|
|
19
|
+
source "$LIB/common.sh"
|
|
20
|
+
cmd="${1:-}"; shift || true
|
|
21
|
+
case "$cmd" in
|
|
22
|
+
a)
|
|
23
|
+
# a comment that says gh api is not a call
|
|
24
|
+
source "$LIB/issue.sh"; issue_read "$@" ;;
|
|
25
|
+
b|bee) exec "$ROOT/scripts/local.sh" "$@" ;;
|
|
26
|
+
c) echo "nothing here" ;;
|
|
27
|
+
d) gh pr view "$1" ;;
|
|
28
|
+
e) source "$LIB/forge.sh"; forge_issue_view "$@" ;;
|
|
29
|
+
f) source "$LIB/clean.sh"; clean_run "$@" ;;
|
|
30
|
+
help|--help) echo usage ;;
|
|
31
|
+
esac
|
|
32
|
+
CCKIT
|
|
33
|
+
cat > "$fx/scripts/lib/common.sh" <<'SH'
|
|
34
|
+
# shared preamble: not attributed to any verb
|
|
35
|
+
gh auth status >/dev/null
|
|
36
|
+
SH
|
|
37
|
+
cat > "$fx/scripts/lib/issue.sh" <<'SH'
|
|
38
|
+
. "$(dirname "${BASH_SOURCE[0]}")/transport.sh"
|
|
39
|
+
issue_read() { gh issue view "$1" --json title; git -C "$PWD" status; echo "needs gh + jq"; }
|
|
40
|
+
SH
|
|
41
|
+
cat > "$fx/scripts/lib/transport.sh" <<'SH'
|
|
42
|
+
transport() { command -v gh >/dev/null 2>&1 || return 0; }
|
|
43
|
+
SH
|
|
44
|
+
cat > "$fx/scripts/local.sh" <<'SH'
|
|
45
|
+
git fetch origin develop
|
|
46
|
+
git -C "$PWD" rev-parse HEAD
|
|
47
|
+
SH
|
|
48
|
+
cat > "$fx/scripts/lib/forge.sh" <<'SH'
|
|
49
|
+
forge_issue_view() { gh api "repos/$1"; }
|
|
50
|
+
SH
|
|
51
|
+
cat > "$fx/scripts/lib/clean.sh" <<'SH'
|
|
52
|
+
clean_run() { git status; forge_available || echo "git only"; }
|
|
53
|
+
SH
|
|
54
|
+
cat > "$fx/scripts/lib/forge-github.sh" <<'SH'
|
|
55
|
+
gh api graphql
|
|
56
|
+
SH
|
|
57
|
+
cat > "$fx/scripts/lib/noise-test.sh" <<'SH'
|
|
58
|
+
gh api never-counted
|
|
59
|
+
SH
|
|
60
|
+
|
|
61
|
+
files="$(bash "$R" --root "$fx" --files)"
|
|
62
|
+
row() { printf '%s\n' "$files" | awk -v f="$1" '$1==f {print $2, $3, $4}'; }
|
|
63
|
+
t "issue.sh: 1 gh line (the comment-free call), 1 git line, both" "$(row scripts/lib/issue.sh)" "1 1 both"
|
|
64
|
+
t "transport.sh: the command -v probe counts as gh" "$(row scripts/lib/transport.sh)" "1 0 gh-only"
|
|
65
|
+
t "local.sh: 2 git lines, git-only" "$(row scripts/local.sh)" "0 2 git-only"
|
|
66
|
+
t "bin/cckit: the comment is not a call; verb d calls gh" "$(row bin/cckit)" "1 0 gh-only"
|
|
67
|
+
t "common.sh counted as a file" "$(row scripts/lib/common.sh)" "1 0 gh-only"
|
|
68
|
+
t "-test.sh files are not measured" "$(row scripts/lib/noise-test.sh)" ""
|
|
69
|
+
|
|
70
|
+
summary="$(bash "$R" --root "$fx" --summary)"
|
|
71
|
+
t "summary: 8 files" "$(printf '%s\n' "$summary" | grep -oE 'files [0-9]+' | sed -n 1p)" "files 8"
|
|
72
|
+
t "summary: classes add up" "$(printf '%s\n' "$summary" | grep -oE 'gh-only [0-9]+ · git-only [0-9]+ · both [0-9]+ · neither [0-9]+')" "gh-only 5 · git-only 2 · both 1 · neither 0"
|
|
73
|
+
t "ratchet leaves the forge layer out (forge.sh, forge-github.sh)" "$(bash "$R" --root "$fx" --ratchet)" "4"
|
|
74
|
+
|
|
75
|
+
verbs="$(bash "$R" --root "$fx" --verbs)"
|
|
76
|
+
vrow() { printf '%s\n' "$verbs" | awk -v v="$1" '$1==v {print $2}'; }
|
|
77
|
+
t "a needs a forge through issue.sh → transport.sh" "$(vrow a)" "yes"
|
|
78
|
+
t "a: via names the files with gh lines" "$(printf '%s\n' "$verbs" | awk '$1=="a" {print $3, $4}')" "scripts/lib/issue.sh scripts/lib/transport.sh"
|
|
79
|
+
t "b: git only" "$(vrow b)" "no"
|
|
80
|
+
t "bee: an alias label is its own row" "$(vrow bee)" "no"
|
|
81
|
+
t "c: nothing" "$(vrow c)" "no"
|
|
82
|
+
t "d: an inline gh call in the dispatcher" "$(vrow d)" "yes"
|
|
83
|
+
t "e: a call into the forge layer needs a forge" "$(vrow e)" "yes"
|
|
84
|
+
t "f: a forge_available probe alone is git only" "$(vrow f)" "no"
|
|
85
|
+
t "help labels are not verbs" "$(vrow help)" ""
|
|
86
|
+
t "verb summary" "$(printf '%s\n' "$summary" | grep -oE 'verbs [0-9]+ · needs a forge [0-9]+ · git only [0-9]+')" "verbs 7 · needs a forge 3 · git only 4"
|
|
87
|
+
|
|
88
|
+
if command -v jq >/dev/null 2>&1; then
|
|
89
|
+
j="$(bash "$R" --root "$fx" --json)"
|
|
90
|
+
t "--json parses" "$(printf '%s' "$j" | jq -r '.summary.files')" "8"
|
|
91
|
+
t "--json verbs carry via" "$(printf '%s' "$j" | jq -r '.verbs[] | select(.verb=="a") | .via | length')" "2"
|
|
92
|
+
t "--json needs_forge is a boolean" "$(printf '%s' "$j" | jq -r '.verbs[] | select(.verb=="d") | .needs_forge')" "true"
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# On the real tree the report runs and the ratchet is a number (its value is the effort's business).
|
|
96
|
+
t "real tree: ratchet is an integer" "$(bash "$R" --ratchet | grep -cE '^[0-9]+$')" "1"
|
|
97
|
+
t "unknown flag exits 2" "$(bash "$R" --nope >/dev/null 2>&1; echo $?)" "2"
|
|
98
|
+
|
|
99
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (forge-report)"
|
|
100
|
+
exit "$fail"
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# forge-report.sh — E537.1: measure where cckit depends on a forge (GitHub through `gh`) and where it
|
|
3
|
+
# needs only git. The ratchet source for effort 537 (git apart from GitHub): every later sub reads
|
|
4
|
+
# its numbers before and after.
|
|
5
|
+
#
|
|
6
|
+
# scripts/forge-report.sh summary + the file table + the verb table
|
|
7
|
+
# scripts/forge-report.sh --summary the two summary lines only
|
|
8
|
+
# scripts/forge-report.sh --files per file: gh lines · git lines · class
|
|
9
|
+
# scripts/forge-report.sh --verbs per verb of bin/cckit: needs a forge yes|no · via which files
|
|
10
|
+
# scripts/forge-report.sh --ratchet ONE integer: files outside the forge layer that call gh
|
|
11
|
+
# scripts/forge-report.sh --json everything as one JSON object (no jq needed to produce it)
|
|
12
|
+
# scripts/forge-report.sh --root <dir> measure another checkout (default: this repository)
|
|
13
|
+
#
|
|
14
|
+
# What is measured (non-test files only: bin/*, scripts/*.sh, scripts/lib/*.sh; never *-test.sh nor
|
|
15
|
+
# the scripts/lib/test-*.sh test doubles):
|
|
16
|
+
# gh line — a non-comment line that runs `gh <subcommand>` in command position (line start, after
|
|
17
|
+
# `(`, `$(`, `|`, `;`, `&`, `!`, `{`, or after if/then/else/do/while/exec), a `gh "$…"`
|
|
18
|
+
# form, or a probe (`command -v gh`, `has_cmd gh`, `_eff_need gh`). A message that
|
|
19
|
+
# tells a person to run gh is not a call.
|
|
20
|
+
# git line — a non-comment line that runs `git <subcommand>` or `git -C`.
|
|
21
|
+
# class — gh-only · git-only · both · neither, from those two counts.
|
|
22
|
+
# verb — a label of the `case "$cmd"` dispatcher in bin/cckit. A verb needs a forge when its
|
|
23
|
+
# own block, or any file it execs or sources (followed transitively through `source`/`.`
|
|
24
|
+
# of *.sh files under scripts/ and scripts/lib/), has a gh line or calls into the forge
|
|
25
|
+
# layer (forge_*, gh_rest_*; a bare forge_available probe does not count). The forge
|
|
26
|
+
# layer's own files are not attributed to a verb. The preamble before the case is
|
|
27
|
+
# shared by every verb and is not attributed to any.
|
|
28
|
+
# forge layer — scripts/lib/forge.sh, scripts/lib/forge-*.sh and scripts/lib/gh-rest.sh (E537.2):
|
|
29
|
+
# gh runs there only (gh auth token), so --ratchet leaves the layer out.
|
|
30
|
+
# errors: strict — set -e; an unreadable root or a bin/cckit without a dispatcher exits 1
|
|
31
|
+
set -euo pipefail
|
|
32
|
+
|
|
33
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
34
|
+
mode="all"
|
|
35
|
+
while [ $# -gt 0 ]; do
|
|
36
|
+
case "$1" in
|
|
37
|
+
--summary|--files|--verbs|--ratchet|--json) mode="${1#--}"; shift ;;
|
|
38
|
+
--root) ROOT="$(cd "${2:?--root needs a directory}" && pwd)"; shift 2 ;;
|
|
39
|
+
-h|--help) sed -n '2,24p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
40
|
+
*) echo "forge-report: unknown argument '$1'" >&2; exit 2 ;;
|
|
41
|
+
esac
|
|
42
|
+
done
|
|
43
|
+
[ -f "$ROOT/bin/cckit" ] || { echo "forge-report: no bin/cckit under $ROOT" >&2; exit 1; }
|
|
44
|
+
|
|
45
|
+
GH_PRE='(^|[;&|(){!`]|\$\(|(^|[^[:alnum:]_])(if|then|else|elif|do|while|until|exec|time|env|nohup)[[:space:]]+)[[:space:]]*'
|
|
46
|
+
GH_RE="${GH_PRE}gh[[:space:]]+(api|pr|issue|repo|run|release|auth|label|project|search|workflow|secret|variable|cache|gist|browse|extension|config|--version)([^[:alnum:]_-]|\$)|(command -v|has_cmd|_eff_need) gh([^[:alnum:]_-]|\$)|${GH_PRE}gh[[:space:]]+\"\\\$"
|
|
47
|
+
# A call into the forge layer: the verb needs a forge even though no gh runs (E537.2+).
|
|
48
|
+
FORGE_RE='(^|[^[:alnum:]_])(forge_(rest|graphql|api|issue_[a-z]+|pr_[a-z]+|need|login[a-z_]*)|gh_rest_[a-z_]+|_ghr_api)([^[:alnum:]_]|$)'
|
|
49
|
+
GIT_RE='(^|[^[:alnum:]_./-])git[[:space:]]+(-C[[:space:]]|-c[[:space:]]|[a-z][a-z-]*([^[:alnum:]_-]|$))'
|
|
50
|
+
|
|
51
|
+
# fr_files: the measured files, repo-relative, sorted.
|
|
52
|
+
fr_files() {
|
|
53
|
+
( cd "$ROOT" && {
|
|
54
|
+
for f in bin/*; do [ -f "$f" ] && echo "$f"; done
|
|
55
|
+
for f in scripts/*.sh scripts/lib/*.sh; do [ -f "$f" ] && echo "$f"; done
|
|
56
|
+
} | grep -vE -- '-test\.sh$|^scripts/lib/test-[a-z-]+\.sh$' | sort -u )
|
|
57
|
+
}
|
|
58
|
+
# fr_count <regex> <file>: matching non-comment lines.
|
|
59
|
+
fr_count() { grep -vE '^[[:space:]]*#' "$ROOT/$2" 2>/dev/null | grep -cE "$1" || true; }
|
|
60
|
+
fr_class() { # <gh> <git>
|
|
61
|
+
if [ "$1" -gt 0 ] && [ "$2" -gt 0 ]; then echo both
|
|
62
|
+
elif [ "$1" -gt 0 ]; then echo gh-only
|
|
63
|
+
elif [ "$2" -gt 0 ]; then echo git-only
|
|
64
|
+
else echo neither; fi
|
|
65
|
+
}
|
|
66
|
+
fr_is_forge_layer() { case "$1" in scripts/lib/forge.sh|scripts/lib/forge-*.sh|scripts/lib/gh-rest.sh) return 0 ;; *) return 1 ;; esac; }
|
|
67
|
+
# fr_calls_forge <file-or-text-on-stdin>: a non-comment, non-definition line that calls the layer.
|
|
68
|
+
fr_calls_forge_text() { local t; t="$(grep -vE '^[[:space:]]*#|^[[:space:]]*[a-z_]+\(\)' || true)"; grep -qE "$FORGE_RE" <<<"$t"; }
|
|
69
|
+
|
|
70
|
+
# fr_resolve <name>: a *.sh basename (or scripts/… path) → repo-relative path, or nothing.
|
|
71
|
+
fr_resolve() {
|
|
72
|
+
local n="$1" b
|
|
73
|
+
n="${n#\$ROOT/}"; n="${n#\$LIB/}"; n="${n#\$\{ROOT\}/}"; n="${n#\$\{LIB\}/}"
|
|
74
|
+
b="$(basename "$n")"
|
|
75
|
+
case "$b" in *-test.sh) return 0 ;; esac
|
|
76
|
+
if [ -f "$ROOT/$n" ] && [ "${n#scripts/}" != "$n" ]; then echo "$n"; return; fi
|
|
77
|
+
if [ -f "$ROOT/scripts/lib/$b" ]; then echo "scripts/lib/$b"; return; fi
|
|
78
|
+
if [ -f "$ROOT/scripts/$b" ]; then echo "scripts/$b"; return; fi
|
|
79
|
+
}
|
|
80
|
+
# fr_refs_in_text: file references in a block of shell (exec/source targets, scripts paths).
|
|
81
|
+
fr_refs_in_text() {
|
|
82
|
+
grep -vE '^[[:space:]]*#' | grep -oE '(\$\{?(ROOT|LIB)\}?/[A-Za-z0-9_./-]+|(^|[[:space:]])(source|\.)[[:space:]]+"?[^;&|]*/[A-Za-z0-9_-]+\.sh)' \
|
|
83
|
+
| sed -E 's/^[[:space:]]*(source|\.)[[:space:]]+"?//' | sort -u
|
|
84
|
+
}
|
|
85
|
+
# fr_closure <file…>: the files plus everything they source, transitively (bash 3.2: a list string).
|
|
86
|
+
fr_closure() {
|
|
87
|
+
local queue="$*" seen="" f r
|
|
88
|
+
while [ -n "$queue" ]; do
|
|
89
|
+
f="${queue%% *}"; queue="${queue#"$f"}"; queue="${queue# }"
|
|
90
|
+
[ -n "$f" ] || continue
|
|
91
|
+
grep -qxF "$f" <<<"$seen" && continue
|
|
92
|
+
seen="$seen
|
|
93
|
+
$f"
|
|
94
|
+
for r in $(fr_refs_in_text < "$ROOT/$f" | while read -r x; do fr_resolve "$x"; done | sort -u); do
|
|
95
|
+
grep -qxF "$r" <<<"$seen" || queue="$queue $r"
|
|
96
|
+
done
|
|
97
|
+
done
|
|
98
|
+
printf '%s\n' "$seen" | sed '/^$/d'
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# The dispatcher: verb labels and their blocks, from `case "$cmd" in` to its `esac`.
|
|
102
|
+
fr_dispatcher() {
|
|
103
|
+
awk '/^case "\$cmd" in/{on=1; next} on && /^esac/{exit} on{print}' "$ROOT/bin/cckit"
|
|
104
|
+
}
|
|
105
|
+
fr_verb_rows() { # verb<TAB>needs<TAB>via (space-separated files with gh lines)
|
|
106
|
+
local disp block label verbs v needs via files f gh
|
|
107
|
+
disp="$(fr_dispatcher)"
|
|
108
|
+
[ -n "$disp" ] || { echo "forge-report: no 'case \"\$cmd\" in' dispatcher in bin/cckit" >&2; return 1; }
|
|
109
|
+
printf '%s\n' "$disp" | awk '
|
|
110
|
+
/^ [a-z][a-z0-9|_-]*\)/ { if (label != "") { print label "\t" block }; label=$0; sub(/\).*/, "", label); sub(/^ /, "", label); block=$0; next }
|
|
111
|
+
label != "" { block = block "\001" $0 }
|
|
112
|
+
END { if (label != "") print label "\t" block }' | while IFS=$'\t' read -r label block; do
|
|
113
|
+
block="$(printf '%s' "$block" | tr '\001' '\n')"
|
|
114
|
+
verbs="$(printf '%s' "$label" | tr '|' ' ')"
|
|
115
|
+
needs=no; via=""
|
|
116
|
+
blk="$(printf '%s\n' "$block" | grep -vE '^[[:space:]]*#' || true)"
|
|
117
|
+
if grep -qE "$GH_RE" <<<"$blk" || printf '%s\n' "$blk" | fr_calls_forge_text; then needs=yes; via="bin/cckit"; fi
|
|
118
|
+
files="$(printf '%s\n' "$block" | fr_refs_in_text | while read -r x; do fr_resolve "$x"; done | sort -u | tr '\n' ' ')"
|
|
119
|
+
if [ -n "${files// /}" ]; then
|
|
120
|
+
for f in $(fr_closure $files); do
|
|
121
|
+
fr_is_forge_layer "$f" && continue
|
|
122
|
+
gh="$(fr_count "$GH_RE" "$f")"
|
|
123
|
+
if [ "$gh" -gt 0 ] || fr_calls_forge_text < "$ROOT/$f"; then needs=yes; via="$via $f"; fi
|
|
124
|
+
done
|
|
125
|
+
fi
|
|
126
|
+
for v in $verbs; do
|
|
127
|
+
case "$v" in help|--help|-h) continue ;; esac
|
|
128
|
+
printf '%s\t%s\t%s\n' "$v" "$needs" "$(printf '%s' "$via" | sed 's/^ //')"
|
|
129
|
+
done
|
|
130
|
+
done
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# ---- gather -----------------------------------------------------------------------------------
|
|
134
|
+
file_rows="$(for f in $(fr_files); do gh="$(fr_count "$GH_RE" "$f")"; git="$(fr_count "$GIT_RE" "$f")"; printf '%s\t%s\t%s\t%s\n' "$f" "$gh" "$git" "$(fr_class "$gh" "$git")"; done)"
|
|
135
|
+
n_files="$(printf '%s\n' "$file_rows" | sed '/^$/d' | wc -l | tr -d ' ')"
|
|
136
|
+
n_gh_only="$(printf '%s\n' "$file_rows" | awk -F'\t' '$4=="gh-only"' | wc -l | tr -d ' ')"
|
|
137
|
+
n_git_only="$(printf '%s\n' "$file_rows" | awk -F'\t' '$4=="git-only"' | wc -l | tr -d ' ')"
|
|
138
|
+
n_both="$(printf '%s\n' "$file_rows" | awk -F'\t' '$4=="both"' | wc -l | tr -d ' ')"
|
|
139
|
+
n_neither="$(printf '%s\n' "$file_rows" | awk -F'\t' '$4=="neither"' | wc -l | tr -d ' ')"
|
|
140
|
+
n_gh_lines="$(printf '%s\n' "$file_rows" | awk -F'\t' '{s+=$2} END{print s+0}')"
|
|
141
|
+
n_git_lines="$(printf '%s\n' "$file_rows" | awk -F'\t' '{s+=$3} END{print s+0}')"
|
|
142
|
+
ratchet="$(printf '%s\n' "$file_rows" | awk -F'\t' '$2>0 {print $1}' | while read -r f; do fr_is_forge_layer "$f" || echo "$f"; done | wc -l | tr -d ' ')"
|
|
143
|
+
|
|
144
|
+
if [ "$mode" = "ratchet" ]; then echo "$ratchet"; exit 0; fi
|
|
145
|
+
|
|
146
|
+
verb_rows="$(fr_verb_rows)"
|
|
147
|
+
n_verbs="$(printf '%s\n' "$verb_rows" | sed '/^$/d' | wc -l | tr -d ' ')"
|
|
148
|
+
n_forge="$(printf '%s\n' "$verb_rows" | awk -F'\t' '$2=="yes"' | wc -l | tr -d ' ')"
|
|
149
|
+
|
|
150
|
+
# ---- print ------------------------------------------------------------------------------------
|
|
151
|
+
print_summary() {
|
|
152
|
+
printf 'forge report · %s\n' "$ROOT"
|
|
153
|
+
printf 'files %s · gh-only %s · git-only %s · both %s · neither %s · gh lines %s · git lines %s · files calling gh outside the forge layer %s\n' \
|
|
154
|
+
"$n_files" "$n_gh_only" "$n_git_only" "$n_both" "$n_neither" "$n_gh_lines" "$n_git_lines" "$ratchet"
|
|
155
|
+
printf 'verbs %s · needs a forge %s · git only %s\n' "$n_verbs" "$n_forge" "$((n_verbs - n_forge))"
|
|
156
|
+
}
|
|
157
|
+
print_files() { printf 'file\tgh\tgit\tclass\n%s\n' "$file_rows" | column -t -s $'\t'; }
|
|
158
|
+
print_verbs() { printf 'verb\tneeds-forge\tvia\n%s\n' "$verb_rows" | column -t -s $'\t'; }
|
|
159
|
+
json_str() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
|
|
160
|
+
print_json() {
|
|
161
|
+
printf '{"root":"%s","summary":{"files":%s,"gh_only":%s,"git_only":%s,"both":%s,"neither":%s,"gh_lines":%s,"git_lines":%s,"files_calling_gh_outside_forge":%s,"verbs":%s,"verbs_needing_forge":%s},' \
|
|
162
|
+
"$(json_str "$ROOT")" "$n_files" "$n_gh_only" "$n_git_only" "$n_both" "$n_neither" "$n_gh_lines" "$n_git_lines" "$ratchet" "$n_verbs" "$n_forge"
|
|
163
|
+
printf '"files":['
|
|
164
|
+
printf '%s\n' "$file_rows" | sed '/^$/d' | awk -F'\t' 'NR>1{printf ","} {printf "{\"path\":\"%s\",\"gh\":%s,\"git\":%s,\"class\":\"%s\"}", $1, $2, $3, $4}'
|
|
165
|
+
printf '],"verbs":['
|
|
166
|
+
printf '%s\n' "$verb_rows" | sed '/^$/d' | awk -F'\t' 'NR>1{printf ","} { n=split($3, v, " "); printf "{\"verb\":\"%s\",\"needs_forge\":%s,\"via\":[", $1, ($2=="yes"?"true":"false"); for(i=1;i<=n;i++){ if(v[i]!=""){ printf "%s\"%s\"", (i>1?",":""), v[i] } } printf "]}" }'
|
|
167
|
+
printf ']}\n'
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
case "$mode" in
|
|
171
|
+
summary) print_summary ;;
|
|
172
|
+
files) print_files ;;
|
|
173
|
+
verbs) print_verbs ;;
|
|
174
|
+
json) print_json ;;
|
|
175
|
+
all) print_summary; echo; print_files; echo; print_verbs ;;
|
|
176
|
+
esac
|