@jeiemgi/cckit 0.5.0 → 0.7.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 +34 -3
- package/README.md +95 -6
- package/bin/cckit +90 -3
- package/cckit.config.json +7 -2
- package/kit.config.schema.json +26 -1
- package/package.json +1 -1
- package/profiles/automation.json +2 -1
- package/profiles/content.json +2 -1
- package/profiles/minimal.json +2 -1
- package/profiles/research.json +2 -1
- package/profiles/software.json +2 -1
- package/scripts/benchmark/benchmark-test.sh +83 -0
- package/scripts/benchmark/gate.sh +55 -0
- package/scripts/benchmark/lib/bench-common.sh +70 -0
- package/scripts/benchmark/lib/model.sh +116 -0
- package/scripts/benchmark/report.sh +105 -0
- package/scripts/benchmark/run-quality.sh +102 -0
- package/scripts/benchmark/run.sh +166 -0
- package/scripts/benchmark/stop-check.sh +83 -0
- package/scripts/commitlint-test.sh +58 -0
- package/scripts/init.sh +57 -1
- package/scripts/kit-self-update.sh +55 -0
- package/scripts/lib/board-view-test.sh +1 -0
- package/scripts/lib/board-view.sh +1 -0
- package/scripts/lib/captain-test.sh +62 -0
- package/scripts/lib/captain.sh +105 -17
- package/scripts/lib/cckit-output.sh +1 -0
- package/scripts/lib/commitlint.sh +54 -0
- package/scripts/lib/config-path-test.sh +1 -0
- package/scripts/lib/config-path.sh +1 -0
- package/scripts/lib/copilot-test.sh +1 -0
- package/scripts/lib/copilot.sh +1 -0
- package/scripts/lib/effort-dispatch-test.sh +10 -0
- package/scripts/lib/effort-flows-test.sh +1 -0
- package/scripts/lib/effort-metrics-test.sh +1 -0
- package/scripts/lib/effort-metrics.sh +1 -0
- package/scripts/lib/effort-ops-test.sh +360 -0
- package/scripts/lib/effort-ops.sh +372 -16
- package/scripts/lib/effort-parity-test.sh +1 -0
- package/scripts/lib/effort-plan.sh +1 -0
- package/scripts/lib/effort-slug-test.sh +32 -0
- package/scripts/lib/effort-slug.sh +72 -8
- package/scripts/lib/effort.sh +1 -0
- package/scripts/lib/engine-adapter.sh +1 -0
- package/scripts/lib/errors-header-test.sh +86 -0
- package/scripts/lib/gh-log.sh +1 -0
- package/scripts/lib/gh-project-test.sh +1 -0
- package/scripts/lib/gh-project.sh +1 -0
- package/scripts/lib/git-remote-test.sh +1 -0
- package/scripts/lib/git-remote.sh +1 -0
- package/scripts/lib/handoff.sh +23 -2
- package/scripts/lib/kit-brief-test.sh +292 -0
- package/scripts/lib/kit-brief.sh +376 -0
- package/scripts/lib/kit-cli-test.sh +1 -0
- package/scripts/lib/kit-cli.sh +1 -0
- package/scripts/lib/kit-config-resolve.sh +1 -0
- package/scripts/lib/kit-config-test.sh +14 -0
- package/scripts/lib/kit-config.sh +7 -0
- package/scripts/lib/kit-engine-test.sh +1 -0
- package/scripts/lib/kit-events.sh +1 -0
- package/scripts/lib/kit-gc-test.sh +125 -0
- package/scripts/lib/kit-gc.sh +193 -5
- package/scripts/lib/kit-interview-test.sh +1 -0
- package/scripts/lib/kit-interview.sh +1 -0
- package/scripts/lib/kit-lib-test.sh +226 -0
- package/scripts/lib/kit-lib.sh +308 -0
- package/scripts/lib/kit-local.sh +1 -0
- package/scripts/lib/kit-manifest.sh +1 -0
- package/scripts/lib/kit-mode-test.sh +1 -0
- package/scripts/lib/kit-mode.sh +1 -0
- package/scripts/lib/kit-msg-test.sh +1 -0
- package/scripts/lib/kit-msg.sh +1 -0
- package/scripts/lib/kit-operate.sh +1 -0
- package/scripts/lib/kit-profile-test.sh +1 -0
- package/scripts/lib/kit-profile.sh +1 -0
- package/scripts/lib/kit-state-test.sh +89 -0
- package/scripts/lib/kit-state.sh +61 -0
- package/scripts/lib/kit-status-test.sh +233 -0
- package/scripts/lib/kit-status.sh +415 -0
- package/scripts/lib/kit-task-ops-test.sh +22 -0
- package/scripts/lib/kit-task-ops.sh +51 -2
- package/scripts/lib/next.sh +1 -0
- package/scripts/lib/plan-machine-test.sh +54 -0
- package/scripts/lib/plan-machine.sh +86 -25
- package/scripts/lib/plan-next-test.sh +1 -0
- package/scripts/lib/plan-next.sh +1 -0
- package/scripts/lib/pr-evidence-test.sh +259 -0
- package/scripts/lib/pr-evidence.sh +220 -35
- package/scripts/lib/project-scan.sh +1 -0
- package/scripts/lib/react-detect.sh +1 -0
- package/scripts/lib/render-test.sh +1 -0
- package/scripts/lib/render.sh +1 -0
- package/scripts/lib/role-identity.sh +1 -0
- package/scripts/lib/secret-guard.sh +21 -1
- package/scripts/lib/toon.sh +1 -0
- package/scripts/lib/ui.sh +1 -0
- package/scripts/lib/version-bump-test.sh +1 -0
- package/scripts/lib/version-bump.sh +1 -0
- package/scripts/lib/worktree-bootstrap-test.sh +220 -0
- package/scripts/lib/worktree-issue-test.sh +15 -1
- package/scripts/lib/worktree-issue.sh +23 -8
- package/scripts/lib/worktree-start.sh +191 -7
- package/scripts/lib/zsh-safety-test.sh +10 -0
- package/scripts/orchestrate.sh +8 -1
- package/scripts/portable-test.sh +13 -2
- package/scripts/self-install-test.sh +282 -0
- package/scripts/setup-labels.sh +1 -0
- package/scripts/status.sh +68 -40
- package/scripts/task-sync.sh +13 -0
- package/scripts/ux-a11y-scan.sh +96 -0
- package/scripts/ux-ds-audit.sh +146 -0
- package/scripts/ux-graph-scan.sh +188 -0
- package/skills/kit-autopilot/SKILL.md +6 -1
- package/skills/kit-cleanup/SKILL.md +83 -0
- package/skills/kit-effort-close/SKILL.md +3 -0
- package/skills/kit-effort-new/SKILL.md +7 -0
- package/skills/kit-effort-start/SKILL.md +39 -4
- package/skills/kit-gc/SKILL.md +19 -0
- package/skills/kit-next/SKILL.md +5 -0
- package/skills/kit-status/SKILL.md +92 -0
- package/skills/kit-task-start/SKILL.md +7 -1
- package/skills/kit-ux-audit/SKILL.md +241 -0
- package/skills/kit-ux-audit/references/a11y.md +79 -0
- package/skills/kit-ux-audit/references/consistency.md +106 -0
- package/skills/kit-ux-audit/references/graph-model.md +92 -0
- package/skills/kit-ux-audit/references/heuristics.md +157 -0
- package/skills/kit-ux-audit/references/report.md +172 -0
- package/templates/agents/ux.md +89 -0
- package/templates/benchmarks/SCHEMA.md +75 -0
- package/templates/benchmarks/abstain.jsonl +8 -0
- package/templates/benchmarks/adversarial.jsonl +8 -0
- package/templates/benchmarks/benchmark.config.json +14 -0
- package/templates/benchmarks/quality.jsonl +8 -0
- package/templates/benchmarks/retrieval.jsonl +7 -0
- package/templates/rules/branch-naming.md +20 -1
- package/templates/rules/communication-style.md +8 -0
- package/templates/rules/delegation-brief.md +38 -4
- package/templates/rules/effort-model.md +47 -4
- package/templates/rules/naming-and-ids.md +199 -0
- package/templates/rules/task-management.md +1 -1
- package/templates/settings/settings.json.tmpl +9 -0
- package/templates/skills/concrete/SKILL.md +117 -0
- package/templates/skills/karpathy-guidelines/SKILL.md +1 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# kit-lib.sh — the helper catalog (Effort 220 · #222). `cckit commands` lists the VERBS; nothing
|
|
3
|
+
# listed the LIBRARY those verbs are built from, so a helper like pr-evidence.sh — which exists
|
|
4
|
+
# precisely to attach gate evidence to a PR — was invisible unless you `ls scripts/lib/`, and an
|
|
5
|
+
# agent asked to post evidence wrote it from scratch. This verb makes the library discoverable.
|
|
6
|
+
#
|
|
7
|
+
# One row per helper in `scripts/lib`, all four facts a caller needs before sourcing it:
|
|
8
|
+
# file the basename to source
|
|
9
|
+
# errors its declared failure contract (`# errors:`, CONTRIBUTING) — propagates or swallows
|
|
10
|
+
# functions its PUBLIC functions (`_`-prefixed names are private by convention, so they are cut)
|
|
11
|
+
# purpose the file's own header sentence — derived, never invented
|
|
12
|
+
#
|
|
13
|
+
# cckit lib the helper catalog as a markdown table
|
|
14
|
+
# cckit lib --llm TOON rows {file,errors,functions,purpose} (JSON fallback)
|
|
15
|
+
# cckit lib --all include the *-test.sh runners (excluded by default)
|
|
16
|
+
# cckit lib --reasons every file's failure reason, not only the `mixed` ones
|
|
17
|
+
# cckit lib --root <dir> catalog <dir>'s library instead of the resolved one
|
|
18
|
+
#
|
|
19
|
+
# Filesystem-only — no network, no gh; jq only for --llm (TOON/JSON). Runs in any project cckit is
|
|
20
|
+
# installed in: it catalogs that project's own scripts/lib when it has one, otherwise the cckit
|
|
21
|
+
# install the verb is running from (which is the library the caller can actually source).
|
|
22
|
+
#
|
|
23
|
+
# All parsing lives in pure per-file helpers (kit_lib_purpose / _functions / _errors) so the test
|
|
24
|
+
# exercises them against fixture files in a temp dir — no repo scanning, no network.
|
|
25
|
+
# errors: best-effort — a file with no `# errors:` header is reported as unknown, never fatal
|
|
26
|
+
|
|
27
|
+
# ── pure parsers: one file in, one fact out ────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
# _kl_clean <text> — make a value safe for a TSV row AND a markdown table cell, then cap it so a
|
|
30
|
+
# row stays scannable. A tab would split a field; a pipe would open a phantom table column, so it
|
|
31
|
+
# becomes a slash.
|
|
32
|
+
_kl_clean() {
|
|
33
|
+
local t
|
|
34
|
+
t="$(printf '%s' "$1" | tr '\t|' ' /' | sed 's/[[:space:]]*$//')"
|
|
35
|
+
if [ "${#t}" -gt 108 ]; then
|
|
36
|
+
t="${t:0:108}"
|
|
37
|
+
case "$t" in *' '*) t="${t% *}" ;; esac # cut back to a word boundary
|
|
38
|
+
t="${t}…" # braces required: a bare $t… is a name under `set -u`
|
|
39
|
+
fi
|
|
40
|
+
printf '%s' "$t"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# _kl_sentence <text> — the first sentence, when the text has one. A lib header's opening line is
|
|
44
|
+
# often "<claim>. <elaboration…>"; the claim alone is the one-liner the catalog wants, and it beats
|
|
45
|
+
# a mid-word truncation. Refuses a suspiciously short cut (an abbreviation, not a sentence end).
|
|
46
|
+
_kl_sentence() {
|
|
47
|
+
local t="$1" first
|
|
48
|
+
case "$t" in
|
|
49
|
+
*'. '*)
|
|
50
|
+
first="${t%%'. '*}."
|
|
51
|
+
if [ "${#first}" -ge 24 ]; then printf '%s' "$first"; return 0; fi ;;
|
|
52
|
+
esac
|
|
53
|
+
printf '%s' "$t"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# kit_lib_purpose <file> — the file's one-line purpose, taken from its OWN header comment: the
|
|
57
|
+
# first real comment line (shebang and `# shellcheck` directives skipped), with the customary
|
|
58
|
+
# "<name>.sh — " self-mention stripped and only the first sentence kept, so the cell reads as a
|
|
59
|
+
# sentence. Never invents one; a file with no header comment reports `unknown`. Honest limit: a
|
|
60
|
+
# header whose opening line has no sentence end is shown truncated with an ellipsis — read the file.
|
|
61
|
+
kit_lib_purpose() {
|
|
62
|
+
local f="$1" t
|
|
63
|
+
[ -f "$f" ] || { printf '%s' "unknown"; return 0; }
|
|
64
|
+
t="$(sed -n '1,25p' "$f" | sed -n '/^#!/d; /^#[[:space:]]*shellcheck/d; /^#/p' | head -1)"
|
|
65
|
+
[ -n "$t" ] || { printf '%s' "unknown"; return 0; }
|
|
66
|
+
t="${t#\#}"
|
|
67
|
+
# trim leading blanks without a subprocess (portable across bash 3.2 + zsh)
|
|
68
|
+
while :; do
|
|
69
|
+
case "$t" in
|
|
70
|
+
' '*) t="${t# }" ;;
|
|
71
|
+
' '*) t="${t# }" ;;
|
|
72
|
+
*) break ;;
|
|
73
|
+
esac
|
|
74
|
+
done
|
|
75
|
+
case "$t" in
|
|
76
|
+
*'.sh — '*) t="${t#*'.sh — '}" ;;
|
|
77
|
+
*'.sh - '*) t="${t#*'.sh - '}" ;;
|
|
78
|
+
*'.sh: '*) t="${t#*'.sh: '}" ;;
|
|
79
|
+
esac
|
|
80
|
+
[ -n "$t" ] || t="unknown"
|
|
81
|
+
_kl_clean "$(_kl_sentence "$t")"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# kit_lib_functions <file> — the PUBLIC function names, space-separated, sorted. The house
|
|
85
|
+
# convention is that `_`-prefixed functions are private, so an initial letter is required; the
|
|
86
|
+
# column-0 anchor also drops helpers defined INSIDE another function (always an implementation
|
|
87
|
+
# detail). Empty output means the file exposes no callable surface (a runner, or config only).
|
|
88
|
+
kit_lib_functions() {
|
|
89
|
+
local f="$1"
|
|
90
|
+
[ -f "$f" ] || return 0
|
|
91
|
+
{
|
|
92
|
+
grep -E '^[A-Za-z][A-Za-z0-9_:.-]*[[:space:]]*\(\)' "$f" 2>/dev/null
|
|
93
|
+
grep -E '^function[[:space:]]+[A-Za-z][A-Za-z0-9_:.-]*' "$f" 2>/dev/null \
|
|
94
|
+
| sed 's/^function[[:space:]]*//'
|
|
95
|
+
} | sed 's/[[:space:]]*(.*//; s/[[:space:]].*//' | grep -E '^[A-Za-z]' | sort -u \
|
|
96
|
+
| tr '\n' ' ' | sed 's/ *$//'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# _kl_header <file> — the file's LEADING comment block: the shebang skipped, blank lines skipped,
|
|
100
|
+
# every comment line up to the first line of actual code. A fixed line window cannot do this job —
|
|
101
|
+
# 25 lines is too tight for pr-evidence.sh and kit-task-ops.sh, whose headers run past it, and any
|
|
102
|
+
# larger number is equally arbitrary. Bounding by structure instead means a later `# errors:` line
|
|
103
|
+
# in the body (a comment quoting this convention, say) is never read as the declaration.
|
|
104
|
+
_kl_header() {
|
|
105
|
+
[ -f "$1" ] || return 0
|
|
106
|
+
awk 'NR==1 && /^#!/ {next} /^[[:space:]]*#/ {print; next} /^[[:space:]]*$/ {next} {exit}' "$1" 2>/dev/null
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# kit_lib_errors <file> — the declared failure contract: pure | strict | best-effort | mixed, or
|
|
110
|
+
# `unknown` when the file carries no `# errors:` header (a file that predates #223, or a host
|
|
111
|
+
# project's own lib). Same parse as scripts/lib/errors-header-test.sh, which enforces it.
|
|
112
|
+
kit_lib_errors() {
|
|
113
|
+
local v=""
|
|
114
|
+
# Read the header block only (see _kl_header) so a body comment is never taken for the contract.
|
|
115
|
+
[ -f "$1" ] && v="$(_kl_header "$1" | sed -n 's/^#[[:space:]]*errors:[[:space:]]*\([a-z-]*\).*/\1/p' | head -1)"
|
|
116
|
+
[ -n "$v" ] || v="unknown"
|
|
117
|
+
printf '%s' "$v"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# kit_lib_errors_reason <file> — the required reason after the em dash, or empty. For a `mixed`
|
|
121
|
+
# file this is the ONLY thing saying which half propagates, so the catalog always shows it there.
|
|
122
|
+
kit_lib_errors_reason() {
|
|
123
|
+
local line=""
|
|
124
|
+
[ -f "$1" ] && line="$(_kl_header "$1" | sed -n 's/^#[[:space:]]*errors:[[:space:]]*//p' | head -1)"
|
|
125
|
+
case "$line" in
|
|
126
|
+
*'— '*) printf '%s' "${line#*'— '}" ;;
|
|
127
|
+
*) printf '' ;;
|
|
128
|
+
esac
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# ── the catalog ───────────────────────────────────────────────────────────────────────────────
|
|
132
|
+
|
|
133
|
+
# kit_lib_files <dir> [all] — one helper path per line, sorted. `*-test.sh` files are EXCLUDED by
|
|
134
|
+
# default: they are runners, not a callable library — their functions are local assertion helpers
|
|
135
|
+
# (`t`, `eq`, `has`) that no caller should source, and every one of them declares the same
|
|
136
|
+
# `strict — a test runner` contract, so listing them buries the ~40 real helpers. `all=1` includes
|
|
137
|
+
# them (the count is surfaced in the human footer either way, so nothing is silently hidden).
|
|
138
|
+
# `find` rather than a glob: an unmatched glob errors under zsh's nomatch and stays literal under
|
|
139
|
+
# bash, while `find` handles "no matches" cleanly in both.
|
|
140
|
+
kit_lib_files() {
|
|
141
|
+
local dir="$1" all="${2:-0}" f b
|
|
142
|
+
[ -n "$dir" ] && [ -d "$dir" ] || return 0
|
|
143
|
+
find "$dir" -maxdepth 1 -name '*.sh' -type f 2>/dev/null | sort | while IFS= read -r f; do
|
|
144
|
+
b="$(basename "$f")"
|
|
145
|
+
case "$b" in
|
|
146
|
+
*-test.sh) if [ "$all" = "1" ]; then printf '%s\n' "$f"; fi ;;
|
|
147
|
+
*) printf '%s\n' "$f" ;;
|
|
148
|
+
esac
|
|
149
|
+
done
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
# kit_lib_rows <dir> [all] [reasons] — the catalog as TSV: file<TAB>errors<TAB>functions<TAB>purpose.
|
|
153
|
+
# One shape feeds both views (markdown table and TOON), so they can never disagree.
|
|
154
|
+
kit_lib_rows() {
|
|
155
|
+
local dir="$1" all="${2:-0}" reasons="${3:-0}" f base ev er fn pu
|
|
156
|
+
[ -n "$dir" ] && [ -d "$dir" ] || return 0
|
|
157
|
+
kit_lib_files "$dir" "$all" | while IFS= read -r f; do
|
|
158
|
+
base="$(basename "$f")"
|
|
159
|
+
ev="$(kit_lib_errors "$f")"
|
|
160
|
+
er="$(kit_lib_errors_reason "$f")"
|
|
161
|
+
if [ -n "$er" ] && { [ "$reasons" = "1" ] || [ "$ev" = "mixed" ]; }; then
|
|
162
|
+
ev="$ev — $er"
|
|
163
|
+
fi
|
|
164
|
+
# NOT capped: the function names are the whole point of the catalog — an elided list would
|
|
165
|
+
# hide the very helper a caller came here to find. Purpose and errors are prose, so they cap.
|
|
166
|
+
fn="$(kit_lib_functions "$f")"
|
|
167
|
+
[ -n "$fn" ] || fn="—"
|
|
168
|
+
pu="$(kit_lib_purpose "$f")"
|
|
169
|
+
printf '%s\t%s\t%s\t%s\n' "$base" "$(_kl_clean "$ev")" "$fn" "$pu"
|
|
170
|
+
done
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
# ── which library to catalog ──────────────────────────────────────────────────────────────────
|
|
174
|
+
|
|
175
|
+
# _kl_project_root — the invoking project's root. Reuses plan-next.sh's `_pn_root` (KIT_CONFIG's
|
|
176
|
+
# parent, else $PWD) rather than re-deriving it: one root-inference rule for both introspection
|
|
177
|
+
# verbs. Falls back to $PWD if that sibling is unavailable. Note this inherits PLAN_NEXT_ROOT.
|
|
178
|
+
_kl_project_root() {
|
|
179
|
+
local here
|
|
180
|
+
if ! command -v _pn_root >/dev/null 2>&1; then
|
|
181
|
+
here="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)" || here=""
|
|
182
|
+
if [ -n "$here" ] && [ -f "$here/plan-next.sh" ]; then
|
|
183
|
+
# shellcheck source=/dev/null
|
|
184
|
+
. "$here/plan-next.sh" 2>/dev/null || true
|
|
185
|
+
fi
|
|
186
|
+
fi
|
|
187
|
+
if command -v _pn_root >/dev/null 2>&1; then _pn_root; return 0; fi
|
|
188
|
+
printf '%s' "$PWD"
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
# kit_lib_dir [root] — the directory to catalog, first hit wins:
|
|
192
|
+
# 1. $KIT_LIB_DIR explicit override (tests point it at a fixture dir)
|
|
193
|
+
# 2. <root>/scripts/lib an explicit --root (then .claude/scripts/lib, then <root> itself)
|
|
194
|
+
# 3. <project>/scripts/lib the invoking project's own library, when it has one
|
|
195
|
+
# 4. this file's own dir the cckit install the verb is running FROM — in a host project with
|
|
196
|
+
# no library of its own, that IS the library `cckit` can source.
|
|
197
|
+
# rc 1 (and no output) when nothing resolves, so the caller shows an empty state instead of crashing.
|
|
198
|
+
kit_lib_dir() {
|
|
199
|
+
local root="${1:-}" d here
|
|
200
|
+
if [ -n "${KIT_LIB_DIR:-}" ] && [ -d "${KIT_LIB_DIR:-}" ]; then printf '%s' "$KIT_LIB_DIR"; return 0; fi
|
|
201
|
+
if [ -n "$root" ]; then
|
|
202
|
+
for d in "$root/scripts/lib" "$root/.claude/scripts/lib" "$root"; do
|
|
203
|
+
[ -d "$d" ] && { printf '%s' "$d"; return 0; }
|
|
204
|
+
done
|
|
205
|
+
return 1
|
|
206
|
+
fi
|
|
207
|
+
root="$(_kl_project_root)"
|
|
208
|
+
for d in "$root/scripts/lib" "$root/.claude/scripts/lib"; do
|
|
209
|
+
[ -d "$d" ] && { printf '%s' "$d"; return 0; }
|
|
210
|
+
done
|
|
211
|
+
here="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)" || here=""
|
|
212
|
+
if [ -n "$here" ] && [ -d "$here" ]; then printf '%s' "$here"; return 0; fi
|
|
213
|
+
return 1
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
# ── the verb ──────────────────────────────────────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
# _kl_usage — the usage block, read back from this file's own header (one source of truth).
|
|
219
|
+
_kl_usage() { sed -n 's/^# \(cckit lib.*\)$/\1/p' "${BASH_SOURCE[0]:-$0}"; }
|
|
220
|
+
|
|
221
|
+
# _kl_err — structured error for --llm mode (mirrors the other verbs' failure shape).
|
|
222
|
+
_kl_err() { printf '{"error":"lib: %s"}\n' "$1"; }
|
|
223
|
+
|
|
224
|
+
# kit_lib — the verb body. Human markdown by default; TOON/JSON under --llm.
|
|
225
|
+
kit_lib() {
|
|
226
|
+
local out="${CCKIT_OUTPUT:-human}" root="" all=0 reasons=0
|
|
227
|
+
while [ "$#" -gt 0 ]; do
|
|
228
|
+
case "$1" in
|
|
229
|
+
--llm|--output=json) out="json"; shift ;;
|
|
230
|
+
--all) all=1; shift ;;
|
|
231
|
+
--reasons) reasons=1; shift ;;
|
|
232
|
+
--root) # Validate BEFORE shifting: `shift 2` on a single remaining argument aborts bash
|
|
233
|
+
# with "shift count out of range" instead of the parser's own error.
|
|
234
|
+
[ "$#" -ge 2 ] || { if [ "$out" = "json" ]; then _kl_err "--root needs a directory"; else echo "lib: --root needs a directory" >&2; fi; return 2; }
|
|
235
|
+
root="$2"; shift 2 ;;
|
|
236
|
+
--root=*) root="${1#*=}"; shift ;;
|
|
237
|
+
-h|--help) _kl_usage; return 0 ;;
|
|
238
|
+
*) if [ "$out" = "json" ]; then _kl_err "unknown arg '$1'"; else echo "lib: unknown arg '$1'" >&2; fi
|
|
239
|
+
return 2 ;;
|
|
240
|
+
esac
|
|
241
|
+
done
|
|
242
|
+
|
|
243
|
+
# --llm needs jq for valid TOON/JSON — emit a structured error rather than malformed output.
|
|
244
|
+
if [ "$out" = "json" ] && ! command -v jq >/dev/null 2>&1; then
|
|
245
|
+
_kl_err "jq is required for --llm output"; return 1
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
local dir rows n runners
|
|
249
|
+
dir="$(kit_lib_dir "$root")" || dir=""
|
|
250
|
+
rows=""; n=0; runners=0
|
|
251
|
+
if [ -n "$dir" ]; then
|
|
252
|
+
rows="$(kit_lib_rows "$dir" "$all" "$reasons")"
|
|
253
|
+
n="$(printf '%s' "$rows" | grep -c . || true)"
|
|
254
|
+
runners="$(kit_lib_files "$dir" 1 | grep -c -- '-test\.sh$' || true)"
|
|
255
|
+
fi
|
|
256
|
+
|
|
257
|
+
local here; here="$(dirname "${BASH_SOURCE[0]:-$0}")"
|
|
258
|
+
|
|
259
|
+
if [ "$out" = "json" ]; then
|
|
260
|
+
# TOON rows {file,errors,functions,purpose}. An empty catalog is a legitimate answer (a host
|
|
261
|
+
# project with no library), so it emits [] rather than an error.
|
|
262
|
+
local json
|
|
263
|
+
json="$(printf '%s\n' "$rows" | jq -R -s '[ split("\n")[] | select(length>0) | split("\t")
|
|
264
|
+
| {file:.[0], errors:.[1], functions:.[2], purpose:.[3]} ]')"
|
|
265
|
+
# shellcheck source=/dev/null
|
|
266
|
+
. "$here/toon.sh"
|
|
267
|
+
printf '%s' "$json" | toon_encode
|
|
268
|
+
return 0
|
|
269
|
+
fi
|
|
270
|
+
|
|
271
|
+
# human: a markdown table through the rendering seam (#82), same as plan-next.
|
|
272
|
+
# shellcheck source=/dev/null
|
|
273
|
+
. "$here/render.sh" 2>/dev/null || true
|
|
274
|
+
_kl_human() {
|
|
275
|
+
printf '# Helper library — %s helper(s)\n\n' "$n"
|
|
276
|
+
if [ -z "$dir" ]; then
|
|
277
|
+
printf '> No `scripts/lib` found here and cckit could not locate its own — nothing to catalog.\n'
|
|
278
|
+
return 0
|
|
279
|
+
fi
|
|
280
|
+
printf '`%s`\n\n' "$dir"
|
|
281
|
+
if [ "$n" -eq 0 ]; then
|
|
282
|
+
printf '> That directory holds no `.sh` helpers to catalog'
|
|
283
|
+
if [ "$all" != "1" ] && [ "$runners" -gt 0 ]; then
|
|
284
|
+
printf ' (its %s `*-test.sh` runner(s) are excluded; pass `--all`)' "$runners"
|
|
285
|
+
fi
|
|
286
|
+
printf '.\n'
|
|
287
|
+
return 0
|
|
288
|
+
fi
|
|
289
|
+
printf '| file | errors | public functions | purpose |\n| --- | --- | --- | --- |\n'
|
|
290
|
+
printf '%s\n' "$rows" | awk -F'\t' 'NF>=4 { printf "| `%s` | %s | %s | %s |\n", $1, $2, $3, $4 }'
|
|
291
|
+
printf '\n## How to read this\n\n'
|
|
292
|
+
printf -- '- **errors** is the file'"'"'s declared failure contract: `pure`, `strict`, `best-effort` or\n'
|
|
293
|
+
printf -- ' `mixed`. A caller that mixes a `strict` helper with a `best-effort` one inherits the weaker\n'
|
|
294
|
+
printf -- ' behaviour, so check this before composing two. `mixed` rows carry their reason because it is\n'
|
|
295
|
+
printf -- ' the only thing saying which half propagates; `--reasons` shows every reason.\n'
|
|
296
|
+
printf -- '- **public functions** excludes `_`-prefixed names (private by convention).\n'
|
|
297
|
+
printf -- '- `unknown` means the file carries no `# errors:` header yet — the catalog reports it and\n'
|
|
298
|
+
printf -- ' moves on rather than failing.\n'
|
|
299
|
+
if [ "$all" = "1" ]; then
|
|
300
|
+
printf -- '- `--all` is on, so the %s `*-test.sh` runner(s) are included.\n' "$runners"
|
|
301
|
+
else
|
|
302
|
+
printf -- '- %s `*-test.sh` runner(s) are excluded — they are test entry points, not a library.\n' "$runners"
|
|
303
|
+
printf -- ' Pass `--all` to include them.\n'
|
|
304
|
+
fi
|
|
305
|
+
printf '\n## Use one\n\n```bash\nsource %s/<file>\n```\n' "$dir"
|
|
306
|
+
}
|
|
307
|
+
if command -v cckit_render >/dev/null 2>&1; then _kl_human | cckit_render; else _kl_human; fi
|
|
308
|
+
}
|
package/scripts/lib/kit-local.sh
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
# (non-local) path". This lib never blocks a hook: alive-check 1s, chat bounded by
|
|
16
16
|
# KIT_LOCAL_TIMEOUT (default 90s; hooks should pass lower via env when latency matters).
|
|
17
17
|
# Config: .claude/kit.config.json -> .local {enabled, port, model} (KIT_LOCAL_* env wins).
|
|
18
|
+
# errors: strict — non-zero on any failure; a dead model server is not a silent empty reply
|
|
18
19
|
|
|
19
20
|
# Resolve config through the ONE shared resolver (config-path.sh, #69): KIT_CONFIG wins, else a root
|
|
20
21
|
# cckit.config.json or a .claude/kit.config.json (walk up). Falls back to the scaffolded path.
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
# }
|
|
20
20
|
# }
|
|
21
21
|
# tier A = portable (Cowork/claude.ai), tier B = CLI-only — see kit-v2 plan §5.
|
|
22
|
+
# errors: strict — ownership facts: a failed read or hash propagates rather than guessing
|
|
22
23
|
|
|
23
24
|
# --- location -------------------------------------------------------------
|
|
24
25
|
# Manifest lives at the project root's .claude/kit.manifest.json. Override with KIT_MANIFEST.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# kit-mode-test.sh — self-test for kit-mode (#371). Runs under bash AND zsh.
|
|
3
3
|
# Run: bash scripts/lib/kit-mode-test.sh
|
|
4
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
4
5
|
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
|
5
6
|
|
|
6
7
|
if [ -n "${KIT_MODE_TEST_INNER:-}" ]; then
|
package/scripts/lib/kit-mode.sh
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# Source it: source scripts/lib/kit-mode.sh (auto-sources kit-config-resolve.sh alongside)
|
|
13
13
|
# CLI: scripts/lib/kit-mode.sh [--dir DIR] -> prints the mode
|
|
14
14
|
# scripts/lib/kit-mode.sh --gate [--dir DIR] -> prints block|warn|off
|
|
15
|
+
# errors: pure — cascade lookup; no I/O of its own
|
|
15
16
|
|
|
16
17
|
_kit_mode_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
17
18
|
# shellcheck source=/dev/null
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
# recipient exactly once, project-scoped), steer marking, and the hook driver's per-event JSON
|
|
7
7
|
# (additionalContext events vs the Stop block that fires ONLY for steer mail and never twice).
|
|
8
8
|
# Run: bash scripts/lib/kit-msg-test.sh
|
|
9
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
9
10
|
set -u
|
|
10
11
|
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
11
12
|
fail=0
|
package/scripts/lib/kit-msg.sh
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
# (override root with KIT_MAIL_DIR; "/" encoded as "+" — the worktree-dir precedent). A direct
|
|
19
19
|
# message is read-ONCE (new/ → read/); a broadcast (`all`) is project-scoped, hits each session
|
|
20
20
|
# exactly once via a per-branch seen ledger, and expires after 7 days.
|
|
21
|
+
# errors: mixed — send/read propagate; delivery-side cleanup is best-effort
|
|
21
22
|
|
|
22
23
|
# Lazily bring in the shared remote-slug resolver (no-op if the caller already sourced it).
|
|
23
24
|
_msg_source_remote() {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# KIT_DRY_RUN=1 show what would happen, write nothing
|
|
13
13
|
# KIT_ASSUME_YES=1 apply without the interactive confirm (CI / batch / Cowork)
|
|
14
14
|
# KIT_NO_COLOR / NO_COLOR plain output
|
|
15
|
+
# errors: strict — the four-beat mutation machine propagates at every beat
|
|
15
16
|
|
|
16
17
|
_kit_op_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
17
18
|
# shellcheck source=/dev/null
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# kit-profile-test.sh — self-test for kit-profile (#372). Runs under bash AND zsh.
|
|
3
3
|
# Run: bash scripts/lib/kit-profile-test.sh
|
|
4
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
4
5
|
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
|
5
6
|
|
|
6
7
|
if [ -n "${KIT_PROFILE_TEST_INNER:-}" ]; then
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
# Source it: source scripts/lib/kit-profile.sh
|
|
12
12
|
# CLI: scripts/lib/kit-profile.sh [--user U] [--path | --user-slug | --show | --get JQPATH]
|
|
13
13
|
# Requires: jq.
|
|
14
|
+
# errors: strict — a failed profile read or write propagates
|
|
14
15
|
|
|
15
16
|
_kit_profile_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
16
17
|
# shellcheck source=/dev/null
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# kit-state-test.sh — the shared .cckit/ resolver (#280).
|
|
3
|
+
#
|
|
4
|
+
# The bug: state resolved CWD-relative (captain) or via `git rev-parse --show-toplevel` (handoff,
|
|
5
|
+
# secret-guard denylist). Inside a worktree --show-toplevel returns the WORKTREE root, so every
|
|
6
|
+
# worktree got its own .cckit/ and none saw the primary one — a handoff written in the main
|
|
7
|
+
# checkout read back as "no resume-here handoff saved" from any worktree, silently.
|
|
8
|
+
#
|
|
9
|
+
# These assertions run against real git worktrees in a temp dir; no network, no gh.
|
|
10
|
+
# errors: strict — rc = the number of failed assertions, so a broken resolver fails the gate
|
|
11
|
+
|
|
12
|
+
set -u
|
|
13
|
+
fail=0
|
|
14
|
+
t() { # t <name> <got> <want>
|
|
15
|
+
if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=$((fail+1)); fi
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
19
|
+
# shellcheck source=kit-state.sh
|
|
20
|
+
. "$LIB/kit-state.sh"
|
|
21
|
+
|
|
22
|
+
TMP="$(mktemp -d)"
|
|
23
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
24
|
+
|
|
25
|
+
# a real repo with a real linked worktree
|
|
26
|
+
git init -q "$TMP/repo"
|
|
27
|
+
git -C "$TMP/repo" config user.email s@e.test
|
|
28
|
+
git -C "$TMP/repo" config user.name s
|
|
29
|
+
printf 'x\n' > "$TMP/repo/f"; git -C "$TMP/repo" add f
|
|
30
|
+
git -C "$TMP/repo" commit -qm init
|
|
31
|
+
git -C "$TMP/repo" worktree add -q "$TMP/wt" -b side
|
|
32
|
+
|
|
33
|
+
# -P: on macOS /var is a symlink to /private/var, and the two entry paths canonicalize differently.
|
|
34
|
+
# That is a property of the temp dir, not of the resolver, so compare physical paths.
|
|
35
|
+
MAIN="$(cd "$TMP/repo" && pwd -P)"
|
|
36
|
+
canon() { ( cd "$(dirname "$1")" 2>/dev/null && printf '%s/%s' "$(pwd -P)" "$(basename "$1")" ) || printf '%s' "$1"; }
|
|
37
|
+
|
|
38
|
+
# ── the resolver ──────────────────────────────────────────────────────────────────────────────────
|
|
39
|
+
got_main="$(canon "$(cd "$TMP/repo" && kit_state_dir)")"
|
|
40
|
+
got_wt="$(canon "$(cd "$TMP/wt" && kit_state_dir)")"
|
|
41
|
+
t "state dir from the primary checkout" "$got_main" "$MAIN/.cckit"
|
|
42
|
+
t "state dir from a worktree is the SAME" "$got_wt" "$MAIN/.cckit"
|
|
43
|
+
t "worktree does not get its own .cckit" "$(cd "$TMP/wt" && kit_state_dir | grep -c '/wt/')" "0"
|
|
44
|
+
|
|
45
|
+
# --git-common-dir is relative (".git") at the primary checkout and absolute from a worktree; both
|
|
46
|
+
# must normalize to the same absolute root.
|
|
47
|
+
t "state file path is absolute" "$(cd "$TMP/wt" && kit_state_file captain.state | cut -c1)" "/"
|
|
48
|
+
# Composition only — the dir itself is asserted above. Deriving the expectation from kit_state_dir
|
|
49
|
+
# keeps this from re-testing path canonicalization on a directory that does not exist yet.
|
|
50
|
+
t "state file composes the name" \
|
|
51
|
+
"$(cd "$TMP/repo" && kit_state_file captain.state)" \
|
|
52
|
+
"$(cd "$TMP/repo" && kit_state_dir)/captain.state"
|
|
53
|
+
|
|
54
|
+
# ── ensure ────────────────────────────────────────────────────────────────────────────────────────
|
|
55
|
+
( cd "$TMP/wt" && kit_state_ensure )
|
|
56
|
+
t "ensure creates the shared dir from a worktree" "$([ -d "$MAIN/.cckit" ] && echo yes || echo no)" "yes"
|
|
57
|
+
t "ensure did not create a worktree-local dir" "$([ -d "$TMP/wt/.cckit" ] && echo yes || echo no)" "no"
|
|
58
|
+
|
|
59
|
+
# ── the actual symptom: a handoff written in one place is visible from the other ──────────────────
|
|
60
|
+
# shellcheck source=handoff.sh
|
|
61
|
+
. "$LIB/handoff.sh"
|
|
62
|
+
( cd "$TMP/repo" && handoff_write "note from the primary checkout" >/dev/null 2>&1 )
|
|
63
|
+
got="$(cd "$TMP/wt" && handoff_read 2>/dev/null | grep -c 'note from the primary checkout')"
|
|
64
|
+
t "handoff written in the checkout is readable from a worktree" "$got" "1"
|
|
65
|
+
|
|
66
|
+
( cd "$TMP/wt" && handoff_write "note from the worktree" >/dev/null 2>&1 )
|
|
67
|
+
got="$(cd "$TMP/repo" && handoff_read 2>/dev/null | grep -c 'note from the worktree')"
|
|
68
|
+
t "handoff written in a worktree is readable from the checkout" "$got" "1"
|
|
69
|
+
|
|
70
|
+
# ── outside a git repo, fall back rather than fail ────────────────────────────────────────────────
|
|
71
|
+
mkdir -p "$TMP/bare"
|
|
72
|
+
got="$(cd "$TMP/bare" && kit_state_dir)"
|
|
73
|
+
case "$got" in */.cckit) t "outside a repo falls back to a .cckit path" ok ok ;;
|
|
74
|
+
*) t "outside a repo falls back to a .cckit path" "$got" "*/.cckit" ;; esac
|
|
75
|
+
|
|
76
|
+
# ── KIT_STATE_DIR override wins ───────────────────────────────────────────────────────────────────
|
|
77
|
+
t "absolute KIT_STATE_DIR is used verbatim" "$(cd "$TMP/repo" && KIT_STATE_DIR=/tmp/override kit_state_dir)" "/tmp/override"
|
|
78
|
+
|
|
79
|
+
# A relative override must anchor to the shared root, not the CWD — otherwise it recreates the
|
|
80
|
+
# per-worktree split this module removes.
|
|
81
|
+
rel_main="$(canon "$(cd "$TMP/repo" && KIT_STATE_DIR=.cckit-alt kit_state_dir)")"
|
|
82
|
+
rel_wt="$(canon "$(cd "$TMP/wt" && KIT_STATE_DIR=.cckit-alt kit_state_dir)")"
|
|
83
|
+
t "relative KIT_STATE_DIR anchors to the shared root" "$rel_main" "$MAIN/.cckit-alt"
|
|
84
|
+
t "relative KIT_STATE_DIR is the SAME from a worktree" "$rel_wt" "$MAIN/.cckit-alt"
|
|
85
|
+
t "relative override does not land in the worktree" \
|
|
86
|
+
"$(cd "$TMP/wt" && KIT_STATE_DIR=.cckit-alt kit_state_dir | grep -c '/wt/')" "0"
|
|
87
|
+
|
|
88
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (kit-state)" || echo "kit-state: FAILURES"
|
|
89
|
+
exit "$fail"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# kit-state.sh — the one home for cckit's LOCAL runtime state directory (.cckit/, gitignored).
|
|
3
|
+
#
|
|
4
|
+
# State here is per-checkout session state, not a repo artifact: the captain's gate record, the
|
|
5
|
+
# resume-here handoff, the user's private secret denylist. All of it must resolve to the SAME
|
|
6
|
+
# directory no matter which worktree you are standing in — cckit tells you to work in worktrees,
|
|
7
|
+
# so CWD-relative or `--show-toplevel`-relative state is state that silently splits per worktree.
|
|
8
|
+
#
|
|
9
|
+
# `git rev-parse --show-toplevel` is the wrong primitive: inside a worktree it returns the
|
|
10
|
+
# WORKTREE's root, so each worktree gets its own .cckit/ and none of them see the main one. The
|
|
11
|
+
# handoff note written before this fix was invisible from every worktree for exactly that reason.
|
|
12
|
+
# `--git-common-dir` points at the shared .git of the primary checkout in every worktree, so its
|
|
13
|
+
# parent is the one stable root.
|
|
14
|
+
#
|
|
15
|
+
# kit_state_dir echo the absolute .cckit directory (does not create it)
|
|
16
|
+
# kit_state_file <name> echo the absolute path of a file inside it
|
|
17
|
+
# kit_state_ensure create the directory; rc 1 if it cannot be created
|
|
18
|
+
#
|
|
19
|
+
# errors: best-effort — outside a git repo it falls back to $PWD/.cckit rather than failing, since
|
|
20
|
+
# session state is never worth aborting a command over.
|
|
21
|
+
|
|
22
|
+
# _kit_state_root — the primary checkout's root, the same from any worktree. Falls back to $PWD
|
|
23
|
+
# outside a git repo.
|
|
24
|
+
_kit_state_root() {
|
|
25
|
+
local common
|
|
26
|
+
common="$(git rev-parse --git-common-dir 2>/dev/null)" || { printf '%s' "$PWD"; return 0; }
|
|
27
|
+
[ -n "$common" ] || { printf '%s' "$PWD"; return 0; }
|
|
28
|
+
# --git-common-dir returns ".git" (relative) at the primary checkout and an absolute path from a
|
|
29
|
+
# worktree, so normalize before resolving the parent.
|
|
30
|
+
case "$common" in /*) ;; *) common="$PWD/$common" ;; esac
|
|
31
|
+
( cd "$common/.." 2>/dev/null && pwd ) 2>/dev/null || printf '%s' "$PWD"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# kit_state_dir — absolute path of the state dir, shared across every worktree of one repo.
|
|
35
|
+
kit_state_dir() {
|
|
36
|
+
if [ -n "${KIT_STATE_DIR:-}" ]; then
|
|
37
|
+
# A RELATIVE override would resolve per-CWD and so reintroduce exactly the split this module
|
|
38
|
+
# exists to remove — one state dir per worktree. Anchor it to the shared root instead, so
|
|
39
|
+
# `KIT_STATE_DIR=.cckit-alt` means one directory, not one per place you happen to stand.
|
|
40
|
+
case "$KIT_STATE_DIR" in
|
|
41
|
+
/*) printf '%s' "$KIT_STATE_DIR" ;;
|
|
42
|
+
*) printf '%s/%s' "$(_kit_state_root)" "$KIT_STATE_DIR" ;;
|
|
43
|
+
esac
|
|
44
|
+
return 0
|
|
45
|
+
fi
|
|
46
|
+
printf '%s/.cckit' "$(_kit_state_root)"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# kit_state_file <name> — absolute path of one file in the state dir.
|
|
50
|
+
kit_state_file() {
|
|
51
|
+
[ -n "${1:-}" ] || { echo "kit_state_file: <name> required" >&2; return 2; }
|
|
52
|
+
printf '%s/%s' "$(kit_state_dir)" "$1"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# kit_state_ensure — create the state dir. rc 1 when it cannot be created, so a caller that must
|
|
56
|
+
# write can say so rather than emitting a raw shell redirection error.
|
|
57
|
+
kit_state_ensure() {
|
|
58
|
+
local d; d="$(kit_state_dir)"
|
|
59
|
+
[ -d "$d" ] && return 0
|
|
60
|
+
mkdir -p "$d" 2>/dev/null || return 1
|
|
61
|
+
}
|