@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.
Files changed (48) hide show
  1. package/CLAUDE.md +475 -475
  2. package/README.md +190 -190
  3. package/bin/ccsm.js +194 -194
  4. package/lib/cliSessionWatcher.js +249 -249
  5. package/lib/config.js +185 -185
  6. package/lib/folders.js +96 -96
  7. package/lib/localCliSessions.js +489 -177
  8. package/lib/persistedSessions.js +134 -134
  9. package/lib/webTerminal.js +208 -208
  10. package/lib/workspace.js +230 -255
  11. package/package.json +57 -57
  12. package/public/css/base.css +99 -99
  13. package/public/css/cards.css +183 -183
  14. package/public/css/feedback.css +303 -303
  15. package/public/css/forms.css +405 -405
  16. package/public/css/layout.css +160 -160
  17. package/public/css/modal.css +190 -183
  18. package/public/css/responsive.css +10 -10
  19. package/public/css/sidebar.css +616 -601
  20. package/public/css/terminals.css +294 -294
  21. package/public/css/tokens.css +81 -79
  22. package/public/css/wco.css +98 -98
  23. package/public/css/widgets.css +1596 -1375
  24. package/public/index.html +105 -103
  25. package/public/js/api.js +272 -260
  26. package/public/js/components/AdoptModal.js +343 -171
  27. package/public/js/components/App.js +35 -35
  28. package/public/js/components/DirectoryPicker.js +203 -203
  29. package/public/js/components/EntityFormModal.js +105 -105
  30. package/public/js/components/Modal.js +51 -51
  31. package/public/js/components/OfflineBanner.js +93 -93
  32. package/public/js/components/PageTitleBar.js +13 -13
  33. package/public/js/components/Picker.js +179 -179
  34. package/public/js/components/Popover.js +55 -55
  35. package/public/js/components/Sidebar.js +270 -270
  36. package/public/js/components/TerminalView.js +298 -298
  37. package/public/js/components/useDragSort.js +67 -67
  38. package/public/js/dialog.js +67 -67
  39. package/public/js/icons.js +177 -177
  40. package/public/js/main.js +140 -140
  41. package/public/js/pages/AboutPage.js +165 -165
  42. package/public/js/pages/ConfigurePage.js +475 -487
  43. package/public/js/pages/LaunchPage.js +369 -369
  44. package/public/js/pages/SessionsPage.js +97 -97
  45. package/public/js/state.js +231 -231
  46. package/public/manifest.webmanifest +15 -15
  47. package/scripts/install.js +137 -137
  48. package/server.js +1126 -1117
@@ -1,137 +1,137 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- // ccsm postinstall · Windows-only · runs after `npm install -g @bakapiano/ccsm`.
5
- // Registers the `ccsm://` URL protocol in HKCU so the hosted frontend
6
- // (https://bakapiano.github.io/ccsm/v1/) can fire `<a href="ccsm://start">`
7
- // from its OfflineBanner and have Windows spawn the backend on demand.
8
- //
9
- // Best-effort: any failure MUST NOT break npm install. Each step is in
10
- // its own try/catch; we just log and move on.
11
- //
12
- // No .lnk file, no Start Menu shortcut — just the protocol handler.
13
-
14
- const path = require('node:path');
15
- const fs = require('node:fs');
16
- const { spawnSync } = require('node:child_process');
17
-
18
- function log(msg) { process.stdout.write(`[ccsm install] ${msg}\n`); }
19
- function warn(msg) { process.stderr.write(`[ccsm install] ${msg}\n`); }
20
-
21
- if (process.platform !== 'win32') {
22
- log('non-Windows · skipping ccsm:// registration');
23
- process.exit(0);
24
- }
25
- // Note: we DO register on npx-cache installs too (not just global). The
26
- // npx cache path is stable across re-runs of the same package, and even
27
- // if the user later cleans the cache, the only consequence is the
28
- // OfflineBanner button no-ops — nothing actively broken. Registering
29
- // always means a first-time `npx @bakapiano/ccsm` gets the full "click
30
- // to wake" UX without needing a separate `npm i -g`.
31
-
32
- function findCcsmCmd() {
33
- const prefix = process.env.npm_config_prefix
34
- || (() => {
35
- try {
36
- const r = spawnSync('npm', ['config', 'get', 'prefix'], { encoding: 'utf8', shell: true });
37
- return r.stdout?.trim() || null;
38
- } catch { return null; }
39
- })();
40
- if (!prefix) return null;
41
- const candidate = path.join(prefix, 'ccsm.cmd');
42
- return fs.existsSync(candidate) ? candidate : null;
43
- }
44
-
45
- // Write a tiny VBScript wrapper that ccsm:// dispatches into. Why VBS:
46
- // wscript.exe is a Windows-subsystem host (no console window), and
47
- // `Shell.Run(..., 0, False)` launches the target completely hidden — so
48
- // when the user clicks ccsm://start, NOTHING flashes on screen, the
49
- // backend just appears in the next health probe.
50
- function writeLauncherVbs(ccsmCmd) {
51
- const home = process.env.LOCALAPPDATA || process.env.APPDATA;
52
- if (!home) throw new Error('no LOCALAPPDATA/APPDATA env var');
53
- const dir = path.join(home, 'ccsm');
54
- fs.mkdirSync(dir, { recursive: true });
55
- const vbsPath = path.join(dir, 'launcher.vbs');
56
- // Escape any double-quotes in the cmd path (rare but possible).
57
- const cmdEsc = ccsmCmd.replace(/"/g, '""');
58
- const vbs = [
59
- "' ccsm protocol launcher · invoked by wscript.exe via the registered",
60
- "' ccsm:// URL handler. Spawns ccsm.cmd with WindowStyle 0 (hidden) +",
61
- "' bWaitOnReturn=False (async), so the click leaves zero visible trace.",
62
- 'If WScript.Arguments.Count >= 1 Then',
63
- ' arg = WScript.Arguments(0)',
64
- 'Else',
65
- ' arg = ""',
66
- 'End If',
67
- 'Set sh = CreateObject("WScript.Shell")',
68
- `sh.Run """${cmdEsc}"" """ & arg & """", 0, False`,
69
- '',
70
- ].join('\r\n');
71
- fs.writeFileSync(vbsPath, vbs, { encoding: 'utf8' });
72
- return vbsPath;
73
- }
74
-
75
- function registerProtocol(vbsPath) {
76
- // wscript.exe is a no-console host. The protocol-registered command
77
- // hands the entire ccsm:// URL to launcher.vbs as argv[0]; the VBS
78
- // forwards it to ccsm.cmd "%1" with a hidden window.
79
- const command = `wscript.exe "${vbsPath}" "%1"`;
80
- const root = 'HKCU\\Software\\Classes\\ccsm';
81
- const calls = [
82
- ['add', root, '/ve', '/d', 'URL:ccsm protocol', '/f'],
83
- ['add', root, '/v', 'URL Protocol', '/d', '', '/f'],
84
- ['add', `${root}\\shell\\open\\command`, '/ve', '/d', command, '/f'],
85
- ];
86
- for (const args of calls) {
87
- const r = spawnSync('reg.exe', args, { windowsHide: true });
88
- if (r.status !== 0) {
89
- throw new Error(`reg ${args.join(' ')} → exit ${r.status}: ${r.stderr?.toString() || ''}`);
90
- }
91
- }
92
- }
93
-
94
- const ccsmCmd = (() => {
95
- try { return findCcsmCmd(); } catch { return null; }
96
- })();
97
- if (!ccsmCmd) {
98
- warn('could not locate ccsm.cmd · skipping protocol registration');
99
- process.exit(0);
100
- }
101
-
102
- try {
103
- const vbsPath = writeLauncherVbs(ccsmCmd);
104
- registerProtocol(vbsPath);
105
- log(`launcher · ${vbsPath}`);
106
- log(`ccsm:// protocol registered (silent · via wscript.exe)`);
107
- } catch (e) {
108
- warn(`failed · ${e.message}`);
109
- warn('the hosted frontend\'s "Start ccsm" button will not be able to launch the backend. You can still run `ccsm` manually in a terminal.');
110
- }
111
-
112
- // Auto-launch ccsm after install so the user lands directly in the app
113
- // without needing a second command. Detached + windowsHide so the npm
114
- // install command returns immediately. Skip if CCSM_NO_AUTOLAUNCH=1 is
115
- // set (CI, headless setups).
116
- if (process.env.CCSM_NO_AUTOLAUNCH !== '1') {
117
- try {
118
- const { spawn } = require('node:child_process');
119
- // Spawn `node bin/ccsm.js` directly — NOT ccsm.cmd. On Windows,
120
- // child_process.spawn() with shell:false refuses .cmd files (throws
121
- // EINVAL); using shell:true would flash a console window. Going
122
- // through node + the JS entrypoint sidesteps both problems and
123
- // matches exactly what the .cmd shim would have invoked.
124
- const launcherJs = path.join(__dirname, '..', 'bin', 'ccsm.js');
125
- const child = spawn(process.execPath, [launcherJs], {
126
- detached: true,
127
- stdio: 'ignore',
128
- windowsHide: true,
129
- });
130
- child.unref();
131
- log('launching ccsm now · check for the chromeless window');
132
- log('(set CCSM_NO_AUTOLAUNCH=1 to skip this on future installs)');
133
- } catch (e) {
134
- warn(`auto-launch failed · ${e.message}`);
135
- warn('run `ccsm` manually to start.');
136
- }
137
- }
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // ccsm postinstall · Windows-only · runs after `npm install -g @bakapiano/ccsm`.
5
+ // Registers the `ccsm://` URL protocol in HKCU so the hosted frontend
6
+ // (https://bakapiano.github.io/ccsm/v1/) can fire `<a href="ccsm://start">`
7
+ // from its OfflineBanner and have Windows spawn the backend on demand.
8
+ //
9
+ // Best-effort: any failure MUST NOT break npm install. Each step is in
10
+ // its own try/catch; we just log and move on.
11
+ //
12
+ // No .lnk file, no Start Menu shortcut — just the protocol handler.
13
+
14
+ const path = require('node:path');
15
+ const fs = require('node:fs');
16
+ const { spawnSync } = require('node:child_process');
17
+
18
+ function log(msg) { process.stdout.write(`[ccsm install] ${msg}\n`); }
19
+ function warn(msg) { process.stderr.write(`[ccsm install] ${msg}\n`); }
20
+
21
+ if (process.platform !== 'win32') {
22
+ log('non-Windows · skipping ccsm:// registration');
23
+ process.exit(0);
24
+ }
25
+ // Note: we DO register on npx-cache installs too (not just global). The
26
+ // npx cache path is stable across re-runs of the same package, and even
27
+ // if the user later cleans the cache, the only consequence is the
28
+ // OfflineBanner button no-ops — nothing actively broken. Registering
29
+ // always means a first-time `npx @bakapiano/ccsm` gets the full "click
30
+ // to wake" UX without needing a separate `npm i -g`.
31
+
32
+ function findCcsmCmd() {
33
+ const prefix = process.env.npm_config_prefix
34
+ || (() => {
35
+ try {
36
+ const r = spawnSync('npm', ['config', 'get', 'prefix'], { encoding: 'utf8', shell: true });
37
+ return r.stdout?.trim() || null;
38
+ } catch { return null; }
39
+ })();
40
+ if (!prefix) return null;
41
+ const candidate = path.join(prefix, 'ccsm.cmd');
42
+ return fs.existsSync(candidate) ? candidate : null;
43
+ }
44
+
45
+ // Write a tiny VBScript wrapper that ccsm:// dispatches into. Why VBS:
46
+ // wscript.exe is a Windows-subsystem host (no console window), and
47
+ // `Shell.Run(..., 0, False)` launches the target completely hidden — so
48
+ // when the user clicks ccsm://start, NOTHING flashes on screen, the
49
+ // backend just appears in the next health probe.
50
+ function writeLauncherVbs(ccsmCmd) {
51
+ const home = process.env.LOCALAPPDATA || process.env.APPDATA;
52
+ if (!home) throw new Error('no LOCALAPPDATA/APPDATA env var');
53
+ const dir = path.join(home, 'ccsm');
54
+ fs.mkdirSync(dir, { recursive: true });
55
+ const vbsPath = path.join(dir, 'launcher.vbs');
56
+ // Escape any double-quotes in the cmd path (rare but possible).
57
+ const cmdEsc = ccsmCmd.replace(/"/g, '""');
58
+ const vbs = [
59
+ "' ccsm protocol launcher · invoked by wscript.exe via the registered",
60
+ "' ccsm:// URL handler. Spawns ccsm.cmd with WindowStyle 0 (hidden) +",
61
+ "' bWaitOnReturn=False (async), so the click leaves zero visible trace.",
62
+ 'If WScript.Arguments.Count >= 1 Then',
63
+ ' arg = WScript.Arguments(0)',
64
+ 'Else',
65
+ ' arg = ""',
66
+ 'End If',
67
+ 'Set sh = CreateObject("WScript.Shell")',
68
+ `sh.Run """${cmdEsc}"" """ & arg & """", 0, False`,
69
+ '',
70
+ ].join('\r\n');
71
+ fs.writeFileSync(vbsPath, vbs, { encoding: 'utf8' });
72
+ return vbsPath;
73
+ }
74
+
75
+ function registerProtocol(vbsPath) {
76
+ // wscript.exe is a no-console host. The protocol-registered command
77
+ // hands the entire ccsm:// URL to launcher.vbs as argv[0]; the VBS
78
+ // forwards it to ccsm.cmd "%1" with a hidden window.
79
+ const command = `wscript.exe "${vbsPath}" "%1"`;
80
+ const root = 'HKCU\\Software\\Classes\\ccsm';
81
+ const calls = [
82
+ ['add', root, '/ve', '/d', 'URL:ccsm protocol', '/f'],
83
+ ['add', root, '/v', 'URL Protocol', '/d', '', '/f'],
84
+ ['add', `${root}\\shell\\open\\command`, '/ve', '/d', command, '/f'],
85
+ ];
86
+ for (const args of calls) {
87
+ const r = spawnSync('reg.exe', args, { windowsHide: true });
88
+ if (r.status !== 0) {
89
+ throw new Error(`reg ${args.join(' ')} → exit ${r.status}: ${r.stderr?.toString() || ''}`);
90
+ }
91
+ }
92
+ }
93
+
94
+ const ccsmCmd = (() => {
95
+ try { return findCcsmCmd(); } catch { return null; }
96
+ })();
97
+ if (!ccsmCmd) {
98
+ warn('could not locate ccsm.cmd · skipping protocol registration');
99
+ process.exit(0);
100
+ }
101
+
102
+ try {
103
+ const vbsPath = writeLauncherVbs(ccsmCmd);
104
+ registerProtocol(vbsPath);
105
+ log(`launcher · ${vbsPath}`);
106
+ log(`ccsm:// protocol registered (silent · via wscript.exe)`);
107
+ } catch (e) {
108
+ warn(`failed · ${e.message}`);
109
+ warn('the hosted frontend\'s "Start ccsm" button will not be able to launch the backend. You can still run `ccsm` manually in a terminal.');
110
+ }
111
+
112
+ // Auto-launch ccsm after install so the user lands directly in the app
113
+ // without needing a second command. Detached + windowsHide so the npm
114
+ // install command returns immediately. Skip if CCSM_NO_AUTOLAUNCH=1 is
115
+ // set (CI, headless setups).
116
+ if (process.env.CCSM_NO_AUTOLAUNCH !== '1') {
117
+ try {
118
+ const { spawn } = require('node:child_process');
119
+ // Spawn `node bin/ccsm.js` directly — NOT ccsm.cmd. On Windows,
120
+ // child_process.spawn() with shell:false refuses .cmd files (throws
121
+ // EINVAL); using shell:true would flash a console window. Going
122
+ // through node + the JS entrypoint sidesteps both problems and
123
+ // matches exactly what the .cmd shim would have invoked.
124
+ const launcherJs = path.join(__dirname, '..', 'bin', 'ccsm.js');
125
+ const child = spawn(process.execPath, [launcherJs], {
126
+ detached: true,
127
+ stdio: 'ignore',
128
+ windowsHide: true,
129
+ });
130
+ child.unref();
131
+ log('launching ccsm now · check for the chromeless window');
132
+ log('(set CCSM_NO_AUTOLAUNCH=1 to skip this on future installs)');
133
+ } catch (e) {
134
+ warn(`auto-launch failed · ${e.message}`);
135
+ warn('run `ccsm` manually to start.');
136
+ }
137
+ }