@bakapiano/ccsm 0.13.0 → 0.15.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 (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 +211 -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 +165 -165
  43. package/public/js/pages/ConfigurePage.js +505 -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 -137
  49. package/scripts/restart-helper.js +91 -0
  50. package/scripts/upgrade-helper.js +155 -0
  51. package/server.js +1278 -1232
  52. package/lib/cliSessionWatcher.js +0 -249
  53. package/public/manifest.webmanifest +0 -15
@@ -1,35 +1,35 @@
1
- import { html } from '../html.js';
2
- import { activeTab } from '../state.js';
3
- import { Sidebar } from './Sidebar.js';
4
- import { Toast } from './Toast.js';
5
- import { DialogHost } from './DialogHost.js';
6
- import { OfflineBanner } from './OfflineBanner.js';
7
- import { SessionsPage } from '../pages/SessionsPage.js';
8
- import { LaunchPage } from '../pages/LaunchPage.js';
9
- import { ConfigurePage } from '../pages/ConfigurePage.js';
10
- import { AboutPage } from '../pages/AboutPage.js';
11
-
12
- function Panel({ name, children }) {
13
- const active = activeTab.value === name;
14
- return html`<section class="tab-panel" data-panel=${name} data-active=${active || null}>${children}</section>`;
15
- }
16
-
17
- export function App() {
18
- const tab = activeTab.value;
19
-
20
- return html`
21
- <div class="app">
22
- <${Sidebar} />
23
- <main class="main">
24
- <div class="content">
25
- ${tab === 'sessions' ? html`<${Panel} name="sessions"><${SessionsPage} /></${Panel}>` : null}
26
- ${tab === 'launch' ? html`<${Panel} name="launch"><${LaunchPage} /></${Panel}>` : null}
27
- ${tab === 'configure' ? html`<${Panel} name="configure"><${ConfigurePage} /></${Panel}>` : null}
28
- ${tab === 'about' ? html`<${Panel} name="about"><${AboutPage} /></${Panel}>` : null}
29
- </div>
30
- </main>
31
- <${OfflineBanner} />
32
- <${Toast} />
33
- <${DialogHost} />
34
- </div>`;
35
- }
1
+ import { html } from '../html.js';
2
+ import { activeTab } from '../state.js';
3
+ import { Sidebar } from './Sidebar.js';
4
+ import { Toast } from './Toast.js';
5
+ import { DialogHost } from './DialogHost.js';
6
+ import { OfflineBanner } from './OfflineBanner.js';
7
+ import { SessionsPage } from '../pages/SessionsPage.js';
8
+ import { LaunchPage } from '../pages/LaunchPage.js';
9
+ import { ConfigurePage } from '../pages/ConfigurePage.js';
10
+ import { AboutPage } from '../pages/AboutPage.js';
11
+
12
+ function Panel({ name, children }) {
13
+ const active = activeTab.value === name;
14
+ return html`<section class="tab-panel" data-panel=${name} data-active=${active || null}>${children}</section>`;
15
+ }
16
+
17
+ export function App() {
18
+ const tab = activeTab.value;
19
+
20
+ return html`
21
+ <div class="app">
22
+ <${Sidebar} />
23
+ <main class="main">
24
+ <div class="content">
25
+ ${tab === 'sessions' ? html`<${Panel} name="sessions"><${SessionsPage} /></${Panel}>` : null}
26
+ ${tab === 'launch' ? html`<${Panel} name="launch"><${LaunchPage} /></${Panel}>` : null}
27
+ ${tab === 'configure' ? html`<${Panel} name="configure"><${ConfigurePage} /></${Panel}>` : null}
28
+ ${tab === 'about' ? html`<${Panel} name="about"><${AboutPage} /></${Panel}>` : null}
29
+ </div>
30
+ </main>
31
+ <${OfflineBanner} />
32
+ <${Toast} />
33
+ <${DialogHost} />
34
+ </div>`;
35
+ }
@@ -1,203 +1,203 @@
1
- // Directory browser used by Launch page. Windows-Explorer-style:
2
- // ┌───────────────────────────────────────────────┐
3
- // │ [←] [→] [↑] Home > Users > Admin > foo [✎] │ nav + breadcrumb
4
- // ├──────────────┬────────────────────────────────┤
5
- // │ Quick access │ folder rows (large, hoverable)│
6
- // │ Home │ ⌃ .. │
7
- // │ Work dir │ 📁 AppData │
8
- // │ C:\ │ 📁 ccsm-workspaces │
9
- // │ D:\ │ │
10
- // └──────────────┴────────────────────────────────┘
11
- //
12
- // The picker streams the currently-selected path back to the parent via
13
- // `onPick(path)` on every selection change. Confirm/cancel UI lives in
14
- // the parent (the workdir modal's shared footer) so auto + cwd modes
15
- // share one CTA.
16
- //
17
- // Props: { initialPath, onPick }
18
-
19
- import { html } from '../html.js';
20
- import { useEffect, useState } from 'preact/hooks';
21
- import { api } from '../api.js';
22
- import { setToast } from '../toast.js';
23
- import { IconFolder, IconHome, IconChevronLeft, IconChevronRight, IconChevronUp, IconPencil } from '../icons.js';
24
-
25
- export function DirectoryPicker({ initialPath, onPick }) {
26
- const [data, setData] = useState(null);
27
- const [path, setPath] = useState(initialPath || '');
28
- const [history, setHistory] = useState({ stack: [], cursor: -1 }); // back/forward
29
- const [editing, setEditing] = useState(false);
30
- const [input, setInput] = useState('');
31
- const [loading, setLoading] = useState(false);
32
-
33
- // Push the current selection up on every change so the parent's
34
- // shared "Use folder" CTA can act on it.
35
- const select = (p) => { setPath(p); setInput(p); onPick?.(p); };
36
-
37
- const browse = async (p, { pushHistory = true } = {}) => {
38
- setLoading(true);
39
- try {
40
- const url = '/api/browse' + (p ? `?path=${encodeURIComponent(p)}` : '');
41
- const r = await api('GET', url);
42
- setData(r);
43
- select(r.path);
44
- if (pushHistory) {
45
- setHistory((h) => {
46
- const head = h.stack.slice(0, h.cursor + 1);
47
- head.push(r.path);
48
- return { stack: head, cursor: head.length - 1 };
49
- });
50
- }
51
- } catch (e) { setToast(e.message, 'error'); }
52
- finally { setLoading(false); }
53
- };
54
-
55
- useEffect(() => { browse(initialPath); }, []);
56
-
57
- const canBack = history.cursor > 0;
58
- const canForward = history.cursor >= 0 && history.cursor < history.stack.length - 1;
59
-
60
- const goBack = () => {
61
- if (!canBack) return;
62
- const idx = history.cursor - 1;
63
- setHistory({ ...history, cursor: idx });
64
- browse(history.stack[idx], { pushHistory: false });
65
- };
66
- const goForward = () => {
67
- if (!canForward) return;
68
- const idx = history.cursor + 1;
69
- setHistory({ ...history, cursor: idx });
70
- browse(history.stack[idx], { pushHistory: false });
71
- };
72
- const goUp = () => {
73
- if (!data?.parent) return;
74
- browse(data.parent);
75
- };
76
- const onAddressSubmit = (ev) => {
77
- ev?.preventDefault?.();
78
- const p = (input || '').trim();
79
- setEditing(false);
80
- if (p && p !== path) browse(p);
81
- };
82
-
83
- if (!data) {
84
- return html`<div class="filex"><div class="filex-loading">Loading…</div></div>`;
85
- }
86
-
87
- // Build breadcrumb segments. Windows-style: "C:\Users\Admin\foo" →
88
- // [C:, Users, Admin, foo] with each segment clickable.
89
- const segments = breadcrumbSegments(data.path);
90
-
91
- return html`
92
- <div class="filex">
93
- <div class="filex-toolbar">
94
- <div class="filex-navbtns">
95
- <button class="filex-navbtn" title="Back" disabled=${!canBack} onClick=${goBack}>
96
- <${IconChevronLeft} />
97
- </button>
98
- <button class="filex-navbtn" title="Forward" disabled=${!canForward} onClick=${goForward}>
99
- <${IconChevronRight} />
100
- </button>
101
- <button class="filex-navbtn" title="Up" disabled=${!data.parent} onClick=${goUp}>
102
- <${IconChevronUp} />
103
- </button>
104
- </div>
105
-
106
- ${editing ? html`
107
- <form class="filex-address-edit" onSubmit=${onAddressSubmit}>
108
- <input class="filex-address-input mono" value=${input}
109
- autoFocus
110
- onInput=${(e) => setInput(e.target.value)}
111
- onBlur=${onAddressSubmit}
112
- onKeyDown=${(e) => { if (e.key === 'Escape') { setInput(data.path); setEditing(false); } }}
113
- spellcheck="false" />
114
- </form>
115
- ` : html`
116
- <div class="filex-breadcrumb"
117
- onClick=${(e) => { if (e.target === e.currentTarget) { setInput(data.path); setEditing(true); } }}>
118
- ${segments.map((seg, i) => html`
119
- <button key=${seg.path} class="filex-crumb"
120
- title=${seg.path}
121
- onClick=${() => browse(seg.path)}>
122
- ${i === 0 && seg.label.match(/^[a-z]:\\?$/i) ? null : null}
123
- ${seg.label}
124
- </button>
125
- ${i < segments.length - 1
126
- ? html`<span class="filex-crumb-sep" aria-hidden="true">›</span>`
127
- : null}
128
- `)}
129
- <button class="filex-address-edit-btn" title="Edit path"
130
- onClick=${() => { setInput(data.path); setEditing(true); }}>
131
- <${IconPencil} />
132
- </button>
133
- </div>
134
- `}
135
- </div>
136
-
137
- <div class="filex-body">
138
- <aside class="filex-side">
139
- <div class="filex-side-label">Quick access</div>
140
- ${(data.starts || []).map((s) => html`
141
- <button key=${s.path} class=${`filex-side-item${path === s.path ? ' is-active' : ''}`}
142
- onClick=${() => browse(s.path)}
143
- title=${s.path}>
144
- <span class="filex-side-icon">
145
- ${s.label === 'Home' ? html`<${IconHome} />` : html`<${IconFolder} />`}
146
- </span>
147
- <span class="filex-side-name">${s.label}</span>
148
- </button>`)}
149
- </aside>
150
-
151
- <div class="filex-main">
152
- ${!data.exists ? html`
153
- <div class="filex-empty">Directory not found.</div>
154
- ` : html`
155
- <div class="filex-list">
156
- ${data.entries.length === 0 ? html`
157
- <div class="filex-empty">This folder is empty.</div>
158
- ` : data.entries.map((e) => html`
159
- <button key=${e.path} class="filex-row"
160
- onDblClick=${() => browse(e.path)}
161
- onClick=${() => select(e.path)}
162
- data-active=${path === e.path}>
163
- <span class="filex-row-icon"><${IconFolder} /></span>
164
- <span class="filex-row-name">${e.name}</span>
165
- </button>`)}
166
- </div>`}
167
- </div>
168
- </div>
169
-
170
- <div class="filex-foot">
171
- <span class="filex-foot-current mono" title=${path}>${path || ' '}</span>
172
- </div>
173
- </div>`;
174
- }
175
-
176
- // "C:\Users\Admin\foo" → [{label:'C:', path:'C:\\'}, {label:'Users', path:'C:\\Users'}, …]
177
- // "/home/me/foo" → [{label:'/', path:'/'}, {label:'home', path:'/home'}, …]
178
- function breadcrumbSegments(p) {
179
- if (!p) return [];
180
- // Windows: split on backslash. Posix: forward slash.
181
- const isWin = /^[a-zA-Z]:[\\/]/.test(p);
182
- const sep = isWin ? '\\' : '/';
183
- const norm = p.replace(/[\\\/]+/g, sep);
184
- const parts = norm.split(sep).filter(Boolean);
185
- const segs = [];
186
- if (isWin) {
187
- // first part is drive like "C:"
188
- let acc = parts[0] + sep;
189
- segs.push({ label: parts[0], path: acc });
190
- for (let i = 1; i < parts.length; i++) {
191
- acc = (acc.endsWith(sep) ? acc.slice(0, -1) : acc) + sep + parts[i];
192
- segs.push({ label: parts[i], path: acc });
193
- }
194
- } else {
195
- let acc = '';
196
- segs.push({ label: '/', path: '/' });
197
- for (const part of parts) {
198
- acc = acc + sep + part;
199
- segs.push({ label: part, path: acc });
200
- }
201
- }
202
- return segs;
203
- }
1
+ // Directory browser used by Launch page. Windows-Explorer-style:
2
+ // ┌───────────────────────────────────────────────┐
3
+ // │ [←] [→] [↑] Home > Users > Admin > foo [✎] │ nav + breadcrumb
4
+ // ├──────────────┬────────────────────────────────┤
5
+ // │ Quick access │ folder rows (large, hoverable)│
6
+ // │ Home │ ⌃ .. │
7
+ // │ Work dir │ 📁 AppData │
8
+ // │ C:\ │ 📁 ccsm-workspaces │
9
+ // │ D:\ │ │
10
+ // └──────────────┴────────────────────────────────┘
11
+ //
12
+ // The picker streams the currently-selected path back to the parent via
13
+ // `onPick(path)` on every selection change. Confirm/cancel UI lives in
14
+ // the parent (the workdir modal's shared footer) so auto + cwd modes
15
+ // share one CTA.
16
+ //
17
+ // Props: { initialPath, onPick }
18
+
19
+ import { html } from '../html.js';
20
+ import { useEffect, useState } from 'preact/hooks';
21
+ import { api } from '../api.js';
22
+ import { setToast } from '../toast.js';
23
+ import { IconFolder, IconHome, IconChevronLeft, IconChevronRight, IconChevronUp, IconPencil } from '../icons.js';
24
+
25
+ export function DirectoryPicker({ initialPath, onPick }) {
26
+ const [data, setData] = useState(null);
27
+ const [path, setPath] = useState(initialPath || '');
28
+ const [history, setHistory] = useState({ stack: [], cursor: -1 }); // back/forward
29
+ const [editing, setEditing] = useState(false);
30
+ const [input, setInput] = useState('');
31
+ const [loading, setLoading] = useState(false);
32
+
33
+ // Push the current selection up on every change so the parent's
34
+ // shared "Use folder" CTA can act on it.
35
+ const select = (p) => { setPath(p); setInput(p); onPick?.(p); };
36
+
37
+ const browse = async (p, { pushHistory = true } = {}) => {
38
+ setLoading(true);
39
+ try {
40
+ const url = '/api/browse' + (p ? `?path=${encodeURIComponent(p)}` : '');
41
+ const r = await api('GET', url);
42
+ setData(r);
43
+ select(r.path);
44
+ if (pushHistory) {
45
+ setHistory((h) => {
46
+ const head = h.stack.slice(0, h.cursor + 1);
47
+ head.push(r.path);
48
+ return { stack: head, cursor: head.length - 1 };
49
+ });
50
+ }
51
+ } catch (e) { setToast(e.message, 'error'); }
52
+ finally { setLoading(false); }
53
+ };
54
+
55
+ useEffect(() => { browse(initialPath); }, []);
56
+
57
+ const canBack = history.cursor > 0;
58
+ const canForward = history.cursor >= 0 && history.cursor < history.stack.length - 1;
59
+
60
+ const goBack = () => {
61
+ if (!canBack) return;
62
+ const idx = history.cursor - 1;
63
+ setHistory({ ...history, cursor: idx });
64
+ browse(history.stack[idx], { pushHistory: false });
65
+ };
66
+ const goForward = () => {
67
+ if (!canForward) return;
68
+ const idx = history.cursor + 1;
69
+ setHistory({ ...history, cursor: idx });
70
+ browse(history.stack[idx], { pushHistory: false });
71
+ };
72
+ const goUp = () => {
73
+ if (!data?.parent) return;
74
+ browse(data.parent);
75
+ };
76
+ const onAddressSubmit = (ev) => {
77
+ ev?.preventDefault?.();
78
+ const p = (input || '').trim();
79
+ setEditing(false);
80
+ if (p && p !== path) browse(p);
81
+ };
82
+
83
+ if (!data) {
84
+ return html`<div class="filex"><div class="filex-loading">Loading…</div></div>`;
85
+ }
86
+
87
+ // Build breadcrumb segments. Windows-style: "C:\Users\Admin\foo" →
88
+ // [C:, Users, Admin, foo] with each segment clickable.
89
+ const segments = breadcrumbSegments(data.path);
90
+
91
+ return html`
92
+ <div class="filex">
93
+ <div class="filex-toolbar">
94
+ <div class="filex-navbtns">
95
+ <button class="filex-navbtn" title="Back" disabled=${!canBack} onClick=${goBack}>
96
+ <${IconChevronLeft} />
97
+ </button>
98
+ <button class="filex-navbtn" title="Forward" disabled=${!canForward} onClick=${goForward}>
99
+ <${IconChevronRight} />
100
+ </button>
101
+ <button class="filex-navbtn" title="Up" disabled=${!data.parent} onClick=${goUp}>
102
+ <${IconChevronUp} />
103
+ </button>
104
+ </div>
105
+
106
+ ${editing ? html`
107
+ <form class="filex-address-edit" onSubmit=${onAddressSubmit}>
108
+ <input class="filex-address-input mono" value=${input}
109
+ autoFocus
110
+ onInput=${(e) => setInput(e.target.value)}
111
+ onBlur=${onAddressSubmit}
112
+ onKeyDown=${(e) => { if (e.key === 'Escape') { setInput(data.path); setEditing(false); } }}
113
+ spellcheck="false" />
114
+ </form>
115
+ ` : html`
116
+ <div class="filex-breadcrumb"
117
+ onClick=${(e) => { if (e.target === e.currentTarget) { setInput(data.path); setEditing(true); } }}>
118
+ ${segments.map((seg, i) => html`
119
+ <button key=${seg.path} class="filex-crumb"
120
+ title=${seg.path}
121
+ onClick=${() => browse(seg.path)}>
122
+ ${i === 0 && seg.label.match(/^[a-z]:\\?$/i) ? null : null}
123
+ ${seg.label}
124
+ </button>
125
+ ${i < segments.length - 1
126
+ ? html`<span class="filex-crumb-sep" aria-hidden="true">›</span>`
127
+ : null}
128
+ `)}
129
+ <button class="filex-address-edit-btn" title="Edit path"
130
+ onClick=${() => { setInput(data.path); setEditing(true); }}>
131
+ <${IconPencil} />
132
+ </button>
133
+ </div>
134
+ `}
135
+ </div>
136
+
137
+ <div class="filex-body">
138
+ <aside class="filex-side">
139
+ <div class="filex-side-label">Quick access</div>
140
+ ${(data.starts || []).map((s) => html`
141
+ <button key=${s.path} class=${`filex-side-item${path === s.path ? ' is-active' : ''}`}
142
+ onClick=${() => browse(s.path)}
143
+ title=${s.path}>
144
+ <span class="filex-side-icon">
145
+ ${s.label === 'Home' ? html`<${IconHome} />` : html`<${IconFolder} />`}
146
+ </span>
147
+ <span class="filex-side-name">${s.label}</span>
148
+ </button>`)}
149
+ </aside>
150
+
151
+ <div class="filex-main">
152
+ ${!data.exists ? html`
153
+ <div class="filex-empty">Directory not found.</div>
154
+ ` : html`
155
+ <div class="filex-list">
156
+ ${data.entries.length === 0 ? html`
157
+ <div class="filex-empty">This folder is empty.</div>
158
+ ` : data.entries.map((e) => html`
159
+ <button key=${e.path} class="filex-row"
160
+ onDblClick=${() => browse(e.path)}
161
+ onClick=${() => select(e.path)}
162
+ data-active=${path === e.path}>
163
+ <span class="filex-row-icon"><${IconFolder} /></span>
164
+ <span class="filex-row-name">${e.name}</span>
165
+ </button>`)}
166
+ </div>`}
167
+ </div>
168
+ </div>
169
+
170
+ <div class="filex-foot">
171
+ <span class="filex-foot-current mono" title=${path}>${path || ' '}</span>
172
+ </div>
173
+ </div>`;
174
+ }
175
+
176
+ // "C:\Users\Admin\foo" → [{label:'C:', path:'C:\\'}, {label:'Users', path:'C:\\Users'}, …]
177
+ // "/home/me/foo" → [{label:'/', path:'/'}, {label:'home', path:'/home'}, …]
178
+ function breadcrumbSegments(p) {
179
+ if (!p) return [];
180
+ // Windows: split on backslash. Posix: forward slash.
181
+ const isWin = /^[a-zA-Z]:[\\/]/.test(p);
182
+ const sep = isWin ? '\\' : '/';
183
+ const norm = p.replace(/[\\\/]+/g, sep);
184
+ const parts = norm.split(sep).filter(Boolean);
185
+ const segs = [];
186
+ if (isWin) {
187
+ // first part is drive like "C:"
188
+ let acc = parts[0] + sep;
189
+ segs.push({ label: parts[0], path: acc });
190
+ for (let i = 1; i < parts.length; i++) {
191
+ acc = (acc.endsWith(sep) ? acc.slice(0, -1) : acc) + sep + parts[i];
192
+ segs.push({ label: parts[i], path: acc });
193
+ }
194
+ } else {
195
+ let acc = '';
196
+ segs.push({ label: '/', path: '/' });
197
+ for (const part of parts) {
198
+ acc = acc + sep + part;
199
+ segs.push({ label: part, path: acc });
200
+ }
201
+ }
202
+ return segs;
203
+ }