@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/index.cjs
CHANGED
|
@@ -145,7 +145,7 @@ function readVersion() {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// src/cli.ts
|
|
148
|
-
var
|
|
148
|
+
var import_localization14 = require("@andpipes/localization");
|
|
149
149
|
var import_commander = require("commander");
|
|
150
150
|
|
|
151
151
|
// src/commands/audit-export.ts
|
|
@@ -3292,8 +3292,8 @@ async function downloadAuditExportArtifact(input) {
|
|
|
3292
3292
|
} finally {
|
|
3293
3293
|
reader.releaseLock();
|
|
3294
3294
|
}
|
|
3295
|
-
const
|
|
3296
|
-
if (bytes !== authorization.manifest.byteCount ||
|
|
3295
|
+
const sha2563 = hash.digest("hex");
|
|
3296
|
+
if (bytes !== authorization.manifest.byteCount || sha2563 !== authorization.manifest.contentSha256) {
|
|
3297
3297
|
throw new UsageError("\u76E3\u67FB\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u306E\u5185\u5BB9\u304C\u7F72\u540Dmanifest\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093");
|
|
3298
3298
|
}
|
|
3299
3299
|
await file.sync();
|
|
@@ -3312,7 +3312,7 @@ async function downloadAuditExportArtifact(input) {
|
|
|
3312
3312
|
} finally {
|
|
3313
3313
|
await directory.close();
|
|
3314
3314
|
}
|
|
3315
|
-
return { output: canonicalTarget, sha256:
|
|
3315
|
+
return { output: canonicalTarget, sha256: sha2563, bytes };
|
|
3316
3316
|
} finally {
|
|
3317
3317
|
clearTimeout(timeout);
|
|
3318
3318
|
await file.close().catch(() => void 0);
|
|
@@ -8554,23 +8554,250 @@ function registerLogs(program, writer, locale = import_localization8.DEFAULT_LOC
|
|
|
8554
8554
|
});
|
|
8555
8555
|
}
|
|
8556
8556
|
|
|
8557
|
-
// src/commands/
|
|
8558
|
-
var
|
|
8559
|
-
var
|
|
8557
|
+
// src/commands/muse.ts
|
|
8558
|
+
var import_node_crypto12 = require("crypto");
|
|
8559
|
+
var import_node_fs12 = require("fs");
|
|
8560
|
+
var import_node_path13 = require("path");
|
|
8560
8561
|
var import_localization10 = require("@andpipes/localization");
|
|
8561
|
-
var
|
|
8562
|
+
var import_tool_contract9 = require("@andpipes/tool-contract");
|
|
8562
8563
|
|
|
8563
|
-
// src/commands/
|
|
8564
|
-
var
|
|
8564
|
+
// src/commands/validate.ts
|
|
8565
|
+
var import_node_fs11 = require("fs");
|
|
8566
|
+
var import_node_path12 = require("path");
|
|
8565
8567
|
var import_localization9 = require("@andpipes/localization");
|
|
8566
|
-
|
|
8568
|
+
function resolveContractPath(file, cwd, locale = import_localization9.DEFAULT_LOCALE) {
|
|
8569
|
+
const messages = import_localization9.CLI_MESSAGES[locale].validate;
|
|
8570
|
+
if (file) {
|
|
8571
|
+
const abs = (0, import_node_path12.resolve)(cwd, file);
|
|
8572
|
+
if (!(0, import_node_fs11.existsSync)(abs)) {
|
|
8573
|
+
throw new UsageError(messages.fileNotFound(file));
|
|
8574
|
+
}
|
|
8575
|
+
return abs;
|
|
8576
|
+
}
|
|
8577
|
+
for (const candidate of import_tool_contract4.CONTRACT_FILENAMES) {
|
|
8578
|
+
const abs = (0, import_node_path12.resolve)(cwd, candidate);
|
|
8579
|
+
if ((0, import_node_fs11.existsSync)(abs)) {
|
|
8580
|
+
return abs;
|
|
8581
|
+
}
|
|
8582
|
+
}
|
|
8583
|
+
throw new UsageError(messages.defaultFileNotFound(import_tool_contract4.CONTRACT_FILENAMES));
|
|
8584
|
+
}
|
|
8585
|
+
function loadContract(path, locale = import_localization9.DEFAULT_LOCALE) {
|
|
8586
|
+
void locale;
|
|
8587
|
+
return loadContractFile(path).contract;
|
|
8588
|
+
}
|
|
8589
|
+
function registerValidate(program, writer, cwd, locale = import_localization9.DEFAULT_LOCALE) {
|
|
8590
|
+
const text = import_localization9.LOCALIZED_TEXT[locale].cli;
|
|
8591
|
+
const messages = import_localization9.CLI_MESSAGES[locale].validate;
|
|
8592
|
+
program.command("validate").description(`${text.validateDescription} (10 checks)`).option("--file <path>", messages.fileOption).action((opts) => {
|
|
8593
|
+
const path = resolveContractPath(opts.file, cwd(), locale);
|
|
8594
|
+
const loaded = loadContractFile(path);
|
|
8595
|
+
const report = loaded.report;
|
|
8596
|
+
const publishGate = loaded.publishGate;
|
|
8597
|
+
json(writer, { checks: report.results, publishGate });
|
|
8598
|
+
const fail2 = report.results.filter((r) => r.status === "fail").length;
|
|
8599
|
+
const pending = report.results.filter((r) => r.status === "pending").length;
|
|
8600
|
+
const pass = report.results.filter((r) => r.status === "pass").length;
|
|
8601
|
+
info(
|
|
8602
|
+
writer,
|
|
8603
|
+
`${text.resultLabel}: pass=${pass} fail=${fail2} pending=${pending} (pending=${text.backendPending})`
|
|
8604
|
+
);
|
|
8605
|
+
info(
|
|
8606
|
+
writer,
|
|
8607
|
+
messages.publishGateSummary(publishGate.errors.length, publishGate.warnings.length)
|
|
8608
|
+
);
|
|
8609
|
+
if (!report.ok || !publishGate.ok) {
|
|
8610
|
+
process.exitCode = 1;
|
|
8611
|
+
info(writer, messages.failed);
|
|
8612
|
+
}
|
|
8613
|
+
});
|
|
8614
|
+
}
|
|
8615
|
+
|
|
8616
|
+
// src/commands/muse.ts
|
|
8617
|
+
var DEFAULT_MUSE_OUTPUT_DIR = "andpipe-muse-preparation";
|
|
8618
|
+
var OUTPUT_DIR_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
8619
|
+
var MAX_MUSE_FILE_BYTES = 8 * 1024 * 1024;
|
|
8620
|
+
var MUSE_PREPARATION_FILE_KEYS = Object.freeze(
|
|
8621
|
+
{
|
|
8622
|
+
"muse/connector.internal.json": "connector",
|
|
8623
|
+
"muse/openapi.json": "openapi",
|
|
8624
|
+
"muse/SKILL.md": "skill",
|
|
8625
|
+
"muse/setup.md": "setup",
|
|
8626
|
+
"muse/compatibility.json": "compatibility",
|
|
8627
|
+
"provenance/build.json": "provenance"
|
|
8628
|
+
}
|
|
8629
|
+
);
|
|
8630
|
+
var REASON_KEYS = {
|
|
8631
|
+
invalid_input: "invalid_input",
|
|
8632
|
+
selection_required: "selection_required",
|
|
8633
|
+
selection_invalid: "selection_invalid",
|
|
8634
|
+
contract_invalid: "contract_invalid",
|
|
8635
|
+
schema_unsupported: "schema_unsupported",
|
|
8636
|
+
sensitive_content: "sensitive_content",
|
|
8637
|
+
risk_unsupported: "risk_unsupported"
|
|
8638
|
+
};
|
|
8639
|
+
function parseToolNames(value, locale) {
|
|
8640
|
+
const names = (value ?? "").split(",").map((name) => name.trim()).filter((name) => name.length > 0);
|
|
8641
|
+
if (names.length === 0) throw new UsageError(import_localization10.MUSE_SETUP_MESSAGES[locale].cli.toolsRequired);
|
|
8642
|
+
return names;
|
|
8643
|
+
}
|
|
8644
|
+
function parseOutputDir(value, locale) {
|
|
8645
|
+
const output = value ?? DEFAULT_MUSE_OUTPUT_DIR;
|
|
8646
|
+
if (!OUTPUT_DIR_RE.test(output) || output === "." || output === "..") {
|
|
8647
|
+
throw new UsageError(import_localization10.MUSE_SETUP_MESSAGES[locale].cli.outputInvalid);
|
|
8648
|
+
}
|
|
8649
|
+
return output;
|
|
8650
|
+
}
|
|
8651
|
+
function sha2562(text) {
|
|
8652
|
+
return `sha256:${(0, import_node_crypto12.createHash)("sha256").update(text, "utf8").digest("hex")}`;
|
|
8653
|
+
}
|
|
8654
|
+
function createOwnedDirectory(path) {
|
|
8655
|
+
(0, import_node_fs12.mkdirSync)(path, { mode: 448 });
|
|
8656
|
+
return ownedDirectoryIdentity(path);
|
|
8657
|
+
}
|
|
8658
|
+
function ownedDirectoryIdentity(path) {
|
|
8659
|
+
let stat2;
|
|
8660
|
+
try {
|
|
8661
|
+
stat2 = (0, import_node_fs12.lstatSync)(path);
|
|
8662
|
+
} catch {
|
|
8663
|
+
throw new LocalFilePolicyError("local_file_changed", "output directory changed after create");
|
|
8664
|
+
}
|
|
8665
|
+
const identity = localRootIdentityFromStat(stat2, "local_file_changed", "output directory");
|
|
8666
|
+
assertOwnerOnlyLocalWrite(identity, "output directory");
|
|
8667
|
+
return identity;
|
|
8668
|
+
}
|
|
8669
|
+
function errorCode(error) {
|
|
8670
|
+
const code = typeof error === "object" && error !== null ? error.code : null;
|
|
8671
|
+
return typeof code === "string" && /^[A-Z][A-Z0-9_]{1,31}$/u.test(code) ? code : null;
|
|
8672
|
+
}
|
|
8673
|
+
function museWriteOrder(paths) {
|
|
8674
|
+
const isProvenance = (path) => path.startsWith("provenance/");
|
|
8675
|
+
return [...paths].sort(
|
|
8676
|
+
(left, right) => isProvenance(left) === isProvenance(right) ? left < right ? -1 : 1 : isProvenance(left) ? 1 : -1
|
|
8677
|
+
);
|
|
8678
|
+
}
|
|
8679
|
+
function writeBundle(root, output, files, locale) {
|
|
8680
|
+
const messages = import_localization10.MUSE_SETUP_MESSAGES[locale].cli;
|
|
8681
|
+
const target = (0, import_node_path13.join)(root, output);
|
|
8682
|
+
const ordered = museWriteOrder(Object.keys(files));
|
|
8683
|
+
const directoryNames = /* @__PURE__ */ new Set();
|
|
8684
|
+
for (const path of ordered) {
|
|
8685
|
+
const [directory, name, ...rest] = path.split("/");
|
|
8686
|
+
if (!directory || !name || rest.length > 0 || !MUSE_PREPARATION_FILE_KEYS[path]) {
|
|
8687
|
+
throw new LocalFilePolicyError("local_file_invalid", "unexpected preparation file path");
|
|
8688
|
+
}
|
|
8689
|
+
directoryNames.add(directory);
|
|
8690
|
+
}
|
|
8691
|
+
try {
|
|
8692
|
+
(0, import_node_fs12.mkdirSync)(target, { mode: 448 });
|
|
8693
|
+
} catch (error) {
|
|
8694
|
+
const code = errorCode(error);
|
|
8695
|
+
if (code === "EEXIST") throw new UsageError(messages.outputExists(output));
|
|
8696
|
+
throw new UsageError(`${messages.outputCreateFailed(output)}${code ? ` (${code})` : ""}`);
|
|
8697
|
+
}
|
|
8698
|
+
try {
|
|
8699
|
+
const targetIdentity = ownedDirectoryIdentity(target);
|
|
8700
|
+
const directories = /* @__PURE__ */ new Map();
|
|
8701
|
+
for (const directory of directoryNames) {
|
|
8702
|
+
assertLocalRootSecurityIdentity(target, targetIdentity, "muse output directory");
|
|
8703
|
+
directories.set(directory, createOwnedDirectory((0, import_node_path13.join)(target, directory)));
|
|
8704
|
+
}
|
|
8705
|
+
for (const path of ordered) {
|
|
8706
|
+
const [directory, name] = path.split("/");
|
|
8707
|
+
const expected = directories.get(directory);
|
|
8708
|
+
assertLocalRootSecurityIdentity(target, targetIdentity, "muse output directory");
|
|
8709
|
+
const delta = writePrivateFileNoReplace(
|
|
8710
|
+
name,
|
|
8711
|
+
(0, import_node_path13.join)(target, directory),
|
|
8712
|
+
files[path],
|
|
8713
|
+
MAX_MUSE_FILE_BYTES,
|
|
8714
|
+
{ expectedRootIdentity: expected }
|
|
8715
|
+
);
|
|
8716
|
+
directories.set(directory, localRootIdentityWithNlink(expected, expected.nlink + delta));
|
|
8717
|
+
}
|
|
8718
|
+
} catch (error) {
|
|
8719
|
+
const reason = error instanceof LocalFilePolicyError ? ` (${error.reason})` : "";
|
|
8720
|
+
throw new UsageError(`${messages.outputIncomplete(output)}${reason}`);
|
|
8721
|
+
}
|
|
8722
|
+
}
|
|
8723
|
+
function runMusePrepare(options, writer, cwd, locale = import_localization10.DEFAULT_LOCALE) {
|
|
8724
|
+
const messages = import_localization10.MUSE_SETUP_MESSAGES[locale];
|
|
8725
|
+
const toolNames = parseToolNames(options.tools, locale);
|
|
8726
|
+
const output = parseOutputDir(options.output, locale);
|
|
8727
|
+
const anchor = captureLocalRootPath(cwd);
|
|
8728
|
+
const loaded = loadContractFile(resolveContractPath(options.file, cwd, locale));
|
|
8729
|
+
const selected = new Set(toolNames);
|
|
8730
|
+
const result = (0, import_tool_contract9.prepareMuseBundle)(
|
|
8731
|
+
loaded.tools.filter((tool) => selected.has(tool.tool)),
|
|
8732
|
+
{ toolNames }
|
|
8733
|
+
);
|
|
8734
|
+
const flags = {
|
|
8735
|
+
enabled: result.enabled,
|
|
8736
|
+
liveVerified: result.liveVerified,
|
|
8737
|
+
submissionReady: result.submissionReady
|
|
8738
|
+
};
|
|
8739
|
+
if (result.status === "blocked") {
|
|
8740
|
+
const reason = messages.reasons[REASON_KEYS[result.reason]];
|
|
8741
|
+
json(writer, { status: "blocked", reason: result.reason, ...flags });
|
|
8742
|
+
info(writer, messages.cli.blocked);
|
|
8743
|
+
info(writer, `${messages.cli.reasonLabel}: ${reason.cause}`);
|
|
8744
|
+
info(writer, `${messages.cli.fixLabel}: ${reason.fix}`);
|
|
8745
|
+
process.exitCode = 1;
|
|
8746
|
+
return;
|
|
8747
|
+
}
|
|
8748
|
+
assertLocalRootSecurityIdentity(anchor.root, anchor.rootIdentity, "muse output");
|
|
8749
|
+
writeBundle(anchor.root, output, result.files, locale);
|
|
8750
|
+
const paths = Object.keys(result.files).sort();
|
|
8751
|
+
json(writer, {
|
|
8752
|
+
status: "prepared",
|
|
8753
|
+
output,
|
|
8754
|
+
contentHash: result.contentHash,
|
|
8755
|
+
...flags,
|
|
8756
|
+
files: paths.map((path) => ({ path, sha256: sha2562(result.files[path]) }))
|
|
8757
|
+
});
|
|
8758
|
+
info(writer, messages.cli.prepared(output));
|
|
8759
|
+
info(writer, messages.cli.notConnected);
|
|
8760
|
+
for (const path of paths) {
|
|
8761
|
+
const key = MUSE_PREPARATION_FILE_KEYS[path];
|
|
8762
|
+
if (key) info(writer, ` ${output}/${path}: ${messages.files[key]}`);
|
|
8763
|
+
}
|
|
8764
|
+
info(writer, `${messages.cli.statesHeading}:`);
|
|
8765
|
+
for (const key of import_localization10.MUSE_SETUP_STATE_KEYS) {
|
|
8766
|
+
const state = messages.states[key];
|
|
8767
|
+
info(
|
|
8768
|
+
writer,
|
|
8769
|
+
`- ${state.title}: ${key === "prepared" ? messages.cli.preparedNow : state.status}`
|
|
8770
|
+
);
|
|
8771
|
+
}
|
|
8772
|
+
info(writer, messages.cli.nextStep);
|
|
8773
|
+
}
|
|
8774
|
+
function registerMuse(program, writer, cwd, locale = import_localization10.DEFAULT_LOCALE) {
|
|
8775
|
+
const messages = import_localization10.MUSE_SETUP_MESSAGES[locale].cli;
|
|
8776
|
+
const muse = program.command("muse").description(messages.groupDescription);
|
|
8777
|
+
muse.command("prepare").description(messages.prepareDescription).option(
|
|
8778
|
+
"--tools <names>",
|
|
8779
|
+
messages.toolsOption,
|
|
8780
|
+
(value, previous) => previous === void 0 ? value : `${previous},${value}`
|
|
8781
|
+
).option("--file <path>", messages.fileOption).option("--output <dir>", messages.outputOption, DEFAULT_MUSE_OUTPUT_DIR).action((options) => runMusePrepare(options, writer, cwd(), locale));
|
|
8782
|
+
}
|
|
8783
|
+
|
|
8784
|
+
// src/commands/oauth.ts
|
|
8785
|
+
var import_node_crypto14 = require("crypto");
|
|
8786
|
+
var import_node_fs13 = require("fs");
|
|
8787
|
+
var import_localization12 = require("@andpipes/localization");
|
|
8788
|
+
var import_tool_contract11 = require("@andpipes/tool-contract");
|
|
8789
|
+
|
|
8790
|
+
// src/commands/publish.ts
|
|
8791
|
+
var import_node_crypto13 = require("crypto");
|
|
8792
|
+
var import_localization11 = require("@andpipes/localization");
|
|
8793
|
+
var import_tool_contract10 = require("@andpipes/tool-contract");
|
|
8567
8794
|
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;
|
|
8568
8795
|
var SAFE_AP_CODE_RE2 = /^AP_[A-Z0-9_]{1,64}$/u;
|
|
8569
8796
|
var PUBLICATION_RESPONSE_MAX_BYTES = 96 * 1024;
|
|
8570
8797
|
var INITIAL_APPLY_MAX_ATTEMPTS = 3;
|
|
8571
|
-
var DEFAULT_PUBLISH_MESSAGES =
|
|
8572
|
-
var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 =
|
|
8573
|
-
var DEFAULT_SCHEMA_REVIEW_MESSAGES =
|
|
8798
|
+
var DEFAULT_PUBLISH_MESSAGES = import_localization11.CLI_MESSAGES.ja.publish;
|
|
8799
|
+
var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 = import_localization11.OAUTH_SCOPE_REGISTRATION_MESSAGES.ja.cli;
|
|
8800
|
+
var DEFAULT_SCHEMA_REVIEW_MESSAGES = import_localization11.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES.ja;
|
|
8574
8801
|
var REVIEW_PROFILE_REQUEST = Object.freeze({
|
|
8575
8802
|
reviewProfile: CLI_PUBLICATION_REVIEW_PROFILE
|
|
8576
8803
|
});
|
|
@@ -8659,7 +8886,7 @@ function createPublishCommandRuntime(createClient) {
|
|
|
8659
8886
|
return {
|
|
8660
8887
|
createClient,
|
|
8661
8888
|
loadProject: loadDevProject,
|
|
8662
|
-
randomUuid: () => (0,
|
|
8889
|
+
randomUuid: () => (0, import_node_crypto13.randomUUID)(),
|
|
8663
8890
|
monotonicNow: () => Number(process.hrtime.bigint() / 1000000n),
|
|
8664
8891
|
wallNow: () => Date.now(),
|
|
8665
8892
|
sleep: (milliseconds) => new Promise((resolve7) => setTimeout(resolve7, milliseconds))
|
|
@@ -8705,7 +8932,7 @@ function responseInvalid(reason, messages) {
|
|
|
8705
8932
|
}
|
|
8706
8933
|
function assertCanonicalResponseSize(value, reason, messages, maxBytes = PUBLICATION_RESPONSE_MAX_BYTES) {
|
|
8707
8934
|
try {
|
|
8708
|
-
(0,
|
|
8935
|
+
(0, import_tool_contract10.assertCanonicalPublicationSize)(value, maxBytes);
|
|
8709
8936
|
} catch {
|
|
8710
8937
|
throw responseInvalid(reason, messages);
|
|
8711
8938
|
}
|
|
@@ -8714,7 +8941,7 @@ function isCanonicalUuid(value) {
|
|
|
8714
8941
|
return typeof value === "string" && UUID_RE6.test(value);
|
|
8715
8942
|
}
|
|
8716
8943
|
function isCommitment(value) {
|
|
8717
|
-
return typeof value === "string" &&
|
|
8944
|
+
return typeof value === "string" && import_tool_contract10.PUBLICATION_SHA256_COMMITMENT_RE.test(value);
|
|
8718
8945
|
}
|
|
8719
8946
|
function isCanonicalTimestamp(value) {
|
|
8720
8947
|
if (typeof value !== "string" || value.length > 64) return false;
|
|
@@ -8723,12 +8950,12 @@ function isCanonicalTimestamp(value) {
|
|
|
8723
8950
|
}
|
|
8724
8951
|
function isStrictlySorted(values) {
|
|
8725
8952
|
return values.every(
|
|
8726
|
-
(value, index) => index === 0 || (0,
|
|
8953
|
+
(value, index) => index === 0 || (0, import_tool_contract10.comparePublicationUnicodeCodePoints)(values[index - 1], value) < 0
|
|
8727
8954
|
);
|
|
8728
8955
|
}
|
|
8729
8956
|
function parseWarnings(value, messages) {
|
|
8730
8957
|
try {
|
|
8731
|
-
return (0,
|
|
8958
|
+
return (0, import_tool_contract10.parsePublicationWarningsDto)(value);
|
|
8732
8959
|
} catch {
|
|
8733
8960
|
throw responseInvalid("publication_warnings_invalid", messages);
|
|
8734
8961
|
}
|
|
@@ -8775,7 +9002,7 @@ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, p
|
|
|
8775
9002
|
const blockedReasons = plan.blockedReasons;
|
|
8776
9003
|
let safeDiff;
|
|
8777
9004
|
try {
|
|
8778
|
-
safeDiff = (0,
|
|
9005
|
+
safeDiff = (0, import_tool_contract10.parsePublicationSafeDiffDto)({
|
|
8779
9006
|
...profile === 2 ? { reviewProfile: 2 } : {},
|
|
8780
9007
|
tools: plan.tools,
|
|
8781
9008
|
retainedTools: plan.retainedTools,
|
|
@@ -8793,7 +9020,7 @@ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, p
|
|
|
8793
9020
|
throw responseInvalid("publication_plan_tools_order_invalid", messages);
|
|
8794
9021
|
}
|
|
8795
9022
|
const warnings = safeDiff.warnings;
|
|
8796
|
-
const expectedPlanCommitment = (0,
|
|
9023
|
+
const expectedPlanCommitment = (0, import_tool_contract10.publicationCommitment)(profile === 2 ? "planV2" : "plan", {
|
|
8797
9024
|
candidateCommitment,
|
|
8798
9025
|
baseCommitment: plan.baseCommitment,
|
|
8799
9026
|
connectorId,
|
|
@@ -8847,7 +9074,7 @@ function parseToolResults(value, messages) {
|
|
|
8847
9074
|
}
|
|
8848
9075
|
const tools = value.map((candidate) => {
|
|
8849
9076
|
const tool = asRecord4(candidate);
|
|
8850
|
-
if (!tool || !hasExactKeys3(tool, ["toolName", "operation", "toolId", "versionId", "version"]) || !(0,
|
|
9077
|
+
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) {
|
|
8851
9078
|
throw responseInvalid("publication_result_tool_invalid", messages);
|
|
8852
9079
|
}
|
|
8853
9080
|
const operation = tool.operation;
|
|
@@ -8904,7 +9131,7 @@ function parsePublicationResult(value, plan, messages, expectedPublicationId) {
|
|
|
8904
9131
|
function parseConfirmation(value, messages) {
|
|
8905
9132
|
if (value === null) return null;
|
|
8906
9133
|
const confirmation = asRecord4(value);
|
|
8907
|
-
if (!confirmation || !hasExactKeys3(confirmation, ["confirmationId", "signature", "confirmed"]) || !isCanonicalUuid(confirmation.confirmationId) || typeof confirmation.signature !== "string" || !
|
|
9134
|
+
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) {
|
|
8908
9135
|
throw responseInvalid("publication_confirmation_invalid", messages);
|
|
8909
9136
|
}
|
|
8910
9137
|
return {
|
|
@@ -9067,7 +9294,7 @@ function writeSchemaReviewSummary(writer, plan, schemaReviewMessages) {
|
|
|
9067
9294
|
}
|
|
9068
9295
|
}
|
|
9069
9296
|
function candidateNeedsReviewProfile2(candidateContract) {
|
|
9070
|
-
return (0,
|
|
9297
|
+
return (0, import_tool_contract10.selectPublicationReviewProfile)({
|
|
9071
9298
|
requestedProfile: CLI_PUBLICATION_REVIEW_PROFILE,
|
|
9072
9299
|
candidateContract,
|
|
9073
9300
|
currentTools: []
|
|
@@ -9091,11 +9318,11 @@ function freezeJson(value) {
|
|
|
9091
9318
|
return value;
|
|
9092
9319
|
}
|
|
9093
9320
|
function prepareCandidate(project) {
|
|
9094
|
-
const canonical = (0,
|
|
9321
|
+
const canonical = (0, import_tool_contract10.assertCanonicalPublicationSize)(project.contract.root);
|
|
9095
9322
|
const candidateContract = freezeJson(JSON.parse(canonical));
|
|
9096
9323
|
return {
|
|
9097
9324
|
candidateContract,
|
|
9098
|
-
candidateCommitment: (0,
|
|
9325
|
+
candidateCommitment: (0, import_tool_contract10.publicationCommitment)("candidate", candidateContract)
|
|
9099
9326
|
};
|
|
9100
9327
|
}
|
|
9101
9328
|
function loadPublicationProject(loadProject, cwd, messages = DEFAULT_PUBLISH_MESSAGES) {
|
|
@@ -9129,15 +9356,15 @@ function assertManifestProject(project, requestedProjectId, messages = DEFAULT_P
|
|
|
9129
9356
|
}
|
|
9130
9357
|
function buildLocalPublicationCandidate(project, connectorId, messages = DEFAULT_PUBLISH_MESSAGES) {
|
|
9131
9358
|
const candidate = prepareCandidate(project);
|
|
9132
|
-
const localToolNames = project.contract.tools.map((tool) => (0,
|
|
9133
|
-
if (localToolNames.some((name) => !(0,
|
|
9359
|
+
const localToolNames = project.contract.tools.map((tool) => (0, import_tool_contract10.toolName)(tool));
|
|
9360
|
+
if (localToolNames.some((name) => !(0, import_tool_contract10.isSafeToolName)(name))) {
|
|
9134
9361
|
throw new PublishCommandError(
|
|
9135
9362
|
"AP_INPUT_INVALID",
|
|
9136
9363
|
"publication_candidate_tool_invalid",
|
|
9137
9364
|
messages.failure("publication_candidate_tool_invalid")
|
|
9138
9365
|
);
|
|
9139
9366
|
}
|
|
9140
|
-
const expectedToolNames = localToolNames.sort(
|
|
9367
|
+
const expectedToolNames = localToolNames.sort(import_tool_contract10.comparePublicationUnicodeCodePoints);
|
|
9141
9368
|
return {
|
|
9142
9369
|
planRequest: {
|
|
9143
9370
|
environment: "production",
|
|
@@ -9494,8 +9721,8 @@ function isUrl(value) {
|
|
|
9494
9721
|
function field(meta, snake, camel) {
|
|
9495
9722
|
return snake in meta ? meta[snake] : meta[camel];
|
|
9496
9723
|
}
|
|
9497
|
-
function validateOAuthMetadata(meta, locale =
|
|
9498
|
-
const messages =
|
|
9724
|
+
function validateOAuthMetadata(meta, locale = import_localization12.DEFAULT_LOCALE) {
|
|
9725
|
+
const messages = import_localization12.CLI_MESSAGES[locale].oauth;
|
|
9499
9726
|
const results = [];
|
|
9500
9727
|
if (!meta || typeof meta !== "object" || Array.isArray(meta)) {
|
|
9501
9728
|
return {
|
|
@@ -9566,7 +9793,7 @@ var RESOURCE_NOT_FOUND_CODES = /* @__PURE__ */ new Set([
|
|
|
9566
9793
|
"AP_TOOL_VERSION_NOT_FOUND"
|
|
9567
9794
|
]);
|
|
9568
9795
|
function createOAuthScopeRegisterRuntime(createClient = (profile) => createAdminApiClient({ profile })) {
|
|
9569
|
-
return { createClient, loadProject: loadDevProject, randomUuid: () => (0,
|
|
9796
|
+
return { createClient, loadProject: loadDevProject, randomUuid: () => (0, import_node_crypto14.randomUUID)() };
|
|
9570
9797
|
}
|
|
9571
9798
|
var OAuthScopeRegistrationCommandError = class extends Error {
|
|
9572
9799
|
constructor(code, reason, message, status) {
|
|
@@ -9589,9 +9816,9 @@ function parseDraftOption(value, messages) {
|
|
|
9589
9816
|
}
|
|
9590
9817
|
return { toolId, versionId };
|
|
9591
9818
|
}
|
|
9592
|
-
function normalizeOAuthScopeRegisterOptions(options, locale =
|
|
9593
|
-
const messages =
|
|
9594
|
-
const cliMessages =
|
|
9819
|
+
function normalizeOAuthScopeRegisterOptions(options, locale = import_localization12.DEFAULT_LOCALE) {
|
|
9820
|
+
const messages = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
9821
|
+
const cliMessages = import_localization12.CLI_MESSAGES[locale];
|
|
9595
9822
|
const apply = options.apply === true;
|
|
9596
9823
|
if (options.yes === true && !apply) throw new UsageError(messages.yesRequiresApply);
|
|
9597
9824
|
if (apply && options.yes !== true) {
|
|
@@ -9618,8 +9845,8 @@ function normalizeOAuthScopeRegisterOptions(options, locale = import_localizatio
|
|
|
9618
9845
|
if (options.connector !== void 0) throw new UsageError(messages.draftConnectorConflict);
|
|
9619
9846
|
if (options.project === void 0) throw new UsageError(messages.draftRequiresProject);
|
|
9620
9847
|
const projectId = canonicalUuidOption(options.project, "--project", cliMessages.publish);
|
|
9621
|
-
const drafts = rawDrafts.map((value) => parseDraftOption(value, messages)).sort((left, right) => (0,
|
|
9622
|
-
if (drafts.length >
|
|
9848
|
+
const drafts = rawDrafts.map((value) => parseDraftOption(value, messages)).sort((left, right) => (0, import_tool_contract11.comparePublicationUnicodeCodePoints)(left.toolId, right.toolId));
|
|
9849
|
+
if (drafts.length > import_tool_contract11.OAUTH_SCOPE_REGISTRATION_MAX_DRAFTS || drafts.some((draft, index) => index > 0 && drafts[index - 1]?.toolId === draft.toolId)) {
|
|
9623
9850
|
throw new UsageError(messages.draftInvalid);
|
|
9624
9851
|
}
|
|
9625
9852
|
return { kind: "saved_drafts", projectId, drafts, apply, profile };
|
|
@@ -9736,8 +9963,8 @@ async function projectAccessibility(client, projectId, error) {
|
|
|
9736
9963
|
}
|
|
9737
9964
|
}
|
|
9738
9965
|
function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
9739
|
-
const messages =
|
|
9740
|
-
const publishMessages =
|
|
9966
|
+
const messages = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
9967
|
+
const publishMessages = import_localization12.CLI_MESSAGES[locale].publish;
|
|
9741
9968
|
const project = loadPublicationProject(runtime.loadProject, cwd, publishMessages);
|
|
9742
9969
|
const projectId = assertManifestProject(project, normalized.projectId, publishMessages);
|
|
9743
9970
|
const connectorId = normalized.connectorId ?? project.manifest.connector_id;
|
|
@@ -9746,7 +9973,7 @@ function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
|
9746
9973
|
try {
|
|
9747
9974
|
candidate = buildLocalPublicationCandidate(project, connectorId, publishMessages);
|
|
9748
9975
|
} catch (error) {
|
|
9749
|
-
if (error instanceof
|
|
9976
|
+
if (error instanceof import_tool_contract11.PublicationCanonicalizationError && error.reason === "publication_value_too_large") {
|
|
9750
9977
|
throw new OAuthScopeRegistrationCommandError(
|
|
9751
9978
|
"AP_INPUT_INVALID",
|
|
9752
9979
|
"publication_candidate_too_large",
|
|
@@ -9766,8 +9993,8 @@ function localCandidateSource(normalized, cwd, runtime, locale) {
|
|
|
9766
9993
|
expectedToolNames: candidate.expectedToolNames
|
|
9767
9994
|
};
|
|
9768
9995
|
}
|
|
9769
|
-
async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale =
|
|
9770
|
-
const messages =
|
|
9996
|
+
async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale = import_localization12.DEFAULT_LOCALE) {
|
|
9997
|
+
const messages = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale];
|
|
9771
9998
|
const normalized = normalizeOAuthScopeRegisterOptions(options, locale);
|
|
9772
9999
|
const target = normalized.kind === "saved_drafts" ? {
|
|
9773
10000
|
projectId: normalized.projectId,
|
|
@@ -9815,7 +10042,7 @@ async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, local
|
|
|
9815
10042
|
throw new OAuthScopeRegistrationCommandError(
|
|
9816
10043
|
"AP_NETWORK_ERROR",
|
|
9817
10044
|
"secure_random_invalid",
|
|
9818
|
-
|
|
10045
|
+
import_localization12.CLI_MESSAGES[locale].publish.failure("secure_random_invalid")
|
|
9819
10046
|
);
|
|
9820
10047
|
}
|
|
9821
10048
|
let applied;
|
|
@@ -9845,7 +10072,7 @@ function upstreamOAuthWizardUrl(profile, projectId, connectorId) {
|
|
|
9845
10072
|
return url.toString();
|
|
9846
10073
|
}
|
|
9847
10074
|
async function loadOAuthMetadata(opts, locale) {
|
|
9848
|
-
const messages =
|
|
10075
|
+
const messages = import_localization12.CLI_MESSAGES[locale];
|
|
9849
10076
|
if (opts.file && opts.issuer) {
|
|
9850
10077
|
throw new UsageError("--file \u3068 --issuer \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
|
|
9851
10078
|
}
|
|
@@ -9856,13 +10083,13 @@ async function loadOAuthMetadata(opts, locale) {
|
|
|
9856
10083
|
throw new UsageError(messages.oauth.fileRequired);
|
|
9857
10084
|
}
|
|
9858
10085
|
try {
|
|
9859
|
-
return JSON.parse((0,
|
|
10086
|
+
return JSON.parse((0, import_node_fs13.readFileSync)(opts.file, "utf8"));
|
|
9860
10087
|
} catch (error) {
|
|
9861
10088
|
throw new UsageError(messages.oauth.metadataReadFailed(error.message));
|
|
9862
10089
|
}
|
|
9863
10090
|
}
|
|
9864
10091
|
async function runOAuthMetadataValidate(opts, writer, locale) {
|
|
9865
|
-
const messages =
|
|
10092
|
+
const messages = import_localization12.CLI_MESSAGES[locale];
|
|
9866
10093
|
const parsed = await loadOAuthMetadata(opts, locale);
|
|
9867
10094
|
const report = validateOAuthMetadata(parsed, locale);
|
|
9868
10095
|
json(writer, report.results);
|
|
@@ -9873,8 +10100,8 @@ async function runOAuthMetadataValidate(opts, writer, locale) {
|
|
|
9873
10100
|
info(writer, messages.oauth.metadataOk);
|
|
9874
10101
|
}
|
|
9875
10102
|
}
|
|
9876
|
-
function registerOauth(program, writer, locale =
|
|
9877
|
-
const messages =
|
|
10103
|
+
function registerOauth(program, writer, locale = import_localization12.DEFAULT_LOCALE, dependencies = {}) {
|
|
10104
|
+
const messages = import_localization12.CLI_MESSAGES[locale];
|
|
9878
10105
|
const oauth = program.command("oauth").description(messages.oauth.commandDescription);
|
|
9879
10106
|
oauth.command("init").description(messages.oauth.initDescription).requiredOption("--provider <name>", messages.oauth.providerOption).action((opts) => {
|
|
9880
10107
|
info(writer, messages.oauth.templateHeading(opts.provider));
|
|
@@ -9917,7 +10144,7 @@ function registerOauth(program, writer, locale = import_localization10.DEFAULT_L
|
|
|
9917
10144
|
});
|
|
9918
10145
|
json(writer, result);
|
|
9919
10146
|
});
|
|
9920
|
-
const registration =
|
|
10147
|
+
const registration = import_localization12.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
9921
10148
|
const scopeRegisterRuntime = dependencies.scopeRegisterRuntime ?? createOAuthScopeRegisterRuntime();
|
|
9922
10149
|
const cwd = dependencies.cwd ?? (() => process.cwd());
|
|
9923
10150
|
scopes.command("register").description(registration.commandDescription).option("--project <project-uuid>", registration.projectOption).option("--connector <connector-uuid>", registration.connectorOption).option(
|
|
@@ -10021,11 +10248,11 @@ function registerOauth(program, writer, locale = import_localization10.DEFAULT_L
|
|
|
10021
10248
|
}
|
|
10022
10249
|
|
|
10023
10250
|
// src/commands/openapi.ts
|
|
10024
|
-
var
|
|
10025
|
-
var
|
|
10026
|
-
var
|
|
10251
|
+
var import_node_crypto15 = require("crypto");
|
|
10252
|
+
var import_node_path14 = require("path");
|
|
10253
|
+
var import_tool_contract12 = require("@andpipes/tool-contract");
|
|
10027
10254
|
function createOpenApiImportRuntime(createClient = (profile) => createAdminApiClient({ profile })) {
|
|
10028
|
-
return { createClient, idempotencyKey:
|
|
10255
|
+
return { createClient, idempotencyKey: import_node_crypto15.randomUUID };
|
|
10029
10256
|
}
|
|
10030
10257
|
function normalizedOptions(options) {
|
|
10031
10258
|
if (!options.file || !options.project || !options.connector) {
|
|
@@ -10081,8 +10308,8 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
10081
10308
|
if (normalized.apply && !/^[a-f0-9]{64}$/.test(normalized.planCommitment ?? "")) {
|
|
10082
10309
|
throw new UsageError("--apply \u306B\u306Fpreview\u3067\u5F97\u305F --plan-commitment \u304C\u5FC5\u9808\u3067\u3059");
|
|
10083
10310
|
}
|
|
10084
|
-
const snapshot = readBoundedLocalFileSnapshot((0,
|
|
10085
|
-
maxBytes:
|
|
10311
|
+
const snapshot = readBoundedLocalFileSnapshot((0, import_node_path14.resolve)(cwd, normalized.file), {
|
|
10312
|
+
maxBytes: import_tool_contract12.OPENAPI_IMPORT_MAX_SOURCE_BYTES,
|
|
10086
10313
|
root: cwd
|
|
10087
10314
|
});
|
|
10088
10315
|
const baseRequest = {
|
|
@@ -10103,7 +10330,7 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
10103
10330
|
if (normalized.sideEffectFree.length > 0) {
|
|
10104
10331
|
if (normalized.apply) {
|
|
10105
10332
|
try {
|
|
10106
|
-
const unclassified = (0,
|
|
10333
|
+
const unclassified = (0, import_tool_contract12.importOpenApi)(snapshot.text, {
|
|
10107
10334
|
format: normalized.format,
|
|
10108
10335
|
baseUrl: normalized.baseUrl,
|
|
10109
10336
|
serviceName: normalized.serviceName,
|
|
@@ -10114,7 +10341,7 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
|
|
|
10114
10341
|
unclassified.operations
|
|
10115
10342
|
);
|
|
10116
10343
|
} catch (error) {
|
|
10117
|
-
if (error instanceof
|
|
10344
|
+
if (error instanceof import_tool_contract12.OpenApiImportError) {
|
|
10118
10345
|
throw new UsageError(`OpenAPI\u304B\u3089Tool Contract\u3092\u751F\u6210\u3067\u304D\u307E\u305B\u3093: ${error.message}`);
|
|
10119
10346
|
}
|
|
10120
10347
|
throw error;
|
|
@@ -10169,15 +10396,15 @@ function registerOpenApi(program, writer, cwd, runtime = createOpenApiImportRunt
|
|
|
10169
10396
|
}
|
|
10170
10397
|
|
|
10171
10398
|
// src/commands/review-package.ts
|
|
10172
|
-
var
|
|
10399
|
+
var import_localization13 = require("@andpipes/localization");
|
|
10173
10400
|
var TARGETS = ["chatgpt", "claude", "generic_mcp"];
|
|
10174
|
-
function assertTarget(value, locale =
|
|
10401
|
+
function assertTarget(value, locale = import_localization13.DEFAULT_LOCALE) {
|
|
10175
10402
|
if (!TARGETS.includes(value)) {
|
|
10176
|
-
throw new UsageError(
|
|
10403
|
+
throw new UsageError(import_localization13.CLI_MESSAGES[locale].reviewPackage.invalidTarget(value, TARGETS));
|
|
10177
10404
|
}
|
|
10178
10405
|
}
|
|
10179
|
-
function registerReviewPackage(program, writer, locale =
|
|
10180
|
-
const messages =
|
|
10406
|
+
function registerReviewPackage(program, writer, locale = import_localization13.DEFAULT_LOCALE, cwd = () => process.cwd()) {
|
|
10407
|
+
const messages = import_localization13.CLI_MESSAGES[locale];
|
|
10181
10408
|
const reviewPackage = program.command("review-package").description(messages.reviewPackage.commandDescription);
|
|
10182
10409
|
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(
|
|
10183
10410
|
"--from-template",
|
|
@@ -10238,65 +10465,13 @@ function registerReviewPackage(program, writer, locale = import_localization11.D
|
|
|
10238
10465
|
});
|
|
10239
10466
|
}
|
|
10240
10467
|
|
|
10241
|
-
// src/commands/validate.ts
|
|
10242
|
-
var import_node_fs12 = require("fs");
|
|
10243
|
-
var import_node_path13 = require("path");
|
|
10244
|
-
var import_localization12 = require("@andpipes/localization");
|
|
10245
|
-
function resolveContractPath(file, cwd, locale = import_localization12.DEFAULT_LOCALE) {
|
|
10246
|
-
const messages = import_localization12.CLI_MESSAGES[locale].validate;
|
|
10247
|
-
if (file) {
|
|
10248
|
-
const abs = (0, import_node_path13.resolve)(cwd, file);
|
|
10249
|
-
if (!(0, import_node_fs12.existsSync)(abs)) {
|
|
10250
|
-
throw new UsageError(messages.fileNotFound(file));
|
|
10251
|
-
}
|
|
10252
|
-
return abs;
|
|
10253
|
-
}
|
|
10254
|
-
for (const candidate of import_tool_contract4.CONTRACT_FILENAMES) {
|
|
10255
|
-
const abs = (0, import_node_path13.resolve)(cwd, candidate);
|
|
10256
|
-
if ((0, import_node_fs12.existsSync)(abs)) {
|
|
10257
|
-
return abs;
|
|
10258
|
-
}
|
|
10259
|
-
}
|
|
10260
|
-
throw new UsageError(messages.defaultFileNotFound(import_tool_contract4.CONTRACT_FILENAMES));
|
|
10261
|
-
}
|
|
10262
|
-
function loadContract(path, locale = import_localization12.DEFAULT_LOCALE) {
|
|
10263
|
-
void locale;
|
|
10264
|
-
return loadContractFile(path).contract;
|
|
10265
|
-
}
|
|
10266
|
-
function registerValidate(program, writer, cwd, locale = import_localization12.DEFAULT_LOCALE) {
|
|
10267
|
-
const text = import_localization12.LOCALIZED_TEXT[locale].cli;
|
|
10268
|
-
const messages = import_localization12.CLI_MESSAGES[locale].validate;
|
|
10269
|
-
program.command("validate").description(`${text.validateDescription} (10 checks)`).option("--file <path>", messages.fileOption).action((opts) => {
|
|
10270
|
-
const path = resolveContractPath(opts.file, cwd(), locale);
|
|
10271
|
-
const loaded = loadContractFile(path);
|
|
10272
|
-
const report = loaded.report;
|
|
10273
|
-
const publishGate = loaded.publishGate;
|
|
10274
|
-
json(writer, { checks: report.results, publishGate });
|
|
10275
|
-
const fail2 = report.results.filter((r) => r.status === "fail").length;
|
|
10276
|
-
const pending = report.results.filter((r) => r.status === "pending").length;
|
|
10277
|
-
const pass = report.results.filter((r) => r.status === "pass").length;
|
|
10278
|
-
info(
|
|
10279
|
-
writer,
|
|
10280
|
-
`${text.resultLabel}: pass=${pass} fail=${fail2} pending=${pending} (pending=${text.backendPending})`
|
|
10281
|
-
);
|
|
10282
|
-
info(
|
|
10283
|
-
writer,
|
|
10284
|
-
messages.publishGateSummary(publishGate.errors.length, publishGate.warnings.length)
|
|
10285
|
-
);
|
|
10286
|
-
if (!report.ok || !publishGate.ok) {
|
|
10287
|
-
process.exitCode = 1;
|
|
10288
|
-
info(writer, messages.failed);
|
|
10289
|
-
}
|
|
10290
|
-
});
|
|
10291
|
-
}
|
|
10292
|
-
|
|
10293
10468
|
// src/cli.ts
|
|
10294
|
-
function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale = (0,
|
|
10295
|
-
const text =
|
|
10296
|
-
const messages =
|
|
10297
|
-
const scopeRegistrationMessages =
|
|
10469
|
+
function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale = (0, import_localization14.normalizeLocale)(process.env.ANDPIPE_LOCALE ?? process.env.LANG)) {
|
|
10470
|
+
const text = import_localization14.LOCALIZED_TEXT[locale].cli;
|
|
10471
|
+
const messages = import_localization14.CLI_MESSAGES[locale];
|
|
10472
|
+
const scopeRegistrationMessages = import_localization14.OAUTH_SCOPE_REGISTRATION_MESSAGES[locale].cli;
|
|
10298
10473
|
const program = new import_commander.Command();
|
|
10299
|
-
program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption,
|
|
10474
|
+
program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption, import_localization14.DEFAULT_LOCALE).version(readVersion());
|
|
10300
10475
|
registerAuth(program, writer, locale);
|
|
10301
10476
|
registerAuditExport(program, writer, locale);
|
|
10302
10477
|
registerInit(
|
|
@@ -10319,6 +10494,7 @@ function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale
|
|
|
10319
10494
|
registerDoctor(program, writer, locale);
|
|
10320
10495
|
registerLogs(program, writer, locale);
|
|
10321
10496
|
registerTemplate(program, writer, cwd);
|
|
10497
|
+
registerMuse(program, writer, cwd, locale);
|
|
10322
10498
|
registerPublish(
|
|
10323
10499
|
program,
|
|
10324
10500
|
writer,
|
|
@@ -10328,20 +10504,20 @@ function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale
|
|
|
10328
10504
|
void 0,
|
|
10329
10505
|
messages.publish,
|
|
10330
10506
|
scopeRegistrationMessages,
|
|
10331
|
-
|
|
10507
|
+
import_localization14.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES[locale]
|
|
10332
10508
|
);
|
|
10333
10509
|
return program;
|
|
10334
10510
|
}
|
|
10335
10511
|
function localeFromArgv(argv) {
|
|
10336
10512
|
const localeIndex = argv.indexOf("--locale");
|
|
10337
10513
|
if (localeIndex >= 0) {
|
|
10338
|
-
return (0,
|
|
10514
|
+
return (0, import_localization14.normalizeLocale)(argv[localeIndex + 1]);
|
|
10339
10515
|
}
|
|
10340
10516
|
const inlineLocale = argv.find((arg) => arg.startsWith("--locale="));
|
|
10341
10517
|
if (inlineLocale) {
|
|
10342
|
-
return (0,
|
|
10518
|
+
return (0, import_localization14.normalizeLocale)(inlineLocale.slice("--locale=".length));
|
|
10343
10519
|
}
|
|
10344
|
-
return (0,
|
|
10520
|
+
return (0, import_localization14.normalizeLocale)(process.env.ANDPIPE_LOCALE ?? process.env.LANG);
|
|
10345
10521
|
}
|
|
10346
10522
|
async function runCli(argv, writer = defaultWriter) {
|
|
10347
10523
|
await buildProgram(writer, () => process.cwd(), localeFromArgv(argv)).parseAsync(argv);
|