@jeiemgi/cckit 0.2.0 → 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.
Files changed (62) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +21 -8
  3. package/README.md +63 -5
  4. package/bin/cckit +37 -16
  5. package/cckit.config.json +1 -1
  6. package/commands/kit-doctor.md +3 -1
  7. package/kit.config.schema.json +24 -0
  8. package/package.json +1 -1
  9. package/scripts/annotate-setup.sh +7 -2
  10. package/scripts/capture-project-ids.sh +23 -10
  11. package/scripts/init.sh +22 -4
  12. package/scripts/kit-doctor.sh +185 -7
  13. package/scripts/kit-version-check-test.sh +36 -0
  14. package/scripts/kit-version-check.sh +19 -4
  15. package/scripts/knowledge-lint.sh +4 -1
  16. package/scripts/lib/board-view-test.sh +54 -0
  17. package/scripts/lib/board-view.sh +80 -0
  18. package/scripts/lib/captain-test.sh +18 -0
  19. package/scripts/lib/captain.sh +92 -5
  20. package/scripts/lib/config-path-test.sh +47 -0
  21. package/scripts/lib/config-path.sh +29 -0
  22. package/scripts/lib/copilot.sh +9 -9
  23. package/scripts/lib/effort-metrics-test.sh +57 -0
  24. package/scripts/lib/effort-metrics.sh +19 -5
  25. package/scripts/lib/effort-ops-test.sh +51 -2
  26. package/scripts/lib/effort-ops.sh +314 -49
  27. package/scripts/lib/effort-parity-test.sh +128 -0
  28. package/scripts/lib/effort-slug-test.sh +87 -0
  29. package/scripts/lib/effort-slug.sh +104 -0
  30. package/scripts/lib/effort.sh +34 -0
  31. package/scripts/lib/gh-project-test.sh +95 -0
  32. package/scripts/lib/gh-project.sh +22 -7
  33. package/scripts/lib/git-remote-test.sh +57 -0
  34. package/scripts/lib/git-remote.sh +21 -0
  35. package/scripts/lib/kit-config-test.sh +37 -0
  36. package/scripts/lib/kit-config.sh +33 -13
  37. package/scripts/lib/kit-events.sh +5 -3
  38. package/scripts/lib/kit-gc-test.sh +88 -0
  39. package/scripts/lib/kit-gc.sh +136 -19
  40. package/scripts/lib/kit-local.sh +8 -1
  41. package/scripts/lib/next.sh +3 -3
  42. package/scripts/lib/plan-next-test.sh +87 -0
  43. package/scripts/lib/plan-next.sh +212 -0
  44. package/scripts/lib/project-scan.sh +7 -1
  45. package/scripts/lib/worktree-start.sh +12 -3
  46. package/scripts/lib/zsh-safety-test.sh +73 -0
  47. package/scripts/portable-test.sh +62 -20
  48. package/scripts/setup-labels.sh +13 -2
  49. package/scripts/showcase.sh +13 -4
  50. package/scripts/status-test.sh +63 -0
  51. package/scripts/status.sh +12 -4
  52. package/scripts/task-sync.sh +79 -10
  53. package/skills/kit-autopilot/SKILL.md +5 -0
  54. package/skills/{docs-writer → kit-docs-writer}/SKILL.md +2 -2
  55. package/skills/kit-effort-new/SKILL.md +39 -111
  56. package/skills/kit-effort-pr/SKILL.md +6 -2
  57. package/skills/kit-next/SKILL.md +4 -0
  58. package/skills/kit-plan-next/SKILL.md +82 -0
  59. package/templates/hooks/mempal_session_start.sh.tmpl +36 -2
  60. package/templates/rules/effort-model.md +26 -6
  61. package/templates/rules/mempalace.md +1 -0
  62. package/templates/rules/plan-next.md +58 -0
@@ -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 [ -f "$root/cckit.config.json" ] || [ -f "$root/.claude/kit.config.json" ]; then kit="configured"
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' \
@@ -30,7 +30,9 @@ _wt_set_port() {
30
30
  # worktrees. Config-driven (no hardcoded app paths) so the kit stays portable: a project with no
31
31
  # `.worktree.devPorts` (or no kit.config.json) is a silent no-op. bash 3.2.
32
32
  wt_assign_ports() {
33
- local wt="$1" num="$2" root="$3" cfg ports n offset i path base
33
+ # `apppath`, not `path`: under zsh `path` is tied to PATH (special array); a bare `path` local
34
+ # would clobber the command search path on assignment. A namespaced name is inert.
35
+ local wt="$1" num="$2" root="$3" cfg ports n offset i apppath base
34
36
  cfg="$root/.claude/kit.config.json"
35
37
  # jq is a stated requirement of this file (see header) — don't pre-check `command -v jq` here: the
36
38
  # `command -v … || return` idiom mis-fires under zsh, and the jq read below already no-ops on a
@@ -41,9 +43,9 @@ wt_assign_ports() {
41
43
  n="$(jq 'length' <<<"$ports" 2>/dev/null)"; [[ "$n" =~ ^[0-9]+$ && "$n" -gt 0 ]] || return 0
42
44
  offset=$(( num % 40 )); i=0
43
45
  while [[ "$i" -lt "$n" ]]; do
44
- path="$(jq -r ".[$i].path // empty" <<<"$ports")"
46
+ apppath="$(jq -r ".[$i].path // empty" <<<"$ports")"
45
47
  base="$(jq -r ".[$i].base // empty" <<<"$ports")"
46
- [[ -n "$path" && "$base" =~ ^[0-9]+$ ]] && _wt_set_port "$wt/$path" $(( base + offset * n )) "$num"
48
+ [[ -n "$apppath" && "$base" =~ ^[0-9]+$ ]] && _wt_set_port "$wt/$apppath" $(( base + offset * n )) "$num"
47
49
  i=$(( i + 1 ))
48
50
  done
49
51
  }
@@ -264,6 +266,13 @@ wt_start() {
264
266
  # lookup on the org board, not a full-board scan. Best-effort — a board hiccup never fails the start.
265
267
  if source "$root/scripts/lib/gh-project.sh" 2>/dev/null; then
266
268
  [[ -n "${STATUS_FIELD_ID:-}" ]] || load_project_ids >/dev/null 2>&1 || true
269
+ # Claim precheck (#124): if the issue is ALREADY In Progress on the board, another session may
270
+ # already own it — warn (never block; the start still proceeds) so two agents don't collide.
271
+ if command -v project_issue_status >/dev/null 2>&1; then
272
+ local _prev_status; _prev_status="$(project_issue_status "$num" 2>/dev/null || true)"
273
+ [[ "$_prev_status" == "In Progress" ]] \
274
+ && echo "[#$num] ⚠ already In Progress on the board — another session may own this issue; continuing." >&2
275
+ fi
267
276
  item="$(project_find_item_by_issue "$num" 2>/dev/null)"
268
277
  if [[ -z "$item" ]]; then
269
278
  local content_id
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # zsh-safety-test.sh — the zsh reserved-name acceptance harness (#116). Every lib that a project may
4
+ # source from an INTERACTIVE zsh (the kit's shells alias `g=git`, and zsh ties `path` to $PATH as a
5
+ # special array) must source AND run clean there — no "defining function based on alias" parse error
6
+ # from a bare `g()`, and no clobbered command-search PATH from a bare `path` local.
7
+ #
8
+ # The bar per fixed lib: under `zsh -ic` with `alias g=git` set, sourcing the lib returns 0, invoking
9
+ # its representative function returns 0, and `git` is still resolvable afterward (PATH intact). Also a
10
+ # static regression guard: no bare `local … path …` or `g()` definition creeps back into these files.
11
+ #
12
+ # Skips (rc 0) when zsh is absent, so the gate stays dependency-light (CI installs zsh, so it runs
13
+ # there). bash 3.2 compatible. Run: bash scripts/lib/zsh-safety-test.sh
14
+ set -u
15
+ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
16
+ LIB="$ROOT/scripts/lib"
17
+ fail=0
18
+ ok() { echo "ok: $1"; }
19
+ bad() { echo "FAIL: $1"; fail=1; }
20
+
21
+ if ! command -v zsh >/dev/null 2>&1; then
22
+ echo "zsh-safety-test: zsh absent — skipping (dependency-light gate)"
23
+ exit 0
24
+ fi
25
+
26
+ cd "$ROOT" || exit 1
27
+
28
+ # run_zsh <label> <snippet> — the snippet runs under `zsh -ic` with `alias g=git` already set. Passes
29
+ # only when it exits 0 AND git is still on PATH afterward (proves no `path` clobber leaked out).
30
+ run_zsh() {
31
+ local label="$1" snippet="$2" out rc
32
+ out="$(zsh -ic "alias g=git; { $snippet ; } ; ec=\$? ; command -v git >/dev/null 2>&1 || ec=99 ; exit \$ec" 2>&1)"
33
+ rc=$?
34
+ case "$rc" in
35
+ 0) ok "$label (zsh source+run clean, PATH intact)" ;;
36
+ 99) bad "$label — PATH clobbered under zsh (a reserved-name local leaked): $(printf '%s' "$out" | tail -1)" ;;
37
+ *) bad "$label — rc=$rc under zsh: $(printf '%s' "$out" | tail -1)" ;;
38
+ esac
39
+ }
40
+
41
+ # kit-config.sh — the `g()` alias collision (source-time parse error) + `_kit_cfg_get` run.
42
+ run_zsh "kit-config.sh :: load_kit_config" \
43
+ "cd '$ROOT'; source scripts/lib/kit-config.sh; load_kit_config >/dev/null 2>&1"
44
+
45
+ # kit-gc.sh — the `path` local in kit_gc_analyze's while-read (read-only, safe to run).
46
+ run_zsh "kit-gc.sh :: kit_gc_analyze" \
47
+ "cd '$ROOT'; export KIT_GC_REPO=jeiemgi/cckit; source scripts/lib/kit-config.sh; load_kit_config >/dev/null 2>&1; source scripts/lib/kit-gc.sh; kit_gc_analyze >/dev/null 2>&1"
48
+
49
+ # worktree-start.sh — the `path` local in wt_assign_ports (no-op without .worktree.devPorts).
50
+ run_zsh "worktree-start.sh :: wt_assign_ports" \
51
+ "cd '$ROOT'; source scripts/lib/worktree-start.sh; wt_assign_ports '$ROOT' 1 '$ROOT' >/dev/null 2>&1"
52
+
53
+ # kit-events.sh — the `path` local in emit_event.
54
+ run_zsh "kit-events.sh :: emit_event" \
55
+ "cd '$ROOT'; source scripts/lib/kit-events.sh; emit_event test op '{}' >/dev/null 2>&1"
56
+
57
+ # ── static regression guard: no bare reserved-name local reintroduced ──────────────────────────
58
+ # Match a `local` declaration listing a bare `path` word, or a bare `g()` function definition. The
59
+ # fixed files use namespaced names (wtpath / apppath / logpath / _kit_cfg_get); a plain word here
60
+ # would be the regression. Comments are stripped first so the explanatory notes don't trip it.
61
+ for f in kit-config.sh kit-gc.sh worktree-start.sh kit-events.sh; do
62
+ code="$(sed 's/#.*$//' "$LIB/$f")"
63
+ if printf '%s\n' "$code" | grep -qE '\blocal\b[^=]*\bpath\b'; then
64
+ bad "$f still declares a bare \`local … path …\`"
65
+ elif printf '%s\n' "$code" | grep -qE '(^|[^_[:alnum:]])g\(\)'; then
66
+ bad "$f still defines a bare \`g()\`"
67
+ else
68
+ ok "$f — no bare reserved-name local (static guard)"
69
+ fi
70
+ done
71
+
72
+ [ "$fail" -eq 0 ] && echo "ALL OK (zsh-safety)" || echo "zsh-safety: FAILURES"
73
+ exit "$fail"
@@ -1,52 +1,94 @@
1
1
  #!/usr/bin/env bash
2
- # portable-test.sh — cckit must operate on the project it is INVOKED in, not its install dir (#41).
3
- # Regression test for the bug where `cckit sync` in another repo read cckit's own config and so
4
- # reported an empty board `[]`. Hermetic: stubs `gh` (no network/auth). Run: bash scripts/portable-test.sh
2
+ # portable-test.sh — the foreign-repo acceptance harness (#41 / #74). cckit must operate on the
3
+ # project it is INVOKED in, never its own install dir. The core invariant: run from a FOREIGN repo,
4
+ # no verb may ever resolve cckit's OWN repo (that was the bug where `cckit sync` elsewhere read
5
+ # cckit's config and reported an empty board). This harness enforces that BY CONSTRUCTION: it
6
+ # iterates `cckit commands`, exercises every read-only verb against a foreign fixture with a stubbed
7
+ # gh, and fails if any new verb is left unclassified — so coverage can't silently rot.
8
+ # Hermetic: stubs `gh` (no network/auth). Run: bash scripts/portable-test.sh
5
9
  set -u
6
10
  ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7
11
  CCKIT="$ROOT/bin/cckit"
8
12
  fail=0
9
- t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
13
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
14
+ no() { case "$2" in *"$3"*) echo "FAIL: $1 -> LEAKED '$3'"; fail=1 ;; *) echo "ok: $1" ;; esac; }
15
+ yes() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> missing '$3' in [$2]"; fail=1 ;; esac; }
10
16
 
11
17
  command -v jq >/dev/null 2>&1 || { echo "portable-test: jq required" >&2; exit 1; }
12
18
 
13
- # Stub gh on PATH: record the --repo it is asked for (to stderr), return an empty JSON array.
19
+ OWN_REPO="$(jq -r '.github.repo' "$ROOT/cckit.config.json")" # cckit's own repo — must NEVER leak
20
+ FIX_REPO="octo/fixture-repo"
21
+
22
+ # Stub gh: log EVERY --repo it is asked about to $GH_REPO_LOG (a file, so it survives a verb that
23
+ # redirects gh's stderr), and return empty results. Also echoes REPO= to stderr for the legacy checks.
14
24
  stub="$(mktemp -d)"
15
25
  cat > "$stub/gh" <<'SH'
16
26
  #!/usr/bin/env bash
17
27
  prev=""
18
28
  for a in "$@"; do
19
- [ "$prev" = "--repo" ] && printf 'REPO=%s\n' "$a" >&2
29
+ if [ "$prev" = "--repo" ]; then
30
+ [ -n "${GH_REPO_LOG:-}" ] && printf '%s\n' "$a" >> "$GH_REPO_LOG"
31
+ printf 'REPO=%s\n' "$a" >&2
32
+ fi
20
33
  prev="$a"
21
34
  done
22
- echo "[]"
35
+ # GraphQL calls read stdin/args; a bare object keeps jq consumers happy. List calls want an array.
36
+ case "$*" in *graphql*) echo '{"data":{}}' ;; *) echo "[]" ;; esac
23
37
  SH
24
38
  chmod +x "$stub/gh"
25
39
 
26
- # A foreign project with its own config pointing at a DISTINCT repo.
40
+ # A foreign project whose config points at a DISTINCT repo, a non-default base branch, and an
41
+ # org-owned board — so we verify repo + base branch + owner type all resolve to the INVOKING project.
27
42
  fix="$(mktemp -d)"
28
- cat > "$fix/cckit.config.json" <<'JSON'
29
- { "kitVersion": "9.9.9", "project": {"name":"fixture"}, "github": {"repo":"octo/fixture-repo","owner":"octo","baseBranch":"main"} }
43
+ cat > "$fix/cckit.config.json" <<JSON
44
+ { "kitVersion": "9.9.9", "project": {"name":"fixture","slug":"fixture"},
45
+ "github": {"repo":"$FIX_REPO","owner":"octo","baseBranch":"develop",
46
+ "projectsV2":true,"projectNumber":5,"projectOwnerType":"organization"} }
30
47
  JSON
31
48
  ( cd "$fix" && git init -q ) 2>/dev/null
32
49
 
33
- # 1) From the fixture, sync resolves the fixture's config → targets the fixture's repo.
34
- got_repo="$(cd "$fix" && PATH="$stub:$PATH" "$CCKIT" sync --llm 2>&1 >/dev/null | sed -n 's/^REPO=//p' | tail -1)"
35
- t "sync targets the invoking project's repo" "$got_repo" "octo/fixture-repo"
50
+ # ── config resolution: the invoking project's repo / base branch / owner type / owner ────────────
51
+ eval "$(cd "$fix" && KIT_CONFIG='' bash -c 'source "'"$ROOT"'/scripts/lib/kit-config.sh"; load_kit_config >/dev/null 2>&1;
52
+ printf "R=%s\nB=%s\nO=%s\nT=%s\n" "$KIT_REPO" "$KIT_BASE_BRANCH" "$KIT_OWNER" "$KIT_PROJECT_OWNER_TYPE"')"
53
+ t "config resolves the invoking repo" "$R" "$FIX_REPO"
54
+ t "config resolves the invoking base branch" "$B" "develop"
55
+ t "config resolves the invoking owner" "$O" "octo"
56
+ t "config resolves the org owner type" "$T" "organization"
36
57
 
37
- # 2) From the fixture, scan reports the fixture as root (no cd to the install dir).
58
+ # ── legacy targeted checks (kept) ────────────────────────────────────────────────────────────────
59
+ export GH_REPO_LOG="$fix/gh.repos"; : > "$GH_REPO_LOG"
60
+ got_repo="$(cd "$fix" && PATH="$stub:$PATH" "$CCKIT" sync --llm 2>&1 >/dev/null | sed -n 's/^REPO=//p' | tail -1)"
61
+ t "sync targets the invoking project's repo" "$got_repo" "$FIX_REPO"
38
62
  got_root="$(cd "$fix" && "$CCKIT" scan --llm 2>/dev/null | jq -r .root)"
39
63
  t "scan root is the invoking dir" "$got_root" "$(cd "$fix" && pwd -P)"
40
-
41
- # 3) Self-hosting: from the cckit repo, sync still targets cckit's own repo.
42
64
  own_repo="$(jq -r '.github.repo' "$ROOT/cckit.config.json")"
43
65
  got_own="$(cd "$ROOT" && PATH="$stub:$PATH" "$CCKIT" sync --llm 2>&1 >/dev/null | sed -n 's/^REPO=//p' | tail -1)"
44
66
  t "self-host sync targets cckit's repo" "$got_own" "$own_repo"
45
-
46
- # 4) `version` is the INSTALLED version regardless of where it is invoked.
47
- inst_ver="$(jq -r '.kitVersion' "$ROOT/cckit.config.json")"
48
67
  got_ver="$(cd "$fix" && "$CCKIT" version | awk '{print $2}')"
49
- t "version is the install version, not the project's" "$got_ver" "$inst_ver"
68
+ t "version is the install version, not the project's" "$got_ver" "$(jq -r '.kitVersion' "$ROOT/cckit.config.json")"
69
+
70
+ # ── BY CONSTRUCTION: exercise every read-only verb; none may resolve cckit's OWN repo ─────────────
71
+ # Read-only board/config verbs that MUST act on the invoking project. Run each from the fixture and
72
+ # assert the gh call log never mentions cckit's own repo (the leak this whole effort guards against).
73
+ EXERCISE="sync status next plan plan-next wave gc scan doctor"
74
+ for v in $EXERCISE; do
75
+ : > "$GH_REPO_LOG"
76
+ ( cd "$fix" && PATH="$stub:$PATH" GH_REPO_LOG="$GH_REPO_LOG" "$CCKIT" "$v" --llm >/dev/null 2>&1 )
77
+ no "verb '$v' never resolves cckit's own repo from a foreign checkout" "$(cat "$GH_REPO_LOG")" "$OWN_REPO"
78
+ done
79
+ # The board verbs that DO call gh with --repo must have hit the FIXTURE repo (proves real resolution).
80
+ : > "$GH_REPO_LOG"; ( cd "$fix" && PATH="$stub:$PATH" GH_REPO_LOG="$GH_REPO_LOG" "$CCKIT" gc --llm >/dev/null 2>&1 )
81
+ yes "gc resolves the invoking repo" "$(cat "$GH_REPO_LOG")" "$FIX_REPO"
82
+
83
+ # ── BY CONSTRUCTION: every verb in `cckit commands` is classified (exercised or explicitly skipped) ─
84
+ # A new verb that is neither exercised nor listed here fails the harness — forcing a coverage
85
+ # decision. SKIP holds verbs that mutate, need args, read stdin, are interactive, or act on the
86
+ # install itself (not the invoking project's board) — deliberately not driven here.
87
+ SKIP="adopt autopilot close commands completions contribute copilot debug digest effort encode-context handoff help init install migrate orchestrate pr release render resume start ui update version watch"
88
+ classified() { case " $EXERCISE $SKIP " in *" $1 "*) return 0 ;; *) return 1 ;; esac; }
89
+ for v in $("$CCKIT" commands); do
90
+ classified "$v" || { echo "FAIL: verb '$v' is unclassified — add it to EXERCISE (read-only, assert no own-repo leak) or SKIP in portable-test.sh"; fail=1; }
91
+ done
50
92
 
51
93
  rm -rf "$stub" "$fix"
52
94
  [ "$fail" -eq 0 ] && echo "ALL OK (portable)" || echo "portable: FAILURES"
@@ -1,8 +1,12 @@
1
1
  #!/usr/bin/env bash
2
- # Create the kind:/priority:/role: label families on the repo. Idempotent.
3
- # Reads repo + roles from .claude/kit.config.json. Run from project root.
2
+ # Create the ctx:/flow:/kind:/priority:/role: label families on the repo. Idempotent.
3
+ # Reads repo + roles from .claude/kit.config.json; the flow vocabulary from effort.sh (EFFORT_FLOWS).
4
+ # These are exactly the labels `cckit effort new` / /kit-effort-new apply — provision them here so a
5
+ # fresh repo can create a fully-labeled effort with no manual label creation. Run from project root.
4
6
  set -euo pipefail
5
7
  source "$(dirname "$0")/lib/kit-config.sh" && load_kit_config
8
+ # shellcheck source=/dev/null
9
+ source "$(dirname "$0")/lib/effort.sh" 2>/dev/null || true # for EFFORT_FLOWS (the flow:* vocabulary)
6
10
 
7
11
  ensure_label() { # name color description
8
12
  gh label create "$1" --repo "$KIT_REPO" --color "$2" --description "$3" --force >/dev/null 2>&1 \
@@ -16,6 +20,13 @@ echo "priorities:"
16
20
  ensure_label "priority:p1" "b60205" "Now / blocking"
17
21
  ensure_label "priority:p2" "fbca04" "Next"
18
22
  ensure_label "priority:p3" "0e8a16" "Later"
23
+ echo "ctx (session weight):"
24
+ for c in S M L XL; do ensure_label "ctx:$c" "c5def5" "Session weight: $c"; done
25
+ echo "flows:"
26
+ for f in ${EFFORT_FLOWS:-Core UI API Docs Infra Auth Data Web App}; do
27
+ slug=$(echo "$f" | tr '[:upper:]' '[:lower:]')
28
+ ensure_label "flow:$slug" "0e8a16" "Flow: $f"
29
+ done
19
30
  echo "roles:"
20
31
  while IFS= read -r role; do
21
32
  [[ -z "$role" ]] && continue
@@ -23,8 +23,17 @@ command -v freeze >/dev/null || { echo "showcase: freeze required (brew install
23
23
  # CCKIT_FORCE_COLOR is cckit-private (see ui.sh) so it never leaks into the gh/jq subprocesses.
24
24
  export PATH="$ROOT/bin:$PATH"
25
25
  export CCKIT_FORCE_COLOR=1
26
+ # Verbs that render markdown (plan/next/copilot) must show their verbatim markdown in the gallery,
27
+ # not shell out to glow — keeps every screenshot deterministic regardless of the local toolchain.
28
+ export CCKIT_NO_GLOW=1
26
29
  mkdir -p "$IMG_DIR"
27
30
 
31
+ # Normalized capture preset — EVERY screenshot is the SAME fixed size (920×400) with the same wrap,
32
+ # font, and line height, so the gallery is one coherent series that fits the docs column. The
33
+ # showcase is a small VISUAL teaser; the full command list lives on the CLI reference page as
34
+ # copyable text. Only include short, visual commands here so nothing clips at height 400.
35
+ FREEZE_PRESET=(--window --padding 20 --width 920 --height 400 --wrap 90 --font.size 14 --line-height 1.25)
36
+
28
37
  # Gallery header.
29
38
  {
30
39
  echo '---'
@@ -32,9 +41,9 @@ mkdir -p "$IMG_DIR"
32
41
  echo 'description: Every cckit capability at a glance — real command output captured as screenshots.'
33
42
  echo '---'
34
43
  echo
35
- echo 'A live tour of cckit, generated from a dataset (`docs-site/showcase/showcase.json`) by'
36
- echo '`scripts/showcase.sh`: each command is run for real and its output captured as a screenshot.'
37
- echo 'Every command here is read-only or a dry-run — safe to run yourself.'
44
+ echo 'A short visual tour of cckit — each shot is a real command run for real, captured at the same'
45
+ echo 'size. For the **full command list** (copyable), see the [CLI reference](/cli-reference/); to'
46
+ echo 'see how the verbs fit together, start with [the GitHub cycle](/github-cycle/).'
38
47
  echo
39
48
  } > "$GALLERY"
40
49
 
@@ -46,7 +55,7 @@ while IFS=$'\t' read -r name group title cmd show; do
46
55
  out="$IMG_DIR/$name.png"
47
56
  echo "==> $name : $cmd" >&2
48
57
  # </dev/null so freeze never consumes this loop's stdin (the jq dataset stream).
49
- if ! freeze --window --padding 20 --execute "$cmd" --output "$out" </dev/null >/dev/null 2>&1; then
58
+ if ! freeze "${FREEZE_PRESET[@]}" --execute "$cmd" --output "$out" </dev/null >/dev/null 2>&1; then
50
59
  echo " FAILED to render $name" >&2; fail=1; continue
51
60
  fi
52
61
  if [ "$group" != "$prev_group" ]; then
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # status-test.sh — regression for #142: `cckit status` board counters must be clean integers and
4
+ # never throw "integer expression expected". The bug: status fed `task-sync --llm` (TOON, not JSON)
5
+ # into `jq 'length'`, so the count became a concatenated value like "1\n0" that broke `[ … -gt 8 ]`.
6
+ # Hermetic: a fixture repo + a stubbed gh returning a known issue list. Run: bash scripts/status-test.sh
7
+ set -u
8
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
9
+ fail=0
10
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
11
+ has(){ case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> output lacks '$3'"; fail=1 ;; esac; }
12
+ no() { case "$2" in *"$3"*) echo "FAIL: $1 -> output HAS '$3'"; fail=1 ;; *) echo "ok: $1" ;; esac; }
13
+ command -v jq >/dev/null 2>&1 || { echo "status-test: jq required — skipping"; exit 0; }
14
+ command -v git >/dev/null 2>&1 || { echo "status-test: git required" >&2; exit 1; }
15
+
16
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
17
+ fix="$tmp/proj"; mkdir -p "$fix"; ( cd "$fix" && git init -q )
18
+ printf '{"kitVersion":"9.9.9","project":{"name":"fix"},"github":{"repo":"octo/fixture","owner":"octo","baseBranch":"main"}}' > "$fix/cckit.config.json"
19
+
20
+ # Stub gh: `issue list` returns $GH_ISSUES (a JSON array file); everything else returns [].
21
+ stub="$tmp/bin"; mkdir -p "$stub"
22
+ cat > "$stub/gh" <<'SH'
23
+ #!/usr/bin/env bash
24
+ case "$1 $2" in
25
+ "issue list") cat "$GH_ISSUES" 2>/dev/null || echo '[]' ;;
26
+ *) echo "[]" ;;
27
+ esac
28
+ SH
29
+ chmod +x "$stub/gh"
30
+
31
+ run_status() { # stdout+stderr of `status.sh` against the fixture with the stub gh
32
+ ( cd "$fix" && KIT_CONFIG="$fix/cckit.config.json" PATH="$stub:$PATH" GH_ISSUES="$1" \
33
+ bash "$ROOT/scripts/status.sh" 2>&1 )
34
+ }
35
+
36
+ # 3 open issues, one blocked ("Blocked by" in the body).
37
+ cat > "$tmp/issues3.json" <<'JSON'
38
+ [ {"number":10,"title":"first","body":"plain"},
39
+ {"number":11,"title":"second","body":"Blocked by #10"},
40
+ {"number":12,"title":"third","body":""} ]
41
+ JSON
42
+ out3="$(run_status "$tmp/issues3.json")"
43
+ has "counts open + blocked correctly" "$out3" "open issues: 3 blocked: 1"
44
+ no "no integer-expression error" "$out3" "integer expression"
45
+ no "count is not the concatenated 1\\n0 bug" "$out3" "open issues: 1"
46
+
47
+ # 10 open issues -> the ">8 more" line must render (the integer test path that used to crash).
48
+ printf '[' > "$tmp/issues10.json"
49
+ for i in $(seq 1 10); do printf '%s{"number":%d,"title":"i%d","body":""}' "$([ "$i" -gt 1 ] && echo ,)" "$i" "$i"; done >> "$tmp/issues10.json"
50
+ printf ']' >> "$tmp/issues10.json"
51
+ out10="$(run_status "$tmp/issues10.json")"
52
+ has "counts 10 open" "$out10" "open issues: 10"
53
+ has "renders the '... and N more' line" "$out10" "and 2 more"
54
+ no "no integer-expression error (10)" "$out10" "integer expression"
55
+
56
+ # empty board -> 0/0, still clean.
57
+ echo '[]' > "$tmp/issues0.json"
58
+ out0="$(run_status "$tmp/issues0.json")"
59
+ has "empty board counts 0/0" "$out0" "open issues: 0 blocked: 0"
60
+ no "no integer-expression error (empty)" "$out0" "integer expression"
61
+
62
+ [ "$fail" -eq 0 ] && echo "ALL OK (status)" || echo "status: FAILURES"
63
+ exit "$fail"
package/scripts/status.sh CHANGED
@@ -16,17 +16,25 @@ sec() { if command -v ui_paint >/dev/null 2>&1; then ui_paint '1;36' "$1"; else
16
16
  sec "cckit status - $KIT_REPO (base ${KIT_BASE_BRANCH:-main})"
17
17
  hr
18
18
 
19
- # Board: open issues, blocked count (reuse the read-only board JSON).
19
+ # Board: open issues, blocked count. Fetch the board as a JSON ARRAY directly (#142) — the
20
+ # `task-sync --llm` output is TOON, not JSON, so piping it into `jq 'length'` mis-parses it (the
21
+ # leading `[N]` header reads as a 1-element array, then jq errors and the `|| echo 0` fallback
22
+ # concatenates onto the partial output, yielding a value like "1\n0" that breaks `[ "$open" -gt 8 ]`
23
+ # with "integer expression expected"). A clean JSON array keeps every count a single integer.
20
24
  sec "Board"
21
- board="$(bash "$ROOT/scripts/task-sync.sh" --llm 2>/dev/null || echo '[]')"
22
- if command -v jq >/dev/null 2>&1; then
25
+ if command -v jq >/dev/null 2>&1 && command -v gh >/dev/null 2>&1; then
26
+ board="$(gh issue list --repo "$KIT_REPO" --state open --limit 200 --json number,title,body 2>/dev/null \
27
+ | jq -c '[.[] | {number, title, blocked: ((.body // "") | test("Blocked by"))}]' 2>/dev/null || echo '[]')"
28
+ [ -n "$board" ] || board='[]'
23
29
  open="$(printf '%s' "$board" | jq 'length' 2>/dev/null || echo 0)"
24
30
  blocked="$(printf '%s' "$board" | jq '[.[]|select(.blocked)]|length' 2>/dev/null || echo 0)"
31
+ case "$open" in ''|*[!0-9]*) open=0 ;; esac # never let a non-integer reach the test below
32
+ case "$blocked" in ''|*[!0-9]*) blocked=0 ;; esac
25
33
  echo " open issues: $open blocked: $blocked"
26
34
  printf '%s' "$board" | jq -r '.[:8][] | " #\(.number) \(.title[0:56])"' 2>/dev/null || true
27
35
  [ "$open" -gt 8 ] && echo " ... and $((open - 8)) more (cckit sync)"
28
36
  else
29
- echo " (jq absent - run cckit sync)"
37
+ echo " (jq/gh absent - run cckit sync)"
30
38
  fi
31
39
  hr
32
40
 
@@ -4,6 +4,8 @@
4
4
  # ./scripts/task-sync.sh [--role <Name>] [--milestone <label>]
5
5
  set -euo pipefail
6
6
  source "$(dirname "$0")/lib/kit-config.sh" && load_kit_config
7
+ # Pure board-view render helpers (merge queue, stale flag, not-on-board flag, Project Status).
8
+ source "$(dirname "$0")/lib/board-view.sh"
7
9
 
8
10
  ROLE_FILTER=""; MS_FILTER=""
9
11
  while [[ $# -gt 0 ]]; do
@@ -18,12 +20,50 @@ done
18
20
  ISSUES=$(gh issue list --repo "$KIT_REPO" --state open --limit 200 \
19
21
  --json number,title,labels,milestone,assignees,updatedAt,body)
20
22
 
21
- # Structured output for agents: emit the open board as a JSON array and stop (--llm / CCKIT_OUTPUT).
23
+ # Structured output for agents: emit the open board and stop (--llm / CCKIT_OUTPUT). The board is a
24
+ # uniform list, so it goes out as TOON — far cheaper in tokens than JSON — via the shared encoder,
25
+ # which falls back to JSON for a non-uniform/empty result. labels + assignees are flattened to
26
+ # space-joined strings (and priority is lifted out) so every row is scalar-only and TOON-eligible.
22
27
  if [ "${CCKIT_OUTPUT:-human}" = "json" ]; then
23
- echo "$ISSUES" | jq -c '[.[] | {number, title, labels: [.labels[].name], milestone: (.milestone.title // null), blocked: ((.body // "") | test("Blocked by"))}]'
28
+ board="$(echo "$ISSUES" | jq -c '[.[] | {
29
+ number,
30
+ title,
31
+ priority: ([.labels[].name | select(startswith("priority:")) | sub("priority:";"")][0] // ""),
32
+ labels: ([.labels[].name] | join(" ")),
33
+ milestone: (.milestone.title // ""),
34
+ assignees: ([.assignees[].login] | join(" ")),
35
+ blocked: ((.body // "") | test("Blocked by"))
36
+ }]')"
37
+ # shellcheck source=/dev/null
38
+ . "$(dirname "$0")/lib/toon.sh"
39
+ printf '%s' "$board" | toon_encode
24
40
  exit 0
25
41
  fi
26
42
 
43
+ # Project Status map {"<number>":"<status>"} — from the Projects v2 board when it is enabled, so each
44
+ # issue row shows its board Status and we can flag issues that never got added (no-board-entry). A
45
+ # best-effort, config-guarded read: with projectsV2 off (or any hiccup) the map stays {} and every
46
+ # row shows "—" — the board view still renders, just without Status.
47
+ STATUS_MAP="{}"
48
+ if [ "${KIT_PROJECTS_V2:-false}" = "true" ] && [ -n "${KIT_PROJECT_NUMBER:-}" ] && [ -n "${KIT_OWNER:-}" ]; then
49
+ case "${KIT_PROJECT_OWNER_TYPE:-user}" in org|organization) _ROOT=organization ;; *) _ROOT=user ;; esac
50
+ STATUS_MAP="$(gh api graphql -f query="
51
+ query(\$login:String!,\$number:Int!){
52
+ $_ROOT(login:\$login){ projectV2(number:\$number){ items(first:200){ nodes{
53
+ content{ ... on Issue { number } ... on PullRequest { number } }
54
+ fieldValueByName(name:\"Status\"){ ... on ProjectV2ItemFieldSingleSelectValue { name } }
55
+ }}}}}" -f login="$KIT_OWNER" -F number="$KIT_PROJECT_NUMBER" 2>/dev/null \
56
+ | jq -c "[.data.${_ROOT}.projectV2.items.nodes[]
57
+ | select(.content.number != null)
58
+ | {key:(.content.number|tostring), value:(.fieldValueByName.name // \"—\")}]
59
+ | from_entries" 2>/dev/null || printf '{}')"
60
+ [ -n "$STATUS_MAP" ] || STATUS_MAP="{}"
61
+ fi
62
+
63
+ # Open PRs for the merge queue (fetched once; risk/size labels + draft/review state drive the order).
64
+ PRS_JSON="$(gh pr list --repo "$KIT_REPO" --state open --limit 100 \
65
+ --json number,title,labels,isDraft,headRefName,reviewDecision,mergeable 2>/dev/null || echo '[]')"
66
+
27
67
  echo "## Board — $KIT_REPO"
28
68
  echo ""
29
69
 
@@ -31,18 +71,19 @@ echo ""
31
71
  print_role() {
32
72
  local role="$1" slug rows
33
73
  slug=$(echo "$role" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
34
- rows=$(echo "$ISSUES" | jq -r --arg slug "role:$slug" --arg ms "$MS_FILTER" '
74
+ rows=$(echo "$ISSUES" | jq -r --arg slug "role:$slug" --arg ms "$MS_FILTER" --argjson st "$STATUS_MAP" '
35
75
  .[] | select(any(.labels[]; .name == $slug))
36
76
  | select($ms == "" or (.milestone.title // "") == $ms)
37
77
  | { n:.number, t:.title,
78
+ s:($st[(.number|tostring)] // "—"),
38
79
  p:([.labels[].name | select(startswith("priority:"))][0] // "—" | sub("priority:";"")),
39
80
  m:(.milestone.title // "—"),
40
81
  blocked:(.body // "" | test("Blocked by")) }
41
- | "| #\(.n) | \(.t) | \(.p) | \(.m) | \(if .blocked then "! blocked" else "—" end) |"')
82
+ | "| #\(.n) | \(.s) | \(.t) | \(.p) | \(.m) | \(if .blocked then "! blocked" else "—" end) |"')
42
83
  [[ -z "$rows" ]] && return
43
84
  echo "### $role"
44
- echo "| # | Title | Pri | Milestone | Flag |"
45
- echo "| - | ----- | --- | --------- | ---- |"
85
+ echo "| # | Status | Title | Pri | Milestone | Flag |"
86
+ echo "| - | ------ | ----- | --- | --------- | ---- |"
46
87
  echo "$rows"
47
88
  echo ""
48
89
  }
@@ -53,7 +94,35 @@ else
53
94
  while IFS= read -r role; do [[ -n "$role" ]] && print_role "$role"; done <<< "$KIT_ROLES"
54
95
  fi
55
96
 
56
- BLOCKED=$(echo "$ISSUES" | jq -r '[.[] | select((.body // "") | test("Blocked by"))] | length')
57
- echo "**Blocked:** ${BLOCKED} item(s)"
58
- STALE=$(echo "$ISSUES" | jq -r '[.[] | .updatedAt] | length')
59
- echo "**Open total:** ${STALE}"
97
+ # ── Flags: blocked / not-on-board / stale ───────────────────────────────────────────────────────
98
+ BLOCKED_LIST=$(echo "$ISSUES" | jq -r '[.[] | select((.body // "") | test("Blocked by")) | "#\(.number)"] | join(" ")')
99
+ NOT_ON_BOARD=$(board_not_on_board "$ISSUES" "$STATUS_MAP")
100
+ STALE_LIST=$(board_stale_list "$ISSUES" 14)
101
+ echo "**Blocked:** ${BLOCKED_LIST:-none ✓}"
102
+ # Only surface no-board-entry when a board is actually configured (otherwise every issue trivially
103
+ # has no entry — noise, not signal).
104
+ if [ "${KIT_PROJECTS_V2:-false}" = "true" ]; then
105
+ echo "**Not on board:** ${NOT_ON_BOARD:-none ✓}"
106
+ fi
107
+ echo "**Stale (>14 days no activity):** ${STALE_LIST:-none ✓}"
108
+ OPEN_TOTAL=$(echo "$ISSUES" | jq -r 'length')
109
+ echo "**Open total:** ${OPEN_TOTAL}"
110
+ echo ""
111
+
112
+ # ── Merge Queue: open PRs ordered ready → draft → blocked (risk asc, size asc) ───────────────────
113
+ board_merge_queue "$PRS_JSON"
114
+
115
+ # ── Optional local-model digest — only when the local endpoint is alive (zero API cost) ──────────
116
+ # A 3–5 line executive read of the board (merge order, blockers, staleness). Best-effort: absent or
117
+ # offline local model → nothing appended, the board view above stands on its own.
118
+ if [ -f "$(dirname "$0")/lib/kit-local.sh" ]; then
119
+ # shellcheck source=/dev/null
120
+ if source "$(dirname "$0")/lib/kit-local.sh" 2>/dev/null && kit_local_alive 2>/dev/null; then
121
+ echo ""
122
+ echo "### Local digest"
123
+ kit_local_chat \
124
+ "You are a release captain. In 3–5 lines, summarize the merge order, blockers, and staleness for a busy maintainer." \
125
+ "Blocked: ${BLOCKED_LIST:-none}. Stale: ${STALE_LIST:-none}. Merge queue follows the ready→draft→blocked order." \
126
+ 2>/dev/null || echo "_(local digest unavailable)_"
127
+ fi
128
+ fi
@@ -15,6 +15,11 @@ scripts; it never reimplements looping or orchestration.
15
15
  | **objective** | one long objective on the current branch | the built-in `/loop` + caps + a stop-check |
16
16
  | **plan** | the planned, file-disjoint set of efforts/flows in parallel | `kit effort plan` + `orchestrate.sh` + `orchestrate-watch.sh` |
17
17
 
18
+ > Need the plan first? `/kit-plan-next` (`cckit plan-next`) proposes what to build next from the
19
+ > kit's current capabilities, then hands a chosen item to `/kit-effort-new` — the effort autopilot
20
+ > later drives. Keep that planner output with the human/orchestrator; never feed it into a monitored
21
+ > agent's context (context-anxiety rule).
22
+
18
23
  ## Established-plan autonomy (the default)
19
24
 
20
25
  **When the plan is already approved, the captain DECIDES + MERGES + CONTINUES — it does not bounce
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: docs-writer
2
+ name: kit-docs-writer
3
3
  description: >
4
4
  Write and edit end-user documentation in the house voice: kind but robust, ADHD-oriented and
5
5
  scannable, ZERO analogies, beginner-inclusive but expert-skippable. Encodes the page template
@@ -15,7 +15,7 @@ metadata:
15
15
  version: 1.0.0
16
16
  ---
17
17
 
18
- # docs-writer — the house voice for human documentation
18
+ # kit-docs-writer — the house voice for human documentation
19
19
 
20
20
  Documentation here is read by people with low software knowledge. It must still be correct and
21
21
  complete for experts. The whole skill is one promise: **a beginner can follow the flow, and an