@volter/supercode-teams 0.2.87 → 0.2.89
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.
- package/package.json +1 -1
- package/popup-terminals.mjs +9 -35
- package/terminal-look.mjs +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-teams",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.89",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
|
|
6
6
|
"license": "MIT",
|
package/popup-terminals.mjs
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
// daemon's ConPTY host on Windows, holds it); the pane ending ends the client, and the terminal closes the window as
|
|
5
5
|
// its command exits. Adapters are tried in rank order; SUPERCODE_POPUP_TERMINAL names one (or `none`).
|
|
6
6
|
import { spawn, spawnSync } from 'node:child_process';
|
|
7
|
-
import { chmodSync, existsSync,
|
|
8
|
-
import {
|
|
7
|
+
import { chmodSync, existsSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
9
9
|
import { join } from 'node:path';
|
|
10
|
-
import {
|
|
10
|
+
import { randomBytes } from 'node:crypto';
|
|
11
11
|
import { weztermConfigFile } from './terminal-look.mjs';
|
|
12
12
|
|
|
13
13
|
const onPath = (name) => {
|
|
@@ -27,39 +27,13 @@ function selfDeletingScript(argv, extension) {
|
|
|
27
27
|
return path;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
// config's content: WezTerm does not reload it (terminal-look.mjs), so a process holding an older look is never reused.
|
|
36
|
-
const WEZTERM_CLASS = 'dev.volter.supercode';
|
|
37
|
-
|
|
38
|
-
/** The socket of a running supercode WezTerm process of class `cls`, or null. */
|
|
39
|
-
function weztermSocket(cls) {
|
|
40
|
-
const dir = join(homedir(), '.local', 'share', 'wezterm');
|
|
41
|
-
let names;
|
|
42
|
-
try { names = readdirSync(dir); } catch { return null; }
|
|
43
|
-
for (const name of names) {
|
|
44
|
-
const pid = Number(/^gui-sock-(\d+)$/.exec(name)?.[1]);
|
|
45
|
-
if (!pid) continue;
|
|
46
|
-
try { process.kill(pid, 0); } catch { continue; }
|
|
47
|
-
const command = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8', timeout: 2_000 }).stdout ?? '';
|
|
48
|
-
if (command.includes(`--class ${cls} `)) return join(dir, name);
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** WezTerm's launch: a window in supercode's running WezTerm, else a new one with supercode's look (terminal-look.mjs). */
|
|
30
|
+
// Each window is a WezTerm process of its own, with supercode's look (terminal-look.mjs). Windows sharing one process
|
|
31
|
+
// share its one main thread: on the owner's Mac, four Claude sessions' output kept that thread painting for whole
|
|
32
|
+
// seconds at a time (97-98% of 3 s samples), and a drag in any other popup went unanswered meanwhile. A process of its
|
|
33
|
+
// own opens in 0.7 to 2 s where a window in a running process opened in about 0.3 s; it is never frozen by another
|
|
34
|
+
// window's output.
|
|
54
35
|
function weztermLaunch(program, argv) {
|
|
55
|
-
|
|
56
|
-
const cls = `${WEZTERM_CLASS}.${createHash('sha256').update(readFileSync(config)).digest('hex').slice(0, 12)}`;
|
|
57
|
-
const start = [program, '--config-file', config, 'start', '--always-new-process', '--class', cls, '--', ...argv];
|
|
58
|
-
const socket = process.platform === 'win32' ? null : weztermSocket(cls);
|
|
59
|
-
if (!socket) return [start[0], start.slice(1)];
|
|
60
|
-
const quote = (arg) => `'${String(arg).replaceAll("'", `'"'"'`)}'`;
|
|
61
|
-
const spawnWindow = [program, 'cli', '--no-auto-start', 'spawn', '--new-window', '--', ...argv].map(quote).join(' ');
|
|
62
|
-
return ['/bin/sh', ['-c', `WEZTERM_UNIX_SOCKET=${quote(socket)} ${spawnWindow} >/dev/null 2>&1 || exec ${start.map(quote).join(' ')}`]];
|
|
36
|
+
return [program, ['--config-file', weztermConfigFile(), 'start', '--always-new-process', '--', ...argv]];
|
|
63
37
|
}
|
|
64
38
|
|
|
65
39
|
/** Adapters by platform, in rank order: { name, find() → program or null, launch(program, argv) → [command, args] }. */
|
package/terminal-look.mjs
CHANGED
|
@@ -165,6 +165,18 @@ export function weztermConfig(profile, { fontDirs = existsSync(TERMINAL_FONTS) ?
|
|
|
165
165
|
'end',
|
|
166
166
|
"wezterm.on('window-config-reloaded', fit)",
|
|
167
167
|
"wezterm.on('window-resized', fit)",
|
|
168
|
+
// Terminal.app's title: the working directory's name, the running process, the size ("yueranyuan — sleep 40 — 81×18").
|
|
169
|
+
"wezterm.on('format-window-title', function(tab, pane)",
|
|
170
|
+
" local ok, title = pcall(function()",
|
|
171
|
+
" local cwd = pane.current_working_dir",
|
|
172
|
+
" cwd = cwd and (type(cwd) == 'userdata' and cwd.file_path or tostring(cwd)) or ''",
|
|
173
|
+
" local folder = cwd:gsub('/+$', ''):match('[^/]+$') or ''",
|
|
174
|
+
" local process = (pane.foreground_process_name or ''):match('[^/]+$') or pane.title",
|
|
175
|
+
" local dims = wezterm.mux.get_pane(pane.pane_id):get_dimensions()",
|
|
176
|
+
" return string.format('%s — %s — %d×%d', folder, process, dims.cols, dims.viewport_rows)",
|
|
177
|
+
" end)",
|
|
178
|
+
" return ok and title or pane.title",
|
|
179
|
+
"end)",
|
|
168
180
|
`config.font_dirs = { ${fontDirs.map(lua).join(', ')} }`,
|
|
169
181
|
...(families.length ? [`config.font = wezterm.font_with_fallback({ ${families.join(', ')} })`] : []),
|
|
170
182
|
// CoreText draws glyphs unhinted; FreeType's default hinting snaps their outlines to the pixel grid.
|