@bakapiano/ccsm 0.22.3 → 0.22.5

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 (61) hide show
  1. package/CLAUDE.md +538 -538
  2. package/README.md +189 -189
  3. package/bin/ccsm.js +235 -235
  4. package/lib/cliActivity.js +139 -139
  5. package/lib/codexSeed.js +183 -183
  6. package/lib/config.js +274 -274
  7. package/lib/devices.js +229 -229
  8. package/lib/folders.js +124 -124
  9. package/lib/localCliSessions.js +519 -519
  10. package/lib/persistedSessions.js +129 -129
  11. package/lib/tunnel.js +621 -621
  12. package/lib/webTerminal.js +225 -225
  13. package/lib/workspace.js +233 -233
  14. package/package.json +57 -57
  15. package/public/css/base.css +99 -99
  16. package/public/css/cards.css +183 -183
  17. package/public/css/feedback.css +504 -504
  18. package/public/css/forms.css +453 -453
  19. package/public/css/layout.css +176 -176
  20. package/public/css/modal.css +190 -190
  21. package/public/css/responsive.css +176 -176
  22. package/public/css/sidebar.css +707 -707
  23. package/public/css/terminals.css +645 -543
  24. package/public/css/tokens.css +81 -81
  25. package/public/css/wco.css +196 -196
  26. package/public/css/widgets.css +2725 -2725
  27. package/public/index.html +152 -152
  28. package/public/js/api.js +371 -371
  29. package/public/js/backend.js +149 -149
  30. package/public/js/components/App.js +73 -73
  31. package/public/js/components/DirectoryPicker.js +203 -203
  32. package/public/js/components/EntityFormModal.js +153 -153
  33. package/public/js/components/Modal.js +57 -57
  34. package/public/js/components/OfflineBanner.js +67 -67
  35. package/public/js/components/PageTitleBar.js +13 -13
  36. package/public/js/components/PendingApprovalOverlay.js +128 -128
  37. package/public/js/components/Picker.js +179 -179
  38. package/public/js/components/Popover.js +55 -55
  39. package/public/js/components/RestartOverlay.js +36 -36
  40. package/public/js/components/Sidebar.js +380 -380
  41. package/public/js/components/TerminalInstance.js +159 -22
  42. package/public/js/components/TerminalResizeDebouncer.js +126 -0
  43. package/public/js/components/TerminalView.js +15 -2
  44. package/public/js/components/XtermTerminal.js +74 -15
  45. package/public/js/components/useDragSort.js +67 -67
  46. package/public/js/dialog.js +67 -67
  47. package/public/js/icons.js +212 -212
  48. package/public/js/main.js +296 -296
  49. package/public/js/pages/AboutPage.js +90 -90
  50. package/public/js/pages/ConfigurePage.js +713 -713
  51. package/public/js/pages/LaunchPage.js +421 -421
  52. package/public/js/pages/RemotePage.js +743 -743
  53. package/public/js/pages/SessionsPage.js +199 -80
  54. package/public/js/state.js +335 -335
  55. package/public/manifest.webmanifest +25 -0
  56. package/public/setup/index.html +567 -0
  57. package/scripts/dev.js +149 -149
  58. package/scripts/install.js +153 -153
  59. package/scripts/restart-helper.js +96 -96
  60. package/scripts/upgrade-helper.js +687 -687
  61. package/server.js +1807 -1807
package/lib/workspace.js CHANGED
@@ -1,233 +1,233 @@
1
- 'use strict';
2
-
3
- const fs = require('node:fs/promises');
4
- const fsSync = require('node:fs');
5
- const path = require('node:path');
6
- const { spawn } = require('node:child_process');
7
-
8
- function normWin(p) {
9
- return path.resolve(String(p)).toLowerCase();
10
- }
11
-
12
- function isInside(child, parent) {
13
- const c = normWin(child);
14
- const p = normWin(parent);
15
- if (c === p) return true;
16
- const pSep = p.endsWith(path.sep) ? p : p + path.sep;
17
- return c.startsWith(pSep);
18
- }
19
-
20
- async function ensureDir(p) {
21
- await fs.mkdir(p, { recursive: true });
22
- }
23
-
24
- async function dirExists(p) {
25
- try {
26
- const st = await fs.stat(p);
27
- return st.isDirectory();
28
- } catch {
29
- return false;
30
- }
31
- }
32
-
33
- async function isGitClone(p) {
34
- return dirExists(path.join(p, '.git'));
35
- }
36
-
37
- async function listSubdirs(p) {
38
- try {
39
- const entries = await fs.readdir(p, { withFileTypes: true });
40
- return entries.filter((e) => e.isDirectory()).map((e) => e.name);
41
- } catch (e) {
42
- if (e.code === 'ENOENT') return [];
43
- throw e;
44
- }
45
- }
46
-
47
- async function describeWorkspace(workspacePath, repos, busyPaths) {
48
- const repoStatus = await Promise.all(
49
- repos.map(async (r) => {
50
- const repoPath = path.join(workspacePath, r.name);
51
- const exists = await dirExists(repoPath);
52
- const cloned = exists ? await isGitClone(repoPath) : false;
53
- return {
54
- name: r.name,
55
- url: r.url,
56
- path: repoPath,
57
- exists,
58
- cloned,
59
- };
60
- })
61
- );
62
- const inUse = busyPaths.some((p) => isInside(p, workspacePath));
63
- const sessionsHere = busyPaths.filter((p) => isInside(p, workspacePath));
64
- return {
65
- name: path.basename(workspacePath),
66
- path: workspacePath,
67
- inUse,
68
- sessionsHere,
69
- repos: repoStatus,
70
- };
71
- }
72
-
73
- async function listWorkspaces({ workDir, repos, busyPaths = [] }) {
74
- await ensureDir(workDir);
75
- const subdirs = await listSubdirs(workDir);
76
-
77
- const workspaces = await Promise.all(
78
- subdirs.map((name) =>
79
- describeWorkspace(path.join(workDir, name), repos, busyPaths)
80
- )
81
- );
82
- workspaces.sort((a, b) => {
83
- if (a.inUse !== b.inUse) return a.inUse ? 1 : -1;
84
- return a.name.localeCompare(b.name, undefined, { numeric: true });
85
- });
86
- return workspaces;
87
- }
88
-
89
- function nextWorkspaceName(existing) {
90
- const used = new Set(existing.map((w) => w.name.toLowerCase()));
91
- for (let i = 1; i < 10000; i++) {
92
- const candidate = `ws-${i}`;
93
- if (!used.has(candidate)) return candidate;
94
- }
95
- throw new Error('Could not allocate workspace name');
96
- }
97
-
98
- async function findOrCreateWorkspace({ workDir, repos, busyPaths = [], requireUnused = true }) {
99
- // Without busyPaths, every workspace looks free → find() always
100
- // returns ws-1 → every new session piles into ws-1. Callers must
101
- // pass the cwds of currently-running persisted sessions.
102
- const all = await listWorkspaces({ workDir, repos, busyPaths });
103
- if (requireUnused) {
104
- const free = all.find((w) => !w.inUse);
105
- if (free) return { workspace: free, created: false };
106
- }
107
- const name = nextWorkspaceName(all);
108
- const wsPath = path.join(workDir, name);
109
- await ensureDir(wsPath);
110
- const ws = await describeWorkspace(wsPath, repos, busyPaths);
111
- return { workspace: ws, created: true };
112
- }
113
-
114
- // Parse a single git --progress line. Git emits these on stderr, using \r
115
- // to overwrite the same line in place, with the format:
116
- // "<phase>: <pct>% (<cur>/<total>), <detail>"
117
- // Examples:
118
- // "Receiving objects: 45% (12345/27384), 23.4 MiB | 5.2 MiB/s"
119
- // "Resolving deltas: 100% (5847/5847), done."
120
- function parseGitProgress(line) {
121
- if (!line) return null;
122
- const clean = line.replace(/^remote:\s*/, '').trim();
123
- const m = clean.match(/^([^:]+):\s+(\d+)%\s*(?:\((\d+)\/(\d+)\))?(?:,\s+(.+?))?$/);
124
- if (!m) return null;
125
- return {
126
- phase: m[1].trim(),
127
- percent: Number(m[2]),
128
- current: m[3] ? Number(m[3]) : null,
129
- total: m[4] ? Number(m[4]) : null,
130
- detail: m[5] ? m[5].trim() : null,
131
- raw: clean,
132
- };
133
- }
134
-
135
- function runGit(args, cwd, { onProgress, onLine } = {}) {
136
- return new Promise((resolve, reject) => {
137
- const child = spawn('git', args, {
138
- cwd,
139
- windowsHide: true,
140
- stdio: ['ignore', 'pipe', 'pipe'],
141
- });
142
- let out = '';
143
- let err = '';
144
- let stderrBuf = '';
145
- child.stdout.on('data', (d) => (out += d.toString()));
146
- child.stderr.on('data', (d) => {
147
- const text = d.toString();
148
- err += text;
149
- if (onProgress || onLine) {
150
- stderrBuf += text;
151
- const parts = stderrBuf.split(/[\r\n]/);
152
- stderrBuf = parts.pop();
153
- for (const line of parts) {
154
- if (!line) continue;
155
- if (onLine) onLine(line);
156
- if (onProgress) {
157
- const p = parseGitProgress(line);
158
- if (p) onProgress(p);
159
- }
160
- }
161
- }
162
- });
163
- child.on('error', reject);
164
- child.on('close', (code) => {
165
- if (stderrBuf && (onLine || onProgress)) {
166
- if (onLine) onLine(stderrBuf);
167
- if (onProgress) {
168
- const p = parseGitProgress(stderrBuf);
169
- if (p) onProgress(p);
170
- }
171
- }
172
- if (code === 0) resolve({ stdout: out, stderr: err });
173
- else
174
- reject(
175
- Object.assign(
176
- new Error(`git ${args.join(' ')} exited ${code}: ${err.trim()}`),
177
- { code, stdout: out, stderr: err }
178
- )
179
- );
180
- });
181
- });
182
- }
183
-
184
- async function cloneRepoInto({ workspacePath, repo, onProgress, onLine }) {
185
- const target = path.join(workspacePath, repo.name);
186
- if (await dirExists(target)) {
187
- if (await isGitClone(target)) {
188
- return { repo: repo.name, action: 'already-cloned', path: target };
189
- }
190
- throw new Error(
191
- `Target ${target} exists but is not a git clone — refusing to overwrite`
192
- );
193
- }
194
- // -c core.longpaths=true defeats Windows' default 260-char MAX_PATH so deep
195
- // repo trees (e.g. nested doc / .github skill paths) can check out
196
- // successfully. The flag only applies to this single git invocation.
197
- await runGit(
198
- ['-c', 'core.longpaths=true', 'clone', '--progress', repo.url, repo.name],
199
- workspacePath,
200
- { onProgress, onLine }
201
- );
202
- return { repo: repo.name, action: 'cloned', path: target };
203
- }
204
-
205
- async function ensureReposInWorkspace({ workspacePath, repos, onProgress, onLine, onRepoStart, onRepoEnd }) {
206
- const results = [];
207
- for (const repo of repos) {
208
- if (onRepoStart) onRepoStart(repo);
209
- try {
210
- const r = await cloneRepoInto({
211
- workspacePath,
212
- repo,
213
- onProgress: onProgress ? (p) => onProgress(repo, p) : null,
214
- onLine: onLine ? (l) => onLine(repo, l) : null,
215
- });
216
- if (onRepoEnd) onRepoEnd(repo, { ok: true, ...r });
217
- results.push({ ok: true, ...r });
218
- } catch (e) {
219
- const err = { ok: false, repo: repo.name, error: String(e && e.message || e) };
220
- if (onRepoEnd) onRepoEnd(repo, err);
221
- results.push(err);
222
- }
223
- }
224
- return results;
225
- }
226
-
227
- module.exports = {
228
- listWorkspaces,
229
- findOrCreateWorkspace,
230
- ensureReposInWorkspace,
231
- isInside,
232
- nextWorkspaceName,
233
- };
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs/promises');
4
+ const fsSync = require('node:fs');
5
+ const path = require('node:path');
6
+ const { spawn } = require('node:child_process');
7
+
8
+ function normWin(p) {
9
+ return path.resolve(String(p)).toLowerCase();
10
+ }
11
+
12
+ function isInside(child, parent) {
13
+ const c = normWin(child);
14
+ const p = normWin(parent);
15
+ if (c === p) return true;
16
+ const pSep = p.endsWith(path.sep) ? p : p + path.sep;
17
+ return c.startsWith(pSep);
18
+ }
19
+
20
+ async function ensureDir(p) {
21
+ await fs.mkdir(p, { recursive: true });
22
+ }
23
+
24
+ async function dirExists(p) {
25
+ try {
26
+ const st = await fs.stat(p);
27
+ return st.isDirectory();
28
+ } catch {
29
+ return false;
30
+ }
31
+ }
32
+
33
+ async function isGitClone(p) {
34
+ return dirExists(path.join(p, '.git'));
35
+ }
36
+
37
+ async function listSubdirs(p) {
38
+ try {
39
+ const entries = await fs.readdir(p, { withFileTypes: true });
40
+ return entries.filter((e) => e.isDirectory()).map((e) => e.name);
41
+ } catch (e) {
42
+ if (e.code === 'ENOENT') return [];
43
+ throw e;
44
+ }
45
+ }
46
+
47
+ async function describeWorkspace(workspacePath, repos, busyPaths) {
48
+ const repoStatus = await Promise.all(
49
+ repos.map(async (r) => {
50
+ const repoPath = path.join(workspacePath, r.name);
51
+ const exists = await dirExists(repoPath);
52
+ const cloned = exists ? await isGitClone(repoPath) : false;
53
+ return {
54
+ name: r.name,
55
+ url: r.url,
56
+ path: repoPath,
57
+ exists,
58
+ cloned,
59
+ };
60
+ })
61
+ );
62
+ const inUse = busyPaths.some((p) => isInside(p, workspacePath));
63
+ const sessionsHere = busyPaths.filter((p) => isInside(p, workspacePath));
64
+ return {
65
+ name: path.basename(workspacePath),
66
+ path: workspacePath,
67
+ inUse,
68
+ sessionsHere,
69
+ repos: repoStatus,
70
+ };
71
+ }
72
+
73
+ async function listWorkspaces({ workDir, repos, busyPaths = [] }) {
74
+ await ensureDir(workDir);
75
+ const subdirs = await listSubdirs(workDir);
76
+
77
+ const workspaces = await Promise.all(
78
+ subdirs.map((name) =>
79
+ describeWorkspace(path.join(workDir, name), repos, busyPaths)
80
+ )
81
+ );
82
+ workspaces.sort((a, b) => {
83
+ if (a.inUse !== b.inUse) return a.inUse ? 1 : -1;
84
+ return a.name.localeCompare(b.name, undefined, { numeric: true });
85
+ });
86
+ return workspaces;
87
+ }
88
+
89
+ function nextWorkspaceName(existing) {
90
+ const used = new Set(existing.map((w) => w.name.toLowerCase()));
91
+ for (let i = 1; i < 10000; i++) {
92
+ const candidate = `ws-${i}`;
93
+ if (!used.has(candidate)) return candidate;
94
+ }
95
+ throw new Error('Could not allocate workspace name');
96
+ }
97
+
98
+ async function findOrCreateWorkspace({ workDir, repos, busyPaths = [], requireUnused = true }) {
99
+ // Without busyPaths, every workspace looks free → find() always
100
+ // returns ws-1 → every new session piles into ws-1. Callers must
101
+ // pass the cwds of currently-running persisted sessions.
102
+ const all = await listWorkspaces({ workDir, repos, busyPaths });
103
+ if (requireUnused) {
104
+ const free = all.find((w) => !w.inUse);
105
+ if (free) return { workspace: free, created: false };
106
+ }
107
+ const name = nextWorkspaceName(all);
108
+ const wsPath = path.join(workDir, name);
109
+ await ensureDir(wsPath);
110
+ const ws = await describeWorkspace(wsPath, repos, busyPaths);
111
+ return { workspace: ws, created: true };
112
+ }
113
+
114
+ // Parse a single git --progress line. Git emits these on stderr, using \r
115
+ // to overwrite the same line in place, with the format:
116
+ // "<phase>: <pct>% (<cur>/<total>), <detail>"
117
+ // Examples:
118
+ // "Receiving objects: 45% (12345/27384), 23.4 MiB | 5.2 MiB/s"
119
+ // "Resolving deltas: 100% (5847/5847), done."
120
+ function parseGitProgress(line) {
121
+ if (!line) return null;
122
+ const clean = line.replace(/^remote:\s*/, '').trim();
123
+ const m = clean.match(/^([^:]+):\s+(\d+)%\s*(?:\((\d+)\/(\d+)\))?(?:,\s+(.+?))?$/);
124
+ if (!m) return null;
125
+ return {
126
+ phase: m[1].trim(),
127
+ percent: Number(m[2]),
128
+ current: m[3] ? Number(m[3]) : null,
129
+ total: m[4] ? Number(m[4]) : null,
130
+ detail: m[5] ? m[5].trim() : null,
131
+ raw: clean,
132
+ };
133
+ }
134
+
135
+ function runGit(args, cwd, { onProgress, onLine } = {}) {
136
+ return new Promise((resolve, reject) => {
137
+ const child = spawn('git', args, {
138
+ cwd,
139
+ windowsHide: true,
140
+ stdio: ['ignore', 'pipe', 'pipe'],
141
+ });
142
+ let out = '';
143
+ let err = '';
144
+ let stderrBuf = '';
145
+ child.stdout.on('data', (d) => (out += d.toString()));
146
+ child.stderr.on('data', (d) => {
147
+ const text = d.toString();
148
+ err += text;
149
+ if (onProgress || onLine) {
150
+ stderrBuf += text;
151
+ const parts = stderrBuf.split(/[\r\n]/);
152
+ stderrBuf = parts.pop();
153
+ for (const line of parts) {
154
+ if (!line) continue;
155
+ if (onLine) onLine(line);
156
+ if (onProgress) {
157
+ const p = parseGitProgress(line);
158
+ if (p) onProgress(p);
159
+ }
160
+ }
161
+ }
162
+ });
163
+ child.on('error', reject);
164
+ child.on('close', (code) => {
165
+ if (stderrBuf && (onLine || onProgress)) {
166
+ if (onLine) onLine(stderrBuf);
167
+ if (onProgress) {
168
+ const p = parseGitProgress(stderrBuf);
169
+ if (p) onProgress(p);
170
+ }
171
+ }
172
+ if (code === 0) resolve({ stdout: out, stderr: err });
173
+ else
174
+ reject(
175
+ Object.assign(
176
+ new Error(`git ${args.join(' ')} exited ${code}: ${err.trim()}`),
177
+ { code, stdout: out, stderr: err }
178
+ )
179
+ );
180
+ });
181
+ });
182
+ }
183
+
184
+ async function cloneRepoInto({ workspacePath, repo, onProgress, onLine }) {
185
+ const target = path.join(workspacePath, repo.name);
186
+ if (await dirExists(target)) {
187
+ if (await isGitClone(target)) {
188
+ return { repo: repo.name, action: 'already-cloned', path: target };
189
+ }
190
+ throw new Error(
191
+ `Target ${target} exists but is not a git clone — refusing to overwrite`
192
+ );
193
+ }
194
+ // -c core.longpaths=true defeats Windows' default 260-char MAX_PATH so deep
195
+ // repo trees (e.g. nested doc / .github skill paths) can check out
196
+ // successfully. The flag only applies to this single git invocation.
197
+ await runGit(
198
+ ['-c', 'core.longpaths=true', 'clone', '--progress', repo.url, repo.name],
199
+ workspacePath,
200
+ { onProgress, onLine }
201
+ );
202
+ return { repo: repo.name, action: 'cloned', path: target };
203
+ }
204
+
205
+ async function ensureReposInWorkspace({ workspacePath, repos, onProgress, onLine, onRepoStart, onRepoEnd }) {
206
+ const results = [];
207
+ for (const repo of repos) {
208
+ if (onRepoStart) onRepoStart(repo);
209
+ try {
210
+ const r = await cloneRepoInto({
211
+ workspacePath,
212
+ repo,
213
+ onProgress: onProgress ? (p) => onProgress(repo, p) : null,
214
+ onLine: onLine ? (l) => onLine(repo, l) : null,
215
+ });
216
+ if (onRepoEnd) onRepoEnd(repo, { ok: true, ...r });
217
+ results.push({ ok: true, ...r });
218
+ } catch (e) {
219
+ const err = { ok: false, repo: repo.name, error: String(e && e.message || e) };
220
+ if (onRepoEnd) onRepoEnd(repo, err);
221
+ results.push(err);
222
+ }
223
+ }
224
+ return results;
225
+ }
226
+
227
+ module.exports = {
228
+ listWorkspaces,
229
+ findOrCreateWorkspace,
230
+ ensureReposInWorkspace,
231
+ isInside,
232
+ nextWorkspaceName,
233
+ };
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "name": "@bakapiano/ccsm",
3
- "version": "0.22.3",
4
- "description": "Claude Code Session Manager — Windows web UI to manage many concurrent claude sessions: live list, snapshot/restore, focus existing window, new session in an isolated workspace with repo clones",
5
- "license": "MIT",
6
- "main": "server.js",
7
- "bin": {
8
- "ccsm": "./bin/ccsm.js"
9
- },
10
- "files": [
11
- "server.js",
12
- "bin/",
13
- "lib/",
14
- "public/",
15
- "scripts/",
16
- "README.md",
17
- "CLAUDE.md"
18
- ],
19
- "scripts": {
20
- "start": "node server.js",
21
- "dev": "node scripts/dev.js",
22
- "postinstall": "node scripts/install.js",
23
- "preuninstall": "node scripts/uninstall.js"
24
- },
25
- "dependencies": {
26
- "express": "^4.21.2"
27
- },
28
- "optionalDependencies": {
29
- "node-pty": "^1.0.0",
30
- "ws": "^8.18.0"
31
- },
32
- "engines": {
33
- "node": ">=20"
34
- },
35
- "os": [
36
- "win32"
37
- ],
38
- "keywords": [
39
- "claude",
40
- "claude-code",
41
- "session-manager",
42
- "windows",
43
- "windows-terminal"
44
- ],
45
- "repository": {
46
- "type": "git",
47
- "url": "git+https://github.com/bakapiano/ccsm.git"
48
- },
49
- "bugs": {
50
- "url": "https://github.com/bakapiano/ccsm/issues"
51
- },
52
- "homepage": "https://github.com/bakapiano/ccsm#readme",
53
- "publishConfig": {
54
- "access": "public",
55
- "registry": "https://registry.npmjs.org/"
56
- }
57
- }
1
+ {
2
+ "name": "@bakapiano/ccsm",
3
+ "version": "0.22.5",
4
+ "description": "Claude Code Session Manager — Windows web UI to manage many concurrent claude sessions: live list, snapshot/restore, focus existing window, new session in an isolated workspace with repo clones",
5
+ "license": "MIT",
6
+ "main": "server.js",
7
+ "bin": {
8
+ "ccsm": "./bin/ccsm.js"
9
+ },
10
+ "files": [
11
+ "server.js",
12
+ "bin/",
13
+ "lib/",
14
+ "public/",
15
+ "scripts/",
16
+ "README.md",
17
+ "CLAUDE.md"
18
+ ],
19
+ "scripts": {
20
+ "start": "node server.js",
21
+ "dev": "node scripts/dev.js",
22
+ "postinstall": "node scripts/install.js",
23
+ "preuninstall": "node scripts/uninstall.js"
24
+ },
25
+ "dependencies": {
26
+ "express": "^4.21.2"
27
+ },
28
+ "optionalDependencies": {
29
+ "node-pty": "^1.0.0",
30
+ "ws": "^8.18.0"
31
+ },
32
+ "engines": {
33
+ "node": ">=20"
34
+ },
35
+ "os": [
36
+ "win32"
37
+ ],
38
+ "keywords": [
39
+ "claude",
40
+ "claude-code",
41
+ "session-manager",
42
+ "windows",
43
+ "windows-terminal"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/bakapiano/ccsm.git"
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/bakapiano/ccsm/issues"
51
+ },
52
+ "homepage": "https://github.com/bakapiano/ccsm#readme",
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "registry": "https://registry.npmjs.org/"
56
+ }
57
+ }