@logicseek/hello-cc 0.1.0 → 0.1.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.
- package/README.md +60 -391
- package/README.zh-CN.md +40 -336
- package/bin/hcc.mjs +30 -5
- package/docs/guide.md +372 -0
- package/docs/guide.zh-CN.md +324 -0
- package/package.json +2 -2
- package/scripts/regression.mjs +26 -0
package/scripts/regression.mjs
CHANGED
|
@@ -473,6 +473,31 @@ async function expectWebSocketMarker(peer, marker) {
|
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
+
async function expectResizeReplaceSnapshot(peer, marker) {
|
|
477
|
+
await new Promise((resolve, reject) => {
|
|
478
|
+
let sawSnapshot = false;
|
|
479
|
+
const ws = new WebSocket(`ws://127.0.0.1:${port}/ws/terminal/${encodeURIComponent(peer)}`);
|
|
480
|
+
const timer = setTimeout(() => reject(new Error(`${peer} resize replace timeout`)), 5000);
|
|
481
|
+
ws.on('open', () => {
|
|
482
|
+
const result = hccMaybe(['inject', peer, `echo ${marker}`]);
|
|
483
|
+
if (result.status !== 0) reject(new Error(result.stderr || result.stdout || 'inject failed'));
|
|
484
|
+
});
|
|
485
|
+
ws.on('message', (raw) => {
|
|
486
|
+
const msg = JSON.parse(String(raw));
|
|
487
|
+
if (msg.type === 'snapshot') {
|
|
488
|
+
sawSnapshot = true;
|
|
489
|
+
ws.send(JSON.stringify({ type: 'resize', cols: 96, rows: 28 }));
|
|
490
|
+
}
|
|
491
|
+
if (sawSnapshot && msg.type === 'replace' && String(msg.data || '').includes(marker)) {
|
|
492
|
+
clearTimeout(timer);
|
|
493
|
+
ws.close();
|
|
494
|
+
resolve();
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
ws.on('error', reject);
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
476
501
|
function tmuxStreamNodes() {
|
|
477
502
|
const dir = path.join(root, '.hello-cc', 'bufs');
|
|
478
503
|
if (!fs.existsSync(dir)) return [];
|
|
@@ -871,6 +896,7 @@ async function tmuxBackedStartWorkflow() {
|
|
|
871
896
|
hcc(['inject', 'shell-a', `echo PTY_OK > ${file}`]);
|
|
872
897
|
await waitForFile(file, 'PTY_OK', 'pty injection');
|
|
873
898
|
await expectWebSocketMarker('shell-a', 'WS_PTY_OK');
|
|
899
|
+
await expectResizeReplaceSnapshot('shell-a', 'WS_RESIZE_OK');
|
|
874
900
|
await expectBoundedTmuxStream('tmux-backed FIFO stream');
|
|
875
901
|
|
|
876
902
|
await stopRuntime();
|