@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.
- package/CLAUDE.md +475 -475
- package/README.md +190 -190
- package/bin/ccsm.js +194 -194
- package/lib/cliSessionWatcher.js +249 -249
- package/lib/config.js +185 -185
- package/lib/folders.js +96 -96
- package/lib/localCliSessions.js +489 -177
- package/lib/persistedSessions.js +134 -134
- package/lib/webTerminal.js +208 -208
- package/lib/workspace.js +230 -255
- package/package.json +57 -57
- package/public/css/base.css +99 -99
- package/public/css/cards.css +183 -183
- package/public/css/feedback.css +303 -303
- package/public/css/forms.css +405 -405
- package/public/css/layout.css +160 -160
- package/public/css/modal.css +190 -183
- package/public/css/responsive.css +10 -10
- package/public/css/sidebar.css +616 -601
- package/public/css/terminals.css +294 -294
- package/public/css/tokens.css +81 -79
- package/public/css/wco.css +98 -98
- package/public/css/widgets.css +1596 -1375
- package/public/index.html +105 -103
- package/public/js/api.js +272 -260
- package/public/js/components/AdoptModal.js +343 -171
- package/public/js/components/App.js +35 -35
- package/public/js/components/DirectoryPicker.js +203 -203
- package/public/js/components/EntityFormModal.js +105 -105
- package/public/js/components/Modal.js +51 -51
- package/public/js/components/OfflineBanner.js +93 -93
- package/public/js/components/PageTitleBar.js +13 -13
- package/public/js/components/Picker.js +179 -179
- package/public/js/components/Popover.js +55 -55
- package/public/js/components/Sidebar.js +270 -270
- package/public/js/components/TerminalView.js +298 -298
- package/public/js/components/useDragSort.js +67 -67
- package/public/js/dialog.js +67 -67
- package/public/js/icons.js +177 -177
- package/public/js/main.js +140 -140
- package/public/js/pages/AboutPage.js +165 -165
- package/public/js/pages/ConfigurePage.js +475 -487
- package/public/js/pages/LaunchPage.js +369 -369
- package/public/js/pages/SessionsPage.js +97 -97
- package/public/js/state.js +231 -231
- package/public/manifest.webmanifest +15 -15
- package/scripts/install.js +137 -137
- package/server.js +1126 -1117
package/lib/persistedSessions.js
CHANGED
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// ccsm-owned session records. Replaces the old "scan ~/.claude/sessions/
|
|
4
|
-
// + tasklist" path entirely: we no longer try to enumerate every claude
|
|
5
|
-
// process on the machine. Instead, every session ccsm starts (via the
|
|
6
|
-
// web terminal) gets recorded here, and the user organises them in
|
|
7
|
-
// folders.
|
|
8
|
-
//
|
|
9
|
-
// Each entry:
|
|
10
|
-
// {
|
|
11
|
-
// id: 'sess-...', // ccsm's session id (matches webTerminal id)
|
|
12
|
-
// cliId: 'claude', // which CLI from config.clis
|
|
13
|
-
// cwd: '...', // absolute workspace path
|
|
14
|
-
// workspace: 'ws-3', // basename of cwd (display)
|
|
15
|
-
// title: '', // user-edited label (Configure / sidebar tree)
|
|
16
|
-
// folderId: null, // nullable; null = "Unsorted" top-level
|
|
17
|
-
// repos: ['foo','bar'], // names of repos cloned into cwd at launch
|
|
18
|
-
// createdAt: 1234,
|
|
19
|
-
// lastActiveAt: 1234, // updated on attach/input; drives sort
|
|
20
|
-
// status: 'running'|'exited',
|
|
21
|
-
// exitedAt: null,
|
|
22
|
-
// exitCode: null,
|
|
23
|
-
// pid: null, // current pid if running
|
|
24
|
-
// cliSessionId: null, // upstream CLI's session UUID (captured
|
|
25
|
-
// // by lib/cliSessionWatcher after spawn);
|
|
26
|
-
// // used for precise --resume <id>.
|
|
27
|
-
// }
|
|
28
|
-
|
|
29
|
-
const path = require('node:path');
|
|
30
|
-
const fs = require('node:fs/promises');
|
|
31
|
-
const { DATA_DIR } = require('./config');
|
|
32
|
-
|
|
33
|
-
const FILE = path.join(DATA_DIR, 'sessions.json');
|
|
34
|
-
|
|
35
|
-
async function loadAll() {
|
|
36
|
-
try {
|
|
37
|
-
const raw = await fs.readFile(FILE, 'utf8');
|
|
38
|
-
const j = JSON.parse(raw);
|
|
39
|
-
return Array.isArray(j) ? j : [];
|
|
40
|
-
} catch (e) {
|
|
41
|
-
if (e.code === 'ENOENT') return [];
|
|
42
|
-
throw e;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function saveAll(list) {
|
|
47
|
-
await fs.writeFile(FILE, JSON.stringify(list, null, 2));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function genId() {
|
|
51
|
-
return 'sess-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function create({ cliId, cwd, workspace, repos = [], folderId = null, title = '', status = 'running', cliSessionId = null }) {
|
|
55
|
-
const list = await loadAll();
|
|
56
|
-
const entry = {
|
|
57
|
-
id: genId(),
|
|
58
|
-
cliId,
|
|
59
|
-
cwd,
|
|
60
|
-
workspace,
|
|
61
|
-
title,
|
|
62
|
-
folderId,
|
|
63
|
-
repos,
|
|
64
|
-
createdAt: Date.now(),
|
|
65
|
-
lastActiveAt: Date.now(),
|
|
66
|
-
status,
|
|
67
|
-
exitedAt: status === 'exited' ? Date.now() : null,
|
|
68
|
-
exitCode: null,
|
|
69
|
-
pid: null,
|
|
70
|
-
cliSessionId,
|
|
71
|
-
};
|
|
72
|
-
list.push(entry);
|
|
73
|
-
await saveAll(list);
|
|
74
|
-
return entry;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function get(id) {
|
|
78
|
-
const list = await loadAll();
|
|
79
|
-
return list.find((s) => s.id === id) || null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async function update(id, patch) {
|
|
83
|
-
const list = await loadAll();
|
|
84
|
-
const idx = list.findIndex((s) => s.id === id);
|
|
85
|
-
if (idx < 0) return null;
|
|
86
|
-
list[idx] = { ...list[idx], ...patch };
|
|
87
|
-
await saveAll(list);
|
|
88
|
-
return list[idx];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async function remove(id) {
|
|
92
|
-
const list = await loadAll();
|
|
93
|
-
const idx = list.findIndex((s) => s.id === id);
|
|
94
|
-
if (idx < 0) return false;
|
|
95
|
-
list.splice(idx, 1);
|
|
96
|
-
await saveAll(list);
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Convenience helpers used at runtime so callers don't have to do
|
|
101
|
-
// load/find/update/save themselves.
|
|
102
|
-
async function markRunning(id, pid) {
|
|
103
|
-
return update(id, { status: 'running', pid, exitedAt: null, exitCode: null, lastActiveAt: Date.now() });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async function markExited(id, exitCode) {
|
|
107
|
-
return update(id, { status: 'exited', exitCode: exitCode ?? null, exitedAt: Date.now(), pid: null });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function touch(id) {
|
|
111
|
-
return update(id, { lastActiveAt: Date.now() });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async function setFolder(id, folderId) {
|
|
115
|
-
return update(id, { folderId: folderId || null });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function setTitle(id, title) {
|
|
119
|
-
return update(id, { title: title || '' });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
module.exports = {
|
|
123
|
-
loadAll,
|
|
124
|
-
create,
|
|
125
|
-
get,
|
|
126
|
-
update,
|
|
127
|
-
remove,
|
|
128
|
-
markRunning,
|
|
129
|
-
markExited,
|
|
130
|
-
touch,
|
|
131
|
-
setFolder,
|
|
132
|
-
setTitle,
|
|
133
|
-
FILE,
|
|
134
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// ccsm-owned session records. Replaces the old "scan ~/.claude/sessions/
|
|
4
|
+
// + tasklist" path entirely: we no longer try to enumerate every claude
|
|
5
|
+
// process on the machine. Instead, every session ccsm starts (via the
|
|
6
|
+
// web terminal) gets recorded here, and the user organises them in
|
|
7
|
+
// folders.
|
|
8
|
+
//
|
|
9
|
+
// Each entry:
|
|
10
|
+
// {
|
|
11
|
+
// id: 'sess-...', // ccsm's session id (matches webTerminal id)
|
|
12
|
+
// cliId: 'claude', // which CLI from config.clis
|
|
13
|
+
// cwd: '...', // absolute workspace path
|
|
14
|
+
// workspace: 'ws-3', // basename of cwd (display)
|
|
15
|
+
// title: '', // user-edited label (Configure / sidebar tree)
|
|
16
|
+
// folderId: null, // nullable; null = "Unsorted" top-level
|
|
17
|
+
// repos: ['foo','bar'], // names of repos cloned into cwd at launch
|
|
18
|
+
// createdAt: 1234,
|
|
19
|
+
// lastActiveAt: 1234, // updated on attach/input; drives sort
|
|
20
|
+
// status: 'running'|'exited',
|
|
21
|
+
// exitedAt: null,
|
|
22
|
+
// exitCode: null,
|
|
23
|
+
// pid: null, // current pid if running
|
|
24
|
+
// cliSessionId: null, // upstream CLI's session UUID (captured
|
|
25
|
+
// // by lib/cliSessionWatcher after spawn);
|
|
26
|
+
// // used for precise --resume <id>.
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
const path = require('node:path');
|
|
30
|
+
const fs = require('node:fs/promises');
|
|
31
|
+
const { DATA_DIR } = require('./config');
|
|
32
|
+
|
|
33
|
+
const FILE = path.join(DATA_DIR, 'sessions.json');
|
|
34
|
+
|
|
35
|
+
async function loadAll() {
|
|
36
|
+
try {
|
|
37
|
+
const raw = await fs.readFile(FILE, 'utf8');
|
|
38
|
+
const j = JSON.parse(raw);
|
|
39
|
+
return Array.isArray(j) ? j : [];
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e.code === 'ENOENT') return [];
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function saveAll(list) {
|
|
47
|
+
await fs.writeFile(FILE, JSON.stringify(list, null, 2));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function genId() {
|
|
51
|
+
return 'sess-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function create({ cliId, cwd, workspace, repos = [], folderId = null, title = '', status = 'running', cliSessionId = null }) {
|
|
55
|
+
const list = await loadAll();
|
|
56
|
+
const entry = {
|
|
57
|
+
id: genId(),
|
|
58
|
+
cliId,
|
|
59
|
+
cwd,
|
|
60
|
+
workspace,
|
|
61
|
+
title,
|
|
62
|
+
folderId,
|
|
63
|
+
repos,
|
|
64
|
+
createdAt: Date.now(),
|
|
65
|
+
lastActiveAt: Date.now(),
|
|
66
|
+
status,
|
|
67
|
+
exitedAt: status === 'exited' ? Date.now() : null,
|
|
68
|
+
exitCode: null,
|
|
69
|
+
pid: null,
|
|
70
|
+
cliSessionId,
|
|
71
|
+
};
|
|
72
|
+
list.push(entry);
|
|
73
|
+
await saveAll(list);
|
|
74
|
+
return entry;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function get(id) {
|
|
78
|
+
const list = await loadAll();
|
|
79
|
+
return list.find((s) => s.id === id) || null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function update(id, patch) {
|
|
83
|
+
const list = await loadAll();
|
|
84
|
+
const idx = list.findIndex((s) => s.id === id);
|
|
85
|
+
if (idx < 0) return null;
|
|
86
|
+
list[idx] = { ...list[idx], ...patch };
|
|
87
|
+
await saveAll(list);
|
|
88
|
+
return list[idx];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function remove(id) {
|
|
92
|
+
const list = await loadAll();
|
|
93
|
+
const idx = list.findIndex((s) => s.id === id);
|
|
94
|
+
if (idx < 0) return false;
|
|
95
|
+
list.splice(idx, 1);
|
|
96
|
+
await saveAll(list);
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Convenience helpers used at runtime so callers don't have to do
|
|
101
|
+
// load/find/update/save themselves.
|
|
102
|
+
async function markRunning(id, pid) {
|
|
103
|
+
return update(id, { status: 'running', pid, exitedAt: null, exitCode: null, lastActiveAt: Date.now() });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function markExited(id, exitCode) {
|
|
107
|
+
return update(id, { status: 'exited', exitCode: exitCode ?? null, exitedAt: Date.now(), pid: null });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function touch(id) {
|
|
111
|
+
return update(id, { lastActiveAt: Date.now() });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function setFolder(id, folderId) {
|
|
115
|
+
return update(id, { folderId: folderId || null });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function setTitle(id, title) {
|
|
119
|
+
return update(id, { title: title || '' });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
loadAll,
|
|
124
|
+
create,
|
|
125
|
+
get,
|
|
126
|
+
update,
|
|
127
|
+
remove,
|
|
128
|
+
markRunning,
|
|
129
|
+
markExited,
|
|
130
|
+
touch,
|
|
131
|
+
setFolder,
|
|
132
|
+
setTitle,
|
|
133
|
+
FILE,
|
|
134
|
+
};
|