glidercli 0.3.15 → 0.3.18
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 +10 -13
- package/lib/bexplore.js +39 -7
- package/package.json +2 -2
package/bin/glider.js
CHANGED
|
@@ -91,7 +91,6 @@ for (const cfgPath of BROWSER_CONFIG_PATHS) {
|
|
|
91
91
|
|
|
92
92
|
// Browsers registry - key → { name, path, processName }. Used when browser.json has "use": "<key>"
|
|
93
93
|
const BROWSERS_REGISTRY_PATHS = [
|
|
94
|
-
path.join(os.homedir(), '.cursor', 'registry', 'browsers.json'),
|
|
95
94
|
path.join(os.homedir(), '.glider', 'config', 'browsers-registry.json'),
|
|
96
95
|
].filter(Boolean);
|
|
97
96
|
let BROWSERS_REGISTRY = {};
|
|
@@ -502,8 +501,8 @@ async function cmdGoto(url) {
|
|
|
502
501
|
method: 'Page.navigate',
|
|
503
502
|
params: { url }
|
|
504
503
|
});
|
|
505
|
-
// v0.3.15
|
|
506
|
-
// Prior code printed raw result THEN unconditionally logged '✓ Navigated'
|
|
504
|
+
// v0.3.15: detect nav errors; auto-attach after successful goto.
|
|
505
|
+
// Prior code printed raw result THEN unconditionally logged '✓ Navigated' -
|
|
507
506
|
// even when result contained {"error":"Session not found"} (stale pinned session after reload-ext).
|
|
508
507
|
// Now: detect embedded error, don't lie about success, then auto-attach the target tab.
|
|
509
508
|
const hasErr = result && (result.error || (typeof result === 'string' && result.includes('error')));
|
|
@@ -722,13 +721,11 @@ async function cmdRestart() {
|
|
|
722
721
|
await cmdStart();
|
|
723
722
|
}
|
|
724
723
|
|
|
725
|
-
//
|
|
726
|
-
// so operators don't have to click chrome://extensions after every code change.
|
|
727
|
-
// Bootstrap cost: one manual reload after installing this handler for the first time.
|
|
724
|
+
// reload-ext: automate extension reload + tab re-attachment
|
|
728
725
|
async function cmdReloadExt() {
|
|
729
726
|
try {
|
|
730
727
|
const r = await postExtension({ method: 'reloadSelf', params: {} });
|
|
731
|
-
// v0.3.15
|
|
728
|
+
// v0.3.15: same response unwrap fix as attach-all - r.result was always undefined
|
|
732
729
|
const persisted = (r.result?.persisted ?? r.persisted ?? '?');
|
|
733
730
|
log.ok(`Extension reload triggered (persisted ${persisted} tab URLs).`);
|
|
734
731
|
log.info('Waiting 4s for extension to boot back up + reconnect...');
|
|
@@ -746,7 +743,7 @@ async function cmdReloadExt() {
|
|
|
746
743
|
async function cmdAttachAll(filter) {
|
|
747
744
|
try {
|
|
748
745
|
const r = await postExtension({ method: 'attachAllTabs', params: filter ? { urlSubstring: filter } : {} });
|
|
749
|
-
// v0.3.15
|
|
746
|
+
// v0.3.15: attach-all response unwrap fix -
|
|
750
747
|
// relay's sendToExtension unwraps msg.result before HTTP POST responds, so relay body is {attached, skipped, failed, total_connected} bare.
|
|
751
748
|
// Prior code read r.result.attached which was always undefined → literal '?' placeholders on every attach-all.
|
|
752
749
|
const d = r.result ?? r;
|
|
@@ -995,7 +992,7 @@ function cmdBrowser() {
|
|
|
995
992
|
}
|
|
996
993
|
console.log('');
|
|
997
994
|
console.log('Source: ~/.glider/config/browser.json { "use": "<key>" } or { name, path } → default "Google Chrome"');
|
|
998
|
-
console.log('Registry: ~/.
|
|
995
|
+
console.log('Registry: ~/.glider/config/browsers-registry.json. Keys: ' + (Object.keys(BROWSERS_REGISTRY).join(', ') || '(none loaded)'));
|
|
999
996
|
console.log('See README.md#browsers for compatibility and examples.');
|
|
1000
997
|
}
|
|
1001
998
|
|
|
@@ -2247,7 +2244,7 @@ async function main() {
|
|
|
2247
2244
|
loadPersistedSession();
|
|
2248
2245
|
let cmd = args[0];
|
|
2249
2246
|
|
|
2250
|
-
// v0.3.15
|
|
2247
|
+
// v0.3.15: reload-ext command aliases -
|
|
2251
2248
|
// Accept common natural-language variants + typos for high-frequency commands.
|
|
2252
2249
|
// Rewrites args in place so downstream switch stays clean.
|
|
2253
2250
|
const RELOAD_EXT_TWO_WORD = new Set([
|
|
@@ -2267,7 +2264,7 @@ async function main() {
|
|
|
2267
2264
|
args[0] = 'reload-ext';
|
|
2268
2265
|
}
|
|
2269
2266
|
// 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
|
|
2267
|
+
// (Only checked in unknown-command branch below - this block just normalizes.)
|
|
2271
2268
|
|
|
2272
2269
|
if (!cmd || cmd === '--help' || cmd === '-h') {
|
|
2273
2270
|
showHelp();
|
|
@@ -2310,7 +2307,7 @@ async function main() {
|
|
|
2310
2307
|
await cmdReloadExt();
|
|
2311
2308
|
break;
|
|
2312
2309
|
case 'attach-all':
|
|
2313
|
-
await cmdAttachAll(args[1]); // optional URL substring filter, e.g. '
|
|
2310
|
+
await cmdAttachAll(args[1]); // optional URL substring filter, e.g. 'example.com'
|
|
2314
2311
|
break;
|
|
2315
2312
|
case 'install':
|
|
2316
2313
|
await cmdInstallDaemon();
|
|
@@ -2465,7 +2462,7 @@ async function main() {
|
|
|
2465
2462
|
break;
|
|
2466
2463
|
}
|
|
2467
2464
|
log.fail(`Unknown command: ${cmd}`);
|
|
2468
|
-
// v0.3.15
|
|
2465
|
+
// v0.3.15: typo suggest (Levenshtein <=2) before dumping full help.
|
|
2469
2466
|
const KNOWN_CMDS = ['status','start','stop','restart','reload-ext','attach-all','install','uninstall',
|
|
2470
2467
|
'update','version','connect','browser','use','test','domains','resolve','goto','eval','click','type',
|
|
2471
2468
|
'screenshot','snapshot','text','html','title','url','tabs','targets','use-session','fetch','spawn',
|
package/lib/bexplore.js
CHANGED
|
@@ -576,12 +576,20 @@ class SiteExplorer {
|
|
|
576
576
|
// Initial screenshot
|
|
577
577
|
await this.screenshot('initial');
|
|
578
578
|
|
|
579
|
-
// Discover all elements
|
|
580
|
-
|
|
581
|
-
|
|
579
|
+
// Discover all elements (best-effort - heavy SPAs may throw during discovery;
|
|
580
|
+
// don't let a discovery failure abort HAR persistence)
|
|
581
|
+
let elements;
|
|
582
|
+
try {
|
|
583
|
+
elements = await this.discoverElements();
|
|
584
|
+
console.error(`[explore] Found: ${elements.tabs.length} tabs, ${elements.buttons.length} buttons, ${elements.links.length} links`);
|
|
585
|
+
} catch (e) {
|
|
586
|
+
console.error(`[explore] DOM discovery failed (${e.message}); skipping discovery, preserving HAR`);
|
|
587
|
+
elements = { tabs: [], buttons: [], links: [], forms: [], tables: [], dropdowns: [], checkboxes: [], modals: [], sidePanels: [] };
|
|
588
|
+
this.siteMap.discoveryError = e.message;
|
|
589
|
+
}
|
|
582
590
|
|
|
583
591
|
if (depth === 0) {
|
|
584
|
-
console.error('[explore] depth=0 passive
|
|
592
|
+
console.error('[explore] depth=0 passive - no clicks, scroll, or toggles');
|
|
585
593
|
} else {
|
|
586
594
|
// Click through tabs
|
|
587
595
|
for (const tab of elements.tabs.slice(0, depth)) {
|
|
@@ -648,8 +656,12 @@ class SiteExplorer {
|
|
|
648
656
|
}
|
|
649
657
|
}
|
|
650
658
|
|
|
651
|
-
// Final screenshot
|
|
652
|
-
|
|
659
|
+
// Final screenshot (best-effort)
|
|
660
|
+
try {
|
|
661
|
+
await this.screenshot('final');
|
|
662
|
+
} catch (e) {
|
|
663
|
+
console.error(`[explore] Final screenshot failed (${e.message}); continuing`);
|
|
664
|
+
}
|
|
653
665
|
|
|
654
666
|
return this.generateReport();
|
|
655
667
|
}
|
|
@@ -833,7 +845,7 @@ Options:
|
|
|
833
845
|
--session-id ID CDP session (e.g. session-6 from GET /targets)
|
|
834
846
|
--help Show this help
|
|
835
847
|
|
|
836
|
-
Depth 0 (passive): reload, discover DOM, screenshots, HAR
|
|
848
|
+
Depth 0 (passive): reload, discover DOM, screenshots, HAR - zero clicks.
|
|
837
849
|
Depth N>0: up to N tab/button/checkbox interactions per category.
|
|
838
850
|
|
|
839
851
|
The tool will:
|
|
@@ -905,6 +917,26 @@ Examples:
|
|
|
905
917
|
|
|
906
918
|
} catch (err) {
|
|
907
919
|
console.error('Error:', err.message);
|
|
920
|
+
// Salvage: even on catastrophic failure, save whatever HAR + partial report we have
|
|
921
|
+
try {
|
|
922
|
+
if (harFile && explorer.requests && explorer.requests.length > 0) {
|
|
923
|
+
explorer.saveHAR();
|
|
924
|
+
console.error(`[explore] HAR salvaged despite error (${explorer.requests.length} requests captured)`);
|
|
925
|
+
}
|
|
926
|
+
if (explorer.outputDir && fs.existsSync(explorer.outputDir)) {
|
|
927
|
+
const partialReport = {
|
|
928
|
+
error: err.message,
|
|
929
|
+
url: explorer.siteMap?.url || 'unknown',
|
|
930
|
+
requestsCaptured: explorer.requests?.length || 0,
|
|
931
|
+
responsesCaptured: explorer.responses?.length || 0,
|
|
932
|
+
partial: true
|
|
933
|
+
};
|
|
934
|
+
fs.writeFileSync(path.join(explorer.outputDir, 'report.json'), JSON.stringify(partialReport, null, 2));
|
|
935
|
+
console.error(`[explore] Partial report saved: ${explorer.outputDir}/report.json`);
|
|
936
|
+
}
|
|
937
|
+
} catch (salvageErr) {
|
|
938
|
+
console.error(`[explore] Salvage failed: ${salvageErr.message}`);
|
|
939
|
+
}
|
|
908
940
|
process.exit(1);
|
|
909
941
|
} finally {
|
|
910
942
|
explorer.close();
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glidercli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"description": "Browser automation CLI. Control Chrome from terminal via CDP, run YAML task files, autonomous loops until completion.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"glider": "bin/glider.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "node bin/glider.js --help
|
|
10
|
+
"test": "node bin/glider.js --help"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"browser",
|