@jeiemgi/cckit 0.4.0 → 0.4.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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "cckit",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "installationPreference": "beta",
5
5
  "description": "cckit — a project operating system for coding agents. The full GitHub work lifecycle (start/pr/close/sync, efforts, worktrees, orchestrate, gc) as agents + skills + rules, drivable by Claude Code and any other agent. Driven from cckit.config.json; no org or repo hardcoded.",
6
6
  "author": {
7
7
  "name": "jeiemgi"
8
8
  },
9
- "homepage": "https://cckit.vercel.app",
9
+ "homepage": "https://cckit.dev",
10
10
  "repository": "jeiemgi/cckit",
11
11
  "license": "MIT OR Apache-2.0",
12
12
  "keywords": [
package/AGENTS.md CHANGED
@@ -86,7 +86,7 @@ Every operation an unattended run needs is reachable through the one CLI:
86
86
 
87
87
  cckit shells out to whatever agent invokes it; it does not embed a model. For verbs that synthesize
88
88
  text (digests, ingest), the model endpoint is configurable via environment — see the docs site (
89
- [cckit.vercel.app](https://cckit.vercel.app).
89
+ [cckit.dev](https://cckit.dev).
90
90
 
91
91
  ## Paste-ready agent prompt
92
92
 
package/README.md CHANGED
@@ -9,10 +9,10 @@
9
9
 
10
10
  [![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)
11
11
  [![Built for Claude Code](https://img.shields.io/badge/built%20for-Claude%20Code-8A63D2.svg)](https://docs.claude.com/claude-code)
12
- [![Docs](https://img.shields.io/badge/docs-cckit.vercel.app-0A7E8C.svg)](https://cckit.vercel.app)
12
+ [![Docs](https://img.shields.io/badge/docs-cckit.dev-0A7E8C.svg)](https://cckit.dev)
13
13
  [![Platforms: macOS · Linux · WSL](https://img.shields.io/badge/platforms-macOS%20%C2%B7%20Linux%20%C2%B7%20WSL-555.svg)](#platforms--requirements)
14
14
 
15
- **[📖 Documentation](https://cckit.vercel.app)** · [The idea](https://cckit.vercel.app/philosophy/) · [Tutorials](https://cckit.vercel.app/tutorials/) · [Quick start](#quick-start) · [Contributing](CONTRIBUTING.md) · [Code of Conduct](CODE_OF_CONDUCT.md)
15
+ **[📖 Documentation](https://cckit.dev)** · [The idea](https://cckit.dev/philosophy/) · [Tutorials](https://cckit.dev/tutorials/) · [Quick start](#quick-start) · [Contributing](CONTRIBUTING.md) · [Code of Conduct](CODE_OF_CONDUCT.md)
16
16
 
17
17
  The whole idea in one line:
18
18
 
@@ -32,6 +32,10 @@ run a shell can drive every operation.
32
32
  the plan and the proof.
33
33
  - **Sessions that pick up where you left off.** `cckit handoff "<note>"` saves a resume-here note;
34
34
  bare `cckit` prints it at the start of the next session — context survives the context window.
35
+ - **Sessions that talk to each other.** `cckit msg send <branch|project:branch|all> [--steer]
36
+ "<text>"` mails any parallel session on the machine — same project or another; the kit's mail
37
+ hook delivers it to a *live* session between tool calls, and a `--steer` message redirects a
38
+ session that is about to stop.
35
39
  - **Agent-operable.** Every verb has a machine-readable mode (`cckit <verb> --llm`) and an
36
40
  [`AGENTS.md`](AGENTS.md) contract, so agents drive the kit without scraping human output.
37
41
  - **Scales from one issue to a wave.** The same verbs that take one issue to a merged PR also plan
@@ -164,13 +168,13 @@ The board is both the plan and the proof.
164
168
 
165
169
  ## Documentation
166
170
 
167
- Full docs live at **[cckit.vercel.app](https://cckit.vercel.app)** — start with
168
- [the idea](https://cckit.vercel.app/philosophy/) if you want the why. The
169
- [tutorials](https://cckit.vercel.app/tutorials/) are step-by-step "How to X with Claude Code"
171
+ Full docs live at **[cckit.dev](https://cckit.dev)** — start with
172
+ [the idea](https://cckit.dev/philosophy/) if you want the why. The
173
+ [tutorials](https://cckit.dev/tutorials/) are step-by-step "How to X with Claude Code"
170
174
  guides, each labelled **Beginner / Intermediate / Advanced** and carrying a **"Copy as Markdown"
171
175
  prompt** you can paste straight into Claude Code — start exactly where you are. The
172
- [cookbook](https://cckit.vercel.app/cookbook/) holds lifecycle recipes, and the
173
- [CLI reference](https://cckit.vercel.app/cli-reference/) covers every verb.
176
+ [cookbook](https://cckit.dev/cookbook/) holds lifecycle recipes, and the
177
+ [CLI reference](https://cckit.dev/cli-reference/) covers every verb.
174
178
 
175
179
  ## Project layout
176
180
 
@@ -182,7 +186,7 @@ cckit/
182
186
  skills/ commands/ # Claude Code skills + slash commands
183
187
  profiles/ templates/ # init profiles + scaffold templates
184
188
  routines/ modules/ # scheduled routines + optional modules
185
- docs-site/ # documentation source — Astro/Starlight (deployed to cckit.vercel.app)
189
+ docs-site/ # documentation source — Astro/Starlight (deployed to cckit.dev)
186
190
  cckit.config.json # project configuration (no hardcoded org/repo)
187
191
  ```
188
192
 
package/bin/cckit CHANGED
@@ -24,6 +24,7 @@
24
24
  # cckit watch [--merge] [--loop] captain: gate open PRs, squash-merge CLEAN, advance the wave
25
25
  # cckit next [--effort N] everyday helper: the unblocked set + how to start the top issue
26
26
  # cckit wave [--effort N] read open efforts, propose incoming waves: fan-out + captain drive
27
+ # cckit msg <send|read|list> session mail across projects: steer a live session (--steer)
27
28
  # cckit gc [--prune [--yes]] report (default) or prune merged branches + worktrees
28
29
  # cckit status thin dashboard: board + worktrees + resume handoff
29
30
  # cckit scan [--llm] detect this repo's stack + kit state (JSON)
@@ -266,6 +267,18 @@ case "$cmd" in
266
267
  status|ui) exec "$ROOT/scripts/status.sh" "$@" ;;
267
268
  resume) source "$LIB/handoff.sh"; handoff_read ;;
268
269
  handoff) source "$LIB/handoff.sh"; handoff_write "$@" ;;
270
+ msg)
271
+ # Session mail (#175) — pure git-local state (.cckit/mail at the root worktree), no config.
272
+ source "$LIB/kit-msg.sh"
273
+ sub="${1:-}"; shift || true
274
+ case "$sub" in
275
+ send) msg_send "$@" ;;
276
+ read) msg_read "$@" ;;
277
+ list) msg_list ;;
278
+ hook-check) msg_hook_check "$@" ;;
279
+ *) echo 'cckit msg <send|read|list|hook-check>' >&2; exit 2 ;;
280
+ esac
281
+ ;;
269
282
  install) exec "$ROOT/scripts/install.sh" "$@" ;;
270
283
  init) exec "$ROOT/scripts/init.sh" "$@" ;;
271
284
  commands)
package/cckit.config.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "./kit.config.schema.json",
3
- "kitVersion": "0.4.0",
3
+ "kitVersion": "0.4.1",
4
4
  "project": {
5
5
  "name": "cckit",
6
6
  "slug": "cckit",
@@ -44,7 +44,7 @@ Run the kit-doctor script to check all dependencies and authentication required
44
44
 
45
45
  4. If all Tier 1 checks pass:
46
46
  - Report success
47
- - Point the user at the pointer the doctor prints on its last line: the local onboarding app at `$CCKIT_ADMIN_URL/onboarding` **only when it is actually reachable**, otherwise the public docs at `https://cckit.vercel.app`. Do not hardcode `localhost:3001` — nothing serves it by default.
47
+ - Point the user at the pointer the doctor prints on its last line: the local onboarding app at `$CCKIT_ADMIN_URL/onboarding` **only when it is actually reachable**, otherwise the public docs at `https://cckit.dev`. Do not hardcode `localhost:3001` — nothing serves it by default.
48
48
 
49
49
  ## Rules
50
50
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@jeiemgi/cckit",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "description": "cckit — a project operating system for coding agents (CLI + Claude Code plugin).",
7
- "homepage": "https://cckit.vercel.app",
7
+ "homepage": "https://cckit.dev",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/jeiemgi/cckit.git"
@@ -833,7 +833,7 @@ _admin_url="${CCKIT_ADMIN_URL:-http://localhost:3001}"
833
833
  if has_cmd curl && curl -fsS --max-time 1 "$_admin_url/onboarding" >/dev/null 2>&1; then
834
834
  printf ' %sOnboarding guide (web): %s/onboarding%s\n' "$C_DIM" "$_admin_url" "$C_RESET"
835
835
  else
836
- printf ' %sDocs & quick start: %shttps://cckit.vercel.app%s\n' "$C_DIM" "" "$C_RESET"
836
+ printf ' %sDocs & quick start: %shttps://cckit.dev%s\n' "$C_DIM" "" "$C_RESET"
837
837
  fi
838
838
  printf '\n'
839
839
 
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # kit-msg-test.sh — #175: session mail. Hermetic: KIT_MAIL_DIR pins the mailbox root; two
4
+ # throwaway repos (with remotes) stand in for two PROJECTS, worktrees for sessions. Covers:
5
+ # send/read-once, CROSS-PROJECT addressing (project:branch), broadcast seen-ledger (each
6
+ # recipient exactly once, project-scoped), steer marking, and the hook driver's per-event JSON
7
+ # (additionalContext events vs the Stop block that fires ONLY for steer mail and never twice).
8
+ # Run: bash scripts/lib/kit-msg-test.sh
9
+ set -u
10
+ LIB="$(cd "$(dirname "$0")" && pwd)"
11
+ fail=0
12
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
13
+ command -v jq >/dev/null 2>&1 || { echo "kit-msg-test: jq required" >&2; exit 1; }
14
+
15
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
16
+ export KIT_MAIL_DIR="$tmp/mail"
17
+
18
+ mkrepo() { # mkrepo <dir> <owner/name>
19
+ git -C "$tmp" init -q -b main "$1"
20
+ git -C "$tmp/$1" -c user.email=t@t -c user.name=t commit -q --allow-empty -m init
21
+ git -C "$tmp/$1" remote add origin "git@github.com:$2.git"
22
+ }
23
+ mkrepo appA "acme/app-a"
24
+ mkrepo appB "acme/app-b"
25
+ git -C "$tmp/appA" worktree add -q -b task/9-fix "$tmp/appA-fix" main >/dev/null 2>&1
26
+ git -C "$tmp/appA" worktree add -q -b docs/site "$tmp/appA-docs" main >/dev/null 2>&1
27
+
28
+ # shellcheck source=/dev/null
29
+ . "$LIB/kit-msg.sh"
30
+
31
+ # ── same-project: send (from main) → read-once (in task/9-fix) ─────────────────────────────────
32
+ cd "$tmp/appA"
33
+ msg_send "task/9-fix" "rebase onto main" >/dev/null 2>&1
34
+ t "mailbox is keyed project/branch (encoded)" \
35
+ "$(ls "$KIT_MAIL_DIR/acme+app-a/task+9-fix/new" | wc -l | tr -d ' ')" "1"
36
+
37
+ cd "$tmp/appA-fix"
38
+ out="$(msg_read)"
39
+ case "$out" in *"rebase onto main"*) echo "ok: recipient reads the message" ;; *) echo "FAIL: read output: $out"; fail=1 ;; esac
40
+ t "direct mail is read-ONCE (moved to read/)" "$(msg_read)" "no mail for acme/app-a:task/9-fix"
41
+ t "consumed mail is archived, not lost" \
42
+ "$(ls "$KIT_MAIL_DIR/acme+app-a/task+9-fix/read" | wc -l | tr -d ' ')" "1"
43
+
44
+ # ── cross-project: appB steers appA's docs session by project:branch ────────────────────────────
45
+ cd "$tmp/appB"
46
+ msg_send "acme/app-a:docs/site" "app-b broke your API fixture" >/dev/null 2>&1
47
+ cd "$tmp/appA-docs"
48
+ out="$(msg_read)"
49
+ case "$out" in *"app-b broke your API fixture"*) echo "ok: cross-project mail delivered" ;; *) echo "FAIL: cross-project: $out"; fail=1 ;; esac
50
+ case "$out" in *"from: main (acme/app-b)"*) echo "ok: sender carries its project identity" ;; *) echo "FAIL: sender header: $out"; fail=1 ;; esac
51
+
52
+ # ── broadcast: project-scoped, each session exactly once ────────────────────────────────────────
53
+ cd "$tmp/appA"
54
+ msg_send all "v0.4.0 released" >/dev/null 2>&1
55
+ cd "$tmp/appA-fix"; out1="$(msg_read)"
56
+ cd "$tmp/appA-docs"; out2="$(msg_read)"
57
+ case "$out1" in *"v0.4.0 released"*) echo "ok: broadcast reaches session 1" ;; *) echo "FAIL: bcast s1: $out1"; fail=1 ;; esac
58
+ case "$out2" in *"v0.4.0 released"*) echo "ok: broadcast reaches session 2" ;; *) echo "FAIL: bcast s2: $out2"; fail=1 ;; esac
59
+ t "broadcast is once per session" "$(msg_read)" "no mail for acme/app-a:docs/site"
60
+ cd "$tmp/appB"
61
+ t "broadcast is project-scoped (app-b unaffected)" "$(msg_read)" "no mail for acme/app-b:main"
62
+
63
+ # ── hook driver: additionalContext events ───────────────────────────────────────────────────────
64
+ cd "$tmp/appA"
65
+ msg_send "docs/site" "please hold merges" >/dev/null 2>&1
66
+ cd "$tmp/appA-docs"
67
+ hj="$(msg_hook_check PostToolUse)"
68
+ t "PostToolUse JSON names the event" "$(printf '%s' "$hj" | jq -r '.hookSpecificOutput.hookEventName')" "PostToolUse"
69
+ case "$(printf '%s' "$hj" | jq -r '.hookSpecificOutput.additionalContext')" in
70
+ *"please hold merges"*) echo "ok: mail rides additionalContext" ;;
71
+ *) echo "FAIL: additionalContext: $hj"; fail=1 ;;
72
+ esac
73
+ t "hook is SILENT with no mail" "$(msg_hook_check PostToolUse)" ""
74
+
75
+ # ── Stop: blocks only for steer mail, consumed so it can never block twice ─────────────────────
76
+ cd "$tmp/appA"
77
+ msg_send "docs/site" "fyi only" >/dev/null 2>&1
78
+ cd "$tmp/appA-docs"
79
+ t "Stop ignores a plain note" "$(msg_hook_check Stop)" ""
80
+ cd "$tmp/appB"
81
+ msg_send "acme/app-a:docs/site" --steer "stop and rebase first" >/dev/null 2>&1
82
+ cd "$tmp/appA-docs"
83
+ sj="$(msg_hook_check Stop)"
84
+ t "Stop blocks for steer mail (cross-project too)" "$(printf '%s' "$sj" | jq -r '.decision')" "block"
85
+ case "$(printf '%s' "$sj" | jq -r '.reason')" in
86
+ *"stop and rebase first"*) echo "ok: steer text is the block reason" ;;
87
+ *) echo "FAIL: stop reason: $sj"; fail=1 ;;
88
+ esac
89
+ t "a consumed steer never blocks twice" "$(msg_hook_check Stop)" ""
90
+ # the plain note from above is still queued for a context event
91
+ case "$(msg_hook_check UserPromptSubmit)" in
92
+ *"fyi only"*) echo "ok: note still delivered on the next context event" ;;
93
+ *) echo "FAIL: note lost after Stop pass"; fail=1 ;;
94
+ esac
95
+
96
+ # ── hcom-informed hardening (#175): cap, typo warning, opt-in Stop long-poll ────────────────────
97
+ # delivery cap: excess mail rides the NEXT hook fire, nothing is lost
98
+ cd "$tmp/appA"
99
+ msg_send "docs/site" "one" >/dev/null 2>&1
100
+ msg_send "docs/site" "two" >/dev/null 2>&1
101
+ cd "$tmp/appA-docs"
102
+ # order within one second is filename-random — assert counts and the union, not sequence
103
+ h1="$(KIT_MAIL_MAX_PER_DELIVERY=1 msg_hook_check PostToolUse | jq -r '.hookSpecificOutput.additionalContext')"
104
+ h2="$(KIT_MAIL_MAX_PER_DELIVERY=1 msg_hook_check PostToolUse | jq -r '.hookSpecificOutput.additionalContext')"
105
+ t "cap: first delivery carries exactly one message" "$(printf '%s' "$h1" | grep -c '^kind: note')" "1"
106
+ t "cap: second delivery carries exactly one message" "$(printf '%s' "$h2" | grep -c '^kind: note')" "1"
107
+ case "$h1$h2" in
108
+ *one*two*|*two*one*) echo "ok: capped-out mail rides the next hook fire (nothing lost)" ;;
109
+ *) echo "FAIL: cap lost mail: [$h1] [$h2]"; fail=1 ;;
110
+ esac
111
+
112
+ # typo'd target → loud warning about a brand-new mailbox
113
+ cd "$tmp/appA"
114
+ warn="$(msg_send "task/9-fxi" "typo target" 2>&1 >/dev/null)"
115
+ case "$warn" in *"new mailbox"*) echo "ok: unknown target warns instead of silently dropping" ;; *) echo "FAIL: no new-mailbox warning: $warn"; fail=1 ;; esac
116
+ warn="$(msg_send "task/9-fix" "known target" 2>&1 >/dev/null)"
117
+ case "$warn" in *"new mailbox"*) echo "FAIL: warned on an existing mailbox"; fail=1 ;; *) echo "ok: existing mailbox does not warn" ;; esac
118
+
119
+ # opt-in Stop long-poll: steer sent DURING the wait is still delivered (near-real-time idle steer)
120
+ cd "$tmp/appA-docs"
121
+ ( sleep 1; cd "$tmp/appA" && . "$LIB/kit-msg.sh" && msg_send "docs/site" --steer "late steer" >/dev/null 2>&1 ) &
122
+ pj="$(KIT_MAIL_STOP_POLL=4 msg_hook_check Stop)"
123
+ wait
124
+ case "$(printf '%s' "$pj" | jq -r '.reason' 2>/dev/null)" in
125
+ *"late steer"*) echo "ok: Stop long-poll catches a steer that lands mid-wait" ;;
126
+ *) echo "FAIL: long-poll missed the steer: $pj"; fail=1 ;;
127
+ esac
128
+ t "long-poll consumed the steer (no double block)" "$(msg_hook_check Stop)" ""
129
+
130
+ # ── hook script resolution (#179): the project's own bin/cckit beats a stale PATH cckit ─────────
131
+ HOOK="$LIB/../../templates/hooks/kit-mail-check.sh.tmpl"
132
+ mkdir -p "$tmp/appA/bin" "$tmp/stalebin"
133
+ cat > "$tmp/appA/bin/cckit" <<'SH'
134
+ #!/usr/bin/env bash
135
+ [ "$1 $2" = "msg hook-check" ] && echo "PROJECT-BIN-DELIVERED $3"
136
+ SH
137
+ cat > "$tmp/stalebin/cckit" <<'SH'
138
+ #!/usr/bin/env bash
139
+ echo "cckit: unknown command '$1'" >&2; exit 2
140
+ SH
141
+ chmod +x "$tmp/appA/bin/cckit" "$tmp/stalebin/cckit"
142
+ hout="$(printf '{"hook_event_name":"PostToolUse","cwd":"%s"}' "$tmp/appA" | PATH="$tmp/stalebin:$PATH" bash "$HOOK")"
143
+ t "hook prefers the project's own bin/cckit over a stale PATH cckit" "$hout" "PROJECT-BIN-DELIVERED PostToolUse"
144
+ rm -rf "$tmp/appA/bin"
145
+ hout="$(printf '{"hook_event_name":"Stop","cwd":"%s"}' "$tmp/appA" | PATH="$tmp/stalebin:$PATH" bash "$HOOK"; echo "rc=$?")"
146
+ t "hook stays a silent no-op when only a broken PATH cckit exists" "$hout" "rc=0"
147
+
148
+ [ "$fail" -eq 0 ] && echo "ALL OK (kit-msg)"
149
+ exit "$fail"
@@ -0,0 +1,220 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # kit-msg.sh — session mail (#175): a MACHINE-GLOBAL filesystem mailbox so parallel sessions reach
4
+ # each other mid-flight — across projects or within one — instead of waiting for a resume.
5
+ # Delivery is hook-driven (see templates/hooks/kit-mail-check.sh.tmpl): PostToolUse injects unread
6
+ # mail between a working session's tool calls (the steer), UserPromptSubmit/SessionStart cover
7
+ # human-driven and cold-start delivery, and Stop blocks a finishing session ONLY for unread
8
+ # --steer messages.
9
+ #
10
+ # msg_send <target> [--steer] <text…> target: <branch> | all (this project)
11
+ # <owner/repo>:<branch> | <owner/repo>:all
12
+ # msg_read [--peek] print + consume this session's unread mail
13
+ # msg_list inventory of every mailbox on this machine
14
+ # msg_hook_check <event> hook driver: emit the event's JSON (silent = no mail)
15
+ #
16
+ # Identity: a session is (project, branch) — project from the git remote slug (owner/repo, the
17
+ # git-remote.sh resolver), branch from HEAD. State lives at ~/.cckit/mail/<project>/<branch>
18
+ # (override root with KIT_MAIL_DIR; "/" encoded as "+" — the worktree-dir precedent). A direct
19
+ # message is read-ONCE (new/ → read/); a broadcast (`all`) is project-scoped, hits each session
20
+ # exactly once via a per-branch seen ledger, and expires after 7 days.
21
+
22
+ # Lazily bring in the shared remote-slug resolver (no-op if the caller already sourced it).
23
+ _msg_source_remote() {
24
+ command -v git_remote_slug >/dev/null 2>&1 && return 0
25
+ local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
26
+ # shellcheck source=/dev/null
27
+ [ -f "$d/git-remote.sh" ] && . "$d/git-remote.sh"
28
+ }
29
+
30
+ _msg_home() { printf '%s' "${KIT_MAIL_DIR:-$HOME/.cckit/mail}"; }
31
+ _msg_encode() { printf '%s' "$1" | tr '/' '+'; }
32
+
33
+ # The invoking session's project id: the remote slug (owner/repo), else the toplevel dir name.
34
+ _msg_proj() {
35
+ _msg_source_remote
36
+ local s=""
37
+ command -v git_remote_slug >/dev/null 2>&1 && s="$(git_remote_slug "$PWD" 2>/dev/null || true)"
38
+ [ -n "$s" ] || s="$(basename "$(git rev-parse --show-toplevel 2>/dev/null || echo no-project)")"
39
+ printf '%s' "$s"
40
+ }
41
+ _msg_branch() { git rev-parse --abbrev-ref HEAD 2>/dev/null; }
42
+
43
+ # _msg_parse <target> — split "[project:]branch-or-all" into PROJ + BOX (current project default).
44
+ _msg_parse() {
45
+ case "$1" in
46
+ *:*) _MSG_PROJ="${1%%:*}"; _MSG_BOX="${1#*:}" ;;
47
+ *) _MSG_PROJ="$(_msg_proj)"; _MSG_BOX="$1" ;;
48
+ esac
49
+ [ -n "$_MSG_PROJ" ] && [ -n "$_MSG_BOX" ]
50
+ }
51
+
52
+ # msg_send <target> [--steer] <text…>
53
+ msg_send() {
54
+ local target="${1:-}"; shift || true
55
+ local steer=0
56
+ [ "${1:-}" = "--steer" ] && { steer=1; shift; }
57
+ local text="$*"
58
+ [ -n "$target" ] && [ -n "$text" ] || { echo 'msg_send: usage: cckit msg send <branch|all|project:branch|project:all> [--steer] "<text>"' >&2; return 1; }
59
+ _msg_parse "$target" || { echo "msg_send: bad target '$target'" >&2; return 1; }
60
+ local from_proj from_branch
61
+ from_proj="$(_msg_proj)"; from_branch="$(_msg_branch)"; from_branch="${from_branch:-unknown}"
62
+ local box="$(_msg_home)/$(_msg_encode "$_MSG_PROJ")/$(_msg_encode "$_MSG_BOX")/new"
63
+ # A typo'd target would silently create a dead mailbox (hcom hard-fails here; we warn) — flag a
64
+ # first-time mailbox so a misaddressed steer doesn't just vanish.
65
+ [ -d "$(dirname "$box")" ] || [ "$_MSG_BOX" = "all" ] \
66
+ || echo " ⚠ new mailbox $_MSG_PROJ:$_MSG_BOX — no session has mail here yet; check the target if you expected one (cckit msg list)" >&2
67
+ mkdir -p "$box" || return 1
68
+ local kind="note"; [ "$steer" = 1 ] && kind="steer"
69
+ # epoch-$$ alone collides for two sends in the same second from one shell — the second message
70
+ # would silently OVERWRITE the first. $RANDOM + an existence check makes the name unique.
71
+ local f
72
+ while :; do
73
+ f="$box/$(date +%s)-$$-${RANDOM}-$kind-from-$(_msg_encode "$from_proj")~$(_msg_encode "$from_branch").md"
74
+ [ -e "$f" ] || break
75
+ done
76
+ {
77
+ printf -- '---\nfrom: %s (%s)\nto: %s:%s\nkind: %s\nsent: %s\n---\n' \
78
+ "$from_branch" "$from_proj" "$_MSG_PROJ" "$_MSG_BOX" "$kind" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
79
+ printf '%s\n' "$text"
80
+ } > "$f" || return 1
81
+ echo " ✓ mail → $_MSG_PROJ:$_MSG_BOX ($kind): $(printf '%.60s' "$text")" >&2
82
+ }
83
+
84
+ # _msg_gc — prune this project's broadcasts older than 7 days (stale ledger entries are harmless).
85
+ _msg_gc() {
86
+ local d="$(_msg_home)/$(_msg_encode "$(_msg_proj)")/all/new"
87
+ [ -d "$d" ] || return 0
88
+ find "$d" -name '*.md' -type f -mtime +7 -delete 2>/dev/null || true
89
+ }
90
+
91
+ # _msg_unread — this session's unread message files (direct new/ + unseen broadcasts), one path
92
+ # per line, oldest first. Consuming is the caller's job (_msg_consume).
93
+ _msg_unread() {
94
+ _msg_gc
95
+ local proj branch pdir seen f base
96
+ proj="$(_msg_encode "$(_msg_proj)")"; branch="$(_msg_encode "$(_msg_branch)")"
97
+ [ -n "$branch" ] || return 0
98
+ pdir="$(_msg_home)/$proj"
99
+ [ -d "$pdir" ] || return 0
100
+ # direct
101
+ ls "$pdir/$branch/new"/*.md 2>/dev/null
102
+ # broadcast: anything in all/new not yet in this branch's seen ledger
103
+ seen="$pdir/.seen/$branch"
104
+ for f in "$pdir/all/new"/*.md; do
105
+ [ -f "$f" ] || continue
106
+ base="$(basename "$f")"
107
+ [ -f "$seen" ] && grep -qxF "$base" "$seen" && continue
108
+ printf '%s\n' "$f"
109
+ done
110
+ }
111
+
112
+ # _msg_consume <file> — mark one message delivered: direct → moved to read/, broadcast → ledgered.
113
+ _msg_consume() {
114
+ local f="$1" pdir branch
115
+ pdir="$(_msg_home)/$(_msg_encode "$(_msg_proj)")"; branch="$(_msg_encode "$(_msg_branch)")"
116
+ case "$f" in
117
+ "$pdir/all/new/"*)
118
+ mkdir -p "$pdir/.seen"
119
+ printf '%s\n' "$(basename "$f")" >> "$pdir/.seen/$branch" ;;
120
+ *)
121
+ mkdir -p "$(dirname "$f")/../read"
122
+ mv "$f" "$(dirname "$f")/../read/" 2>/dev/null || true ;;
123
+ esac
124
+ }
125
+
126
+ # msg_read [--peek] — print unread mail; consume unless --peek.
127
+ msg_read() {
128
+ local peek=0; [ "${1:-}" = "--peek" ] && peek=1
129
+ local any=0 f
130
+ while IFS= read -r f; do
131
+ [ -n "$f" ] || continue
132
+ any=1
133
+ echo "── $(basename "$f")"
134
+ cat "$f"
135
+ [ "$peek" = 1 ] || _msg_consume "$f"
136
+ done <<EOF_UNREAD
137
+ $(_msg_unread)
138
+ EOF_UNREAD
139
+ [ "$any" = 1 ] || echo "no mail for $(_msg_proj):$(_msg_branch)"
140
+ }
141
+
142
+ # msg_list — machine-wide inventory (unread counts per project:mailbox).
143
+ msg_list() {
144
+ local home d n proj
145
+ home="$(_msg_home)"
146
+ [ -d "$home" ] || { echo "no mail yet"; return 0; }
147
+ for d in "$home"/*/*/new; do
148
+ [ -d "$d" ] || continue
149
+ n="$(ls "$d"/*.md 2>/dev/null | wc -l | tr -d ' ')"
150
+ proj="$(basename "$(dirname "$(dirname "$d")")")"
151
+ [ "$n" -gt 0 ] && echo " $proj:$(basename "$(dirname "$d")"): $n unread"
152
+ done
153
+ return 0
154
+ }
155
+
156
+ # _msg_json_escape — minimal JSON string escaping (jq when present, sed fallback).
157
+ _msg_json_escape() {
158
+ if command -v jq >/dev/null 2>&1; then jq -Rs . ; else
159
+ sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' | awk 'BEGIN{printf "\""} {printf "%s\\n", $0} END{printf "\""}'
160
+ fi
161
+ }
162
+
163
+ # msg_hook_check <event> — the hook driver. Silent (exit 0, no output) when there is no mail, so
164
+ # the hook adds zero noise on the hot path. With mail, emits the event's JSON:
165
+ # PostToolUse | UserPromptSubmit | SessionStart | PreToolUse → hookSpecificOutput.additionalContext
166
+ # Stop → decision:block with the mail as reason — ONLY for steer-marked mail (a note never traps
167
+ # a finishing session). KIT_MAIL_STOP_POLL=<seconds> (default 0) makes the Stop pass WAIT
168
+ # that long for a steer to arrive before letting the session end — near-real-time steering
169
+ # of an idle session, no daemon (the hcom long-poll trick, opt-in).
170
+ # Ordering: the JSON is emitted BEFORE the mail is consumed — a hook killed mid-run redelivers
171
+ # instead of losing the message (at-least-once, like hcom's two-phase ack). Delivery is capped at
172
+ # KIT_MAIL_MAX_PER_DELIVERY (default 20) messages per injection; the rest ride the next hook fire.
173
+ msg_hook_check() {
174
+ local event="${1:-}" f body="" steer_only=0 count=0 max="${KIT_MAIL_MAX_PER_DELIVERY:-20}"
175
+ [ -n "$event" ] || { echo "msg_hook_check: <event> required" >&2; return 1; }
176
+ [ "$event" = "Stop" ] && steer_only=1
177
+
178
+ _msg_hook_pick() { # fill _MSG_PICKED + body from current unread (respects steer filter + cap)
179
+ _MSG_PICKED=""
180
+ while IFS= read -r f; do
181
+ [ -n "$f" ] || continue
182
+ [ "$count" -lt "$max" ] || break
183
+ if [ "$steer_only" = 1 ]; then
184
+ case "$(basename "$f")" in *-steer-from-*) : ;; *) continue ;; esac
185
+ fi
186
+ body="$body$(cat "$f")
187
+ "
188
+ _MSG_PICKED="$_MSG_PICKED$f
189
+ "
190
+ count=$((count + 1))
191
+ done <<EOF_UNREAD
192
+ $(_msg_unread)
193
+ EOF_UNREAD
194
+ }
195
+
196
+ _msg_hook_pick
197
+ # Opt-in Stop long-poll: no steer yet → wait up to KIT_MAIL_STOP_POLL seconds for one to land.
198
+ if [ "$count" -eq 0 ] && [ "$event" = "Stop" ] && [ "${KIT_MAIL_STOP_POLL:-0}" -gt 0 ] 2>/dev/null; then
199
+ local waited=0
200
+ while [ "$count" -eq 0 ] && [ "$waited" -lt "${KIT_MAIL_STOP_POLL}" ]; do
201
+ sleep 1; waited=$((waited + 1)); _msg_hook_pick
202
+ done
203
+ fi
204
+ [ "$count" -gt 0 ] || return 0
205
+
206
+ local msg="SESSION MAIL (cckit msg): a parallel session sent you the message(s) below. If one is kind: steer, act on it BEFORE continuing your current plan.
207
+ $body"
208
+ local esc; esc="$(printf '%s' "$msg" | _msg_json_escape)"
209
+ if [ "$event" = "Stop" ]; then
210
+ printf '{"decision":"block","reason":%s}\n' "$esc"
211
+ else
212
+ printf '{"hookSpecificOutput":{"hookEventName":"%s","additionalContext":%s}}\n' "$event" "$esc"
213
+ fi
214
+ # consume AFTER emit (see header) — read the picked list back without a subshell.
215
+ while IFS= read -r f; do
216
+ [ -n "$f" ] && _msg_consume "$f"
217
+ done <<EOF_PICKED
218
+ $_MSG_PICKED
219
+ EOF_PICKED
220
+ }
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # version-bump-test.sh — #173: version-bump.sh --write is the ONE version stamper, and every
4
+ # version surface it owns must agree. The release path (publish.sh) used an inline jq that wrote
5
+ # only cckit.config.json.kitVersion, shipping releases whose .claude-plugin/plugin.json and
6
+ # package.json lagged behind. Guards: (1) vb_write stamps all four files, (2) publish.sh calls the
7
+ # shared bumper (no second implementation), (3) the repo's four version files currently agree.
8
+ # Run: bash scripts/lib/version-bump-test.sh
9
+ set -u
10
+ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
11
+ fail=0
12
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
13
+ command -v jq >/dev/null 2>&1 || { echo "version-bump-test: jq required" >&2; exit 1; }
14
+
15
+ # (1) vb_write stamps every surface — exercised against a throwaway copy of the four files.
16
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
17
+ mkdir -p "$tmp/.claude-plugin" "$tmp/docs-site" "$tmp/scripts/lib"
18
+ echo '{"kitVersion":"0.0.1"}' > "$tmp/cckit.config.json"
19
+ echo '{"version":"0.0.1"}' > "$tmp/.claude-plugin/plugin.json"
20
+ echo '{"version":"0.0.1"}' > "$tmp/package.json"
21
+ echo '{"version":"0.0.1"}' > "$tmp/docs-site/package.json"
22
+ cp "$ROOT/scripts/lib/version-bump.sh" "$tmp/scripts/lib/version-bump.sh"
23
+ (cd "$tmp" && bash scripts/lib/version-bump.sh --write 9.9.9 >/dev/null 2>&1)
24
+ t "vb_write stamps cckit.config.json" "$(jq -r .kitVersion "$tmp/cckit.config.json")" "9.9.9"
25
+ t "vb_write stamps plugin.json" "$(jq -r .version "$tmp/.claude-plugin/plugin.json")" "9.9.9"
26
+ t "vb_write stamps package.json" "$(jq -r .version "$tmp/package.json")" "9.9.9"
27
+ t "vb_write stamps docs-site/package.json" "$(jq -r .version "$tmp/docs-site/package.json")" "9.9.9"
28
+
29
+ # (2) publish.sh delegates to the shared bumper — a reintroduced inline kitVersion jq is the drift.
30
+ t "publish.sh calls version-bump.sh --write" \
31
+ "$(grep -c 'version-bump.sh. --write' "$ROOT/scripts/publish.sh")" "1"
32
+ t "publish.sh has no inline kitVersion bump" \
33
+ "$(grep -c 'kitVersion=' "$ROOT/scripts/publish.sh")" "0"
34
+
35
+ # (3) the repo's four version surfaces agree RIGHT NOW (catches a drifted release after the fact).
36
+ v="$(jq -r .kitVersion "$ROOT/cckit.config.json")"
37
+ t "plugin.json matches kitVersion ($v)" "$(jq -r .version "$ROOT/.claude-plugin/plugin.json")" "$v"
38
+ t "package.json matches kitVersion ($v)" "$(jq -r .version "$ROOT/package.json")" "$v"
39
+ t "docs-site/package.json matches kitVersion ($v)" "$(jq -r .version "$ROOT/docs-site/package.json")" "$v"
40
+
41
+ [ "$fail" -eq 0 ] && echo "ALL OK (version-bump)"
42
+ exit "$fail"
@@ -84,7 +84,7 @@ yes "gc resolves the invoking repo" "$(cat "$GH_REPO_LOG")" "$FIX_REPO"
84
84
  # A new verb that is neither exercised nor listed here fails the harness — forcing a coverage
85
85
  # decision. SKIP holds verbs that mutate, need args, read stdin, are interactive, or act on the
86
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"
87
+ SKIP="adopt autopilot close commands completions contribute copilot debug digest effort encode-context handoff help init install migrate msg orchestrate pr release render resume start ui update version watch"
88
88
  classified() { case " $EXERCISE $SKIP " in *" $1 "*) return 0 ;; *) return 1 ;; esac; }
89
89
  for v in $("$CCKIT" commands); do
90
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; }
@@ -40,12 +40,17 @@ if [ "$PUBLISH" = 1 ]; then
40
40
  command -v gh >/dev/null || { echo "x gh required" >&2; exit 1; }
41
41
  fi
42
42
 
43
- # 1. Stamp version, tag, and cut the GitHub release (creates the tarball).
44
- run bash -c "cd '$root' && command -v jq >/dev/null && jq '.kitVersion=\"$VERSION\"' cckit.config.json > .v.tmp && mv .v.tmp cckit.config.json || true"
43
+ # 1. Stamp the version on ALL FOUR version surfaces via the ONE shared bumper (#173 — an inline jq
44
+ # here used to write only cckit.config.json.kitVersion, shipping releases whose
45
+ # .claude-plugin/plugin.json and package.json lagged behind and made `cckit update` report a
46
+ # version drift on a fully current install), then tag and cut the GitHub release.
47
+ run bash "$root/scripts/lib/version-bump.sh" --write "$VERSION"
45
48
  run git -C "$root" add -A
46
49
  run git -C "$root" commit -m "release: $tag"
47
- run git -C "$root" tag "$tag"
48
- run git -C "$root" push origin main --tags
50
+ # -m makes the tag annotated, which also satisfies tag.gpgsign=true configs — a bare `git tag`
51
+ # aborts there with "fatal: no tag message?" and kills the publish mid-run (#167).
52
+ run git -C "$root" tag -m "$tag" "$tag"
53
+ run git -C "$root" push origin main "$tag"
49
54
  run gh release create "$tag" --repo "$repo" --title "$tag" --generate-notes
50
55
 
51
56
  # 2. Compute the tarball sha256 for the stable Homebrew formula.
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bash
2
+ # kit-mail-check.sh — session-mail delivery hook (#175). Scaffolded by claude-kit.
3
+ # One event-aware script wired to FOUR hook events; it reads the event from the hook's stdin JSON:
4
+ # PostToolUse → unread mail injected between a working session's tool calls (the steer)
5
+ # UserPromptSubmit → delivery on the next human prompt
6
+ # SessionStart → cold-start delivery
7
+ # Stop → blocks the stop ONLY for unread `--steer` mail (redirects a finishing
8
+ # session); mail is consumed on delivery so it can never block twice
9
+ # Silent (no output) when there is no mail — zero noise on the hot path.
10
+ # Send with: cckit msg send <branch|project:branch|all> [--steer] "<text>"
11
+ set -u
12
+ input="$(cat 2>/dev/null || true)"
13
+ event="$(printf '%s' "$input" | jq -r '.hook_event_name // empty' 2>/dev/null || true)"
14
+ [ -n "$event" ] || event="${1:-UserPromptSubmit}"
15
+ # Run from the project the hook fired in (hooks provide cwd; fall back to where we are).
16
+ cwd="$(printf '%s' "$input" | jq -r '.cwd // empty' 2>/dev/null || true)"
17
+ [ -n "$cwd" ] && cd "$cwd" 2>/dev/null
18
+ # Prefer the project's own bin/cckit (version-matched to this checkout — the dogfood case) over
19
+ # the PATH install: a stale PATH cckit without the msg verb would silently no-op delivery (#179).
20
+ kit="cckit"
21
+ [ -x "./bin/cckit" ] && kit="./bin/cckit"
22
+ command -v "$kit" >/dev/null 2>&1 || exit 0
23
+ "$kit" msg hook-check "$event" 2>/dev/null || true
24
+ exit 0
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # claude-kit terminal identity — the seed-head sigil, brand palette, glyph vocabulary.
3
- # Canonical brief: claude-kit terminal identity (kit docs; see cckit.vercel.app:
3
+ # Canonical brief: claude-kit terminal identity (kit docs; see cckit.dev:
4
4
  # apps/admin/src/plans/terminal-identity brief) #
5
5
  # The line-leader is the LOCKED seed-head: ⡶ (U+2876) in Azafrán — the n=13 Vogel
6
6
  # seed-head reduced to one Braille cell. One Azafrán per line: the seed only;