@jeiemgi/cckit 0.6.1 → 0.7.1

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.
Files changed (114) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +34 -3
  3. package/README.md +86 -5
  4. package/bin/cckit +72 -3
  5. package/cckit.config.json +6 -1
  6. package/kit.config.schema.json +26 -1
  7. package/package.json +1 -1
  8. package/profiles/automation.json +2 -1
  9. package/profiles/content.json +2 -1
  10. package/profiles/minimal.json +2 -1
  11. package/profiles/research.json +2 -1
  12. package/profiles/software.json +2 -1
  13. package/scripts/init.sh +31 -1
  14. package/scripts/lib/board-view-test.sh +1 -0
  15. package/scripts/lib/board-view.sh +1 -0
  16. package/scripts/lib/captain-test.sh +62 -0
  17. package/scripts/lib/captain.sh +105 -17
  18. package/scripts/lib/cckit-output.sh +1 -0
  19. package/scripts/lib/commitlint.sh +1 -0
  20. package/scripts/lib/config-path-test.sh +1 -0
  21. package/scripts/lib/config-path.sh +1 -0
  22. package/scripts/lib/copilot-test.sh +1 -0
  23. package/scripts/lib/copilot.sh +1 -0
  24. package/scripts/lib/effort-dispatch-test.sh +10 -0
  25. package/scripts/lib/effort-flows-test.sh +1 -0
  26. package/scripts/lib/effort-metrics-test.sh +1 -0
  27. package/scripts/lib/effort-metrics.sh +1 -0
  28. package/scripts/lib/effort-ops-test.sh +360 -0
  29. package/scripts/lib/effort-ops.sh +372 -16
  30. package/scripts/lib/effort-parity-test.sh +1 -0
  31. package/scripts/lib/effort-plan.sh +1 -0
  32. package/scripts/lib/effort-slug-test.sh +32 -0
  33. package/scripts/lib/effort-slug.sh +72 -8
  34. package/scripts/lib/effort.sh +1 -0
  35. package/scripts/lib/engine-adapter.sh +1 -0
  36. package/scripts/lib/errors-header-test.sh +86 -0
  37. package/scripts/lib/gh-log.sh +1 -0
  38. package/scripts/lib/gh-project-test.sh +1 -0
  39. package/scripts/lib/gh-project.sh +1 -0
  40. package/scripts/lib/git-remote-test.sh +1 -0
  41. package/scripts/lib/git-remote.sh +1 -0
  42. package/scripts/lib/handoff.sh +23 -2
  43. package/scripts/lib/kit-brief-test.sh +292 -0
  44. package/scripts/lib/kit-brief.sh +376 -0
  45. package/scripts/lib/kit-cli-test.sh +1 -0
  46. package/scripts/lib/kit-cli.sh +1 -0
  47. package/scripts/lib/kit-config-resolve.sh +1 -0
  48. package/scripts/lib/kit-config-test.sh +14 -0
  49. package/scripts/lib/kit-config.sh +7 -0
  50. package/scripts/lib/kit-engine-test.sh +1 -0
  51. package/scripts/lib/kit-events.sh +1 -0
  52. package/scripts/lib/kit-gc-test.sh +125 -0
  53. package/scripts/lib/kit-gc.sh +193 -5
  54. package/scripts/lib/kit-interview-test.sh +1 -0
  55. package/scripts/lib/kit-interview.sh +1 -0
  56. package/scripts/lib/kit-lib-test.sh +226 -0
  57. package/scripts/lib/kit-lib.sh +308 -0
  58. package/scripts/lib/kit-local.sh +1 -0
  59. package/scripts/lib/kit-manifest.sh +1 -0
  60. package/scripts/lib/kit-mode-test.sh +1 -0
  61. package/scripts/lib/kit-mode.sh +1 -0
  62. package/scripts/lib/kit-msg-test.sh +1 -0
  63. package/scripts/lib/kit-msg.sh +1 -0
  64. package/scripts/lib/kit-operate.sh +1 -0
  65. package/scripts/lib/kit-profile-test.sh +1 -0
  66. package/scripts/lib/kit-profile.sh +1 -0
  67. package/scripts/lib/kit-state-test.sh +89 -0
  68. package/scripts/lib/kit-state.sh +61 -0
  69. package/scripts/lib/kit-status-test.sh +233 -0
  70. package/scripts/lib/kit-status.sh +415 -0
  71. package/scripts/lib/kit-task-ops-test.sh +1 -0
  72. package/scripts/lib/kit-task-ops.sh +1 -0
  73. package/scripts/lib/next.sh +1 -0
  74. package/scripts/lib/plan-machine-test.sh +54 -0
  75. package/scripts/lib/plan-machine.sh +86 -25
  76. package/scripts/lib/plan-next-test.sh +1 -0
  77. package/scripts/lib/plan-next.sh +1 -0
  78. package/scripts/lib/pr-evidence-test.sh +259 -0
  79. package/scripts/lib/pr-evidence.sh +220 -35
  80. package/scripts/lib/project-scan.sh +1 -0
  81. package/scripts/lib/react-detect.sh +1 -0
  82. package/scripts/lib/render-test.sh +1 -0
  83. package/scripts/lib/render.sh +1 -0
  84. package/scripts/lib/role-identity.sh +1 -0
  85. package/scripts/lib/secret-guard.sh +21 -1
  86. package/scripts/lib/toon.sh +1 -0
  87. package/scripts/lib/ui.sh +1 -0
  88. package/scripts/lib/version-bump-test.sh +1 -0
  89. package/scripts/lib/version-bump.sh +1 -0
  90. package/scripts/lib/worktree-bootstrap-test.sh +220 -0
  91. package/scripts/lib/worktree-issue-test.sh +15 -1
  92. package/scripts/lib/worktree-issue.sh +23 -8
  93. package/scripts/lib/worktree-start.sh +191 -7
  94. package/scripts/lib/zsh-safety-test.sh +10 -0
  95. package/scripts/portable-test.sh +13 -2
  96. package/scripts/self-install-test.sh +282 -0
  97. package/scripts/setup-labels.sh +1 -0
  98. package/scripts/status.sh +25 -10
  99. package/skills/kit-cleanup/SKILL.md +83 -0
  100. package/skills/kit-effort-close/SKILL.md +3 -0
  101. package/skills/kit-effort-new/SKILL.md +7 -0
  102. package/skills/kit-effort-start/SKILL.md +39 -4
  103. package/skills/kit-gc/SKILL.md +19 -0
  104. package/skills/kit-next/SKILL.md +5 -0
  105. package/skills/kit-status/SKILL.md +92 -0
  106. package/skills/kit-task-start/SKILL.md +7 -1
  107. package/templates/rules/branch-naming.md +20 -1
  108. package/templates/rules/communication-style.md +8 -0
  109. package/templates/rules/delegation-brief.md +38 -4
  110. package/templates/rules/effort-model.md +47 -4
  111. package/templates/rules/naming-and-ids.md +199 -0
  112. package/templates/rules/task-management.md +1 -1
  113. package/templates/skills/concrete/SKILL.md +117 -0
  114. package/templates/skills/karpathy-guidelines/SKILL.md +1 -0
@@ -8,21 +8,92 @@
8
8
  # Source it: source scripts/lib/pr-evidence.sh
9
9
  #
10
10
  # Functions:
11
- # pr_attach_evidence <pr-number> <evidence-file> [caption] post the evidence into the PR
11
+ # pr_attach_evidence [--strict|--best-effort] <pr-number> <evidence-file> [caption]
12
+ # upsert the evidence into the PR
12
13
  # pr_evidence_usage print how kit-effort-pr should call it
13
14
  #
14
- # Best-effort by contract: a missing gh, missing args, or missing file warns + returns 0 so it
15
- # NEVER hard-fails the caller. Callers should still append `|| true` for set -e safety.
15
+ # UPSERT, not append (#224). Each comment carries an invisible HTML-comment marker keyed on the
16
+ # caption — `<!-- cckit:pr-evidence key=<slug> -->` — so a re-run finds this helper's own previous
17
+ # comment for THAT caption and EDITs it in place. Two captions on one PR are two comments; the same
18
+ # caption twice is one comment, updated. Nothing is ever posted twice by a successful run.
16
19
  #
17
- # Requires: gh, jq not needed; uses git/coreutils. bash 3.2 compatible.
20
+ # TWO FAILURE MODES, best-effort is the DEFAULT:
21
+ # default every failure warns on stderr and returns 0, so a failed comment never breaks
22
+ # the PR flow it is only annotating. Callers may still append `|| true`.
23
+ # --strict, or every failure returns a distinct non-zero rc. Nothing that could not run is
24
+ # PR_EVIDENCE_STRICT=1
25
+ # ever reported as a clean result — no `|| true`, no swallowed API error.
26
+ # Either way `$PR_EVIDENCE_LAST_RESULT` names the outcome, so even a best-effort caller can tell
27
+ # whether the evidence actually landed:
28
+ # created · updated · bad-args · no-gh · no-file · mktemp-failed · lookup-failed · post-failed
29
+ #
30
+ # Strict exit codes: 2 bad args · 3 gh missing · 4 evidence file missing · 5 mktemp failed ·
31
+ # 6 comment lookup failed · 7 create/edit failed
32
+ #
33
+ # Requires: gh (its built-in --jq; no external jq). bash 3.2 compatible, zsh-safe.
18
34
  #
19
35
  # Env:
20
36
  # PR_EVIDENCE_REPO target repo in OWNER/REPO form; empty (default) = let gh resolve it
21
- # from the current repo (omits --repo)
37
+ # from the current repo (uses the {owner}/{repo} placeholders)
38
+ # PR_EVIDENCE_STRICT 1/true/yes/on = strict mode for every call (default 0 = best-effort)
22
39
  # KIT_EVIDENCE_URL_BASE host base for images — set it and an image embeds as ![caption](URL)
23
40
  # KIT_EVIDENCE_MAX_BYTES inline truncation cap for text/log files (default 60000)
41
+ # errors: mixed — pr_attach_evidence is best-effort by default (warns, rc 0) and propagates every failure with a distinct rc under --strict / PR_EVIDENCE_STRICT=1; the marker/body builders are pure
24
42
 
25
43
  PR_EVIDENCE_REPO="${PR_EVIDENCE_REPO:-}"
44
+ PR_EVIDENCE_STRICT="${PR_EVIDENCE_STRICT:-0}"
45
+ PR_EVIDENCE_LAST_RESULT="${PR_EVIDENCE_LAST_RESULT:-}"
46
+
47
+ # The marker prefix. STABLE ACROSS VERSIONS by contract: changing it orphans every evidence comment
48
+ # already on every open PR, so an older cckit's comments would be appended to instead of edited.
49
+ PR_EVIDENCE_MARKER_PREFIX='<!-- cckit:pr-evidence key='
50
+
51
+ # ── pure: identity ─────────────────────────────────────────────────────────────────────────────
52
+
53
+ # _pr_evidence_key <caption> — a stable slug identifying ONE evidence artifact.
54
+ # Deterministic on the caption alone, so the same gate re-run keys to the same comment. Falls back
55
+ # to a checksum when the caption has no [a-z0-9] at all (an emoji-only caption would otherwise slug
56
+ # to the empty string and collide with every other such caption).
57
+ _pr_evidence_key() {
58
+ local raw="$1" slug
59
+ slug="$(printf '%s' "$raw" | LC_ALL=C tr '[:upper:]' '[:lower:]' | LC_ALL=C tr -cs 'a-z0-9' '-')"
60
+ slug="${slug#-}"; slug="${slug%-}"
61
+ slug="$(printf '%s' "$slug" | cut -c1-48)"; slug="${slug%-}"
62
+ if [ -z "$slug" ]; then
63
+ slug="k$(printf '%s' "$raw" | cksum 2>/dev/null | awk '{print $1}')"
64
+ [ "$slug" != "k" ] || slug="evidence"
65
+ fi
66
+ printf '%s' "$slug"
67
+ }
68
+
69
+ # _pr_evidence_marker <caption> — the invisible marker line for that caption.
70
+ # An HTML comment: GitHub renders nothing, so the comment reads clean while staying findable.
71
+ _pr_evidence_marker() {
72
+ printf '%s%s -->' "$PR_EVIDENCE_MARKER_PREFIX" "$(_pr_evidence_key "$1")"
73
+ }
74
+
75
+ # _pr_evidence_match_id <marker> — read `<id><TAB><body>` lines on stdin, print the id of EVERY
76
+ # comment whose body carries the marker (oldest first, as the API returns them). rc 1 when none
77
+ # match. Pure: no gh, no network — this is the half the test drives with fixtures.
78
+ _pr_evidence_match_id() {
79
+ local marker="$1" id rest found=1
80
+ while read -r id rest; do
81
+ case "$rest" in *"$marker"*) ;; *) continue ;; esac
82
+ case "$id" in ''|*[!0-9]*) continue ;; esac
83
+ printf '%s\n' "$id"
84
+ found=0
85
+ done
86
+ return "$found"
87
+ }
88
+
89
+ # _pr_evidence_api_path <repo> <suffix> — the gh api path. An empty repo yields the
90
+ # {owner}/{repo} placeholders, which gh fills from the current repo (matching the old
91
+ # "omit --repo" behaviour).
92
+ _pr_evidence_api_path() {
93
+ if [ -n "$1" ]; then printf 'repos/%s/%s' "$1" "$2"; else printf 'repos/{owner}/{repo}/%s' "$2"; fi
94
+ }
95
+
96
+ # ── pure: body composition ─────────────────────────────────────────────────────────────────────
26
97
 
27
98
  # True when the file extension is a raster/vector image GitHub would render if uploaded.
28
99
  _pr_evidence_is_image() {
@@ -97,63 +168,165 @@ _pr_evidence_image_body() {
97
168
  printf 'Local file: `%s`\n' "$abs"
98
169
  }
99
170
 
100
- # pr_attach_evidence <pr-number> <evidence-file> [caption]
101
- # Post the evidence into the PR as a comment. Text/log files inline in a fenced block; images are
102
- # referenced (see _pr_evidence_image_body). Caption defaults to the file basename.
171
+ # _pr_evidence_compose <caption> <file> [abs-path] — the full comment body, marker first.
172
+ # Deterministic: no timestamp, no run id. A re-run with unchanged evidence produces a byte-identical
173
+ # body, so the edit is a genuine no-op instead of churning the PR timeline.
174
+ _pr_evidence_compose() {
175
+ local caption="$1" file="$2" abs="${3:-$2}"
176
+ printf '%s\n\n' "$(_pr_evidence_marker "$caption")"
177
+ if _pr_evidence_is_image "$file"; then
178
+ _pr_evidence_image_body "$caption" "$abs" "$(basename "$file")"
179
+ else
180
+ _pr_evidence_text_body "$caption" "$file"
181
+ fi
182
+ }
183
+
184
+ # ── gh seams (the only impure functions; the test stubs `gh` on PATH) ──────────────────────────
185
+
186
+ # _pr_evidence_list <repo> <pr> — `<id><TAB><json-escaped body>` per comment on the PR.
187
+ # @json keeps each body on ONE line, so a multi-line log body can never be mistaken for another
188
+ # comment's row. rc mirrors gh's, so an auth/rate-limit failure is visible to the caller.
189
+ _pr_evidence_list() {
190
+ local p
191
+ p="$(_pr_evidence_api_path "$1" "issues/$2/comments")"
192
+ gh api --paginate "$p" --jq '.[] | "\(.id)\t\(.body | @json)"' 2>/dev/null
193
+ }
194
+
195
+ # _pr_evidence_edit <repo> <comment-id> <body-file> — PATCH an existing comment in place.
196
+ _pr_evidence_edit() {
197
+ local p
198
+ p="$(_pr_evidence_api_path "$1" "issues/comments/$2")"
199
+ gh api --method PATCH "$p" -F "body=@$3" >/dev/null 2>&1
200
+ }
201
+
202
+ # _pr_evidence_create <repo> <pr> <body-file> — post a new comment.
203
+ _pr_evidence_create() {
204
+ if [ -n "$1" ]; then
205
+ gh pr comment "$2" --repo "$1" --body-file "$3" >/dev/null 2>&1
206
+ else
207
+ gh pr comment "$2" --body-file "$3" >/dev/null 2>&1
208
+ fi
209
+ }
210
+
211
+ # ── the entry point ────────────────────────────────────────────────────────────────────────────
212
+
213
+ # _pr_evidence_bail <strict> <code> <result> <message> — the one place the two failure modes fork.
214
+ # Always warns and always records the result; returns <code> only under strict.
215
+ _pr_evidence_bail() {
216
+ PR_EVIDENCE_LAST_RESULT="$3"
217
+ echo "pr_attach_evidence: $4" >&2
218
+ [ "$1" = 1 ] && return "$2"
219
+ return 0
220
+ }
221
+
222
+ # pr_attach_evidence [--strict|--best-effort] <pr-number> <evidence-file> [caption]
223
+ # Upsert the evidence into the PR as a comment. Text/log files inline in a fenced block; images are
224
+ # referenced (see _pr_evidence_image_body). Caption defaults to the file basename and is the
225
+ # comment's identity — the same caption edits its own comment, a new caption gets its own.
103
226
  pr_attach_evidence() {
227
+ local strict=0 rc
228
+ case "${PR_EVIDENCE_STRICT:-0}" in 1|true|yes|on|TRUE|YES|ON) strict=1 ;; esac
229
+ while [ "$#" -gt 0 ]; do
230
+ case "$1" in
231
+ --strict) strict=1; shift ;;
232
+ --best-effort) strict=0; shift ;;
233
+ --) shift; break ;;
234
+ -?*) _pr_evidence_bail "$strict" 2 bad-args "unknown option: $1"; rc=$?
235
+ pr_evidence_usage >&2; return "$rc" ;;
236
+ *) break ;;
237
+ esac
238
+ done
239
+
104
240
  local pr="${1:-}" file="${2:-}" caption="${3:-}"
241
+ PR_EVIDENCE_LAST_RESULT=""
105
242
 
106
- if [[ -z "$pr" || -z "$file" ]]; then
107
- echo "pr_attach_evidence: need <pr-number> <evidence-file> [caption] — skipping" >&2
243
+ if [ -z "$pr" ] || [ -z "$file" ]; then
244
+ _pr_evidence_bail "$strict" 2 bad-args \
245
+ "need <pr-number> <evidence-file> [caption] — skipping"; rc=$?
108
246
  pr_evidence_usage >&2
109
- return 0
247
+ return "$rc"
110
248
  fi
111
249
  if ! command -v gh >/dev/null 2>&1; then
112
- echo "pr_attach_evidence: gh CLI not found — cannot post evidence to PR #$pr (skipping)" >&2
113
- return 0
250
+ _pr_evidence_bail "$strict" 3 no-gh \
251
+ "gh CLI not found — cannot post evidence to PR #$pr (skipping)"
252
+ return $?
114
253
  fi
115
- if [[ ! -f "$file" ]]; then
116
- echo "pr_attach_evidence: evidence file not found: $file (skipping)" >&2
117
- return 0
254
+ if [ ! -f "$file" ]; then
255
+ _pr_evidence_bail "$strict" 4 no-file "evidence file not found: $file (skipping)"
256
+ return $?
118
257
  fi
119
- [[ -n "$caption" ]] || caption="$(basename "$file")"
258
+ [ -n "$caption" ] || caption="$(basename "$file")"
120
259
 
121
- local repo abs tmp
260
+ local repo abs tmp marker
122
261
  repo="${PR_EVIDENCE_REPO:-}"
123
262
  abs="$(cd "$(dirname "$file")" 2>/dev/null && printf '%s/%s' "$(pwd)" "$(basename "$file")")"
124
- [[ -n "$abs" ]] || abs="$file"
263
+ [ -n "$abs" ] || abs="$file"
264
+ marker="$(_pr_evidence_marker "$caption")"
125
265
 
126
- tmp="$(mktemp 2>/dev/null)" || { echo "pr_attach_evidence: mktemp failed (skipping)" >&2; return 0; }
266
+ tmp="$(mktemp 2>/dev/null)" || {
267
+ _pr_evidence_bail "$strict" 5 mktemp-failed "mktemp failed (skipping)"
268
+ return $?
269
+ }
270
+ _pr_evidence_compose "$caption" "$file" "$abs" >"$tmp"
127
271
 
128
- if _pr_evidence_is_image "$file"; then
129
- _pr_evidence_image_body "$caption" "$abs" "$(basename "$file")" >"$tmp"
130
- else
131
- _pr_evidence_text_body "$caption" "$file" >"$tmp"
272
+ # ── find this helper's own previous comment for THIS caption ────────────────────────────────
273
+ # The lookup is a network call and can fail on its own (auth, rate limit, DNS). It must NOT be
274
+ # confused with "no previous comment exists": that difference is exactly what decides between
275
+ # editing and creating.
276
+ local listing="" ids id extra
277
+ if ! listing="$(_pr_evidence_list "$repo" "$pr")"; then
278
+ # Strict: a failed lookup is a failure, full stop — nothing is posted, nothing looks green.
279
+ if [ "$strict" = 1 ]; then
280
+ PR_EVIDENCE_LAST_RESULT=lookup-failed
281
+ echo "pr_attach_evidence: could not list comments on PR #$pr (auth/rate-limit/network) — body kept at $tmp" >&2
282
+ return 6
283
+ fi
284
+ # Best-effort: FALL FORWARD to a create, deliberately risking a duplicate.
285
+ # Missing evidence is invisible and defeats the point of the helper; a duplicate comment is
286
+ # visible noise a human can collapse. It also does not compound: the new comment carries the
287
+ # same marker, so the next successful run matches and edits one of them instead of adding a
288
+ # third. The cost is one stale copy left behind, which is the honest limit of this branch.
289
+ echo "pr_attach_evidence: comment lookup failed on PR #$pr — posting a new comment (may duplicate)" >&2
290
+ listing=""
132
291
  fi
133
292
 
134
- # Omit --repo when PR_EVIDENCE_REPO is empty so gh resolves the repo from the current directory.
135
- local posted=1
136
- if [[ -n "$repo" ]]; then
137
- gh pr comment "$pr" --repo "$repo" --body-file "$tmp" >/dev/null 2>&1 && posted=0
138
- else
139
- gh pr comment "$pr" --body-file "$tmp" >/dev/null 2>&1 && posted=0
293
+ ids="$(printf '%s\n' "$listing" | _pr_evidence_match_id "$marker")" || ids=""
294
+ id="$(printf '%s\n' "$ids" | head -1)"
295
+ extra="$(printf '%s\n' "$ids" | grep -c '[0-9]' | tr -d '[:space:]')"
296
+
297
+ if [ -n "$id" ]; then
298
+ if _pr_evidence_edit "$repo" "$id" "$tmp"; then
299
+ PR_EVIDENCE_LAST_RESULT=updated
300
+ echo "✓ evidence updated in place on PR #$pr ($caption, comment $id)" >&2
301
+ [ "${extra:-1}" -gt 1 ] && echo " note: ${extra} comments carry this marker — edited the oldest; the rest are stale duplicates from an earlier failed lookup" >&2
302
+ rm -f "$tmp"
303
+ return 0
304
+ fi
305
+ PR_EVIDENCE_LAST_RESULT=post-failed
306
+ echo "✗ failed to EDIT evidence comment $id on PR #$pr — body kept at $tmp" >&2
307
+ [ "$strict" = 1 ] && return 7
308
+ return 0
140
309
  fi
141
- if [[ "$posted" -eq 0 ]]; then
310
+
311
+ if _pr_evidence_create "$repo" "$pr" "$tmp"; then
312
+ PR_EVIDENCE_LAST_RESULT=created
142
313
  echo "✓ evidence attached to PR #$pr ($caption)" >&2
143
314
  rm -f "$tmp"
144
315
  return 0
145
316
  fi
317
+ PR_EVIDENCE_LAST_RESULT=post-failed
146
318
  echo "✗ failed to post evidence comment to PR #$pr — body kept at $tmp" >&2
147
- return 1
319
+ [ "$strict" = 1 ] && return 7
320
+ return 0
148
321
  }
149
322
 
150
323
  # pr_evidence_usage — how kit-effort-pr / kit-task-pr should call this helper.
151
324
  pr_evidence_usage() {
152
325
  cat <<'USAGE'
153
- pr-evidence.sh — attach PR evidence (build/typecheck logs, screenshots) as a PR comment.
326
+ pr-evidence.sh — upsert PR evidence (build/typecheck logs, screenshots) as a PR comment.
154
327
 
155
328
  source scripts/lib/pr-evidence.sh
156
- pr_attach_evidence <pr-number> <evidence-file> [caption]
329
+ pr_attach_evidence [--strict|--best-effort] <pr-number> <evidence-file> [caption]
157
330
 
158
331
  kit-effort-pr should call it AFTER the PR is opened, once per gate artifact:
159
332
 
@@ -162,12 +335,24 @@ kit-effort-pr should call it AFTER the PR is opened, once per gate artifact:
162
335
  pr_attach_evidence "$pr_num" typecheck.log "typecheck" || true
163
336
  pr_attach_evidence "$pr_num" screen.png "rendered — success state" || true
164
337
 
338
+ UPSERT, not append. Every comment carries an invisible marker keyed on the CAPTION
339
+ (<!-- cckit:pr-evidence key=<slug> -->), so re-running on the same branch EDITS the
340
+ comment for that caption instead of stacking a new one. Different captions stay
341
+ separate comments.
342
+
343
+ Best-effort is the DEFAULT: a failure warns on stderr and returns 0, so a comment can
344
+ never break the PR flow. Pass --strict (or export PR_EVIDENCE_STRICT=1) when the
345
+ evidence must exist — then a failure returns non-zero (2 bad args, 3 no gh, 4 no file,
346
+ 5 mktemp, 6 lookup, 7 create/edit) and no `|| true` may hide it. Either way
347
+ $PR_EVIDENCE_LAST_RESULT names the outcome: created · updated · bad-args · no-gh ·
348
+ no-file · mktemp-failed · lookup-failed · post-failed.
349
+
165
350
  Text/log files are inlined in an auto-sized fenced block (truncated past
166
351
  KIT_EVIDENCE_MAX_BYTES, default 60000). Images CANNOT be uploaded via gh/REST, so they
167
352
  are referenced by local path + instructions; set KIT_EVIDENCE_URL_BASE to a host base
168
353
  and the helper embeds ![caption](URL) instead.
169
354
 
170
355
  Env: PR_EVIDENCE_REPO (OWNER/REPO; empty = gh resolves it from the current repo) ·
171
- KIT_EVIDENCE_URL_BASE · KIT_EVIDENCE_MAX_BYTES (default 60000).
356
+ PR_EVIDENCE_STRICT · KIT_EVIDENCE_URL_BASE · KIT_EVIDENCE_MAX_BYTES (default 60000).
172
357
  USAGE
173
358
  }
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  # project-scan.sh — agnostic project detection. Reports what cckit is pointed at, from the
3
3
  # filesystem only (no baked-in project knowledge). Usage: source it && project_scan [dir]
4
+ # errors: pure — filesystem detection only
4
5
  project_scan() {
5
6
  local dir="${1:-$PWD}" root stack=() kit="none"
6
7
  # ONE shared config discovery (config-path.sh, #69), sourced from this file's own dir when needed.
@@ -4,6 +4,7 @@
4
4
  # Specificity-ordered: Next.js → React Router v7 (framework mode) → Vite → generic React.
5
5
  # (A flat "is vite present?" check is unreliable — Next/RR apps often carry vite for tests.)
6
6
  # Requires: jq. Safe to source (no `set -e`); never aborts the caller.
7
+ # errors: best-effort — never aborts the caller; falls back to generic React
7
8
 
8
9
  react_detect() {
9
10
  local dir="${1:-$PWD}" pkg deps
@@ -2,6 +2,7 @@
2
2
  # render-test.sh — self-test for render.sh under bash AND zsh.
3
3
  # Network-free, TTY-free: covers width clamping, the markdown table composers, and the pipe-safety
4
4
  # guarantee (non-TTY in == verbatim out). Run: bash scripts/lib/render-test.sh
5
+ # errors: strict — a test runner: rc 1 on any failed assertion
5
6
 
6
7
  dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
7
8
 
@@ -16,6 +16,7 @@
16
16
  # render_rule a markdown horizontal rule.
17
17
  #
18
18
  # Depends on ui.sh (ui_tty). glow is optional; never required.
19
+ # errors: best-effort — glow when present, verbatim markdown otherwise
19
20
 
20
21
  # render_width — target wrap width: COLUMNS if sane, else `tput cols`, else 100; clamped to [40,120]
21
22
  # so rendered output fits a docs column / normal terminal and never sprawls.
@@ -11,6 +11,7 @@
11
11
  # Tunables (env):
12
12
  # KIT_ROLE_EMAIL_DOMAIN synthetic author-email domain (default: agents.local — not a real inbox)
13
13
  # KIT_AGENT_LABEL suffix in the author/sig label (default: agent)
14
+ # errors: pure — maps a role slug to an author + signature
14
15
  KIT_ROLE_EMAIL_DOMAIN="${KIT_ROLE_EMAIL_DOMAIN:-agents.local}"
15
16
  KIT_AGENT_LABEL="${KIT_AGENT_LABEL:-agent}"
16
17
 
@@ -7,6 +7,22 @@
7
7
  # Applies to EVERYTHING publishable — code, docs, cookbook, examples, templates.
8
8
  # Usage: source secret-guard.sh && secret_guard_scan [file...] (default: git-tracked files)
9
9
  # exit 0 = clean, 1 = a finding (with a report on stderr).
10
+ # errors: strict — rc 1 on a finding — a scan that cannot run is not a clean scan
11
+
12
+ # kit-state.sh resolves the shared .cckit/ so the private denylist is found from any worktree.
13
+ # BASH_SOURCE is bash-only and empty in zsh (#313), hence the portable self-locate.
14
+ if [ -n "${BASH_SOURCE:-}" ]; then
15
+ _sg_self="$BASH_SOURCE"
16
+ elif [ -n "${ZSH_VERSION:-}" ]; then
17
+ eval '_sg_self="${(%):-%x}"'
18
+ else
19
+ _sg_self="$0"
20
+ fi
21
+ if [ -f "$(dirname "$_sg_self")/kit-state.sh" ]; then
22
+ # shellcheck source=kit-state.sh
23
+ . "$(dirname "$_sg_self")/kit-state.sh"
24
+ fi
25
+ unset _sg_self
10
26
 
11
27
  # Files that must never be committed (by basename). Env files include .env.example/.sample —
12
28
  # even an example leaks your variable *names* and structure, so it stays local.
@@ -77,7 +93,11 @@ secret_guard_scan() {
77
93
  done < <(printf '%s\n' "${files[@]:-}" | tr '\n' '\0' | xargs -0 grep -niIE "$_sg_assign_pattern" 2>/dev/null | head -20)
78
94
 
79
95
  # (d) user-supplied privacy denylist (agnostic: YOU declare what is yours; file stays local)
80
- denylist=".cckit/privacy-denylist"
96
+ # Resolve against the shared .cckit/, not the CWD: the denylist is the user's declaration of what
97
+ # is private, and a CWD-relative path meant it was silently NOT loaded from any worktree — the
98
+ # scan ran weaker there than in the primary checkout, with no indication it had.
99
+ if command -v kit_state_file >/dev/null 2>&1; then denylist="$(kit_state_file privacy-denylist)"
100
+ else denylist=".cckit/privacy-denylist"; fi
81
101
  if [ -f "$denylist" ]; then
82
102
  while IFS= read -r term; do
83
103
  term="$(printf '%s' "$term" | sed 's/#.*//;s/^[[:space:]]*//;s/[[:space:]]*$//')"
@@ -6,6 +6,7 @@
6
6
  #
7
7
  # toon_encode read JSON on stdin, write TOON (or JSON fallback) on stdout
8
8
  # TOON_MIN_ROWS=N size gate: arrays shorter than N stay JSON (default 2)
9
+ # errors: pure — stdin JSON to stdout TOON, JSON fallback
9
10
 
10
11
  # toon_encode - stdin JSON -> stdout TOON-or-JSON.
11
12
  toon_encode() {
package/scripts/lib/ui.sh CHANGED
@@ -3,6 +3,7 @@
3
3
  # Color is gated on a real TTY + NO_COLOR; optional tools (glow, fzf, gum) enhance output when
4
4
  # present and degrade silently when not. Keeping this in one place gives every verb consistent,
5
5
  # pipe-safe behavior: piped or non-tty output is always plain.
6
+ # errors: best-effort — detect-or-fallback; optional tools degrade silently
6
7
 
7
8
  # ui_tty - true only when stdout is a real terminal (so pipes/redirects stay plain).
8
9
  ui_tty() { [ -t 1 ]; }
@@ -6,6 +6,7 @@
6
6
  # package.json lagged behind. Guards: (1) vb_write stamps all four files, (2) publish.sh calls the
7
7
  # shared bumper (no second implementation), (3) the repo's four version files currently agree.
8
8
  # Run: bash scripts/lib/version-bump-test.sh
9
+ # errors: strict — a test runner: rc 1 on any failed assertion
9
10
  set -u
10
11
  ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
11
12
  fail=0
@@ -11,6 +11,7 @@
11
11
  # `feat:` -> minor; `fix|perf|refactor|revert:` -> patch; non-functional types
12
12
  # (`docs|chore|style|test|ci|build`) and anything else -> none (no release).
13
13
  # no commits -> none (no release).
14
+ # errors: strict — set -e; a bad manifest or missing tag propagates
14
15
  set -euo pipefail
15
16
  ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
16
17