@bakapiano/ccsm 0.10.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CLAUDE.md +475 -475
  2. package/README.md +190 -190
  3. package/bin/ccsm.js +194 -194
  4. package/lib/cliSessionWatcher.js +249 -249
  5. package/lib/config.js +185 -185
  6. package/lib/folders.js +96 -96
  7. package/lib/localCliSessions.js +489 -177
  8. package/lib/persistedSessions.js +134 -134
  9. package/lib/webTerminal.js +208 -208
  10. package/lib/workspace.js +230 -255
  11. package/package.json +57 -57
  12. package/public/css/base.css +99 -99
  13. package/public/css/cards.css +183 -183
  14. package/public/css/feedback.css +303 -303
  15. package/public/css/forms.css +405 -405
  16. package/public/css/layout.css +160 -160
  17. package/public/css/modal.css +190 -183
  18. package/public/css/responsive.css +10 -10
  19. package/public/css/sidebar.css +616 -601
  20. package/public/css/terminals.css +294 -294
  21. package/public/css/tokens.css +81 -79
  22. package/public/css/wco.css +98 -98
  23. package/public/css/widgets.css +1596 -1375
  24. package/public/index.html +105 -103
  25. package/public/js/api.js +272 -260
  26. package/public/js/components/AdoptModal.js +343 -171
  27. package/public/js/components/App.js +35 -35
  28. package/public/js/components/DirectoryPicker.js +203 -203
  29. package/public/js/components/EntityFormModal.js +105 -105
  30. package/public/js/components/Modal.js +51 -51
  31. package/public/js/components/OfflineBanner.js +93 -93
  32. package/public/js/components/PageTitleBar.js +13 -13
  33. package/public/js/components/Picker.js +179 -179
  34. package/public/js/components/Popover.js +55 -55
  35. package/public/js/components/Sidebar.js +270 -270
  36. package/public/js/components/TerminalView.js +298 -298
  37. package/public/js/components/useDragSort.js +67 -67
  38. package/public/js/dialog.js +67 -67
  39. package/public/js/icons.js +177 -177
  40. package/public/js/main.js +140 -140
  41. package/public/js/pages/AboutPage.js +165 -165
  42. package/public/js/pages/ConfigurePage.js +475 -487
  43. package/public/js/pages/LaunchPage.js +369 -369
  44. package/public/js/pages/SessionsPage.js +97 -97
  45. package/public/js/state.js +231 -231
  46. package/public/manifest.webmanifest +15 -15
  47. package/scripts/install.js +137 -137
  48. package/server.js +1126 -1117
package/lib/workspace.js CHANGED
@@ -1,255 +1,230 @@
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, requireUnused = true }) {
99
- const all = await listWorkspaces({ workDir, repos });
100
- if (requireUnused) {
101
- const free = all.find((w) => !w.inUse);
102
- if (free) return { workspace: free, created: false };
103
- }
104
- const name = nextWorkspaceName(all);
105
- const wsPath = path.join(workDir, name);
106
- await ensureDir(wsPath);
107
- const ws = await describeWorkspace(wsPath, repos, []);
108
- return { workspace: ws, created: true };
109
- }
110
-
111
- // Parse a single git --progress line. Git emits these on stderr, using \r
112
- // to overwrite the same line in place, with the format:
113
- // "<phase>: <pct>% (<cur>/<total>), <detail>"
114
- // Examples:
115
- // "Receiving objects: 45% (12345/27384), 23.4 MiB | 5.2 MiB/s"
116
- // "Resolving deltas: 100% (5847/5847), done."
117
- function parseGitProgress(line) {
118
- if (!line) return null;
119
- const clean = line.replace(/^remote:\s*/, '').trim();
120
- const m = clean.match(/^([^:]+):\s+(\d+)%\s*(?:\((\d+)\/(\d+)\))?(?:,\s+(.+?))?$/);
121
- if (!m) return null;
122
- return {
123
- phase: m[1].trim(),
124
- percent: Number(m[2]),
125
- current: m[3] ? Number(m[3]) : null,
126
- total: m[4] ? Number(m[4]) : null,
127
- detail: m[5] ? m[5].trim() : null,
128
- raw: clean,
129
- };
130
- }
131
-
132
- function runGit(args, cwd, { onProgress, onLine } = {}) {
133
- return new Promise((resolve, reject) => {
134
- const child = spawn('git', args, {
135
- cwd,
136
- windowsHide: true,
137
- stdio: ['ignore', 'pipe', 'pipe'],
138
- });
139
- let out = '';
140
- let err = '';
141
- let stderrBuf = '';
142
- child.stdout.on('data', (d) => (out += d.toString()));
143
- child.stderr.on('data', (d) => {
144
- const text = d.toString();
145
- err += text;
146
- if (onProgress || onLine) {
147
- stderrBuf += text;
148
- const parts = stderrBuf.split(/[\r\n]/);
149
- stderrBuf = parts.pop();
150
- for (const line of parts) {
151
- if (!line) continue;
152
- if (onLine) onLine(line);
153
- if (onProgress) {
154
- const p = parseGitProgress(line);
155
- if (p) onProgress(p);
156
- }
157
- }
158
- }
159
- });
160
- child.on('error', reject);
161
- child.on('close', (code) => {
162
- if (stderrBuf && (onLine || onProgress)) {
163
- if (onLine) onLine(stderrBuf);
164
- if (onProgress) {
165
- const p = parseGitProgress(stderrBuf);
166
- if (p) onProgress(p);
167
- }
168
- }
169
- if (code === 0) resolve({ stdout: out, stderr: err });
170
- else
171
- reject(
172
- Object.assign(
173
- new Error(`git ${args.join(' ')} exited ${code}: ${err.trim()}`),
174
- { code, stdout: out, stderr: err }
175
- )
176
- );
177
- });
178
- });
179
- }
180
-
181
- async function cloneRepoInto({ workspacePath, repo, onProgress, onLine }) {
182
- const target = path.join(workspacePath, repo.name);
183
- if (await dirExists(target)) {
184
- if (await isGitClone(target)) {
185
- return { repo: repo.name, action: 'already-cloned', path: target };
186
- }
187
- throw new Error(
188
- `Target ${target} exists but is not a git clone — refusing to overwrite`
189
- );
190
- }
191
- // -c core.longpaths=true defeats Windows' default 260-char MAX_PATH so deep
192
- // repo trees (e.g. nested doc / .github skill paths) can check out
193
- // successfully. The flag only applies to this single git invocation.
194
- await runGit(
195
- ['-c', 'core.longpaths=true', 'clone', '--progress', repo.url, repo.name],
196
- workspacePath,
197
- { onProgress, onLine }
198
- );
199
- return { repo: repo.name, action: 'cloned', path: target };
200
- }
201
-
202
- async function ensureReposInWorkspace({ workspacePath, repos, onProgress, onLine, onRepoStart, onRepoEnd }) {
203
- const results = [];
204
- for (const repo of repos) {
205
- if (onRepoStart) onRepoStart(repo);
206
- try {
207
- const r = await cloneRepoInto({
208
- workspacePath,
209
- repo,
210
- onProgress: onProgress ? (p) => onProgress(repo, p) : null,
211
- onLine: onLine ? (l) => onLine(repo, l) : null,
212
- });
213
- if (onRepoEnd) onRepoEnd(repo, { ok: true, ...r });
214
- results.push({ ok: true, ...r });
215
- } catch (e) {
216
- const err = { ok: false, repo: repo.name, error: String(e && e.message || e) };
217
- if (onRepoEnd) onRepoEnd(repo, err);
218
- results.push(err);
219
- }
220
- }
221
- return results;
222
- }
223
-
224
- async function dirSize(p) {
225
- let total = 0;
226
- async function walk(dir) {
227
- let entries;
228
- try {
229
- entries = await fs.readdir(dir, { withFileTypes: true });
230
- } catch { return; }
231
- await Promise.all(entries.map(async (e) => {
232
- const full = path.join(dir, e.name);
233
- if (e.isSymbolicLink()) return; // don't follow symlinks
234
- if (e.isDirectory()) {
235
- await walk(full);
236
- } else if (e.isFile()) {
237
- try {
238
- const st = await fs.stat(full);
239
- total += st.size;
240
- } catch { /* skip */ }
241
- }
242
- }));
243
- }
244
- await walk(p);
245
- return total;
246
- }
247
-
248
- module.exports = {
249
- listWorkspaces,
250
- findOrCreateWorkspace,
251
- ensureReposInWorkspace,
252
- isInside,
253
- nextWorkspaceName,
254
- dirSize,
255
- };
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, requireUnused = true }) {
99
+ const all = await listWorkspaces({ workDir, repos });
100
+ if (requireUnused) {
101
+ const free = all.find((w) => !w.inUse);
102
+ if (free) return { workspace: free, created: false };
103
+ }
104
+ const name = nextWorkspaceName(all);
105
+ const wsPath = path.join(workDir, name);
106
+ await ensureDir(wsPath);
107
+ const ws = await describeWorkspace(wsPath, repos, []);
108
+ return { workspace: ws, created: true };
109
+ }
110
+
111
+ // Parse a single git --progress line. Git emits these on stderr, using \r
112
+ // to overwrite the same line in place, with the format:
113
+ // "<phase>: <pct>% (<cur>/<total>), <detail>"
114
+ // Examples:
115
+ // "Receiving objects: 45% (12345/27384), 23.4 MiB | 5.2 MiB/s"
116
+ // "Resolving deltas: 100% (5847/5847), done."
117
+ function parseGitProgress(line) {
118
+ if (!line) return null;
119
+ const clean = line.replace(/^remote:\s*/, '').trim();
120
+ const m = clean.match(/^([^:]+):\s+(\d+)%\s*(?:\((\d+)\/(\d+)\))?(?:,\s+(.+?))?$/);
121
+ if (!m) return null;
122
+ return {
123
+ phase: m[1].trim(),
124
+ percent: Number(m[2]),
125
+ current: m[3] ? Number(m[3]) : null,
126
+ total: m[4] ? Number(m[4]) : null,
127
+ detail: m[5] ? m[5].trim() : null,
128
+ raw: clean,
129
+ };
130
+ }
131
+
132
+ function runGit(args, cwd, { onProgress, onLine } = {}) {
133
+ return new Promise((resolve, reject) => {
134
+ const child = spawn('git', args, {
135
+ cwd,
136
+ windowsHide: true,
137
+ stdio: ['ignore', 'pipe', 'pipe'],
138
+ });
139
+ let out = '';
140
+ let err = '';
141
+ let stderrBuf = '';
142
+ child.stdout.on('data', (d) => (out += d.toString()));
143
+ child.stderr.on('data', (d) => {
144
+ const text = d.toString();
145
+ err += text;
146
+ if (onProgress || onLine) {
147
+ stderrBuf += text;
148
+ const parts = stderrBuf.split(/[\r\n]/);
149
+ stderrBuf = parts.pop();
150
+ for (const line of parts) {
151
+ if (!line) continue;
152
+ if (onLine) onLine(line);
153
+ if (onProgress) {
154
+ const p = parseGitProgress(line);
155
+ if (p) onProgress(p);
156
+ }
157
+ }
158
+ }
159
+ });
160
+ child.on('error', reject);
161
+ child.on('close', (code) => {
162
+ if (stderrBuf && (onLine || onProgress)) {
163
+ if (onLine) onLine(stderrBuf);
164
+ if (onProgress) {
165
+ const p = parseGitProgress(stderrBuf);
166
+ if (p) onProgress(p);
167
+ }
168
+ }
169
+ if (code === 0) resolve({ stdout: out, stderr: err });
170
+ else
171
+ reject(
172
+ Object.assign(
173
+ new Error(`git ${args.join(' ')} exited ${code}: ${err.trim()}`),
174
+ { code, stdout: out, stderr: err }
175
+ )
176
+ );
177
+ });
178
+ });
179
+ }
180
+
181
+ async function cloneRepoInto({ workspacePath, repo, onProgress, onLine }) {
182
+ const target = path.join(workspacePath, repo.name);
183
+ if (await dirExists(target)) {
184
+ if (await isGitClone(target)) {
185
+ return { repo: repo.name, action: 'already-cloned', path: target };
186
+ }
187
+ throw new Error(
188
+ `Target ${target} exists but is not a git clone — refusing to overwrite`
189
+ );
190
+ }
191
+ // -c core.longpaths=true defeats Windows' default 260-char MAX_PATH so deep
192
+ // repo trees (e.g. nested doc / .github skill paths) can check out
193
+ // successfully. The flag only applies to this single git invocation.
194
+ await runGit(
195
+ ['-c', 'core.longpaths=true', 'clone', '--progress', repo.url, repo.name],
196
+ workspacePath,
197
+ { onProgress, onLine }
198
+ );
199
+ return { repo: repo.name, action: 'cloned', path: target };
200
+ }
201
+
202
+ async function ensureReposInWorkspace({ workspacePath, repos, onProgress, onLine, onRepoStart, onRepoEnd }) {
203
+ const results = [];
204
+ for (const repo of repos) {
205
+ if (onRepoStart) onRepoStart(repo);
206
+ try {
207
+ const r = await cloneRepoInto({
208
+ workspacePath,
209
+ repo,
210
+ onProgress: onProgress ? (p) => onProgress(repo, p) : null,
211
+ onLine: onLine ? (l) => onLine(repo, l) : null,
212
+ });
213
+ if (onRepoEnd) onRepoEnd(repo, { ok: true, ...r });
214
+ results.push({ ok: true, ...r });
215
+ } catch (e) {
216
+ const err = { ok: false, repo: repo.name, error: String(e && e.message || e) };
217
+ if (onRepoEnd) onRepoEnd(repo, err);
218
+ results.push(err);
219
+ }
220
+ }
221
+ return results;
222
+ }
223
+
224
+ module.exports = {
225
+ listWorkspaces,
226
+ findOrCreateWorkspace,
227
+ ensureReposInWorkspace,
228
+ isInside,
229
+ nextWorkspaceName,
230
+ };
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "name": "@bakapiano/ccsm",
3
- "version": "0.10.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 --watch server.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.11.0",
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 --watch server.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
+ }