@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
@@ -1,142 +1,144 @@
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
- };
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. Pre-assigned
25
+ // // at spawn time for CLIs with
26
+ // // newSessionIdArgs (claude, copilot); set
27
+ // // from disk for adopted sessions. Used
28
+ // // for precise --resume <id>.
29
+ // }
30
+
31
+ const path = require('node:path');
32
+ const fs = require('node:fs/promises');
33
+ const { DATA_DIR } = require('./config');
34
+ const { atomicWriteJson, withFileLock } = require('./atomicJson');
35
+
36
+ const FILE = path.join(DATA_DIR, 'sessions.json');
37
+
38
+ async function loadAll() {
39
+ try {
40
+ const raw = await fs.readFile(FILE, 'utf8');
41
+ const j = JSON.parse(raw);
42
+ return Array.isArray(j) ? j : [];
43
+ } catch (e) {
44
+ if (e.code === 'ENOENT') return [];
45
+ throw e;
46
+ }
47
+ }
48
+
49
+ async function saveAll(list) {
50
+ await atomicWriteJson(FILE, list);
51
+ }
52
+
53
+ function genId() {
54
+ return 'sess-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
55
+ }
56
+
57
+ async function create(opts) {
58
+ return withFileLock(FILE, async () => {
59
+ const { cliId, cwd, workspace, repos = [], folderId = null, title = '', status = 'running', cliSessionId = null } = opts;
60
+ const list = await loadAll();
61
+ const entry = {
62
+ id: genId(),
63
+ cliId,
64
+ cwd,
65
+ workspace,
66
+ title,
67
+ folderId,
68
+ repos,
69
+ createdAt: Date.now(),
70
+ lastActiveAt: Date.now(),
71
+ status,
72
+ exitedAt: status === 'exited' ? Date.now() : null,
73
+ exitCode: null,
74
+ pid: null,
75
+ cliSessionId,
76
+ };
77
+ list.push(entry);
78
+ await saveAll(list);
79
+ return entry;
80
+ });
81
+ }
82
+
83
+ async function get(id) {
84
+ const list = await loadAll();
85
+ return list.find((s) => s.id === id) || null;
86
+ }
87
+
88
+ async function update(id, patch) {
89
+ return withFileLock(FILE, async () => {
90
+ const list = await loadAll();
91
+ const idx = list.findIndex((s) => s.id === id);
92
+ if (idx < 0) return null;
93
+ list[idx] = { ...list[idx], ...patch };
94
+ await saveAll(list);
95
+ return list[idx];
96
+ });
97
+ }
98
+
99
+ async function remove(id) {
100
+ return withFileLock(FILE, async () => {
101
+ const list = await loadAll();
102
+ const idx = list.findIndex((s) => s.id === id);
103
+ if (idx < 0) return false;
104
+ list.splice(idx, 1);
105
+ await saveAll(list);
106
+ return true;
107
+ });
108
+ }
109
+
110
+ // Convenience helpers used at runtime so callers don't have to do
111
+ // load/find/update/save themselves.
112
+ async function markRunning(id, pid) {
113
+ return update(id, { status: 'running', pid, exitedAt: null, exitCode: null, lastActiveAt: Date.now() });
114
+ }
115
+
116
+ async function markExited(id, exitCode) {
117
+ return update(id, { status: 'exited', exitCode: exitCode ?? null, exitedAt: Date.now(), pid: null });
118
+ }
119
+
120
+ async function touch(id) {
121
+ return update(id, { lastActiveAt: Date.now() });
122
+ }
123
+
124
+ async function setFolder(id, folderId) {
125
+ return update(id, { folderId: folderId || null });
126
+ }
127
+
128
+ async function setTitle(id, title) {
129
+ return update(id, { title: title || '' });
130
+ }
131
+
132
+ module.exports = {
133
+ loadAll,
134
+ create,
135
+ get,
136
+ update,
137
+ remove,
138
+ markRunning,
139
+ markExited,
140
+ touch,
141
+ setFolder,
142
+ setTitle,
143
+ FILE,
144
+ };