@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/dist/bin.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  ConfirmationRequiredError,
4
4
  maskSecrets,
5
5
  runCli
6
- } from "./chunk-2PG5NEI2.js";
6
+ } from "./chunk-TTC7UVIV.js";
7
7
  import "./chunk-7LSHSW4Q.js";
8
8
 
9
9
  // src/bin.ts
@@ -32,7 +32,7 @@ function readVersion() {
32
32
  // src/cli.ts
33
33
  import {
34
34
  CLI_MESSAGES as CLI_MESSAGES12,
35
- DEFAULT_LOCALE as DEFAULT_LOCALE10,
35
+ DEFAULT_LOCALE as DEFAULT_LOCALE11,
36
36
  LOCALIZED_TEXT as LOCALIZED_TEXT4,
37
37
  normalizeLocale,
38
38
  OAUTH_SCOPE_REGISTRATION_MESSAGES as OAUTH_SCOPE_REGISTRATION_MESSAGES4,
@@ -3225,8 +3225,8 @@ async function downloadAuditExportArtifact(input) {
3225
3225
  } finally {
3226
3226
  reader.releaseLock();
3227
3227
  }
3228
- const sha2562 = hash.digest("hex");
3229
- if (bytes !== authorization.manifest.byteCount || sha2562 !== authorization.manifest.contentSha256) {
3228
+ const sha2563 = hash.digest("hex");
3229
+ if (bytes !== authorization.manifest.byteCount || sha2563 !== authorization.manifest.contentSha256) {
3230
3230
  throw new UsageError("\u76E3\u67FB\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u306E\u5185\u5BB9\u304C\u7F72\u540Dmanifest\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093");
3231
3231
  }
3232
3232
  await file.sync();
@@ -3245,7 +3245,7 @@ async function downloadAuditExportArtifact(input) {
3245
3245
  } finally {
3246
3246
  await directory.close();
3247
3247
  }
3248
- return { output: canonicalTarget, sha256: sha2562, bytes };
3248
+ return { output: canonicalTarget, sha256: sha2563, bytes };
3249
3249
  } finally {
3250
3250
  clearTimeout(timeout);
3251
3251
  await file.close().catch(() => void 0);
@@ -7902,12 +7902,247 @@ function registerLogs(program, writer, locale = DEFAULT_LOCALE6) {
7902
7902
  });
7903
7903
  }
7904
7904
 
7905
+ // src/commands/muse.ts
7906
+ import { createHash as createHash4 } from "crypto";
7907
+ import { lstatSync as lstatSync6, mkdirSync as mkdirSync2 } from "fs";
7908
+ import { join as join6 } from "path";
7909
+ import {
7910
+ DEFAULT_LOCALE as DEFAULT_LOCALE8,
7911
+ MUSE_SETUP_MESSAGES,
7912
+ MUSE_SETUP_STATE_KEYS
7913
+ } from "@andpipes/localization";
7914
+ import { prepareMuseBundle } from "@andpipes/tool-contract";
7915
+
7916
+ // src/commands/validate.ts
7917
+ import { existsSync as existsSync2 } from "fs";
7918
+ import { resolve as resolve4 } from "path";
7919
+ import {
7920
+ CLI_MESSAGES as CLI_MESSAGES8,
7921
+ DEFAULT_LOCALE as DEFAULT_LOCALE7,
7922
+ LOCALIZED_TEXT as LOCALIZED_TEXT3
7923
+ } from "@andpipes/localization";
7924
+ function resolveContractPath(file, cwd, locale = DEFAULT_LOCALE7) {
7925
+ const messages = CLI_MESSAGES8[locale].validate;
7926
+ if (file) {
7927
+ const abs = resolve4(cwd, file);
7928
+ if (!existsSync2(abs)) {
7929
+ throw new UsageError(messages.fileNotFound(file));
7930
+ }
7931
+ return abs;
7932
+ }
7933
+ for (const candidate of CONTRACT_FILENAMES) {
7934
+ const abs = resolve4(cwd, candidate);
7935
+ if (existsSync2(abs)) {
7936
+ return abs;
7937
+ }
7938
+ }
7939
+ throw new UsageError(messages.defaultFileNotFound(CONTRACT_FILENAMES));
7940
+ }
7941
+ function loadContract(path, locale = DEFAULT_LOCALE7) {
7942
+ void locale;
7943
+ return loadContractFile(path).contract;
7944
+ }
7945
+ function registerValidate(program, writer, cwd, locale = DEFAULT_LOCALE7) {
7946
+ const text = LOCALIZED_TEXT3[locale].cli;
7947
+ const messages = CLI_MESSAGES8[locale].validate;
7948
+ program.command("validate").description(`${text.validateDescription} (10 checks)`).option("--file <path>", messages.fileOption).action((opts) => {
7949
+ const path = resolveContractPath(opts.file, cwd(), locale);
7950
+ const loaded = loadContractFile(path);
7951
+ const report = loaded.report;
7952
+ const publishGate = loaded.publishGate;
7953
+ json(writer, { checks: report.results, publishGate });
7954
+ const fail2 = report.results.filter((r) => r.status === "fail").length;
7955
+ const pending = report.results.filter((r) => r.status === "pending").length;
7956
+ const pass = report.results.filter((r) => r.status === "pass").length;
7957
+ info(
7958
+ writer,
7959
+ `${text.resultLabel}: pass=${pass} fail=${fail2} pending=${pending} (pending=${text.backendPending})`
7960
+ );
7961
+ info(
7962
+ writer,
7963
+ messages.publishGateSummary(publishGate.errors.length, publishGate.warnings.length)
7964
+ );
7965
+ if (!report.ok || !publishGate.ok) {
7966
+ process.exitCode = 1;
7967
+ info(writer, messages.failed);
7968
+ }
7969
+ });
7970
+ }
7971
+
7972
+ // src/commands/muse.ts
7973
+ var DEFAULT_MUSE_OUTPUT_DIR = "andpipe-muse-preparation";
7974
+ var OUTPUT_DIR_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
7975
+ var MAX_MUSE_FILE_BYTES = 8 * 1024 * 1024;
7976
+ var MUSE_PREPARATION_FILE_KEYS = Object.freeze(
7977
+ {
7978
+ "muse/connector.internal.json": "connector",
7979
+ "muse/openapi.json": "openapi",
7980
+ "muse/SKILL.md": "skill",
7981
+ "muse/setup.md": "setup",
7982
+ "muse/compatibility.json": "compatibility",
7983
+ "provenance/build.json": "provenance"
7984
+ }
7985
+ );
7986
+ var REASON_KEYS = {
7987
+ invalid_input: "invalid_input",
7988
+ selection_required: "selection_required",
7989
+ selection_invalid: "selection_invalid",
7990
+ contract_invalid: "contract_invalid",
7991
+ schema_unsupported: "schema_unsupported",
7992
+ sensitive_content: "sensitive_content",
7993
+ risk_unsupported: "risk_unsupported"
7994
+ };
7995
+ function parseToolNames(value, locale) {
7996
+ const names = (value ?? "").split(",").map((name) => name.trim()).filter((name) => name.length > 0);
7997
+ if (names.length === 0) throw new UsageError(MUSE_SETUP_MESSAGES[locale].cli.toolsRequired);
7998
+ return names;
7999
+ }
8000
+ function parseOutputDir(value, locale) {
8001
+ const output = value ?? DEFAULT_MUSE_OUTPUT_DIR;
8002
+ if (!OUTPUT_DIR_RE.test(output) || output === "." || output === "..") {
8003
+ throw new UsageError(MUSE_SETUP_MESSAGES[locale].cli.outputInvalid);
8004
+ }
8005
+ return output;
8006
+ }
8007
+ function sha2562(text) {
8008
+ return `sha256:${createHash4("sha256").update(text, "utf8").digest("hex")}`;
8009
+ }
8010
+ function createOwnedDirectory(path) {
8011
+ mkdirSync2(path, { mode: 448 });
8012
+ return ownedDirectoryIdentity(path);
8013
+ }
8014
+ function ownedDirectoryIdentity(path) {
8015
+ let stat2;
8016
+ try {
8017
+ stat2 = lstatSync6(path);
8018
+ } catch {
8019
+ throw new LocalFilePolicyError("local_file_changed", "output directory changed after create");
8020
+ }
8021
+ const identity = localRootIdentityFromStat(stat2, "local_file_changed", "output directory");
8022
+ assertOwnerOnlyLocalWrite(identity, "output directory");
8023
+ return identity;
8024
+ }
8025
+ function errorCode(error) {
8026
+ const code = typeof error === "object" && error !== null ? error.code : null;
8027
+ return typeof code === "string" && /^[A-Z][A-Z0-9_]{1,31}$/u.test(code) ? code : null;
8028
+ }
8029
+ function museWriteOrder(paths) {
8030
+ const isProvenance = (path) => path.startsWith("provenance/");
8031
+ return [...paths].sort(
8032
+ (left, right) => isProvenance(left) === isProvenance(right) ? left < right ? -1 : 1 : isProvenance(left) ? 1 : -1
8033
+ );
8034
+ }
8035
+ function writeBundle(root, output, files, locale) {
8036
+ const messages = MUSE_SETUP_MESSAGES[locale].cli;
8037
+ const target = join6(root, output);
8038
+ const ordered = museWriteOrder(Object.keys(files));
8039
+ const directoryNames = /* @__PURE__ */ new Set();
8040
+ for (const path of ordered) {
8041
+ const [directory, name, ...rest] = path.split("/");
8042
+ if (!directory || !name || rest.length > 0 || !MUSE_PREPARATION_FILE_KEYS[path]) {
8043
+ throw new LocalFilePolicyError("local_file_invalid", "unexpected preparation file path");
8044
+ }
8045
+ directoryNames.add(directory);
8046
+ }
8047
+ try {
8048
+ mkdirSync2(target, { mode: 448 });
8049
+ } catch (error) {
8050
+ const code = errorCode(error);
8051
+ if (code === "EEXIST") throw new UsageError(messages.outputExists(output));
8052
+ throw new UsageError(`${messages.outputCreateFailed(output)}${code ? ` (${code})` : ""}`);
8053
+ }
8054
+ try {
8055
+ const targetIdentity = ownedDirectoryIdentity(target);
8056
+ const directories = /* @__PURE__ */ new Map();
8057
+ for (const directory of directoryNames) {
8058
+ assertLocalRootSecurityIdentity(target, targetIdentity, "muse output directory");
8059
+ directories.set(directory, createOwnedDirectory(join6(target, directory)));
8060
+ }
8061
+ for (const path of ordered) {
8062
+ const [directory, name] = path.split("/");
8063
+ const expected = directories.get(directory);
8064
+ assertLocalRootSecurityIdentity(target, targetIdentity, "muse output directory");
8065
+ const delta = writePrivateFileNoReplace(
8066
+ name,
8067
+ join6(target, directory),
8068
+ files[path],
8069
+ MAX_MUSE_FILE_BYTES,
8070
+ { expectedRootIdentity: expected }
8071
+ );
8072
+ directories.set(directory, localRootIdentityWithNlink(expected, expected.nlink + delta));
8073
+ }
8074
+ } catch (error) {
8075
+ const reason = error instanceof LocalFilePolicyError ? ` (${error.reason})` : "";
8076
+ throw new UsageError(`${messages.outputIncomplete(output)}${reason}`);
8077
+ }
8078
+ }
8079
+ function runMusePrepare(options, writer, cwd, locale = DEFAULT_LOCALE8) {
8080
+ const messages = MUSE_SETUP_MESSAGES[locale];
8081
+ const toolNames = parseToolNames(options.tools, locale);
8082
+ const output = parseOutputDir(options.output, locale);
8083
+ const anchor = captureLocalRootPath(cwd);
8084
+ const loaded = loadContractFile(resolveContractPath(options.file, cwd, locale));
8085
+ const selected = new Set(toolNames);
8086
+ const result = prepareMuseBundle(
8087
+ loaded.tools.filter((tool) => selected.has(tool.tool)),
8088
+ { toolNames }
8089
+ );
8090
+ const flags = {
8091
+ enabled: result.enabled,
8092
+ liveVerified: result.liveVerified,
8093
+ submissionReady: result.submissionReady
8094
+ };
8095
+ if (result.status === "blocked") {
8096
+ const reason = messages.reasons[REASON_KEYS[result.reason]];
8097
+ json(writer, { status: "blocked", reason: result.reason, ...flags });
8098
+ info(writer, messages.cli.blocked);
8099
+ info(writer, `${messages.cli.reasonLabel}: ${reason.cause}`);
8100
+ info(writer, `${messages.cli.fixLabel}: ${reason.fix}`);
8101
+ process.exitCode = 1;
8102
+ return;
8103
+ }
8104
+ assertLocalRootSecurityIdentity(anchor.root, anchor.rootIdentity, "muse output");
8105
+ writeBundle(anchor.root, output, result.files, locale);
8106
+ const paths = Object.keys(result.files).sort();
8107
+ json(writer, {
8108
+ status: "prepared",
8109
+ output,
8110
+ contentHash: result.contentHash,
8111
+ ...flags,
8112
+ files: paths.map((path) => ({ path, sha256: sha2562(result.files[path]) }))
8113
+ });
8114
+ info(writer, messages.cli.prepared(output));
8115
+ info(writer, messages.cli.notConnected);
8116
+ for (const path of paths) {
8117
+ const key = MUSE_PREPARATION_FILE_KEYS[path];
8118
+ if (key) info(writer, ` ${output}/${path}: ${messages.files[key]}`);
8119
+ }
8120
+ info(writer, `${messages.cli.statesHeading}:`);
8121
+ for (const key of MUSE_SETUP_STATE_KEYS) {
8122
+ const state = messages.states[key];
8123
+ info(
8124
+ writer,
8125
+ `- ${state.title}: ${key === "prepared" ? messages.cli.preparedNow : state.status}`
8126
+ );
8127
+ }
8128
+ info(writer, messages.cli.nextStep);
8129
+ }
8130
+ function registerMuse(program, writer, cwd, locale = DEFAULT_LOCALE8) {
8131
+ const messages = MUSE_SETUP_MESSAGES[locale].cli;
8132
+ const muse = program.command("muse").description(messages.groupDescription);
8133
+ muse.command("prepare").description(messages.prepareDescription).option(
8134
+ "--tools <names>",
8135
+ messages.toolsOption,
8136
+ (value, previous) => previous === void 0 ? value : `${previous},${value}`
8137
+ ).option("--file <path>", messages.fileOption).option("--output <dir>", messages.outputOption, DEFAULT_MUSE_OUTPUT_DIR).action((options) => runMusePrepare(options, writer, cwd(), locale));
8138
+ }
8139
+
7905
8140
  // src/commands/oauth.ts
7906
8141
  import { randomUUID as randomUUID7 } from "crypto";
7907
8142
  import { readFileSync as readFileSync2 } from "fs";
7908
8143
  import {
7909
- CLI_MESSAGES as CLI_MESSAGES9,
7910
- DEFAULT_LOCALE as DEFAULT_LOCALE7,
8144
+ CLI_MESSAGES as CLI_MESSAGES10,
8145
+ DEFAULT_LOCALE as DEFAULT_LOCALE9,
7911
8146
  OAUTH_SCOPE_REGISTRATION_MESSAGES as OAUTH_SCOPE_REGISTRATION_MESSAGES3
7912
8147
  } from "@andpipes/localization";
7913
8148
  import {
@@ -7919,7 +8154,7 @@ import {
7919
8154
  // src/commands/publish.ts
7920
8155
  import { randomUUID as randomUUID6 } from "crypto";
7921
8156
  import {
7922
- CLI_MESSAGES as CLI_MESSAGES8,
8157
+ CLI_MESSAGES as CLI_MESSAGES9,
7923
8158
  OAUTH_SCOPE_REGISTRATION_MESSAGES as OAUTH_SCOPE_REGISTRATION_MESSAGES2,
7924
8159
  PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES
7925
8160
  } from "@andpipes/localization";
@@ -7939,7 +8174,7 @@ var UUID_RE6 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9
7939
8174
  var SAFE_AP_CODE_RE2 = /^AP_[A-Z0-9_]{1,64}$/u;
7940
8175
  var PUBLICATION_RESPONSE_MAX_BYTES = 96 * 1024;
7941
8176
  var INITIAL_APPLY_MAX_ATTEMPTS = 3;
7942
- var DEFAULT_PUBLISH_MESSAGES = CLI_MESSAGES8.ja.publish;
8177
+ var DEFAULT_PUBLISH_MESSAGES = CLI_MESSAGES9.ja.publish;
7943
8178
  var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 = OAUTH_SCOPE_REGISTRATION_MESSAGES2.ja.cli;
7944
8179
  var DEFAULT_SCHEMA_REVIEW_MESSAGES = PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES.ja;
7945
8180
  var REVIEW_PROFILE_REQUEST = Object.freeze({
@@ -8865,8 +9100,8 @@ function isUrl(value) {
8865
9100
  function field(meta, snake, camel) {
8866
9101
  return snake in meta ? meta[snake] : meta[camel];
8867
9102
  }
8868
- function validateOAuthMetadata(meta, locale = DEFAULT_LOCALE7) {
8869
- const messages = CLI_MESSAGES9[locale].oauth;
9103
+ function validateOAuthMetadata(meta, locale = DEFAULT_LOCALE9) {
9104
+ const messages = CLI_MESSAGES10[locale].oauth;
8870
9105
  const results = [];
8871
9106
  if (!meta || typeof meta !== "object" || Array.isArray(meta)) {
8872
9107
  return {
@@ -8960,9 +9195,9 @@ function parseDraftOption(value, messages) {
8960
9195
  }
8961
9196
  return { toolId, versionId };
8962
9197
  }
8963
- function normalizeOAuthScopeRegisterOptions(options, locale = DEFAULT_LOCALE7) {
9198
+ function normalizeOAuthScopeRegisterOptions(options, locale = DEFAULT_LOCALE9) {
8964
9199
  const messages = OAUTH_SCOPE_REGISTRATION_MESSAGES3[locale].cli;
8965
- const cliMessages = CLI_MESSAGES9[locale];
9200
+ const cliMessages = CLI_MESSAGES10[locale];
8966
9201
  const apply = options.apply === true;
8967
9202
  if (options.yes === true && !apply) throw new UsageError(messages.yesRequiresApply);
8968
9203
  if (apply && options.yes !== true) {
@@ -9108,7 +9343,7 @@ async function projectAccessibility(client, projectId, error) {
9108
9343
  }
9109
9344
  function localCandidateSource(normalized, cwd, runtime, locale) {
9110
9345
  const messages = OAUTH_SCOPE_REGISTRATION_MESSAGES3[locale].cli;
9111
- const publishMessages = CLI_MESSAGES9[locale].publish;
9346
+ const publishMessages = CLI_MESSAGES10[locale].publish;
9112
9347
  const project = loadPublicationProject(runtime.loadProject, cwd, publishMessages);
9113
9348
  const projectId = assertManifestProject(project, normalized.projectId, publishMessages);
9114
9349
  const connectorId = normalized.connectorId ?? project.manifest.connector_id;
@@ -9137,7 +9372,7 @@ function localCandidateSource(normalized, cwd, runtime, locale) {
9137
9372
  expectedToolNames: candidate.expectedToolNames
9138
9373
  };
9139
9374
  }
9140
- async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale = DEFAULT_LOCALE7) {
9375
+ async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, locale = DEFAULT_LOCALE9) {
9141
9376
  const messages = OAUTH_SCOPE_REGISTRATION_MESSAGES3[locale];
9142
9377
  const normalized = normalizeOAuthScopeRegisterOptions(options, locale);
9143
9378
  const target = normalized.kind === "saved_drafts" ? {
@@ -9186,7 +9421,7 @@ async function runOAuthScopeRegisterCommand(options, writer, cwd, runtime, local
9186
9421
  throw new OAuthScopeRegistrationCommandError(
9187
9422
  "AP_NETWORK_ERROR",
9188
9423
  "secure_random_invalid",
9189
- CLI_MESSAGES9[locale].publish.failure("secure_random_invalid")
9424
+ CLI_MESSAGES10[locale].publish.failure("secure_random_invalid")
9190
9425
  );
9191
9426
  }
9192
9427
  let applied;
@@ -9216,7 +9451,7 @@ function upstreamOAuthWizardUrl(profile, projectId, connectorId) {
9216
9451
  return url.toString();
9217
9452
  }
9218
9453
  async function loadOAuthMetadata(opts, locale) {
9219
- const messages = CLI_MESSAGES9[locale];
9454
+ const messages = CLI_MESSAGES10[locale];
9220
9455
  if (opts.file && opts.issuer) {
9221
9456
  throw new UsageError("--file \u3068 --issuer \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093");
9222
9457
  }
@@ -9233,7 +9468,7 @@ async function loadOAuthMetadata(opts, locale) {
9233
9468
  }
9234
9469
  }
9235
9470
  async function runOAuthMetadataValidate(opts, writer, locale) {
9236
- const messages = CLI_MESSAGES9[locale];
9471
+ const messages = CLI_MESSAGES10[locale];
9237
9472
  const parsed = await loadOAuthMetadata(opts, locale);
9238
9473
  const report = validateOAuthMetadata(parsed, locale);
9239
9474
  json(writer, report.results);
@@ -9244,8 +9479,8 @@ async function runOAuthMetadataValidate(opts, writer, locale) {
9244
9479
  info(writer, messages.oauth.metadataOk);
9245
9480
  }
9246
9481
  }
9247
- function registerOauth(program, writer, locale = DEFAULT_LOCALE7, dependencies = {}) {
9248
- const messages = CLI_MESSAGES9[locale];
9482
+ function registerOauth(program, writer, locale = DEFAULT_LOCALE9, dependencies = {}) {
9483
+ const messages = CLI_MESSAGES10[locale];
9249
9484
  const oauth = program.command("oauth").description(messages.oauth.commandDescription);
9250
9485
  oauth.command("init").description(messages.oauth.initDescription).requiredOption("--provider <name>", messages.oauth.providerOption).action((opts) => {
9251
9486
  info(writer, messages.oauth.templateHeading(opts.provider));
@@ -9393,7 +9628,7 @@ function registerOauth(program, writer, locale = DEFAULT_LOCALE7, dependencies =
9393
9628
 
9394
9629
  // src/commands/openapi.ts
9395
9630
  import { randomUUID as randomUUID8 } from "crypto";
9396
- import { resolve as resolve4 } from "path";
9631
+ import { resolve as resolve5 } from "path";
9397
9632
  import {
9398
9633
  importOpenApi as importOpenApi2,
9399
9634
  OPENAPI_IMPORT_MAX_SOURCE_BYTES as OPENAPI_IMPORT_MAX_SOURCE_BYTES2,
@@ -9456,7 +9691,7 @@ async function runOpenApiImportCommand(options, writer, cwd, runtime = createOpe
9456
9691
  if (normalized.apply && !/^[a-f0-9]{64}$/.test(normalized.planCommitment ?? "")) {
9457
9692
  throw new UsageError("--apply \u306B\u306Fpreview\u3067\u5F97\u305F --plan-commitment \u304C\u5FC5\u9808\u3067\u3059");
9458
9693
  }
9459
- const snapshot = readBoundedLocalFileSnapshot(resolve4(cwd, normalized.file), {
9694
+ const snapshot = readBoundedLocalFileSnapshot(resolve5(cwd, normalized.file), {
9460
9695
  maxBytes: OPENAPI_IMPORT_MAX_SOURCE_BYTES2,
9461
9696
  root: cwd
9462
9697
  });
@@ -9544,15 +9779,15 @@ function registerOpenApi(program, writer, cwd, runtime = createOpenApiImportRunt
9544
9779
  }
9545
9780
 
9546
9781
  // src/commands/review-package.ts
9547
- import { CLI_MESSAGES as CLI_MESSAGES10, DEFAULT_LOCALE as DEFAULT_LOCALE8 } from "@andpipes/localization";
9782
+ import { CLI_MESSAGES as CLI_MESSAGES11, DEFAULT_LOCALE as DEFAULT_LOCALE10 } from "@andpipes/localization";
9548
9783
  var TARGETS = ["chatgpt", "claude", "generic_mcp"];
9549
- function assertTarget(value, locale = DEFAULT_LOCALE8) {
9784
+ function assertTarget(value, locale = DEFAULT_LOCALE10) {
9550
9785
  if (!TARGETS.includes(value)) {
9551
- throw new UsageError(CLI_MESSAGES10[locale].reviewPackage.invalidTarget(value, TARGETS));
9786
+ throw new UsageError(CLI_MESSAGES11[locale].reviewPackage.invalidTarget(value, TARGETS));
9552
9787
  }
9553
9788
  }
9554
- function registerReviewPackage(program, writer, locale = DEFAULT_LOCALE8, cwd = () => process.cwd()) {
9555
- const messages = CLI_MESSAGES10[locale];
9789
+ function registerReviewPackage(program, writer, locale = DEFAULT_LOCALE10, cwd = () => process.cwd()) {
9790
+ const messages = CLI_MESSAGES11[locale];
9556
9791
  const reviewPackage = program.command("review-package").description(messages.reviewPackage.commandDescription);
9557
9792
  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(
9558
9793
  "--from-template",
@@ -9613,69 +9848,13 @@ function registerReviewPackage(program, writer, locale = DEFAULT_LOCALE8, cwd =
9613
9848
  });
9614
9849
  }
9615
9850
 
9616
- // src/commands/validate.ts
9617
- import { existsSync as existsSync2 } from "fs";
9618
- import { resolve as resolve5 } from "path";
9619
- import {
9620
- CLI_MESSAGES as CLI_MESSAGES11,
9621
- DEFAULT_LOCALE as DEFAULT_LOCALE9,
9622
- LOCALIZED_TEXT as LOCALIZED_TEXT3
9623
- } from "@andpipes/localization";
9624
- function resolveContractPath(file, cwd, locale = DEFAULT_LOCALE9) {
9625
- const messages = CLI_MESSAGES11[locale].validate;
9626
- if (file) {
9627
- const abs = resolve5(cwd, file);
9628
- if (!existsSync2(abs)) {
9629
- throw new UsageError(messages.fileNotFound(file));
9630
- }
9631
- return abs;
9632
- }
9633
- for (const candidate of CONTRACT_FILENAMES) {
9634
- const abs = resolve5(cwd, candidate);
9635
- if (existsSync2(abs)) {
9636
- return abs;
9637
- }
9638
- }
9639
- throw new UsageError(messages.defaultFileNotFound(CONTRACT_FILENAMES));
9640
- }
9641
- function loadContract(path, locale = DEFAULT_LOCALE9) {
9642
- void locale;
9643
- return loadContractFile(path).contract;
9644
- }
9645
- function registerValidate(program, writer, cwd, locale = DEFAULT_LOCALE9) {
9646
- const text = LOCALIZED_TEXT3[locale].cli;
9647
- const messages = CLI_MESSAGES11[locale].validate;
9648
- program.command("validate").description(`${text.validateDescription} (10 checks)`).option("--file <path>", messages.fileOption).action((opts) => {
9649
- const path = resolveContractPath(opts.file, cwd(), locale);
9650
- const loaded = loadContractFile(path);
9651
- const report = loaded.report;
9652
- const publishGate = loaded.publishGate;
9653
- json(writer, { checks: report.results, publishGate });
9654
- const fail2 = report.results.filter((r) => r.status === "fail").length;
9655
- const pending = report.results.filter((r) => r.status === "pending").length;
9656
- const pass = report.results.filter((r) => r.status === "pass").length;
9657
- info(
9658
- writer,
9659
- `${text.resultLabel}: pass=${pass} fail=${fail2} pending=${pending} (pending=${text.backendPending})`
9660
- );
9661
- info(
9662
- writer,
9663
- messages.publishGateSummary(publishGate.errors.length, publishGate.warnings.length)
9664
- );
9665
- if (!report.ok || !publishGate.ok) {
9666
- process.exitCode = 1;
9667
- info(writer, messages.failed);
9668
- }
9669
- });
9670
- }
9671
-
9672
9851
  // src/cli.ts
9673
9852
  function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale = normalizeLocale(process.env.ANDPIPE_LOCALE ?? process.env.LANG)) {
9674
9853
  const text = LOCALIZED_TEXT4[locale].cli;
9675
9854
  const messages = CLI_MESSAGES12[locale];
9676
9855
  const scopeRegistrationMessages = OAUTH_SCOPE_REGISTRATION_MESSAGES4[locale].cli;
9677
9856
  const program = new Command();
9678
- program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption, DEFAULT_LOCALE10).version(readVersion());
9857
+ program.name(CLI_NAME).description(text.description).option("--locale <locale>", messages.localeOption, DEFAULT_LOCALE11).version(readVersion());
9679
9858
  registerAuth(program, writer, locale);
9680
9859
  registerAuditExport(program, writer, locale);
9681
9860
  registerInit(
@@ -9698,6 +9877,7 @@ function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale
9698
9877
  registerDoctor(program, writer, locale);
9699
9878
  registerLogs(program, writer, locale);
9700
9879
  registerTemplate(program, writer, cwd);
9880
+ registerMuse(program, writer, cwd, locale);
9701
9881
  registerPublish(
9702
9882
  program,
9703
9883
  writer,
@@ -9816,6 +9996,8 @@ export {
9816
9996
  normalizeInitOptions,
9817
9997
  runInitCommand,
9818
9998
  registerInit,
9999
+ resolveContractPath,
10000
+ loadContract,
9819
10001
  PublishCommandError,
9820
10002
  createPublishCommandRuntime,
9821
10003
  normalizePublishOptions,
@@ -9828,8 +10010,6 @@ export {
9828
10010
  createOpenApiImportRuntime,
9829
10011
  runOpenApiImportCommand,
9830
10012
  registerOpenApi,
9831
- resolveContractPath,
9832
- loadContract,
9833
10013
  buildProgram,
9834
10014
  runCli,
9835
10015
  packageName