poe-code 3.0.207 → 3.0.209
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/index.js +286 -42
- package/dist/index.js.map +4 -4
- package/dist/providers/poe-agent.js.map +2 -2
- package/dist/sdk/spawn.js +17 -9
- package/dist/sdk/spawn.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35457,6 +35457,212 @@ var init_check_auth = __esm({
|
|
|
35457
35457
|
}
|
|
35458
35458
|
});
|
|
35459
35459
|
|
|
35460
|
+
// packages/poe-oauth/src/authorization-state.ts
|
|
35461
|
+
import crypto5 from "node:crypto";
|
|
35462
|
+
function parseAuthorizationState2(value) {
|
|
35463
|
+
if (value === null || value.length === 0) {
|
|
35464
|
+
return null;
|
|
35465
|
+
}
|
|
35466
|
+
try {
|
|
35467
|
+
const decoded = Buffer.from(value, "base64url").toString("utf8");
|
|
35468
|
+
const parsed = JSON.parse(decoded);
|
|
35469
|
+
if (parsed.v !== 1 || typeof parsed.n !== "string" || parsed.n.length === 0 || typeof parsed.i !== "string" || parsed.i.length === 0 || typeof parsed.r !== "boolean") {
|
|
35470
|
+
return null;
|
|
35471
|
+
}
|
|
35472
|
+
return {
|
|
35473
|
+
issuer: parsed.i,
|
|
35474
|
+
requireIssuer: parsed.r
|
|
35475
|
+
};
|
|
35476
|
+
} catch {
|
|
35477
|
+
return null;
|
|
35478
|
+
}
|
|
35479
|
+
}
|
|
35480
|
+
var init_authorization_state2 = __esm({
|
|
35481
|
+
"packages/poe-oauth/src/authorization-state.ts"() {
|
|
35482
|
+
"use strict";
|
|
35483
|
+
}
|
|
35484
|
+
});
|
|
35485
|
+
|
|
35486
|
+
// packages/poe-oauth/src/loopback-authorization.ts
|
|
35487
|
+
import http2 from "node:http";
|
|
35488
|
+
async function createLoopbackAuthorizationSession2(options = {}) {
|
|
35489
|
+
const callbackPath = options.callbackPath ?? "/callback";
|
|
35490
|
+
const server = options.createServer ? options.createServer() : http2.createServer();
|
|
35491
|
+
const port = await startServer2(server);
|
|
35492
|
+
const redirectUri = `http://127.0.0.1:${port}${callbackPath}`;
|
|
35493
|
+
return {
|
|
35494
|
+
redirectUri,
|
|
35495
|
+
async waitForCode(authorizationUrl) {
|
|
35496
|
+
return waitForAuthorizationCode2(server, authorizationUrl, options, callbackPath);
|
|
35497
|
+
},
|
|
35498
|
+
close() {
|
|
35499
|
+
server.closeAllConnections?.();
|
|
35500
|
+
server.close();
|
|
35501
|
+
}
|
|
35502
|
+
};
|
|
35503
|
+
}
|
|
35504
|
+
async function startServer2(server) {
|
|
35505
|
+
return new Promise((resolve2) => {
|
|
35506
|
+
server.listen(0, "127.0.0.1", () => {
|
|
35507
|
+
const address = server.address();
|
|
35508
|
+
resolve2(address.port);
|
|
35509
|
+
});
|
|
35510
|
+
});
|
|
35511
|
+
}
|
|
35512
|
+
function waitForAuthorizationCode2(server, authorizationUrl, options, callbackPath) {
|
|
35513
|
+
const expectedAuthorization = readExpectedAuthorizationCallback2(authorizationUrl);
|
|
35514
|
+
return new Promise((resolve2, reject) => {
|
|
35515
|
+
let settled = false;
|
|
35516
|
+
const settle = (fn) => {
|
|
35517
|
+
if (!settled) {
|
|
35518
|
+
settled = true;
|
|
35519
|
+
fn();
|
|
35520
|
+
}
|
|
35521
|
+
};
|
|
35522
|
+
server.on("request", (req, res) => {
|
|
35523
|
+
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
35524
|
+
if (url.pathname !== callbackPath) {
|
|
35525
|
+
res.writeHead(404);
|
|
35526
|
+
res.end("Not found");
|
|
35527
|
+
return;
|
|
35528
|
+
}
|
|
35529
|
+
const error2 = url.searchParams.get("error");
|
|
35530
|
+
if (error2 !== null) {
|
|
35531
|
+
const description = url.searchParams.get("error_description") ?? error2;
|
|
35532
|
+
res.writeHead(400);
|
|
35533
|
+
res.end(`Authorization failed: ${description}`);
|
|
35534
|
+
settle(() => reject(new Error(`OAuth authorization failed: ${error2} \u2014 ${description}`)));
|
|
35535
|
+
return;
|
|
35536
|
+
}
|
|
35537
|
+
try {
|
|
35538
|
+
const code = validateAuthorizationCallbackParameters2({
|
|
35539
|
+
code: url.searchParams.get("code"),
|
|
35540
|
+
state: url.searchParams.get("state"),
|
|
35541
|
+
iss: url.searchParams.get("iss")
|
|
35542
|
+
}, expectedAuthorization);
|
|
35543
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
35544
|
+
res.end(buildSuccessPage2(options.landingPage));
|
|
35545
|
+
settle(() => resolve2(code));
|
|
35546
|
+
} catch (error3) {
|
|
35547
|
+
res.writeHead(400);
|
|
35548
|
+
res.end(error3 instanceof Error ? error3.message : "Invalid OAuth callback");
|
|
35549
|
+
settle(() => reject(error3 instanceof Error ? error3 : new Error(String(error3))));
|
|
35550
|
+
}
|
|
35551
|
+
});
|
|
35552
|
+
if (options.readLine !== void 0) {
|
|
35553
|
+
options.readLine().then((input) => {
|
|
35554
|
+
const callbackParameters = extractCallbackParametersFromInput2(input);
|
|
35555
|
+
if (callbackParameters === null) {
|
|
35556
|
+
settle(() => reject(new Error("OAuth callback missing authorization code")));
|
|
35557
|
+
return;
|
|
35558
|
+
}
|
|
35559
|
+
try {
|
|
35560
|
+
const code = validateAuthorizationCallbackParameters2(
|
|
35561
|
+
callbackParameters,
|
|
35562
|
+
expectedAuthorization
|
|
35563
|
+
);
|
|
35564
|
+
settle(() => resolve2(code));
|
|
35565
|
+
} catch (error2) {
|
|
35566
|
+
settle(() => reject(error2 instanceof Error ? error2 : new Error(String(error2))));
|
|
35567
|
+
}
|
|
35568
|
+
}).catch(() => void 0);
|
|
35569
|
+
}
|
|
35570
|
+
if (options.openBrowser !== void 0) {
|
|
35571
|
+
options.openBrowser(authorizationUrl).catch((error2) => {
|
|
35572
|
+
settle(() => reject(error2));
|
|
35573
|
+
});
|
|
35574
|
+
}
|
|
35575
|
+
});
|
|
35576
|
+
}
|
|
35577
|
+
function extractCallbackParametersFromInput2(input) {
|
|
35578
|
+
const trimmed = input.replaceAll("\r", "").replaceAll("\n", "").trim();
|
|
35579
|
+
if (trimmed.length === 0) {
|
|
35580
|
+
return null;
|
|
35581
|
+
}
|
|
35582
|
+
try {
|
|
35583
|
+
const url = new URL(trimmed);
|
|
35584
|
+
return {
|
|
35585
|
+
code: url.searchParams.get("code"),
|
|
35586
|
+
state: url.searchParams.get("state"),
|
|
35587
|
+
iss: url.searchParams.get("iss")
|
|
35588
|
+
};
|
|
35589
|
+
} catch {
|
|
35590
|
+
return {
|
|
35591
|
+
code: trimmed,
|
|
35592
|
+
state: null,
|
|
35593
|
+
iss: null
|
|
35594
|
+
};
|
|
35595
|
+
}
|
|
35596
|
+
}
|
|
35597
|
+
function readExpectedAuthorizationCallback2(authorizationUrl) {
|
|
35598
|
+
const url = new URL(authorizationUrl);
|
|
35599
|
+
const state = url.searchParams.get("state");
|
|
35600
|
+
const parsedState = parseAuthorizationState2(state);
|
|
35601
|
+
return {
|
|
35602
|
+
state,
|
|
35603
|
+
issuer: parsedState?.issuer ?? null,
|
|
35604
|
+
requireIssuer: parsedState?.requireIssuer ?? false
|
|
35605
|
+
};
|
|
35606
|
+
}
|
|
35607
|
+
function validateAuthorizationCallbackParameters2(callback, expected) {
|
|
35608
|
+
if (callback.code === null || callback.code.length === 0) {
|
|
35609
|
+
throw new Error("OAuth callback missing authorization code");
|
|
35610
|
+
}
|
|
35611
|
+
if (expected.state !== null) {
|
|
35612
|
+
if (callback.state === null || callback.state.length === 0) {
|
|
35613
|
+
throw new Error("OAuth callback missing state");
|
|
35614
|
+
}
|
|
35615
|
+
if (callback.state !== expected.state) {
|
|
35616
|
+
throw new Error("OAuth callback state mismatch");
|
|
35617
|
+
}
|
|
35618
|
+
}
|
|
35619
|
+
if (expected.requireIssuer) {
|
|
35620
|
+
if (callback.iss === null || callback.iss.length === 0) {
|
|
35621
|
+
throw new Error("OAuth callback missing issuer");
|
|
35622
|
+
}
|
|
35623
|
+
}
|
|
35624
|
+
if (callback.iss !== null && callback.iss.length > 0 && expected.issuer !== null && callback.iss !== expected.issuer) {
|
|
35625
|
+
throw new Error("OAuth callback issuer mismatch");
|
|
35626
|
+
}
|
|
35627
|
+
return callback.code;
|
|
35628
|
+
}
|
|
35629
|
+
function escapeHtml2(text5) {
|
|
35630
|
+
return text5.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
35631
|
+
}
|
|
35632
|
+
function buildSuccessPage2(landingPage) {
|
|
35633
|
+
const title = landingPage?.title ?? "Connected";
|
|
35634
|
+
const body = landingPage?.body ?? "You can close this tab and return to your terminal.";
|
|
35635
|
+
return [
|
|
35636
|
+
"<!DOCTYPE html>",
|
|
35637
|
+
`<html><head><meta charset=utf-8><title>${escapeHtml2(title)}</title></head>`,
|
|
35638
|
+
'<body style="font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0">',
|
|
35639
|
+
'<div style="text-align:center">',
|
|
35640
|
+
`<h1>${escapeHtml2(title)}</h1>`,
|
|
35641
|
+
`<p style="color:#666">${escapeHtml2(body)}</p>`,
|
|
35642
|
+
"</div></body></html>"
|
|
35643
|
+
].join("");
|
|
35644
|
+
}
|
|
35645
|
+
var init_loopback_authorization2 = __esm({
|
|
35646
|
+
"packages/poe-oauth/src/loopback-authorization.ts"() {
|
|
35647
|
+
"use strict";
|
|
35648
|
+
init_authorization_state2();
|
|
35649
|
+
}
|
|
35650
|
+
});
|
|
35651
|
+
|
|
35652
|
+
// packages/poe-oauth/src/pkce.ts
|
|
35653
|
+
import crypto6 from "node:crypto";
|
|
35654
|
+
function generateCodeVerifier2() {
|
|
35655
|
+
return crypto6.randomBytes(32).toString("base64url");
|
|
35656
|
+
}
|
|
35657
|
+
function generateCodeChallenge2(verifier) {
|
|
35658
|
+
return crypto6.createHash("sha256").update(verifier).digest("base64url");
|
|
35659
|
+
}
|
|
35660
|
+
var init_pkce2 = __esm({
|
|
35661
|
+
"packages/poe-oauth/src/pkce.ts"() {
|
|
35662
|
+
"use strict";
|
|
35663
|
+
}
|
|
35664
|
+
});
|
|
35665
|
+
|
|
35460
35666
|
// packages/poe-oauth/src/oauth-client.ts
|
|
35461
35667
|
function createOAuthClient(config) {
|
|
35462
35668
|
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
@@ -35464,15 +35670,15 @@ function createOAuthClient(config) {
|
|
|
35464
35670
|
authorize: () => startAuthorization(config, fetchFn)
|
|
35465
35671
|
};
|
|
35466
35672
|
}
|
|
35467
|
-
function
|
|
35468
|
-
return
|
|
35673
|
+
function generateCodeVerifier3() {
|
|
35674
|
+
return generateCodeVerifier2();
|
|
35469
35675
|
}
|
|
35470
35676
|
async function startAuthorization(config, fetchFn) {
|
|
35471
35677
|
const authorizationEndpoint = config.authorizationEndpoint ?? DEFAULT_AUTHORIZATION_ENDPOINT;
|
|
35472
35678
|
const tokenEndpoint = config.tokenEndpoint ?? DEFAULT_TOKEN_ENDPOINT;
|
|
35473
|
-
const codeVerifier =
|
|
35474
|
-
const codeChallenge =
|
|
35475
|
-
const loopbackSession = await
|
|
35679
|
+
const codeVerifier = generateCodeVerifier3();
|
|
35680
|
+
const codeChallenge = generateCodeChallenge2(codeVerifier);
|
|
35681
|
+
const loopbackSession = await createLoopbackAuthorizationSession2({
|
|
35476
35682
|
openBrowser: config.openBrowser,
|
|
35477
35683
|
readLine: config.readLine,
|
|
35478
35684
|
createServer: config.createServer,
|
|
@@ -35559,7 +35765,8 @@ var DEFAULT_AUTHORIZATION_ENDPOINT, DEFAULT_TOKEN_ENDPOINT;
|
|
|
35559
35765
|
var init_oauth_client = __esm({
|
|
35560
35766
|
"packages/poe-oauth/src/oauth-client.ts"() {
|
|
35561
35767
|
"use strict";
|
|
35562
|
-
|
|
35768
|
+
init_loopback_authorization2();
|
|
35769
|
+
init_pkce2();
|
|
35563
35770
|
DEFAULT_AUTHORIZATION_ENDPOINT = "https://poe.com/oauth/authorize";
|
|
35564
35771
|
DEFAULT_TOKEN_ENDPOINT = "https://api.poe.com/token";
|
|
35565
35772
|
}
|
|
@@ -36894,6 +37101,7 @@ function spawn8(service, promptOrOptions, maybeOptions) {
|
|
|
36894
37101
|
})();
|
|
36895
37102
|
const result = (async () => {
|
|
36896
37103
|
let workspace;
|
|
37104
|
+
let integrations = null;
|
|
36897
37105
|
try {
|
|
36898
37106
|
workspace = await resolveSpawnWorkspace(options.cwd, {
|
|
36899
37107
|
baseDir: process.cwd(),
|
|
@@ -36911,12 +37119,16 @@ function spawn8(service, promptOrOptions, maybeOptions) {
|
|
|
36911
37119
|
if (!process.env.POE_API_KEY || process.env.POE_API_KEY.trim().length === 0) {
|
|
36912
37120
|
process.env.POE_API_KEY = resolvedApiKey;
|
|
36913
37121
|
}
|
|
36914
|
-
|
|
36915
|
-
|
|
36916
|
-
|
|
36917
|
-
|
|
36918
|
-
|
|
36919
|
-
|
|
37122
|
+
const container = createSdkContainer({ cwd });
|
|
37123
|
+
integrations = await loadIntegrations(await resolveMergedDocument(container));
|
|
37124
|
+
const middlewares = [
|
|
37125
|
+
sessionCapture,
|
|
37126
|
+
usageCapture,
|
|
37127
|
+
spawnLog,
|
|
37128
|
+
...integrations?.spawnMiddleware ? [integrations.spawnMiddleware] : [],
|
|
37129
|
+
...options.middlewares ?? []
|
|
37130
|
+
];
|
|
37131
|
+
const resolveModel3 = async () => options.model ?? await resolveConfiguredModel(container, service);
|
|
36920
37132
|
const runtimeOverrides = pickRuntimeOverrides(options);
|
|
36921
37133
|
const hasRuntimeOverrides = Object.keys(runtimeOverrides).length > 0;
|
|
36922
37134
|
if (options.interactive) {
|
|
@@ -36970,10 +37182,7 @@ function spawn8(service, promptOrOptions, maybeOptions) {
|
|
|
36970
37182
|
cwd: options.cwd,
|
|
36971
37183
|
startedAt: /* @__PURE__ */ new Date()
|
|
36972
37184
|
};
|
|
36973
|
-
await applyMiddlewares(
|
|
36974
|
-
[sessionCapture, usageCapture, spawnLog, ...options.middlewares ?? []],
|
|
36975
|
-
middlewareContext
|
|
36976
|
-
);
|
|
37185
|
+
await applyMiddlewares(middlewares, middlewareContext);
|
|
36977
37186
|
resolveEventsOnce(middlewareContext.eventStream ?? emptyEvents);
|
|
36978
37187
|
const final = await done;
|
|
36979
37188
|
const threadId = middlewareContext.threadId ?? final.threadId;
|
|
@@ -37023,10 +37232,7 @@ function spawn8(service, promptOrOptions, maybeOptions) {
|
|
|
37023
37232
|
cwd,
|
|
37024
37233
|
startedAt: /* @__PURE__ */ new Date()
|
|
37025
37234
|
};
|
|
37026
|
-
await applyMiddlewares(
|
|
37027
|
-
[sessionCapture, usageCapture, spawnLog, ...options.middlewares ?? []],
|
|
37028
|
-
middlewareContext
|
|
37029
|
-
);
|
|
37235
|
+
await applyMiddlewares(middlewares, middlewareContext);
|
|
37030
37236
|
resolveEventsOnce(middlewareContext.eventStream ?? emptyEvents);
|
|
37031
37237
|
const final = await done;
|
|
37032
37238
|
const threadId = middlewareContext.threadId ?? final.threadId;
|
|
@@ -37063,7 +37269,7 @@ function spawn8(service, promptOrOptions, maybeOptions) {
|
|
|
37063
37269
|
}
|
|
37064
37270
|
resolveEventsOnce(emptyEvents);
|
|
37065
37271
|
const model = await resolveModel3();
|
|
37066
|
-
return spawnCore(
|
|
37272
|
+
return spawnCore(container, service, {
|
|
37067
37273
|
prompt: options.prompt,
|
|
37068
37274
|
cwd,
|
|
37069
37275
|
model,
|
|
@@ -37077,6 +37283,7 @@ function spawn8(service, promptOrOptions, maybeOptions) {
|
|
|
37077
37283
|
resolveEventsOnce(emptyEvents);
|
|
37078
37284
|
throw error2;
|
|
37079
37285
|
} finally {
|
|
37286
|
+
await integrations?.shutdown();
|
|
37080
37287
|
await workspace?.cleanup?.();
|
|
37081
37288
|
}
|
|
37082
37289
|
})();
|
|
@@ -37112,6 +37319,8 @@ var init_spawn4 = __esm({
|
|
|
37112
37319
|
await init_container();
|
|
37113
37320
|
init_autonomous2();
|
|
37114
37321
|
init_src12();
|
|
37322
|
+
init_src18();
|
|
37323
|
+
init_shared();
|
|
37115
37324
|
init_resolve_spawn_workspace();
|
|
37116
37325
|
spawn8.pretty = async function pretty(service, promptOrOptions, maybeOptions) {
|
|
37117
37326
|
const { events, result } = spawn8(service, promptOrOptions, maybeOptions);
|
|
@@ -51836,6 +52045,7 @@ function collectFields(schema2, casing, globalLongOptionFlags, path108 = [], inh
|
|
|
51836
52045
|
hasDefault: childSchema.default !== void 0,
|
|
51837
52046
|
defaultValue: childSchema.default,
|
|
51838
52047
|
requiredWhenActive,
|
|
52048
|
+
global: childSchema.global === true ? true : void 0,
|
|
51839
52049
|
variantId: variantContext?.id,
|
|
51840
52050
|
variantBranchId: variantContext?.branchId
|
|
51841
52051
|
});
|
|
@@ -52387,7 +52597,7 @@ function formatCommandDynamicParameterTokens(field, casing) {
|
|
|
52387
52597
|
function formatCommandParameterTokens(command, casing, globalLongOptionFlags) {
|
|
52388
52598
|
const collected = collectFields(command.params, casing, globalLongOptionFlags);
|
|
52389
52599
|
const fields = assignPositionals(collected.fields, command.positional);
|
|
52390
|
-
return fields.map(
|
|
52600
|
+
return fields.filter((field) => field.global !== true).map(
|
|
52391
52601
|
(field) => wrapOptionalCommandParameterToken(
|
|
52392
52602
|
formatHelpFieldFlags(field, globalLongOptionFlags),
|
|
52393
52603
|
field.positionalIndex === void 0 && (field.optional || field.hasDefault)
|
|
@@ -52424,6 +52634,10 @@ function formatGlobalOptionRows(ctx) {
|
|
|
52424
52634
|
{
|
|
52425
52635
|
flags: "--output <format>",
|
|
52426
52636
|
description: "Output format: rich, md, json."
|
|
52637
|
+
},
|
|
52638
|
+
{
|
|
52639
|
+
flags: "--debug",
|
|
52640
|
+
description: "Print stack traces for unexpected errors."
|
|
52427
52641
|
}
|
|
52428
52642
|
);
|
|
52429
52643
|
if (ctx.showVersion) {
|
|
@@ -52434,6 +52648,33 @@ function formatGlobalOptionRows(ctx) {
|
|
|
52434
52648
|
}
|
|
52435
52649
|
return rows;
|
|
52436
52650
|
}
|
|
52651
|
+
function collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlags) {
|
|
52652
|
+
const seen = /* @__PURE__ */ new Map();
|
|
52653
|
+
const visit = (node) => {
|
|
52654
|
+
if (node.kind === "command") {
|
|
52655
|
+
const collected = collectFields(node.params, casing, globalLongOptionFlags);
|
|
52656
|
+
for (const field of collected.fields) {
|
|
52657
|
+
if (field.global !== true) {
|
|
52658
|
+
continue;
|
|
52659
|
+
}
|
|
52660
|
+
const dedupeKey = `${field.optionFlag}|${field.shortFlag ?? ""}`;
|
|
52661
|
+
if (seen.has(dedupeKey)) {
|
|
52662
|
+
continue;
|
|
52663
|
+
}
|
|
52664
|
+
seen.set(dedupeKey, {
|
|
52665
|
+
flags: formatHelpFieldFlags(field, globalLongOptionFlags),
|
|
52666
|
+
description: formatHelpFieldDescription(field)
|
|
52667
|
+
});
|
|
52668
|
+
}
|
|
52669
|
+
return;
|
|
52670
|
+
}
|
|
52671
|
+
for (const child of getVisibleChildren(node, scope)) {
|
|
52672
|
+
visit(child);
|
|
52673
|
+
}
|
|
52674
|
+
};
|
|
52675
|
+
visit(group);
|
|
52676
|
+
return [...seen.values()];
|
|
52677
|
+
}
|
|
52437
52678
|
function renderHelpSections(sections) {
|
|
52438
52679
|
return sections.filter((section) => section.length > 0).join("\n\n");
|
|
52439
52680
|
}
|
|
@@ -52450,7 +52691,7 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
|
|
|
52450
52691
|
const tokens = [rootUsageName, subPath, suffix].filter((segment) => segment.length > 0);
|
|
52451
52692
|
return tokens.join(" ");
|
|
52452
52693
|
}
|
|
52453
|
-
function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUsageName) {
|
|
52694
|
+
function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUsageName, isRoot) {
|
|
52454
52695
|
const sections = [];
|
|
52455
52696
|
const globalLongOptionFlags = getGlobalLongOptionFlags(globalOptions.presetsEnabled);
|
|
52456
52697
|
const commandRows = formatCommandRows(group, scope, casing, globalLongOptionFlags);
|
|
@@ -52458,14 +52699,20 @@ function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUs
|
|
|
52458
52699
|
sections.push(`${text.sectionHeader("Commands")}
|
|
52459
52700
|
${formatHelpCommandList(commandRows)}`);
|
|
52460
52701
|
}
|
|
52461
|
-
|
|
52462
|
-
|
|
52463
|
-
|
|
52464
|
-
|
|
52702
|
+
if (isRoot) {
|
|
52703
|
+
const globalRows = [
|
|
52704
|
+
...formatGlobalOptionRows(globalOptions),
|
|
52705
|
+
...collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlags)
|
|
52706
|
+
];
|
|
52707
|
+
sections.push(
|
|
52708
|
+
`${text.sectionHeader("Global options")}
|
|
52709
|
+
${formatHelpOptionList(globalRows)}`
|
|
52710
|
+
);
|
|
52711
|
+
}
|
|
52465
52712
|
return renderHelpDocument({
|
|
52466
52713
|
breadcrumb,
|
|
52467
52714
|
rootUsageName,
|
|
52468
|
-
usageLine: buildUsageLine(breadcrumb, rootUsageName, "[command] [
|
|
52715
|
+
usageLine: buildUsageLine(breadcrumb, rootUsageName, "[command] [OPTIONS]"),
|
|
52469
52716
|
description: group.description,
|
|
52470
52717
|
requiresAuth: group.requires?.auth === true,
|
|
52471
52718
|
sections
|
|
@@ -52476,7 +52723,7 @@ function renderLeafHelp(command, breadcrumb, casing, globalOptions, rootUsageNam
|
|
|
52476
52723
|
const globalLongOptionFlags = getGlobalLongOptionFlags(globalOptions.presetsEnabled);
|
|
52477
52724
|
const collected = collectFields(command.params, casing, globalLongOptionFlags);
|
|
52478
52725
|
const fields = assignPositionals(collected.fields, command.positional);
|
|
52479
|
-
const optionRows = fields.map((field) => ({
|
|
52726
|
+
const optionRows = fields.filter((field) => field.global !== true).map((field) => ({
|
|
52480
52727
|
flags: formatHelpFieldFlags(field, globalLongOptionFlags),
|
|
52481
52728
|
description: formatHelpFieldDescription(field)
|
|
52482
52729
|
})).concat(collected.dynamicFields.flatMap((field) => formatDynamicHelpFields(field, casing)));
|
|
@@ -52484,10 +52731,6 @@ function renderLeafHelp(command, breadcrumb, casing, globalOptions, rootUsageNam
|
|
|
52484
52731
|
sections.push(`${text.sectionHeader("Options")}
|
|
52485
52732
|
${formatHelpOptionList(optionRows)}`);
|
|
52486
52733
|
}
|
|
52487
|
-
sections.push(
|
|
52488
|
-
`${text.sectionHeader("Options")}
|
|
52489
|
-
${formatHelpOptionList(formatGlobalOptionRows(globalOptions))}`
|
|
52490
|
-
);
|
|
52491
52734
|
const secretRows = formatSecretRows(command.secrets);
|
|
52492
52735
|
if (secretRows.length > 0) {
|
|
52493
52736
|
sections.push(
|
|
@@ -52496,7 +52739,7 @@ ${formatHelpOptionList(secretRows)}`
|
|
|
52496
52739
|
);
|
|
52497
52740
|
}
|
|
52498
52741
|
const positionalFields = fields.filter((f) => f.positionalIndex !== void 0);
|
|
52499
|
-
const usageSuffix = positionalFields.length > 0 ? `[
|
|
52742
|
+
const usageSuffix = positionalFields.length > 0 ? `[OPTIONS] ${positionalFields.map(formatPositionalToken).join(" ")}` : "[OPTIONS]";
|
|
52500
52743
|
return renderHelpDocument({
|
|
52501
52744
|
breadcrumb,
|
|
52502
52745
|
rootUsageName,
|
|
@@ -52543,7 +52786,8 @@ async function renderGeneratedHelp(root, argv, options) {
|
|
|
52543
52786
|
showVersion: options.version !== void 0,
|
|
52544
52787
|
presetsEnabled: options.presets === true
|
|
52545
52788
|
},
|
|
52546
|
-
rootUsageName
|
|
52789
|
+
rootUsageName,
|
|
52790
|
+
target.node === root
|
|
52547
52791
|
) : renderLeafHelp(
|
|
52548
52792
|
target.node,
|
|
52549
52793
|
target.breadcrumb,
|
|
@@ -52643,7 +52887,7 @@ function addGlobalOptions(command, presetsEnabled) {
|
|
|
52643
52887
|
throw new InvalidArgumentError(
|
|
52644
52888
|
'Invalid value for "--output". Expected one of: rich, md, markdown, json.'
|
|
52645
52889
|
);
|
|
52646
|
-
}).option("--
|
|
52890
|
+
}).option("--debug", "Print stack traces for unexpected errors.");
|
|
52647
52891
|
}
|
|
52648
52892
|
function setNestedValue(target, path108, value) {
|
|
52649
52893
|
let cursor = target;
|
|
@@ -53754,7 +53998,7 @@ async function executeCommand(state, services, requirementOptions, runtimeOption
|
|
|
53754
53998
|
}
|
|
53755
53999
|
});
|
|
53756
54000
|
}
|
|
53757
|
-
function handleRunError(error2,
|
|
54001
|
+
function handleRunError(error2, debug) {
|
|
53758
54002
|
const logger2 = createLogger();
|
|
53759
54003
|
if (error2 instanceof UserError) {
|
|
53760
54004
|
logger2.error(error2.message);
|
|
@@ -53769,8 +54013,8 @@ function handleRunError(error2, verbose) {
|
|
|
53769
54013
|
return;
|
|
53770
54014
|
}
|
|
53771
54015
|
const message2 = error2 instanceof Error ? error2.message : String(error2);
|
|
53772
|
-
logger2.error(
|
|
53773
|
-
if (
|
|
54016
|
+
logger2.error(debug ? message2 : `${message2} Use --debug for a stack trace.`);
|
|
54017
|
+
if (debug && error2 instanceof Error && error2.stack) {
|
|
53774
54018
|
process.stderr.write(`${error2.stack}
|
|
53775
54019
|
`);
|
|
53776
54020
|
}
|
|
@@ -53835,7 +54079,7 @@ async function runCLI(roots, options = {}) {
|
|
|
53835
54079
|
}
|
|
53836
54080
|
handleRunError(
|
|
53837
54081
|
error2,
|
|
53838
|
-
lastActionCommand ? Boolean(getResolvedFlags(lastActionCommand).
|
|
54082
|
+
lastActionCommand ? Boolean(getResolvedFlags(lastActionCommand).debug) : process.argv.includes("--debug")
|
|
53839
54083
|
);
|
|
53840
54084
|
}
|
|
53841
54085
|
}
|
|
@@ -53854,7 +54098,7 @@ var init_cli = __esm({
|
|
|
53854
54098
|
RESERVED_SERVICE_NAMES2 = /* @__PURE__ */ new Set(["params", "secrets", "fetch", "fs", "env", "progress"]);
|
|
53855
54099
|
NULL_OPTION_VALUE = /* @__PURE__ */ Symbol("toolcraft.cli.null");
|
|
53856
54100
|
HELP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h"]);
|
|
53857
|
-
ALWAYS_GLOBAL_LONG_OPTION_FLAGS = ["--yes", "--output", "--
|
|
54101
|
+
ALWAYS_GLOBAL_LONG_OPTION_FLAGS = ["--yes", "--output", "--debug"];
|
|
53858
54102
|
DESIGN_SYSTEM_OUTPUT_BY_MODE = {
|
|
53859
54103
|
rich: "terminal",
|
|
53860
54104
|
md: "markdown",
|
|
@@ -81032,7 +81276,7 @@ var init_package2 = __esm({
|
|
|
81032
81276
|
"package.json"() {
|
|
81033
81277
|
package_default2 = {
|
|
81034
81278
|
name: "poe-code",
|
|
81035
|
-
version: "3.0.
|
|
81279
|
+
version: "3.0.209",
|
|
81036
81280
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
81037
81281
|
type: "module",
|
|
81038
81282
|
main: "./dist/index.js",
|