claude-code-kanban 7.32.0 → 7.34.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/cli.js +12 -2
- package/hub-app.json +8 -1
- package/lib/parsers.js +0 -43
- package/lib/program-status.js +194 -0
- package/lib/reveal.js +30 -0
- package/lib/terminal-client.js +13 -1
- package/lib/terminal-host.js +3 -0
- package/lib/terminal.js +82 -11
- package/package.json +1 -1
- package/plugin/plugins/claude-code-kanban/.claude-plugin/plugin.json +1 -1
- package/plugin/plugins/claude-code-kanban/skills/kanban/SKILL.md +4 -0
- package/public/app.js +394 -172
- package/public/index.html +4 -2
- package/public/style.css +107 -11
- package/public/terminal-frame.js +55 -5
- package/server.js +75 -126
- package/lib/scratch-servers.js +0 -119
package/cli.js
CHANGED
|
@@ -68,7 +68,7 @@ const COMMANDS = {
|
|
|
68
68
|
summary: 'Add a pane to a session; it opens as a tab next to Board, in the background',
|
|
69
69
|
usage: 'claude-code-kanban pane add <url|file> | --shell [<folder>] [--run <cmd>] [--title <text>] [--session <id>] [--json]',
|
|
70
70
|
flags: {
|
|
71
|
-
'<url|file>': 'An http(s) URL,
|
|
71
|
+
'<url|file>': 'An http(s) URL, a local HTML, markdown, text or image file, or a scratchpad (its folder or scratchpad.json; needs the scratch CLI). Relative paths resolve against the current dir',
|
|
72
72
|
'--shell [<folder>]': 'A plain shell (the terminal shell, no claude) in <folder> (default: the current dir). Needs the board\'s terminal. Each add opens a new shell; closing the pane ends it',
|
|
73
73
|
'--run <cmd>': 'With --shell: a one-line command the shell runs when it starts, and again on each restart',
|
|
74
74
|
'--title <text>': 'Tab title (default: the host or file name)',
|
|
@@ -806,6 +806,13 @@ const cliTarget = (arg) => linkUrl(arg) || cliPath(arg);
|
|
|
806
806
|
|
|
807
807
|
const PANES_WHY = 'panes are stored per session.';
|
|
808
808
|
|
|
809
|
+
function scratchpadTarget(arg) {
|
|
810
|
+
if (linkUrl(arg)) return null;
|
|
811
|
+
const abs = cliPath(arg);
|
|
812
|
+
if (path.basename(abs).toLowerCase() === 'scratchpad.json') return abs;
|
|
813
|
+
return fs.existsSync(path.join(abs, 'scratchpad.json')) ? abs : null;
|
|
814
|
+
}
|
|
815
|
+
|
|
809
816
|
const panesPath = (sessionId, paneId) =>
|
|
810
817
|
`/api/panes/${encodeURIComponent(sessionId)}${paneId ? `/${encodeURIComponent(paneId)}` : ''}`;
|
|
811
818
|
|
|
@@ -822,9 +829,12 @@ async function runPaneAddCli(args, entry) {
|
|
|
822
829
|
if (!resolved) return 1;
|
|
823
830
|
try {
|
|
824
831
|
const title = getArgValue(args, 'title') || '';
|
|
832
|
+
const pad = shell ? null : scratchpadTarget(target);
|
|
825
833
|
const body = shell
|
|
826
834
|
? { kind: 'shell', target: canonicalDir(target || '.'), title, ...(run && { run }) }
|
|
827
|
-
:
|
|
835
|
+
: pad
|
|
836
|
+
? { kind: 'scratchpad', target: pad, title }
|
|
837
|
+
: { target: cliTarget(target), title };
|
|
828
838
|
const out = await cliPostJson(panesPath(resolved.id), body, 'Pane add');
|
|
829
839
|
if (!out) return 1;
|
|
830
840
|
const { pane } = out;
|
package/hub-app.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "Kanban",
|
|
5
5
|
"icon": "columns",
|
|
6
6
|
"run": { "entry": "server.js", "defaultPort": 3541 },
|
|
7
|
-
"publishes": ["session.changed", "voice.context"],
|
|
7
|
+
"publishes": ["session.changed", "voice.context", "attention.changed"],
|
|
8
8
|
"actions": {
|
|
9
9
|
"handles": {
|
|
10
10
|
"session.open": { "params": { "session": "string" }, "mode": "message" },
|
|
@@ -54,6 +54,13 @@
|
|
|
54
54
|
],
|
|
55
55
|
"default": "dots"
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
"key": "cardStatus",
|
|
59
|
+
"type": "boolean",
|
|
60
|
+
"label": "Live status on session cards",
|
|
61
|
+
"help": "Shows what a session in the board's terminal reports it is doing, such as its message and progress, in the card's footer in place of the time.",
|
|
62
|
+
"default": true
|
|
63
|
+
},
|
|
57
64
|
{
|
|
58
65
|
"key": "terminalHost",
|
|
59
66
|
"type": "choice",
|
package/lib/parsers.js
CHANGED
|
@@ -1658,48 +1658,6 @@ async function readArtifactLinks(jsonlPath) {
|
|
|
1658
1658
|
return [...byUrl.values()].sort((x, y) => (x.firstSeen < y.firstSeen ? -1 : x.firstSeen > y.firstSeen ? 1 : 0));
|
|
1659
1659
|
}
|
|
1660
1660
|
|
|
1661
|
-
const SCRATCH_NEW_RE = /\bscratch new\b/;
|
|
1662
|
-
// `scratch new` reports where it put the pad; the two spaces are the CLI's own column
|
|
1663
|
-
// padding, which is what makes the prefilter below narrow enough to be worth having.
|
|
1664
|
-
const SCRATCH_MANIFEST_RE = /^\s*manifest\s*:\s*(.+?)\s*$/m;
|
|
1665
|
-
// The name must sit immediately after `new`, and the bare-word branch must refuse a
|
|
1666
|
-
// leading `-`, so that a flag or a flag's value cannot be read as the name.
|
|
1667
|
-
const SCRATCH_NAME_RE = /\bscratch\s+new\s+(?:"([^"]+)"|'([^']+)'|(?!-)(\S+))/;
|
|
1668
|
-
|
|
1669
|
-
// The `scratch new` calls in a transcript, `{ ts, path, name }` per call. `path` is null
|
|
1670
|
-
// whenever the command piped the CLI's output away — the common case, not an edge one:
|
|
1671
|
-
// the manifest is the 4th of ~13 printed lines, so any `| tail -N` cuts it off. `name`
|
|
1672
|
-
// stands in because it is what the manifest stores as its own `name`; the path is not
|
|
1673
|
-
// recovered from the command, which would mean tracking the `cd` and a relative `--dir`.
|
|
1674
|
-
async function readScratchpadCreations(jsonlPath) {
|
|
1675
|
-
const calls = new Map();
|
|
1676
|
-
try {
|
|
1677
|
-
for await (const line of readLines(jsonlPath)) {
|
|
1678
|
-
// Substring reject before JSON.parse: transcripts reach tens of megabytes and
|
|
1679
|
-
// only a handful of lines can ever match.
|
|
1680
|
-
const isCall = line.includes('scratch new');
|
|
1681
|
-
if (!isCall && !line.includes('manifest :')) continue;
|
|
1682
|
-
let obj;
|
|
1683
|
-
try { obj = JSON.parse(line); } catch (_) { continue; }
|
|
1684
|
-
const blocks = obj?.message?.content;
|
|
1685
|
-
if (!Array.isArray(blocks)) continue;
|
|
1686
|
-
const ts = Date.parse(obj.timestamp);
|
|
1687
|
-
for (const b of blocks) {
|
|
1688
|
-
if (b?.type === 'tool_use' && b.name === 'Bash' && SCRATCH_NEW_RE.test(b.input?.command || '')) {
|
|
1689
|
-
if (b.id && Number.isFinite(ts)) {
|
|
1690
|
-
const named = SCRATCH_NAME_RE.exec(b.input.command);
|
|
1691
|
-
calls.set(b.id, { ts, path: null, name: named?.slice(1).find(Boolean) ?? null });
|
|
1692
|
-
}
|
|
1693
|
-
} else if (b?.type === 'tool_result' && calls.has(b.tool_use_id)) {
|
|
1694
|
-
const m = SCRATCH_MANIFEST_RE.exec(toolResultText(b.content));
|
|
1695
|
-
if (m) calls.get(b.tool_use_id).path = m[1];
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
} catch (_) {}
|
|
1700
|
-
return [...calls.values()];
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
1661
|
async function readCompactSummaries(jsonlPath) {
|
|
1704
1662
|
const results = [];
|
|
1705
1663
|
// Inline format: newer Claude Code stores the summary directly in the parent
|
|
@@ -2137,7 +2095,6 @@ module.exports = {
|
|
|
2137
2095
|
readCompactSummaries,
|
|
2138
2096
|
fillCompactSummaries,
|
|
2139
2097
|
readArtifactLinks,
|
|
2140
|
-
readScratchpadCreations,
|
|
2141
2098
|
findTerminatedTeammates,
|
|
2142
2099
|
extractPromptFromTranscript,
|
|
2143
2100
|
extractModelFromTranscript,
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Program Status Protocol, OSC 7501, revision 0.4:
|
|
4
|
+
// https://www.superlogical.com/rex/docs/build/program-status
|
|
5
|
+
// A program in the terminal reports what it is doing; claude-code sends it once the
|
|
6
|
+
// terminal answers the feature query. Every report is untrusted input.
|
|
7
|
+
|
|
8
|
+
const OSC_CODE = 7501;
|
|
9
|
+
const QUERY_REPLY = '\x1b]7501;?\x1b\\';
|
|
10
|
+
const STATES = new Set(['idle', 'working', 'done', 'blocked', 'error']);
|
|
11
|
+
const KINDS = new Set(['permission', 'question', 'auth']);
|
|
12
|
+
const TRANSIENT = new Set(['working', 'blocked']);
|
|
13
|
+
const FINISH = new Set(['done', 'error']);
|
|
14
|
+
const ATTENTION = { blocked: 4, working: 3, error: 2, done: 2, idle: 1 };
|
|
15
|
+
|
|
16
|
+
const MAX_SEQUENCE = 4096;
|
|
17
|
+
const MAX_KEY = 16;
|
|
18
|
+
const MAX_RECORDS = 256;
|
|
19
|
+
const MAX_ID = 128;
|
|
20
|
+
const MAX_DEPTH = 8;
|
|
21
|
+
const TEXT_LIMITS = { msg: [2732, 2048], title: [256, 192] };
|
|
22
|
+
|
|
23
|
+
const KEY_RE = /^[a-z]+$/;
|
|
24
|
+
const VALUE_RE = /^[A-Za-z0-9_.,+/=-]*$/;
|
|
25
|
+
const SEGMENT_RE = /^[A-Za-z0-9_.+-]{1,32}$/;
|
|
26
|
+
const APP_RE = /^[A-Za-z0-9_.+-]{1,32}$/;
|
|
27
|
+
const BASE64_RE = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
28
|
+
const PROGRESS_RE = /^(?:100|[1-9]?\d)$/;
|
|
29
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: the spec refuses C0, DEL and C1 in decoded text
|
|
30
|
+
const CONTROL_RE = /[\u0000-\u001f\u007f-\u009f]/;
|
|
31
|
+
const utf8 = new TextDecoder('utf-8', { fatal: true });
|
|
32
|
+
|
|
33
|
+
// The spec asks a terminal to disarm bidi overrides and invisible format characters before it shows a msg.
|
|
34
|
+
const FORMAT_RE = /[---]/g;
|
|
35
|
+
const SHOWN_MSG = 160;
|
|
36
|
+
|
|
37
|
+
function shownText(text) {
|
|
38
|
+
const clean = text.replace(FORMAT_RE, '').trim();
|
|
39
|
+
return clean.length > SHOWN_MSG ? `${clean.slice(0, SHOWN_MSG - 1)}…` : clean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function decodeText(value, [maxEncoded, maxDecoded]) {
|
|
43
|
+
if (value.length > maxEncoded || !BASE64_RE.test(value) || value.length % 4 === 1) return null;
|
|
44
|
+
let text;
|
|
45
|
+
try {
|
|
46
|
+
text = utf8.decode(Buffer.from(value, 'base64'));
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (Buffer.byteLength(text) > maxDecoded || CONTROL_RE.test(text)) return null;
|
|
51
|
+
return text;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function validId(id) {
|
|
55
|
+
if (id.length > MAX_ID) return false;
|
|
56
|
+
const segments = id.split('/');
|
|
57
|
+
return segments.length <= MAX_DEPTH && segments.every((s) => SEGMENT_RE.test(s));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Null when the spec says to drop the whole report.
|
|
61
|
+
function parseReport(data) {
|
|
62
|
+
if (Buffer.byteLength(data) > MAX_SEQUENCE) return null;
|
|
63
|
+
const pairs = {};
|
|
64
|
+
for (const raw of data.split(':')) {
|
|
65
|
+
const eq = raw.indexOf('=');
|
|
66
|
+
if (eq < 0) continue;
|
|
67
|
+
const key = raw.slice(0, eq).trim();
|
|
68
|
+
const value = raw.slice(eq + 1).trim();
|
|
69
|
+
if (!key || key.length > MAX_KEY || !KEY_RE.test(key) || !VALUE_RE.test(value)) continue;
|
|
70
|
+
pairs[key] = value;
|
|
71
|
+
}
|
|
72
|
+
const state = pairs.state;
|
|
73
|
+
if (state !== 'clear' && !STATES.has(state)) return null;
|
|
74
|
+
const id = pairs.id ?? '';
|
|
75
|
+
if (pairs.id !== undefined && !validId(id)) return null;
|
|
76
|
+
const report = { state, id };
|
|
77
|
+
for (const key of ['msg', 'title']) {
|
|
78
|
+
if (pairs[key] === undefined) continue;
|
|
79
|
+
const text = decodeText(pairs[key], TEXT_LIMITS[key]);
|
|
80
|
+
if (text === null) return null;
|
|
81
|
+
report[key] = text;
|
|
82
|
+
}
|
|
83
|
+
if (pairs.app !== undefined && APP_RE.test(pairs.app)) report.app = pairs.app;
|
|
84
|
+
if (state === 'blocked' && KINDS.has(pairs.kind)) report.kind = pairs.kind;
|
|
85
|
+
if (TRANSIENT.has(state) && PROGRESS_RE.test(pairs.progress ?? '')) report.progress = Number(pairs.progress);
|
|
86
|
+
return report;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const isUnder = (id, parent) => !parent || id === parent || id.startsWith(`${parent}/`);
|
|
90
|
+
|
|
91
|
+
function parentOf(id) {
|
|
92
|
+
if (!id) return null;
|
|
93
|
+
const slash = id.lastIndexOf('/');
|
|
94
|
+
return slash < 0 ? '' : id.slice(0, slash);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function createProgramStatus() {
|
|
98
|
+
const records = new Map();
|
|
99
|
+
let seq = 0;
|
|
100
|
+
// The user opened the session after its last done or error; a new one is unseen again.
|
|
101
|
+
let seen = false;
|
|
102
|
+
|
|
103
|
+
function appOf(id) {
|
|
104
|
+
for (let at = id; at !== null; at = parentOf(at)) {
|
|
105
|
+
const app = records.get(at)?.app;
|
|
106
|
+
if (app) return app;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function summary() {
|
|
112
|
+
let best = null;
|
|
113
|
+
for (const [id, r] of records) {
|
|
114
|
+
const rank = ATTENTION[r.state];
|
|
115
|
+
if (!best || rank > best.rank || (rank === best.rank && r.seq > best.r.seq)) best = { id, r, rank };
|
|
116
|
+
}
|
|
117
|
+
if (!best) return null;
|
|
118
|
+
const { r, id } = best;
|
|
119
|
+
const out = {
|
|
120
|
+
state: r.state,
|
|
121
|
+
kind: r.kind || null,
|
|
122
|
+
app: appOf(id),
|
|
123
|
+
msg: r.msg || null,
|
|
124
|
+
};
|
|
125
|
+
if (seen && FINISH.has(r.state)) out.seen = true;
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function apply(report) {
|
|
130
|
+
if (report.state === 'clear') {
|
|
131
|
+
for (const id of [...records.keys()]) if (isUnder(id, report.id)) records.delete(id);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (FINISH.has(report.state)) seen = false;
|
|
135
|
+
records.delete(report.id);
|
|
136
|
+
if (records.size >= MAX_RECORDS) records.delete(records.keys().next().value);
|
|
137
|
+
const { id, ...rest } = report;
|
|
138
|
+
if (rest.msg) rest.msg = shownText(rest.msg);
|
|
139
|
+
records.set(id, { ...rest, seq: ++seq });
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function dropWhere(test) {
|
|
143
|
+
for (const [id, r] of records) if (test(r)) records.delete(id);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function track(fn) {
|
|
147
|
+
const before = JSON.stringify(summary());
|
|
148
|
+
fn();
|
|
149
|
+
return JSON.stringify(summary()) !== before;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
handle(data) {
|
|
154
|
+
if (data === '?') return 'query';
|
|
155
|
+
const report = parseReport(data);
|
|
156
|
+
return report ? track(() => apply(report)) : false;
|
|
157
|
+
},
|
|
158
|
+
dropTransient: () => track(() => dropWhere((r) => TRANSIENT.has(r.state))),
|
|
159
|
+
reset: () =>
|
|
160
|
+
track(() => {
|
|
161
|
+
records.clear();
|
|
162
|
+
seen = false;
|
|
163
|
+
}),
|
|
164
|
+
markSeen: () =>
|
|
165
|
+
track(() => {
|
|
166
|
+
seen = true;
|
|
167
|
+
}),
|
|
168
|
+
summary,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: the query is an escape sequence
|
|
173
|
+
const QUERY_RE = /\x1b\]7501;\?(?:\x07|\x1b\\)/g;
|
|
174
|
+
const QUERY_TAIL = 9;
|
|
175
|
+
|
|
176
|
+
// Counts the queries in raw PTY output as it arrives, across chunk borders.
|
|
177
|
+
function createQueryScanner() {
|
|
178
|
+
let tail = '';
|
|
179
|
+
return (data) => {
|
|
180
|
+
const text = tail + data;
|
|
181
|
+
let count = 0;
|
|
182
|
+
let end = 0;
|
|
183
|
+
if (text.includes('\x1b]7501;?')) {
|
|
184
|
+
for (const m of text.matchAll(QUERY_RE)) {
|
|
185
|
+
count++;
|
|
186
|
+
end = m.index + m[0].length;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
tail = text.slice(Math.max(end, text.length - QUERY_TAIL));
|
|
190
|
+
return count;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
module.exports = { OSC_CODE, QUERY_REPLY, parseReport, createProgramStatus, createQueryScanner };
|
package/lib/reveal.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { spawn } = require('node:child_process');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The command that shows an already-validated absolute path in the OS file manager:
|
|
7
|
+
* a folder opens, a file is selected in its folder where the file manager can do that.
|
|
8
|
+
* @param {string} target
|
|
9
|
+
* @param {boolean} isDir
|
|
10
|
+
* @param {NodeJS.Platform} [platform]
|
|
11
|
+
*/
|
|
12
|
+
function revealCommand(target, isDir, platform = process.platform) {
|
|
13
|
+
if (platform === 'win32') {
|
|
14
|
+
// explorer.exe reads `/select,` and its path as one argument and takes quotes only
|
|
15
|
+
// around the path, so Node's own quoting of the whole argument opens Documents instead.
|
|
16
|
+
const arg = isDir ? `"${target}"` : `/select,"${target}"`;
|
|
17
|
+
return { cmd: 'explorer.exe', args: [arg], opts: { windowsVerbatimArguments: true } };
|
|
18
|
+
}
|
|
19
|
+
if (platform === 'darwin') return { cmd: 'open', args: isDir ? [target] : ['-R', target], opts: {} };
|
|
20
|
+
return { cmd: 'xdg-open', args: [isDir ? target : path.dirname(target)], opts: {} };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function revealInFileManager(target) {
|
|
24
|
+
const { cmd, args, opts } = revealCommand(target, fs.statSync(target).isDirectory());
|
|
25
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true, ...opts });
|
|
26
|
+
child.on('error', (e) => console.error('File manager failed to start:', e.message));
|
|
27
|
+
child.unref();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = { revealCommand, revealInFileManager };
|
package/lib/terminal-client.js
CHANGED
|
@@ -46,6 +46,8 @@ function createTerminalClient(o) {
|
|
|
46
46
|
let ids = [];
|
|
47
47
|
let terminalIds = [];
|
|
48
48
|
let awaitingTrust = [];
|
|
49
|
+
let programStatus = {};
|
|
50
|
+
let statusSilent = [];
|
|
49
51
|
let serverUrl = null;
|
|
50
52
|
let restoreAsked = false;
|
|
51
53
|
let stopped = false;
|
|
@@ -83,6 +85,8 @@ function createTerminalClient(o) {
|
|
|
83
85
|
ids = msg.ids;
|
|
84
86
|
terminalIds = msg.terminalIds || [];
|
|
85
87
|
awaitingTrust = msg.awaitingTrust || [];
|
|
88
|
+
programStatus = msg.programStatus || {};
|
|
89
|
+
statusSilent = msg.statusSilent || [];
|
|
86
90
|
settle(hostReason);
|
|
87
91
|
o.onChange?.();
|
|
88
92
|
} else if (msg.t === 'exit') o.onExit?.(msg.id);
|
|
@@ -130,6 +134,8 @@ function createTerminalClient(o) {
|
|
|
130
134
|
ids = [];
|
|
131
135
|
terminalIds = [];
|
|
132
136
|
awaitingTrust = [];
|
|
137
|
+
programStatus = {};
|
|
138
|
+
statusSilent = [];
|
|
133
139
|
for (const id of lost) o.onExit?.(id);
|
|
134
140
|
o.onChange?.();
|
|
135
141
|
const now = Date.now();
|
|
@@ -205,6 +211,10 @@ function createTerminalClient(o) {
|
|
|
205
211
|
return call('type', id, from, text, submit).catch(() => false);
|
|
206
212
|
}
|
|
207
213
|
|
|
214
|
+
function markStatusSeen(id) {
|
|
215
|
+
if (isRunning(id)) call('markStatusSeen', id).catch(() => {});
|
|
216
|
+
}
|
|
217
|
+
|
|
208
218
|
function restore() {
|
|
209
219
|
restoreAsked = true;
|
|
210
220
|
if (child) call('restore').catch(() => {});
|
|
@@ -245,10 +255,12 @@ function createTerminalClient(o) {
|
|
|
245
255
|
else spawn();
|
|
246
256
|
|
|
247
257
|
return {
|
|
248
|
-
token, handleUpgrade, clientConfig, unavailableReason, authorized, isRunning, hasTerminal, sessionOfTerminal, startNew, end, paste, type, restore,
|
|
258
|
+
token, handleUpgrade, clientConfig, unavailableReason, authorized, isRunning, hasTerminal, sessionOfTerminal, startNew, end, paste, type, markStatusSeen, restore,
|
|
249
259
|
setServerUrl, setConptyDll, sessions, stats, shutdown, started,
|
|
250
260
|
ids: () => [...ids],
|
|
251
261
|
awaitingTrust: () => [...awaitingTrust],
|
|
262
|
+
programStatus: () => ({ ...programStatus }),
|
|
263
|
+
statusSilent: () => [...statusSilent],
|
|
252
264
|
};
|
|
253
265
|
}
|
|
254
266
|
|
package/lib/terminal-host.js
CHANGED
|
@@ -35,6 +35,8 @@ function pushState() {
|
|
|
35
35
|
ids: live.map((s) => s.id),
|
|
36
36
|
terminalIds: live.map((s) => s.terminalId),
|
|
37
37
|
awaitingTrust: live.filter((s) => s.awaitingTrust).map((s) => s.id),
|
|
38
|
+
programStatus: Object.fromEntries(live.filter((s) => s.programStatus).map((s) => [s.id, s.programStatus])),
|
|
39
|
+
statusSilent: live.filter((s) => s.statusSilent).map((s) => s.id),
|
|
38
40
|
};
|
|
39
41
|
const key = JSON.stringify(state);
|
|
40
42
|
if (key === lastState) return;
|
|
@@ -75,6 +77,7 @@ const CALLS = {
|
|
|
75
77
|
end: (id, token) => service.end(id, token),
|
|
76
78
|
paste: (id, text, submit) => service.paste(id, text, submit),
|
|
77
79
|
type: (id, from, text, submit) => service.type(id, from, text, submit),
|
|
80
|
+
markStatusSeen: (id) => service.markStatusSeen(id),
|
|
78
81
|
restore: () => service.restore(),
|
|
79
82
|
sessions: () => service.list(),
|
|
80
83
|
claudePids: () => service.claudePids(),
|
package/lib/terminal.js
CHANGED
|
@@ -20,11 +20,13 @@ const path = require('node:path');
|
|
|
20
20
|
const { isContained } = require('./contain');
|
|
21
21
|
const { isPidAlive } = require('./live-sessions');
|
|
22
22
|
const priority = require('./priority');
|
|
23
|
+
const programStatus = require('./program-status');
|
|
23
24
|
|
|
24
25
|
const WS_PATH = '/api/terminal/ws';
|
|
25
26
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
26
27
|
const MODES = new Set(['auto', 'resume', 'shell', 'new', 'pick']);
|
|
27
28
|
const PICK_POLL_MS = 1000;
|
|
29
|
+
const SILENT_PROBE_MS = 3000;
|
|
28
30
|
// How long before the PTY a registry entry may claim to have started (clock skew between the two).
|
|
29
31
|
const PICK_START_SLACK_MS = 2000;
|
|
30
32
|
// A new session's name and worktree reach a shell command line, so they are held to a
|
|
@@ -78,7 +80,7 @@ const HEADLESS_ROWS = 32;
|
|
|
78
80
|
// The hub hands its children PORT=0 and friends; a dev server started in the terminal
|
|
79
81
|
// would otherwise bind a random port, and a nested `claude` would think it runs inside one.
|
|
80
82
|
const STRIP_ENV = [
|
|
81
|
-
'PORT', 'HOST', 'ALLOWED_HOSTS', 'CLAUDE_HUB', 'HUB_URL',
|
|
83
|
+
'PORT', 'HOST', 'ALLOWED_HOSTS', 'CLAUDE_HUB', 'HUB_URL', 'HUB_APP_SETTINGS',
|
|
82
84
|
'CCK_TERMINAL', 'CCK_TERMINAL_TOKEN', 'CCK_TERMINAL_SHELL', 'CLAUDECODE', 'CLAUDE_CODE_ENTRYPOINT',
|
|
83
85
|
// A cck started from inside Claude Code carries these; a claude that inherits them runs as that
|
|
84
86
|
// session's child and writes no live-session registry entry, which the resume picker relies on.
|
|
@@ -97,10 +99,12 @@ function posInt(v, fallback) {
|
|
|
97
99
|
return Number.isInteger(n) && n > 0 ? n : fallback;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
// CCK_TERMINAL is the hub's `terminal` config block as JSON; flags win over it.
|
|
102
|
+
// CCK_TERMINAL is the hub's `terminal` config block as JSON; flags win over it. HUB_APP_SETTINGS
|
|
103
|
+
// carries the board's hub settings at spawn, so restored terminals start on the chosen host.
|
|
101
104
|
function readTerminalConfig({ argv = process.argv, env = process.env, getArgValue } = {}) {
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
const parseJson = (v) => { try { return JSON.parse(v || '{}') || {}; } catch { return {}; } };
|
|
106
|
+
const cfg = parseJson(env.CCK_TERMINAL);
|
|
107
|
+
const settings = parseJson(env.HUB_APP_SETTINGS);
|
|
104
108
|
return {
|
|
105
109
|
enabled: argv.includes('--enable-terminal') || cfg.enabled === true,
|
|
106
110
|
shell:
|
|
@@ -114,7 +118,7 @@ function readTerminalConfig({ argv = process.argv, env = process.env, getArgValu
|
|
|
114
118
|
scrollback: posInt(cfg.scrollback, 5000),
|
|
115
119
|
noFlicker: cfg.noFlicker !== false,
|
|
116
120
|
restore: cfg.restore !== false,
|
|
117
|
-
conptyDll: cfg.conptyDll === true,
|
|
121
|
+
conptyDll: cfg.conptyDll === true || settings.terminalHost === 'bundled',
|
|
118
122
|
};
|
|
119
123
|
}
|
|
120
124
|
|
|
@@ -617,6 +621,7 @@ function createTerminalService(o) {
|
|
|
617
621
|
}
|
|
618
622
|
s.claudeExitedAt = Date.now();
|
|
619
623
|
s.claudePid = null;
|
|
624
|
+
s.status.dropTransient();
|
|
620
625
|
moved = true;
|
|
621
626
|
}
|
|
622
627
|
if (moved) changed();
|
|
@@ -656,14 +661,15 @@ function createTerminalService(o) {
|
|
|
656
661
|
// Windows' own ConPTY swallows OSC 10/11 color queries and drops OSC replies on input, so apps such as
|
|
657
662
|
// hunk cannot read the theme. The ConPTY that node-pty ships passes both; a spawn it fails falls back.
|
|
658
663
|
function spawnPty(args, opts) {
|
|
659
|
-
if (process.platform
|
|
664
|
+
if (process.platform !== 'win32') return { proc: pty.spawn(shell, args, opts), systemConpty: false };
|
|
665
|
+
if (config.conptyDll) {
|
|
660
666
|
try {
|
|
661
|
-
return pty.spawn(shell, args, { ...opts, useConptyDll: true });
|
|
667
|
+
return { proc: pty.spawn(shell, args, { ...opts, useConptyDll: true }), systemConpty: false };
|
|
662
668
|
} catch (e) {
|
|
663
669
|
console.log(`Bundled ConPTY failed, using the system one: ${e.message}`);
|
|
664
670
|
}
|
|
665
671
|
}
|
|
666
|
-
return pty.spawn(shell, args, opts);
|
|
672
|
+
return { proc: pty.spawn(shell, args, opts), systemConpty: true };
|
|
667
673
|
}
|
|
668
674
|
|
|
669
675
|
function spawnSession(id, mode, cwdCandidate, cols, rows, spec, extraEnv) {
|
|
@@ -675,7 +681,7 @@ function createTerminalService(o) {
|
|
|
675
681
|
// Git Bash's login profile cds to $HOME unless this is set.
|
|
676
682
|
if (shellFamily(shell) === 'gitbash') env.CHERE_INVOKING = '1';
|
|
677
683
|
const claudeArgs = claudeArgsFor(mode, id, spec);
|
|
678
|
-
const proc = spawnPty(shellArgs(shell, spec?.edit ? null : claudeArgs), { name: 'xterm-256color', cols, rows, cwd, env });
|
|
684
|
+
const { proc, systemConpty } = spawnPty(shellArgs(shell, spec?.edit ? null : claudeArgs), { name: 'xterm-256color', cols, rows, cwd, env });
|
|
679
685
|
const term = new Headless({ cols, rows, scrollback: config.scrollback, allowProposedApi: true });
|
|
680
686
|
const serializer = new Serialize();
|
|
681
687
|
term.loadAddon(serializer);
|
|
@@ -683,7 +689,9 @@ function createTerminalService(o) {
|
|
|
683
689
|
id, terminalId, mode, cwd, pty: proc, term, serializer, sockets: new Set(), exited: false, ended: false, paused: false, startedAt: Date.now(),
|
|
684
690
|
name: spec?.name || null, worktree: spec?.worktree || false, taskList, onOutput: null, awaitingTrust: false, edit: !!spec?.edit,
|
|
685
691
|
forkOf: spec?.forkOf || null, resumeOf: spec?.resume || null, restore: spec?.restore !== false, prompted: !!spec?.prompt,
|
|
692
|
+
status: programStatus.createProgramStatus(), systemConpty, scanQuery: programStatus.createQueryScanner(), repliedAhead: 0,
|
|
686
693
|
};
|
|
694
|
+
watchProgramStatus(s);
|
|
687
695
|
if (s.forkOf) o.onFork?.(id, s.forkOf);
|
|
688
696
|
if (s.edit) queueText(s, claudeCommand(shell, claudeArgs, spec.prompt), false);
|
|
689
697
|
else if (spec?.prompt) queueText(s, spec.prompt, true);
|
|
@@ -691,6 +699,7 @@ function createTerminalService(o) {
|
|
|
691
699
|
if (mode === 'pick') watchPick(s);
|
|
692
700
|
|
|
693
701
|
proc.onData((data) => {
|
|
702
|
+
answerQueries(s, data);
|
|
694
703
|
term.write(data);
|
|
695
704
|
if (s.onOutput) s.onOutput(data);
|
|
696
705
|
if (!s.sockets.size) return;
|
|
@@ -703,6 +712,7 @@ function createTerminalService(o) {
|
|
|
703
712
|
clearInterval(s.pickTimer);
|
|
704
713
|
clearInterval(s.boostTimer);
|
|
705
714
|
clearInterval(s.submitTimer);
|
|
715
|
+
clearTimeout(s.silentTimer);
|
|
706
716
|
if (sessions.get(s.id) === s) sessions.delete(s.id);
|
|
707
717
|
o.onExit?.(s.id);
|
|
708
718
|
if (!s.ended) changed();
|
|
@@ -718,6 +728,59 @@ function createTerminalService(o) {
|
|
|
718
728
|
return s;
|
|
719
729
|
}
|
|
720
730
|
|
|
731
|
+
// The headless terminal sees every byte, viewer or not, so it answers the query and keeps the
|
|
732
|
+
// records. The board's xterm ignores the sequence. Only a change of the summary reaches cck.
|
|
733
|
+
function watchProgramStatus(s) {
|
|
734
|
+
const { parser } = s.term;
|
|
735
|
+
const changedIf = (moved) => {
|
|
736
|
+
if (moved === true) o.onChange?.();
|
|
737
|
+
};
|
|
738
|
+
parser.registerOscHandler(programStatus.OSC_CODE, (data) => {
|
|
739
|
+
const r = s.status.handle(data);
|
|
740
|
+
if (r === 'query') {
|
|
741
|
+
if (s.repliedAhead) s.repliedAhead--;
|
|
742
|
+
else if (!s.exited) s.pty.write(programStatus.QUERY_REPLY);
|
|
743
|
+
watchSilentProbe(s);
|
|
744
|
+
} else {
|
|
745
|
+
if (r) {
|
|
746
|
+
s.statusHeard = true;
|
|
747
|
+
s.statusSilent = false;
|
|
748
|
+
}
|
|
749
|
+
changedIf(r);
|
|
750
|
+
}
|
|
751
|
+
return true;
|
|
752
|
+
});
|
|
753
|
+
parser.registerOscHandler(133, (data) => {
|
|
754
|
+
if (data[0] === 'A') changedIf(s.status.dropTransient());
|
|
755
|
+
return false;
|
|
756
|
+
});
|
|
757
|
+
parser.registerEscHandler({ final: 'c' }, () => {
|
|
758
|
+
changedIf(s.status.reset());
|
|
759
|
+
return false;
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// The program takes the query as unanswered once the DA1 reply comes back. The headless
|
|
764
|
+
// terminal parses on a later tick, while the board's xterm gets the bytes now and answers DA1,
|
|
765
|
+
// so the reply goes out here, before the bytes reach a viewer.
|
|
766
|
+
function answerQueries(s, data) {
|
|
767
|
+
const asked = s.scanQuery(data);
|
|
768
|
+
if (!asked || s.exited) return;
|
|
769
|
+
for (let i = 0; i < asked; i++) s.pty.write(programStatus.QUERY_REPLY);
|
|
770
|
+
s.repliedAhead += asked;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// Windows' own ConPTY answers DA1 itself and drops the reply, so the program asks and never
|
|
774
|
+
// reports. One check per terminal tells the board, which suggests the bundled ConPTY.
|
|
775
|
+
function watchSilentProbe(s) {
|
|
776
|
+
if (!s.systemConpty || s.statusHeard || s.silentTimer) return;
|
|
777
|
+
s.silentTimer = setTimeout(() => {
|
|
778
|
+
if (s.statusHeard || s.exited) return;
|
|
779
|
+
s.statusSilent = true;
|
|
780
|
+
o.onChange?.();
|
|
781
|
+
}, SILENT_PROBE_MS);
|
|
782
|
+
}
|
|
783
|
+
|
|
721
784
|
// `claude --resume` opens its own picker, so the session is unknown until the user picks.
|
|
722
785
|
// Claude's registry entry keeps its pid and swaps its sessionId to the picked one; the entry
|
|
723
786
|
// is found by folder and start time, and the pick shows as an id with a transcript behind it.
|
|
@@ -782,7 +845,8 @@ function createTerminalService(o) {
|
|
|
782
845
|
ws.unacked = 0;
|
|
783
846
|
s.sockets.add(ws);
|
|
784
847
|
syncBoost(s);
|
|
785
|
-
|
|
848
|
+
// ConPTY drops DEC 2026, and a clear inside a 2026 block hits xterm #5801 unless noFlicker is on.
|
|
849
|
+
send(ws, { t: 'ready', attached, holdRedraw: process.platform === 'win32' && config.noFlicker });
|
|
786
850
|
const snapshot = s.serializer.serialize();
|
|
787
851
|
if (snapshot) sendOutput(ws, Buffer.from(snapshot, 'utf8'));
|
|
788
852
|
|
|
@@ -918,6 +982,8 @@ function createTerminalService(o) {
|
|
|
918
982
|
return [...sessions.values()].filter((s) => !s.ended).map((s) => ({
|
|
919
983
|
id: s.id, terminalId: s.terminalId, mode: s.mode, cwd: s.cwd, pid: s.pty.pid, clients: s.sockets.size, startedAt: s.startedAt,
|
|
920
984
|
name: s.name, worktree: s.worktree, edit: s.edit, forkOf: s.forkOf, prompted: s.prompted, claudeExited: !!s.claudeExitedAt, awaitingTrust: s.awaitingTrust,
|
|
985
|
+
programStatus: s.status.summary(),
|
|
986
|
+
statusSilent: !!s.statusSilent,
|
|
921
987
|
}));
|
|
922
988
|
}
|
|
923
989
|
|
|
@@ -974,6 +1040,11 @@ function createTerminalService(o) {
|
|
|
974
1040
|
return s;
|
|
975
1041
|
}
|
|
976
1042
|
|
|
1043
|
+
function markStatusSeen(id) {
|
|
1044
|
+
const s = sessions.get(id);
|
|
1045
|
+
if (s && !s.ended && s.status.markSeen()) o.onChange?.();
|
|
1046
|
+
}
|
|
1047
|
+
|
|
977
1048
|
function paste(id, text, submit = false) {
|
|
978
1049
|
const s = inputBox(id);
|
|
979
1050
|
if (!s) return false;
|
|
@@ -1017,7 +1088,7 @@ function createTerminalService(o) {
|
|
|
1017
1088
|
sessions.clear();
|
|
1018
1089
|
}
|
|
1019
1090
|
|
|
1020
|
-
return { token, handleUpgrade, clientConfig, list, claudePids, isRunning, end, authorized, startNew, paste, type, restore, shutdown, unavailableReason };
|
|
1091
|
+
return { token, handleUpgrade, clientConfig, list, claudePids, isRunning, end, authorized, startNew, paste, type, markStatusSeen, restore, shutdown, unavailableReason };
|
|
1021
1092
|
}
|
|
1022
1093
|
|
|
1023
1094
|
module.exports = { MODELS,createTerminalService, DIALOG_SCREEN, screenText, readTerminalConfig, localUnavailableReason, refuseUpgrade, clientConfigFor, ptyEnv, shellArgs, claudeCommand, resolveShell, claudeArgsFor, parseNewSpec, findPickProcess, tokenMatches };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-kanban",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "claude-code-kanban dashboard integration: agent activity tracking, context and cost tracking, board moves and reviews delivered to the session, and skills to drive the board from a session"
|
|
5
5
|
}
|
|
@@ -39,6 +39,10 @@ The user works in other windows while you run, so pick the quiet command. `doc l
|
|
|
39
39
|
|
|
40
40
|
To show the user a page, a prototype or a collage of screenshots, write it as HTML and link or preview that file. The preview renders HTML as authored in a sandboxed iframe and inlines its local stylesheets, scripts and images, so the file alone is enough.
|
|
41
41
|
|
|
42
|
+
## Scratchpads
|
|
43
|
+
|
|
44
|
+
A scratchpad (a folder with `scratchpad.json`) is one document: `doc link` or `pane add` its `scratchpad.json`, never its files one by one.
|
|
45
|
+
|
|
42
46
|
## Another session
|
|
43
47
|
|
|
44
48
|
Read its transcript. `session view <id>` and `session search <text> --json` print the path.
|