@jeiemgi/cckit 0.1.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +21 -8
- package/README.md +63 -5
- package/bin/cckit +77 -12
- package/cckit.config.json +1 -1
- package/commands/kit-doctor.md +3 -1
- package/kit.config.schema.json +24 -0
- package/package.json +1 -1
- package/scripts/annotate-setup.sh +7 -2
- package/scripts/capture-project-ids.sh +23 -10
- package/scripts/copilot-loop-test.sh +162 -0
- package/scripts/init.sh +22 -4
- package/scripts/kit-doctor.sh +185 -7
- package/scripts/kit-version-check-test.sh +36 -0
- package/scripts/kit-version-check.sh +19 -4
- package/scripts/knowledge-lint.sh +4 -1
- package/scripts/lib/board-view-test.sh +54 -0
- package/scripts/lib/board-view.sh +80 -0
- package/scripts/lib/captain-test.sh +76 -0
- package/scripts/lib/captain.sh +268 -0
- package/scripts/lib/config-path-test.sh +47 -0
- package/scripts/lib/config-path.sh +29 -0
- package/scripts/lib/copilot-test.sh +30 -0
- package/scripts/lib/copilot.sh +101 -0
- package/scripts/lib/effort-metrics-test.sh +57 -0
- package/scripts/lib/effort-metrics.sh +19 -5
- package/scripts/lib/effort-ops-test.sh +51 -2
- package/scripts/lib/effort-ops.sh +314 -49
- package/scripts/lib/effort-parity-test.sh +128 -0
- package/scripts/lib/effort-slug-test.sh +87 -0
- package/scripts/lib/effort-slug.sh +104 -0
- package/scripts/lib/effort.sh +34 -0
- package/scripts/lib/gh-project-test.sh +95 -0
- package/scripts/lib/gh-project.sh +22 -7
- package/scripts/lib/git-remote-test.sh +57 -0
- package/scripts/lib/git-remote.sh +21 -0
- package/scripts/lib/kit-config-test.sh +37 -0
- package/scripts/lib/kit-config.sh +33 -13
- package/scripts/lib/kit-events.sh +5 -3
- package/scripts/lib/kit-gc-test.sh +88 -0
- package/scripts/lib/kit-gc.sh +136 -19
- package/scripts/lib/kit-local.sh +8 -1
- package/scripts/lib/next.sh +75 -0
- package/scripts/lib/plan-machine-test.sh +72 -0
- package/scripts/lib/plan-machine.sh +260 -0
- package/scripts/lib/plan-next-test.sh +87 -0
- package/scripts/lib/plan-next.sh +212 -0
- package/scripts/lib/project-scan.sh +7 -1
- package/scripts/lib/render-test.sh +40 -0
- package/scripts/lib/render.sh +57 -0
- package/scripts/lib/worktree-start.sh +12 -3
- package/scripts/lib/zsh-safety-test.sh +73 -0
- package/scripts/portable-test.sh +62 -20
- package/scripts/setup-labels.sh +13 -2
- package/scripts/showcase.sh +13 -4
- package/scripts/status-test.sh +63 -0
- package/scripts/status.sh +12 -4
- package/scripts/task-sync.sh +79 -10
- package/skills/kit-autopilot/SKILL.md +5 -0
- package/skills/kit-docs-writer/SKILL.md +135 -0
- package/skills/kit-effort-new/SKILL.md +39 -111
- package/skills/kit-effort-pr/SKILL.md +6 -2
- package/skills/kit-next/SKILL.md +58 -0
- package/skills/kit-plan-next/SKILL.md +82 -0
- package/templates/hooks/mempal_session_start.sh.tmpl +36 -2
- package/templates/rules/effort-model.md +26 -6
- package/templates/rules/mempalace.md +1 -0
- package/templates/rules/plan-next.md +58 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# plan-machine.sh — the wave plan: turn the board into a deps-ordered, file-disjoint, session-fit
|
|
3
|
+
# execution plan the copilot fans out over (Effort 75 · #76).
|
|
4
|
+
#
|
|
5
|
+
# `cckit plan` reads the open board (or one effort's sub-issues), resolves the native GitHub
|
|
6
|
+
# `blocked_by` edges, and layers the issues into WAVES: wave 0 is everything unblocked, wave N is
|
|
7
|
+
# everything whose blockers all landed in earlier waves. Every issue in a wave is independent of the
|
|
8
|
+
# others in that wave, so a wave is exactly "what N agents can run in parallel right now". Within a
|
|
9
|
+
# wave we pack issues into BATCHES under a session ctx budget, starting a new batch when the budget
|
|
10
|
+
# would overflow or two issues declare overlapping files (so parallel subagents don't collide).
|
|
11
|
+
#
|
|
12
|
+
# cckit plan human wave plan for the open board
|
|
13
|
+
# cckit plan --llm TOON wave plan (uniform rows: wave,batch,number,ctx,blockers,title)
|
|
14
|
+
# cckit plan --effort <N> plan only effort #N's sub-issues
|
|
15
|
+
# cckit plan --milestone <M> filter to milestone M
|
|
16
|
+
# cckit plan --cap <N> session ctx budget per batch (default KIT_SESSION_BUDGET or 4)
|
|
17
|
+
#
|
|
18
|
+
# ctx weights: S=1 · M=2 · L=4 · XL=8. File hints: a "Files:"/"Touches:" line in the issue body
|
|
19
|
+
# (comma/space-separated paths) drives intra-wave disjointness; absent → ctx budget alone batches.
|
|
20
|
+
#
|
|
21
|
+
# Requires: gh, jq. bash 3.2 (no associative arrays — parallel indexed arrays + linear scan; N small).
|
|
22
|
+
|
|
23
|
+
PLAN_REPO="${PLAN_REPO:-${KIT_REPO:-}}"
|
|
24
|
+
|
|
25
|
+
_pm_weight() { case "$1" in S) echo 1 ;; M) echo 2 ;; L) echo 4 ;; XL) echo 8 ;; *) echo 2 ;; esac; }
|
|
26
|
+
|
|
27
|
+
# pm_waves — pure layered topo-sort. stdin: lines "num<TAB>csvBlockers"; stdout: "num<TAB>wave".
|
|
28
|
+
# Only blockers present in the input set constrain layering (out-of-set/closed blockers are the
|
|
29
|
+
# caller's concern). Cycle-safe: any leftover after no-progress lands in a final wave.
|
|
30
|
+
pm_waves() {
|
|
31
|
+
# dual-shell arrays: ksh_arrays gives zsh 0-based indexing + bash-style subscripting.
|
|
32
|
+
[ -n "${ZSH_VERSION:-}" ] && setopt local_options ksh_arrays sh_word_split 2>/dev/null
|
|
33
|
+
local -a N=() B=() W=()
|
|
34
|
+
local num blk
|
|
35
|
+
while IFS="$(printf '\t')" read -r num blk; do
|
|
36
|
+
[ -n "$num" ] || continue
|
|
37
|
+
N[${#N[@]}]="$num"; B[${#B[@]}]="$blk"; W[${#W[@]}]="-1"
|
|
38
|
+
done
|
|
39
|
+
local n="${#N[@]}" w=0 remaining="${#N[@]}" progress=1 i j b bl ok
|
|
40
|
+
[ "$remaining" -gt 0 ] || return 0
|
|
41
|
+
while [ "$remaining" -gt 0 ] && [ "$progress" -eq 1 ]; do
|
|
42
|
+
progress=0
|
|
43
|
+
local -a ready=()
|
|
44
|
+
i=0
|
|
45
|
+
while [ "$i" -lt "$n" ]; do
|
|
46
|
+
if [ "${W[$i]}" = "-1" ]; then
|
|
47
|
+
ok=1; bl="${B[$i]}"
|
|
48
|
+
for b in ${bl//,/ }; do
|
|
49
|
+
j=0
|
|
50
|
+
while [ "$j" -lt "$n" ]; do
|
|
51
|
+
if [ "${N[$j]}" = "$b" ] && [ "${W[$j]}" = "-1" ]; then ok=0; fi
|
|
52
|
+
j=$((j + 1))
|
|
53
|
+
done
|
|
54
|
+
done
|
|
55
|
+
[ "$ok" = "1" ] && ready[${#ready[@]}]="$i"
|
|
56
|
+
fi
|
|
57
|
+
i=$((i + 1))
|
|
58
|
+
done
|
|
59
|
+
if [ "${#ready[@]}" -gt 0 ]; then
|
|
60
|
+
for i in "${ready[@]}"; do W[$i]="$w"; done
|
|
61
|
+
remaining=$((remaining - ${#ready[@]})); w=$((w + 1)); progress=1
|
|
62
|
+
fi
|
|
63
|
+
done
|
|
64
|
+
i=0
|
|
65
|
+
while [ "$i" -lt "$n" ]; do [ "${W[$i]}" = "-1" ] && W[$i]="$w"; i=$((i + 1)); done
|
|
66
|
+
i=0
|
|
67
|
+
while [ "$i" -lt "$n" ]; do printf '%s\t%s\n' "${N[$i]}" "${W[$i]}"; i=$((i + 1)); done
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# pm_batches — pure session-fit + file-disjoint packer for ONE wave (already deps-independent).
|
|
71
|
+
# stdin: lines "num<TAB>ctx<TAB>spaceSepFiles"; stdout: "num<TAB>batch". Budget = $1 (default 4).
|
|
72
|
+
# New batch when load+weight would overflow the budget OR the issue's files intersect the batch.
|
|
73
|
+
pm_batches() {
|
|
74
|
+
[ -n "${ZSH_VERSION:-}" ] && setopt local_options ksh_arrays sh_word_split 2>/dev/null
|
|
75
|
+
local budget="${1:-4}"
|
|
76
|
+
local -a N=() C=() F=()
|
|
77
|
+
local num ctx files
|
|
78
|
+
while IFS="$(printf '\t')" read -r num ctx files; do
|
|
79
|
+
[ -n "$num" ] || continue
|
|
80
|
+
N[${#N[@]}]="$num"; C[${#C[@]}]="$ctx"; F[${#F[@]}]="$files"
|
|
81
|
+
done
|
|
82
|
+
local n="${#N[@]}" batch=0 load=0 batchfiles=" " i w f ff need
|
|
83
|
+
i=0
|
|
84
|
+
while [ "$i" -lt "$n" ]; do
|
|
85
|
+
w="$(_pm_weight "${C[$i]}")"
|
|
86
|
+
need=0
|
|
87
|
+
[ $((load + w)) -gt "$budget" ] && need=1
|
|
88
|
+
ff="${F[$i]}"
|
|
89
|
+
for f in $ff; do
|
|
90
|
+
case "$batchfiles" in *" $f "*) need=1 ;; esac
|
|
91
|
+
done
|
|
92
|
+
if [ "$need" = "1" ] && [ "$load" -gt 0 ]; then
|
|
93
|
+
batch=$((batch + 1)); load=0; batchfiles=" "
|
|
94
|
+
fi
|
|
95
|
+
load=$((load + w))
|
|
96
|
+
for f in $ff; do batchfiles="$batchfiles$f "; done
|
|
97
|
+
printf '%s\t%s\n' "${N[$i]}" "$batch"
|
|
98
|
+
i=$((i + 1))
|
|
99
|
+
done
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# _pm_files — pull a "Files:" / "Touches:" hint line from an issue body; emit space-separated paths.
|
|
103
|
+
_pm_files() {
|
|
104
|
+
printf '%s' "$1" | grep -ioE '^[[:space:]]*(Files|Touches):[[:space:]]*.*' 2>/dev/null \
|
|
105
|
+
| head -1 | sed -E 's/^[[:space:]]*(Files|Touches):[[:space:]]*//I; s/[,]+/ /g' \
|
|
106
|
+
| tr -s ' ' | sed 's/^ //; s/ $//'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
plan_machine() {
|
|
110
|
+
command -v gh >/dev/null 2>&1 && command -v jq >/dev/null 2>&1 || { echo "plan: needs gh + jq" >&2; return 1; }
|
|
111
|
+
# output mode: the dispatcher strips --llm and exports CCKIT_OUTPUT=json, so honor that env first;
|
|
112
|
+
# --llm/--output=json are kept for direct lib calls / tests.
|
|
113
|
+
local repo="$PLAN_REPO" budget="${KIT_SESSION_BUDGET:-4}" out="${CCKIT_OUTPUT:-human}" effort="" ms=""
|
|
114
|
+
while [ "$#" -gt 0 ]; do
|
|
115
|
+
case "$1" in
|
|
116
|
+
--llm|--output=json) out="json"; shift ;;
|
|
117
|
+
--effort) effort="$2"; shift 2 ;;
|
|
118
|
+
--effort=*) effort="${1#*=}"; shift ;;
|
|
119
|
+
--milestone) ms="$2"; shift 2 ;;
|
|
120
|
+
--milestone=*) ms="${1#*=}"; shift ;;
|
|
121
|
+
--cap) budget="$2"; shift 2 ;;
|
|
122
|
+
--cap=*) budget="${1#*=}"; shift ;;
|
|
123
|
+
-h|--help) sed -n '14,21p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; return 0 ;;
|
|
124
|
+
*) echo "plan: unknown arg '$1'" >&2; return 2 ;;
|
|
125
|
+
esac
|
|
126
|
+
done
|
|
127
|
+
[ -n "$repo" ] || { echo "plan: no repo (set KIT_REPO / PLAN_REPO)" >&2; return 1; }
|
|
128
|
+
case "$budget" in ''|*[!0-9]*) echo "plan: --cap needs a number (got '$budget')" >&2; return 2 ;; esac
|
|
129
|
+
|
|
130
|
+
# 1. the issue set: an effort's sub-issues, or the open board.
|
|
131
|
+
local raw
|
|
132
|
+
if [ -n "$effort" ]; then
|
|
133
|
+
raw="$(gh api "repos/$repo/issues/$effort/sub_issues" --paginate \
|
|
134
|
+
--jq '.[] | select(.state=="open") | [(.number|tostring), .title, .body] | @tsv' 2>/dev/null)" \
|
|
135
|
+
|| { echo "plan: failed to read sub-issues of #$effort" >&2; return 1; }
|
|
136
|
+
else
|
|
137
|
+
local mjq='.[]'
|
|
138
|
+
[ -n "$ms" ] && mjq=".[] | select((.milestone.title // \"\") == \"$ms\")"
|
|
139
|
+
raw="$(gh issue list --repo "$repo" --state open --limit 200 --json number,title,body,milestone \
|
|
140
|
+
--jq "$mjq | [(.number|tostring), .title, .body] | @tsv" 2>/dev/null)" \
|
|
141
|
+
|| { echo "plan: gh query failed (check gh auth)" >&2; return 1; }
|
|
142
|
+
fi
|
|
143
|
+
[ -n "$raw" ] || { [ "$out" = "json" ] && echo "[]" || echo "plan: no open issues to plan"; return 0; }
|
|
144
|
+
|
|
145
|
+
# 2. parallel arrays + per-issue ctx label, file hint, and OPEN blocked_by edges.
|
|
146
|
+
local -a nums=() titles=() ctxs=() files=() blkall=()
|
|
147
|
+
local n t b body lab
|
|
148
|
+
while IFS="$(printf '\t')" read -r n t body; do
|
|
149
|
+
[ -n "$n" ] || continue
|
|
150
|
+
nums+=("$n"); titles+=("$t")
|
|
151
|
+
lab="$(gh issue view "$n" --repo "$repo" --json labels \
|
|
152
|
+
--jq '[.labels[].name|select(startswith("ctx:"))|ltrimstr("ctx:")]|first // "M"' 2>/dev/null)"
|
|
153
|
+
ctxs+=("${lab:-M}")
|
|
154
|
+
files+=("$(_pm_files "$body")")
|
|
155
|
+
# only OPEN blockers gate execution; closed ones are already satisfied.
|
|
156
|
+
b="$(gh api "repos/$repo/issues/$n/dependencies/blocked_by" \
|
|
157
|
+
--jq '[.[]|select(.state=="open")|.number]|join(",")' 2>/dev/null)"
|
|
158
|
+
blkall+=("$b")
|
|
159
|
+
done <<EOF
|
|
160
|
+
$raw
|
|
161
|
+
EOF
|
|
162
|
+
|
|
163
|
+
# 3. split blockers into in-set (gate the wave layering) vs external-open (issue can't start yet).
|
|
164
|
+
local -a inset=() ext=()
|
|
165
|
+
local i j bb keepin keepext present
|
|
166
|
+
for i in "${!nums[@]}"; do
|
|
167
|
+
keepin=""; keepext=""
|
|
168
|
+
for bb in ${blkall[$i]//,/ }; do
|
|
169
|
+
present=0
|
|
170
|
+
for j in "${!nums[@]}"; do [ "${nums[$j]}" = "$bb" ] && present=1; done
|
|
171
|
+
if [ "$present" = "1" ]; then keepin="$keepin,$bb"; else keepext="$keepext,$bb"; fi
|
|
172
|
+
done
|
|
173
|
+
inset+=("${keepin#,}"); ext+=("${keepext#,}")
|
|
174
|
+
done
|
|
175
|
+
|
|
176
|
+
# 4. layer into waves (in-set deps only).
|
|
177
|
+
local wavetsv waves
|
|
178
|
+
wavetsv="$(for i in "${!nums[@]}"; do printf '%s\t%s\n' "${nums[$i]}" "${inset[$i]}"; done | pm_waves)"
|
|
179
|
+
# map number -> wave (linear; N small)
|
|
180
|
+
_wave_of() { printf '%s' "$wavetsv" | awk -F'\t' -v k="$1" '$1==k{print $2; exit}'; }
|
|
181
|
+
waves="$(printf '%s' "$wavetsv" | awk -F'\t' '{print $2}' | sort -n | uniq)"
|
|
182
|
+
|
|
183
|
+
# 5. within each wave, pack into batches (ctx budget + file overlap), then emit.
|
|
184
|
+
emit_rows() { # writes "wave<TAB>batch<TAB>number<TAB>ctx<TAB>blockers<TAB>title"
|
|
185
|
+
local wv batchtsv num bt
|
|
186
|
+
for wv in $waves; do
|
|
187
|
+
# gather this wave's issues as "num<TAB>ctx<TAB>files" in array order
|
|
188
|
+
batchtsv="$(for i in "${!nums[@]}"; do
|
|
189
|
+
[ "$(_wave_of "${nums[$i]}")" = "$wv" ] || continue
|
|
190
|
+
printf '%s\t%s\t%s\n' "${nums[$i]}" "${ctxs[$i]}" "${files[$i]}"
|
|
191
|
+
done | pm_batches "$budget")"
|
|
192
|
+
while IFS="$(printf '\t')" read -r num bt; do
|
|
193
|
+
[ -n "$num" ] || continue
|
|
194
|
+
for i in "${!nums[@]}"; do
|
|
195
|
+
if [ "${nums[$i]}" = "$num" ]; then
|
|
196
|
+
printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$wv" "$bt" "$num" "${ctxs[$i]}" "${inset[$i]}" "${titles[$i]}"
|
|
197
|
+
fi
|
|
198
|
+
done
|
|
199
|
+
done <<EOF2
|
|
200
|
+
$batchtsv
|
|
201
|
+
EOF2
|
|
202
|
+
done
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
local here; here="$(dirname "${BASH_SOURCE[0]}")"
|
|
206
|
+
|
|
207
|
+
# raw rows (wave<TAB>batch<TAB>number<TAB>ctx<TAB>blockers<TAB>title) — the copilot driver (#78)
|
|
208
|
+
# consumes this; not a public output mode.
|
|
209
|
+
if [ "$out" = "tsv" ]; then emit_rows; return 0; fi
|
|
210
|
+
|
|
211
|
+
if [ "$out" = "json" ]; then
|
|
212
|
+
# TOON-encode a uniform row array (wave,batch,number,ctx,blockers,title) for the copilot.
|
|
213
|
+
local json
|
|
214
|
+
json="$(emit_rows | jq -R -s '
|
|
215
|
+
[ split("\n")[] | select(length>0) | split("\t")
|
|
216
|
+
| {wave:(.[0]|tonumber), batch:(.[1]|tonumber), number:(.[2]|tonumber),
|
|
217
|
+
ctx:.[3], blockers:.[4], title:.[5]} ]')"
|
|
218
|
+
# route through the TOON encoder (uniform array -> tabular; falls back to JSON under the gate).
|
|
219
|
+
# shellcheck source=/dev/null
|
|
220
|
+
. "$here/toon.sh"
|
|
221
|
+
printf '%s' "$json" | toon_encode
|
|
222
|
+
return 0
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# human render: emit MARKDOWN (a table per wave) and route it through the rendering seam (#82) —
|
|
226
|
+
# rich via glow in a TTY, verbatim markdown otherwise (renders natively in Claude Code, pipe-safe).
|
|
227
|
+
# awk -F'\t' is used so the empty blockers field never collapses the columns.
|
|
228
|
+
# shellcheck source=/dev/null
|
|
229
|
+
. "$here/render.sh"
|
|
230
|
+
{
|
|
231
|
+
printf '# cckit plan — %s\n\n' "$repo"
|
|
232
|
+
printf '_session budget %s · ctx S=1 M=2 L=4 XL=8 · each wave runs in parallel_\n' "$budget"
|
|
233
|
+
emit_rows | awk -F'\t' '
|
|
234
|
+
BEGIN { lw="" }
|
|
235
|
+
{
|
|
236
|
+
wv=$1; bt=$2; num=$3; ctx=$4; blk=$5; title=$6
|
|
237
|
+
if (wv != lw) {
|
|
238
|
+
printf "\n## Wave %s\n\n", wv
|
|
239
|
+
print "| # | ctx | batch | issue | after |"
|
|
240
|
+
print "|---|-----|-------|-------|-------|"
|
|
241
|
+
lw=wv
|
|
242
|
+
}
|
|
243
|
+
sub(/^\[Effort( [0-9]+)?\] [0-9]+ · ?/, "", title)
|
|
244
|
+
sub(/^\[[A-Za-z]+\] /, "", title)
|
|
245
|
+
dep="—"
|
|
246
|
+
if (blk != "") { gsub(/,/, ", #", blk); dep="#" blk }
|
|
247
|
+
printf "| #%s | %s | %s | %s | %s |\n", num, ctx, bt, title, dep
|
|
248
|
+
}'
|
|
249
|
+
# externally-blocked issues never enter a wave — surface them so they aren't silently dropped.
|
|
250
|
+
local anyext=0
|
|
251
|
+
for i in "${!nums[@]}"; do [ -n "${ext[$i]}" ] && anyext=1; done
|
|
252
|
+
if [ "$anyext" = "1" ]; then
|
|
253
|
+
printf '\n## Blocked (open blockers outside this set — not scheduled)\n\n'
|
|
254
|
+
for i in "${!nums[@]}"; do
|
|
255
|
+
[ -n "${ext[$i]}" ] && printf -- '- #%s waits on #%s\n' "${nums[$i]}" "${ext[$i]//,/, #}"
|
|
256
|
+
done
|
|
257
|
+
fi
|
|
258
|
+
printf '\n'
|
|
259
|
+
} | cckit_render
|
|
260
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# plan-next-test.sh — self-test for plan-next.sh (Effort 86 · #91).
|
|
3
|
+
# Network-free, filesystem-only: builds a throwaway fixture project and asserts the inventory
|
|
4
|
+
# scanners, the proposal shape (TOON + JSON + human), empty states, the structured error, and the
|
|
5
|
+
# invariant that EVERY plan carries the mandatory docs + README step. The pure scanners + proposals
|
|
6
|
+
# run under bash AND zsh; the full plan_next verb (which sources render/toon via BASH_SOURCE) runs
|
|
7
|
+
# under bash, matching how the dispatcher invokes it. Run: bash scripts/lib/plan-next-test.sh
|
|
8
|
+
|
|
9
|
+
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
|
10
|
+
|
|
11
|
+
# _pn_fixture <root> — a small capability tree. docs mention alpha-skill + the 'foo' verb but NOT
|
|
12
|
+
# beta-skill or 'bar', so those two become the coverage-gap proposals.
|
|
13
|
+
_pn_fixture() {
|
|
14
|
+
local r="$1"
|
|
15
|
+
mkdir -p "$r/skills/alpha-skill" "$r/skills/beta-skill" "$r/rules" "$r/docs" "$r/commands"
|
|
16
|
+
: > "$r/skills/alpha-skill/SKILL.md"; : > "$r/skills/beta-skill/SKILL.md"
|
|
17
|
+
: > "$r/rules/r1.md"; : > "$r/rules/r2.md"
|
|
18
|
+
: > "$r/commands/foo.md"; : > "$r/commands/bar.md"
|
|
19
|
+
printf 'see the alpha-skill skill and the foo verb.\n' > "$r/docs/intro.md"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if [ -n "${PN_TEST_INNER:-}" ]; then
|
|
23
|
+
. "$dir/plan-next.sh"
|
|
24
|
+
fail=0
|
|
25
|
+
eq() { if [ "$2" != "$3" ]; then echo "FAIL($PN_TEST_INNER): $1 -> '[$2]', want '[$3]'"; fail=1; fi; }
|
|
26
|
+
has() { case "$2" in *"$3"*) ;; *) echo "FAIL($PN_TEST_INNER): $1 missing '[$3]'"; fail=1 ;; esac; }
|
|
27
|
+
no() { case "$2" in *"$3"*) echo "FAIL($PN_TEST_INNER): $1 should NOT contain '[$3]'"; fail=1 ;; esac; }
|
|
28
|
+
|
|
29
|
+
fix="$(mktemp -d)"; _pn_fixture "$fix"
|
|
30
|
+
empty="$(mktemp -d)"
|
|
31
|
+
|
|
32
|
+
# --- pure scanners (bash + zsh) ---
|
|
33
|
+
eq "skills scanner" "$(plan_next_skills "$fix" | tr '\n' ',')" "alpha-skill,beta-skill,"
|
|
34
|
+
eq "verbs scanner (commands fallback)" "$(plan_next_verbs "$fix" | tr '\n' ',')" "bar,foo,"
|
|
35
|
+
eq "rules scanner" "$(plan_next_rules "$fix" | tr '\n' ',')" "r1,r2,"
|
|
36
|
+
eq "docs scanner" "$(plan_next_docs "$fix" | tr '\n' ',')" "intro,"
|
|
37
|
+
eq "empty skills -> nothing" "$(plan_next_skills "$empty")" ""
|
|
38
|
+
|
|
39
|
+
# --- proposals shape (bash + zsh) ---
|
|
40
|
+
props="$(_pn_proposals "$fix")"
|
|
41
|
+
first="$(printf '%s\n' "$props" | head -1)"
|
|
42
|
+
has "rank 1 is docs" "$first" "1 docs"
|
|
43
|
+
has "mandatory docs+README" "$first" "README"
|
|
44
|
+
has "undocumented skill gap" "$props" "beta-skill"
|
|
45
|
+
has "undocumented verb gap" "$props" "bar"
|
|
46
|
+
no "documented skill not flagged as gap" "$props" "Document the alpha-skill"
|
|
47
|
+
# EVERY plan carries the docs + README step — also on a bare project.
|
|
48
|
+
has "empty plan still has docs+README" "$(_pn_proposals "$empty")" "README"
|
|
49
|
+
|
|
50
|
+
# --- full verb (bash only — sources render/toon via BASH_SOURCE) ---
|
|
51
|
+
if [ "$PN_TEST_INNER" = "bash" ]; then
|
|
52
|
+
hum="$(PLAN_NEXT_ROOT="$fix" CCKIT_NO_GLOW=1 CCKIT_OUTPUT=human plan_next)"
|
|
53
|
+
has "human shows capabilities" "$hum" "Current capabilities"
|
|
54
|
+
has "human shows docs+README" "$hum" "README"
|
|
55
|
+
has "human states context rule" "$hum" "context-anxiety"
|
|
56
|
+
|
|
57
|
+
# empty/host project: graceful, exits 0, still carries the docs step.
|
|
58
|
+
eout="$(PLAN_NEXT_ROOT="$empty" CCKIT_NO_GLOW=1 CCKIT_OUTPUT=human plan_next)"; erc=$?
|
|
59
|
+
eq "empty exits 0" "$erc" "0"
|
|
60
|
+
has "empty has graceful banner" "$eout" "No kit capabilities found"
|
|
61
|
+
has "empty still has docs+README" "$eout" "README"
|
|
62
|
+
|
|
63
|
+
if command -v jq >/dev/null 2>&1; then
|
|
64
|
+
llm="$(PLAN_NEXT_ROOT="$fix" CCKIT_OUTPUT=json plan_next --llm)"
|
|
65
|
+
has "TOON header" "$llm" "{rank,area,proposal,next}"
|
|
66
|
+
has "TOON has docs row" "$llm" "README"
|
|
67
|
+
has "TOON has next col" "$llm" "/kit-effort-new"
|
|
68
|
+
# structured error on a bad arg.
|
|
69
|
+
err="$(PLAN_NEXT_ROOT="$fix" CCKIT_OUTPUT=json plan_next --llm --bogus)"; brc=$?
|
|
70
|
+
eq "bad arg rc=2" "$brc" "2"
|
|
71
|
+
has "structured error" "$err" '"error"'
|
|
72
|
+
else
|
|
73
|
+
echo " (jq absent — skipping TOON/JSON assertions)"
|
|
74
|
+
fi
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
rm -rf "$fix" "$empty"
|
|
78
|
+
if [ "$fail" -eq 0 ]; then echo "PASS($PN_TEST_INNER): plan-next inventory + plan shapes"; fi
|
|
79
|
+
exit "$fail"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
rc=0
|
|
83
|
+
for sh in bash zsh; do
|
|
84
|
+
command -v "$sh" >/dev/null 2>&1 || continue
|
|
85
|
+
PN_TEST_INNER="$sh" "$sh" "$0" || rc=1
|
|
86
|
+
done
|
|
87
|
+
exit "$rc"
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# plan-next.sh — the forward planner (Effort 86 · #87/#88). cckit's "given where we are, here is what
|
|
3
|
+
# to build next" triage, productized. It introspects the CURRENT capability surface — skills,
|
|
4
|
+
# commands/verbs, rules, docs — at runtime and proposes concrete next efforts grounded in what the
|
|
5
|
+
# kit can already do. Run against cckit itself (full inventory) or any project the kit is installed
|
|
6
|
+
# in (degrades to whatever capability dirs exist, never crashes).
|
|
7
|
+
#
|
|
8
|
+
# cckit plan-next current capabilities + a proposed forward plan (markdown)
|
|
9
|
+
# cckit plan-next --llm the proposed plan as TOON rows {rank,area,proposal,next} (JSON fallback)
|
|
10
|
+
# cckit plan-next --root <dir> scan <dir> instead of the resolved project/kit root
|
|
11
|
+
#
|
|
12
|
+
# CRITICAL — context-anxiety rule: this output is HUMAN / orchestrator-facing ONLY. It is NEVER to
|
|
13
|
+
# be injected into a monitored model's prompt or context. The planner pre-grounds planning in the
|
|
14
|
+
# current docs/skills/rules so the EXECUTING agent burns fewer tokens rediscovering context — it is
|
|
15
|
+
# not itself agent-context fuel. The verb and the skill both honor this; see rules/plan-next.md.
|
|
16
|
+
#
|
|
17
|
+
# Filesystem-only — needs jq only for --llm (TOON/JSON). bash 3.2 / zsh compatible.
|
|
18
|
+
|
|
19
|
+
# _pn_first_dir <dir> [dir …] — echo the first directory that exists (graceful host-project fallback).
|
|
20
|
+
_pn_first_dir() {
|
|
21
|
+
local d
|
|
22
|
+
for d in "$@"; do [ -n "$d" ] && [ -d "$d" ] && { printf '%s' "$d"; return 0; }; done
|
|
23
|
+
return 1
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# plan_next_skills_dir / _rules_dir / _docs_dir <root> — resolve the capability dir for one area,
|
|
27
|
+
# trying cckit's own layout first, then the installed-in-a-project layout. Empty when none exist.
|
|
28
|
+
plan_next_skills_dir() { _pn_first_dir "$1/skills" "$1/.claude/skills" 2>/dev/null; }
|
|
29
|
+
plan_next_rules_dir() { _pn_first_dir "$1/rules" "$1/templates/rules" "$1/.claude/rules" 2>/dev/null; }
|
|
30
|
+
plan_next_docs_dir() { _pn_first_dir "$1/docs-site/src/content/docs" "$1/docs" "$1/.claude/docs" 2>/dev/null; }
|
|
31
|
+
|
|
32
|
+
# All scanners use `find` (not shell globs): an unmatched glob errors under zsh's nomatch and stays
|
|
33
|
+
# literal under bash — `find` handles "no matches" cleanly in both, so the lib is shell-portable.
|
|
34
|
+
|
|
35
|
+
# plan_next_skills <root> — one skill name per line (the SKILL.md parent dir basename), sorted.
|
|
36
|
+
plan_next_skills() {
|
|
37
|
+
local dir; dir="$(plan_next_skills_dir "$1")" || return 0
|
|
38
|
+
find "$dir" -mindepth 2 -maxdepth 2 -name SKILL.md -type f 2>/dev/null \
|
|
39
|
+
| while IFS= read -r f; do basename "$(dirname "$f")"; done | sort -u
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# plan_next_rules <root> — one rule name per line (the .md basename without extension), sorted.
|
|
43
|
+
plan_next_rules() {
|
|
44
|
+
local dir; dir="$(plan_next_rules_dir "$1")" || return 0
|
|
45
|
+
find "$dir" -maxdepth 1 -name '*.md' -type f 2>/dev/null \
|
|
46
|
+
| while IFS= read -r f; do b="$(basename "$f")"; printf '%s\n' "${b%.md}"; done | sort -u
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# plan_next_verbs <root> — one verb per line. Prefer the cckit dispatcher's own case labels (the
|
|
50
|
+
# single source of truth, same parse as `cckit commands`); fall back to a commands/ listing when run
|
|
51
|
+
# in a host project that has no bin/cckit.
|
|
52
|
+
plan_next_verbs() {
|
|
53
|
+
local root="$1"
|
|
54
|
+
if [ -f "$root/bin/cckit" ]; then
|
|
55
|
+
grep -oE '^ [a-z][a-z|-]*\)' "$root/bin/cckit" \
|
|
56
|
+
| sed 's/[) ]//g' | tr '|' '\n' | grep -vE '^(-|$)' | sort -u
|
|
57
|
+
return 0
|
|
58
|
+
fi
|
|
59
|
+
local dir; dir="$(_pn_first_dir "$root/commands" "$root/.claude/commands" 2>/dev/null)" || return 0
|
|
60
|
+
find "$dir" -maxdepth 1 -name '*.md' -type f 2>/dev/null \
|
|
61
|
+
| while IFS= read -r f; do b="$(basename "$f")"; printf '%s\n' "${b%.md}"; done | sort -u
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# plan_next_docs <root> — one doc name per line (the .md/.mdx basename without extension), sorted.
|
|
65
|
+
plan_next_docs() {
|
|
66
|
+
local dir; dir="$(plan_next_docs_dir "$1")" || return 0
|
|
67
|
+
find "$dir" -maxdepth 1 \( -name '*.md' -o -name '*.mdx' \) -type f 2>/dev/null \
|
|
68
|
+
| while IFS= read -r f; do b="$(basename "$f")"; b="${b%.mdx}"; printf '%s\n' "${b%.md}"; done | sort -u
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# _pn_docs_blob <root> — all doc text concatenated + lowercased, for coverage-gap detection.
|
|
72
|
+
_pn_docs_blob() {
|
|
73
|
+
local dir; dir="$(plan_next_docs_dir "$1")" || return 0
|
|
74
|
+
find "$dir" -maxdepth 1 \( -name '*.md' -o -name '*.mdx' \) -type f -exec cat {} + 2>/dev/null \
|
|
75
|
+
| tr '[:upper:]' '[:lower:]'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# _pn_root — the directory to scan. PLAN_NEXT_ROOT wins (tests / explicit), else the project root
|
|
79
|
+
# inferred from KIT_CONFIG (parent of a .claude/ config), else $PWD. In cckit this is the cckit repo;
|
|
80
|
+
# in a host project it is that project — so the inventory is always "this project's capabilities".
|
|
81
|
+
_pn_root() {
|
|
82
|
+
if [ -n "${PLAN_NEXT_ROOT:-}" ]; then printf '%s' "$PLAN_NEXT_ROOT"; return 0; fi
|
|
83
|
+
local cfg="${KIT_CONFIG:-}" d
|
|
84
|
+
if [ -n "$cfg" ] && [ -f "$cfg" ]; then
|
|
85
|
+
d="$(cd "$(dirname "$cfg")" 2>/dev/null && pwd)" || d=""
|
|
86
|
+
case "$d" in */.claude) d="$(dirname "$d")" ;; esac
|
|
87
|
+
[ -n "$d" ] && { printf '%s' "$d"; return 0; }
|
|
88
|
+
fi
|
|
89
|
+
printf '%s' "$PWD"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# _pn_proposals <root> — the forward plan as TSV rows: rank<TAB>area<TAB>proposal<TAB>next.
|
|
93
|
+
# Deterministic + grounded in the inventory. ALWAYS emits the mandatory docs + README item first
|
|
94
|
+
# (docs-always rule — never dropped, even for a tiny change). Then up to 3 concrete coverage gaps
|
|
95
|
+
# (skills/verbs not referenced anywhere in the docs), then a thinnest-area suggestion so there is
|
|
96
|
+
# always >=1 concrete next effort beyond docs. Capped so the plan stays scannable.
|
|
97
|
+
_pn_proposals() {
|
|
98
|
+
local root="$1" rank=1
|
|
99
|
+
local handoff="/kit-effort-new"
|
|
100
|
+
|
|
101
|
+
# 1. MANDATORY — docs + README. Non-negotiable, always present (asserted by tests).
|
|
102
|
+
printf '%s\tdocs\t%s\t%s\n' "$rank" \
|
|
103
|
+
"Update the docs site + README + AGENTS for the latest work (mandatory, never skipped)" "$handoff"
|
|
104
|
+
rank=$((rank + 1))
|
|
105
|
+
|
|
106
|
+
# 2. Coverage gaps — capabilities not yet mentioned anywhere in the docs (grounded in current state).
|
|
107
|
+
local blob s v added=0
|
|
108
|
+
blob="$(_pn_docs_blob "$root")"
|
|
109
|
+
for s in $(plan_next_skills "$root"); do
|
|
110
|
+
[ "$added" -ge 3 ] && break
|
|
111
|
+
case "$blob" in *"$s"*) ;; *)
|
|
112
|
+
printf '%s\tskills\t%s\t%s\n' "$rank" "Document the $s skill — it is not referenced in any doc page" "$handoff"
|
|
113
|
+
rank=$((rank + 1)); added=$((added + 1)) ;;
|
|
114
|
+
esac
|
|
115
|
+
done
|
|
116
|
+
for v in $(plan_next_verbs "$root"); do
|
|
117
|
+
[ "$added" -ge 3 ] && break
|
|
118
|
+
case "$blob" in *"$v"*) ;; *)
|
|
119
|
+
printf '%s\tcommands\t%s\t%s\n' "$rank" "Add the '$v' verb to the CLI reference — it ships but is undocumented" "$handoff"
|
|
120
|
+
rank=$((rank + 1)); added=$((added + 1)) ;;
|
|
121
|
+
esac
|
|
122
|
+
done
|
|
123
|
+
|
|
124
|
+
# 3. Thinnest-area suggestion — guarantees a concrete non-docs proposal even when coverage is clean.
|
|
125
|
+
local cs cv cr thin tn
|
|
126
|
+
cs="$(plan_next_skills "$root" | grep -c .)"
|
|
127
|
+
cv="$(plan_next_verbs "$root" | grep -c .)"
|
|
128
|
+
cr="$(plan_next_rules "$root" | grep -c .)"
|
|
129
|
+
thin="skills"; tn="$cs"
|
|
130
|
+
[ "$cv" -lt "$tn" ] && { thin="commands"; tn="$cv"; }
|
|
131
|
+
[ "$cr" -lt "$tn" ] && { thin="rules"; tn="$cr"; }
|
|
132
|
+
printf '%s\t%s\t%s\t%s\n' "$rank" "$thin" \
|
|
133
|
+
"Deepen the thinnest area '$thin' ($tn entries) — propose one new capability there" "$handoff"
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# plan_next — the verb body. Human markdown by default; TOON/JSON under --llm. Never injects into
|
|
137
|
+
# any agent context (context-anxiety rule).
|
|
138
|
+
plan_next() {
|
|
139
|
+
local out="${CCKIT_OUTPUT:-human}" root=""
|
|
140
|
+
while [ "$#" -gt 0 ]; do
|
|
141
|
+
case "$1" in
|
|
142
|
+
--llm|--output=json) out="json"; shift ;;
|
|
143
|
+
--root) root="$2"; shift 2 ;;
|
|
144
|
+
--root=*) root="${1#*=}"; shift ;;
|
|
145
|
+
-h|--help) sed -n '8,11p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; return 0 ;;
|
|
146
|
+
*) if [ "$out" = "json" ]; then _pn_err "unknown arg '$1'"; else echo "plan-next: unknown arg '$1'" >&2; fi; return 2 ;;
|
|
147
|
+
esac
|
|
148
|
+
done
|
|
149
|
+
[ -n "$root" ] && PLAN_NEXT_ROOT="$root"
|
|
150
|
+
root="$(_pn_root)"
|
|
151
|
+
|
|
152
|
+
# --llm needs jq for valid TOON/JSON — emit a structured error rather than malformed output.
|
|
153
|
+
if [ "$out" = "json" ] && ! command -v jq >/dev/null 2>&1; then
|
|
154
|
+
printf '{"error":"plan-next: jq is required for --llm output"}\n'; return 1
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
local skills verbs rules docs cs cv cr cd total
|
|
158
|
+
skills="$(plan_next_skills "$root")"; cs="$(printf '%s' "$skills" | grep -c .)"
|
|
159
|
+
verbs="$(plan_next_verbs "$root")"; cv="$(printf '%s' "$verbs" | grep -c .)"
|
|
160
|
+
rules="$(plan_next_rules "$root")"; cr="$(printf '%s' "$rules" | grep -c .)"
|
|
161
|
+
docs="$(plan_next_docs "$root")"; cd="$(printf '%s' "$docs" | grep -c .)"
|
|
162
|
+
total=$((cs + cv + cr + cd))
|
|
163
|
+
|
|
164
|
+
local proposals; proposals="$(_pn_proposals "$root")"
|
|
165
|
+
|
|
166
|
+
if [ "$out" = "json" ]; then
|
|
167
|
+
# TOON rows {rank,area,proposal,next}. Always >=1 row (the mandatory docs item), so the plan is
|
|
168
|
+
# never empty; the explicit empty state is the capability inventory being bare (total==0), which
|
|
169
|
+
# the human view surfaces and the rule documents. The 'next' field carries the next-step handoff.
|
|
170
|
+
local here json; here="$(dirname "${BASH_SOURCE[0]}")"
|
|
171
|
+
json="$(printf '%s\n' "$proposals" \
|
|
172
|
+
| jq -R -s '[ split("\n")[] | select(length>0) | split("\t")
|
|
173
|
+
| {rank:(.[0]|tonumber), area:.[1], proposal:.[2], next:.[3]} ]')"
|
|
174
|
+
# shellcheck source=/dev/null
|
|
175
|
+
. "$here/toon.sh"
|
|
176
|
+
printf '%s' "$json" | toon_encode
|
|
177
|
+
return 0
|
|
178
|
+
fi
|
|
179
|
+
|
|
180
|
+
# human: current capabilities + the proposed plan, through the rendering seam (#82). Leads with
|
|
181
|
+
# human-meaningful names; no `--llm` decoration in the prose (house presentation rule).
|
|
182
|
+
local here; here="$(dirname "${BASH_SOURCE[0]}")"
|
|
183
|
+
# shellcheck source=/dev/null
|
|
184
|
+
. "$here/render.sh" 2>/dev/null || true
|
|
185
|
+
local name; name="$(basename "$root")"
|
|
186
|
+
_pn_human() {
|
|
187
|
+
printf '# Plan next — %s\n\n' "$name"
|
|
188
|
+
if [ "$total" -eq 0 ]; then
|
|
189
|
+
printf '> No kit capabilities found here — this looks like a host project with no skills, verbs,\n'
|
|
190
|
+
printf '> rules, or docs yet. The plan below still carries the mandatory docs + README step; run\n'
|
|
191
|
+
printf '> from the cckit repo (or scaffold with `cckit init`) for a full forward plan.\n\n'
|
|
192
|
+
fi
|
|
193
|
+
printf '## Current capabilities\n\n'
|
|
194
|
+
printf '| area | count | sample |\n| --- | --- | --- |\n'
|
|
195
|
+
printf '| skills | %s | %s |\n' "$cs" "$(printf '%s' "$skills" | head -3 | tr '\n' ' ' | sed 's/ $//')"
|
|
196
|
+
printf '| commands | %s | %s |\n' "$cv" "$(printf '%s' "$verbs" | head -3 | tr '\n' ' ' | sed 's/ $//')"
|
|
197
|
+
printf '| rules | %s | %s |\n' "$cr" "$(printf '%s' "$rules" | head -3 | tr '\n' ' ' | sed 's/ $//')"
|
|
198
|
+
printf '| docs | %s | %s |\n' "$cd" "$(printf '%s' "$docs" | head -3 | tr '\n' ' ' | sed 's/ $//')"
|
|
199
|
+
printf '\n## Proposed next — grounded in the above\n\n'
|
|
200
|
+
printf '| rank | area | proposal |\n| --- | --- | --- |\n'
|
|
201
|
+
printf '%s\n' "$proposals" | awk -F'\t' 'NF>=3 { printf "| %s | %s | %s |\n", $1, $2, $3 }'
|
|
202
|
+
printf '\n## Next step\n\n'
|
|
203
|
+
printf 'Pick an item and scope it into an effort with `/kit-plan-next` (conversational), or directly:\n\n'
|
|
204
|
+
printf '```\n/kit-effort-new\n```\n\n'
|
|
205
|
+
printf '> This plan is human / orchestrator-facing only — never paste it into a monitored agent'\''s\n'
|
|
206
|
+
printf '> context (context-anxiety rule). See rules/plan-next.md.\n'
|
|
207
|
+
}
|
|
208
|
+
if command -v cckit_render >/dev/null 2>&1; then _pn_human | cckit_render; else _pn_human; fi
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
# _pn_err — structured error for --llm mode (mirrors the other verbs' failure shape).
|
|
212
|
+
_pn_err() { printf '{"error":"plan-next: %s"}\n' "$1"; }
|
|
@@ -3,12 +3,18 @@
|
|
|
3
3
|
# filesystem only (no baked-in project knowledge). Usage: source it && project_scan [dir]
|
|
4
4
|
project_scan() {
|
|
5
5
|
local dir="${1:-$PWD}" root stack=() kit="none"
|
|
6
|
+
# ONE shared config discovery (config-path.sh, #69), sourced from this file's own dir when needed.
|
|
7
|
+
if ! command -v kit_config_find >/dev/null 2>&1; then
|
|
8
|
+
local _psd; _psd="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
[ -f "$_psd/config-path.sh" ] && . "$_psd/config-path.sh"
|
|
11
|
+
fi
|
|
6
12
|
root="$(git -C "$dir" rev-parse --show-toplevel 2>/dev/null || printf '%s' "$dir")"
|
|
7
13
|
[ -f "$root/package.json" ] && stack+=("node")
|
|
8
14
|
[ -f "$root/pyproject.toml" ] && stack+=("python")
|
|
9
15
|
[ -f "$root/go.mod" ] && stack+=("go")
|
|
10
16
|
[ -f "$root/Cargo.toml" ] && stack+=("rust")
|
|
11
|
-
if
|
|
17
|
+
if kit_config_find "$root" >/dev/null 2>&1; then kit="configured"
|
|
12
18
|
elif [ -d "$root/.cckit" ]; then kit="partial"
|
|
13
19
|
elif [ -d "$root/.claude" ]; then kit="claude-only"; fi
|
|
14
20
|
printf '{"root":"%s","stack":[%s],"kit":"%s"}\n' \
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# render-test.sh — self-test for render.sh under bash AND zsh.
|
|
3
|
+
# Network-free, TTY-free: covers width clamping, the markdown table composers, and the pipe-safety
|
|
4
|
+
# guarantee (non-TTY in == verbatim out). Run: bash scripts/lib/render-test.sh
|
|
5
|
+
|
|
6
|
+
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
|
7
|
+
|
|
8
|
+
if [ -n "${RND_TEST_INNER:-}" ]; then
|
|
9
|
+
. "$dir/ui.sh"
|
|
10
|
+
. "$dir/render.sh"
|
|
11
|
+
fail=0
|
|
12
|
+
eq() { if [ "$2" != "$3" ]; then echo "FAIL($RND_TEST_INNER): $1 -> '[$2]', want '[$3]'"; fail=1; fi; }
|
|
13
|
+
|
|
14
|
+
# render_width — clamp to [40,120].
|
|
15
|
+
eq "width clamps high" "$(COLUMNS=999 render_width)" "120"
|
|
16
|
+
eq "width clamps low" "$(COLUMNS=5 render_width)" "40"
|
|
17
|
+
eq "width passes mid" "$(COLUMNS=90 render_width)" "90"
|
|
18
|
+
eq "width junk -> safe" "$( (COLUMNS=abc; unset TERM; render_width) | grep -qE '^[0-9]+$' && echo ok)" "ok"
|
|
19
|
+
|
|
20
|
+
# table composers.
|
|
21
|
+
eq "table row" "$(render_table_row '#76' 'M' 'plan')" "| #76 | M | plan |"
|
|
22
|
+
eq "table sep" "$(render_table_sep 3)" "| --- | --- | --- |"
|
|
23
|
+
eq "h1" "$(render_h1 'Title')" "# Title"
|
|
24
|
+
|
|
25
|
+
# pipe-safety: not a TTY here, so cckit_render must pass markdown through byte-for-byte.
|
|
26
|
+
md="$(printf '# H\n\n| a | b |\n')"
|
|
27
|
+
eq "render verbatim when piped" "$(printf '%s' "$md" | cckit_render)" "$md"
|
|
28
|
+
# explicit CCKIT_NO_GLOW also forces verbatim.
|
|
29
|
+
eq "render verbatim NO_GLOW" "$(printf '%s' "$md" | CCKIT_NO_GLOW=1 cckit_render)" "$md"
|
|
30
|
+
|
|
31
|
+
if [ "$fail" -eq 0 ]; then echo "PASS($RND_TEST_INNER): render seam"; fi
|
|
32
|
+
exit "$fail"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
rc=0
|
|
36
|
+
for sh in bash zsh; do
|
|
37
|
+
command -v "$sh" >/dev/null 2>&1 || continue
|
|
38
|
+
RND_TEST_INNER="$sh" "$sh" "$0" || rc=1
|
|
39
|
+
done
|
|
40
|
+
exit "$rc"
|