@sberpay-cli/cli-diagnostic 0.4.0-dev.11 → 0.4.0-dev.13

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/build-info.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "profile": "diagnostic",
3
- "version": "0.4.0-dev.11",
4
- "sourceCommit": "d122f70c9e8ce080f6ba74c47ad55f10bf2d26cc",
5
- "sourceTreeDigest": "21eb5b7735af881c83bfb9c43bbf63310e0e0ac2111c8f3b69459dd15fc71f2f",
3
+ "version": "0.4.0-dev.13",
4
+ "sourceCommit": "6929de81ad2c6a7298f56910a2ee0474fd0bbef2",
5
+ "sourceTreeDigest": "8b102a5fe1422222e62aad4eacb1bf3203d4d568caac4608ba09972748b1e855",
6
6
  "snapshot": false,
7
- "buildId": "8f501a66a8d065ff9ab196e35121535ed0a287c2acea160202bbf124c99431eb",
7
+ "buildId": "f155858c1b44812f515e4913bc2f93921794988610ea690e76a698beda6cc547",
8
8
  "stateFormat": 2
9
9
  }
package/manifest.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "buildId": "8f501a66a8d065ff9ab196e35121535ed0a287c2acea160202bbf124c99431eb",
3
+ "buildId": "f155858c1b44812f515e4913bc2f93921794988610ea690e76a698beda6cc547",
4
4
  "setupHash": "7a8f1518a3429696aa575171d8e42e399432089462cd92b50888fd291d363a37",
5
5
  "files": {
6
6
  "bin/sberpay-cli.mjs": "1ae77e7ac7e62b5877c48fc277a185a5f4c1b7fa252896b8494c88580537928c",
7
7
  "config/logging.yaml": "2a7103f6f5b70d2c0752c6f679adc613de71cc189d94ebf09e937ae22469b4e6",
8
- "dist/binding-worker.mjs": "a8f9d7273d0e4c65f0776f308faad9605edbd7881829c777c086c9f47c021ba4",
9
- "dist/cli.mjs": "3564f1be633814cc9d8c292b7fe0022cc367f9575b5a316d154a684982503450",
8
+ "dist/binding-worker.mjs": "99d8abdb7f439bed5d251ffced720ab17bd2d2cfcf8c03a98b076c1ef8981630",
9
+ "dist/cli.mjs": "902ee1f57654f2c836be7d838e3a2ee74d40ad530d2fd9b3aa3903a03e090a78",
10
10
  "helpers/darwin/sberpay-se": "970ca41609d177f9ac7bc61352db38840d889fe478bcbae2fe5f32999d089023",
11
11
  "helpers/linux-arm64/sberpay-tpm": "4daa77f2bf2ce08225181cda11052c0c70d14782bc77ba2d31bcf5f6ac44124c",
12
12
  "helpers/linux-x64/sberpay-tpm": "a5baef556ede1ae56732d6edd4547ea6e038d22d7da7cdf74e42f75156651e69",
13
13
  "helpers/win32-arm64/sberpay-tpm.exe": "3c29fa49441c39bcf894fb320e31bd0c22a54e994293124d278fbcb0f56c9a58",
14
14
  "helpers/win32-x64/sberpay-tpm.exe": "831e6604edcbe715bc9076c9f10366360fb7c4b39fd270451f5d373a86c459ce",
15
- "package.json": "878e56d93d1f19ffd295fcf24c6fb590ccb99cdf2fa784e7c213719fa522afba",
15
+ "package.json": "b0ec4cfa5acbf52d3cf9b6eac4021496d9e9506d772bb1626ec243133029f359",
16
16
  "README.md": "355b016a373233d6771ef3d8374b593e1f08a396bdb6a5833000f03c94716492",
17
- "SHA256SUMS": "130d03f2794c7504c6b418e6575e2d6162b17a47b382a40641bc9c5ceae9d813",
17
+ "SHA256SUMS": "e158478f63b046d8291931caec09d9fa387dcc4aa4b38691f105e70ebb445520",
18
18
  "skill/sberpay/references/invoice-id.md": "7585226176836de2e3f62f50b15ec2530b31e5bec26be60dee624c21e511d117",
19
19
  "skill/sberpay/references/root-ca.md": "16cc83c00ecb9d4a58cc910f69f58c133fdb94467951875fc2b978db5f19ecc5",
20
20
  "skill/sberpay/scripts/approved-message.mjs": "6835ab5c7a196b075edda7a3cdc31cd18d1e7402dbc04d9f2bb2b3e42e4f6a39",
@@ -2,14 +2,14 @@
2
2
  b74dd6b8f90644b59f69eddc7a9e64c8f78eee3d6606cedb3de2e4cfc530f324 THIRD_PARTY_NOTICES.md
3
3
  1ae77e7ac7e62b5877c48fc277a185a5f4c1b7fa252896b8494c88580537928c bin/sberpay-cli.mjs
4
4
  2a7103f6f5b70d2c0752c6f679adc613de71cc189d94ebf09e937ae22469b4e6 config/logging.yaml
5
- a8f9d7273d0e4c65f0776f308faad9605edbd7881829c777c086c9f47c021ba4 dist/binding-worker.mjs
6
- 3564f1be633814cc9d8c292b7fe0022cc367f9575b5a316d154a684982503450 dist/cli.mjs
5
+ 99d8abdb7f439bed5d251ffced720ab17bd2d2cfcf8c03a98b076c1ef8981630 dist/binding-worker.mjs
6
+ 902ee1f57654f2c836be7d838e3a2ee74d40ad530d2fd9b3aa3903a03e090a78 dist/cli.mjs
7
7
  970ca41609d177f9ac7bc61352db38840d889fe478bcbae2fe5f32999d089023 helpers/darwin/sberpay-se
8
8
  4daa77f2bf2ce08225181cda11052c0c70d14782bc77ba2d31bcf5f6ac44124c helpers/linux-arm64/sberpay-tpm
9
9
  a5baef556ede1ae56732d6edd4547ea6e038d22d7da7cdf74e42f75156651e69 helpers/linux-x64/sberpay-tpm
10
10
  3c29fa49441c39bcf894fb320e31bd0c22a54e994293124d278fbcb0f56c9a58 helpers/win32-arm64/sberpay-tpm.exe
11
11
  831e6604edcbe715bc9076c9f10366360fb7c4b39fd270451f5d373a86c459ce helpers/win32-x64/sberpay-tpm.exe
12
- 878e56d93d1f19ffd295fcf24c6fb590ccb99cdf2fa784e7c213719fa522afba package.json
12
+ b0ec4cfa5acbf52d3cf9b6eac4021496d9e9506d772bb1626ec243133029f359 package.json
13
13
  11ad6c02a268214dff11dead6289af1e955cafb65e7b86530f3838ddd6663ce3 skill/sberpay/SKILL.md
14
14
  7585226176836de2e3f62f50b15ec2530b31e5bec26be60dee624c21e511d117 skill/sberpay/references/invoice-id.md
15
15
  16cc83c00ecb9d4a58cc910f69f58c133fdb94467951875fc2b978db5f19ecc5 skill/sberpay/references/root-ca.md
@@ -27729,7 +27729,7 @@ import { fileURLToPath } from "node:url";
27729
27729
  var NPM_PACKAGE = true ? "@sberpay-cli/cli-diagnostic" : "@sberpay-cli/cli";
27730
27730
  var kind = true ? "release" : "dev";
27731
27731
  var BUILD = {
27732
- sourceCommit: true ? "d122f70c9e8ce080f6ba74c47ad55f10bf2d26cc" : "dev",
27732
+ sourceCommit: true ? "6929de81ad2c6a7298f56910a2ee0474fd0bbef2" : "dev",
27733
27733
  profile: true ? "diagnostic" : "standard",
27734
27734
  kind,
27735
27735
  // Бандл — dist/cli.mjs в корне пакета; этот файл под tsx — packages/cli/src/core/.
@@ -29336,7 +29336,7 @@ function ensureTrustFor(url2, store = tls, roots = PINNED_ROOTS, now = /* @__PUR
29336
29336
  }
29337
29337
 
29338
29338
  // packages/cli/src/core/version.ts
29339
- var CLI_VERSION = "0.4.0-dev.11";
29339
+ var CLI_VERSION = "0.4.0-dev.13";
29340
29340
 
29341
29341
  // packages/cli/src/core/http.ts
29342
29342
  var USER_AGENT = `sberpay-cli/${CLI_VERSION}`;
@@ -7375,7 +7375,7 @@ import { fileURLToPath } from "node:url";
7375
7375
  var NPM_PACKAGE = true ? "@sberpay-cli/cli-diagnostic" : "@sberpay-cli/cli";
7376
7376
  var kind = true ? "release" : "dev";
7377
7377
  var BUILD = {
7378
- sourceCommit: true ? "d122f70c9e8ce080f6ba74c47ad55f10bf2d26cc" : "dev",
7378
+ sourceCommit: true ? "6929de81ad2c6a7298f56910a2ee0474fd0bbef2" : "dev",
7379
7379
  profile: true ? "diagnostic" : "standard",
7380
7380
  kind,
7381
7381
  // Бандл — dist/cli.mjs в корне пакета; этот файл под tsx — packages/cli/src/core/.
@@ -8852,7 +8852,7 @@ function $constructor(name, initializer3, proto, params) {
8852
8852
  Internals.prototype = zodProto;
8853
8853
  const protoMembers = proto;
8854
8854
  const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
8855
- function init(inst, def) {
8855
+ function init2(inst, def) {
8856
8856
  if (!inst._zod) {
8857
8857
  _zodDesc.value = new Internals(def);
8858
8858
  try {
@@ -8892,7 +8892,7 @@ function $constructor(name, initializer3, proto, params) {
8892
8892
  Object.defineProperty(Definition, "name", { value: name });
8893
8893
  function _(def) {
8894
8894
  const inst = params?.Parent ? newError(Definition) : this;
8895
- init(inst, def);
8895
+ init2(inst, def);
8896
8896
  const deferred = inst._zod.deferred;
8897
8897
  if (deferred) {
8898
8898
  for (const fn of deferred) {
@@ -8905,7 +8905,7 @@ function $constructor(name, initializer3, proto, params) {
8905
8905
  pp(inst);
8906
8906
  return inst;
8907
8907
  }
8908
- Object.defineProperty(_, "init", { value: init });
8908
+ Object.defineProperty(_, "init", { value: init2 });
8909
8909
  Object.defineProperty(_, Symbol.hasInstance, {
8910
8910
  value: (inst) => {
8911
8911
  if (params?.Parent && inst instanceof params.Parent)
@@ -29720,7 +29720,7 @@ function zipSync(data, opts) {
29720
29720
  }
29721
29721
 
29722
29722
  // packages/cli/src/core/version.ts
29723
- var CLI_VERSION = "0.4.0-dev.11";
29723
+ var CLI_VERSION = "0.4.0-dev.13";
29724
29724
 
29725
29725
  // packages/cli/src/report/journal.ts
29726
29726
  import { closeSync as closeSync5, constants as constants6, openSync as openSync5, writeSync as writeSync2 } from "node:fs";
@@ -34948,13 +34948,13 @@ function headersToRecord(h) {
34948
34948
  return Object.fromEntries(h.entries());
34949
34949
  }
34950
34950
  var newRqUid = () => randomUUID10().replace(/-/g, "");
34951
- async function loggedFetch(logger, meta3, url2, init = {}) {
34951
+ async function loggedFetch(logger, meta3, url2, init2 = {}) {
34952
34952
  const rqUid = meta3.rqUid ?? newRqUid();
34953
- const headers = new Headers(init.headers);
34953
+ const headers = new Headers(init2.headers);
34954
34954
  headers.set("rqUid", rqUid);
34955
34955
  headers.set("X-RqUID", rqUid);
34956
34956
  const started = performance.now();
34957
- const reqBody = typeof init.body === "string" ? init.body : init.body ? String(init.body) : void 0;
34957
+ const reqBody = typeof init2.body === "string" ? init2.body : init2.body ? String(init2.body) : void 0;
34958
34958
  logger.log({
34959
34959
  event: "request_sent",
34960
34960
  transport: "HTTP",
@@ -34963,7 +34963,7 @@ async function loggedFetch(logger, meta3, url2, init = {}) {
34963
34963
  headers: headersToRecord(headers),
34964
34964
  body: meta3.redactBody ? "[REDACTED]" : reqBody
34965
34965
  });
34966
- const res = await fetch(url2, { ...init, headers });
34966
+ const res = await fetch(url2, { ...init2, headers });
34967
34967
  const text2 = await res.clone().text();
34968
34968
  logger.log({
34969
34969
  event: "response_received",
@@ -40052,6 +40052,12 @@ async function setupCommand(globals, opts) {
40052
40052
  }
40053
40053
  }
40054
40054
 
40055
+ // packages/cli/src/setup/init.ts
40056
+ import { spawnSync as spawnSync5 } from "node:child_process";
40057
+ import { existsSync as existsSync14, mkdirSync as mkdirSync14, readFileSync as readFileSync16, appendFileSync as appendFileSync2 } from "node:fs";
40058
+ import { homedir as homedir9 } from "node:os";
40059
+ import { join as join27, dirname as dirname12 } from "node:path";
40060
+
40055
40061
  // packages/cli/src/setup/environment.ts
40056
40062
  import { accessSync, constants as constants8, existsSync as existsSync13, readFileSync as readFileSync15 } from "node:fs";
40057
40063
  import { homedir as homedir8, release as release2 } from "node:os";
@@ -40279,15 +40285,212 @@ async function doctorCommand(globals, opts) {
40279
40285
  if (v.suitable === false) process.exitCode = EXIT.API;
40280
40286
  }
40281
40287
 
40288
+ // packages/cli/src/setup/init.ts
40289
+ var INIT_REGISTRY = "https://registry.npmjs.org";
40290
+ var DIAG_PACKAGE = "@sberpay-cli/cli-diagnostic";
40291
+ var CHANNEL = "latest";
40292
+ var PREFIX = () => join27(homedir9(), ".npm-global");
40293
+ var BIN = () => join27(PREFIX(), "bin");
40294
+ var PATH_LINE = 'export PATH="$HOME/.npm-global/bin:$PATH"';
40295
+ var CODEX_SKILLS = () => join27(homedir9(), ".codex", "skills");
40296
+ var CLAUDE_SKILLS = () => join27(homedir9(), ".claude", "skills");
40297
+ function npm(args) {
40298
+ const res = spawnSync5("npm", args, { stdio: "inherit", shell: process.platform === "win32" });
40299
+ return !res.error && res.status === 0;
40300
+ }
40301
+ function harnessSkills() {
40302
+ return existsSync14(CODEX_SKILLS()) ? CODEX_SKILLS() : CLAUDE_SKILLS();
40303
+ }
40304
+ function ensureNpmPrefix(prefix) {
40305
+ mkdirSync14(prefix, { recursive: true });
40306
+ npm(["config", "set", "prefix", prefix, "--location=user"]);
40307
+ for (const rcName of [".zshrc", ".bashrc"]) {
40308
+ const rc = join27(homedir9(), rcName);
40309
+ if (!existsSync14(rc)) continue;
40310
+ if (readFileSync16(rc, "utf8").includes(".npm-global/bin")) continue;
40311
+ appendFileSync2(rc, `
40312
+ ${PATH_LINE}
40313
+ `);
40314
+ }
40315
+ }
40316
+ function resolveVersion(pkg, ref) {
40317
+ const res = spawnSync5("npm", ["view", `${pkg}@${ref}`, "version", "--registry", INIT_REGISTRY], { encoding: "utf8" });
40318
+ if (res.error || res.status !== 0) {
40319
+ throw new CliError(
40320
+ EXIT.CONFIG_OR_NETWORK,
40321
+ "INIT_REGISTRY_UNREACHABLE",
40322
+ `\u0420\u0435\u0435\u0441\u0442\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D: \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C ${pkg}@${ref}`,
40323
+ { hint: `\u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0434\u043E\u0441\u0442\u0443\u043F \u043A ${INIT_REGISTRY} \u0438 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 sberpay-cli init` }
40324
+ );
40325
+ }
40326
+ const v = (res.stdout ?? "").trim().split("\n").pop()?.trim();
40327
+ if (!v) {
40328
+ throw new CliError(
40329
+ EXIT.CONFIG_OR_NETWORK,
40330
+ "INIT_REGISTRY_UNREACHABLE",
40331
+ `\u0420\u0435\u0435\u0441\u0442\u0440 \u0432\u0435\u0440\u043D\u0443\u043B \u043F\u0443\u0441\u0442\u043E\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442 \u0434\u043B\u044F ${pkg}@${ref}`,
40332
+ { hint: `\u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u043A\u0430\u043D\u0430\u043B ${ref} \u0438 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 sberpay-cli init` }
40333
+ );
40334
+ }
40335
+ return v;
40336
+ }
40337
+ function rerunInit(globals, opts) {
40338
+ const bin = join27(BIN(), process.platform === "win32" ? "sberpay-cli.cmd" : "sberpay-cli");
40339
+ const args = ["init"];
40340
+ if (globals.json) args.push("--json");
40341
+ if (opts.skillDir) args.push("--skill-dir", opts.skillDir);
40342
+ if (opts.offline) args.push("--offline");
40343
+ if (opts.yes) args.push("--yes");
40344
+ if (opts.version) args.push("--version", opts.version);
40345
+ if (opts.channel) args.push("--channel", opts.channel);
40346
+ const res = spawnSync5(bin, args, { stdio: "inherit", encoding: "utf8" });
40347
+ process.exit(res.status ?? EXIT.INTERNAL);
40348
+ }
40349
+ function skillTarget2(opts) {
40350
+ if (opts.skillDir) return opts.skillDir;
40351
+ return existsSync14(CODEX_SKILLS()) ? join27(CODEX_SKILLS(), "sberpay") : void 0;
40352
+ }
40353
+ function diagSkillSource(stdout) {
40354
+ const pick2 = (o) => {
40355
+ if (typeof o === "string") {
40356
+ const s = o.trim();
40357
+ return s || void 0;
40358
+ }
40359
+ if (o && typeof o === "object") {
40360
+ for (const key of ["skill", "skillDir", "source", "path", "skillSource"]) {
40361
+ const v = o[key];
40362
+ if (typeof v === "string" && v.trim()) return v.trim();
40363
+ }
40364
+ }
40365
+ return void 0;
40366
+ };
40367
+ try {
40368
+ const data = JSON.parse(stdout);
40369
+ const top = pick2(data);
40370
+ if (top) return top;
40371
+ const state = data?.["state"];
40372
+ if (state) return pick2(state);
40373
+ } catch {
40374
+ }
40375
+ return void 0;
40376
+ }
40377
+ function ensureDiagSkill(stdout, harness) {
40378
+ const source = diagSkillSource(stdout);
40379
+ if (!source || !harness) return;
40380
+ const dest = join27(harness, "sberpay-diagnostic");
40381
+ if (source.replace(/\/+$/, "") === dest.replace(/\/+$/, "")) return;
40382
+ if (!existsSync14(source) || existsSync14(dest)) return;
40383
+ if (process.platform === "win32") {
40384
+ process.stderr.write("\u2717 \u041D\u0435 \u0441\u043C\u043E\u0433 \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043A\u0438\u043B\u043B \u0434\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0438 \u0432 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u0445\u0430\u0440\u043D\u0435\u0441\u0441\u0430 \u2014 \u0441\u043A\u043E\u043F\u0438\u0440\u0443\u0439\u0442\u0435 \u0432\u0440\u0443\u0447\u043D\u0443\u044E.\n");
40385
+ return;
40386
+ }
40387
+ mkdirSync14(dirname12(dest), { recursive: true });
40388
+ const res = spawnSync5("cp", ["-R", source, dest], { encoding: "utf8" });
40389
+ if (res.status !== 0) {
40390
+ process.stderr.write(`\u2717 \u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043A\u0438\u043B\u043B \u0434\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0438 \u0432 ${dest}.
40391
+ `);
40392
+ }
40393
+ }
40394
+ async function initCommand(globals, opts) {
40395
+ const out = createOutput(Boolean(globals.json));
40396
+ const release3 = BUILD.kind === "release";
40397
+ const yes = opts.yes ?? true;
40398
+ const channel = opts.channel ?? CHANNEL;
40399
+ const spec = opts.version ?? channel;
40400
+ if (release3) {
40401
+ const prefix = PREFIX();
40402
+ ensureNpmPrefix(prefix);
40403
+ const target = resolveVersion(NPM_PACKAGE, spec);
40404
+ const binName = process.platform === "win32" ? "sberpay-cli.cmd" : "sberpay-cli";
40405
+ const selfBin = join27(BIN(), binName);
40406
+ if (opts.version) {
40407
+ if (target !== CLI_VERSION || !existsSync14(selfBin)) {
40408
+ out.progress(`\u0421\u0442\u0430\u0432\u043B\u044E sberpay-cli ${target} (\u043F\u0438\u043D) \u0432 ${PREFIX()}\u2026`);
40409
+ if (!npm(["install", "-g", "--prefix", prefix, `${NPM_PACKAGE}@${spec}`, "--registry", INIT_REGISTRY])) {
40410
+ out.error(new CliError(EXIT.CONFIG_OR_NETWORK, "INIT_PIN_FAILED", `\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 sberpay-cli ${target} \u043D\u0435 \u0443\u0434\u0430\u043B\u0430\u0441\u044C`, {
40411
+ hint: `\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u0432\u0440\u0443\u0447\u043D\u0443\u044E: npm install -g --prefix "${prefix}" ${NPM_PACKAGE}@${spec} --registry=${INIT_REGISTRY}`
40412
+ }));
40413
+ return;
40414
+ }
40415
+ }
40416
+ } else {
40417
+ if (!existsSync14(selfBin)) {
40418
+ out.progress("sberpay-cli \u043D\u0435 \u0432 ~/.npm-global/bin \u2014 \u043F\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043D\u0430\u0432\u043B\u0438\u0432\u0430\u044E \u0432 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C\u0441\u043A\u0438\u0439 \u043A\u0430\u0442\u0430\u043B\u043E\u0433");
40419
+ if (!npm(["install", "-g", "--prefix", prefix, `${NPM_PACKAGE}@${channel}`, "--registry", INIT_REGISTRY])) {
40420
+ out.error(new CliError(EXIT.CONFIG_OR_NETWORK, "INIT_INSTALL_FAILED", "\u041F\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 sberpay-cli \u043D\u0435 \u0443\u0434\u0430\u043B\u0430\u0441\u044C", {
40421
+ hint: `\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u0432\u0440\u0443\u0447\u043D\u0443\u044E: npm install -g --prefix "${prefix}" ${NPM_PACKAGE}@${channel} --registry=${INIT_REGISTRY}`
40422
+ }));
40423
+ return;
40424
+ }
40425
+ rerunInit(globals, opts);
40426
+ }
40427
+ if (target !== CLI_VERSION) {
40428
+ out.progress(`\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u043E ${target}, \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u043E ${CLI_VERSION} \u2014 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u044E \u0434\u043E \u0432\u0435\u0440\u0441\u0438\u0438 \u043A\u0430\u043D\u0430\u043B\u0430 ${channel}`);
40429
+ if (!npm(["install", "-g", "--prefix", prefix, `${NPM_PACKAGE}@${channel}`, "--registry", INIT_REGISTRY])) {
40430
+ out.error(new CliError(EXIT.CONFIG_OR_NETWORK, "INIT_UPGRADE_FAILED", "\u041E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0435 sberpay-cli \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C", {
40431
+ hint: `\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u0432\u0440\u0443\u0447\u043D\u0443\u044E: npm install -g --prefix "${prefix}" ${NPM_PACKAGE}@${channel} --registry=${INIT_REGISTRY}`
40432
+ }));
40433
+ return;
40434
+ }
40435
+ rerunInit(globals, opts);
40436
+ }
40437
+ }
40438
+ }
40439
+ await doctorCommand(globals, { offline: Boolean(opts.offline ?? true) });
40440
+ if (process.exitCode) return;
40441
+ await setupCommand(globals, {
40442
+ dev: false,
40443
+ skill: true,
40444
+ skillDir: skillTarget2(opts),
40445
+ project: false,
40446
+ forceSkill: false,
40447
+ yes
40448
+ });
40449
+ if (release3) {
40450
+ resolveVersion(DIAG_PACKAGE, spec);
40451
+ if (!npm(["install", "-g", "--prefix", PREFIX(), `${DIAG_PACKAGE}@${spec}`, "--registry", INIT_REGISTRY])) {
40452
+ out.error(new CliError(EXIT.CONFIG_OR_NETWORK, "INIT_DIAG_INSTALL_FAILED", "\u0423\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u0434\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u0447\u0435\u0441\u043A\u043E\u0433\u043E CLI \u043D\u0435 \u0443\u0434\u0430\u043B\u0430\u0441\u044C", {
40453
+ hint: `\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u0432\u0440\u0443\u0447\u043D\u0443\u044E: npm install -g --prefix "${PREFIX()}" ${DIAG_PACKAGE}@${spec} --registry=${INIT_REGISTRY}`
40454
+ }));
40455
+ return;
40456
+ }
40457
+ const diagBin = join27(BIN(), process.platform === "win32" ? "sberpay-cli-diagnostic.cmd" : "sberpay-cli-diagnostic");
40458
+ const setupRes = spawnSync5(diagBin, ["setup", "--json"], { encoding: "utf8" });
40459
+ if (setupRes.status !== 0) {
40460
+ out.error(new CliError(EXIT.API, "INIT_DIAG_SETUP_FAILED", '\u0414\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u0439 CLI: "setup" \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0441\u044F \u0441 \u043E\u0448\u0438\u0431\u043A\u043E\u0439', {
40461
+ hint: "\u0421\u043C\u043E\u0442\u0440\u0438\u0442\u0435 \u0432\u044B\u0432\u043E\u0434 \u0432\u044B\u0448\u0435; \u043F\u0440\u043E\u0444\u0438\u043B\u044C \u0434\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0438 \u043D\u0435 \u0443\u0434\u0430\u043B\u044F\u0439\u0442\u0435."
40462
+ }));
40463
+ return;
40464
+ }
40465
+ ensureDiagSkill(setupRes.stdout ?? "", harnessSkills());
40466
+ for (const argv of [
40467
+ ["payment-mode", "set", "live", "--confirm-real-payments", "--json"],
40468
+ ["payment-mode", "status", "--json"]
40469
+ ]) {
40470
+ const res = spawnSync5(diagBin, [...argv], { stdio: "inherit", encoding: "utf8" });
40471
+ if (res.status !== 0) {
40472
+ out.error(new CliError(EXIT.API, "INIT_DIAG_SETUP_FAILED", `\u0414\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u0439 CLI: "${argv.join(" ")}" \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0441\u044F \u0441 \u043E\u0448\u0438\u0431\u043A\u043E\u0439`, {
40473
+ hint: "\u0421\u043C\u043E\u0442\u0440\u0438\u0442\u0435 \u0432\u044B\u0432\u043E\u0434 \u0432\u044B\u0448\u0435; \u0440\u0435\u0436\u0438\u043C \u043E\u043F\u043B\u0430\u0442\u044B \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C live."
40474
+ }));
40475
+ return;
40476
+ }
40477
+ }
40478
+ }
40479
+ out.result(
40480
+ { installed: true, diagnostic: release3, next: "auth login" },
40481
+ "\u0412\u0441\u0451 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u043E. \u041E\u0441\u0442\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043A\u0430\u0440\u0442\u0443: sberpay-cli auth login \u2014 \u0430\u0433\u0435\u043D\u0442 \u0441\u0430\u043C \u0432\u044B\u0431\u0435\u0440\u0435\u0442 --local/--remote."
40482
+ );
40483
+ }
40484
+
40282
40485
  // packages/cli/src/ca/command.ts
40283
- import { spawnSync as spawnSync5 } from "node:child_process";
40284
- import { existsSync as existsSync14 } from "node:fs";
40285
- import { homedir as homedir9 } from "node:os";
40486
+ import { spawnSync as spawnSync6 } from "node:child_process";
40487
+ import { existsSync as existsSync15 } from "node:fs";
40488
+ import { homedir as homedir10 } from "node:os";
40286
40489
  var INSTALL_TIMEOUT_MS = 12e4;
40287
40490
  var WHERE = { system: "\u0432 \u0434\u043E\u0432\u0435\u0440\u0435\u043D\u043D\u044B\u0445 \u043A\u043E\u0440\u043D\u044F\u0445 \u0441\u0438\u0441\u0442\u0435\u043C\u044B", extra: "\u0438\u0437 NODE_EXTRA_CA_CERTS (\u0441\u0438\u0441\u0442\u0435\u043C\u0430 \u0435\u0433\u043E \u043D\u0435 \u0437\u043D\u0430\u0435\u0442)" };
40288
40491
  function runSecurity(argv) {
40289
40492
  const [head = "", ...rest] = argv;
40290
- const result = spawnSync5(head, rest, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: INSTALL_TIMEOUT_MS });
40493
+ const result = spawnSync6(head, rest, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: INSTALL_TIMEOUT_MS });
40291
40494
  return { status: result.status, stderr: result.error ? result.error.message : result.stderr };
40292
40495
  }
40293
40496
  function caStatusCommand(globals) {
@@ -40322,7 +40525,7 @@ async function caFetchCommand(globals) {
40322
40525
  function caInstallCommand(globals) {
40323
40526
  const out = createOutput(Boolean(globals.json));
40324
40527
  out.progress("\u0414\u043E\u0431\u0430\u0432\u043B\u044F\u044E \u043A\u043E\u0440\u0435\u043D\u044C \u0432 \u0434\u043E\u0432\u0435\u0440\u0435\u043D\u043D\u044B\u0435 \u043A\u043E\u0440\u043D\u0438 \u0441\u0438\u0441\u0442\u0435\u043C\u044B \u2014 \u0441\u0438\u0441\u0442\u0435\u043C\u0430 \u043C\u043E\u0436\u0435\u0442 \u0441\u043F\u0440\u043E\u0441\u0438\u0442\u044C \u043F\u0430\u0440\u043E\u043B\u044C\u2026");
40325
- const result = installRootCa({ paths: cliPaths(), platform: process.platform, home: homedir9(), exists: existsSync14, run: runSecurity });
40528
+ const result = installRootCa({ paths: cliPaths(), platform: process.platform, home: homedir10(), exists: existsSync15, run: runSecurity });
40326
40529
  const human = result.installed ? `\u2713 ${result.say}` : [`\u041A\u043E\u043C\u0430\u043D\u0434\u0443 \u0432\u044B\u043F\u043E\u043B\u043D\u044F\u0435\u0442 \u0447\u0435\u043B\u043E\u0432\u0435\u043A: ${result.command ?? "\u2014"}`, ` ${result.say}`].join("\n");
40327
40530
  out.result(result, human);
40328
40531
  }
@@ -40392,6 +40595,29 @@ setup.command("doctor").description("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\
40392
40595
  fail(globals, error62);
40393
40596
  }
40394
40597
  });
40598
+ var init = program2.command("init").description(
40599
+ "\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043F\u043E INSTALL-FROM-REGISTRY.md \u043E\u0434\u043D\u043E\u0439 \u043A\u043E\u043C\u0430\u043D\u0434\u043E\u0439: prefix, \u043A\u0430\u043D\u0430\u043B latest/next (\u0438\u043B\u0438 --version), doctor, \u0441\u043A\u0438\u043B\u043B, \u0434\u0438\u0430\u0433\u043D\u043E\u0441\u0442\u0438\u043A\u0430; \u043F\u043E\u0432\u0442\u043E\u0440\u044F\u0439\u0442\u0435 \u0434\u043E \xAB\u0433\u043E\u0442\u043E\u0432\u043E\xBB"
40600
+ ).option(
40601
+ "--skill-dir <path>",
40602
+ "\u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u0441\u043A\u0438\u043B\u043B\u0430 \u0432\u043C\u0435\u0441\u0442\u043E \u0430\u0432\u0442\u043E\u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D\u0438\u044F (Codex/Claude)"
40603
+ ).option(
40604
+ "--channel <next|latest>",
40605
+ "\u043A\u0430\u043D\u0430\u043B \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0438 (\u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E latest \u2014 \u0440\u0435\u043A\u043E\u043C\u0435\u043D\u0434\u043E\u0432\u0430\u043D\u043D\u0430\u044F; next \u2014 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u044F\u044F \u0441\u0431\u043E\u0440\u043A\u0430)",
40606
+ "latest"
40607
+ ).option("--version <semver>", "\u043F\u043E\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043D\u043A\u0440\u0435\u0442\u043D\u0443\u044E \u0432\u0435\u0440\u0441\u0438\u044E \u0432\u043C\u0435\u0441\u0442\u043E \u043A\u0430\u043D\u0430\u043B\u0430").option("--offline", "doctor \u0431\u0435\u0437 \u043E\u0431\u0440\u0430\u0449\u0435\u043D\u0438\u044F \u043A \u0448\u043B\u044E\u0437\u0443").option("-y, --yes", "\u0431\u0435\u0437 \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432").action(async (opts) => {
40608
+ const globals = program2.opts();
40609
+ try {
40610
+ await initCommand(globals, {
40611
+ skillDir: opts.skillDir,
40612
+ offline: Boolean(opts.offline),
40613
+ yes: Boolean(opts.yes),
40614
+ channel: opts.channel,
40615
+ version: opts.version
40616
+ });
40617
+ } catch (error62) {
40618
+ fail(globals, error62);
40619
+ }
40620
+ });
40395
40621
  function standalone(fn) {
40396
40622
  return async () => {
40397
40623
  const globals = program2.opts();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sberpay-cli/cli-diagnostic",
3
- "version": "0.4.0-dev.11",
3
+ "version": "0.4.0-dev.13",
4
4
  "description": "Оплата SberPay для AI-агентов: карта, привязанная к агенту, и лимиты клиента",
5
5
  "type": "module",
6
6
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sberpay-cli/cli-diagnostic",
3
- "version": "0.4.0-dev.11",
3
+ "version": "0.4.0-dev.13",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sberpay-cli-diagnostic": "bin/sberpay-cli-diagnostic.mjs"