@andpipes/cli 0.1.5 → 0.1.6
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/README.md +2 -0
- package/dist/bin.cjs +295 -119
- package/dist/bin.js +1 -1
- package/dist/{chunk-2PG5NEI2.js → chunk-TTC7UVIV.js} +265 -85
- package/dist/index.cjs +299 -123
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/bin.cjs
CHANGED
|
@@ -19,7 +19,7 @@ function readVersion() {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// src/cli.ts
|
|
22
|
-
var
|
|
22
|
+
var import_localization14 = require("@andpipes/localization");
|
|
23
23
|
var import_commander = require("commander");
|
|
24
24
|
|
|
25
25
|
// src/commands/audit-export.ts
|
|
@@ -3140,8 +3140,8 @@ async function downloadAuditExportArtifact(input) {
|
|
|
3140
3140
|
} finally {
|
|
3141
3141
|
reader.releaseLock();
|
|
3142
3142
|
}
|
|
3143
|
-
const
|
|
3144
|
-
if (bytes !== authorization.manifest.byteCount ||
|
|
3143
|
+
const sha2563 = hash.digest("hex");
|
|
3144
|
+
if (bytes !== authorization.manifest.byteCount || sha2563 !== authorization.manifest.contentSha256) {
|
|
3145
3145
|
throw new UsageError("\u76E3\u67FB\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u306E\u5185\u5BB9\u304C\u7F72\u540Dmanifest\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093");
|
|
3146
3146
|
}
|
|
3147
3147
|
await file.sync();
|
|
@@ -3160,7 +3160,7 @@ async function downloadAuditExportArtifact(input) {
|
|
|
3160
3160
|
} finally {
|
|
3161
3161
|
await directory.close();
|
|
3162
3162
|
}
|
|
3163
|
-
return { output: canonicalTarget, sha256:
|
|
3163
|
+
return { output: canonicalTarget, sha256: sha2563, bytes };
|
|
3164
3164
|
} finally {
|
|
3165
3165
|
clearTimeout(timeout);
|
|
3166
3166
|
await file.close().catch(() => void 0);
|
|
@@ -8402,23 +8402,246 @@ function registerLogs(program, writer, locale = import_localization8.DEFAULT_LOC
|
|
|
8402
8402
|
});
|
|
8403
8403
|
}
|
|
8404
8404
|
|
|
8405
|
-
// src/commands/
|
|
8406
|
-
var
|
|
8407
|
-
var
|
|
8405
|
+
// src/commands/muse.ts
|
|
8406
|
+
var import_node_crypto12 = require("crypto");
|
|
8407
|
+
var import_node_fs12 = require("fs");
|
|
8408
|
+
var import_node_path13 = require("path");
|
|
8408
8409
|
var import_localization10 = require("@andpipes/localization");
|
|
8409
|
-
var
|
|
8410
|
+
var import_tool_contract9 = require("@andpipes/tool-contract");
|
|
8410
8411
|
|
|
8411
|
-
// src/commands/
|
|
8412
|
-
var
|
|
8412
|
+
// src/commands/validate.ts
|
|
8413
|
+
var import_node_fs11 = require("fs");
|
|
8414
|
+
var import_node_path12 = require("path");
|
|
8413
8415
|
var import_localization9 = require("@andpipes/localization");
|
|
8414
|
-
|
|
8416
|
+
function resolveContractPath(file, cwd, locale = import_localization9.DEFAULT_LOCALE) {
|
|
8417
|
+
const messages = import_localization9.CLI_MESSAGES[locale].validate;
|
|
8418
|
+
if (file) {
|
|
8419
|
+
const abs = (0, import_node_path12.resolve)(cwd, file);
|
|
8420
|
+
if (!(0, import_node_fs11.existsSync)(abs)) {
|
|
8421
|
+
throw new UsageError(messages.fileNotFound(file));
|
|
8422
|
+
}
|
|
8423
|
+
return abs;
|
|
8424
|
+
}
|
|
8425
|
+
for (const candidate of import_tool_contract4.CONTRACT_FILENAMES) {
|
|
8426
|
+
const abs = (0, import_node_path12.resolve)(cwd, candidate);
|
|
8427
|
+
if ((0, import_node_fs11.existsSync)(abs)) {
|
|
8428
|
+
return abs;
|
|
8429
|
+
}
|
|
8430
|
+
}
|
|
8431
|
+
throw new UsageError(messages.defaultFileNotFound(import_tool_contract4.CONTRACT_FILENAMES));
|
|
8432
|
+
}
|
|
8433
|
+
function registerValidate(program, writer, cwd, locale = import_localization9.DEFAULT_LOCALE) {
|
|
8434
|
+
const text = import_localization9.LOCALIZED_TEXT[locale].cli;
|
|
8435
|
+
const messages = import_localization9.CLI_MESSAGES[locale].validate;
|
|
8436
|
+
program.command("validate").description(`${text.validateDescription} (10 checks)`).option("--file <path>", messages.fileOption).action((opts) => {
|
|
8437
|
+
const path = resolveContractPath(opts.file, cwd(), locale);
|
|
8438
|
+
const loaded = loadContractFile(path);
|
|
8439
|
+
const report = loaded.report;
|
|
8440
|
+
const publishGate = loaded.publishGate;
|
|
8441
|
+
json(writer, { checks: report.results, publishGate });
|
|
8442
|
+
const fail2 = report.results.filter((r) => r.status === "fail").length;
|
|
8443
|
+
const pending = report.results.filter((r) => r.status === "pending").length;
|
|
8444
|
+
const pass = report.results.filter((r) => r.status === "pass").length;
|
|
8445
|
+
info(
|
|
8446
|
+
writer,
|
|
8447
|
+
`${text.resultLabel}: pass=${pass} fail=${fail2} pending=${pending} (pending=${text.backendPending})`
|
|
8448
|
+
);
|
|
8449
|
+
info(
|
|
8450
|
+
writer,
|
|
8451
|
+
messages.publishGateSummary(publishGate.errors.length, publishGate.warnings.length)
|
|
8452
|
+
);
|
|
8453
|
+
if (!report.ok || !publishGate.ok) {
|
|
8454
|
+
process.exitCode = 1;
|
|
8455
|
+
info(writer, messages.failed);
|
|
8456
|
+
}
|
|
8457
|
+
});
|
|
8458
|
+
}
|
|
8459
|
+
|
|
8460
|
+
// src/commands/muse.ts
|
|
8461
|
+
var DEFAULT_MUSE_OUTPUT_DIR = "andpipe-muse-preparation";
|
|
8462
|
+
var OUTPUT_DIR_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
8463
|
+
var MAX_MUSE_FILE_BYTES = 8 * 1024 * 1024;
|
|
8464
|
+
var MUSE_PREPARATION_FILE_KEYS = Object.freeze(
|
|
8465
|
+
{
|
|
8466
|
+
"muse/connector.internal.json": "connector",
|
|
8467
|
+
"muse/openapi.json": "openapi",
|
|
8468
|
+
"muse/SKILL.md": "skill",
|
|
8469
|
+
"muse/setup.md": "setup",
|
|
8470
|
+
"muse/compatibility.json": "compatibility",
|
|
8471
|
+
"provenance/build.json": "provenance"
|
|
8472
|
+
}
|
|
8473
|
+
);
|
|
8474
|
+
var REASON_KEYS = {
|
|
8475
|
+
invalid_input: "invalid_input",
|
|
8476
|
+
selection_required: "selection_required",
|
|
8477
|
+
selection_invalid: "selection_invalid",
|
|
8478
|
+
contract_invalid: "contract_invalid",
|
|
8479
|
+
schema_unsupported: "schema_unsupported",
|
|
8480
|
+
sensitive_content: "sensitive_content",
|
|
8481
|
+
risk_unsupported: "risk_unsupported"
|
|
8482
|
+
};
|
|
8483
|
+
function parseToolNames(value, locale) {
|
|
8484
|
+
const names = (value ?? "").split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
8485
|
+
if (names.length === 0) throw new UsageError(import_localization10.MUSE_SETUP_MESSAGES[locale].cli.toolsRequired);
|
|
8486
|
+
return names;
|
|
8487
|
+
}
|
|
8488
|
+
function parseOutputDir(value, locale) {
|
|
8489
|
+
const output = value ?? DEFAULT_MUSE_OUTPUT_DIR;
|
|
8490
|
+
if (!OUTPUT_DIR_RE.test(output) || output === "." || output === "..") {
|
|
8491
|
+
throw new UsageError(import_localization10.MUSE_SETUP_MESSAGES[locale].cli.outputInvalid);
|
|
8492
|
+
}
|
|
8493
|
+
return output;
|
|
8494
|
+
}
|
|
8495
|
+
function sha2562(text) {
|
|
8496
|
+
return `sha256:${(0, import_node_crypto12.createHash)("sha256").update(text, "utf8").digest("hex")}`;
|
|
8497
|
+
}
|
|
8498
|
+
function createOwnedDirectory(path) {
|
|
8499
|
+
(0, import_node_fs12.mkdirSync)(path, { mode: 448 });
|
|
8500
|
+
return ownedDirectoryIdentity(path);
|
|
8501
|
+
}
|
|
8502
|
+
function ownedDirectoryIdentity(path) {
|
|
8503
|
+
let stat2;
|
|
8504
|
+
try {
|
|
8505
|
+
stat2 = (0, import_node_fs12.lstatSync)(path);
|
|
8506
|
+
} catch {
|
|
8507
|
+
throw new LocalFilePolicyError("local_file_changed", "output directory changed after create");
|
|
8508
|
+
}
|
|
8509
|
+
const identity = localRootIdentityFromStat(stat2, "local_file_changed", "output directory");
|
|
8510
|
+
assertOwnerOnlyLocalWrite(identity, "output directory");
|
|
8511
|
+
return identity;
|
|
8512
|
+
}
|
|
8513
|
+
function errorCode(error) {
|
|
8514
|
+
const code = typeof error === "object" && error !== null ? error.code : null;
|
|
8515
|
+
return typeof code === "string" && /^[A-Z][A-Z0-9_]{1,31}$/u.test(code) ? code : null;
|
|
8516
|
+
}
|
|
8517
|
+
function museWriteOrder(paths) {
|
|
8518
|
+
const isProvenance = (path) => path.startsWith("provenance/");
|
|
8519
|
+
return [...paths].sort(
|
|
8520
|
+
(left, right) => isProvenance(left) === isProvenance(right) ? left < right ? -1 : 1 : isProvenance(left) ? 1 : -1
|
|
8521
|
+
);
|
|
8522
|
+
}
|
|
8523
|
+
function writeBundle(root, output, files, locale) {
|
|
8524
|
+
const messages = import_localization10.MUSE_SETUP_MESSAGES[locale].cli;
|
|
8525
|
+
const target = (0, import_node_path13.join)(root, output);
|
|
8526
|
+
const ordered = museWriteOrder(Object.keys(files));
|
|
8527
|
+
const directoryNames = /* @__PURE__ */ new Set();
|
|
8528
|
+
for (const path of ordered) {
|
|
8529
|
+
const [directory, name, ...rest] = path.split("/");
|
|
8530
|
+
if (!directory || !name || rest.length > 0 || !MUSE_PREPARATION_FILE_KEYS[path]) {
|
|
8531
|
+
throw new LocalFilePolicyError("local_file_invalid", "unexpected preparation file path");
|
|
8532
|
+
}
|
|
8533
|
+
directoryNames.add(directory);
|
|
8534
|
+
}
|
|
8535
|
+
try {
|
|
8536
|
+
(0, import_node_fs12.mkdirSync)(target, { mode: 448 });
|
|
8537
|
+
} catch (error) {
|
|
8538
|
+
const code = errorCode(error);
|
|
8539
|
+
if (code === "EEXIST") throw new UsageError(messages.outputExists(output));
|
|
8540
|
+
throw new UsageError(`${messages.outputCreateFailed(output)}${code ? ` (${code})` : ""}`);
|
|
8541
|
+
}
|
|
8542
|
+
try {
|
|
8543
|
+
const targetIdentity = ownedDirectoryIdentity(target);
|
|
8544
|
+
const directories = /* @__PURE__ */ new Map();
|
|
8545
|
+
for (const directory of directoryNames) {
|
|
8546
|
+
assertLocalRootSecurityIdentity(target, targetIdentity, "muse output directory");
|
|
8547
|
+
directories.set(directory, createOwnedDirectory((0, import_node_path13.join)(target, directory)));
|
|
8548
|
+
}
|
|
8549
|
+
for (const path of ordered) {
|
|
8550
|
+
const [directory, name] = path.split("/");
|
|
8551
|
+
const expected = directories.get(directory);
|
|
8552
|
+
assertLocalRootSecurityIdentity(target, targetIdentity, "muse output directory");
|
|
8553
|
+
const delta = writePrivateFileNoReplace(
|
|
8554
|
+
name,
|
|
8555
|
+
(0, import_node_path13.join)(target, directory),
|
|
8556
|
+
files[path],
|
|
8557
|
+
MAX_MUSE_FILE_BYTES,
|
|
8558
|
+
{ expectedRootIdentity: expected }
|
|
8559
|
+
);
|
|
8560
|
+
directories.set(directory, localRootIdentityWithNlink(expected, expected.nlink + delta));
|
|
8561
|
+
}
|
|
8562
|
+
} catch (error) {
|
|
8563
|
+
const reason = error instanceof LocalFilePolicyError ? ` (${error.reason})` : "";
|
|
8564
|
+
throw new UsageError(`${messages.outputIncomplete(output)}${reason}`);
|
|
8565
|
+
}
|
|
8566
|
+
}
|
|
8567
|
+
function runMusePrepare(options, writer, cwd, locale = import_localization10.DEFAULT_LOCALE) {
|
|
8568
|
+
const messages = import_localization10.MUSE_SETUP_MESSAGES[locale];
|
|
8569
|
+
const toolNames = parseToolNames(options.tools, locale);
|
|
8570
|
+
const output = parseOutputDir(options.output, locale);
|
|
8571
|
+
const anchor = captureLocalRootPath(cwd);
|
|
8572
|
+
const loaded = loadContractFile(resolveContractPath(options.file, cwd, locale));
|
|
8573
|
+
const selected = new Set(toolNames);
|
|
8574
|
+
const result = (0, import_tool_contract9.prepareMuseBundle)(
|
|
8575
|
+
loaded.tools.filter((tool) => selected.has(tool.tool)),
|
|
8576
|
+
{ toolNames }
|
|
8577
|
+
);
|
|
8578
|
+
const flags = {
|
|
8579
|
+
enabled: result.enabled,
|
|
8580
|
+
liveVerified: result.liveVerified,
|
|
8581
|
+
submissionReady: result.submissionReady
|
|
8582
|
+
};
|
|
8583
|
+
if (result.status === "blocked") {
|
|
8584
|
+
const reason = messages.reasons[REASON_KEYS[result.reason]];
|
|
8585
|
+
json(writer, { status: "blocked", reason: result.reason, ...flags });
|
|
8586
|
+
info(writer, messages.cli.blocked);
|
|
8587
|
+
info(writer, `${messages.cli.reasonLabel}: ${reason.cause}`);
|
|
8588
|
+
info(writer, `${messages.cli.fixLabel}: ${reason.fix}`);
|
|
8589
|
+
process.exitCode = 1;
|
|
8590
|
+
return;
|
|
8591
|
+
}
|
|
8592
|
+
assertLocalRootSecurityIdentity(anchor.root, anchor.rootIdentity, "muse output");
|
|
8593
|
+
writeBundle(anchor.root, output, result.files, locale);
|
|
8594
|
+
const paths = Object.keys(result.files).sort();
|
|
8595
|
+
json(writer, {
|
|
8596
|
+
status: "prepared",
|
|
8597
|
+
output,
|
|
8598
|
+
contentHash: result.contentHash,
|
|
8599
|
+
...flags,
|
|
8600
|
+
files: paths.map((path) => ({ path, sha256: sha2562(result.files[path]) }))
|
|
8601
|
+
});
|
|
8602
|
+
info(writer, messages.cli.prepared(output));
|
|
8603
|
+
info(writer, messages.cli.notConnected);
|
|
8604
|
+
for (const path of paths) {
|
|
8605
|
+
const key = MUSE_PREPARATION_FILE_KEYS[path];
|
|
8606
|
+
if (key) info(writer, ` ${output}/${path}: ${messages.files[key]}`);
|
|
8607
|
+
}
|
|
8608
|
+
info(writer, `${messages.cli.statesHeading}:`);
|
|
8609
|
+
for (const key of import_localization10.MUSE_SETUP_STATE_KEYS) {
|
|
8610
|
+
const state = messages.states[key];
|
|
8611
|
+
info(
|
|
8612
|
+
writer,
|
|
8613
|
+
`- ${state.title}: ${key === "prepared" ? messages.cli.preparedNow : state.status}`
|
|
8614
|
+
);
|
|
8615
|
+
}
|
|
8616
|
+
info(writer, messages.cli.nextStep);
|
|
8617
|
+
}
|
|
8618
|
+
function registerMuse(program, writer, cwd, locale = import_localization10.DEFAULT_LOCALE) {
|
|
8619
|
+
const messages = import_localization10.MUSE_SETUP_MESSAGES[locale].cli;
|
|
8620
|
+
const muse = program.command("muse").description(messages.groupDescription);
|
|
8621
|
+
muse.command("prepare").description(messages.prepareDescription).option(
|
|
8622
|
+
"--tools <names>",
|
|
8623
|
+
messages.toolsOption,
|
|
8624
|
+
(value, previous) => previous === void 0 ? value : `${previous},${value}`
|
|
8625
|
+
).option("--file <path>", messages.fileOption).option("--output <dir>", messages.outputOption, DEFAULT_MUSE_OUTPUT_DIR).action((options) => runMusePrepare(options, writer, cwd(), locale));
|
|
8626
|
+
}
|
|
8627
|
+
|
|
8628
|
+
// src/commands/oauth.ts
|
|
8629
|
+
var import_node_crypto14 = require("crypto");
|
|
8630
|
+
var import_node_fs13 = require("fs");
|
|
8631
|
+
var import_localization12 = require("@andpipes/localization");
|
|
8632
|
+
var import_tool_contract11 = require("@andpipes/tool-contract");
|
|
8633
|
+
|
|
8634
|
+
// src/commands/publish.ts
|
|
8635
|
+
var import_node_crypto13 = require("crypto");
|
|
8636
|
+
var import_localization11 = require("@andpipes/localization");
|
|
8637
|
+
var import_tool_contract10 = require("@andpipes/tool-contract");
|
|
8415
8638
|
var UUID_RE6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
8416
8639
|
var SAFE_AP_CODE_RE2 = /^AP_[A-Z0-9_]{1,64}$/u;
|
|
8417
8640
|
var PUBLICATION_RESPONSE_MAX_BYTES = 96 * 1024;
|
|
8418
8641
|
var INITIAL_APPLY_MAX_ATTEMPTS = 3;
|
|
8419
|
-
var DEFAULT_PUBLISH_MESSAGES =
|
|
8420
|
-
var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 =
|
|
8421
|
-
var DEFAULT_SCHEMA_REVIEW_MESSAGES =
|
|
8642
|
+
var DEFAULT_PUBLISH_MESSAGES = import_localization11.CLI_MESSAGES.ja.publish;
|
|
8643
|
+
var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 = import_localization11.OAUTH_SCOPE_REGISTRATION_MESSAGES.ja.cli;
|
|
8644
|
+
var DEFAULT_SCHEMA_REVIEW_MESSAGES = import_localization11.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES.ja;
|
|
8422
8645
|
var REVIEW_PROFILE_REQUEST = Object.freeze({
|
|
8423
8646
|
reviewProfile: CLI_PUBLICATION_REVIEW_PROFILE
|
|
8424
8647
|
});
|
|
@@ -8507,7 +8730,7 @@ function createPublishCommandRuntime(createClient) {
|
|
|
8507
8730
|
return {
|
|
8508
8731
|
createClient,
|
|
8509
8732
|
loadProject: loadDevProject,
|
|
8510
|
-
randomUuid: () => (0,
|
|
8733
|
+
randomUuid: () => (0, import_node_crypto13.randomUUID)(),
|
|
8511
8734
|
monotonicNow: () => Number(process.hrtime.bigint() / 1000000n),
|
|
8512
8735
|
wallNow: () => Date.now(),
|
|
8513
8736
|
sleep: (milliseconds) => new Promise((resolve7) => setTimeout(resolve7, milliseconds))
|
|
@@ -8553,7 +8776,7 @@ function responseInvalid(reason, messages) {
|
|
|
8553
8776
|
}
|
|
8554
8777
|
function assertCanonicalResponseSize(value, reason, messages, maxBytes = PUBLICATION_RESPONSE_MAX_BYTES) {
|
|
8555
8778
|
try {
|
|
8556
|
-
(0,
|
|
8779
|
+
(0, import_tool_contract10.assertCanonicalPublicationSize)(value, maxBytes);
|
|
8557
8780
|
} catch {
|
|
8558
8781
|
throw responseInvalid(reason, messages);
|
|
8559
8782
|
}
|
|
@@ -8562,7 +8785,7 @@ function isCanonicalUuid(value) {
|
|
|
8562
8785
|
return typeof value === "string" && UUID_RE6.test(value);
|
|
8563
8786
|
}
|
|
8564
8787
|
function isCommitment(value) {
|
|
8565
|
-
return typeof value === "string" &&
|
|
8788
|
+
return typeof value === "string" && import_tool_contract10.PUBLICATION_SHA256_COMMITMENT_RE.test(value);
|
|
8566
8789
|
}
|
|
8567
8790
|
function isCanonicalTimestamp(value) {
|
|
8568
8791
|
if (typeof value !== "string" || value.length > 64) return false;
|
|
@@ -8571,12 +8794,12 @@ function isCanonicalTimestamp(value) {
|
|
|
8571
8794
|
}
|
|
8572
8795
|
function isStrictlySorted(values) {
|
|
8573
8796
|
return values.every(
|
|
8574
|
-
(value, index) => index === 0 || (0,
|
|
8797
|
+
(value, index) => index === 0 || (0, import_tool_contract10.comparePublicationUnicodeCodePoints)(values[index - 1], value) < 0
|
|
8575
8798
|
);
|
|
8576
8799
|
}
|
|
8577
8800
|
function parseWarnings(value, messages) {
|
|
8578
8801
|
try {
|
|
8579
|
-
return (0,
|
|
8802
|
+
return (0, import_tool_contract10.parsePublicationWarningsDto)(value);
|
|
8580
8803
|
} catch {
|
|
8581
8804
|
throw responseInvalid("publication_warnings_invalid", messages);
|
|
8582
8805
|
}
|
|
@@ -8623,7 +8846,7 @@ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, p
|
|
|
8623
8846
|
const blockedReasons = plan.blockedReasons;
|
|
8624
8847
|
let safeDiff;
|
|
8625
8848
|
try {
|
|
8626
|
-
safeDiff = (0,
|
|
8849
|
+
safeDiff = (0, import_tool_contract10.parsePublicationSafeDiffDto)({
|
|
8627
8850
|
...profile === 2 ? { reviewProfile: 2 } : {},
|
|
8628
8851
|
tools: plan.tools,
|
|
8629
8852
|
retainedTools: plan.retainedTools,
|
|
@@ -8641,7 +8864,7 @@ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, p
|
|
|
8641
8864
|
throw responseInvalid("publication_plan_tools_order_invalid", messages);
|
|
8642
8865
|
}
|
|
8643
8866
|
const warnings = safeDiff.warnings;
|
|
8644
|
-
const expectedPlanCommitment = (0,
|
|
8867
|
+
const expectedPlanCommitment = (0, import_tool_contract10.publicationCommitment)(profile === 2 ? "planV2" : "plan", {
|
|
8645
8868
|
candidateCommitment,
|
|
8646
8869
|
baseCommitment: plan.baseCommitment,
|
|
8647
8870
|
connectorId,
|
|
@@ -8695,7 +8918,7 @@ function parseToolResults(value, messages) {
|
|
|
8695
8918
|
}
|
|
8696
8919
|
const tools = value.map((candidate) => {
|
|
8697
8920
|
const tool = asRecord4(candidate);
|
|
8698
|
-
if (!tool || !hasExactKeys3(tool, ["toolName", "operation", "toolId", "versionId", "version"]) || !(0,
|
|
8921
|
+
if (!tool || !hasExactKeys3(tool, ["toolName", "operation", "toolId", "versionId", "version"]) || !(0, import_tool_contract10.isSafeToolName)(tool.toolName) || tool.operation !== "create" && tool.operation !== "update" || !isCanonicalUuid(tool.toolId) || !isCanonicalUuid(tool.versionId) || typeof tool.version !== "number" || !Number.isSafeInteger(tool.version) || tool.version < 1) {
|
|
8699
8922
|
throw responseInvalid("publication_result_tool_invalid", messages);
|
|
8700
8923
|
}
|
|
8701
8924
|
const operation = tool.operation;
|
|
@@ -8752,7 +8975,7 @@ function parsePublicationResult(value, plan, messages, expectedPublicationId) {
|
|
|
8752
8975
|
function parseConfirmation(value, messages) {
|
|
8753
8976
|
if (value === null) return null;
|
|
8754
8977
|
const confirmation = asRecord4(value);
|
|
8755
|
-
if (!confirmation || !hasExactKeys3(confirmation, ["confirmationId", "signature", "confirmed"]) || !isCanonicalUuid(confirmation.confirmationId) || typeof confirmation.signature !== "string" || !
|
|
8978
|
+
if (!confirmation || !hasExactKeys3(confirmation, ["confirmationId", "signature", "confirmed"]) || !isCanonicalUuid(confirmation.confirmationId) || typeof confirmation.signature !== "string" || !import_tool_contract10.PUBLICATION_CONFIRMATION_SIGNATURE_RE.test(confirmation.signature) || confirmation.confirmed !== true) {
|
|
8756
8979
|
throw responseInvalid("publication_confirmation_invalid", messages);
|
|
8757
8980
|
}
|
|
8758
8981
|
return {
|
|
@@ -8915,7 +9138,7 @@ function writeSchemaReviewSummary(writer, plan, schemaReviewMessages) {
|
|
|
8915
9138
|
}
|
|
8916
9139
|
}
|
|
8917
9140
|
function candidateNeedsReviewProfile2(candidateContract) {
|
|
8918
|
-
return (0,
|
|
9141
|
+
return (0, import_tool_contract10.selectPublicationReviewProfile)({
|
|
8919
9142
|
requestedProfile: CLI_PUBLICATION_REVIEW_PROFILE,
|
|
8920
9143
|
candidateContract,
|
|
8921
9144
|
currentTools: []
|
|
@@ -8939,11 +9162,11 @@ function freezeJson(value) {
|
|
|
8939
9162
|
return value;
|
|
8940
9163
|
}
|
|
8941
9164
|
function prepareCandidate(project) {
|
|
8942
|
-
const canonical = (0,
|
|
9165
|
+
const canonical = (0, import_tool_contract10.assertCanonicalPublicationSize)(project.contract.root);
|
|
8943
9166
|
const candidateContract = freezeJson(JSON.parse(canonical));
|
|
8944
9167
|
return {
|
|
8945
9168
|
candidateContract,
|
|
8946
|
-
candidateCommitment: (0,
|
|
9169
|
+
candidateCommitment: (0, import_tool_contract10.publicationCommitment)("candidate", candidateContract)
|
|
8947
9170
|
};
|
|
8948
9171
|
}
|
|
8949
9172
|
function loadPublicationProject(loadProject, cwd, messages = DEFAULT_PUBLISH_MESSAGES) {
|
|
@@ -8977,15 +9200,15 @@ function assertManifestProject(project, requestedProjectId, messages = DEFAULT_P
|
|
|
8977
9200
|
}
|
|
8978
9201
|
function buildLocalPublicationCandidate(project, connectorId, messages = DEFAULT_PUBLISH_MESSAGES) {
|
|
8979
9202
|
const candidate = prepareCandidate(project);
|
|
8980
|
-
const localToolNames = project.contract.tools.map((tool) => (0,
|
|
8981
|
-
if (localToolNames.some((name) => !(0,
|
|
9203
|
+
const localToolNames = project.contract.tools.map((tool) => (0, import_tool_contract10.toolName)(tool));
|
|
9204
|
+
if (localToolNames.some((name) => !(0, import_tool_contract10.isSafeToolName)(name))) {
|
|
8982
9205
|
throw new PublishCommandError(
|
|
8983
9206
|
"AP_INPUT_INVALID",
|
|
8984
9207
|
"publication_candidate_tool_invalid",
|
|
8985
9208
|
messages.failure("publication_candidate_tool_invalid")
|
|
8986
9209
|
);
|
|
8987
9210
|
}
|
|
8988
|
-
const expectedToolNames = localToolNames.sort(
|
|
9211
|
+
const expectedToolNames = localToolNames.sort(import_tool_contract10.comparePublicationUnicodeCodePoints);
|
|
8989
9212
|
return {
|
|
8990
9213
|
planRequest: {
|
|
8991
9214
|
environment: "production",
|
|
@@ -9342,8 +9565,8 @@ function isUrl(value) {
|
|
|
9342
9565
|
function field(meta, snake, camel) {
|
|
9343
9566
|
return snake in meta ? meta[snake] : meta[camel];
|
|
9344
9567
|
}
|
|
9345
|
-
function validateOAuthMetadata(meta, locale =
|
|
9346
|
-
const messages =
|
|
9568
|
+
function validateOAuthMetadata(meta, locale = import_localization12.DEFAULT_LOCALE) {
|
|
9569
|
+
const messages = import_localization12.CLI_MESSAGES[locale].oauth;
|
|
9347
9570
|
const results = [];
|
|
9348
9571
|
if (!meta || typeof meta !== "object" || Array.isArray(meta)) {
|
|
9349
9572
|
return {
|
|
@@ -9414,7 +9637,7 @@ var RESOURCE_NOT_FOUND_CODES = /* @__PURE__ */ new Set([
|
|
|
9414
9637
|
"AP_TOOL_VERSION_NOT_FOUND"
|
|
9415
9638
|
]);
|
|
9416
9639
|
function createOAuthScopeRegisterRuntime(createClient = (profile) => createAdminApiClient({ profile })) {
|
|
9417
|
-
return { createClient, loadProject: loadDevProject, randomUuid: () => (0,
|
|
9640
|
+
return { createClient, loadProject: loadDevProject, randomUuid: () => (0, import_node_crypto14.randomUUID)() };
|
|
9418
9641
|
}
|
|
9419
9642
|
var OAuthScopeRegistrationCommandError = class extends Error {
|
|
9420
9643
|
constructor(code, reason, message, status) {
|
|
@@ -9437,9 +9660,9 @@ function parseDraftOption(value, messages) {
|
|
|
9437
9660
|
}
|
|
9438
9661
|
return { toolId, versionId };
|
|
9439
9662
|
}
|
|
9440
|
-
function normalizeOAuthScopeRegisterOptions(options, locale =
|
|
9441
|
-
const messages =
|
|
9442
|
-
const cliMessages =
|
|
9663
|
+
function normalizeOAuthScopeRegisterOptions(options, locale = import_localization12.DEFAULT_LOCALE) {
|
|
9664
|
+
const messages = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
9665
|
+
const cliMessages = import_localization12.CLI_MESSAGES[locale];
|
|
9443
9666
|
const apply = options.apply === true;
|
|
9444
9667
|
if (options.yes === true && !apply) throw new UsageError(messages.yesRequiresApply);
|
|
9445
9668
|
if (apply && options.yes !== true) {
|
|
@@ -9466,8 +9689,8 @@ function normalizeOAuthScopeRegisterOptions(options, locale = import_localizatio
|
|
|
9466
9689
|
if (options.connector !== void 0) throw new UsageError(messages.draftConnectorConflict);
|
|
9467
9690
|
if (options.project === void 0) throw new UsageError(messages.draftRequiresProject);
|
|
9468
9691
|
const projectId = canonicalUuidOption(options.project, "--project", cliMessages.publish);
|
|
9469
|
-
const drafts = rawDrafts.map((value) => parseDraftOption(value, messages)).sort((left, right) => (0,
|
|
9470
|
-
if (drafts.length >
|
|
9692
|
+
const drafts = rawDrafts.map((value) => parseDraftOption(value, messages)).sort((left, right) => (0, import_tool_contract11.comparePublicationUnicodeCodePoints)(left.toolId, right.toolId));
|
|
9693
|
+
if (drafts.length > import_tool_contract11.OAUTH_SCOPE_REGISTRATION_MAX_DRAFTS || drafts.some((draft, index) => index > 0 && drafts[index - 1]?.toolId === draft.toolId)) {
|
|
9471
9694
|
throw new UsageError(messages.draftInvalid);
|
|
9472
9695
|
}
|
|
9473
9696
|
return { kind: "saved_drafts", projectId, drafts, apply, profile };
|
|
@@ -9584,8 +9807,8 @@ async function projectAccessibility(client, projectId, error) {
|
|
|
9584
9807
|
}
|
|
9585
9808
|
}
|
|
9586
9809
|
function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
9587
|
-
const messages =
|
|
9588
|
-
const publishMessages =
|
|
9810
|
+
const messages = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
9811
|
+
const publishMessages = import_localization12.CLI_MESSAGES[locale].publish;
|
|
9589
9812
|
const project = loadPublicationProject(runtime.loadProject, cwd, publishMessages);
|
|
9590
9813
|
const projectId = assertManifestProject(project, normalized.projectId, publishMessages);
|
|
9591
9814
|
const connectorId = normalized.connectorId ?? project.manifest.connector_id;
|
|
@@ -9594,7 +9817,7 @@ function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
|
9594
9817
|
try {
|
|
9595
9818
|
candidate = buildLocalPublicationCandidate(project, connectorId, publishMessages);
|
|
9596
9819
|
} catch (error) {
|
|
9597
|
-
if (error instanceof
|
|
9820
|
+
if (error instanceof import_tool_contract11.PublicationCanonicalizationError && error.reason === "publication_value_too_large") {
|
|
9598
9821
|
throw new OAuthScopeRegistrationCommandError(
|
|
9599
9822
|
"AP_INPUT_INVALID",
|
|
9600
9823
|
"publication_candidate_too_large",
|
|
@@ -9614,8 +9837,8 @@ function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
|
9614
9837
|
expectedToolNames: candidate.expectedToolNames
|
|
9615
9838
|
};
|
|
9616
9839
|
}
|
|
9617
|
-
async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale =
|
|
9618
|
-
const messages =
|
|
9840
|
+
async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale = import_localization12.DEFAULT_LOCALE) {
|
|
9841
|
+
const messages = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale];
|
|
9619
9842
|
const normalized = normalizeOAuthScopeRegisterOptions(options, locale);
|
|
9620
9843
|
const target = normalized.kind === "saved_drafts" ? {
|
|
9621
9844
|
projectId: normalized.projectId,
|
|
@@ -9663,7 +9886,7 @@ async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, local
|
|
|
9663
9886
|
throw new OAuthScopeRegistrationCommandError(
|
|
9664
9887
|
"AP_NETWORK_ERROR",
|
|
9665
9888
|
"secure_random_invalid",
|
|
9666
|
-
|
|
9889
|
+
import_localization12.CLI_MESSAGES[locale].publish.failure("secure_random_invalid")
|
|
9667
9890
|
);
|
|
9668
9891
|
}
|
|
9669
9892
|
let applied;
|
|
@@ -9693,7 +9916,7 @@ function upstreamOAuthWizardUrl(profile, projectId, connectorId) {
|
|
|
9693
9916
|
return url.toString();
|
|
9694
9917
|
}
|
|
9695
9918
|
async function loadOAuthMetadata(opts, locale) {
|
|
9696
|
-
const messages =
|
|
9919
|
+
const messages = import_localization12.CLI_MESSAGES[locale];
|
|
9697
9920
|
if (opts.file && opts.issuer) {
|
|
9698
9921
|
throw new UsageError("--file \u3068 --issuer \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
|
|
9699
9922
|
}
|
|
@@ -9704,13 +9927,13 @@ async function loadOAuthMetadata(opts, locale) {
|
|
|
9704
9927
|
throw new UsageError(messages.oauth.fileRequired);
|
|
9705
9928
|
}
|
|
9706
9929
|
try {
|
|
9707
|
-
return JSON.parse((0,
|
|
9930
|
+
return JSON.parse((0, import_node_fs13.readFileSync)(opts.file, "utf8"));
|
|
9708
9931
|
} catch (error) {
|
|
9709
9932
|
throw new UsageError(messages.oauth.metadataReadFailed(error.message));
|
|
9710
9933
|
}
|
|
9711
9934
|
}
|
|
9712
9935
|
async function runOAuthMetadataValidate(opts, writer, locale) {
|
|
9713
|
-
const messages =
|
|
9936
|
+
const messages = import_localization12.CLI_MESSAGES[locale];
|
|
9714
9937
|
const parsed = await loadOAuthMetadata(opts, locale);
|
|
9715
9938
|
const report = validateOAuthMetadata(parsed, locale);
|
|
9716
9939
|
json(writer, report.results);
|
|
@@ -9721,8 +9944,8 @@ async function runOAuthMetadataValidate(opts, writer, locale) {
|
|
|
9721
9944
|
info(writer, messages.oauth.metadataOk);
|
|
9722
9945
|
}
|
|
9723
9946
|
}
|
|
9724
|
-
function registerOauth(program, writer, locale =
|
|
9725
|
-
const messages =
|
|
9947
|
+
function registerOauth(program, writer, locale = import_localization12.DEFAULT_LOCALE, dependencies = {}) {
|
|
9948
|
+
const messages = import_localization12.CLI_MESSAGES[locale];
|
|
9726
9949
|
const oauth = program.command("oauth").description(messages.oauth.commandDescription);
|
|
9727
9950
|
oauth.command("init").description(messages.oauth.initDescription).requiredOption("--provider <name>", messages.oauth.providerOption).action((opts) => {
|
|
9728
9951
|
info(writer, messages.oauth.templateHeading(opts.provider));
|
|
@@ -9765,7 +9988,7 @@ function registerOauth(program, writer, locale = import_localization10.DEFAULT_L
|
|
|
9765
9988
|
});
|
|
9766
9989
|
json(writer, result);
|
|
9767
9990
|
});
|
|
9768
|
-
const registration =
|
|
9991
|
+
const registration = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
9769
9992
|
const scopeRegisterRuntime = dependencies.scopeRegisterRuntime ?? createOAuthScopeRegisterRuntime();
|
|
9770
9993
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
9771
9994
|
scopes.command("register").description(registration.commandDescription).option("--project <project-uuid>", registration.projectOption).option("--connector <connector-uuid>", registration.connectorOption).option(
|
|
@@ -9869,11 +10092,11 @@ function registerOauth(program, writer, locale = import_localization10.DEFAULT_L
|
|
|
9869
10092
|
}
|
|
9870
10093
|
|
|
9871
10094
|
// src/commands/openapi.ts
|
|
9872
|
-
var
|
|
9873
|
-
var
|
|
9874
|
-
var
|
|
10095
|
+
var import_node_crypto15 = require("crypto");
|
|
10096
|
+
var import_node_path14 = require("path");
|
|
10097
|
+
var import_tool_contract12 = require("@andpipes/tool-contract");
|
|
9875
10098
|
function createOpenApiImportRuntime(createClient = (profile) => createAdminApiClient({ profile })) {
|
|
9876
|
-
return { createClient, idempotencyKey:
|
|
10099
|
+
return { createClient, idempotencyKey: import_node_crypto15.randomUUID };
|
|
9877
10100
|
}
|
|
9878
10101
|
function normalizedOptions(options) {
|
|
9879
10102
|
if (!options.file || !options.project || !options.connector) {
|
|
@@ -9929,8 +10152,8 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
9929
10152
|
if (normalized.apply && !/^[a-f0-9]{64}$/.test(normalized.planCommitment ?? "")) {
|
|
9930
10153
|
throw new UsageError("--apply \u306B\u306Fpreview\u3067\u5F97\u305F --plan-commitment \u304C\u5FC5\u9808\u3067\u3059");
|
|
9931
10154
|
}
|
|
9932
|
-
const snapshot = readBoundedLocalFileSnapshot((0,
|
|
9933
|
-
maxBytes:
|
|
10155
|
+
const snapshot = readBoundedLocalFileSnapshot((0, import_node_path14.resolve)(cwd, normalized.file), {
|
|
10156
|
+
maxBytes: import_tool_contract12.OPENAPI_IMPORT_MAX_SOURCE_BYTES,
|
|
9934
10157
|
root: cwd
|
|
9935
10158
|
});
|
|
9936
10159
|
const baseRequest = {
|
|
@@ -9951,7 +10174,7 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
9951
10174
|
if (normalized.sideEffectFree.length > 0) {
|
|
9952
10175
|
if (normalized.apply) {
|
|
9953
10176
|
try {
|
|
9954
|
-
const unclassified = (0,
|
|
10177
|
+
const unclassified = (0, import_tool_contract12.importOpenApi)(snapshot.text, {
|
|
9955
10178
|
format: normalized.format,
|
|
9956
10179
|
baseUrl: normalized.baseUrl,
|
|
9957
10180
|
serviceName: normalized.serviceName,
|
|
@@ -9962,7 +10185,7 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
9962
10185
|
unclassified.operations
|
|
9963
10186
|
);
|
|
9964
10187
|
} catch (error) {
|
|
9965
|
-
if (error instanceof
|
|
10188
|
+
if (error instanceof import_tool_contract12.OpenApiImportError) {
|
|
9966
10189
|
throw new UsageError(`OpenAPI\u304B\u3089Tool Contract\u3092\u751F\u6210\u3067\u304D\u307E\u305B\u3093: ${error.message}`);
|
|
9967
10190
|
}
|
|
9968
10191
|
throw error;
|
|
@@ -10017,15 +10240,15 @@ function registerOpenApi(program, writer, cwd, runtime = createOpenApiImportRunt
|
|
|
10017
10240
|
}
|
|
10018
10241
|
|
|
10019
10242
|
// src/commands/review-package.ts
|
|
10020
|
-
var
|
|
10243
|
+
var import_localization13 = require("@andpipes/localization");
|
|
10021
10244
|
var TARGETS = ["chatgpt", "claude", "generic_mcp"];
|
|
10022
|
-
function assertTarget(value, locale =
|
|
10245
|
+
function assertTarget(value, locale = import_localization13.DEFAULT_LOCALE) {
|
|
10023
10246
|
if (!TARGETS.includes(value)) {
|
|
10024
|
-
throw new UsageError(
|
|
10247
|
+
throw new UsageError(import_localization13.CLI_MESSAGES[locale].reviewPackage.invalidTarget(value, TARGETS));
|
|
10025
10248
|
}
|
|
10026
10249
|
}
|
|
10027
|
-
function registerReviewPackage(program, writer, locale =
|
|
10028
|
-
const messages =
|
|
10250
|
+
function registerReviewPackage(program, writer, locale = import_localization13.DEFAULT_LOCALE, cwd = () => process.cwd()) {
|
|
10251
|
+
const messages = import_localization13.CLI_MESSAGES[locale];
|
|
10029
10252
|
const reviewPackage = program.command("review-package").description(messages.reviewPackage.commandDescription);
|
|
10030
10253
|
reviewPackage.command("generate").description(messages.reviewPackage.generateDescription).requiredOption("--project <project>", messages.common.projectOption).requiredOption("--package-version <version>", messages.reviewPackage.packageVersionOption).option("--target <target>", messages.reviewPackage.targetOption).option(
|
|
10031
10254
|
"--from-template",
|
|
@@ -10086,61 +10309,13 @@ function registerReviewPackage(program, writer, locale = import_localization11.D
|
|
|
10086
10309
|
});
|
|
10087
10310
|
}
|
|
10088
10311
|
|
|
10089
|
-
// src/commands/validate.ts
|
|
10090
|
-
var import_node_fs12 = require("fs");
|
|
10091
|
-
var import_node_path13 = require("path");
|
|
10092
|
-
var import_localization12 = require("@andpipes/localization");
|
|
10093
|
-
function resolveContractPath(file, cwd, locale = import_localization12.DEFAULT_LOCALE) {
|
|
10094
|
-
const messages = import_localization12.CLI_MESSAGES[locale].validate;
|
|
10095
|
-
if (file) {
|
|
10096
|
-
const abs = (0, import_node_path13.resolve)(cwd, file);
|
|
10097
|
-
if (!(0, import_node_fs12.existsSync)(abs)) {
|
|
10098
|
-
throw new UsageError(messages.fileNotFound(file));
|
|
10099
|
-
}
|
|
10100
|
-
return abs;
|
|
10101
|
-
}
|
|
10102
|
-
for (const candidate of import_tool_contract4.CONTRACT_FILENAMES) {
|
|
10103
|
-
const abs = (0, import_node_path13.resolve)(cwd, candidate);
|
|
10104
|
-
if ((0, import_node_fs12.existsSync)(abs)) {
|
|
10105
|
-
return abs;
|
|
10106
|
-
}
|
|
10107
|
-
}
|
|
10108
|
-
throw new UsageError(messages.defaultFileNotFound(import_tool_contract4.CONTRACT_FILENAMES));
|
|
10109
|
-
}
|
|
10110
|
-
function registerValidate(program, writer, cwd, locale = import_localization12.DEFAULT_LOCALE) {
|
|
10111
|
-
const text = import_localization12.LOCALIZED_TEXT[locale].cli;
|
|
10112
|
-
const messages = import_localization12.CLI_MESSAGES[locale].validate;
|
|
10113
|
-
program.command("validate").description(`${text.validateDescription} (10 checks)`).option("--file <path>", messages.fileOption).action((opts) => {
|
|
10114
|
-
const path = resolveContractPath(opts.file, cwd(), locale);
|
|
10115
|
-
const loaded = loadContractFile(path);
|
|
10116
|
-
const report = loaded.report;
|
|
10117
|
-
const publishGate = loaded.publishGate;
|
|
10118
|
-
json(writer, { checks: report.results, publishGate });
|
|
10119
|
-
const fail2 = report.results.filter((r) => r.status === "fail").length;
|
|
10120
|
-
const pending = report.results.filter((r) => r.status === "pending").length;
|
|
10121
|
-
const pass = report.results.filter((r) => r.status === "pass").length;
|
|
10122
|
-
info(
|
|
10123
|
-
writer,
|
|
10124
|
-
`${text.resultLabel}: pass=${pass} fail=${fail2} pending=${pending} (pending=${text.backendPending})`
|
|
10125
|
-
);
|
|
10126
|
-
info(
|
|
10127
|
-
writer,
|
|
10128
|
-
messages.publishGateSummary(publishGate.errors.length, publishGate.warnings.length)
|
|
10129
|
-
);
|
|
10130
|
-
if (!report.ok || !publishGate.ok) {
|
|
10131
|
-
process.exitCode = 1;
|
|
10132
|
-
info(writer, messages.failed);
|
|
10133
|
-
}
|
|
10134
|
-
});
|
|
10135
|
-
}
|
|
10136
|
-
|
|
10137
10312
|
// src/cli.ts
|
|
10138
|
-
function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale = (0,
|
|
10139
|
-
const text =
|
|
10140
|
-
const messages =
|
|
10141
|
-
const scopeRegistrationMessages =
|
|
10313
|
+
function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale = (0, import_localization14.normalizeLocale)(process.env.ANDPIPE_LOCALE ?? process.env.LANG)) {
|
|
10314
|
+
const text = import_localization14.LOCALIZED_TEXT[locale].cli;
|
|
10315
|
+
const messages = import_localization14.CLI_MESSAGES[locale];
|
|
10316
|
+
const scopeRegistrationMessages = import_localization14.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
10142
10317
|
const program = new import_commander.Command();
|
|
10143
|
-
program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption,
|
|
10318
|
+
program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption, import_localization14.DEFAULT_LOCALE).version(readVersion());
|
|
10144
10319
|
registerAuth(program, writer, locale);
|
|
10145
10320
|
registerAuditExport(program, writer, locale);
|
|
10146
10321
|
registerInit(
|
|
@@ -10163,6 +10338,7 @@ function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale
|
|
|
10163
10338
|
registerDoctor(program, writer, locale);
|
|
10164
10339
|
registerLogs(program, writer, locale);
|
|
10165
10340
|
registerTemplate(program, writer, cwd);
|
|
10341
|
+
registerMuse(program, writer, cwd, locale);
|
|
10166
10342
|
registerPublish(
|
|
10167
10343
|
program,
|
|
10168
10344
|
writer,
|
|
@@ -10172,20 +10348,20 @@ function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale
|
|
|
10172
10348
|
void 0,
|
|
10173
10349
|
messages.publish,
|
|
10174
10350
|
scopeRegistrationMessages,
|
|
10175
|
-
|
|
10351
|
+
import_localization14.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES[locale]
|
|
10176
10352
|
);
|
|
10177
10353
|
return program;
|
|
10178
10354
|
}
|
|
10179
10355
|
function localeFromArgv(argv) {
|
|
10180
10356
|
const localeIndex = argv.indexOf("--locale");
|
|
10181
10357
|
if (localeIndex >= 0) {
|
|
10182
|
-
return (0,
|
|
10358
|
+
return (0, import_localization14.normalizeLocale)(argv[localeIndex + 1]);
|
|
10183
10359
|
}
|
|
10184
10360
|
const inlineLocale = argv.find((arg) => arg.startsWith("--locale="));
|
|
10185
10361
|
if (inlineLocale) {
|
|
10186
|
-
return (0,
|
|
10362
|
+
return (0, import_localization14.normalizeLocale)(inlineLocale.slice("--locale=".length));
|
|
10187
10363
|
}
|
|
10188
|
-
return (0,
|
|
10364
|
+
return (0, import_localization14.normalizeLocale)(process.env.ANDPIPE_LOCALE ?? process.env.LANG);
|
|
10189
10365
|
}
|
|
10190
10366
|
async function runCli(argv, writer = defaultWriter) {
|
|
10191
10367
|
await buildProgram(writer, () => process.cwd(), localeFromArgv(argv)).parseAsync(argv);
|