@xbrowser/cli 1.28.0 → 1.29.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.
- package/dist/{browser-NYYCR4O7.js → browser-2K3XYAKM.js} +5 -3
- package/dist/{browser-ZD53IMUJ.js → browser-OTEMG5NL.js} +6 -4
- package/dist/{browser-4IYIHZ6R.js → browser-XD3IOU5I.js} +8 -6
- package/dist/{cdp-driver-EFEW4ZEN.js → cdp-driver-AAS55KT2.js} +4 -4
- package/dist/{cdp-driver-4X6Q62WI.js → cdp-driver-O5I7SJ24.js} +3 -3
- package/dist/{cdp-driver-HB744QB4.js → cdp-driver-XTPY7EXP.js} +1296 -852
- package/dist/{chunk-SEEWE5SJ.js → chunk-2KPI5GKP.js} +3 -0
- package/dist/{chunk-75DNUI6M.js → chunk-6UJU2FJK.js} +146 -0
- package/dist/{chunk-3PUOISKE.js → chunk-CO2ZVOVT.js} +496 -452
- package/dist/{chunk-V6KGBU5J.js → chunk-FCPVQFTQ.js} +1011 -1038
- package/dist/{chunk-WK3INZLA.js → chunk-GDKKVT2P.js} +750 -651
- package/dist/{chunk-HSYRAV3H.js → chunk-LFSLNHW5.js} +1846 -1358
- package/dist/{chunk-OSZNJT4U.js → chunk-LM32MNBB.js} +79 -8
- package/dist/{chunk-J3HXZVSN.js → chunk-N5XTLNKS.js} +1166 -868
- package/dist/{chunk-T2AI24A5.js → chunk-NAIHOVDZ.js} +3 -0
- package/dist/{chunk-WYETQ5C7.js → chunk-NEE6EMYA.js} +14 -1
- package/dist/{chunk-ME5FO5YV.js → chunk-NQPXZ74W.js} +1296 -852
- package/dist/{chunk-KECYFWJO.js → chunk-P33R7F2D.js} +413 -384
- package/dist/{chunk-OEC7ZSFW.js → chunk-SCYBNSOG.js} +1560 -1461
- package/dist/{chunk-R3F4K2SB.js → chunk-SMYSNO4M.js} +10 -0
- package/dist/{chunk-IR6C24P7.js → chunk-UZ6XPUBD.js} +1030 -1048
- package/dist/cli.js +3398 -3357
- package/dist/daemon-main.js +737 -707
- package/dist/index.d.ts +362 -474
- package/dist/index.js +5730 -5689
- package/dist/{launcher-SJ44X25U.js → launcher-TOLF23ET.js} +1 -1
- package/dist/{launcher-XHKIC4GP.js → launcher-ZYB32LSZ.js} +1 -1
- package/dist/{plugin-singleton-GGSBI3EG.js → plugin-singleton-A6RNITJW.js} +1 -1
- package/dist/{proxy-NKCYE76M.js → proxy-H3RIUOCN.js} +2 -2
- package/dist/{server-JXF3JOAM.js → server-LNZTDAKT.js} +4 -4
- package/dist/{server-26SE6YZR.js → server-ZTI2K5YJ.js} +7 -7
- package/dist/{session-recorder-GEZVQBKW.js → session-recorder-DF2YGH2E.js} +1 -1
- package/dist/{session-recorder-563ISSJK.js → session-recorder-R3GDGXLJ.js} +1 -1
- package/dist/{session-replayer-TXTNTG33.js → session-replayer-CLTZ2URU.js} +1 -1
- package/dist/{stealth-QNSMIHQK.js → stealth-FMPZO2OB.js} +1 -1
- package/dist/{stealth-MHJNBJY7.js → stealth-MCKFKPZ6.js} +1 -1
- package/package.json +6 -3
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
Core
|
|
4
4
|
} from "@dyyz1993/xcli-core";
|
|
5
5
|
import { resolve as resolve2, basename, dirname } from "path";
|
|
6
|
-
import { existsSync as
|
|
7
|
-
import { homedir } from "os";
|
|
6
|
+
import { existsSync as existsSync4, readdirSync } from "fs";
|
|
7
|
+
import { homedir as homedir2 } from "os";
|
|
8
8
|
|
|
9
9
|
// src/plugin/metadata-parser.ts
|
|
10
10
|
import { existsSync } from "fs";
|
|
@@ -300,6 +300,75 @@ function patchLoginRequired() {
|
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
// src/lib/mistake-ledger.ts
|
|
304
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
305
|
+
import { homedir } from "os";
|
|
306
|
+
import { join as join2 } from "path";
|
|
307
|
+
var MISTAKE_THRESHOLD = 3;
|
|
308
|
+
var MISTAKE_LEDGER_PATH = join2(
|
|
309
|
+
homedir(),
|
|
310
|
+
".xbrowser",
|
|
311
|
+
"knowledge",
|
|
312
|
+
"mistakes.json"
|
|
313
|
+
);
|
|
314
|
+
function emptyLedger() {
|
|
315
|
+
return { version: 1, entries: {} };
|
|
316
|
+
}
|
|
317
|
+
function normalizeMistakeText(value) {
|
|
318
|
+
return value.replace(/\d{4}-\d{2}-\d{2}T[^'"\s]+/g, "<timestamp>").replace(/\d+(?:\.\d+)?\s*(?:ms|s)\b/gi, "<duration>").replace(/\b\d+\b/g, "<number>").replace(/\s+/g, " ").trim();
|
|
319
|
+
}
|
|
320
|
+
function mistakeFingerprint(category, message) {
|
|
321
|
+
return `${category}::${normalizeMistakeText(message)}`;
|
|
322
|
+
}
|
|
323
|
+
function readMistakeLedger(path = MISTAKE_LEDGER_PATH) {
|
|
324
|
+
try {
|
|
325
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
326
|
+
if (parsed.version !== 1 || typeof parsed.entries !== "object") {
|
|
327
|
+
return emptyLedger();
|
|
328
|
+
}
|
|
329
|
+
return parsed;
|
|
330
|
+
} catch {
|
|
331
|
+
return emptyLedger();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function writeMistakeLedger(ledger, path = MISTAKE_LEDGER_PATH) {
|
|
335
|
+
mkdirSync2(join2(path, ".."), { recursive: true });
|
|
336
|
+
writeFileSync3(path, JSON.stringify(ledger, null, 2), "utf8");
|
|
337
|
+
}
|
|
338
|
+
function recordMistake(input, path = MISTAKE_LEDGER_PATH) {
|
|
339
|
+
if (!input.category) throw new Error("mistake category is required");
|
|
340
|
+
if (!input.command) throw new Error("mistake command is required");
|
|
341
|
+
if (!input.message) throw new Error("mistake message is required");
|
|
342
|
+
const ledger = readMistakeLedger(path);
|
|
343
|
+
const fingerprint = input.fingerprint || mistakeFingerprint(input.category, input.message);
|
|
344
|
+
const previous = ledger.entries[fingerprint];
|
|
345
|
+
const occurrence = {
|
|
346
|
+
timestamp: input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
347
|
+
command: input.command,
|
|
348
|
+
message: input.message,
|
|
349
|
+
...input.context ? { context: input.context } : {}
|
|
350
|
+
};
|
|
351
|
+
const entry = previous ? {
|
|
352
|
+
...previous,
|
|
353
|
+
lastSeen: occurrence.timestamp,
|
|
354
|
+
occurrences: [...previous.occurrences, occurrence].slice(-100),
|
|
355
|
+
constrained: previous.constrained || previous.occurrences.length + 1 >= MISTAKE_THRESHOLD
|
|
356
|
+
} : {
|
|
357
|
+
fingerprint,
|
|
358
|
+
category: input.category,
|
|
359
|
+
firstSeen: occurrence.timestamp,
|
|
360
|
+
lastSeen: occurrence.timestamp,
|
|
361
|
+
occurrences: [occurrence],
|
|
362
|
+
constrained: false
|
|
363
|
+
};
|
|
364
|
+
ledger.entries[fingerprint] = entry;
|
|
365
|
+
writeMistakeLedger(ledger, path);
|
|
366
|
+
return {
|
|
367
|
+
entry,
|
|
368
|
+
newlyConstrained: Boolean(previous && !previous.constrained && entry.constrained)
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
303
372
|
// src/plugin/loader.ts
|
|
304
373
|
var DEFAULT_PLUGIN_DIRS = [".xcli/plugins", "../.xcli/plugins"];
|
|
305
374
|
var XBrowserPluginLoader = class {
|
|
@@ -310,6 +379,7 @@ var XBrowserPluginLoader = class {
|
|
|
310
379
|
dirSiteAliases = /* @__PURE__ */ new Map();
|
|
311
380
|
constructor(options) {
|
|
312
381
|
patchLoginRequired();
|
|
382
|
+
globalThis.__xbrowserRecordMistake = recordMistake;
|
|
313
383
|
this.options = options ?? {};
|
|
314
384
|
const cwd = this.options.cwd || process.cwd();
|
|
315
385
|
const coreConfig = {
|
|
@@ -390,18 +460,18 @@ var XBrowserPluginLoader = class {
|
|
|
390
460
|
}
|
|
391
461
|
async scanAndLoad() {
|
|
392
462
|
const cwd = this.options.cwd || process.cwd();
|
|
393
|
-
const globalDir = this.options.globalDir || resolve2(
|
|
463
|
+
const globalDir = this.options.globalDir || resolve2(homedir2(), ".xbrowser/plugins");
|
|
394
464
|
ensurePluginDependencies(globalDir);
|
|
395
465
|
const dirs = [
|
|
396
466
|
resolve2(cwd, ".xcli/plugins"),
|
|
397
467
|
resolve2(cwd, "../.xcli/plugins"),
|
|
398
|
-
this.options.userDir || resolve2(
|
|
468
|
+
this.options.userDir || resolve2(homedir2(), ".xcli/plugins"),
|
|
399
469
|
globalDir
|
|
400
470
|
];
|
|
401
471
|
const loaded = [];
|
|
402
472
|
const seen = /* @__PURE__ */ new Set();
|
|
403
473
|
for (const dir of dirs) {
|
|
404
|
-
if (!
|
|
474
|
+
if (!existsSync4(dir)) continue;
|
|
405
475
|
const entries = readdirSync(dir, { withFileTypes: true });
|
|
406
476
|
for (const entry of entries) {
|
|
407
477
|
if (!entry.isDirectory()) continue;
|
|
@@ -409,12 +479,12 @@ var XBrowserPluginLoader = class {
|
|
|
409
479
|
seen.add(entry.name);
|
|
410
480
|
const pluginDir = resolve2(dir, entry.name);
|
|
411
481
|
let indexPath = resolve2(pluginDir, "index.js");
|
|
412
|
-
if (!
|
|
482
|
+
if (!existsSync4(indexPath)) {
|
|
413
483
|
indexPath = resolve2(pluginDir, "index.ts");
|
|
414
484
|
}
|
|
415
|
-
if (!
|
|
485
|
+
if (!existsSync4(indexPath)) continue;
|
|
416
486
|
try {
|
|
417
|
-
if (!
|
|
487
|
+
if (!existsSync4(resolve2(pluginDir, "package.json"))) {
|
|
418
488
|
console.warn(`\u26A0\uFE0F Plugin "${entry.name}" has no package.json. Use "xbrowser create ${entry.name} --template static" for proper structure.`);
|
|
419
489
|
} else {
|
|
420
490
|
const metadata = PluginMetadataParser.parseFromPackageJson(pluginDir);
|
|
@@ -471,6 +541,7 @@ function resetPluginLoader() {
|
|
|
471
541
|
}
|
|
472
542
|
|
|
473
543
|
export {
|
|
544
|
+
recordMistake,
|
|
474
545
|
getPluginLoader,
|
|
475
546
|
resetPluginLoader
|
|
476
547
|
};
|