@xbrowser/cli 1.0.3 → 1.0.4
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/cli.js +57 -57
- package/dist/daemon-main.js +43 -43
- package/dist/index.js +55 -53
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -58,9 +58,7 @@ import {
|
|
|
58
58
|
import {
|
|
59
59
|
errMsg
|
|
60
60
|
} from "./chunk-GDKLH7ZY.js";
|
|
61
|
-
import
|
|
62
|
-
__require
|
|
63
|
-
} from "./chunk-KFQGP6VL.js";
|
|
61
|
+
import "./chunk-KFQGP6VL.js";
|
|
64
62
|
|
|
65
63
|
// src/router.ts
|
|
66
64
|
import { parseArgs, outputFormatter as outputFormatter2, isCommandResult as isCommandResult2, helpGenerator as helpGenerator2, TipCollector as TipCollector3, normalizeTips as normalizeTips7, tip as makeTip } from "@dyyz1993/xcli-core";
|
|
@@ -201,8 +199,10 @@ import {
|
|
|
201
199
|
} from "@dyyz1993/xcli-core";
|
|
202
200
|
|
|
203
201
|
// src/utils/stub-context.ts
|
|
202
|
+
import { join } from "path";
|
|
203
|
+
import { homedir } from "os";
|
|
204
204
|
import { TipCollector, CompositeStorage } from "@dyyz1993/xcli-core";
|
|
205
|
-
var CONFIG_DIR =
|
|
205
|
+
var CONFIG_DIR = join(homedir(), ".xbrowser");
|
|
206
206
|
var NoopSiteInstance = class {
|
|
207
207
|
name = "stub";
|
|
208
208
|
url = "";
|
|
@@ -1024,9 +1024,9 @@ var clearLocalStorageCommand = registerCommand({
|
|
|
1024
1024
|
import { z as z9 } from "zod";
|
|
1025
1025
|
import { ok as ok9 } from "@dyyz1993/xcli-core";
|
|
1026
1026
|
import { writeFileSync, mkdirSync } from "fs";
|
|
1027
|
-
import { join } from "path";
|
|
1028
|
-
import { homedir } from "os";
|
|
1029
|
-
var SCREENSHOTS_DIR =
|
|
1027
|
+
import { join as join2 } from "path";
|
|
1028
|
+
import { homedir as homedir2 } from "os";
|
|
1029
|
+
var SCREENSHOTS_DIR = join2(homedir2(), ".xbrowser", "screenshots");
|
|
1030
1030
|
function ensureScreenshotsDir() {
|
|
1031
1031
|
mkdirSync(SCREENSHOTS_DIR, { recursive: true });
|
|
1032
1032
|
}
|
|
@@ -1034,7 +1034,7 @@ function generateScreenshotPath(format) {
|
|
|
1034
1034
|
const timestamp = Date.now();
|
|
1035
1035
|
const random = Math.random().toString(36).slice(2, 8);
|
|
1036
1036
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
1037
|
-
return
|
|
1037
|
+
return join2(SCREENSHOTS_DIR, `screenshot-${timestamp}-${random}.${ext}`);
|
|
1038
1038
|
}
|
|
1039
1039
|
var screenshotCommand = registerCommand({
|
|
1040
1040
|
name: "screenshot",
|
|
@@ -1691,9 +1691,9 @@ var healthCheckCommand = registerCommand({
|
|
|
1691
1691
|
import { z as z14 } from "zod";
|
|
1692
1692
|
import { ok as ok14 } from "@dyyz1993/xcli-core";
|
|
1693
1693
|
import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
1694
|
-
import { join as
|
|
1695
|
-
import { homedir as
|
|
1696
|
-
var SCREENSHOTS_DIR2 =
|
|
1694
|
+
import { join as join3 } from "path";
|
|
1695
|
+
import { homedir as homedir3 } from "os";
|
|
1696
|
+
var SCREENSHOTS_DIR2 = join3(homedir3(), ".xbrowser", "screenshots");
|
|
1697
1697
|
function ensureScreenshotsDir2() {
|
|
1698
1698
|
mkdirSync2(SCREENSHOTS_DIR2, { recursive: true });
|
|
1699
1699
|
}
|
|
@@ -1701,7 +1701,7 @@ function generateScreenshotPath2(format) {
|
|
|
1701
1701
|
const timestamp = Date.now();
|
|
1702
1702
|
const random = Math.random().toString(36).slice(2, 8);
|
|
1703
1703
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
1704
|
-
return
|
|
1704
|
+
return join3(SCREENSHOTS_DIR2, `screenshot-${timestamp}-${random}.${ext}`);
|
|
1705
1705
|
}
|
|
1706
1706
|
var waitActionSchema = z14.object({
|
|
1707
1707
|
type: z14.literal("wait"),
|
|
@@ -4203,8 +4203,8 @@ async function resolveRefParams(page, params, selectorKeys, cache, sessionId) {
|
|
|
4203
4203
|
|
|
4204
4204
|
// src/utils/site-semantics.ts
|
|
4205
4205
|
import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, existsSync, readFileSync } from "fs";
|
|
4206
|
-
import { join as
|
|
4207
|
-
import { homedir as
|
|
4206
|
+
import { join as join4, dirname } from "path";
|
|
4207
|
+
import { homedir as homedir4 } from "os";
|
|
4208
4208
|
import { stringify, parse } from "yaml";
|
|
4209
4209
|
import { execFile } from "child_process";
|
|
4210
4210
|
var INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
@@ -4281,10 +4281,10 @@ function inferAction(role, label) {
|
|
|
4281
4281
|
return {};
|
|
4282
4282
|
}
|
|
4283
4283
|
function getSemanticsDir() {
|
|
4284
|
-
return
|
|
4284
|
+
return join4(homedir4(), ".xbrowser", "site-semantics");
|
|
4285
4285
|
}
|
|
4286
4286
|
function getSemanticsPath(domain) {
|
|
4287
|
-
return
|
|
4287
|
+
return join4(getSemanticsDir(), `${domain}.yaml`);
|
|
4288
4288
|
}
|
|
4289
4289
|
function extractDomain2(url) {
|
|
4290
4290
|
try {
|
|
@@ -5865,7 +5865,7 @@ import {
|
|
|
5865
5865
|
} from "@dyyz1993/xcli-core";
|
|
5866
5866
|
import { resolve as resolve2 } from "path";
|
|
5867
5867
|
import { existsSync as existsSync4, readdirSync } from "fs";
|
|
5868
|
-
import { homedir as
|
|
5868
|
+
import { homedir as homedir5 } from "os";
|
|
5869
5869
|
|
|
5870
5870
|
// src/plugin/metadata-parser.ts
|
|
5871
5871
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -5952,17 +5952,17 @@ var PluginMetadataParser = class {
|
|
|
5952
5952
|
|
|
5953
5953
|
// src/plugin/ensure-deps.ts
|
|
5954
5954
|
import { existsSync as existsSync3, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
5955
|
-
import { join as
|
|
5955
|
+
import { join as join5 } from "path";
|
|
5956
5956
|
import { execSync } from "child_process";
|
|
5957
5957
|
var SHARED_PLUGIN_DEPENDENCIES = {
|
|
5958
5958
|
"zod": "^3.24.0",
|
|
5959
5959
|
"@dyyz1993/xcli-core": "^0.12.1"
|
|
5960
5960
|
};
|
|
5961
5961
|
function ensurePluginDependencies(pluginsDir) {
|
|
5962
|
-
const zodPath =
|
|
5962
|
+
const zodPath = join5(pluginsDir, "node_modules", "zod");
|
|
5963
5963
|
if (existsSync3(zodPath)) return;
|
|
5964
5964
|
mkdirSync4(pluginsDir, { recursive: true });
|
|
5965
|
-
const pkgPath =
|
|
5965
|
+
const pkgPath = join5(pluginsDir, "package.json");
|
|
5966
5966
|
let pkg2 = {};
|
|
5967
5967
|
if (existsSync3(pkgPath)) {
|
|
5968
5968
|
try {
|
|
@@ -5978,7 +5978,7 @@ function ensurePluginDependencies(pluginsDir) {
|
|
|
5978
5978
|
needsInstall = true;
|
|
5979
5979
|
}
|
|
5980
5980
|
}
|
|
5981
|
-
if (!needsInstall && existsSync3(
|
|
5981
|
+
if (!needsInstall && existsSync3(join5(pluginsDir, "node_modules"))) return;
|
|
5982
5982
|
pkg2.dependencies = existingDeps;
|
|
5983
5983
|
pkg2.private = true;
|
|
5984
5984
|
pkg2.description = pkg2.description || "xbrowser plugins \u2014 shared dependencies";
|
|
@@ -6225,12 +6225,12 @@ var XBrowserPluginLoader = class {
|
|
|
6225
6225
|
}
|
|
6226
6226
|
async scanAndLoad() {
|
|
6227
6227
|
const cwd = this.options.cwd || process.cwd();
|
|
6228
|
-
const globalDir = this.options.globalDir || resolve2(
|
|
6228
|
+
const globalDir = this.options.globalDir || resolve2(homedir5(), ".xbrowser/plugins");
|
|
6229
6229
|
ensurePluginDependencies(globalDir);
|
|
6230
6230
|
const dirs = [
|
|
6231
6231
|
resolve2(cwd, ".xcli/plugins"),
|
|
6232
6232
|
resolve2(cwd, "../.xcli/plugins"),
|
|
6233
|
-
this.options.userDir || resolve2(
|
|
6233
|
+
this.options.userDir || resolve2(homedir5(), ".xcli/plugins"),
|
|
6234
6234
|
globalDir
|
|
6235
6235
|
];
|
|
6236
6236
|
const loaded = [];
|
|
@@ -6887,11 +6887,11 @@ async function loadHooks() {
|
|
|
6887
6887
|
}
|
|
6888
6888
|
|
|
6889
6889
|
// src/executor.ts
|
|
6890
|
-
import { homedir as
|
|
6891
|
-
import { join as
|
|
6890
|
+
import { homedir as homedir6 } from "os";
|
|
6891
|
+
import { join as join6 } from "path";
|
|
6892
6892
|
var NAVIGATION_COMMANDS = /* @__PURE__ */ new Set(["goto", "back", "forward", "refresh"]);
|
|
6893
6893
|
var snapshotHintShown = /* @__PURE__ */ new WeakSet();
|
|
6894
|
-
var CONFIG_DIR2 =
|
|
6894
|
+
var CONFIG_DIR2 = join6(homedir6(), ".xbrowser");
|
|
6895
6895
|
var storageCache = /* @__PURE__ */ new Map();
|
|
6896
6896
|
function getPluginStorage(pluginName) {
|
|
6897
6897
|
if (!storageCache.has(pluginName)) {
|
|
@@ -6903,7 +6903,7 @@ var archiveInitialized = false;
|
|
|
6903
6903
|
function ensureArchiveInit() {
|
|
6904
6904
|
if (!archiveInitialized) {
|
|
6905
6905
|
try {
|
|
6906
|
-
configureArchiveStore({ archiveDir:
|
|
6906
|
+
configureArchiveStore({ archiveDir: join6(homedir6(), ".xbrowser", "archives") });
|
|
6907
6907
|
} catch {
|
|
6908
6908
|
}
|
|
6909
6909
|
archiveInitialized = true;
|
|
@@ -7542,11 +7542,11 @@ var sessionKillBuiltin = {
|
|
|
7542
7542
|
};
|
|
7543
7543
|
|
|
7544
7544
|
// src/config.ts
|
|
7545
|
-
import { homedir as
|
|
7546
|
-
import { join as
|
|
7545
|
+
import { homedir as homedir7, tmpdir } from "os";
|
|
7546
|
+
import { join as join7 } from "path";
|
|
7547
7547
|
import { loadConfig as coreLoadConfig, saveConfig as coreSaveConfig } from "@dyyz1993/xcli-core";
|
|
7548
7548
|
function getConfigSource() {
|
|
7549
|
-
return { configDir:
|
|
7549
|
+
return { configDir: join7(homedir7() || tmpdir(), ".xbrowser") };
|
|
7550
7550
|
}
|
|
7551
7551
|
function loadConfig() {
|
|
7552
7552
|
return coreLoadConfig(getConfigSource());
|
|
@@ -7666,7 +7666,7 @@ import {
|
|
|
7666
7666
|
rmSync as rmSync6
|
|
7667
7667
|
} from "fs";
|
|
7668
7668
|
import { resolve as resolve8, basename as basename2 } from "path";
|
|
7669
|
-
import { homedir as
|
|
7669
|
+
import { homedir as homedir8 } from "os";
|
|
7670
7670
|
|
|
7671
7671
|
// src/plugin/install-sources/local.ts
|
|
7672
7672
|
import { existsSync as existsSync5, cpSync, rmSync } from "fs";
|
|
@@ -7708,7 +7708,7 @@ async function installFromLocal(source, name, targetDir) {
|
|
|
7708
7708
|
|
|
7709
7709
|
// src/plugin/install-sources/npm.ts
|
|
7710
7710
|
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync6, rmSync as rmSync2, cpSync as cpSync2 } from "fs";
|
|
7711
|
-
import { resolve as resolve4, join as
|
|
7711
|
+
import { resolve as resolve4, join as join8 } from "path";
|
|
7712
7712
|
import { tmpdir as tmpdir2 } from "os";
|
|
7713
7713
|
import {
|
|
7714
7714
|
downloadToFile,
|
|
@@ -7781,13 +7781,13 @@ async function installFromNpm(packageName, name, targetDir) {
|
|
|
7781
7781
|
throw new Error(`No tarball URL for ${packageName}@${latestVersion}`);
|
|
7782
7782
|
}
|
|
7783
7783
|
const tarballUrl = versionMeta.dist.tarball;
|
|
7784
|
-
const tmpDir =
|
|
7784
|
+
const tmpDir = join8(tmpdir2(), `xbrowser-npm-${Date.now()}`);
|
|
7785
7785
|
mkdirSync5(tmpDir, { recursive: true });
|
|
7786
7786
|
let warnings = [];
|
|
7787
7787
|
try {
|
|
7788
|
-
const tarballPath =
|
|
7788
|
+
const tarballPath = join8(tmpDir, `${name}.tgz`);
|
|
7789
7789
|
await downloadToFile(tarballUrl, tarballPath);
|
|
7790
|
-
const extractDir =
|
|
7790
|
+
const extractDir = join8(tmpDir, "extracted");
|
|
7791
7791
|
extractTarGz(tarballPath, extractDir);
|
|
7792
7792
|
flattenPackageRoot(extractDir);
|
|
7793
7793
|
const verify = verifyPlugin2(extractDir, { metadataField: "xbrowser" });
|
|
@@ -7822,12 +7822,12 @@ async function installFromNpm(packageName, name, targetDir) {
|
|
|
7822
7822
|
|
|
7823
7823
|
// src/plugin/install-sources/git.ts
|
|
7824
7824
|
import { existsSync as existsSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync7, rmSync as rmSync3, cpSync as cpSync3 } from "fs";
|
|
7825
|
-
import { resolve as resolve5, join as
|
|
7825
|
+
import { resolve as resolve5, join as join9 } from "path";
|
|
7826
7826
|
import { tmpdir as tmpdir3 } from "os";
|
|
7827
7827
|
import { execSync as execSync2 } from "child_process";
|
|
7828
7828
|
import { verifyPlugin as verifyPlugin3, safeCleanup as safeCleanup3 } from "@dyyz1993/xcli-core";
|
|
7829
7829
|
async function installFromGit(gitUrl, name, targetDir) {
|
|
7830
|
-
const tmpDir =
|
|
7830
|
+
const tmpDir = join9(tmpdir3(), `xbrowser-git-${Date.now()}`);
|
|
7831
7831
|
let warnings = [];
|
|
7832
7832
|
try {
|
|
7833
7833
|
execSync2(`git clone --depth 1 "${gitUrl}" "${tmpDir}"`, { stdio: "pipe" });
|
|
@@ -7864,7 +7864,7 @@ async function installFromGit(gitUrl, name, targetDir) {
|
|
|
7864
7864
|
|
|
7865
7865
|
// src/plugin/install-sources/url.ts
|
|
7866
7866
|
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync8, rmSync as rmSync4, cpSync as cpSync4 } from "fs";
|
|
7867
|
-
import { resolve as resolve6, join as
|
|
7867
|
+
import { resolve as resolve6, join as join10, basename } from "path";
|
|
7868
7868
|
import { tmpdir as tmpdir4 } from "os";
|
|
7869
7869
|
import {
|
|
7870
7870
|
downloadToFile as downloadToFile2,
|
|
@@ -7874,14 +7874,14 @@ import {
|
|
|
7874
7874
|
safeCleanup as safeCleanup4
|
|
7875
7875
|
} from "@dyyz1993/xcli-core";
|
|
7876
7876
|
async function installFromUrl(url, name, targetDir) {
|
|
7877
|
-
const tmpDir =
|
|
7877
|
+
const tmpDir = join10(tmpdir4(), `xbrowser-url-${Date.now()}`);
|
|
7878
7878
|
mkdirSync6(tmpDir, { recursive: true });
|
|
7879
7879
|
let warnings = [];
|
|
7880
7880
|
try {
|
|
7881
7881
|
const fileName = basename(new URL(url).pathname) || "plugin.tar.gz";
|
|
7882
|
-
const tarballPath =
|
|
7882
|
+
const tarballPath = join10(tmpDir, fileName);
|
|
7883
7883
|
await downloadToFile2(url, tarballPath);
|
|
7884
|
-
const extractDir =
|
|
7884
|
+
const extractDir = join10(tmpDir, "extracted");
|
|
7885
7885
|
extractTarGz2(tarballPath, extractDir);
|
|
7886
7886
|
flattenPackageRoot2(extractDir);
|
|
7887
7887
|
const verify = verifyPlugin4(extractDir, { metadataField: "xbrowser" });
|
|
@@ -7923,7 +7923,7 @@ import {
|
|
|
7923
7923
|
rmSync as rmSync5,
|
|
7924
7924
|
cpSync as cpSync5
|
|
7925
7925
|
} from "fs";
|
|
7926
|
-
import { resolve as resolve7, join as
|
|
7926
|
+
import { resolve as resolve7, join as join11, dirname as dirname2 } from "path";
|
|
7927
7927
|
import { tmpdir as tmpdir5 } from "os";
|
|
7928
7928
|
import { gunzipSync } from "zlib";
|
|
7929
7929
|
import {
|
|
@@ -7952,7 +7952,7 @@ async function installFromMarketplace(pluginsDir, slug, options) {
|
|
|
7952
7952
|
throw new Error(`Plugin "${name}" already exists. Use --force to overwrite.`);
|
|
7953
7953
|
}
|
|
7954
7954
|
mkdirSync7(targetDir, { recursive: true });
|
|
7955
|
-
const tmpDir =
|
|
7955
|
+
const tmpDir = join11(tmpdir5(), `xbrowser-marketplace-${Date.now()}`);
|
|
7956
7956
|
mkdirSync7(tmpDir, { recursive: true });
|
|
7957
7957
|
const realSlug = String(plugin.slug || slug);
|
|
7958
7958
|
try {
|
|
@@ -8015,7 +8015,7 @@ async function downloadAndExtractMarketplaceTarball(baseUrl, slug, tmpDir, targe
|
|
|
8015
8015
|
}
|
|
8016
8016
|
if (tarballRes.status === 302 || tarballRes.headers.get("location")) {
|
|
8017
8017
|
const redirectUrl = tarballRes.headers.get("location");
|
|
8018
|
-
const tarballPath =
|
|
8018
|
+
const tarballPath = join11(tmpDir, `${slug}.tar.gz`);
|
|
8019
8019
|
await downloadToFile3(redirectUrl, tarballPath);
|
|
8020
8020
|
const buffer = readFileSync7(tarballPath);
|
|
8021
8021
|
const manifest = tryParseAsGzippedManifest(buffer);
|
|
@@ -8023,7 +8023,7 @@ async function downloadAndExtractMarketplaceTarball(baseUrl, slug, tmpDir, targe
|
|
|
8023
8023
|
extractManifestToDir(manifest, targetDir);
|
|
8024
8024
|
return;
|
|
8025
8025
|
}
|
|
8026
|
-
const extractDir =
|
|
8026
|
+
const extractDir = join11(tmpDir, "extracted");
|
|
8027
8027
|
extractTarGz3(tarballPath, extractDir);
|
|
8028
8028
|
flattenPackageRoot3(extractDir);
|
|
8029
8029
|
if (existsSync9(targetDir)) {
|
|
@@ -8037,10 +8037,10 @@ async function downloadAndExtractMarketplaceTarball(baseUrl, slug, tmpDir, targe
|
|
|
8037
8037
|
extractManifestToDir(manifest, targetDir);
|
|
8038
8038
|
return;
|
|
8039
8039
|
}
|
|
8040
|
-
const tarballPath =
|
|
8040
|
+
const tarballPath = join11(tmpDir, `${slug}.tar.gz`);
|
|
8041
8041
|
writeFileSync9(tarballPath, buffer);
|
|
8042
8042
|
try {
|
|
8043
|
-
const extractDir =
|
|
8043
|
+
const extractDir = join11(tmpDir, "extracted");
|
|
8044
8044
|
extractTarGz3(tarballPath, extractDir);
|
|
8045
8045
|
flattenPackageRoot3(extractDir);
|
|
8046
8046
|
if (existsSync9(targetDir)) {
|
|
@@ -8133,7 +8133,7 @@ function ensureIndexFile(plugin, name, targetDir) {
|
|
|
8133
8133
|
var PluginInstaller = class {
|
|
8134
8134
|
pluginsDir;
|
|
8135
8135
|
constructor(pluginsDir) {
|
|
8136
|
-
this.pluginsDir = pluginsDir || resolve8(
|
|
8136
|
+
this.pluginsDir = pluginsDir || resolve8(homedir8(), ".xbrowser/plugins");
|
|
8137
8137
|
}
|
|
8138
8138
|
getPluginsDir() {
|
|
8139
8139
|
return this.pluginsDir;
|
|
@@ -9765,15 +9765,15 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
|
|
|
9765
9765
|
}
|
|
9766
9766
|
|
|
9767
9767
|
// src/cli/session-routes.ts
|
|
9768
|
-
import { homedir as
|
|
9769
|
-
import { join as
|
|
9768
|
+
import { homedir as homedir9 } from "os";
|
|
9769
|
+
import { join as join13 } from "path";
|
|
9770
9770
|
import { readdirSync as readdirSync3, rmSync as rmSync7 } from "fs";
|
|
9771
9771
|
function cleanSessionFiles() {
|
|
9772
|
-
const dir =
|
|
9772
|
+
const dir = join13(homedir9(), ".xbrowser", "sessions");
|
|
9773
9773
|
let count = 0;
|
|
9774
9774
|
try {
|
|
9775
9775
|
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
9776
|
-
const p =
|
|
9776
|
+
const p = join13(dir, entry.name);
|
|
9777
9777
|
rmSync7(p, { recursive: true, force: true });
|
|
9778
9778
|
count++;
|
|
9779
9779
|
}
|
|
@@ -10570,7 +10570,7 @@ async function handleGeneratePlugin(sessionName, pluginName, outputDir) {
|
|
|
10570
10570
|
const { SessionRecorder: SessionRecorder2 } = await import("./session-recorder-RTDGURIJ.js");
|
|
10571
10571
|
const { readSiteKnowledge: readSiteKnowledge2, toMarkdown } = await import("./site-knowledge-SYC6VCDB.js");
|
|
10572
10572
|
const { mkdirSync: mkdirSync10, writeFileSync: writeFileSync11 } = await import("fs");
|
|
10573
|
-
const { join:
|
|
10573
|
+
const { join: join14 } = await import("path");
|
|
10574
10574
|
const data = SessionRecorder2.readData(sessionName);
|
|
10575
10575
|
if (!data) {
|
|
10576
10576
|
outputError(`No recording found for session "${sessionName}". Run \`xbrowser record stop --session ${sessionName}\` first.`);
|
|
@@ -10582,14 +10582,14 @@ async function handleGeneratePlugin(sessionName, pluginName, outputDir) {
|
|
|
10582
10582
|
} catch {
|
|
10583
10583
|
}
|
|
10584
10584
|
const finalPluginName = pluginName || domain.split(".")[0] || "my-site";
|
|
10585
|
-
const finalOutputDir = outputDir ||
|
|
10585
|
+
const finalOutputDir = outputDir || join14(process.cwd(), ".xcli", "plugins", finalPluginName);
|
|
10586
10586
|
const knowledge = readSiteKnowledge2(domain);
|
|
10587
10587
|
const knowledgeMd = knowledge ? toMarkdown(knowledge) : "";
|
|
10588
10588
|
const pluginCode = generatePluginCode(finalPluginName, domain, data, knowledgeMd);
|
|
10589
|
-
mkdirSync10(
|
|
10590
|
-
writeFileSync11(
|
|
10589
|
+
mkdirSync10(join14(finalOutputDir), { recursive: true });
|
|
10590
|
+
writeFileSync11(join14(finalOutputDir, "index.ts"), pluginCode, "utf-8");
|
|
10591
10591
|
if (knowledgeMd) {
|
|
10592
|
-
writeFileSync11(
|
|
10592
|
+
writeFileSync11(join14(finalOutputDir, "SITE_KNOWLEDGE.md"), knowledgeMd, "utf-8");
|
|
10593
10593
|
}
|
|
10594
10594
|
console.log("");
|
|
10595
10595
|
console.log("=== Plugin Generated ===");
|
package/dist/daemon-main.js
CHANGED
|
@@ -31,20 +31,18 @@ import {
|
|
|
31
31
|
import {
|
|
32
32
|
errMsg
|
|
33
33
|
} from "./chunk-GDKLH7ZY.js";
|
|
34
|
-
import
|
|
35
|
-
__require
|
|
36
|
-
} from "./chunk-KFQGP6VL.js";
|
|
34
|
+
import "./chunk-KFQGP6VL.js";
|
|
37
35
|
|
|
38
36
|
// src/daemon/daemon-main.ts
|
|
39
37
|
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync7, appendFileSync } from "fs";
|
|
40
|
-
import { join as
|
|
41
|
-
import { homedir as
|
|
38
|
+
import { join as join9 } from "path";
|
|
39
|
+
import { homedir as homedir9 } from "os";
|
|
42
40
|
import { startHttpServer } from "@dyyz1993/xcli-core";
|
|
43
41
|
|
|
44
42
|
// src/daemon/rpc-handlers.ts
|
|
45
43
|
import { writeFileSync as writeFileSync7, mkdirSync as mkdirSync6, readFileSync as readFileSync6 } from "fs";
|
|
46
|
-
import { join as
|
|
47
|
-
import { homedir as
|
|
44
|
+
import { join as join8 } from "path";
|
|
45
|
+
import { homedir as homedir8 } from "os";
|
|
48
46
|
import {
|
|
49
47
|
createSessionMeta,
|
|
50
48
|
removeSession
|
|
@@ -175,8 +173,10 @@ function parsePluginParams(args, schema, base = {}) {
|
|
|
175
173
|
}
|
|
176
174
|
|
|
177
175
|
// src/utils/stub-context.ts
|
|
176
|
+
import { join } from "path";
|
|
177
|
+
import { homedir } from "os";
|
|
178
178
|
import { TipCollector, CompositeStorage } from "@dyyz1993/xcli-core";
|
|
179
|
-
var CONFIG_DIR =
|
|
179
|
+
var CONFIG_DIR = join(homedir(), ".xbrowser");
|
|
180
180
|
var NoopSiteInstance = class {
|
|
181
181
|
name = "stub";
|
|
182
182
|
url = "";
|
|
@@ -982,9 +982,9 @@ var clearLocalStorageCommand = registerCommand({
|
|
|
982
982
|
import { z as z9 } from "zod";
|
|
983
983
|
import { ok as ok9 } from "@dyyz1993/xcli-core";
|
|
984
984
|
import { writeFileSync, mkdirSync } from "fs";
|
|
985
|
-
import { join } from "path";
|
|
986
|
-
import { homedir } from "os";
|
|
987
|
-
var SCREENSHOTS_DIR =
|
|
985
|
+
import { join as join2 } from "path";
|
|
986
|
+
import { homedir as homedir2 } from "os";
|
|
987
|
+
var SCREENSHOTS_DIR = join2(homedir2(), ".xbrowser", "screenshots");
|
|
988
988
|
function ensureScreenshotsDir() {
|
|
989
989
|
mkdirSync(SCREENSHOTS_DIR, { recursive: true });
|
|
990
990
|
}
|
|
@@ -992,7 +992,7 @@ function generateScreenshotPath(format) {
|
|
|
992
992
|
const timestamp = Date.now();
|
|
993
993
|
const random = Math.random().toString(36).slice(2, 8);
|
|
994
994
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
995
|
-
return
|
|
995
|
+
return join2(SCREENSHOTS_DIR, `screenshot-${timestamp}-${random}.${ext}`);
|
|
996
996
|
}
|
|
997
997
|
var screenshotCommand = registerCommand({
|
|
998
998
|
name: "screenshot",
|
|
@@ -1649,9 +1649,9 @@ var healthCheckCommand = registerCommand({
|
|
|
1649
1649
|
import { z as z14 } from "zod";
|
|
1650
1650
|
import { ok as ok14 } from "@dyyz1993/xcli-core";
|
|
1651
1651
|
import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
1652
|
-
import { join as
|
|
1653
|
-
import { homedir as
|
|
1654
|
-
var SCREENSHOTS_DIR2 =
|
|
1652
|
+
import { join as join3 } from "path";
|
|
1653
|
+
import { homedir as homedir3 } from "os";
|
|
1654
|
+
var SCREENSHOTS_DIR2 = join3(homedir3(), ".xbrowser", "screenshots");
|
|
1655
1655
|
function ensureScreenshotsDir2() {
|
|
1656
1656
|
mkdirSync2(SCREENSHOTS_DIR2, { recursive: true });
|
|
1657
1657
|
}
|
|
@@ -1659,7 +1659,7 @@ function generateScreenshotPath2(format) {
|
|
|
1659
1659
|
const timestamp = Date.now();
|
|
1660
1660
|
const random = Math.random().toString(36).slice(2, 8);
|
|
1661
1661
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
1662
|
-
return
|
|
1662
|
+
return join3(SCREENSHOTS_DIR2, `screenshot-${timestamp}-${random}.${ext}`);
|
|
1663
1663
|
}
|
|
1664
1664
|
var waitActionSchema = z14.object({
|
|
1665
1665
|
type: z14.literal("wait"),
|
|
@@ -4161,8 +4161,8 @@ async function resolveRefParams(page, params, selectorKeys, cache, sessionId) {
|
|
|
4161
4161
|
|
|
4162
4162
|
// src/utils/site-semantics.ts
|
|
4163
4163
|
import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, existsSync, readFileSync } from "fs";
|
|
4164
|
-
import { join as
|
|
4165
|
-
import { homedir as
|
|
4164
|
+
import { join as join4, dirname } from "path";
|
|
4165
|
+
import { homedir as homedir4 } from "os";
|
|
4166
4166
|
import { stringify, parse } from "yaml";
|
|
4167
4167
|
import { execFile } from "child_process";
|
|
4168
4168
|
var INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
@@ -4239,10 +4239,10 @@ function inferAction(role, label) {
|
|
|
4239
4239
|
return {};
|
|
4240
4240
|
}
|
|
4241
4241
|
function getSemanticsDir() {
|
|
4242
|
-
return
|
|
4242
|
+
return join4(homedir4(), ".xbrowser", "site-semantics");
|
|
4243
4243
|
}
|
|
4244
4244
|
function getSemanticsPath(domain) {
|
|
4245
|
-
return
|
|
4245
|
+
return join4(getSemanticsDir(), `${domain}.yaml`);
|
|
4246
4246
|
}
|
|
4247
4247
|
function extractDomain2(url) {
|
|
4248
4248
|
try {
|
|
@@ -5823,7 +5823,7 @@ import {
|
|
|
5823
5823
|
} from "@dyyz1993/xcli-core";
|
|
5824
5824
|
import { resolve as resolve2 } from "path";
|
|
5825
5825
|
import { existsSync as existsSync4, readdirSync } from "fs";
|
|
5826
|
-
import { homedir as
|
|
5826
|
+
import { homedir as homedir5 } from "os";
|
|
5827
5827
|
|
|
5828
5828
|
// src/plugin/metadata-parser.ts
|
|
5829
5829
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -5910,17 +5910,17 @@ var PluginMetadataParser = class {
|
|
|
5910
5910
|
|
|
5911
5911
|
// src/plugin/ensure-deps.ts
|
|
5912
5912
|
import { existsSync as existsSync3, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
5913
|
-
import { join as
|
|
5913
|
+
import { join as join5 } from "path";
|
|
5914
5914
|
import { execSync } from "child_process";
|
|
5915
5915
|
var SHARED_PLUGIN_DEPENDENCIES = {
|
|
5916
5916
|
"zod": "^3.24.0",
|
|
5917
5917
|
"@dyyz1993/xcli-core": "^0.12.1"
|
|
5918
5918
|
};
|
|
5919
5919
|
function ensurePluginDependencies(pluginsDir) {
|
|
5920
|
-
const zodPath =
|
|
5920
|
+
const zodPath = join5(pluginsDir, "node_modules", "zod");
|
|
5921
5921
|
if (existsSync3(zodPath)) return;
|
|
5922
5922
|
mkdirSync4(pluginsDir, { recursive: true });
|
|
5923
|
-
const pkgPath =
|
|
5923
|
+
const pkgPath = join5(pluginsDir, "package.json");
|
|
5924
5924
|
let pkg = {};
|
|
5925
5925
|
if (existsSync3(pkgPath)) {
|
|
5926
5926
|
try {
|
|
@@ -5936,7 +5936,7 @@ function ensurePluginDependencies(pluginsDir) {
|
|
|
5936
5936
|
needsInstall = true;
|
|
5937
5937
|
}
|
|
5938
5938
|
}
|
|
5939
|
-
if (!needsInstall && existsSync3(
|
|
5939
|
+
if (!needsInstall && existsSync3(join5(pluginsDir, "node_modules"))) return;
|
|
5940
5940
|
pkg.dependencies = existingDeps;
|
|
5941
5941
|
pkg.private = true;
|
|
5942
5942
|
pkg.description = pkg.description || "xbrowser plugins \u2014 shared dependencies";
|
|
@@ -6183,12 +6183,12 @@ var XBrowserPluginLoader = class {
|
|
|
6183
6183
|
}
|
|
6184
6184
|
async scanAndLoad() {
|
|
6185
6185
|
const cwd = this.options.cwd || process.cwd();
|
|
6186
|
-
const globalDir = this.options.globalDir || resolve2(
|
|
6186
|
+
const globalDir = this.options.globalDir || resolve2(homedir5(), ".xbrowser/plugins");
|
|
6187
6187
|
ensurePluginDependencies(globalDir);
|
|
6188
6188
|
const dirs = [
|
|
6189
6189
|
resolve2(cwd, ".xcli/plugins"),
|
|
6190
6190
|
resolve2(cwd, "../.xcli/plugins"),
|
|
6191
|
-
this.options.userDir || resolve2(
|
|
6191
|
+
this.options.userDir || resolve2(homedir5(), ".xcli/plugins"),
|
|
6192
6192
|
globalDir
|
|
6193
6193
|
];
|
|
6194
6194
|
const loaded = [];
|
|
@@ -6845,11 +6845,11 @@ async function loadHooks() {
|
|
|
6845
6845
|
}
|
|
6846
6846
|
|
|
6847
6847
|
// src/executor.ts
|
|
6848
|
-
import { homedir as
|
|
6849
|
-
import { join as
|
|
6848
|
+
import { homedir as homedir6 } from "os";
|
|
6849
|
+
import { join as join6 } from "path";
|
|
6850
6850
|
var NAVIGATION_COMMANDS = /* @__PURE__ */ new Set(["goto", "back", "forward", "refresh"]);
|
|
6851
6851
|
var snapshotHintShown = /* @__PURE__ */ new WeakSet();
|
|
6852
|
-
var CONFIG_DIR2 =
|
|
6852
|
+
var CONFIG_DIR2 = join6(homedir6(), ".xbrowser");
|
|
6853
6853
|
var storageCache = /* @__PURE__ */ new Map();
|
|
6854
6854
|
function getPluginStorage(pluginName) {
|
|
6855
6855
|
if (!storageCache.has(pluginName)) {
|
|
@@ -6861,7 +6861,7 @@ var archiveInitialized = false;
|
|
|
6861
6861
|
function ensureArchiveInit() {
|
|
6862
6862
|
if (!archiveInitialized) {
|
|
6863
6863
|
try {
|
|
6864
|
-
configureArchiveStore({ archiveDir:
|
|
6864
|
+
configureArchiveStore({ archiveDir: join6(homedir6(), ".xbrowser", "archives") });
|
|
6865
6865
|
} catch {
|
|
6866
6866
|
}
|
|
6867
6867
|
archiveInitialized = true;
|
|
@@ -7619,9 +7619,9 @@ async function replayEntry(entry, options = {}) {
|
|
|
7619
7619
|
|
|
7620
7620
|
// src/daemon/feedback-store.ts
|
|
7621
7621
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync6, mkdirSync as mkdirSync5 } from "fs";
|
|
7622
|
-
import { join as
|
|
7623
|
-
import { homedir as
|
|
7624
|
-
var FEEDBACK_FILE =
|
|
7622
|
+
import { join as join7 } from "path";
|
|
7623
|
+
import { homedir as homedir7 } from "os";
|
|
7624
|
+
var FEEDBACK_FILE = join7(homedir7(), ".xbrowser", "feedback.json");
|
|
7625
7625
|
var FeedbackStore = class {
|
|
7626
7626
|
entries = [];
|
|
7627
7627
|
constructor() {
|
|
@@ -7637,7 +7637,7 @@ var FeedbackStore = class {
|
|
|
7637
7637
|
}
|
|
7638
7638
|
save() {
|
|
7639
7639
|
try {
|
|
7640
|
-
mkdirSync5(
|
|
7640
|
+
mkdirSync5(join7(homedir7(), ".xbrowser"), { recursive: true });
|
|
7641
7641
|
writeFileSync6(FEEDBACK_FILE, JSON.stringify(this.entries, null, 2));
|
|
7642
7642
|
} catch {
|
|
7643
7643
|
}
|
|
@@ -7936,7 +7936,7 @@ var PlaybackEngine = class _PlaybackEngine {
|
|
|
7936
7936
|
// src/daemon/rpc-handlers.ts
|
|
7937
7937
|
var activeRecorders = /* @__PURE__ */ new Map();
|
|
7938
7938
|
var replayResumeResolvers = /* @__PURE__ */ new Map();
|
|
7939
|
-
var CONFIG_DIR3 =
|
|
7939
|
+
var CONFIG_DIR3 = join8(homedir8(), ".xbrowser");
|
|
7940
7940
|
var RECORDING_INJECT_JS = `
|
|
7941
7941
|
(function(){
|
|
7942
7942
|
if(window.__xb_rec) return;
|
|
@@ -8384,9 +8384,9 @@ function createRPCHandler() {
|
|
|
8384
8384
|
if (!sess) return { ok: false, error: "No session" };
|
|
8385
8385
|
try {
|
|
8386
8386
|
const events = await sess.page.evaluate(() => window.__xb_evts || []);
|
|
8387
|
-
const recordingsDir =
|
|
8387
|
+
const recordingsDir = join8(CONFIG_DIR3, "recordings");
|
|
8388
8388
|
mkdirSync6(recordingsDir, { recursive: true });
|
|
8389
|
-
const outPath = params.path ||
|
|
8389
|
+
const outPath = params.path || join8(recordingsDir, `recording-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.json`);
|
|
8390
8390
|
writeFileSync7(outPath, JSON.stringify({
|
|
8391
8391
|
startUrl: sess.page.url(),
|
|
8392
8392
|
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -9704,12 +9704,12 @@ var FileListHandler = class {
|
|
|
9704
9704
|
const msg = ctx.message;
|
|
9705
9705
|
try {
|
|
9706
9706
|
const { readdirSync: readdirSync2, statSync } = await import("fs");
|
|
9707
|
-
const { join:
|
|
9707
|
+
const { join: join10, resolve: resolve3 } = await import("path");
|
|
9708
9708
|
const targetPath = resolve3(msg.path);
|
|
9709
9709
|
const entries = readdirSync2(targetPath);
|
|
9710
9710
|
const files = entries.map((name) => {
|
|
9711
9711
|
try {
|
|
9712
|
-
const stat = statSync(
|
|
9712
|
+
const stat = statSync(join10(targetPath, name));
|
|
9713
9713
|
return { name, isDir: stat.isDirectory(), size: stat.size, modified: stat.mtime.toISOString() };
|
|
9714
9714
|
} catch {
|
|
9715
9715
|
return { name, isDir: false, size: 0, modified: "" };
|
|
@@ -11370,8 +11370,8 @@ connectWS();
|
|
|
11370
11370
|
}
|
|
11371
11371
|
|
|
11372
11372
|
// src/daemon/daemon-main.ts
|
|
11373
|
-
var CONFIG_DIR4 =
|
|
11374
|
-
var LOG_FILE =
|
|
11373
|
+
var CONFIG_DIR4 = join9(homedir9(), ".xbrowser");
|
|
11374
|
+
var LOG_FILE = join9(CONFIG_DIR4, "daemon.log");
|
|
11375
11375
|
function log(msg) {
|
|
11376
11376
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
|
|
11377
11377
|
const line = `[DAEMON ${ts}] ${msg}
|
|
@@ -11426,7 +11426,7 @@ async function main() {
|
|
|
11426
11426
|
previewWS.on("screencast-started", (sid) => log(`Preview screencast started: ${sid}`));
|
|
11427
11427
|
previewWS.on("screencast-stopped", (sid) => log(`Preview screencast stopped: ${sid}`));
|
|
11428
11428
|
mkdirSync7(CONFIG_DIR4, { recursive: true });
|
|
11429
|
-
writeFileSync8(
|
|
11429
|
+
writeFileSync8(join9(CONFIG_DIR4, "daemon.json"), JSON.stringify({
|
|
11430
11430
|
port: daemonPort,
|
|
11431
11431
|
pid: process.pid,
|
|
11432
11432
|
startedAt: Date.now()
|
package/dist/index.js
CHANGED
|
@@ -236,8 +236,10 @@ function parsePluginParams(args, schema, base = {}) {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
// src/utils/stub-context.ts
|
|
239
|
+
import { join } from "path";
|
|
240
|
+
import { homedir } from "os";
|
|
239
241
|
import { TipCollector, CompositeStorage } from "@dyyz1993/xcli-core";
|
|
240
|
-
var CONFIG_DIR =
|
|
242
|
+
var CONFIG_DIR = join(homedir(), ".xbrowser");
|
|
241
243
|
var NoopSiteInstance = class {
|
|
242
244
|
name = "stub";
|
|
243
245
|
url = "";
|
|
@@ -1062,9 +1064,9 @@ var clearLocalStorageCommand = registerCommand({
|
|
|
1062
1064
|
import { z as z9 } from "zod";
|
|
1063
1065
|
import { ok as ok9 } from "@dyyz1993/xcli-core";
|
|
1064
1066
|
import { writeFileSync, mkdirSync } from "fs";
|
|
1065
|
-
import { join } from "path";
|
|
1066
|
-
import { homedir } from "os";
|
|
1067
|
-
var SCREENSHOTS_DIR =
|
|
1067
|
+
import { join as join2 } from "path";
|
|
1068
|
+
import { homedir as homedir2 } from "os";
|
|
1069
|
+
var SCREENSHOTS_DIR = join2(homedir2(), ".xbrowser", "screenshots");
|
|
1068
1070
|
function ensureScreenshotsDir() {
|
|
1069
1071
|
mkdirSync(SCREENSHOTS_DIR, { recursive: true });
|
|
1070
1072
|
}
|
|
@@ -1072,7 +1074,7 @@ function generateScreenshotPath(format) {
|
|
|
1072
1074
|
const timestamp = Date.now();
|
|
1073
1075
|
const random = Math.random().toString(36).slice(2, 8);
|
|
1074
1076
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
1075
|
-
return
|
|
1077
|
+
return join2(SCREENSHOTS_DIR, `screenshot-${timestamp}-${random}.${ext}`);
|
|
1076
1078
|
}
|
|
1077
1079
|
var screenshotCommand = registerCommand({
|
|
1078
1080
|
name: "screenshot",
|
|
@@ -1729,9 +1731,9 @@ var healthCheckCommand = registerCommand({
|
|
|
1729
1731
|
import { z as z14 } from "zod";
|
|
1730
1732
|
import { ok as ok14 } from "@dyyz1993/xcli-core";
|
|
1731
1733
|
import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
1732
|
-
import { join as
|
|
1733
|
-
import { homedir as
|
|
1734
|
-
var SCREENSHOTS_DIR2 =
|
|
1734
|
+
import { join as join3 } from "path";
|
|
1735
|
+
import { homedir as homedir3 } from "os";
|
|
1736
|
+
var SCREENSHOTS_DIR2 = join3(homedir3(), ".xbrowser", "screenshots");
|
|
1735
1737
|
function ensureScreenshotsDir2() {
|
|
1736
1738
|
mkdirSync2(SCREENSHOTS_DIR2, { recursive: true });
|
|
1737
1739
|
}
|
|
@@ -1739,7 +1741,7 @@ function generateScreenshotPath2(format) {
|
|
|
1739
1741
|
const timestamp = Date.now();
|
|
1740
1742
|
const random = Math.random().toString(36).slice(2, 8);
|
|
1741
1743
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
1742
|
-
return
|
|
1744
|
+
return join3(SCREENSHOTS_DIR2, `screenshot-${timestamp}-${random}.${ext}`);
|
|
1743
1745
|
}
|
|
1744
1746
|
var waitActionSchema = z14.object({
|
|
1745
1747
|
type: z14.literal("wait"),
|
|
@@ -4518,8 +4520,8 @@ async function resolveRefParams(page, params, selectorKeys, cache, sessionId) {
|
|
|
4518
4520
|
|
|
4519
4521
|
// src/utils/site-semantics.ts
|
|
4520
4522
|
import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, existsSync, readFileSync } from "fs";
|
|
4521
|
-
import { join as
|
|
4522
|
-
import { homedir as
|
|
4523
|
+
import { join as join4, dirname } from "path";
|
|
4524
|
+
import { homedir as homedir4 } from "os";
|
|
4523
4525
|
import { stringify, parse } from "yaml";
|
|
4524
4526
|
import { execFile } from "child_process";
|
|
4525
4527
|
var INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
@@ -4596,10 +4598,10 @@ function inferAction(role, label) {
|
|
|
4596
4598
|
return {};
|
|
4597
4599
|
}
|
|
4598
4600
|
function getSemanticsDir() {
|
|
4599
|
-
return
|
|
4601
|
+
return join4(homedir4(), ".xbrowser", "site-semantics");
|
|
4600
4602
|
}
|
|
4601
4603
|
function getSemanticsPath(domain) {
|
|
4602
|
-
return
|
|
4604
|
+
return join4(getSemanticsDir(), `${domain}.yaml`);
|
|
4603
4605
|
}
|
|
4604
4606
|
function extractDomain2(url) {
|
|
4605
4607
|
try {
|
|
@@ -6180,7 +6182,7 @@ import {
|
|
|
6180
6182
|
} from "@dyyz1993/xcli-core";
|
|
6181
6183
|
import { resolve as resolve2 } from "path";
|
|
6182
6184
|
import { existsSync as existsSync4, readdirSync } from "fs";
|
|
6183
|
-
import { homedir as
|
|
6185
|
+
import { homedir as homedir5 } from "os";
|
|
6184
6186
|
|
|
6185
6187
|
// src/plugin/metadata-parser.ts
|
|
6186
6188
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -6267,17 +6269,17 @@ var PluginMetadataParser = class {
|
|
|
6267
6269
|
|
|
6268
6270
|
// src/plugin/ensure-deps.ts
|
|
6269
6271
|
import { existsSync as existsSync3, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
|
|
6270
|
-
import { join as
|
|
6272
|
+
import { join as join5 } from "path";
|
|
6271
6273
|
import { execSync } from "child_process";
|
|
6272
6274
|
var SHARED_PLUGIN_DEPENDENCIES = {
|
|
6273
6275
|
"zod": "^3.24.0",
|
|
6274
6276
|
"@dyyz1993/xcli-core": "^0.12.1"
|
|
6275
6277
|
};
|
|
6276
6278
|
function ensurePluginDependencies(pluginsDir) {
|
|
6277
|
-
const zodPath =
|
|
6279
|
+
const zodPath = join5(pluginsDir, "node_modules", "zod");
|
|
6278
6280
|
if (existsSync3(zodPath)) return;
|
|
6279
6281
|
mkdirSync4(pluginsDir, { recursive: true });
|
|
6280
|
-
const pkgPath =
|
|
6282
|
+
const pkgPath = join5(pluginsDir, "package.json");
|
|
6281
6283
|
let pkg2 = {};
|
|
6282
6284
|
if (existsSync3(pkgPath)) {
|
|
6283
6285
|
try {
|
|
@@ -6293,7 +6295,7 @@ function ensurePluginDependencies(pluginsDir) {
|
|
|
6293
6295
|
needsInstall = true;
|
|
6294
6296
|
}
|
|
6295
6297
|
}
|
|
6296
|
-
if (!needsInstall && existsSync3(
|
|
6298
|
+
if (!needsInstall && existsSync3(join5(pluginsDir, "node_modules"))) return;
|
|
6297
6299
|
pkg2.dependencies = existingDeps;
|
|
6298
6300
|
pkg2.private = true;
|
|
6299
6301
|
pkg2.description = pkg2.description || "xbrowser plugins \u2014 shared dependencies";
|
|
@@ -6540,12 +6542,12 @@ var XBrowserPluginLoader = class {
|
|
|
6540
6542
|
}
|
|
6541
6543
|
async scanAndLoad() {
|
|
6542
6544
|
const cwd = this.options.cwd || process.cwd();
|
|
6543
|
-
const globalDir = this.options.globalDir || resolve2(
|
|
6545
|
+
const globalDir = this.options.globalDir || resolve2(homedir5(), ".xbrowser/plugins");
|
|
6544
6546
|
ensurePluginDependencies(globalDir);
|
|
6545
6547
|
const dirs = [
|
|
6546
6548
|
resolve2(cwd, ".xcli/plugins"),
|
|
6547
6549
|
resolve2(cwd, "../.xcli/plugins"),
|
|
6548
|
-
this.options.userDir || resolve2(
|
|
6550
|
+
this.options.userDir || resolve2(homedir5(), ".xcli/plugins"),
|
|
6549
6551
|
globalDir
|
|
6550
6552
|
];
|
|
6551
6553
|
const loaded = [];
|
|
@@ -7202,11 +7204,11 @@ async function loadHooks() {
|
|
|
7202
7204
|
}
|
|
7203
7205
|
|
|
7204
7206
|
// src/executor.ts
|
|
7205
|
-
import { homedir as
|
|
7206
|
-
import { join as
|
|
7207
|
+
import { homedir as homedir6 } from "os";
|
|
7208
|
+
import { join as join6 } from "path";
|
|
7207
7209
|
var NAVIGATION_COMMANDS = /* @__PURE__ */ new Set(["goto", "back", "forward", "refresh"]);
|
|
7208
7210
|
var snapshotHintShown = /* @__PURE__ */ new WeakSet();
|
|
7209
|
-
var CONFIG_DIR2 =
|
|
7211
|
+
var CONFIG_DIR2 = join6(homedir6(), ".xbrowser");
|
|
7210
7212
|
var storageCache = /* @__PURE__ */ new Map();
|
|
7211
7213
|
function getPluginStorage(pluginName) {
|
|
7212
7214
|
if (!storageCache.has(pluginName)) {
|
|
@@ -7218,7 +7220,7 @@ var archiveInitialized = false;
|
|
|
7218
7220
|
function ensureArchiveInit() {
|
|
7219
7221
|
if (!archiveInitialized) {
|
|
7220
7222
|
try {
|
|
7221
|
-
configureArchiveStore({ archiveDir:
|
|
7223
|
+
configureArchiveStore({ archiveDir: join6(homedir6(), ".xbrowser", "archives") });
|
|
7222
7224
|
} catch {
|
|
7223
7225
|
}
|
|
7224
7226
|
archiveInitialized = true;
|
|
@@ -7999,7 +8001,7 @@ import {
|
|
|
7999
8001
|
rmSync as rmSync6
|
|
8000
8002
|
} from "fs";
|
|
8001
8003
|
import { resolve as resolve8, basename as basename2 } from "path";
|
|
8002
|
-
import { homedir as
|
|
8004
|
+
import { homedir as homedir7 } from "os";
|
|
8003
8005
|
|
|
8004
8006
|
// src/plugin/install-sources/local.ts
|
|
8005
8007
|
import { existsSync as existsSync5, cpSync, rmSync } from "fs";
|
|
@@ -8041,7 +8043,7 @@ async function installFromLocal(source, name, targetDir) {
|
|
|
8041
8043
|
|
|
8042
8044
|
// src/plugin/install-sources/npm.ts
|
|
8043
8045
|
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync6, rmSync as rmSync2, cpSync as cpSync2 } from "fs";
|
|
8044
|
-
import { resolve as resolve4, join as
|
|
8046
|
+
import { resolve as resolve4, join as join7 } from "path";
|
|
8045
8047
|
import { tmpdir } from "os";
|
|
8046
8048
|
import {
|
|
8047
8049
|
downloadToFile,
|
|
@@ -8114,13 +8116,13 @@ async function installFromNpm(packageName, name, targetDir) {
|
|
|
8114
8116
|
throw new Error(`No tarball URL for ${packageName}@${latestVersion}`);
|
|
8115
8117
|
}
|
|
8116
8118
|
const tarballUrl = versionMeta.dist.tarball;
|
|
8117
|
-
const tmpDir =
|
|
8119
|
+
const tmpDir = join7(tmpdir(), `xbrowser-npm-${Date.now()}`);
|
|
8118
8120
|
mkdirSync5(tmpDir, { recursive: true });
|
|
8119
8121
|
let warnings = [];
|
|
8120
8122
|
try {
|
|
8121
|
-
const tarballPath =
|
|
8123
|
+
const tarballPath = join7(tmpDir, `${name}.tgz`);
|
|
8122
8124
|
await downloadToFile(tarballUrl, tarballPath);
|
|
8123
|
-
const extractDir =
|
|
8125
|
+
const extractDir = join7(tmpDir, "extracted");
|
|
8124
8126
|
extractTarGz(tarballPath, extractDir);
|
|
8125
8127
|
flattenPackageRoot(extractDir);
|
|
8126
8128
|
const verify = verifyPlugin2(extractDir, { metadataField: "xbrowser" });
|
|
@@ -8155,12 +8157,12 @@ async function installFromNpm(packageName, name, targetDir) {
|
|
|
8155
8157
|
|
|
8156
8158
|
// src/plugin/install-sources/git.ts
|
|
8157
8159
|
import { existsSync as existsSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync7, rmSync as rmSync3, cpSync as cpSync3 } from "fs";
|
|
8158
|
-
import { resolve as resolve5, join as
|
|
8160
|
+
import { resolve as resolve5, join as join8 } from "path";
|
|
8159
8161
|
import { tmpdir as tmpdir2 } from "os";
|
|
8160
8162
|
import { execSync as execSync2 } from "child_process";
|
|
8161
8163
|
import { verifyPlugin as verifyPlugin3, safeCleanup as safeCleanup3 } from "@dyyz1993/xcli-core";
|
|
8162
8164
|
async function installFromGit(gitUrl, name, targetDir) {
|
|
8163
|
-
const tmpDir =
|
|
8165
|
+
const tmpDir = join8(tmpdir2(), `xbrowser-git-${Date.now()}`);
|
|
8164
8166
|
let warnings = [];
|
|
8165
8167
|
try {
|
|
8166
8168
|
execSync2(`git clone --depth 1 "${gitUrl}" "${tmpDir}"`, { stdio: "pipe" });
|
|
@@ -8197,7 +8199,7 @@ async function installFromGit(gitUrl, name, targetDir) {
|
|
|
8197
8199
|
|
|
8198
8200
|
// src/plugin/install-sources/url.ts
|
|
8199
8201
|
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync8, rmSync as rmSync4, cpSync as cpSync4 } from "fs";
|
|
8200
|
-
import { resolve as resolve6, join as
|
|
8202
|
+
import { resolve as resolve6, join as join9, basename } from "path";
|
|
8201
8203
|
import { tmpdir as tmpdir3 } from "os";
|
|
8202
8204
|
import {
|
|
8203
8205
|
downloadToFile as downloadToFile2,
|
|
@@ -8207,14 +8209,14 @@ import {
|
|
|
8207
8209
|
safeCleanup as safeCleanup4
|
|
8208
8210
|
} from "@dyyz1993/xcli-core";
|
|
8209
8211
|
async function installFromUrl(url, name, targetDir) {
|
|
8210
|
-
const tmpDir =
|
|
8212
|
+
const tmpDir = join9(tmpdir3(), `xbrowser-url-${Date.now()}`);
|
|
8211
8213
|
mkdirSync6(tmpDir, { recursive: true });
|
|
8212
8214
|
let warnings = [];
|
|
8213
8215
|
try {
|
|
8214
8216
|
const fileName = basename(new URL(url).pathname) || "plugin.tar.gz";
|
|
8215
|
-
const tarballPath =
|
|
8217
|
+
const tarballPath = join9(tmpDir, fileName);
|
|
8216
8218
|
await downloadToFile2(url, tarballPath);
|
|
8217
|
-
const extractDir =
|
|
8219
|
+
const extractDir = join9(tmpDir, "extracted");
|
|
8218
8220
|
extractTarGz2(tarballPath, extractDir);
|
|
8219
8221
|
flattenPackageRoot2(extractDir);
|
|
8220
8222
|
const verify = verifyPlugin4(extractDir, { metadataField: "xbrowser" });
|
|
@@ -8256,7 +8258,7 @@ import {
|
|
|
8256
8258
|
rmSync as rmSync5,
|
|
8257
8259
|
cpSync as cpSync5
|
|
8258
8260
|
} from "fs";
|
|
8259
|
-
import { resolve as resolve7, join as
|
|
8261
|
+
import { resolve as resolve7, join as join10, dirname as dirname2 } from "path";
|
|
8260
8262
|
import { tmpdir as tmpdir4 } from "os";
|
|
8261
8263
|
import { gunzipSync } from "zlib";
|
|
8262
8264
|
import {
|
|
@@ -8285,7 +8287,7 @@ async function installFromMarketplace(pluginsDir, slug, options) {
|
|
|
8285
8287
|
throw new Error(`Plugin "${name}" already exists. Use --force to overwrite.`);
|
|
8286
8288
|
}
|
|
8287
8289
|
mkdirSync7(targetDir, { recursive: true });
|
|
8288
|
-
const tmpDir =
|
|
8290
|
+
const tmpDir = join10(tmpdir4(), `xbrowser-marketplace-${Date.now()}`);
|
|
8289
8291
|
mkdirSync7(tmpDir, { recursive: true });
|
|
8290
8292
|
const realSlug = String(plugin.slug || slug);
|
|
8291
8293
|
try {
|
|
@@ -8348,7 +8350,7 @@ async function downloadAndExtractMarketplaceTarball(baseUrl, slug, tmpDir, targe
|
|
|
8348
8350
|
}
|
|
8349
8351
|
if (tarballRes.status === 302 || tarballRes.headers.get("location")) {
|
|
8350
8352
|
const redirectUrl = tarballRes.headers.get("location");
|
|
8351
|
-
const tarballPath =
|
|
8353
|
+
const tarballPath = join10(tmpDir, `${slug}.tar.gz`);
|
|
8352
8354
|
await downloadToFile3(redirectUrl, tarballPath);
|
|
8353
8355
|
const buffer = readFileSync7(tarballPath);
|
|
8354
8356
|
const manifest = tryParseAsGzippedManifest(buffer);
|
|
@@ -8356,7 +8358,7 @@ async function downloadAndExtractMarketplaceTarball(baseUrl, slug, tmpDir, targe
|
|
|
8356
8358
|
extractManifestToDir(manifest, targetDir);
|
|
8357
8359
|
return;
|
|
8358
8360
|
}
|
|
8359
|
-
const extractDir =
|
|
8361
|
+
const extractDir = join10(tmpDir, "extracted");
|
|
8360
8362
|
extractTarGz3(tarballPath, extractDir);
|
|
8361
8363
|
flattenPackageRoot3(extractDir);
|
|
8362
8364
|
if (existsSync9(targetDir)) {
|
|
@@ -8370,10 +8372,10 @@ async function downloadAndExtractMarketplaceTarball(baseUrl, slug, tmpDir, targe
|
|
|
8370
8372
|
extractManifestToDir(manifest, targetDir);
|
|
8371
8373
|
return;
|
|
8372
8374
|
}
|
|
8373
|
-
const tarballPath =
|
|
8375
|
+
const tarballPath = join10(tmpDir, `${slug}.tar.gz`);
|
|
8374
8376
|
writeFileSync9(tarballPath, buffer);
|
|
8375
8377
|
try {
|
|
8376
|
-
const extractDir =
|
|
8378
|
+
const extractDir = join10(tmpDir, "extracted");
|
|
8377
8379
|
extractTarGz3(tarballPath, extractDir);
|
|
8378
8380
|
flattenPackageRoot3(extractDir);
|
|
8379
8381
|
if (existsSync9(targetDir)) {
|
|
@@ -8466,7 +8468,7 @@ function ensureIndexFile(plugin, name, targetDir) {
|
|
|
8466
8468
|
var PluginInstaller = class {
|
|
8467
8469
|
pluginsDir;
|
|
8468
8470
|
constructor(pluginsDir) {
|
|
8469
|
-
this.pluginsDir = pluginsDir || resolve8(
|
|
8471
|
+
this.pluginsDir = pluginsDir || resolve8(homedir7(), ".xbrowser/plugins");
|
|
8470
8472
|
}
|
|
8471
8473
|
getPluginsDir() {
|
|
8472
8474
|
return this.pluginsDir;
|
|
@@ -10103,15 +10105,15 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
|
|
|
10103
10105
|
}
|
|
10104
10106
|
|
|
10105
10107
|
// src/cli/session-routes.ts
|
|
10106
|
-
import { homedir as
|
|
10107
|
-
import { join as
|
|
10108
|
+
import { homedir as homedir8 } from "os";
|
|
10109
|
+
import { join as join12 } from "path";
|
|
10108
10110
|
import { readdirSync as readdirSync3, rmSync as rmSync7 } from "fs";
|
|
10109
10111
|
function cleanSessionFiles() {
|
|
10110
|
-
const dir =
|
|
10112
|
+
const dir = join12(homedir8(), ".xbrowser", "sessions");
|
|
10111
10113
|
let count = 0;
|
|
10112
10114
|
try {
|
|
10113
10115
|
for (const entry of readdirSync3(dir, { withFileTypes: true })) {
|
|
10114
|
-
const p =
|
|
10116
|
+
const p = join12(dir, entry.name);
|
|
10115
10117
|
rmSync7(p, { recursive: true, force: true });
|
|
10116
10118
|
count++;
|
|
10117
10119
|
}
|
|
@@ -10908,7 +10910,7 @@ async function handleGeneratePlugin(sessionName, pluginName, outputDir) {
|
|
|
10908
10910
|
const { SessionRecorder: SessionRecorder2 } = await import("./session-recorder-RTDGURIJ.js");
|
|
10909
10911
|
const { readSiteKnowledge: readSiteKnowledge2, toMarkdown } = await import("./site-knowledge-SYC6VCDB.js");
|
|
10910
10912
|
const { mkdirSync: mkdirSync11, writeFileSync: writeFileSync12 } = await import("fs");
|
|
10911
|
-
const { join:
|
|
10913
|
+
const { join: join14 } = await import("path");
|
|
10912
10914
|
const data = SessionRecorder2.readData(sessionName);
|
|
10913
10915
|
if (!data) {
|
|
10914
10916
|
outputError(`No recording found for session "${sessionName}". Run \`xbrowser record stop --session ${sessionName}\` first.`);
|
|
@@ -10920,14 +10922,14 @@ async function handleGeneratePlugin(sessionName, pluginName, outputDir) {
|
|
|
10920
10922
|
} catch {
|
|
10921
10923
|
}
|
|
10922
10924
|
const finalPluginName = pluginName || domain.split(".")[0] || "my-site";
|
|
10923
|
-
const finalOutputDir = outputDir ||
|
|
10925
|
+
const finalOutputDir = outputDir || join14(process.cwd(), ".xcli", "plugins", finalPluginName);
|
|
10924
10926
|
const knowledge = readSiteKnowledge2(domain);
|
|
10925
10927
|
const knowledgeMd = knowledge ? toMarkdown(knowledge) : "";
|
|
10926
10928
|
const pluginCode = generatePluginCode(finalPluginName, domain, data, knowledgeMd);
|
|
10927
|
-
mkdirSync11(
|
|
10928
|
-
writeFileSync12(
|
|
10929
|
+
mkdirSync11(join14(finalOutputDir), { recursive: true });
|
|
10930
|
+
writeFileSync12(join14(finalOutputDir, "index.ts"), pluginCode, "utf-8");
|
|
10929
10931
|
if (knowledgeMd) {
|
|
10930
|
-
writeFileSync12(
|
|
10932
|
+
writeFileSync12(join14(finalOutputDir, "SITE_KNOWLEDGE.md"), knowledgeMd, "utf-8");
|
|
10931
10933
|
}
|
|
10932
10934
|
console.log("");
|
|
10933
10935
|
console.log("=== Plugin Generated ===");
|
|
@@ -14191,12 +14193,12 @@ var FileListHandler = class {
|
|
|
14191
14193
|
const msg = ctx.message;
|
|
14192
14194
|
try {
|
|
14193
14195
|
const { readdirSync: readdirSync4, statSync } = await import("fs");
|
|
14194
|
-
const { join:
|
|
14196
|
+
const { join: join14, resolve: resolve10 } = await import("path");
|
|
14195
14197
|
const targetPath = resolve10(msg.path);
|
|
14196
14198
|
const entries = readdirSync4(targetPath);
|
|
14197
14199
|
const files = entries.map((name) => {
|
|
14198
14200
|
try {
|
|
14199
|
-
const stat = statSync(
|
|
14201
|
+
const stat = statSync(join14(targetPath, name));
|
|
14200
14202
|
return { name, isDir: stat.isDirectory(), size: stat.size, modified: stat.mtime.toISOString() };
|
|
14201
14203
|
} catch {
|
|
14202
14204
|
return { name, isDir: false, size: 0, modified: "" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbrowser/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Browser automation CLI for web scraping, headless browsing, SEO analysis, and AI agent workflows. A command-line alternative to Playwright, Puppeteer, and Selenium.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|