@bakapiano/ccsm 0.14.0 → 0.15.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.
Files changed (53) hide show
  1. package/CLAUDE.md +474 -475
  2. package/README.md +189 -190
  3. package/bin/ccsm.js +194 -194
  4. package/lib/cliActivity.js +118 -0
  5. package/lib/codexSeed.js +147 -0
  6. package/lib/config.js +205 -188
  7. package/lib/folders.js +105 -105
  8. package/lib/localCliSessions.js +489 -489
  9. package/lib/persistedSessions.js +144 -142
  10. package/lib/webTerminal.js +224 -224
  11. package/lib/workspace.js +230 -230
  12. package/package.json +57 -57
  13. package/public/css/base.css +99 -99
  14. package/public/css/cards.css +183 -183
  15. package/public/css/feedback.css +303 -303
  16. package/public/css/forms.css +405 -405
  17. package/public/css/layout.css +160 -160
  18. package/public/css/modal.css +190 -190
  19. package/public/css/responsive.css +10 -10
  20. package/public/css/sidebar.css +613 -608
  21. package/public/css/terminals.css +294 -294
  22. package/public/css/tokens.css +81 -81
  23. package/public/css/wco.css +98 -98
  24. package/public/css/widgets.css +1628 -1628
  25. package/public/index.html +111 -105
  26. package/public/js/api.js +296 -280
  27. package/public/js/components/AdoptModal.js +343 -343
  28. package/public/js/components/App.js +35 -35
  29. package/public/js/components/DirectoryPicker.js +203 -203
  30. package/public/js/components/EntityFormModal.js +141 -141
  31. package/public/js/components/Modal.js +51 -51
  32. package/public/js/components/OfflineBanner.js +93 -93
  33. package/public/js/components/PageTitleBar.js +13 -13
  34. package/public/js/components/Picker.js +179 -179
  35. package/public/js/components/Popover.js +55 -55
  36. package/public/js/components/Sidebar.js +299 -299
  37. package/public/js/components/TerminalView.js +314 -314
  38. package/public/js/components/useDragSort.js +67 -67
  39. package/public/js/dialog.js +67 -67
  40. package/public/js/icons.js +177 -177
  41. package/public/js/main.js +132 -132
  42. package/public/js/pages/AboutPage.js +173 -165
  43. package/public/js/pages/ConfigurePage.js +513 -475
  44. package/public/js/pages/LaunchPage.js +369 -369
  45. package/public/js/pages/SessionsPage.js +101 -97
  46. package/public/js/state.js +231 -231
  47. package/scripts/dev.js +44 -11
  48. package/scripts/install.js +158 -158
  49. package/scripts/restart-helper.js +96 -0
  50. package/scripts/upgrade-helper.js +6 -1
  51. package/server.js +1282 -1254
  52. package/lib/cliSessionWatcher.js +0 -275
  53. package/public/manifest.webmanifest +0 -15
package/lib/workspace.js CHANGED
@@ -1,230 +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
- module.exports = {
225
- listWorkspaces,
226
- findOrCreateWorkspace,
227
- ensureReposInWorkspace,
228
- isInside,
229
- nextWorkspaceName,
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
+ 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.14.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 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.15.1",
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
+ }