glidercli 0.3.14 → 0.3.15
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/bin/glider.js +81 -5
- package/package.json +1 -1
package/bin/glider.js
CHANGED
|
@@ -502,11 +502,33 @@ async function cmdGoto(url) {
|
|
|
502
502
|
method: 'Page.navigate',
|
|
503
503
|
params: { url }
|
|
504
504
|
});
|
|
505
|
+
// v0.3.15 FRONTLOG-FIX P0.CLI-goto-false-green + P0.CLI-goto-auto-attach:
|
|
506
|
+
// Prior code printed raw result THEN unconditionally logged '✓ Navigated' —
|
|
507
|
+
// even when result contained {"error":"Session not found"} (stale pinned session after reload-ext).
|
|
508
|
+
// Now: detect embedded error, don't lie about success, then auto-attach the target tab.
|
|
509
|
+
const hasErr = result && (result.error || (typeof result === 'string' && result.includes('error')));
|
|
505
510
|
if (jsonOutput) {
|
|
506
|
-
emitJson(
|
|
511
|
+
emitJson(!hasErr, { url, navigate: result }, hasErr ? (result.error?.message || result.error || 'unknown') : null);
|
|
512
|
+
} else if (hasErr) {
|
|
513
|
+
log.fail(`Navigation reported error: ${JSON.stringify(result)}`);
|
|
514
|
+
log.info(' hint: pinned session may be stale (e.g. after reload-ext). Try `glider attach-all` or unset GLIDER_SESSION_ID.');
|
|
507
515
|
} else {
|
|
508
|
-
console.log(JSON.stringify(result));
|
|
509
516
|
log.ok('Navigated');
|
|
517
|
+
// Auto-attach the tab we just navigated to (best-effort, non-fatal on failure).
|
|
518
|
+
// Uses URL host as substring filter so we don't accidentally re-attach unrelated tabs.
|
|
519
|
+
try {
|
|
520
|
+
const u = new URL(url);
|
|
521
|
+
const host = u.hostname;
|
|
522
|
+
// small delay lets the tab actually load + register in chrome.tabs before attach
|
|
523
|
+
await new Promise(x => setTimeout(x, 800));
|
|
524
|
+
const attach = await postExtension({ method: 'attachAllTabs', params: { urlSubstring: host } });
|
|
525
|
+
const d = attach.result ?? attach;
|
|
526
|
+
if ((d.attached ?? 0) > 0) {
|
|
527
|
+
log.info(` auto-attached ${d.attached} tab(s) matching host="${host}"`);
|
|
528
|
+
}
|
|
529
|
+
} catch (attErr) {
|
|
530
|
+
// silent: nav succeeded, auto-attach is a nice-to-have
|
|
531
|
+
}
|
|
510
532
|
}
|
|
511
533
|
} catch (e) {
|
|
512
534
|
if (jsonOutput) emitJson(false, null, e.message);
|
|
@@ -706,7 +728,9 @@ async function cmdRestart() {
|
|
|
706
728
|
async function cmdReloadExt() {
|
|
707
729
|
try {
|
|
708
730
|
const r = await postExtension({ method: 'reloadSelf', params: {} });
|
|
709
|
-
|
|
731
|
+
// v0.3.15 FRONTLOG-FIX: same unwrap bug as attach-all — r.result was always undefined
|
|
732
|
+
const persisted = (r.result?.persisted ?? r.persisted ?? '?');
|
|
733
|
+
log.ok(`Extension reload triggered (persisted ${persisted} tab URLs).`);
|
|
710
734
|
log.info('Waiting 4s for extension to boot back up + reconnect...');
|
|
711
735
|
await new Promise(x => setTimeout(x, 4000));
|
|
712
736
|
// Extension reboots → autoAttachActiveTab restores from chrome.storage
|
|
@@ -722,7 +746,18 @@ async function cmdReloadExt() {
|
|
|
722
746
|
async function cmdAttachAll(filter) {
|
|
723
747
|
try {
|
|
724
748
|
const r = await postExtension({ method: 'attachAllTabs', params: filter ? { urlSubstring: filter } : {} });
|
|
725
|
-
|
|
749
|
+
// v0.3.15 FRONTLOG-FIX P0.CLI-attach-all-observability:
|
|
750
|
+
// relay's sendToExtension unwraps msg.result before HTTP POST responds, so relay body is {attached, skipped, failed, total_connected} bare.
|
|
751
|
+
// Prior code read r.result.attached which was always undefined → literal '?' placeholders on every attach-all.
|
|
752
|
+
const d = r.result ?? r;
|
|
753
|
+
const attached = d.attached ?? 0;
|
|
754
|
+
const skipped = d.skipped ?? 0;
|
|
755
|
+
const failed = d.failed ?? 0;
|
|
756
|
+
const total = d.total_connected ?? 0;
|
|
757
|
+
log.ok(`attach-all: attached=${attached} skipped=${skipped} failed=${failed} total_connected=${total}`);
|
|
758
|
+
if (filter && attached === 0 && total > 0) {
|
|
759
|
+
log.info(` hint: filter "${filter}" matched 0 new tabs. Try 'glider attach-all' with no filter, or check 'glider tabs' for URL substrings that would match.`);
|
|
760
|
+
}
|
|
726
761
|
} catch (e) {
|
|
727
762
|
log.fail(`attach-all failed: ${e.message}`);
|
|
728
763
|
}
|
|
@@ -2210,7 +2245,29 @@ async function cmdUpdate() {
|
|
|
2210
2245
|
async function main() {
|
|
2211
2246
|
const args = parseGlobalFlags(process.argv.slice(2));
|
|
2212
2247
|
loadPersistedSession();
|
|
2213
|
-
|
|
2248
|
+
let cmd = args[0];
|
|
2249
|
+
|
|
2250
|
+
// v0.3.15 FRONTLOG-FIX P0.CLI-ALIAS-reload-ext:
|
|
2251
|
+
// Accept common natural-language variants + typos for high-frequency commands.
|
|
2252
|
+
// Rewrites args in place so downstream switch stays clean.
|
|
2253
|
+
const RELOAD_EXT_TWO_WORD = new Set([
|
|
2254
|
+
'ext-reload', 'ext reload',
|
|
2255
|
+
'reload-extension', 'reload extension',
|
|
2256
|
+
'reload-ext'
|
|
2257
|
+
]);
|
|
2258
|
+
const RELOAD_EXT_ALIASES = new Set(['rex', 'reloadext', 'reloadExt']);
|
|
2259
|
+
if (cmd === 'ext' && args[1] === 'reload') {
|
|
2260
|
+
cmd = 'reload-ext';
|
|
2261
|
+
args.splice(0, 2, 'reload-ext');
|
|
2262
|
+
} else if (cmd === 'reload' && (args[1] === 'ext' || args[1] === 'extension')) {
|
|
2263
|
+
cmd = 'reload-ext';
|
|
2264
|
+
args.splice(0, 2, 'reload-ext');
|
|
2265
|
+
} else if (RELOAD_EXT_ALIASES.has(cmd)) {
|
|
2266
|
+
cmd = 'reload-ext';
|
|
2267
|
+
args[0] = 'reload-ext';
|
|
2268
|
+
}
|
|
2269
|
+
// Typo suggest: if cmd looks like a common command with 1-2 char edit distance, hint it.
|
|
2270
|
+
// (Only checked in unknown-command branch below — this block just normalizes.)
|
|
2214
2271
|
|
|
2215
2272
|
if (!cmd || cmd === '--help' || cmd === '-h') {
|
|
2216
2273
|
showHelp();
|
|
@@ -2408,6 +2465,25 @@ async function main() {
|
|
|
2408
2465
|
break;
|
|
2409
2466
|
}
|
|
2410
2467
|
log.fail(`Unknown command: ${cmd}`);
|
|
2468
|
+
// v0.3.15 FRONTLOG-FIX: typo suggest (Levenshtein <=2) before dumping full help.
|
|
2469
|
+
const KNOWN_CMDS = ['status','start','stop','restart','reload-ext','attach-all','install','uninstall',
|
|
2470
|
+
'update','version','connect','browser','use','test','domains','resolve','goto','eval','click','type',
|
|
2471
|
+
'screenshot','snapshot','text','html','title','url','tabs','targets','use-session','fetch','spawn',
|
|
2472
|
+
'extract','explore','favicon','window','reg','run','loop','ralph'];
|
|
2473
|
+
function lev(a, b) {
|
|
2474
|
+
if (Math.abs(a.length - b.length) > 2) return 3;
|
|
2475
|
+
const m = Array.from({length: a.length+1}, () => new Array(b.length+1).fill(0));
|
|
2476
|
+
for (let i = 0; i <= a.length; i++) m[i][0] = i;
|
|
2477
|
+
for (let j = 0; j <= b.length; j++) m[0][j] = j;
|
|
2478
|
+
for (let i = 1; i <= a.length; i++) for (let j = 1; j <= b.length; j++) {
|
|
2479
|
+
m[i][j] = a[i-1] === b[j-1] ? m[i-1][j-1] : 1 + Math.min(m[i-1][j-1], m[i-1][j], m[i][j-1]);
|
|
2480
|
+
}
|
|
2481
|
+
return m[a.length][b.length];
|
|
2482
|
+
}
|
|
2483
|
+
const near = KNOWN_CMDS.map(k => [k, lev(cmd, k)]).filter(x => x[1] <= 2).sort((a,b) => a[1]-b[1]).slice(0, 3);
|
|
2484
|
+
if (near.length > 0) {
|
|
2485
|
+
log.info(` Did you mean: ${near.map(x => x[0]).join(', ')} ?`);
|
|
2486
|
+
}
|
|
2411
2487
|
showHelp();
|
|
2412
2488
|
process.exit(1);
|
|
2413
2489
|
}
|
package/package.json
CHANGED