shoplazza-ai-dev-cli 0.1.21 → 0.1.22-snapshot.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/ThirdPartyNoticeText.txt +2 -48
- package/dist/_chunks/af.mjs +1653 -0
- package/dist/_chunks/commands.mjs +2265 -0
- package/dist/_chunks/executor.mjs +2554 -0
- package/dist/_chunks/heartbeat.mjs +910 -0
- package/dist/_chunks/libs/@clack/core.mjs +5 -10
- package/dist/_chunks/libs/@clack/prompts.mjs +6 -4
- package/dist/_chunks/libs/@kwsites/file-exists.mjs +2 -2
- package/dist/_chunks/libs/@kwsites/promise-deferred.mjs +2 -2
- package/dist/_chunks/libs/core-util-is.mjs +2 -2
- package/dist/_chunks/libs/immediate.mjs +2 -2
- package/dist/_chunks/libs/inherits.mjs +4 -2
- package/dist/_chunks/libs/isarray.mjs +2 -2
- package/dist/_chunks/libs/jszip.mjs +13 -9
- package/dist/_chunks/libs/simple-git.mjs +115 -92
- package/dist/_chunks/main.mjs +116 -0
- package/dist/_chunks/rolldown-runtime.mjs +2 -2
- package/dist/_chunks/run.mjs +289 -0
- package/dist/_chunks/session-forward.mjs +82 -0
- package/dist/_chunks/test.mjs +6 -9
- package/dist/cli.mjs +127 -62
- package/package.json +3 -1
- package/dist/THIRD-PARTY-LICENSES.md +0 -584
- package/dist/_chunks/libs/@simple-git/args-pathspec.mjs +0 -12
- package/dist/_chunks/libs/@simple-git/argv-parser.mjs +0 -465
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { __toESM } from "./_chunks/rolldown-runtime.mjs";
|
|
3
|
-
import { pD, require_picocolors } from "./_chunks/libs/@clack/core.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
2
|
+
import { r as __toESM } from "./_chunks/rolldown-runtime.mjs";
|
|
3
|
+
import { l as pD, u as require_picocolors } from "./_chunks/libs/@clack/core.mjs";
|
|
4
|
+
import { a as Y, c as ve, i as Se, l as xe, n as M, o as be, r as Me, s as fe, t as Ie, u as ye } from "./_chunks/libs/@clack/prompts.mjs";
|
|
5
|
+
import "./_chunks/libs/@kwsites/file-exists.mjs";
|
|
6
|
+
import "./_chunks/libs/@kwsites/promise-deferred.mjs";
|
|
7
|
+
import { t as esm_default } from "./_chunks/libs/simple-git.mjs";
|
|
8
|
+
import { t as require_lib } from "./_chunks/libs/jszip.mjs";
|
|
9
|
+
import "./_chunks/libs/isarray.mjs";
|
|
10
|
+
import "./_chunks/libs/core-util-is.mjs";
|
|
11
|
+
import "./_chunks/libs/inherits.mjs";
|
|
12
|
+
import "./_chunks/libs/immediate.mjs";
|
|
13
|
+
import { execFile, execFileSync, execSync, spawnSync } from "child_process";
|
|
8
14
|
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "fs";
|
|
9
|
-
import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "path";
|
|
15
|
+
import { basename, dirname, isAbsolute, join, normalize, relative, resolve as resolve$1, sep } from "path";
|
|
10
16
|
import { URL as URL$1, fileURLToPath } from "url";
|
|
11
17
|
import { stripVTControlCharacters } from "node:util";
|
|
12
18
|
import { homedir, hostname, platform, tmpdir } from "os";
|
|
@@ -14,7 +20,7 @@ import { access, chmod, cp, lstat, mkdir, mkdtemp, readFile, readdir, readlink,
|
|
|
14
20
|
import { createServer } from "http";
|
|
15
21
|
import { gunzipSync } from "node:zlib";
|
|
16
22
|
import { chmodSync as chmodSync$1, mkdirSync as mkdirSync$1, writeFileSync as writeFileSync$1 } from "node:fs";
|
|
17
|
-
import { dirname as dirname$1, normalize as normalize$1, resolve as resolve$
|
|
23
|
+
import { dirname as dirname$1, normalize as normalize$1, resolve as resolve$2, sep as sep$1 } from "node:path";
|
|
18
24
|
import { parse } from "yaml";
|
|
19
25
|
import * as readline from "readline";
|
|
20
26
|
import { Writable } from "stream";
|
|
@@ -166,7 +172,7 @@ function parseSource(input, bootstrap) {
|
|
|
166
172
|
};
|
|
167
173
|
}
|
|
168
174
|
if (isLocalPath(input)) {
|
|
169
|
-
const resolvedPath = resolve(input);
|
|
175
|
+
const resolvedPath = resolve$1(input);
|
|
170
176
|
return {
|
|
171
177
|
type: "local",
|
|
172
178
|
url: resolvedPath,
|
|
@@ -500,6 +506,9 @@ function configCommand(args) {
|
|
|
500
506
|
console.error("Available: get | set | unset | list | path");
|
|
501
507
|
process.exit(2);
|
|
502
508
|
}
|
|
509
|
+
function getConfigFile() {
|
|
510
|
+
return CONFIG_FILE;
|
|
511
|
+
}
|
|
503
512
|
const FORGE_CURSOR_EVENTS = ["beforeReadFile", "beforeSubmitPrompt"];
|
|
504
513
|
const CURSOR_HOOK_SCRIPT_BASENAME = "track-skill-cursor.mjs";
|
|
505
514
|
const LEGACY_CURSOR_HOOK_BASENAME = "track-skill-read.mjs";
|
|
@@ -642,7 +651,7 @@ process.stdin.on('end', () => {
|
|
|
642
651
|
}
|
|
643
652
|
function isForgeOwnedCommand(command) {
|
|
644
653
|
if (typeof command !== "string") return false;
|
|
645
|
-
return command.includes(
|
|
654
|
+
return command.includes(CURSOR_HOOK_SCRIPT_BASENAME) || command.includes(LEGACY_CURSOR_HOOK_BASENAME);
|
|
646
655
|
}
|
|
647
656
|
function isFlatEntry(e) {
|
|
648
657
|
return !!e && typeof e === "object" && typeof e.command === "string";
|
|
@@ -922,7 +931,7 @@ async function ensureForgeCliWrapper() {
|
|
|
922
931
|
async function ensureForgeHooks(agent) {
|
|
923
932
|
const warnings = [];
|
|
924
933
|
try {
|
|
925
|
-
const portal = loadConfig().portal ||
|
|
934
|
+
const portal = loadConfig().portal || DEFAULT_PORTAL;
|
|
926
935
|
const home = getAgentHome(agent);
|
|
927
936
|
if (agent === "claude-code") {
|
|
928
937
|
const scriptPath = join(home, HOOK_DIRNAME, HOOK_SCRIPT_BASENAME);
|
|
@@ -1034,6 +1043,31 @@ function shellEscape(p) {
|
|
|
1034
1043
|
if (!/[\s"'$`\\]/.test(p)) return p;
|
|
1035
1044
|
return `'${p.replace(/'/g, `'\\''`)}'`;
|
|
1036
1045
|
}
|
|
1046
|
+
var LoginFailedError = class extends Error {
|
|
1047
|
+
constructor(reason) {
|
|
1048
|
+
super(`login failed: ${reason}`);
|
|
1049
|
+
this.reason = reason;
|
|
1050
|
+
this.name = "LoginFailedError";
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
const DEFAULT_LOGIN_TIMEOUT_MS = 12e4;
|
|
1054
|
+
async function openBrowser(url, deps = {}) {
|
|
1055
|
+
const platform = deps.platform ?? process.platform;
|
|
1056
|
+
const print = deps.print ?? ((msg) => M.warn(msg));
|
|
1057
|
+
const run = deps.run ?? ((cmd, args) => new Promise((resolve, reject) => {
|
|
1058
|
+
execFile(cmd, args, (err) => err ? reject(err) : resolve());
|
|
1059
|
+
}));
|
|
1060
|
+
const cmd = platform === "darwin" ? "open" : platform === "linux" ? "xdg-open" : void 0;
|
|
1061
|
+
if (cmd === void 0) {
|
|
1062
|
+
print(`请在浏览器中打开:${url}`);
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
try {
|
|
1066
|
+
await run(cmd, [url]);
|
|
1067
|
+
} catch {
|
|
1068
|
+
print(`无法自动打开浏览器,请手动在浏览器中打开:${url}`);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1037
1071
|
function getRandomPort() {
|
|
1038
1072
|
return new Promise((resolve, reject) => {
|
|
1039
1073
|
const server = createServer();
|
|
@@ -1166,7 +1200,6 @@ function getErrorHtml(error) {
|
|
|
1166
1200
|
</svg>`
|
|
1167
1201
|
});
|
|
1168
1202
|
}
|
|
1169
|
-
let callbackResolve = null;
|
|
1170
1203
|
async function runLogin(options = {}) {
|
|
1171
1204
|
const cfg = loadConfig();
|
|
1172
1205
|
if (options.logout) {
|
|
@@ -1195,21 +1228,17 @@ async function runLogin(options = {}) {
|
|
|
1195
1228
|
}
|
|
1196
1229
|
console.log();
|
|
1197
1230
|
Ie(import_picocolors.default.bgCyan(import_picocolors.default.black(" login ")));
|
|
1198
|
-
const portalUrl = cfg.portal;
|
|
1231
|
+
const portalUrl = options.portal ?? cfg.portal;
|
|
1199
1232
|
const port = await getRandomPort();
|
|
1200
1233
|
const redirectUrl = `http://127.0.0.1:${port}/callback`;
|
|
1201
1234
|
const machine = hostname().slice(0, 64);
|
|
1202
1235
|
const authUrl = `${portalUrl}/cli-auth?redirect=${encodeURIComponent(redirectUrl)}&hostname=${encodeURIComponent(machine)}`;
|
|
1203
1236
|
M.message(`Opening browser for authentication...`);
|
|
1204
1237
|
M.info(import_picocolors.default.dim(authUrl));
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
if (err) reject(err);
|
|
1208
|
-
else resolve();
|
|
1209
|
-
});
|
|
1210
|
-
});
|
|
1238
|
+
const openUrl = options.openUrl ?? openBrowser;
|
|
1239
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_LOGIN_TIMEOUT_MS;
|
|
1211
1240
|
const result = await new Promise((resolve) => {
|
|
1212
|
-
|
|
1241
|
+
let timer;
|
|
1213
1242
|
const server = createServer((req, res) => {
|
|
1214
1243
|
const url = new URL$1(req.url || "", `http://127.0.0.1:${port}`);
|
|
1215
1244
|
if (url.pathname === "/callback") {
|
|
@@ -1219,14 +1248,14 @@ async function runLogin(options = {}) {
|
|
|
1219
1248
|
if (error) {
|
|
1220
1249
|
res.writeHead(400, { "Content-Type": "text/html" });
|
|
1221
1250
|
res.end(getErrorHtml(error));
|
|
1222
|
-
|
|
1251
|
+
finish({
|
|
1223
1252
|
success: false,
|
|
1224
1253
|
error
|
|
1225
1254
|
});
|
|
1226
1255
|
} else if (token) {
|
|
1227
1256
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
1228
1257
|
res.end(getSuccessHtml());
|
|
1229
|
-
|
|
1258
|
+
finish({
|
|
1230
1259
|
success: true,
|
|
1231
1260
|
token,
|
|
1232
1261
|
tokenName: tokenName || "default"
|
|
@@ -1234,7 +1263,7 @@ async function runLogin(options = {}) {
|
|
|
1234
1263
|
} else {
|
|
1235
1264
|
res.writeHead(400, { "Content-Type": "text/html" });
|
|
1236
1265
|
res.end(getErrorHtml("No token received"));
|
|
1237
|
-
|
|
1266
|
+
finish({
|
|
1238
1267
|
success: false,
|
|
1239
1268
|
error: "No token received"
|
|
1240
1269
|
});
|
|
@@ -1244,26 +1273,31 @@ async function runLogin(options = {}) {
|
|
|
1244
1273
|
res.end("Not found");
|
|
1245
1274
|
}
|
|
1246
1275
|
});
|
|
1247
|
-
|
|
1248
|
-
|
|
1276
|
+
const finish = (r) => {
|
|
1277
|
+
if (timer) clearTimeout(timer);
|
|
1249
1278
|
server.close();
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1279
|
+
server.closeAllConnections();
|
|
1280
|
+
resolve(r);
|
|
1281
|
+
};
|
|
1282
|
+
server.listen(port, "127.0.0.1", () => {
|
|
1283
|
+
openUrl(authUrl).catch((e) => {
|
|
1284
|
+
M.warn(`无法自动打开浏览器,请手动打开上面的链接:${String(e)}`);
|
|
1253
1285
|
});
|
|
1254
|
-
}
|
|
1286
|
+
});
|
|
1287
|
+
timer = setTimeout(() => finish({
|
|
1288
|
+
success: false,
|
|
1289
|
+
error: "Login timed out"
|
|
1290
|
+
}), timeoutMs);
|
|
1255
1291
|
});
|
|
1256
|
-
if (!result.success)
|
|
1257
|
-
|
|
1258
|
-
process.exit(1);
|
|
1259
|
-
}
|
|
1260
|
-
saveConfig({
|
|
1292
|
+
if (!result.success) throw new LoginFailedError(result.error ?? "unknown error");
|
|
1293
|
+
if (options.save !== false) saveConfig({
|
|
1261
1294
|
token: result.token,
|
|
1262
1295
|
token_name: result.tokenName
|
|
1263
1296
|
});
|
|
1264
1297
|
M.success("Login successful!");
|
|
1265
|
-
M.message(import_picocolors.default.dim(`Token saved as: ${result.tokenName}`));
|
|
1298
|
+
M.message(import_picocolors.default.dim(`Token ${options.save === false ? "obtained" : "saved"} as: ${result.tokenName}`));
|
|
1266
1299
|
Se(import_picocolors.default.green("You can now publish skills."));
|
|
1300
|
+
return result.token;
|
|
1267
1301
|
}
|
|
1268
1302
|
function isCancelled$1(value) {
|
|
1269
1303
|
return typeof value === "symbol";
|
|
@@ -1338,7 +1372,7 @@ async function fetchPluginArchive(ref, portalUrl, bearerToken) {
|
|
|
1338
1372
|
}
|
|
1339
1373
|
function extractTarGz(gz, dest) {
|
|
1340
1374
|
const tar = gunzipSync(gz);
|
|
1341
|
-
const destAbs = resolve$
|
|
1375
|
+
const destAbs = resolve$2(dest);
|
|
1342
1376
|
let offset = 0;
|
|
1343
1377
|
while (offset + 512 <= tar.length) {
|
|
1344
1378
|
const header = tar.subarray(offset, offset + 512);
|
|
@@ -1357,7 +1391,7 @@ function extractTarGz(gz, dest) {
|
|
|
1357
1391
|
continue;
|
|
1358
1392
|
}
|
|
1359
1393
|
if (fullName.startsWith("/") || fullName.split("/").includes("..")) throw new Error(`unsafe path in tar entry: ${fullName}`);
|
|
1360
|
-
const targetAbs = resolve$
|
|
1394
|
+
const targetAbs = resolve$2(destAbs, normalize$1(fullName));
|
|
1361
1395
|
if (!targetAbs.startsWith(destAbs + sep$1) && targetAbs !== destAbs) throw new Error(`unsafe path in tar entry: ${fullName}`);
|
|
1362
1396
|
if (typeFlag === "5" || fullName.endsWith("/")) mkdirSync$1(targetAbs, { recursive: true });
|
|
1363
1397
|
else if (typeFlag === "0" || typeFlag === "\0") {
|
|
@@ -1385,7 +1419,7 @@ async function assertEntryReplaceable(entryPath, ctx) {
|
|
|
1385
1419
|
}
|
|
1386
1420
|
if (st.isSymbolicLink()) {
|
|
1387
1421
|
const target = await readlink(entryPath);
|
|
1388
|
-
const absTarget = isAbsolute(target) ? target : resolve(dirname(entryPath), target);
|
|
1422
|
+
const absTarget = isAbsolute(target) ? target : resolve$1(dirname(entryPath), target);
|
|
1389
1423
|
if (!pathInside(ctx.storeRoot, absTarget)) return {
|
|
1390
1424
|
kind: "foreign-symlink",
|
|
1391
1425
|
realPath: absTarget
|
|
@@ -1415,11 +1449,11 @@ async function assertEntryReplaceable(entryPath, ctx) {
|
|
|
1415
1449
|
};
|
|
1416
1450
|
}
|
|
1417
1451
|
function pathInside(root, p) {
|
|
1418
|
-
const r = relative(resolve(root), resolve(p));
|
|
1452
|
+
const r = relative(resolve$1(root), resolve$1(p));
|
|
1419
1453
|
return r === "" || !r.startsWith("..") && !isAbsolute(r);
|
|
1420
1454
|
}
|
|
1421
1455
|
function pathsEqual(a, b) {
|
|
1422
|
-
return resolve(a) === resolve(b);
|
|
1456
|
+
return resolve$1(a) === resolve$1(b);
|
|
1423
1457
|
}
|
|
1424
1458
|
async function readForgeRef(p) {
|
|
1425
1459
|
for (const name of FORGE_SIDECARS) try {
|
|
@@ -1474,6 +1508,7 @@ async function promptForeignOverwrite(conflicts, opts = {}) {
|
|
|
1474
1508
|
}
|
|
1475
1509
|
const AGENTS_DIR$1 = ".agents";
|
|
1476
1510
|
const SKILLS_SUBDIR = "skills";
|
|
1511
|
+
const DEFAULT_PLUGIN_VERSION = "0.0.0";
|
|
1477
1512
|
function parseFrontmatter(raw) {
|
|
1478
1513
|
const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
1479
1514
|
if (!match) return {
|
|
@@ -1498,8 +1533,8 @@ function sanitizeMetadata(str) {
|
|
|
1498
1533
|
return stripTerminalEscapes(str).replace(/[\r\n]+/g, " ").trim();
|
|
1499
1534
|
}
|
|
1500
1535
|
function isContainedIn(targetPath, basePath) {
|
|
1501
|
-
const normalizedBase = normalize(resolve(basePath));
|
|
1502
|
-
const normalizedTarget = normalize(resolve(targetPath));
|
|
1536
|
+
const normalizedBase = normalize(resolve$1(basePath));
|
|
1537
|
+
const normalizedTarget = normalize(resolve$1(targetPath));
|
|
1503
1538
|
return normalizedTarget.startsWith(normalizedBase + sep) || normalizedTarget === normalizedBase;
|
|
1504
1539
|
}
|
|
1505
1540
|
function isValidRelativePath(path) {
|
|
@@ -1547,7 +1582,7 @@ async function getPluginGroupings(basePath) {
|
|
|
1547
1582
|
if (plugin.skills && plugin.skills.length > 0) for (const skillPath of plugin.skills) {
|
|
1548
1583
|
if (!isValidRelativePath(skillPath)) continue;
|
|
1549
1584
|
const skillDir = join(pluginBase, skillPath);
|
|
1550
|
-
if (isContainedIn(skillDir, basePath)) groupings.set(resolve(skillDir), plugin.name);
|
|
1585
|
+
if (isContainedIn(skillDir, basePath)) groupings.set(resolve$1(skillDir), plugin.name);
|
|
1551
1586
|
}
|
|
1552
1587
|
}
|
|
1553
1588
|
} catch {}
|
|
@@ -1557,7 +1592,7 @@ async function getPluginGroupings(basePath) {
|
|
|
1557
1592
|
if (manifest.name && manifest.skills && manifest.skills.length > 0) for (const skillPath of manifest.skills) {
|
|
1558
1593
|
if (!isValidRelativePath(skillPath)) continue;
|
|
1559
1594
|
const skillDir = join(basePath, skillPath);
|
|
1560
|
-
if (isContainedIn(skillDir, basePath)) groupings.set(resolve(skillDir), manifest.name);
|
|
1595
|
+
if (isContainedIn(skillDir, basePath)) groupings.set(resolve$1(skillDir), manifest.name);
|
|
1561
1596
|
}
|
|
1562
1597
|
} catch {}
|
|
1563
1598
|
return groupings;
|
|
@@ -1611,8 +1646,8 @@ async function findSkillDirs(dir, depth = 0, maxDepth = 5) {
|
|
|
1611
1646
|
}
|
|
1612
1647
|
}
|
|
1613
1648
|
function isSubpathSafe(basePath, subpath) {
|
|
1614
|
-
const normalizedBase = normalize(resolve(basePath));
|
|
1615
|
-
const normalizedTarget = normalize(resolve(join(basePath, subpath)));
|
|
1649
|
+
const normalizedBase = normalize(resolve$1(basePath));
|
|
1650
|
+
const normalizedTarget = normalize(resolve$1(join(basePath, subpath)));
|
|
1616
1651
|
return normalizedTarget.startsWith(normalizedBase + sep) || normalizedTarget === normalizedBase;
|
|
1617
1652
|
}
|
|
1618
1653
|
async function discoverSkills(basePath, subpath, options) {
|
|
@@ -1622,7 +1657,7 @@ async function discoverSkills(basePath, subpath, options) {
|
|
|
1622
1657
|
const searchPath = subpath ? join(basePath, subpath) : basePath;
|
|
1623
1658
|
const pluginGroupings = await getPluginGroupings(searchPath);
|
|
1624
1659
|
const enhanceSkill = (skill) => {
|
|
1625
|
-
const resolvedPath = resolve(skill.path);
|
|
1660
|
+
const resolvedPath = resolve$1(skill.path);
|
|
1626
1661
|
if (pluginGroupings.has(resolvedPath)) skill.pluginName = pluginGroupings.get(resolvedPath);
|
|
1627
1662
|
return skill;
|
|
1628
1663
|
};
|
|
@@ -1708,8 +1743,8 @@ function sanitizeName(name) {
|
|
|
1708
1743
|
return name.toLowerCase().replace(/[^a-z0-9._]+/g, "-").replace(/^[.\-]+|[.\-]+$/g, "").substring(0, 255) || "unnamed-skill";
|
|
1709
1744
|
}
|
|
1710
1745
|
function isPathSafe(basePath, targetPath) {
|
|
1711
|
-
const normalizedBase = normalize(resolve(basePath));
|
|
1712
|
-
const normalizedTarget = normalize(resolve(targetPath));
|
|
1746
|
+
const normalizedBase = normalize(resolve$1(basePath));
|
|
1747
|
+
const normalizedTarget = normalize(resolve$1(targetPath));
|
|
1713
1748
|
return normalizedTarget.startsWith(normalizedBase + sep) || normalizedTarget === normalizedBase;
|
|
1714
1749
|
}
|
|
1715
1750
|
function getCanonicalSkillsDir(global, cwd) {
|
|
@@ -1726,7 +1761,7 @@ function getAgentBaseDir(agentType, global, cwd) {
|
|
|
1726
1761
|
return join(baseDir, agent.skillsDir);
|
|
1727
1762
|
}
|
|
1728
1763
|
function resolveSymlinkTarget(linkPath, linkTarget) {
|
|
1729
|
-
return resolve(dirname(linkPath), linkTarget);
|
|
1764
|
+
return resolve$1(dirname(linkPath), linkTarget);
|
|
1730
1765
|
}
|
|
1731
1766
|
async function cleanAndCreateDirectory(path) {
|
|
1732
1767
|
try {
|
|
@@ -1738,7 +1773,7 @@ async function cleanAndCreateDirectory(path) {
|
|
|
1738
1773
|
await mkdir(path, { recursive: true });
|
|
1739
1774
|
}
|
|
1740
1775
|
async function cleanCanonicalDir(canonicalPath, storeRoot) {
|
|
1741
|
-
const rel = relative(resolve(storeRoot), resolve(canonicalPath));
|
|
1776
|
+
const rel = relative(resolve$1(storeRoot), resolve$1(canonicalPath));
|
|
1742
1777
|
if (rel.startsWith("..") || isAbsolute(rel)) throw new Error(`refusing to clean path outside forge store: ${canonicalPath}`);
|
|
1743
1778
|
try {
|
|
1744
1779
|
await rm(canonicalPath, {
|
|
@@ -1749,7 +1784,7 @@ async function cleanCanonicalDir(canonicalPath, storeRoot) {
|
|
|
1749
1784
|
await mkdir(canonicalPath, { recursive: true });
|
|
1750
1785
|
}
|
|
1751
1786
|
async function resolveParentSymlinks(path) {
|
|
1752
|
-
const resolved = resolve(path);
|
|
1787
|
+
const resolved = resolve$1(path);
|
|
1753
1788
|
const dir = dirname(resolved);
|
|
1754
1789
|
const base = basename(resolved);
|
|
1755
1790
|
try {
|
|
@@ -1760,8 +1795,8 @@ async function resolveParentSymlinks(path) {
|
|
|
1760
1795
|
}
|
|
1761
1796
|
async function createSymlink(target, linkPath) {
|
|
1762
1797
|
try {
|
|
1763
|
-
const resolvedTarget = resolve(target);
|
|
1764
|
-
const resolvedLinkPath = resolve(linkPath);
|
|
1798
|
+
const resolvedTarget = resolve$1(target);
|
|
1799
|
+
const resolvedLinkPath = resolve$1(linkPath);
|
|
1765
1800
|
const [realTarget, realLinkPath] = await Promise.all([realpath(resolvedTarget).catch(() => resolvedTarget), realpath(resolvedLinkPath).catch(() => resolvedLinkPath)]);
|
|
1766
1801
|
if (realTarget === realLinkPath) return true;
|
|
1767
1802
|
if (await resolveParentSymlinks(target) === await resolveParentSymlinks(linkPath)) return true;
|
|
@@ -2251,10 +2286,10 @@ async function upsertMarketplaceEntry(home, pluginName) {
|
|
|
2251
2286
|
}
|
|
2252
2287
|
async function registerClaudePlugin(params) {
|
|
2253
2288
|
if (params.scope === "project" && !params.cwd) throw new Error("registerClaudePlugin: 'cwd' is required when scope is 'project'");
|
|
2254
|
-
const cwd = params.cwd ? resolve(params.cwd) : void 0;
|
|
2289
|
+
const cwd = params.cwd ? resolve$1(params.cwd) : void 0;
|
|
2255
2290
|
const home = getAgentHome("claude-code");
|
|
2256
2291
|
await ensureMarketplace(home);
|
|
2257
|
-
const version = params.version ??
|
|
2292
|
+
const version = params.version ?? DEFAULT_PLUGIN_VERSION;
|
|
2258
2293
|
const installPath = join(pluginCacheBase(home, params.pluginName), version);
|
|
2259
2294
|
await rm(installPath, {
|
|
2260
2295
|
recursive: true,
|
|
@@ -2273,7 +2308,7 @@ async function registerClaudePlugin(params) {
|
|
|
2273
2308
|
name: full["name"],
|
|
2274
2309
|
description: full["description"]
|
|
2275
2310
|
};
|
|
2276
|
-
if (version !==
|
|
2311
|
+
if (version !== DEFAULT_PLUGIN_VERSION) minimal["version"] = version;
|
|
2277
2312
|
if (full["author"]) minimal["author"] = full["author"];
|
|
2278
2313
|
await writeFile(join(mPluginDir, "plugin.json"), JSON.stringify(minimal, null, 2) + "\n", "utf-8");
|
|
2279
2314
|
}
|
|
@@ -2335,7 +2370,7 @@ async function unregisterClaudePlugin(pluginName, opts) {
|
|
|
2335
2370
|
} catch {}
|
|
2336
2371
|
const projectDirs = /* @__PURE__ */ new Set();
|
|
2337
2372
|
if (projectPath) projectDirs.add(projectPath);
|
|
2338
|
-
if (opts?.cwd) projectDirs.add(resolve(opts.cwd));
|
|
2373
|
+
if (opts?.cwd) projectDirs.add(resolve$1(opts.cwd));
|
|
2339
2374
|
for (const dir of projectDirs) try {
|
|
2340
2375
|
const projSettingsPath = join(dir, ".claude", "settings.json");
|
|
2341
2376
|
const settings = await readJson(projSettingsPath, {});
|
|
@@ -2799,7 +2834,7 @@ async function readJsonOrNull(path) {
|
|
|
2799
2834
|
async function resolvePluginVersion(pluginCanonical, pluginName) {
|
|
2800
2835
|
for (const manifestPath of [join(pluginCanonical, "plugin.json"), join(pluginCanonical, ".claude-plugin", "plugin.json")]) try {
|
|
2801
2836
|
const manifest = JSON.parse(await readFile(manifestPath, "utf-8"));
|
|
2802
|
-
if (manifest.name && manifest.description) return manifest.version ||
|
|
2837
|
+
if (manifest.name && manifest.description) return manifest.version || DEFAULT_PLUGIN_VERSION;
|
|
2803
2838
|
} catch {}
|
|
2804
2839
|
throw new Error(`refusing to register ${pluginName}: no valid plugin.json (with name/description) in canonical store ${pluginCanonical} (partial/corrupt install?)`);
|
|
2805
2840
|
}
|
|
@@ -3193,8 +3228,8 @@ async function cloneRepo(url, ref) {
|
|
|
3193
3228
|
}
|
|
3194
3229
|
}
|
|
3195
3230
|
async function cleanupTempDir(dir) {
|
|
3196
|
-
const normalizedDir = normalize(resolve(dir));
|
|
3197
|
-
const normalizedTmpDir = normalize(resolve(tmpdir()));
|
|
3231
|
+
const normalizedDir = normalize(resolve$1(dir));
|
|
3232
|
+
const normalizedTmpDir = normalize(resolve$1(tmpdir()));
|
|
3198
3233
|
if (!normalizedDir.startsWith(normalizedTmpDir + sep) && normalizedDir !== normalizedTmpDir) throw new Error("Attempted to clean up directory outside of temp directory");
|
|
3199
3234
|
await rm(dir, {
|
|
3200
3235
|
recursive: true,
|
|
@@ -3828,6 +3863,7 @@ async function isSourcePrivate(source) {
|
|
|
3828
3863
|
if (!ownerRepo) return false;
|
|
3829
3864
|
return isRepoPrivate(ownerRepo.owner, ownerRepo.repo);
|
|
3830
3865
|
}
|
|
3866
|
+
function initTelemetry(version) {}
|
|
3831
3867
|
function riskLabel(risk) {
|
|
3832
3868
|
switch (risk) {
|
|
3833
3869
|
case "critical": return import_picocolors.default.red(import_picocolors.default.bold("Critical Risk"));
|
|
@@ -4328,6 +4364,7 @@ async function runTeamBatchAdd(teamScope, options) {
|
|
|
4328
4364
|
try {
|
|
4329
4365
|
await runAdd([item.ref], childOptions);
|
|
4330
4366
|
} catch (err) {
|
|
4367
|
+
if (err instanceof LoginFailedError) throw err;
|
|
4331
4368
|
failures++;
|
|
4332
4369
|
const msg = err instanceof Error ? err.message : String(err);
|
|
4333
4370
|
M.warn(`Failed to install ${item.name}: ${msg}`);
|
|
@@ -5209,6 +5246,7 @@ async function runAdd(args, options = {}) {
|
|
|
5209
5246
|
Se(import_picocolors.default.green("Done!") + import_picocolors.default.dim(" Review skills before use; they run with full agent permissions."));
|
|
5210
5247
|
await promptForFindSkills(options, targetAgents);
|
|
5211
5248
|
} catch (error) {
|
|
5249
|
+
if (error instanceof LoginFailedError) throw error;
|
|
5212
5250
|
if (error instanceof GitCloneError) {
|
|
5213
5251
|
M.error(import_picocolors.default.red("Failed to clone repository"));
|
|
5214
5252
|
for (const line of error.message.split("\n")) M.message(import_picocolors.default.dim(line));
|
|
@@ -5910,6 +5948,7 @@ async function runInstallFromLock(args) {
|
|
|
5910
5948
|
yes: true
|
|
5911
5949
|
});
|
|
5912
5950
|
} catch (error) {
|
|
5951
|
+
if (error instanceof LoginFailedError) throw error;
|
|
5913
5952
|
M.error(`Failed to install from ${import_picocolors.default.cyan(source)}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
5914
5953
|
}
|
|
5915
5954
|
if (nodeModuleSkills.length > 0) {
|
|
@@ -6823,6 +6862,7 @@ async function runPublish(paths, options = {}) {
|
|
|
6823
6862
|
if (result?.asset_ref) M.message(import_picocolors.default.dim(`Asset: ${result.asset_ref}`));
|
|
6824
6863
|
if (result?.mr_iid) M.message(import_picocolors.default.dim(`MR !${result.mr_iid}`));
|
|
6825
6864
|
} catch (err) {
|
|
6865
|
+
if (err instanceof LoginFailedError) throw err;
|
|
6826
6866
|
const message = err instanceof Error ? err.message : String(err);
|
|
6827
6867
|
M.error(`Failed to publish ${name}: ${message}`);
|
|
6828
6868
|
}
|
|
@@ -6871,6 +6911,7 @@ function getVersion() {
|
|
|
6871
6911
|
}
|
|
6872
6912
|
}
|
|
6873
6913
|
const VERSION = getVersion();
|
|
6914
|
+
initTelemetry(VERSION);
|
|
6874
6915
|
const RESET = "\x1B[0m";
|
|
6875
6916
|
const BOLD = "\x1B[1m";
|
|
6876
6917
|
const DIM = "\x1B[38;5;102m";
|
|
@@ -6942,6 +6983,10 @@ ${BOLD}Publishing:${RESET}
|
|
|
6942
6983
|
|
|
6943
6984
|
${BOLD}Testing:${RESET}
|
|
6944
6985
|
test <resource> <action> Testing platform commands (Scenario A & B)
|
|
6986
|
+
runner <bind|setup|start|stop|status|doctor|update|uninstall> Manage this computer's autoflow runner
|
|
6987
|
+
runner trial Local autoflow trial runner (scripts/autoflow-trial)
|
|
6988
|
+
af <submit|ask|task|browser> Session tools inside an autoflow agent session
|
|
6989
|
+
af schedule create Create an autoflow schedule from inside an agent session
|
|
6945
6990
|
|
|
6946
6991
|
${BOLD}Auth:${RESET}
|
|
6947
6992
|
login Authenticate with the forge portal (browser OAuth)
|
|
@@ -7314,6 +7359,21 @@ async function main() {
|
|
|
7314
7359
|
case "report-event":
|
|
7315
7360
|
await runReportEvent(restArgs);
|
|
7316
7361
|
break;
|
|
7362
|
+
case "runner": {
|
|
7363
|
+
if (restArgs[0] === "trial") {
|
|
7364
|
+
const { runTrial } = await import("./_chunks/run.mjs");
|
|
7365
|
+
await runTrial(restArgs.slice(1));
|
|
7366
|
+
break;
|
|
7367
|
+
}
|
|
7368
|
+
const { runRunnerCommand, defaultRunnerDeps } = await import("./_chunks/commands.mjs");
|
|
7369
|
+
process.exitCode = await runRunnerCommand(restArgs, defaultRunnerDeps(VERSION));
|
|
7370
|
+
break;
|
|
7371
|
+
}
|
|
7372
|
+
case "af": {
|
|
7373
|
+
const { runAf } = await import("./_chunks/af.mjs");
|
|
7374
|
+
process.exitCode = await runAf(restArgs);
|
|
7375
|
+
break;
|
|
7376
|
+
}
|
|
7317
7377
|
case "--help":
|
|
7318
7378
|
case "-h":
|
|
7319
7379
|
showHelp();
|
|
@@ -7328,6 +7388,11 @@ async function main() {
|
|
|
7328
7388
|
}
|
|
7329
7389
|
}
|
|
7330
7390
|
main().catch((err) => {
|
|
7391
|
+
if (err instanceof LoginFailedError) {
|
|
7392
|
+
console.error(`\n${BOLD}✗${RESET} 登录失败:${err.reason},请重新执行命令并在浏览器里完成登录`);
|
|
7393
|
+
process.exitCode = 1;
|
|
7394
|
+
return;
|
|
7395
|
+
}
|
|
7331
7396
|
const msg = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
7332
7397
|
console.error(`\n${BOLD}✗${RESET} ${msg}`);
|
|
7333
7398
|
process.exitCode = 1;
|
|
@@ -7339,4 +7404,4 @@ main().catch((err) => {
|
|
|
7339
7404
|
process.stdout.write("", done);
|
|
7340
7405
|
process.stderr.write("", done);
|
|
7341
7406
|
})).then(() => process.exit(process.exitCode ?? 0)));
|
|
7342
|
-
export { loadConfig, runLogin };
|
|
7407
|
+
export { loadConfig as i, runLogin as n, getConfigFile as r, LoginFailedError as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shoplazza-ai-dev-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22-snapshot.0",
|
|
4
4
|
"description": "Shoplazza AI Dev CLI: install, publish and manage AI agent skills/rules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"build": "tsx scripts/generate-licenses.ts && obuild",
|
|
17
17
|
"generate-licenses": "tsx scripts/generate-licenses.ts",
|
|
18
18
|
"dev": "tsx src/cli.ts",
|
|
19
|
+
"browser:serve": "tsx src/runner/browser/main.ts",
|
|
19
20
|
"exec:test": "tsx scripts/execute-tests.ts",
|
|
20
21
|
"prepublishOnly": "npm run build",
|
|
21
22
|
"format": "prettier --write \"src/**/*.ts\" \"scripts/**/*.ts\"",
|
|
@@ -64,6 +65,7 @@
|
|
|
64
65
|
},
|
|
65
66
|
"packageManager": "pnpm@10.17.1",
|
|
66
67
|
"dependencies": {
|
|
68
|
+
"playwright-core": "1.58.2",
|
|
67
69
|
"yaml": "^2.8.3"
|
|
68
70
|
}
|
|
69
71
|
}
|