@bakapiano/ccsm 0.22.3 → 0.22.4

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 (60) hide show
  1. package/CLAUDE.md +538 -538
  2. package/README.md +189 -189
  3. package/bin/ccsm.js +235 -235
  4. package/lib/cliActivity.js +139 -139
  5. package/lib/codexSeed.js +183 -183
  6. package/lib/config.js +274 -274
  7. package/lib/devices.js +229 -229
  8. package/lib/folders.js +124 -124
  9. package/lib/localCliSessions.js +519 -519
  10. package/lib/persistedSessions.js +129 -129
  11. package/lib/tunnel.js +621 -621
  12. package/lib/webTerminal.js +225 -225
  13. package/lib/workspace.js +233 -233
  14. package/package.json +57 -57
  15. package/public/css/base.css +99 -99
  16. package/public/css/cards.css +183 -183
  17. package/public/css/feedback.css +504 -504
  18. package/public/css/forms.css +453 -453
  19. package/public/css/layout.css +176 -176
  20. package/public/css/modal.css +190 -190
  21. package/public/css/responsive.css +176 -176
  22. package/public/css/sidebar.css +707 -707
  23. package/public/css/terminals.css +592 -592
  24. package/public/css/tokens.css +81 -81
  25. package/public/css/wco.css +196 -196
  26. package/public/css/widgets.css +2725 -2725
  27. package/public/index.html +152 -152
  28. package/public/js/api.js +371 -371
  29. package/public/js/backend.js +149 -149
  30. package/public/js/components/App.js +73 -73
  31. package/public/js/components/DirectoryPicker.js +203 -203
  32. package/public/js/components/EntityFormModal.js +153 -153
  33. package/public/js/components/Modal.js +57 -57
  34. package/public/js/components/OfflineBanner.js +67 -67
  35. package/public/js/components/PageTitleBar.js +13 -13
  36. package/public/js/components/PendingApprovalOverlay.js +128 -128
  37. package/public/js/components/Picker.js +179 -179
  38. package/public/js/components/Popover.js +55 -55
  39. package/public/js/components/RestartOverlay.js +36 -36
  40. package/public/js/components/Sidebar.js +380 -380
  41. package/public/js/components/TerminalInstance.js +148 -22
  42. package/public/js/components/TerminalResizeDebouncer.js +126 -0
  43. package/public/js/components/XtermTerminal.js +62 -15
  44. package/public/js/components/useDragSort.js +67 -67
  45. package/public/js/dialog.js +67 -67
  46. package/public/js/icons.js +212 -212
  47. package/public/js/main.js +296 -296
  48. package/public/js/pages/AboutPage.js +90 -90
  49. package/public/js/pages/ConfigurePage.js +713 -713
  50. package/public/js/pages/LaunchPage.js +421 -421
  51. package/public/js/pages/RemotePage.js +743 -743
  52. package/public/js/pages/SessionsPage.js +100 -100
  53. package/public/js/state.js +335 -335
  54. package/public/manifest.webmanifest +25 -0
  55. package/public/setup/index.html +567 -0
  56. package/scripts/dev.js +149 -149
  57. package/scripts/install.js +153 -153
  58. package/scripts/restart-helper.js +96 -96
  59. package/scripts/upgrade-helper.js +687 -687
  60. package/server.js +1807 -1807
package/lib/folders.js CHANGED
@@ -1,124 +1,124 @@
1
- 'use strict';
2
-
3
- // User-curated folders. Sessions reference these by id. Order is
4
- // user-controlled (drag-reorder in sidebar). The store is a flat list
5
- // in $DATA_DIR/folders.json:
6
- // [{ id, name, order, createdAt }]
7
- //
8
- // Top-level "Unsorted" is implicit — sessions with folderId === null
9
- // render under it. The user can't delete or rename it; we just synthesise
10
- // the bucket in the frontend.
11
-
12
- const path = require('node:path');
13
- const fs = require('node:fs/promises');
14
- const { DATA_DIR } = require('./config');
15
- const { atomicWriteJson, withFileLock } = require('./atomicJson');
16
-
17
- const FILE = path.join(DATA_DIR, 'folders.json');
18
-
19
- // Sentinel for the synthetic "Unsorted" folder. Sessions with
20
- // folderId === null render under it. We always materialize it in the
21
- // returned list so the sidebar can drag-reorder it like a real folder,
22
- // but create/update/delete refuse to touch it.
23
- const UNSORTED_ID = 'unsorted';
24
- function unsortedDefault(order) {
25
- return { id: UNSORTED_ID, name: 'Unsorted', order, builtin: true };
26
- }
27
-
28
- async function loadAll() {
29
- let list = [];
30
- try {
31
- const raw = await fs.readFile(FILE, 'utf8');
32
- const j = JSON.parse(raw);
33
- if (Array.isArray(j)) list = j;
34
- } catch (e) {
35
- if (e.code !== 'ENOENT') throw e;
36
- }
37
- // Ensure the synthetic Unsorted entry is present. New install: append
38
- // at the end. Existing install pre-Unsorted-draggable: same.
39
- if (!list.find((f) => f.id === UNSORTED_ID)) {
40
- list = list.concat(unsortedDefault(list.length));
41
- }
42
- return list;
43
- }
44
-
45
- async function saveAll(list) {
46
- await atomicWriteJson(FILE, list);
47
- }
48
-
49
- function genId() {
50
- return 'folder-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
51
- }
52
-
53
- async function create({ name }) {
54
- if (!name || typeof name !== 'string') throw new Error('name required');
55
- return withFileLock(FILE, async () => {
56
- const list = await loadAll();
57
- const entry = {
58
- id: genId(),
59
- name: name.trim(),
60
- order: list.length,
61
- createdAt: Date.now(),
62
- };
63
- list.push(entry);
64
- await saveAll(list);
65
- return entry;
66
- });
67
- }
68
-
69
- async function update(id, patch) {
70
- if (id === UNSORTED_ID && typeof patch.name === 'string') {
71
- throw new Error('cannot rename the Unsorted bucket');
72
- }
73
- return withFileLock(FILE, async () => {
74
- const list = await loadAll();
75
- const idx = list.findIndex((f) => f.id === id);
76
- if (idx < 0) return null;
77
- // Allow rename + reorder, ignore other keys.
78
- const allowed = {};
79
- if (id !== UNSORTED_ID && typeof patch.name === 'string') allowed.name = patch.name.trim();
80
- if (typeof patch.order === 'number') allowed.order = patch.order;
81
- list[idx] = { ...list[idx], ...allowed };
82
- await saveAll(list);
83
- return list[idx];
84
- });
85
- }
86
-
87
- async function remove(id) {
88
- if (id === UNSORTED_ID) throw new Error('cannot delete the Unsorted bucket');
89
- return withFileLock(FILE, async () => {
90
- const list = await loadAll();
91
- const idx = list.findIndex((f) => f.id === id);
92
- if (idx < 0) return false;
93
- list.splice(idx, 1);
94
- await saveAll(list);
95
- return true;
96
- });
97
- }
98
-
99
- async function reorder(idsInOrder) {
100
- if (!Array.isArray(idsInOrder)) throw new Error('idsInOrder must be array');
101
- return withFileLock(FILE, async () => {
102
- const list = await loadAll();
103
- const byId = new Map(list.map((f) => [f.id, f]));
104
- const next = [];
105
- idsInOrder.forEach((id, i) => {
106
- const f = byId.get(id);
107
- if (f) {
108
- f.order = i;
109
- next.push(f);
110
- byId.delete(id);
111
- }
112
- });
113
- // Append any folders not mentioned in the new order, preserving original
114
- // relative order. Prevents accidentally dropping folders.
115
- for (const f of byId.values()) {
116
- f.order = next.length;
117
- next.push(f);
118
- }
119
- await saveAll(next);
120
- return next;
121
- });
122
- }
123
-
124
- module.exports = { loadAll, create, update, remove, reorder, FILE };
1
+ 'use strict';
2
+
3
+ // User-curated folders. Sessions reference these by id. Order is
4
+ // user-controlled (drag-reorder in sidebar). The store is a flat list
5
+ // in $DATA_DIR/folders.json:
6
+ // [{ id, name, order, createdAt }]
7
+ //
8
+ // Top-level "Unsorted" is implicit — sessions with folderId === null
9
+ // render under it. The user can't delete or rename it; we just synthesise
10
+ // the bucket in the frontend.
11
+
12
+ const path = require('node:path');
13
+ const fs = require('node:fs/promises');
14
+ const { DATA_DIR } = require('./config');
15
+ const { atomicWriteJson, withFileLock } = require('./atomicJson');
16
+
17
+ const FILE = path.join(DATA_DIR, 'folders.json');
18
+
19
+ // Sentinel for the synthetic "Unsorted" folder. Sessions with
20
+ // folderId === null render under it. We always materialize it in the
21
+ // returned list so the sidebar can drag-reorder it like a real folder,
22
+ // but create/update/delete refuse to touch it.
23
+ const UNSORTED_ID = 'unsorted';
24
+ function unsortedDefault(order) {
25
+ return { id: UNSORTED_ID, name: 'Unsorted', order, builtin: true };
26
+ }
27
+
28
+ async function loadAll() {
29
+ let list = [];
30
+ try {
31
+ const raw = await fs.readFile(FILE, 'utf8');
32
+ const j = JSON.parse(raw);
33
+ if (Array.isArray(j)) list = j;
34
+ } catch (e) {
35
+ if (e.code !== 'ENOENT') throw e;
36
+ }
37
+ // Ensure the synthetic Unsorted entry is present. New install: append
38
+ // at the end. Existing install pre-Unsorted-draggable: same.
39
+ if (!list.find((f) => f.id === UNSORTED_ID)) {
40
+ list = list.concat(unsortedDefault(list.length));
41
+ }
42
+ return list;
43
+ }
44
+
45
+ async function saveAll(list) {
46
+ await atomicWriteJson(FILE, list);
47
+ }
48
+
49
+ function genId() {
50
+ return 'folder-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 8);
51
+ }
52
+
53
+ async function create({ name }) {
54
+ if (!name || typeof name !== 'string') throw new Error('name required');
55
+ return withFileLock(FILE, async () => {
56
+ const list = await loadAll();
57
+ const entry = {
58
+ id: genId(),
59
+ name: name.trim(),
60
+ order: list.length,
61
+ createdAt: Date.now(),
62
+ };
63
+ list.push(entry);
64
+ await saveAll(list);
65
+ return entry;
66
+ });
67
+ }
68
+
69
+ async function update(id, patch) {
70
+ if (id === UNSORTED_ID && typeof patch.name === 'string') {
71
+ throw new Error('cannot rename the Unsorted bucket');
72
+ }
73
+ return withFileLock(FILE, async () => {
74
+ const list = await loadAll();
75
+ const idx = list.findIndex((f) => f.id === id);
76
+ if (idx < 0) return null;
77
+ // Allow rename + reorder, ignore other keys.
78
+ const allowed = {};
79
+ if (id !== UNSORTED_ID && typeof patch.name === 'string') allowed.name = patch.name.trim();
80
+ if (typeof patch.order === 'number') allowed.order = patch.order;
81
+ list[idx] = { ...list[idx], ...allowed };
82
+ await saveAll(list);
83
+ return list[idx];
84
+ });
85
+ }
86
+
87
+ async function remove(id) {
88
+ if (id === UNSORTED_ID) throw new Error('cannot delete the Unsorted bucket');
89
+ return withFileLock(FILE, async () => {
90
+ const list = await loadAll();
91
+ const idx = list.findIndex((f) => f.id === id);
92
+ if (idx < 0) return false;
93
+ list.splice(idx, 1);
94
+ await saveAll(list);
95
+ return true;
96
+ });
97
+ }
98
+
99
+ async function reorder(idsInOrder) {
100
+ if (!Array.isArray(idsInOrder)) throw new Error('idsInOrder must be array');
101
+ return withFileLock(FILE, async () => {
102
+ const list = await loadAll();
103
+ const byId = new Map(list.map((f) => [f.id, f]));
104
+ const next = [];
105
+ idsInOrder.forEach((id, i) => {
106
+ const f = byId.get(id);
107
+ if (f) {
108
+ f.order = i;
109
+ next.push(f);
110
+ byId.delete(id);
111
+ }
112
+ });
113
+ // Append any folders not mentioned in the new order, preserving original
114
+ // relative order. Prevents accidentally dropping folders.
115
+ for (const f of byId.values()) {
116
+ f.order = next.length;
117
+ next.push(f);
118
+ }
119
+ await saveAll(next);
120
+ return next;
121
+ });
122
+ }
123
+
124
+ module.exports = { loadAll, create, update, remove, reorder, FILE };