@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
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
# shellcheck shell=bash
|
|
3
3
|
# task-sync-test.sh — covers the dashboard layer of `cckit sync` (#383): the `--json` summary, the
|
|
4
4
|
# atomic `--write` cache, `--cached [TTL]`, one `--watch` iteration, the op.start/op.done events and
|
|
5
|
-
# `--plan`. Hermetic: a throwaway repo +
|
|
5
|
+
# `--plan`. Hermetic: a throwaway repo + the forge shim (scripts/lib/test-forge-shim.sh), whose log
|
|
6
|
+
# counts the requests and whose fixture fails on demand.
|
|
6
7
|
# Run: bash scripts/task-sync-test.sh
|
|
7
8
|
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
8
9
|
set -u
|
|
@@ -23,43 +24,48 @@ CALLS="$tmp/gh-calls"
|
|
|
23
24
|
|
|
24
25
|
OLD20="$(date -u -v-20d +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '20 days ago' +%Y-%m-%dT%H:%M:%SZ)"
|
|
25
26
|
NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
27
|
+
# The issues as `GET repos/<r>/issues` answers them (REST field names).
|
|
26
28
|
cat > "$tmp/issues.json" <<JSON
|
|
27
|
-
[ {"number":1,"title":"lead work","labels":[{"name":"role:tech-lead"},{"name":"priority:p1"}],"milestone":{"title":"v1"},"assignees":[],"
|
|
28
|
-
{"number":2,"title":"docs work","labels":[{"name":"role:docs"}],"milestone":null,"assignees":[],"
|
|
29
|
-
{"number":3,"title":"no role","labels":[],"milestone":null,"assignees":[],"
|
|
29
|
+
[ {"number":1,"title":"lead work","labels":[{"name":"role:tech-lead"},{"name":"priority:p1"}],"milestone":{"title":"v1"},"assignees":[],"updated_at":"$NOW","body":"plain"},
|
|
30
|
+
{"number":2,"title":"docs work","labels":[{"name":"role:docs"}],"milestone":null,"assignees":[],"updated_at":"$OLD20","body":"Blocked by #1"},
|
|
31
|
+
{"number":3,"title":"no role","labels":[],"milestone":null,"assignees":[],"updated_at":"$NOW","body":""} ]
|
|
30
32
|
JSON
|
|
31
|
-
# Same five PRs board-view-test.sh orders: ready(risk asc, size asc) → draft → blocked.
|
|
33
|
+
# Same five PRs board-view-test.sh orders: ready(risk asc, size asc) → draft → blocked. prs.json is
|
|
34
|
+
# what `GET repos/<r>/pulls` answers; prs-view.json the same PRs in the shape board_merge_queue
|
|
35
|
+
# reads (REST has no reviewDecision, so sync maps it to null — the view fixture says so too).
|
|
32
36
|
cat > "$tmp/prs.json" <<'JSON'
|
|
33
37
|
[
|
|
34
|
-
{"number":10,"title":"blocked one","labels":[{"name":"risk:low"},{"name":"size:S"},{"name":"blocked"}],"
|
|
35
|
-
{"number":11,"title":"draft one","labels":[{"name":"risk:low"},{"name":"size:XS"}],"
|
|
36
|
-
{"number":12,"title":"ready high risk","labels":[{"name":"risk:high"},{"name":"size:S"}],"
|
|
37
|
-
{"number":13,"title":"ready low risk L","labels":[{"name":"risk:low"},{"name":"size:L"}],"
|
|
38
|
-
{"number":14,"title":"ready low risk S","labels":[{"name":"risk:low"},{"name":"size:S"}],"
|
|
38
|
+
{"number":10,"title":"blocked one","labels":[{"name":"risk:low"},{"name":"size:S"},{"name":"blocked"}],"draft":false,"head":{"ref":"feat/10"},"mergeable":true},
|
|
39
|
+
{"number":11,"title":"draft one","labels":[{"name":"risk:low"},{"name":"size:XS"}],"draft":true,"head":{"ref":"feat/11"},"mergeable":true},
|
|
40
|
+
{"number":12,"title":"ready high risk","labels":[{"name":"risk:high"},{"name":"size:S"}],"draft":false,"head":{"ref":"claude/12"},"mergeable":true},
|
|
41
|
+
{"number":13,"title":"ready low risk L","labels":[{"name":"risk:low"},{"name":"size:L"}],"draft":false,"head":{"ref":"feat/13"},"mergeable":true},
|
|
42
|
+
{"number":14,"title":"ready low risk S","labels":[{"name":"risk:low"},{"name":"size:S"}],"draft":false,"head":{"ref":"feat/14"},"mergeable":true}
|
|
39
43
|
]
|
|
40
44
|
JSON
|
|
45
|
+
jq '[.[] | {number, title, labels, isDraft: .draft, headRefName: .head.ref, reviewDecision: null, mergeable: "MERGEABLE"}]' \
|
|
46
|
+
"$tmp/prs.json" > "$tmp/prs-view.json"
|
|
41
47
|
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*)
|
|
48
|
+
# The forge shim: every request is one line in $CALLS; GH_FAIL=1 fails every call (HTTP 500),
|
|
49
|
+
# GH_FAIL_PR=1 only the PR list. The open-issue list filtered on `labels=effort` is effort_plan's
|
|
50
|
+
# query (effort_open_rows parses the array).
|
|
51
|
+
stub="$tmp/bin"
|
|
52
|
+
# shellcheck source=/dev/null
|
|
53
|
+
. "$ROOT/scripts/lib/test-forge-shim.sh"; forge_shim_install "$stub"
|
|
54
|
+
cat > "$tmp/fixture.sh" <<'SH'
|
|
55
|
+
[ "${GH_FAIL:-0}" = 1 ] && code=500
|
|
56
|
+
case "$method $ep" in
|
|
57
|
+
"GET repos/octo/fixture/issues")
|
|
58
|
+
case "$path" in
|
|
59
|
+
*labels=effort*) out='[{"number":42,"title":"[Effort] 42 · [Core] demo effort","labels":[{"name":"effort"},{"name":"flow:core"},{"name":"ctx:M"}]}]' ;;
|
|
60
|
+
*) out="$(cat "$GH_ISSUES")" ;;
|
|
54
61
|
esac ;;
|
|
55
|
-
"
|
|
56
|
-
*) echo "" ;;
|
|
62
|
+
"GET repos/octo/fixture/pulls") [ "${GH_FAIL_PR:-0}" = 1 ] && code=500; out="$(cat "$GH_PRS")" ;;
|
|
57
63
|
esac
|
|
58
64
|
SH
|
|
59
|
-
chmod +x "$stub/gh"
|
|
60
65
|
|
|
61
66
|
sync() { # run task-sync.sh against the fixture; extra env via leading VAR=val words in "$ENVV"
|
|
62
|
-
( cd "$fix" && env KIT_CONFIG="$fix/cckit.config.json" PATH="$stub:$PATH"
|
|
67
|
+
( cd "$fix" && env KIT_CONFIG="$fix/cckit.config.json" PATH="$stub:$PATH" GH_LOG="$CALLS" \
|
|
68
|
+
GH_FIXTURE="$tmp/fixture.sh" GH_TOKEN=test-token CCKIT_FORGE=github \
|
|
63
69
|
GH_ISSUES="$tmp/issues.json" GH_PRS="$tmp/prs.json" CCKIT_OUTPUT=human ${ENVV:-} \
|
|
64
70
|
bash "$ROOT/scripts/task-sync.sh" "$@" )
|
|
65
71
|
}
|
|
@@ -80,11 +86,14 @@ t "--json stale section" "$(printf '%s' "$doc" | jq -c '.stale')" '{"days":14,"i
|
|
|
80
86
|
t "--json notOnBoard is null with the board off" "$(printf '%s' "$doc" | jq -r '.notOnBoard')" "null"
|
|
81
87
|
# shellcheck source=/dev/null
|
|
82
88
|
source "$ROOT/scripts/lib/board-view.sh"
|
|
83
|
-
rendered="$(board_merge_queue "$(cat "$tmp/prs.json")" | grep -oE '#1[0-4]' | tr -d '#' | tr '\n' ' ')"
|
|
89
|
+
rendered="$(board_merge_queue "$(cat "$tmp/prs-view.json")" | grep -oE '#1[0-4]' | tr -d '#' | tr '\n' ' ')"
|
|
84
90
|
t "--json merge queue order matches board_merge_queue" "$(printf '%s' "$doc" | jq -r '[.mergeQueue[].number|tostring]|join(" ")') " "$rendered"
|
|
85
91
|
t "--json merge queue order is ready, draft, blocked" "$(printf '%s' "$doc" | jq -r '[.mergeQueue[].number|tostring]|join(" ")')" "14 13 12 11 10"
|
|
86
92
|
t "--json does not write the cache on its own" "$([ -f "$CACHE" ] && echo yes || echo no)" "no"
|
|
87
93
|
t "--json applies --role" "$(sync --json --role Docs 2>/dev/null | jq -r '([.roles[].role]|join(",")) + " " + (.unassigned|length|tostring)')" "Docs 0"
|
|
94
|
+
has "--json reads the open issues over REST" "$(cat "$CALLS")" "GET repos/octo/fixture/issues?state=open&per_page=100 "
|
|
95
|
+
has "--json reads the open PRs over REST" "$(cat "$CALLS")" "GET repos/octo/fixture/pulls?state=open&per_page=100 "
|
|
96
|
+
t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$CALLS")" "0"
|
|
88
97
|
|
|
89
98
|
# ── (5) events: op.start + op.done for the sync ────────────────────────────────────────────────
|
|
90
99
|
t "kit-events.jsonl has an op.start for sync" "$(jq -rs '[.[]|select(.type=="op.start" and .op=="sync")]|length > 0' "$EVENTS" 2>/dev/null)" "true"
|
|
@@ -99,7 +108,7 @@ t "the cache is the --json document" "$(jq -r '.mergeQueue|length' "$CACHE" 2>/d
|
|
|
99
108
|
t "--write leaves no temp file behind" "$(find "$fix/.git" -maxdepth 1 -name 'kit-sync-cache.json.*' | wc -l | tr -d ' ')" "0"
|
|
100
109
|
before="$(sum "$CACHE")"
|
|
101
110
|
ENVV="GH_FAIL=1"; sync --write >/dev/null 2>&1; rc=$?
|
|
102
|
-
t "--write with a failing
|
|
111
|
+
t "--write with a failing forge exits non-zero" "$([ "$rc" -ne 0 ] && echo nz || echo z)" "nz"
|
|
103
112
|
t "a failing fetch leaves the cache byte-identical" "$(sum "$CACHE")" "$before"
|
|
104
113
|
ENVV="GH_FAIL_PR=1"; sync --write >/dev/null 2>&1; rc=$?
|
|
105
114
|
t "a partial fetch (PR list down) exits non-zero" "$([ "$rc" -ne 0 ] && echo nz || echo z)" "nz"
|
|
@@ -109,15 +118,15 @@ ENVV=""; sync --write --role Docs >/dev/null 2>&1; rc=$?
|
|
|
109
118
|
t "--write refuses a filtered document" "$rc" "2"
|
|
110
119
|
t "the refusal leaves the cache byte-identical" "$(sum "$CACHE")" "$before"
|
|
111
120
|
|
|
112
|
-
# ── (3) --cached: zero
|
|
121
|
+
# ── (3) --cached: zero forge calls inside the TTL, one refresh past it ─────────────────────────────
|
|
113
122
|
rm -f "$CALLS"
|
|
114
123
|
ENVV=""; out="$(sync --cached 600 2>/dev/null)"
|
|
115
|
-
t "--cached inside the TTL makes zero
|
|
124
|
+
t "--cached inside the TTL makes zero forge calls" "$(calls)" "0"
|
|
116
125
|
t "--cached serves the cache bytes" "$(printf '%s\n' "$out" | cksum)" "$before"
|
|
117
126
|
# Age the cache past the TTL by rewriting its timestamp (no sleep).
|
|
118
127
|
jq '.generatedEpoch = 1000' "$CACHE" > "$CACHE.aged" && mv "$CACHE.aged" "$CACHE"
|
|
119
128
|
out="$(sync --cached 600 2>/dev/null)"
|
|
120
|
-
t "--cached past the TTL refreshes (
|
|
129
|
+
t "--cached past the TTL refreshes (the forge is called)" "$([ "$(calls)" -gt 0 ] && echo yes || echo no)" "yes"
|
|
121
130
|
t "the refresh rewrote the cache" "$([ "$(jq -r '.generatedEpoch' "$CACHE")" -gt 1000 ] && echo yes || echo no)" "yes"
|
|
122
131
|
t "the refresh prints the fresh document" "$(printf '%s' "$out" | jq -r '.open')" "3"
|
|
123
132
|
n1="$(calls)"; sync --cached 600 >/dev/null 2>&1
|
|
@@ -144,9 +153,43 @@ has "--plan lists the effort" "$pout" "demo effort"
|
|
|
144
153
|
has "--json --plan carries the plan text" "$(sync --json --plan 2>/dev/null | jq -r '.plan')" "kit effort plan"
|
|
145
154
|
t "--json without --plan has no plan key" "$(printf '%s' "$doc" | jq -r 'has("plan")')" "false"
|
|
146
155
|
|
|
156
|
+
# ── (7) the local board snapshot (E546.9): one greppable line per open issue ─────────────────────
|
|
157
|
+
cat > "$tmp/issues-efforts.json" <<'JSON'
|
|
158
|
+
[ {"number":546,"title":"[Effort] 546 · Traceable work","labels":[{"name":"effort"},{"name":"flow:core"}],"milestone":null,"assignees":[],"updated_at":"2026-11-24T00:00:00Z","body":""},
|
|
159
|
+
{"number":575,"title":"[E546.3] Local board snapshot","labels":[{"name":"kind:feat"}],"milestone":null,"assignees":[],"updated_at":"2026-11-24T00:00:00Z","body":""},
|
|
160
|
+
{"number":600,"title":"Fix the docs link","labels":[],"milestone":null,"assignees":[],"updated_at":"2026-11-24T00:00:00Z","body":""} ]
|
|
161
|
+
JSON
|
|
162
|
+
SNAP="$tmp/snap/board.md"; rm -f "$SNAP"
|
|
163
|
+
ENVV="GH_ISSUES=$tmp/issues-efforts.json CCKIT_BOARD_SNAPSHOT=$SNAP"; serr="$(sync --llm 2>&1 >/dev/null)"
|
|
164
|
+
t "the snapshot is written to CCKIT_BOARD_SNAPSHOT" "$([ -f "$SNAP" ] && echo yes || echo no)" "yes"
|
|
165
|
+
has "sync names the snapshot and how to read it" "$serr" "read with: rg <pattern> $SNAP"
|
|
166
|
+
t "the snapshot has one line per open issue" "$(grep -c '^#[0-9]' "$SNAP")" "3"
|
|
167
|
+
t "an effort line carries its token" "$(grep '^#546' "$SNAP" | cut -f2-5)" "$(printf 'open\teffort\tE546\teffort,flow:core')"
|
|
168
|
+
t "a sub line carries effort.step" "$(grep '^#575' "$SNAP" | cut -f3,4,6)" "$(printf 'sub\tE546.3\t[E546.3] Local board snapshot')"
|
|
169
|
+
t "a standalone line has no token" "$(grep '^#600' "$SNAP" | cut -f3-5)" "$(printf 'issue\t-\t-')"
|
|
170
|
+
t "rg on one number hits one line" "$(grep -c '#575' "$SNAP")" "1"
|
|
171
|
+
t "issues are grouped effort, sub, standalone" "$(grep -E '^(## |#[0-9])' "$SNAP" | cut -f1 | tr '\n' ' ')" "## Efforts #546 ## Sub-issues #575 ## Standalone #600 "
|
|
172
|
+
has "the header names the repo" "$(cat "$SNAP")" "# Board snapshot — octo/fixture"
|
|
173
|
+
has "the header names the command" "$(cat "$SNAP")" "made by: cckit status --board --llm"
|
|
174
|
+
has "the header says rg needs the path" "$(cat "$SNAP")" "gitignored"
|
|
175
|
+
t "the atomic write leaves no temp file" "$(find "$tmp/snap" -name 'board.md.*' | wc -l | tr -d ' ')" "0"
|
|
176
|
+
ENVV="GH_ISSUES=$tmp/issues-efforts.json"; sync >/dev/null 2>&1
|
|
177
|
+
t "the default snapshot lands in the repo's .cckit/" "$(grep -c '^#[0-9]' "$fix/.cckit/board.md" 2>/dev/null)" "3"
|
|
178
|
+
rm -f "$SNAP"
|
|
179
|
+
ENVV="GH_ISSUES=$tmp/issues-efforts.json CCKIT_BOARD_SNAPSHOT=$SNAP"; sync --no-snapshot >/dev/null 2>&1
|
|
180
|
+
t "--no-snapshot writes nothing" "$([ -e "$SNAP" ] && echo yes || echo no)" "no"
|
|
181
|
+
sync --raw-json >/dev/null 2>&1
|
|
182
|
+
t "--raw-json writes no snapshot" "$([ -e "$SNAP" ] && echo yes || echo no)" "no"
|
|
183
|
+
ENVV="CCKIT_FORGE=none CCKIT_BOARD_SNAPSHOT=$SNAP"; nerr="$(sync 2>&1 >/dev/null)"
|
|
184
|
+
t "no forge writes no snapshot" "$([ -e "$SNAP" ] && echo yes || echo no)" "no"
|
|
185
|
+
has "no forge says the snapshot was not written" "$nerr" "no forge — no board snapshot written"
|
|
186
|
+
ENVV="GH_FAIL=1 CCKIT_BOARD_SNAPSHOT=$SNAP"; sync >/dev/null 2>&1
|
|
187
|
+
t "a failed read writes no snapshot" "$([ -e "$SNAP" ] && echo yes || echo no)" "no"
|
|
188
|
+
ENVV=""
|
|
189
|
+
|
|
147
190
|
# ── unchanged surfaces ─────────────────────────────────────────────────────────────────────────
|
|
148
191
|
has "human board still renders" "$(sync 2>/dev/null)" "## Board — octo/fixture"
|
|
149
|
-
t "--raw-json still returns the
|
|
192
|
+
t "--raw-json still returns the issue objects" "$(sync --raw-json 2>/dev/null | jq -r '.[0].labels[0].name')" "role:tech-lead"
|
|
150
193
|
has "--llm is still TOON" "$(sync --llm 2>/dev/null)" '[3]{number,title,priority,labels,milestone,assignees,blocked}:'
|
|
151
194
|
ENVV=""; sync --bogus >/dev/null 2>&1; t "an unknown flag still exits 1" "$?" "1"
|
|
152
195
|
|
package/scripts/task-sync.sh
CHANGED
|
@@ -12,16 +12,28 @@
|
|
|
12
12
|
# --watch [SECS] refresh + write every SECS seconds (default 30); a failed refresh keeps the
|
|
13
13
|
# last good cache. KIT_SYNC_WATCH_MAX=<n> stops after n refreshes
|
|
14
14
|
# --plan inline `effort plan` (a "### Effort plan" section; `plan` in the document)
|
|
15
|
+
# The local snapshot (E546.9): every board read except --raw-json and a --cached hit also writes
|
|
16
|
+
# .cckit/board.md (kit_state_dir: the primary checkout's, shared by every worktree), one
|
|
17
|
+
# tab-separated line per open issue, for `rg`. Atomic (temp file + mv); never written from a failed
|
|
18
|
+
# read or without a forge. --no-snapshot skips it; CCKIT_BOARD_SNAPSHOT=<path> moves it.
|
|
15
19
|
# Every fetch emits op.start / op.done (op "sync") on the kit-events.jsonl bus.
|
|
16
20
|
# --json document: { schema, repo, generatedAt, generatedEpoch, open,
|
|
17
21
|
# roles:[{role, slug, issues:[{number,title,status,priority,milestone,blocked}]}],
|
|
18
22
|
# unassigned:[same rows — issues carrying none of the configured role: labels; [] under --role],
|
|
19
23
|
# blocked:[n], notOnBoard:[n]|null (null = no Projects v2 board), stale:{days, issues:[{number,days}]},
|
|
20
24
|
# mergeQueue:[{number,title,risk,size,state,blocked,draft,agent,conflict,approved}], plan? }
|
|
25
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
26
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
27
|
+
# shellcheck source=/dev/null
|
|
28
|
+
. "$(cd "$(dirname "$0")" && pwd)/lib/gh-rest.sh"
|
|
29
|
+
fi
|
|
30
|
+
|
|
21
31
|
set -euo pipefail
|
|
22
32
|
source "$(dirname "$0")/lib/kit-config.sh" && load_kit_config
|
|
23
33
|
# Pure board-view helpers (merge queue, stale flag, not-on-board flag, Project Status).
|
|
24
34
|
source "$(dirname "$0")/lib/board-view.sh"
|
|
35
|
+
# The shared .cckit/ state dir (kit_state_file) — the snapshot's home.
|
|
36
|
+
source "$(dirname "$0")/lib/kit-state.sh" 2>/dev/null || true
|
|
25
37
|
# The rendering seam (#82): the human board is markdown, routed through cckit_render — rich via glow
|
|
26
38
|
# in a TTY, verbatim markdown otherwise (renders natively in Claude Code, pipe-safe).
|
|
27
39
|
source "$(dirname "$0")/lib/ui.sh" 2>/dev/null || true
|
|
@@ -34,7 +46,8 @@ ROLE_FILTER=""; MS_FILTER=""
|
|
|
34
46
|
# OUT is what goes to stdout: human | json (TOON, the --llm form) | raw-json | doc (--json) | none.
|
|
35
47
|
OUT="${CCKIT_OUTPUT:-human}"; OUT_SET=0
|
|
36
48
|
case "$OUT" in json|raw-json) ;; *) OUT=human ;; esac
|
|
37
|
-
WRITE=0; PLAN=0; CACHED_TTL=""; WATCH_SECS=""
|
|
49
|
+
WRITE=0; PLAN=0; CACHED_TTL=""; WATCH_SECS=""; SNAPSHOT=1
|
|
50
|
+
SYNC_ARGS="$*"
|
|
38
51
|
_is_int() { case "${1:-}" in ''|*[!0-9]*) return 1 ;; *) return 0 ;; esac; }
|
|
39
52
|
while [[ $# -gt 0 ]]; do
|
|
40
53
|
case "$1" in
|
|
@@ -45,6 +58,7 @@ while [[ $# -gt 0 ]]; do
|
|
|
45
58
|
--json) OUT=doc; OUT_SET=1; shift ;;
|
|
46
59
|
--write) WRITE=1; shift ;;
|
|
47
60
|
--plan) PLAN=1; shift ;;
|
|
61
|
+
--no-snapshot) SNAPSHOT=0; shift ;;
|
|
48
62
|
--cached) CACHED_TTL=60; shift; if _is_int "${1:-}"; then CACHED_TTL="$1"; shift; fi ;;
|
|
49
63
|
--watch) WATCH_SECS=30; shift; if _is_int "${1:-}"; then WATCH_SECS="$1"; shift; fi ;;
|
|
50
64
|
*) echo "unknown flag: $1" >&2; exit 1 ;;
|
|
@@ -79,8 +93,11 @@ ISSUES="[]"; STATUS_MAP="{}"; PRS_JSON="[]"; PLAN_TEXT=""; DOC=""
|
|
|
79
93
|
# empty queue / "—" Status and still renders, as it always has.
|
|
80
94
|
sync_fetch() {
|
|
81
95
|
local mode="${1:-lenient}" raw
|
|
82
|
-
raw="$(
|
|
83
|
-
--
|
|
96
|
+
raw="$(forge_rest "repos/$KIT_REPO/issues" -X GET -f state=open -f per_page=100 --paginate \
|
|
97
|
+
--jq '[.[] | select(.pull_request | not) | {number, title, labels: [.labels[] | {name}],
|
|
98
|
+
milestone: (if .milestone then {title: .milestone.title} else null end),
|
|
99
|
+
assignees: [.assignees[]? | {login}], updatedAt: .updated_at, body: (.body // "")}]' \
|
|
100
|
+
| jq -s 'add // []')" || return 1
|
|
84
101
|
# Only the data path validates: --raw-json hands gh's bytes to its caller verbatim, and the
|
|
85
102
|
# caller (autopilot) owns the "invalid board data" diagnosis.
|
|
86
103
|
if [ "$mode" = strict ]; then
|
|
@@ -97,7 +114,7 @@ sync_fetch() {
|
|
|
97
114
|
if [ "${KIT_PROJECTS_V2:-false}" = "true" ] && [ -n "${KIT_PROJECT_NUMBER:-}" ] && [ -n "${KIT_OWNER:-}" ]; then
|
|
98
115
|
local root map
|
|
99
116
|
case "${KIT_PROJECT_OWNER_TYPE:-user}" in org|organization) root=organization ;; *) root=user ;; esac
|
|
100
|
-
map="$(
|
|
117
|
+
map="$(forge_rest graphql -f query="
|
|
101
118
|
query(\$login:String!,\$number:Int!){
|
|
102
119
|
$root(login:\$login){ projectV2(number:\$number){ items(first:200){ nodes{
|
|
103
120
|
content{ ... on Issue { number } ... on PullRequest { number } }
|
|
@@ -111,8 +128,10 @@ sync_fetch() {
|
|
|
111
128
|
fi
|
|
112
129
|
|
|
113
130
|
# Open PRs for the merge queue (fetched once; risk/size labels + draft/review state drive the order).
|
|
114
|
-
if raw="$(
|
|
115
|
-
--
|
|
131
|
+
if raw="$(forge_rest "repos/$KIT_REPO/pulls" -X GET -f state=open -f per_page=100 \
|
|
132
|
+
--jq '[.[] | {number, title, labels: [.labels[]? | {name}], isDraft: .draft, headRefName: .head.ref,
|
|
133
|
+
reviewDecision: null,
|
|
134
|
+
mergeable: (if .mergeable == true then "MERGEABLE" elif .mergeable == false then "CONFLICTING" else "UNKNOWN" end)}]' 2>/dev/null)" \
|
|
116
135
|
&& printf '%s' "$raw" | jq -e 'type == "array"' >/dev/null 2>&1; then
|
|
117
136
|
PRS_JSON="$raw"
|
|
118
137
|
elif [ "$mode" = strict ]; then
|
|
@@ -123,6 +142,74 @@ sync_fetch() {
|
|
|
123
142
|
return 0
|
|
124
143
|
}
|
|
125
144
|
|
|
145
|
+
# sync_snapshot_path — CCKIT_BOARD_SNAPSHOT, else <kit_state_dir>/board.md (one per repository).
|
|
146
|
+
sync_snapshot_path() {
|
|
147
|
+
if [ -n "${CCKIT_BOARD_SNAPSHOT:-}" ]; then printf '%s\n' "$CCKIT_BOARD_SNAPSHOT"; return 0; fi
|
|
148
|
+
if command -v kit_state_file >/dev/null 2>&1; then printf '%s\n' "$(kit_state_file board.md)"; return 0; fi
|
|
149
|
+
printf '%s/.cckit/board.md\n' "$PWD"
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
# sync_snapshot — write the fetched ISSUES to the snapshot, one tab-separated line per open issue:
|
|
153
|
+
# #N status kind token labels title
|
|
154
|
+
# status is the Projects v2 Status when the board is on and was read, else the issue state (open).
|
|
155
|
+
# kind/token follow the title prefix (scripts/lib/naming.sh: [E<n>], [E<n>.<s>], legacy
|
|
156
|
+
# [Effort] N · and [Effort N] M · ) or the `effort` label; a standalone issue is `issue` / `-`.
|
|
157
|
+
# Best-effort: a write that fails says so on stderr and never fails the sync.
|
|
158
|
+
sync_snapshot() {
|
|
159
|
+
[ "$SNAPSHOT" = 1 ] || return 0
|
|
160
|
+
local dest tmpf body
|
|
161
|
+
dest="$(sync_snapshot_path)" || return 0
|
|
162
|
+
body="$(printf '%s' "$ISSUES" | jq -r --argjson st "$STATUS_MAP" --arg repo "$KIT_REPO" \
|
|
163
|
+
--arg at "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg cmd "cckit status --board${SYNC_ARGS:+ $SYNC_ARGS}" \
|
|
164
|
+
--arg path "$dest" '
|
|
165
|
+
def tok: (.title // "") as $t
|
|
166
|
+
| if ($t | test("^\\[E[0-9]+\\.[0-9]+\\] ")) then ($t | capture("^\\[E(?<e>[0-9]+)\\.(?<s>[0-9]+)\\]") | "E\(.e).\(.s)")
|
|
167
|
+
elif ($t | test("^\\[E[0-9]+\\] ")) then ($t | capture("^\\[E(?<e>[0-9]+)\\]") | "E\(.e)")
|
|
168
|
+
elif ($t | test("^\\[Effort [0-9]+\\] [0-9]+ ·")) then ($t | capture("^\\[Effort (?<e>[0-9]+)\\] (?<s>[0-9]+) ·") | "E\(.e).\(.s)")
|
|
169
|
+
elif ($t | test("^\\[Effort\\] [0-9]+ ·")) then ($t | capture("^\\[Effort\\] (?<e>[0-9]+) ·") | "E\(.e)")
|
|
170
|
+
else null end;
|
|
171
|
+
def row: tok as $k
|
|
172
|
+
| (if ($k // "" | contains(".")) then "sub"
|
|
173
|
+
elif $k != null or any(.labels[]?; .name == "effort") then "effort"
|
|
174
|
+
else "issue" end) as $kind
|
|
175
|
+
| { n: .number, kind: $kind,
|
|
176
|
+
token: (if $kind == "issue" then "-" else ($k // "E\(.number)") end),
|
|
177
|
+
status: (($st[(.number | tostring)] // "open") | if . == "—" then "open" else . end),
|
|
178
|
+
labels: ([.labels[]?.name] | join(",") | if . == "" then "-" else . end),
|
|
179
|
+
title: ((.title // "") | gsub("[\t\r\n]"; " ")) };
|
|
180
|
+
def line: "#\(.n)\t\(.status)\t\(.kind)\t\(.token)\t\(.labels)\t\(.title)";
|
|
181
|
+
def section($name; $kind; $rows):
|
|
182
|
+
"", "## \($name)", ([$rows[] | select(.kind == $kind) | line] | if length == 0 then "(none)" else .[] end);
|
|
183
|
+
[.[] | row] | sort_by(.n) as $rows
|
|
184
|
+
| "# Board snapshot — \($repo)",
|
|
185
|
+
"generated-at: \($at)",
|
|
186
|
+
"made by: \($cmd)",
|
|
187
|
+
"read with: rg <pattern> \($path)",
|
|
188
|
+
" (.cckit/ is gitignored, so a bare `rg` skips this file: always give rg the path)",
|
|
189
|
+
"columns: #N<TAB>status<TAB>kind<TAB>effort-token<TAB>labels<TAB>title — open issues only",
|
|
190
|
+
section("Efforts"; "effort"; $rows),
|
|
191
|
+
section("Sub-issues"; "sub"; $rows),
|
|
192
|
+
section("Standalone"; "issue"; $rows)')" \
|
|
193
|
+
|| { echo "sync: could not build the board snapshot — $dest left as it was" >&2; return 0; }
|
|
194
|
+
mkdir -p "$(dirname "$dest")" 2>/dev/null || { echo "sync: cannot create $(dirname "$dest") — no board snapshot" >&2; return 0; }
|
|
195
|
+
tmpf="$dest.$$.tmp"
|
|
196
|
+
if printf '%s\n' "$body" > "$tmpf" 2>/dev/null && mv -f "$tmpf" "$dest" 2>/dev/null; then
|
|
197
|
+
echo "sync: board snapshot $dest (read with: rg <pattern> $dest)" >&2
|
|
198
|
+
else
|
|
199
|
+
rm -f "$tmpf"; echo "sync: could not write the board snapshot $dest" >&2
|
|
200
|
+
fi
|
|
201
|
+
return 0
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
# sync_snapshot_check_forge — without a forge there is no board to snapshot: say so once.
|
|
205
|
+
sync_snapshot_check_forge() {
|
|
206
|
+
[ "$SNAPSHOT" = 1 ] || return 0
|
|
207
|
+
[ "$OUT" = raw-json ] && return 0
|
|
208
|
+
command -v forge_available >/dev/null 2>&1 || return 0
|
|
209
|
+
forge_available && return 0
|
|
210
|
+
forge_note_none sync "no board snapshot written ($(sync_snapshot_path))"
|
|
211
|
+
}
|
|
212
|
+
|
|
126
213
|
# sync_plan — fill PLAN_TEXT with `effort plan` output. Non-zero when the plan cannot be produced.
|
|
127
214
|
sync_plan() {
|
|
128
215
|
local lib; lib="$(dirname "$0")/lib/effort-plan.sh"
|
|
@@ -194,7 +281,9 @@ sync_write() {
|
|
|
194
281
|
sync_refresh() {
|
|
195
282
|
local ok=1
|
|
196
283
|
emit_event op.start sync "{\"mode\":\"$OUT\",\"write\":$WRITE}"
|
|
284
|
+
sync_snapshot_check_forge
|
|
197
285
|
sync_fetch strict || ok=0
|
|
286
|
+
if [ "$ok" = 1 ]; then sync_snapshot; fi
|
|
198
287
|
if [ "$ok" = 1 ] && [ "$PLAN" = 1 ]; then sync_plan || ok=0; fi
|
|
199
288
|
if [ "$ok" = 1 ]; then sync_doc || ok=0; fi
|
|
200
289
|
if [ "$ok" = 1 ] && [ "$WRITE" = 1 ]; then sync_write || ok=0; fi
|
|
@@ -246,7 +335,9 @@ if [ "$OUT" = doc ] || [ "$WRITE" = 1 ]; then
|
|
|
246
335
|
[ "$OUT" = none ] && exit 0
|
|
247
336
|
else
|
|
248
337
|
emit_event op.start sync "{\"mode\":\"$OUT\",\"write\":0}"
|
|
338
|
+
sync_snapshot_check_forge
|
|
249
339
|
sync_fetch lenient || { emit_event op.done sync '{"ok":false}'; echo "sync: could not read the board" >&2; exit 1; }
|
|
340
|
+
[ "$OUT" = raw-json ] || sync_snapshot
|
|
250
341
|
emit_event op.done sync "{\"ok\":true,\"open\":$(printf '%s' "$ISSUES" | jq 'length' 2>/dev/null || echo 0)}"
|
|
251
342
|
fi
|
|
252
343
|
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# terms-check-test.sh — behavioral test of scripts/terms-check.sh. Builds a throwaway project under
|
|
4
|
+
# its own mktemp -d (no fixed port, no shared state) and checks that a well-formed term passes and
|
|
5
|
+
# that each field rule in ontology/README.md names the file and the field when broken.
|
|
6
|
+
# Run: bash scripts/terms-check-test.sh
|
|
7
|
+
set -u
|
|
8
|
+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
9
|
+
fail=0
|
|
10
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
11
|
+
has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> '$3' not in: $2"; fail=1 ;; esac; }
|
|
12
|
+
|
|
13
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
14
|
+
fx="$tmp/project"; mkdir -p "$fx/ontology/terms" "$fx/skills" "$fx/bin"; : > "$fx/skills/routing.yaml"
|
|
15
|
+
printf 'case "$cmd" in\n effort) ;;\nesac\n' > "$fx/bin/cckit"
|
|
16
|
+
check() { bash "$ROOT/scripts/terms-check.sh" --root "$fx" "$@" 2>&1; }
|
|
17
|
+
checkj() { bash "$ROOT/scripts/terms-check.sh" --root "$fx" --llm 2>/dev/null; }
|
|
18
|
+
term() { # term <Stem> <json>
|
|
19
|
+
printf '%s\n' "$2" > "$fx/ontology/terms/$1.json"
|
|
20
|
+
}
|
|
21
|
+
good='{"id":"Effort","label":["effort"],"definition":"One parent issue, one branch, one worktree, one PR.","is_not":["A task: a task is one issue with one PR."],"avoid":["epic"],"home":{"cli":"effort"},"status":"sapling"}'
|
|
22
|
+
|
|
23
|
+
# 1. one well-formed term passes and is counted
|
|
24
|
+
term Effort "$good"
|
|
25
|
+
out="$(check)"; rc=$?
|
|
26
|
+
t "well-formed term: exit 0" "$rc" "0"
|
|
27
|
+
has "counts line names 1 term" "$out" "1 terms"
|
|
28
|
+
out="$(checkj)"
|
|
29
|
+
t "--llm: one JSON object" "$(printf '%s' "$out" | jq -r '.terms, .ok' | tr '\n' ' ')" "1 true "
|
|
30
|
+
|
|
31
|
+
# 2. an empty folder is a defect
|
|
32
|
+
rm "$fx/ontology/terms/Effort.json"
|
|
33
|
+
out="$(check)"; rc=$?
|
|
34
|
+
t "no term file: exit 1" "$rc" "1"
|
|
35
|
+
has "no term file: named" "$out" "no term file"
|
|
36
|
+
|
|
37
|
+
# 3. each field rule, one broken file at a time; the defect line names the file and the field
|
|
38
|
+
broken() { # broken <label> <Stem> <json> <expected fragment>
|
|
39
|
+
rm -f "$fx"/ontology/terms/*.json; term "$2" "$3"
|
|
40
|
+
out="$(check)"; rc=$?
|
|
41
|
+
t "$1: exit 1" "$rc" "1"
|
|
42
|
+
has "$1: names the field" "$out" "ontology/terms/$2.json: $4"
|
|
43
|
+
}
|
|
44
|
+
broken "id not PascalCase" effort "$(printf '%s' "$good" | jq -c '.id="effort"')" "id: not PascalCase"
|
|
45
|
+
broken "id differs from file name" Task "$good" "id: does not equal the file name Task"
|
|
46
|
+
broken "label empty list" Effort "$(printf '%s' "$good" | jq -c '.label=[]')" "label:"
|
|
47
|
+
broken "definition short" Effort "$(printf '%s' "$good" | jq -c '.definition="short"')" "definition: under 20"
|
|
48
|
+
broken "is_not empty" Effort "$(printf '%s' "$good" | jq -c '.is_not=[]')" "is_not: needs at least one"
|
|
49
|
+
broken "avoid not a list" Effort "$(printf '%s' "$good" | jq -c '.avoid="epic"')" "avoid: a list"
|
|
50
|
+
broken "home unknown key" Effort "$(printf '%s' "$good" | jq -c '.home={"web":"x"}')" "home: an object with any of cli, skill, rule"
|
|
51
|
+
broken "status unknown" Effort "$(printf '%s' "$good" | jq -c '.status="sprout"')" "status: seed, sapling or tree"
|
|
52
|
+
broken "sapling with no home" Effort "$(printf '%s' "$good" | jq -c '.home={}')" "home: a sapling or a tree needs at least one"
|
|
53
|
+
broken "unknown field" Effort "$(printf '%s' "$good" | jq -c '.owner="core"')" "unknown field: owner"
|
|
54
|
+
broken "not JSON" Effort '{not json' "not a JSON object"
|
|
55
|
+
|
|
56
|
+
# 4. a seed may have an empty home
|
|
57
|
+
rm -f "$fx"/ontology/terms/*.json
|
|
58
|
+
term Advisor "$(printf '%s' "$good" | jq -c '.id="Advisor" | .label="advisor" | .home={} | .status="seed"')"
|
|
59
|
+
out="$(check)"; rc=$?
|
|
60
|
+
t "seed with empty home: exit 0" "$rc" "0"
|
|
61
|
+
|
|
62
|
+
# 5. a missing folder exits 2
|
|
63
|
+
out="$(bash "$ROOT/scripts/terms-check.sh" --root "$tmp" 2>&1)"; rc=$?
|
|
64
|
+
t "no ontology/terms/: exit 2" "$rc" "2"
|
|
65
|
+
|
|
66
|
+
# ── homes, routing, the AGENTS.md table ─────────────────────────────────────────────────────────
|
|
67
|
+
# A whole small project: a dispatcher with three verbs, two skills, one rule, two terms, a routing
|
|
68
|
+
# file and the AGENTS.md table that mirrors it. `fixture` rebuilds it clean before each mutation.
|
|
69
|
+
fixture() {
|
|
70
|
+
rm -rf "$fx"; mkdir -p "$fx/ontology/terms" "$fx/bin" "$fx/skills/kit-a" "$fx/skills/kit-b" "$fx/.claude/rules"
|
|
71
|
+
printf '#!/usr/bin/env bash\ncase "$cmd" in\n effort)\n case "$1" in\n new) ;;\n esac ;;\n start) ;;\n pr|close) ;;\nesac\n' > "$fx/bin/cckit"
|
|
72
|
+
printf -- '---\nname: kit-a\nterms: Effort, Task\ndescription: a\n---\n# a\n' > "$fx/skills/kit-a/SKILL.md"
|
|
73
|
+
printf -- '---\nname: kit-b\nterms: none\ndescription: b\n---\n# b\n' > "$fx/skills/kit-b/SKILL.md"
|
|
74
|
+
printf '# r\n' > "$fx/.claude/rules/r.md"
|
|
75
|
+
term Effort "$(printf '%s' "$good" | jq -c '.home={"cli":"effort plan","skill":"kit-a","rule":".claude/rules/r.md"}')"
|
|
76
|
+
term Advisor "$(printf '%s' "$good" | jq -c '.id="Advisor" | .label="advisor" | .home={"skill":"kit-zz"} | .status="seed"')"
|
|
77
|
+
term Task "$(printf '%s' "$good" | jq -c '.id="Task" | .label="task" | .home={"cli":"start"}')"
|
|
78
|
+
cat > "$fx/skills/routing.yaml" <<'YAML'
|
|
79
|
+
# comment
|
|
80
|
+
- task: "scope a goal"
|
|
81
|
+
skill: kit-a
|
|
82
|
+
term: Effort
|
|
83
|
+
|
|
84
|
+
- task: "do a second thing"
|
|
85
|
+
skill: kit-a
|
|
86
|
+
term: Task
|
|
87
|
+
- task: "set up"
|
|
88
|
+
skill: kit-b
|
|
89
|
+
term: none
|
|
90
|
+
YAML
|
|
91
|
+
cat > "$fx/AGENTS.md" <<'MD'
|
|
92
|
+
# agents
|
|
93
|
+
|
|
94
|
+
## Which skill does what
|
|
95
|
+
|
|
96
|
+
| What you want | Skill | Term |
|
|
97
|
+
| --- | --- | --- |
|
|
98
|
+
| scope a goal · do a second thing | `kit-a` | Effort, Task |
|
|
99
|
+
| set up | `kit-b` | none |
|
|
100
|
+
|
|
101
|
+
## Next
|
|
102
|
+
MD
|
|
103
|
+
}
|
|
104
|
+
counts() { printf '%s\n' "$1" | grep '^terms-check:' ; }
|
|
105
|
+
|
|
106
|
+
fixture
|
|
107
|
+
out="$(check)"; rc=$?
|
|
108
|
+
t "whole fixture: exit 0" "$rc" "0"
|
|
109
|
+
has "seed home is noted, not a defect" "$out" "seed Advisor: home skill kit-zz does not exist yet (allowed)"
|
|
110
|
+
t "counts line" "$(counts "$out")" "terms-check: 3 terms · 4/5 homes resolved · 2/2 skills routed · 0 unrouted · 1 with no term · 0 defects"
|
|
111
|
+
t "--llm counts" "$(checkj | jq -c 'del(.ok)' 2>/dev/null)" '{"terms":3,"homes":5,"homes_resolved":4,"skills":2,"skills_routed":2,"unrouted":0,"skills_no_term":1,"defects":0}'
|
|
112
|
+
|
|
113
|
+
# homes
|
|
114
|
+
fixture; term Effort "$(printf '%s' "$good" | jq -c '.home={"cli":"nope"}')"
|
|
115
|
+
out="$(check)"; t "unknown verb home: exit 1" "$?" "1"; has "unknown verb named" "$out" "Effort.json: home cli nope does not exist"
|
|
116
|
+
fixture; term Effort "$(printf '%s' "$good" | jq -c '.home={"skill":"kit-zz"}')"
|
|
117
|
+
out="$(check)"; t "missing skill home: exit 1" "$?" "1"; has "missing skill named" "$out" "home skill kit-zz does not exist"
|
|
118
|
+
fixture; term Effort "$(printf '%s' "$good" | jq -c '.home={"rule":".claude/rules/none.md"}')"
|
|
119
|
+
out="$(check)"; t "missing rule home: exit 1" "$?" "1"; has "missing rule named" "$out" "home rule .claude/rules/none.md does not exist"
|
|
120
|
+
|
|
121
|
+
# routing
|
|
122
|
+
fixture; mkdir -p "$fx/skills/kit-c"; printf -- '---\nname: kit-c\nterms: none\ndescription: c\n---\n' > "$fx/skills/kit-c/SKILL.md"
|
|
123
|
+
out="$(check)"; t "unrouted skill: exit 1" "$?" "1"; has "unrouted skill named" "$out" "skills/kit-c: not routed"
|
|
124
|
+
has "unrouted counted" "$(counts "$out")" "2/3 skills routed · 1 unrouted"
|
|
125
|
+
fixture; printf -- '- task: "x"\n skill: kit-zz\n term: none\n' >> "$fx/skills/routing.yaml"
|
|
126
|
+
out="$(check)"; t "entry with unknown skill: exit 1" "$?" "1"; has "unknown skill named" "$out" "skill kit-zz has no SKILL.md"
|
|
127
|
+
fixture; printf -- '- task: "x"\n skill: kit-b\n term: Nope\n' >> "$fx/skills/routing.yaml"
|
|
128
|
+
out="$(check)"; t "entry with unknown term: exit 1" "$?" "1"; has "unknown term named" "$out" "term Nope is not under ontology/terms/"
|
|
129
|
+
fixture; printf -- '- task: "x"\n skill: kit-b\n terms: [a, b]\n' >> "$fx/skills/routing.yaml"
|
|
130
|
+
out="$(check)"; t "line outside the subset: exit 1" "$?" "1"; has "line number and expectation" "$out" 'skills/routing.yaml:14: expected ` term: <Term>` or ` term: none`'
|
|
131
|
+
fixture; printf -- '- task: "x"\n skill: kit-b\n' >> "$fx/skills/routing.yaml"
|
|
132
|
+
out="$(check)"; t "entry cut short: exit 1" "$?" "1"; has "cut short named" "$out" "entry ends before its term line"
|
|
133
|
+
fixture; printf -- '---\nname: kit-a\nterms: Task\ndescription: a\n---\n' > "$fx/skills/kit-a/SKILL.md"
|
|
134
|
+
out="$(check)"; t "terms: drift: exit 1" "$?" "1"; has "drift names both" "$out" "skills/kit-a/SKILL.md: terms: 'Task' but skills/routing.yaml says 'Effort, Task'"
|
|
135
|
+
fixture; rm "$fx/skills/routing.yaml"
|
|
136
|
+
out="$(check)"; t "no routing file: exit 1" "$?" "1"; has "no routing named" "$out" "skills/routing.yaml: missing"
|
|
137
|
+
|
|
138
|
+
# AGENTS.md
|
|
139
|
+
fixture; sed -i.bak '/kit-b/d' "$fx/AGENTS.md"
|
|
140
|
+
out="$(check)"; t "AGENTS.md row missing: exit 1" "$?" "1"; has "missing row named" "$out" "AGENTS.md: no row for kit-b"
|
|
141
|
+
fixture; sed -i.bak 's/| Effort, Task |/| Effort |/' "$fx/AGENTS.md"
|
|
142
|
+
out="$(check)"; t "AGENTS.md terms differ: exit 1" "$?" "1"; has "terms drift named" "$out" "AGENTS.md: kit-a terms differ"
|
|
143
|
+
fixture; sed -i.bak 's/scope a goal · do a second thing/scope a goal/' "$fx/AGENTS.md"
|
|
144
|
+
out="$(check)"; t "AGENTS.md tasks differ: exit 1" "$?" "1"; has "tasks drift named" "$out" "AGENTS.md: kit-a tasks differ"
|
|
145
|
+
fixture; printf '| extra | `kit-zz` | none |\n' > "$tmp/row"; sed -i.bak '/kit-b/r '"$tmp/row" "$fx/AGENTS.md"
|
|
146
|
+
out="$(check)"; t "AGENTS.md extra row: exit 1" "$?" "1"; has "extra row named" "$out" "AGENTS.md: row for kit-zz, which skills/routing.yaml does not route"
|
|
147
|
+
fixture; rm "$fx/AGENTS.md"
|
|
148
|
+
out="$(check)"; t "no AGENTS.md: not a defect" "$?" "0"
|
|
149
|
+
|
|
150
|
+
# the skills page
|
|
151
|
+
page() { mkdir -p "$fx/docs-site/src/content/docs"; cat > "$fx/docs-site/src/content/docs/skills.mdx"; }
|
|
152
|
+
good_page() { page <<'MDX'
|
|
153
|
+
---
|
|
154
|
+
title: Skills
|
|
155
|
+
---
|
|
156
|
+
## Effort
|
|
157
|
+
|
|
158
|
+
| Skill | Activates | What it does |
|
|
159
|
+
| ----- | --------- | ------------ |
|
|
160
|
+
| `kit-a` | <Tag kind="skill" /> | a |
|
|
161
|
+
|
|
162
|
+
## The kit itself
|
|
163
|
+
|
|
164
|
+
| Skill | Activates | What it does |
|
|
165
|
+
| ----- | --------- | ------------ |
|
|
166
|
+
| `kit-b` | <Tag kind="skill" /> | b |
|
|
167
|
+
|
|
168
|
+
## Skills a profile scaffolds
|
|
169
|
+
|
|
170
|
+
| Skill | Profiles | What it does |
|
|
171
|
+
| ----- | -------- | ------------ |
|
|
172
|
+
| `concrete` | all | not one of skills/ |
|
|
173
|
+
MDX
|
|
174
|
+
}
|
|
175
|
+
fixture; good_page
|
|
176
|
+
out="$(check)"; t "page grouped by term: exit 0" "$?" "0"
|
|
177
|
+
fixture; good_page; sed -i.bak '/kit-b/d' "$fx/docs-site/src/content/docs/skills.mdx"
|
|
178
|
+
out="$(check)"; t "page row missing: exit 1" "$?" "1"; has "missing page row named" "$out" "skills.mdx: no row for kit-b"
|
|
179
|
+
fixture; good_page; sed -i.bak 's/^## Effort$/## Task/' "$fx/docs-site/src/content/docs/skills.mdx"
|
|
180
|
+
out="$(check)"; t "page row under its other term: exit 0" "$?" "0"
|
|
181
|
+
fixture; good_page; sed -i.bak 's/^## Effort$/## Gate/' "$fx/docs-site/src/content/docs/skills.mdx"
|
|
182
|
+
out="$(check)"; t "page row under a wrong heading: exit 1" "$?" "1"; has "wrong heading named" "$out" 'skills.mdx: kit-a is under "Gate", not under a heading of its terms'
|
|
183
|
+
fixture; good_page; printf '| `kit-zz` | <Tag kind="skill" /> | zz |\n' > "$tmp/prow"; mkdir -p "$fx/skills/kit-zz"; : > "$fx/skills/kit-zz/SKILL.md"
|
|
184
|
+
sed -i.bak '/kit-b/r '"$tmp/prow" "$fx/docs-site/src/content/docs/skills.mdx"; printf -- '- task: "zz"\n skill: kit-zz\n term: none\n' >> "$fx/skills/routing.yaml"
|
|
185
|
+
printf '| zz | `kit-zz` | none |\n' > "$tmp/arow"; sed -i.bak '/kit-b/r '"$tmp/arow" "$fx/AGENTS.md"; printf -- '---\nname: kit-zz\nterms: none\n---\n' > "$fx/skills/kit-zz/SKILL.md"
|
|
186
|
+
out="$(check)"; t "page: a routed skill added everywhere: exit 0" "$?" "0"
|
|
187
|
+
fixture; good_page; printf '| `kit-zz` | <Tag kind="skill" /> | zz |\n' > "$tmp/prow"; mkdir -p "$fx/skills/kit-zz"; printf -- '---\nname: kit-zz\nterms: none\n---\n' > "$fx/skills/kit-zz/SKILL.md"
|
|
188
|
+
sed -i.bak '/kit-b/r '"$tmp/prow" "$fx/docs-site/src/content/docs/skills.mdx"
|
|
189
|
+
out="$(check)"; t "page row for an unrouted skill: exit 1" "$?" "1"; has "unrouted page row named" "$out" "skills.mdx: row for kit-zz, which skills/routing.yaml does not route"
|
|
190
|
+
|
|
191
|
+
[ "$fail" -eq 0 ] && echo "terms-check-test: all ok" || { echo "terms-check-test: FAILED"; exit 1; }
|