claude-code-kanban 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/cli.js +10 -5
- package/install.js +43 -123
- package/lib/approvals.js +16 -17
- package/lib/git-branch.js +47 -0
- package/lib/parsers.js +96 -59
- package/lib/plugin-status.js +1 -1
- package/lib/session-cache.js +1 -1
- package/lib/terminal.js +2 -1
- package/package.json +1 -2
- package/plugin/.claude-plugin/marketplace.json +1 -1
- package/plugin/plugins/claude-code-kanban/.claude-plugin/plugin.json +2 -2
- package/plugin/plugins/claude-code-kanban/hooks/activity.ts +266 -0
- package/plugin/plugins/claude-code-kanban/hooks/context.ts +77 -0
- package/plugin/plugins/claude-code-kanban/hooks/hooks.json +1 -93
- package/plugin/plugins/claude-code-kanban/hooks/index.ts +8 -0
- package/plugin/plugins/claude-code-kanban/scripts/postman.js +4 -4
- package/plugin/plugins/claude-code-kanban/tests/activity.test.ts +300 -0
- package/plugin/plugins/claude-code-kanban/tests/context.test.ts +72 -0
- package/plugin/plugins/claude-code-kanban/tsconfig.json +3 -0
- package/public/app.js +8 -8
- package/server.js +106 -95
- package/plugin/plugins/claude-code-kanban/scripts/agent-spy.sh +0 -135
- package/plugin/plugins/claude-code-kanban/scripts/approval-gate.sh +0 -208
- package/plugin/plugins/claude-code-kanban/scripts/context-status.sh +0 -18
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Blocking approval gate: lets the cck board answer a permission ask or an
|
|
3
|
-
# AskUserQuestion. Always writes the _waiting.json marker first (badge behavior
|
|
4
|
-
# is unchanged when the feature is off), then — unless config.json opts out, and
|
|
5
|
-
# only while the board's server is alive — waits for a decision file written by the server.
|
|
6
|
-
#
|
|
7
|
-
# Contract (_plans/cck-ui-approvals/decisions.md), rooted at <CLAUDE_CONFIG_DIR or ~/.claude>/.cck:
|
|
8
|
-
# marker agent-activity/<sid>/_waiting.json (D8: + id, cwd, permissionSuggestions)
|
|
9
|
-
# decision agent-activity/<sid>/_decision-<id>.json (server writes it, Phase 3)
|
|
10
|
-
# config config.json {approvals: {enabled, mode, waitSeconds}} (on by default; absent = defaults)
|
|
11
|
-
# liveness server.json {port, pid} (D1: a dead board costs nothing)
|
|
12
|
-
#
|
|
13
|
-
# First writer wins (D5): a terminal answer deletes the marker (this gate, via
|
|
14
|
-
# the session registry, or PostToolUse) and this gate exits silently; a decision arriving after the tool already ran
|
|
15
|
-
# is discarded by Claude Code, so a losing write on either side is harmless.
|
|
16
|
-
|
|
17
|
-
INPUT=$(cat)
|
|
18
|
-
|
|
19
|
-
eval "$(echo "$INPUT" | jq -r '
|
|
20
|
-
@sh "SESSION_ID=\(.session_id // "")",
|
|
21
|
-
@sh "EVENT=\(.hook_event_name // "")",
|
|
22
|
-
@sh "TOOL_NAME=\(.tool_name // "")"
|
|
23
|
-
')"
|
|
24
|
-
|
|
25
|
-
[ -z "$SESSION_ID" ] && exit 0
|
|
26
|
-
|
|
27
|
-
# AskUserQuestion and ExitPlanMode gate on PermissionRequest, not PreToolUse:
|
|
28
|
-
# the TUI question and plan dialogs render ~10 s in while a PermissionRequest
|
|
29
|
-
# hook blocks (first writer wins, like permissions), but stay frozen for the
|
|
30
|
-
# whole wait during a PreToolUse hook — measured live (#42, #40). Suppress the
|
|
31
|
-
# PreToolUse double-fire in case a stale hooks.json still registers it.
|
|
32
|
-
if [ "$EVENT" = "PreToolUse" ]; then
|
|
33
|
-
exit 0
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
KIND="permission"
|
|
37
|
-
[ "$TOOL_NAME" = "AskUserQuestion" ] && KIND="question"
|
|
38
|
-
[ "$TOOL_NAME" = "ExitPlanMode" ] && KIND="plan"
|
|
39
|
-
|
|
40
|
-
CCK_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.cck"
|
|
41
|
-
DIR="$CCK_DIR/agent-activity/$SESSION_ID"
|
|
42
|
-
MARKER="$DIR/_waiting.json"
|
|
43
|
-
mkdir -p "$DIR"
|
|
44
|
-
|
|
45
|
-
# uuidgen is missing on some Git Bash installs; uniqueness only has to hold
|
|
46
|
-
# across the asks of one session, so a timestamp compound is enough
|
|
47
|
-
REQ_ID=$(uuidgen 2>/dev/null) || REQ_ID="$(date +%s%N)-$$-$RANDOM"
|
|
48
|
-
|
|
49
|
-
TS=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
50
|
-
echo "$INPUT" | jq -c --arg kind "$KIND" --arg ts "$TS" --arg id "$REQ_ID" '{
|
|
51
|
-
status: "waiting",
|
|
52
|
-
kind: $kind,
|
|
53
|
-
id: $id,
|
|
54
|
-
toolName: (.tool_name // "unknown"),
|
|
55
|
-
toolInput: ((.tool_input | tostring) // ""),
|
|
56
|
-
cwd: (.cwd // ""),
|
|
57
|
-
permissionSuggestions: (.permission_suggestions // []),
|
|
58
|
-
timestamp: $ts
|
|
59
|
-
}' > "$MARKER"
|
|
60
|
-
|
|
61
|
-
# Every exit below leaves the marker in place for the badge; agent-spy.sh's
|
|
62
|
-
# PostToolUse (or the server's TTL) retires it, exactly as before this feature.
|
|
63
|
-
|
|
64
|
-
# Defaults mirror lib/approvals.js — keep in sync. A missing or unparseable
|
|
65
|
-
# config.json means defaults, i.e. the gate is on.
|
|
66
|
-
ENABLED="true"
|
|
67
|
-
MODE="permission+question"
|
|
68
|
-
WAIT_SECONDS=""
|
|
69
|
-
CONFIG="$CCK_DIR/config.json"
|
|
70
|
-
if [ -f "$CONFIG" ]; then
|
|
71
|
-
eval "$(jq -r '
|
|
72
|
-
@sh "ENABLED=\(if .approvals.enabled == false then "false" else "true" end)",
|
|
73
|
-
@sh "MODE=\(.approvals.mode // "permission+question")",
|
|
74
|
-
@sh "WAIT_SECONDS=\(.approvals.waitSeconds // "")"
|
|
75
|
-
' < "$CONFIG" 2>/dev/null)"
|
|
76
|
-
fi
|
|
77
|
-
[ "$ENABLED" = "false" ] && exit 0
|
|
78
|
-
|
|
79
|
-
if [ "$KIND" = "question" ] && [ "$MODE" != "permission+question" ]; then
|
|
80
|
-
exit 0
|
|
81
|
-
fi
|
|
82
|
-
|
|
83
|
-
case "$WAIT_SECONDS" in *[!0-9]* | "") WAIT_SECONDS=1800 ;; esac
|
|
84
|
-
# PERMISSION_TTL_MS hides the card at 30 min — waiting longer than the UI can
|
|
85
|
-
# show the ask is strictly worse than giving up (D11)
|
|
86
|
-
[ "$WAIT_SECONDS" -gt 1800 ] && WAIT_SECONDS=1800
|
|
87
|
-
|
|
88
|
-
SERVER_INFO="$CCK_DIR/server.json"
|
|
89
|
-
|
|
90
|
-
# A TCP connect beats a pid probe: it proves the board is actually serving, and
|
|
91
|
-
# it works in the stripped environment Claude Code spawns hooks into, where
|
|
92
|
-
# kill -0 cannot see native Windows pids and ps may be missing from PATH. The
|
|
93
|
-
# port is re-read on every probe, not cached: under the hub every sub-app binds
|
|
94
|
-
# an ephemeral port, so a board that restarts mid-wait comes back on a new one.
|
|
95
|
-
# $(<file) and =~ keep the probe free of jq and cat spawns (~280 ms each here).
|
|
96
|
-
board_alive() {
|
|
97
|
-
local raw port
|
|
98
|
-
raw=$(<"$SERVER_INFO") 2>/dev/null || return 1
|
|
99
|
-
[[ $raw =~ \"port\"[[:space:]]*:[[:space:]]*([0-9]+) ]] || return 1
|
|
100
|
-
port=${BASH_REMATCH[1]}
|
|
101
|
-
(: < "/dev/tcp/127.0.0.1/$port") 2>/dev/null
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
DECISION="$DIR/_decision-$REQ_ID.json"
|
|
105
|
-
# EPOCHSECONDS (bash 5) keeps the poll loop free of `date` spawns
|
|
106
|
-
DEADLINE=$((EPOCHSECONDS + WAIT_SECONDS))
|
|
107
|
-
# Probing once up front made one unreachable moment disarm the whole ask, so a
|
|
108
|
-
# board restarting on a new port (every hub-spawned sub-app binds an ephemeral
|
|
109
|
-
# one) took the ask with it. Probe on a cadence instead and only give up once
|
|
110
|
-
# the board has been gone for the whole grace. The terminal prompt stays live
|
|
111
|
-
# throughout either way.
|
|
112
|
-
BOARD_PROBE_SECONDS=5
|
|
113
|
-
BOARD_GRACE_SECONDS=15
|
|
114
|
-
NEXT_PROBE=0
|
|
115
|
-
UNREACHABLE_SINCE=0
|
|
116
|
-
|
|
117
|
-
# Claude Code's live-session registry flips from "waiting" the moment the
|
|
118
|
-
# terminal prompt is answered, while PostToolUse waits for the tool to finish
|
|
119
|
-
# and never fires on a deny. Undocumented, so a missing file or field leaves
|
|
120
|
-
# PostToolUse in charge, as before.
|
|
121
|
-
SESSIONS_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/sessions"
|
|
122
|
-
REGISTRY=""
|
|
123
|
-
SEEN_WAITING=0
|
|
124
|
-
find_registry() {
|
|
125
|
-
local f raw
|
|
126
|
-
for f in "$SESSIONS_DIR"/*.json; do
|
|
127
|
-
[ -f "$f" ] || continue
|
|
128
|
-
raw=""
|
|
129
|
-
IFS= read -r raw 2>/dev/null < "$f"
|
|
130
|
-
case "$raw" in *"\"sessionId\":\"$SESSION_ID\""*) REGISTRY=$f; return 0 ;; esac
|
|
131
|
-
done
|
|
132
|
-
return 1
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
while :; do
|
|
136
|
-
if [ -f "$DECISION" ]; then
|
|
137
|
-
PAYLOAD=$(cat "$DECISION" 2>/dev/null)
|
|
138
|
-
rm -f "$DECISION" "$MARKER"
|
|
139
|
-
[ -n "$PAYLOAD" ] || exit 0
|
|
140
|
-
if [ "$KIND" = "plan" ] && [ "$(echo "$PAYLOAD" | jq -r '.behavior // "deny"' 2>/dev/null)" = "allow" ]; then
|
|
141
|
-
# A plan allow must echo tool_input as updatedInput — Claude Code
|
|
142
|
-
# >= 2.1.199 silently drops an ExitPlanMode allow without it and falls
|
|
143
|
-
# back to the built-in dialog (measured; plannotator does the same).
|
|
144
|
-
echo "$INPUT" | jq -c --argjson p "$PAYLOAD" \
|
|
145
|
-
'{hookSpecificOutput: {hookEventName: "PermissionRequest",
|
|
146
|
-
decision: ({behavior: "allow", updatedInput: (.tool_input // {})}
|
|
147
|
-
+ (if $p.updatedPermissions then {updatedPermissions: $p.updatedPermissions} else {} end))}}' 2>/dev/null
|
|
148
|
-
elif [ "$KIND" != "question" ]; then
|
|
149
|
-
# Permission asks and plan denies share this shaping — the server sends
|
|
150
|
-
# only behavior+message for a plan deny. PermissionRequest decisions must
|
|
151
|
-
# ride hookSpecificOutput — a top-level {decision} is the approve/block
|
|
152
|
-
# string channel and an object there throws
|
|
153
|
-
echo "$PAYLOAD" | jq -c '{hookSpecificOutput: {hookEventName: "PermissionRequest",
|
|
154
|
-
decision: ({behavior: (.behavior // "deny")}
|
|
155
|
-
+ (if .message then {message: .message} else {} end)
|
|
156
|
-
+ (if .updatedInput then {updatedInput: .updatedInput} else {} end)
|
|
157
|
-
+ (if .updatedPermissions then {updatedPermissions: .updatedPermissions} else {} end))}}' 2>/dev/null
|
|
158
|
-
else
|
|
159
|
-
# updatedInput replaces the whole input object, so echo every field and
|
|
160
|
-
# add the answers Claude never fills in itself (D6). Questions ride the
|
|
161
|
-
# PermissionRequest channel now (#42) — allow with the answers filled in.
|
|
162
|
-
ANSWERS=$(echo "$PAYLOAD" | jq -c '.answers // empty' 2>/dev/null)
|
|
163
|
-
[ -n "$ANSWERS" ] || exit 0
|
|
164
|
-
echo "$INPUT" | jq -c --argjson answers "$ANSWERS" \
|
|
165
|
-
'{hookSpecificOutput: {hookEventName: "PermissionRequest",
|
|
166
|
-
decision: {behavior: "allow", updatedInput: ((.tool_input // {}) + {answers: $answers})}}}' 2>/dev/null
|
|
167
|
-
fi
|
|
168
|
-
exit 0
|
|
169
|
-
fi
|
|
170
|
-
|
|
171
|
-
# Marker gone = answered in the terminal (PostToolUse fires ~23 ms after — D5);
|
|
172
|
-
# id changed = displaced by a newer ask (D8). Either way this gate is over.
|
|
173
|
-
# Builtin read + substring match instead of jq: a spawn costs ~280 ms on
|
|
174
|
-
# Windows (O2), and the marker is single-line jq -c output with a known id.
|
|
175
|
-
IFS= read -r CUR_MARKER < "$MARKER" 2>/dev/null || exit 0
|
|
176
|
-
case "$CUR_MARKER" in *"\"id\":\"$REQ_ID\""*) ;; *) exit 0 ;; esac
|
|
177
|
-
|
|
178
|
-
if [ -n "$REGISTRY" ]; then
|
|
179
|
-
REG_RAW=""
|
|
180
|
-
IFS= read -r REG_RAW 2>/dev/null < "$REGISTRY"
|
|
181
|
-
if [[ $REG_RAW =~ \"status\":\"([a-z]+)\" ]]; then
|
|
182
|
-
if [ "${BASH_REMATCH[1]}" = "waiting" ]; then
|
|
183
|
-
SEEN_WAITING=1
|
|
184
|
-
elif [ "$SEEN_WAITING" -eq 1 ]; then
|
|
185
|
-
rm -f "$MARKER"
|
|
186
|
-
exit 0
|
|
187
|
-
fi
|
|
188
|
-
fi
|
|
189
|
-
fi
|
|
190
|
-
|
|
191
|
-
if [ "$EPOCHSECONDS" -ge "$NEXT_PROBE" ]; then
|
|
192
|
-
NEXT_PROBE=$((EPOCHSECONDS + BOARD_PROBE_SECONDS))
|
|
193
|
-
[ -n "$REGISTRY" ] || find_registry
|
|
194
|
-
# No beacon at all = no board on this config dir, now or a moment ago: give
|
|
195
|
-
# up at once, exactly as before. A beacon whose port is closed is the
|
|
196
|
-
# restart window instead, so that one gets the grace.
|
|
197
|
-
[ -f "$SERVER_INFO" ] || exit 0
|
|
198
|
-
if board_alive; then
|
|
199
|
-
UNREACHABLE_SINCE=0
|
|
200
|
-
else
|
|
201
|
-
[ "$UNREACHABLE_SINCE" -eq 0 ] && UNREACHABLE_SINCE=$EPOCHSECONDS
|
|
202
|
-
[ $((EPOCHSECONDS - UNREACHABLE_SINCE)) -ge "$BOARD_GRACE_SECONDS" ] && exit 0
|
|
203
|
-
fi
|
|
204
|
-
fi
|
|
205
|
-
|
|
206
|
-
[ "$EPOCHSECONDS" -ge "$DEADLINE" ] && exit 0
|
|
207
|
-
sleep 0.5
|
|
208
|
-
done
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Statusline spy: writes raw context data for kanban dashboard, passes input through
|
|
3
|
-
# Layout: <CLAUDE_CONFIG_DIR or ~/.claude>/.cck/context-status/{sessionId}.json
|
|
4
|
-
#
|
|
5
|
-
# Usage: pipe before your statusline command:
|
|
6
|
-
# "command": "~/.claude/hooks/context-status.sh | npx -y ccstatusline@latest"
|
|
7
|
-
|
|
8
|
-
INPUT=$(cat)
|
|
9
|
-
|
|
10
|
-
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // ""')
|
|
11
|
-
if [ -n "$SESSION_ID" ]; then
|
|
12
|
-
DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}/.cck/context-status"
|
|
13
|
-
mkdir -p "$DIR"
|
|
14
|
-
echo "$INPUT" > "$DIR/$SESSION_ID.json"
|
|
15
|
-
fi
|
|
16
|
-
|
|
17
|
-
# Pass through original input for downstream statusline
|
|
18
|
-
echo "$INPUT"
|