@bakapiano/ccsm 0.10.3 → 0.12.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 (51) hide show
  1. package/CLAUDE.md +475 -475
  2. package/README.md +190 -190
  3. package/bin/ccsm.js +194 -194
  4. package/lib/atomicJson.js +48 -0
  5. package/lib/cliSessionWatcher.js +249 -249
  6. package/lib/config.js +188 -185
  7. package/lib/folders.js +105 -96
  8. package/lib/jsonStore.js +15 -10
  9. package/lib/localCliSessions.js +489 -177
  10. package/lib/persistedSessions.js +142 -134
  11. package/lib/webTerminal.js +208 -208
  12. package/lib/workspace.js +230 -255
  13. package/package.json +57 -57
  14. package/public/css/base.css +99 -99
  15. package/public/css/cards.css +183 -183
  16. package/public/css/feedback.css +303 -303
  17. package/public/css/forms.css +405 -405
  18. package/public/css/layout.css +160 -160
  19. package/public/css/modal.css +190 -183
  20. package/public/css/responsive.css +10 -10
  21. package/public/css/sidebar.css +608 -601
  22. package/public/css/terminals.css +294 -294
  23. package/public/css/tokens.css +81 -79
  24. package/public/css/wco.css +98 -98
  25. package/public/css/widgets.css +1596 -1375
  26. package/public/index.html +105 -103
  27. package/public/js/api.js +272 -260
  28. package/public/js/components/AdoptModal.js +343 -171
  29. package/public/js/components/App.js +35 -35
  30. package/public/js/components/DirectoryPicker.js +203 -203
  31. package/public/js/components/EntityFormModal.js +105 -105
  32. package/public/js/components/Modal.js +51 -51
  33. package/public/js/components/OfflineBanner.js +93 -93
  34. package/public/js/components/PageTitleBar.js +13 -13
  35. package/public/js/components/Picker.js +179 -179
  36. package/public/js/components/Popover.js +55 -55
  37. package/public/js/components/Sidebar.js +341 -270
  38. package/public/js/components/TerminalView.js +298 -298
  39. package/public/js/components/useDragSort.js +67 -67
  40. package/public/js/dialog.js +67 -67
  41. package/public/js/icons.js +177 -177
  42. package/public/js/main.js +132 -140
  43. package/public/js/pages/AboutPage.js +165 -165
  44. package/public/js/pages/ConfigurePage.js +475 -487
  45. package/public/js/pages/LaunchPage.js +369 -369
  46. package/public/js/pages/SessionsPage.js +97 -97
  47. package/public/js/state.js +231 -231
  48. package/public/manifest.webmanifest +15 -15
  49. package/scripts/dev.js +59 -0
  50. package/scripts/install.js +137 -137
  51. package/server.js +1147 -1117
@@ -1,134 +1,142 @@
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
+ const { atomicWriteJson, withFileLock } = require('./atomicJson');
33
+
34
+ const FILE = path.join(DATA_DIR, 'sessions.json');
35
+
36
+ async function loadAll() {
37
+ try {
38
+ const raw = await fs.readFile(FILE, 'utf8');
39
+ const j = JSON.parse(raw);
40
+ return Array.isArray(j) ? j : [];
41
+ } catch (e) {
42
+ if (e.code === 'ENOENT') return [];
43
+ throw e;
44
+ }
45
+ }
46
+
47
+ async function saveAll(list) {
48
+ await atomicWriteJson(FILE, list);
49
+ }
50
+
51
+ function genId() {
52
+ return 'sess-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
53
+ }
54
+
55
+ async function create(opts) {
56
+ return withFileLock(FILE, async () => {
57
+ const { cliId, cwd, workspace, repos = [], folderId = null, title = '', status = 'running', cliSessionId = null } = opts;
58
+ const list = await loadAll();
59
+ const entry = {
60
+ id: genId(),
61
+ cliId,
62
+ cwd,
63
+ workspace,
64
+ title,
65
+ folderId,
66
+ repos,
67
+ createdAt: Date.now(),
68
+ lastActiveAt: Date.now(),
69
+ status,
70
+ exitedAt: status === 'exited' ? Date.now() : null,
71
+ exitCode: null,
72
+ pid: null,
73
+ cliSessionId,
74
+ };
75
+ list.push(entry);
76
+ await saveAll(list);
77
+ return entry;
78
+ });
79
+ }
80
+
81
+ async function get(id) {
82
+ const list = await loadAll();
83
+ return list.find((s) => s.id === id) || null;
84
+ }
85
+
86
+ async function update(id, patch) {
87
+ return withFileLock(FILE, async () => {
88
+ const list = await loadAll();
89
+ const idx = list.findIndex((s) => s.id === id);
90
+ if (idx < 0) return null;
91
+ list[idx] = { ...list[idx], ...patch };
92
+ await saveAll(list);
93
+ return list[idx];
94
+ });
95
+ }
96
+
97
+ async function remove(id) {
98
+ return withFileLock(FILE, async () => {
99
+ const list = await loadAll();
100
+ const idx = list.findIndex((s) => s.id === id);
101
+ if (idx < 0) return false;
102
+ list.splice(idx, 1);
103
+ await saveAll(list);
104
+ return true;
105
+ });
106
+ }
107
+
108
+ // Convenience helpers used at runtime so callers don't have to do
109
+ // load/find/update/save themselves.
110
+ async function markRunning(id, pid) {
111
+ return update(id, { status: 'running', pid, exitedAt: null, exitCode: null, lastActiveAt: Date.now() });
112
+ }
113
+
114
+ async function markExited(id, exitCode) {
115
+ return update(id, { status: 'exited', exitCode: exitCode ?? null, exitedAt: Date.now(), pid: null });
116
+ }
117
+
118
+ async function touch(id) {
119
+ return update(id, { lastActiveAt: Date.now() });
120
+ }
121
+
122
+ async function setFolder(id, folderId) {
123
+ return update(id, { folderId: folderId || null });
124
+ }
125
+
126
+ async function setTitle(id, title) {
127
+ return update(id, { title: title || '' });
128
+ }
129
+
130
+ module.exports = {
131
+ loadAll,
132
+ create,
133
+ get,
134
+ update,
135
+ remove,
136
+ markRunning,
137
+ markExited,
138
+ touch,
139
+ setFolder,
140
+ setTitle,
141
+ FILE,
142
+ };