@swmansion/argent 0.16.1-next.7 → 0.16.1-next.9

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/cli-cmds.mjs CHANGED
@@ -8423,6 +8423,11 @@ var STATUS_GLYPH = {
8423
8423
  error: "\u2717",
8424
8424
  skip: "\xB7"
8425
8425
  };
8426
+ var MAX_RENDER_DEPTH = 20;
8427
+ function stepIndent(depth) {
8428
+ if (typeof depth !== "number" || !Number.isInteger(depth) || depth <= 0) return "";
8429
+ return " ".repeat(Math.min(depth, MAX_RENDER_DEPTH));
8430
+ }
8426
8431
  function printHelp() {
8427
8432
  console.log(`Usage: argent flow <subcommand> [options]
8428
8433
 
@@ -8491,11 +8496,12 @@ function parseRunArgs(argv) {
8491
8496
  }
8492
8497
  function renderEchoLine(s) {
8493
8498
  if (!s.message) return void 0;
8499
+ const indent = stepIndent(s.depth);
8494
8500
  if (s.status === "skip") {
8495
8501
  const reason = s.reason ? ` \u2014 ${s.reason}` : "";
8496
- return ` ${STATUS_GLYPH.skip} \u203A ${s.message}${reason}`;
8502
+ return ` ${STATUS_GLYPH.skip} ${indent}\u203A ${s.message}${reason}`;
8497
8503
  }
8498
- return ` \u203A ${s.message}`;
8504
+ return ` ${indent}\u203A ${s.message}`;
8499
8505
  }
8500
8506
  function renderStepLine(s, n2, topFlow) {
8501
8507
  const where = s.flow && s.flow !== topFlow ? ` [${s.flow}]` : "";
@@ -8503,7 +8509,10 @@ function renderStepLine(s, n2, topFlow) {
8503
8509
  const label = what ? `${s.kind} ${what}` : s.kind;
8504
8510
  const reason = s.reason ? ` \u2014 ${s.reason}` : "";
8505
8511
  const glyph = s.status === "pass" && s.warning ? "\u26A0" : STATUS_GLYPH[s.status];
8506
- return ` ${glyph} ${String(n2).padStart(2)} ${label}${where}${reason}`;
8512
+ return ` ${glyph} ${String(n2).padStart(2)} ${stepIndent(s.depth)}${label}${where}${reason}`;
8513
+ }
8514
+ function renderUnderStepLine(s, n2, text2) {
8515
+ return `${" ".repeat(5 + Math.max(2, String(n2).length))}${stepIndent(s.depth)}${text2}`;
8507
8516
  }
8508
8517
  function renderSummary(report, opts = {}) {
8509
8518
  const warnings = report.steps.filter((s) => s.warning).length;
@@ -8590,10 +8599,10 @@ function renderReport(report) {
8590
8599
  }
8591
8600
  n2++;
8592
8601
  lines.push(renderStepLine(s, n2, report.flow));
8593
- if (s.warning) lines.push(` \u26A0 ${s.warning}`);
8602
+ if (s.warning) lines.push(renderUnderStepLine(s, n2, `\u26A0 ${s.warning}`));
8594
8603
  if (s.artifacts && typeof s.artifacts === "object") {
8595
8604
  for (const [k, v] of Object.entries(s.artifacts)) {
8596
- if (typeof v === "string") lines.push(` ${k}: ${v}`);
8605
+ if (typeof v === "string") lines.push(renderUnderStepLine(s, n2, `${k}: ${v}`));
8597
8606
  }
8598
8607
  }
8599
8608
  }
@@ -8668,7 +8677,7 @@ async function flow(argv, options) {
8668
8677
  }
8669
8678
  liveIndex++;
8670
8679
  console.log(renderStepLine(s, liveIndex, flowName));
8671
- if (s.warning) console.log(` \u26A0 ${s.warning}`);
8680
+ if (s.warning) console.log(renderUnderStepLine(s, liveIndex, `\u26A0 ${s.warning}`));
8672
8681
  };
8673
8682
  let report;
8674
8683
  try {
@@ -18896,6 +18896,11 @@ var STATUS_GLYPH = {
18896
18896
  error: "\u2717",
18897
18897
  skip: "\xB7"
18898
18898
  };
18899
+ var MAX_RENDER_DEPTH = 20;
18900
+ function stepIndent(depth) {
18901
+ if (typeof depth !== "number" || !Number.isInteger(depth) || depth <= 0) return "";
18902
+ return " ".repeat(Math.min(depth, MAX_RENDER_DEPTH));
18903
+ }
18899
18904
  function stepLabel(step) {
18900
18905
  if (step.kind === "echo") return step.message ?? "";
18901
18906
  if (step.kind === "run") return `run ${step.flow ?? ""}`.trim();
@@ -18919,12 +18924,15 @@ async function flowRunToMcpContent(result, ctx) {
18919
18924
  const reason = step.reason ?? step.error;
18920
18925
  const suffix = reason ? ` \u2014 ${reason}` : "";
18921
18926
  const warning = step.warning ? ` \u26A0 ${step.warning}` : "";
18922
- blocks.push({ type: "text", text: `[${num}] ${glyph}${stepLabel(step)}${suffix}${warning}` });
18927
+ blocks.push({
18928
+ type: "text",
18929
+ text: `[${num}] ${glyph}${stepIndent(step.depth)}${stepLabel(step)}${suffix}${warning}`
18930
+ });
18923
18931
  if (step.result !== void 0) {
18924
18932
  blocks.push(...await toMcpContent(step.result, step.outputHint, ctx, step.args));
18925
18933
  }
18926
18934
  if (isRecord(step.artifacts)) {
18927
- blocks.push(...await stepArtifactBlocks(step.artifacts, step.status, ctx));
18935
+ blocks.push(...await stepArtifactBlocks(step.artifacts, step.status, ctx, step.depth));
18928
18936
  }
18929
18937
  }
18930
18938
  if (result.ok !== void 0) {
@@ -18937,7 +18945,7 @@ async function flowRunToMcpContent(result, ctx) {
18937
18945
  }
18938
18946
  return blocks;
18939
18947
  }
18940
- async function stepArtifactBlocks(artifacts, status, ctx) {
18948
+ async function stepArtifactBlocks(artifacts, status, ctx, depth) {
18941
18949
  const failed = status === "fail" || status === "error";
18942
18950
  const entries = [];
18943
18951
  let diffImage;
@@ -18953,7 +18961,8 @@ async function stepArtifactBlocks(artifacts, status, ctx) {
18953
18961
  entries.push([k, v]);
18954
18962
  }
18955
18963
  }
18956
- const blocks = entries.length > 0 ? [{ type: "text", text: entries.map(([k, v]) => ` ${k}: ${v}`).join("\n") }] : [];
18964
+ const indent = stepIndent(depth);
18965
+ const blocks = entries.length > 0 ? [{ type: "text", text: entries.map(([k, v]) => ` ${indent}${k}: ${v}`).join("\n") }] : [];
18957
18966
  if (diffImage) blocks.push(diffImage);
18958
18967
  return blocks;
18959
18968
  }
@@ -105916,6 +105916,7 @@ var import_node_util8 = require("node:util");
105916
105916
 
105917
105917
  // ../tool-server/src/utils/simctl-config.ts
105918
105918
  var SIMCTL_SPAWN_TIMEOUT_MS = 1e4;
105919
+ var SIMCTL_KILL_SIGNAL = "SIGKILL";
105919
105920
 
105920
105921
  // ../tool-server/src/utils/ios-devices.ts
105921
105922
  var import_node_child_process6 = require("node:child_process");
@@ -105924,7 +105925,8 @@ var execFileAsync5 = (0, import_node_util5.promisify)(import_node_child_process6
105924
105925
  async function listIosSimulators() {
105925
105926
  try {
105926
105927
  const { stdout } = await execFileAsync5("xcrun", ["simctl", "list", "devices", "--json"], {
105927
- timeout: 1e4
105928
+ timeout: 1e4,
105929
+ killSignal: SIMCTL_KILL_SIGNAL
105928
105930
  });
105929
105931
  const data = JSON.parse(stdout);
105930
105932
  const out = [];
@@ -105986,7 +105988,7 @@ async function ensureAutomationEnabled(udid) {
105986
105988
  "-bool",
105987
105989
  "true"
105988
105990
  ],
105989
- { timeout: SIMCTL_SPAWN_TIMEOUT_MS }
105991
+ { timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
105990
105992
  );
105991
105993
  }
105992
105994
  async function isEntitlementBypassActive(udid) {
@@ -106001,7 +106003,7 @@ async function isEntitlementBypassActive(udid) {
106001
106003
  "com.apple.Accessibility",
106002
106004
  "IgnoreAXServerEntitlements"
106003
106005
  ],
106004
- { timeout: SIMCTL_SPAWN_TIMEOUT_MS }
106006
+ { timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
106005
106007
  ).then(({ stdout }) => stdout.trim() === "1").catch(() => false);
106006
106008
  }
106007
106009
  function accessibilityPlistPath(udid) {
@@ -106236,7 +106238,7 @@ async function ensureAccessibilityEnabled(udid) {
106236
106238
  "-bool",
106237
106239
  "true"
106238
106240
  ],
106239
- { timeout: SIMCTL_SPAWN_TIMEOUT_MS }
106241
+ { timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
106240
106242
  )
106241
106243
  )
106242
106244
  );
@@ -106246,7 +106248,7 @@ async function setupNativeDevtoolsEnvLocal(udid, endpoint) {
106246
106248
  const result = await execFileAsync8(
106247
106249
  "xcrun",
106248
106250
  ["simctl", "spawn", udid, "launchctl", "getenv", "DYLD_INSERT_LIBRARIES"],
106249
- { encoding: "utf8", timeout: SIMCTL_SPAWN_TIMEOUT_MS }
106251
+ { encoding: "utf8", timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
106250
106252
  ).catch((e) => ({ stdout: e.stdout ?? "" }));
106251
106253
  const existing = (result.stdout ?? "").trim();
106252
106254
  const updated = buildDyldInsertLibraries(existing, bootstrapPath);
@@ -106254,7 +106256,7 @@ async function setupNativeDevtoolsEnvLocal(udid, endpoint) {
106254
106256
  await execFileAsync8(
106255
106257
  "xcrun",
106256
106258
  ["simctl", "spawn", udid, "launchctl", "setenv", "DYLD_INSERT_LIBRARIES", updated],
106257
- { timeout: SIMCTL_SPAWN_TIMEOUT_MS }
106259
+ { timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
106258
106260
  );
106259
106261
  }
106260
106262
  if (endpoint.transport === "tcp") {
@@ -106272,7 +106274,7 @@ async function setupNativeDevtoolsEnvLocal(udid, endpoint) {
106272
106274
  "NATIVE_DEVTOOLS_IOS_CDP_PORT",
106273
106275
  String(endpoint.port)
106274
106276
  ],
106275
- { timeout: SIMCTL_SPAWN_TIMEOUT_MS }
106277
+ { timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
106276
106278
  );
106277
106279
  } else {
106278
106280
  await execFileAsync8(
@@ -106286,7 +106288,7 @@ async function setupNativeDevtoolsEnvLocal(udid, endpoint) {
106286
106288
  "NATIVE_DEVTOOLS_IOS_CDP_SOCKET",
106287
106289
  endpoint.socketPath
106288
106290
  ],
106289
- { timeout: SIMCTL_SPAWN_TIMEOUT_MS }
106291
+ { timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
106290
106292
  );
106291
106293
  }
106292
106294
  await ensureAccessibilityEnabled(udid);
@@ -106316,7 +106318,9 @@ function parseUIKitApplicationBundleIds(stdout) {
106316
106318
  }
106317
106319
  async function listRunningUIKitApplicationBundleIds(udid) {
106318
106320
  const { stdout } = await execFileAsync8("xcrun", ["simctl", "spawn", udid, "launchctl", "list"], {
106319
- encoding: "utf8"
106321
+ encoding: "utf8",
106322
+ timeout: SIMCTL_SPAWN_TIMEOUT_MS,
106323
+ killSignal: SIMCTL_KILL_SIGNAL
106320
106324
  });
106321
106325
  return parseUIKitApplicationBundleIds(stdout);
106322
106326
  }
@@ -149128,7 +149132,11 @@ returns a notice with the prerequisite instead of running.`,
149128
149132
  };
149129
149133
  let aborted2;
149130
149134
  try {
149131
- await execSteps(state3, flow.steps, params.name, [params.name]);
149135
+ await execSteps(state3, flow.steps, {
149136
+ flow: params.name,
149137
+ runStack: [params.name],
149138
+ depth: 0
149139
+ });
149132
149140
  } finally {
149133
149141
  aborted2 = state3.signal?.aborted === true;
149134
149142
  if (state3.pinned) await restoreStatusBar(device);
@@ -149263,7 +149271,13 @@ function stepTarget(step) {
149263
149271
  return void 0;
149264
149272
  }
149265
149273
  }
149266
- async function execSteps(state3, steps, sourceFlow, runStack) {
149274
+ function childScope(scope, overrides = {}) {
149275
+ return { ...scope, ...overrides, depth: scope.depth + 1 };
149276
+ }
149277
+ function depthOf(scope) {
149278
+ return scope.depth ? { depth: scope.depth } : {};
149279
+ }
149280
+ async function execSteps(state3, steps, scope) {
149267
149281
  for (const step of steps) {
149268
149282
  const index = state3.reports.length;
149269
149283
  if (state3.stopped) {
@@ -149271,13 +149285,14 @@ async function execSteps(state3, steps, sourceFlow, runStack) {
149271
149285
  index,
149272
149286
  kind: step.kind,
149273
149287
  status: "skip",
149274
- flow: sourceFlow,
149288
+ flow: scope.flow,
149275
149289
  target: stepTarget(step),
149290
+ ...depthOf(scope),
149276
149291
  // Carry the echo's message so a skipped narration renders as a skip
149277
149292
  // line rather than vanishing — matching reportBlockSkipped.
149278
149293
  ...step.kind === "echo" ? { message: step.message } : {}
149279
149294
  });
149280
- if (step.kind === "when") reportBlockSkipped(state3, step.steps, sourceFlow);
149295
+ if (step.kind === "when") reportBlockSkipped(state3, step.steps, childScope(scope));
149281
149296
  continue;
149282
149297
  }
149283
149298
  if (state3.signal?.aborted) {
@@ -149287,22 +149302,25 @@ async function execSteps(state3, steps, sourceFlow, runStack) {
149287
149302
  kind: step.kind,
149288
149303
  status: "skip",
149289
149304
  reason: "run aborted",
149290
- flow: sourceFlow,
149305
+ flow: scope.flow,
149291
149306
  target: stepTarget(step),
149307
+ ...depthOf(scope),
149292
149308
  ...step.kind === "echo" ? { message: step.message } : {}
149293
149309
  });
149294
- if (step.kind === "when") reportBlockSkipped(state3, step.steps, sourceFlow, "run aborted");
149310
+ if (step.kind === "when") {
149311
+ reportBlockSkipped(state3, step.steps, childScope(scope), "run aborted");
149312
+ }
149295
149313
  continue;
149296
149314
  }
149297
149315
  if (step.kind === "run") {
149298
- await execRunStep(state3, step, runStack);
149316
+ await execRunStep(state3, step, scope);
149299
149317
  continue;
149300
149318
  }
149301
149319
  if (step.kind === "when") {
149302
- await execWhenStep(state3, step, sourceFlow, runStack);
149320
+ await execWhenStep(state3, step, scope);
149303
149321
  continue;
149304
149322
  }
149305
- const report = await execLeafStep(state3, step, index, sourceFlow);
149323
+ const report = await execLeafStep(state3, step, index, scope);
149306
149324
  pushReport(state3, report);
149307
149325
  if (report.status === "fail" || report.status === "error") state3.stopped = true;
149308
149326
  }
@@ -149311,7 +149329,7 @@ function describeWhenCondition(cond) {
149311
149329
  if (cond.kind === "platform") return `platform ${cond.platform}`;
149312
149330
  return conditionLabel(cond, describeSelector);
149313
149331
  }
149314
- function reportBlockSkipped(state3, steps, sourceFlow, reason) {
149332
+ function reportBlockSkipped(state3, steps, scope, reason) {
149315
149333
  for (const step of steps) {
149316
149334
  pushReport(state3, {
149317
149335
  index: state3.reports.length,
@@ -149321,17 +149339,20 @@ function reportBlockSkipped(state3, steps, sourceFlow, reason) {
149321
149339
  // A `run:` line is attributed to the fragment it names, matching the
149322
149340
  // executed marker in execRunStep; everything else belongs to the
149323
149341
  // enclosing flow.
149324
- flow: step.kind === "run" ? step.flow : sourceFlow,
149342
+ flow: step.kind === "run" ? step.flow : scope.flow,
149325
149343
  target: stepTarget(step),
149344
+ ...depthOf(scope),
149326
149345
  ...step.kind === "echo" ? { message: step.message } : {}
149327
149346
  });
149328
- if (step.kind === "when") reportBlockSkipped(state3, step.steps, sourceFlow, reason);
149347
+ if (step.kind === "when") reportBlockSkipped(state3, step.steps, childScope(scope), reason);
149329
149348
  }
149330
149349
  }
149331
- async function execWhenStep(state3, step, sourceFlow, runStack) {
149350
+ async function execWhenStep(state3, step, scope) {
149332
149351
  const index = state3.reports.length;
149333
149352
  const label = describeWhenCondition(step.condition);
149334
149353
  const target = stepTarget(step);
149354
+ const marker = { index, kind: "when", flow: scope.flow, target, ...depthOf(scope) };
149355
+ const inner = childScope(scope);
149335
149356
  let met;
149336
149357
  if (step.condition.kind === "platform") {
149337
149358
  const platform = state3.device.platform === "ios-remote" ? "ios" : state3.device.platform;
@@ -149339,28 +149360,18 @@ async function execWhenStep(state3, step, sourceFlow, runStack) {
149339
149360
  } else {
149340
149361
  const probe3 = await probeWhenCondition(state3, step.condition);
149341
149362
  if (probe3.aborted) {
149342
- pushReport(state3, {
149343
- index,
149344
- kind: "when",
149345
- status: "skip",
149346
- reason: "run aborted",
149347
- flow: sourceFlow,
149348
- target
149349
- });
149350
- reportBlockSkipped(state3, step.steps, sourceFlow, "run aborted");
149363
+ pushReport(state3, { ...marker, status: "skip", reason: "run aborted" });
149364
+ reportBlockSkipped(state3, step.steps, inner, "run aborted");
149351
149365
  return;
149352
149366
  }
149353
149367
  if (!probe3.ok && probe3.indeterminate) {
149354
149368
  pushReport(state3, {
149355
- index,
149356
- kind: "when",
149369
+ ...marker,
149357
149370
  status: "error",
149358
- reason: `could not evaluate when guard (${label}): ${probe3.reason}`,
149359
- flow: sourceFlow,
149360
- target
149371
+ reason: `could not evaluate when guard (${label}): ${probe3.reason}`
149361
149372
  });
149362
149373
  state3.stopped = true;
149363
- reportBlockSkipped(state3, step.steps, sourceFlow, "when guard errored");
149374
+ reportBlockSkipped(state3, step.steps, inner, "when guard errored");
149364
149375
  return;
149365
149376
  }
149366
149377
  met = probe3.ok;
@@ -149368,37 +149379,34 @@ async function execWhenStep(state3, step, sourceFlow, runStack) {
149368
149379
  if (!met) {
149369
149380
  const n = step.steps.length;
149370
149381
  pushReport(state3, {
149371
- index,
149372
- kind: "when",
149382
+ ...marker,
149373
149383
  status: "skip",
149374
- reason: `condition not met (${label}) \u2014 block skipped (${n} step${n === 1 ? "" : "s"})`,
149375
- flow: sourceFlow,
149376
- target
149384
+ reason: `condition not met (${label}) \u2014 block skipped (${n} step${n === 1 ? "" : "s"})`
149377
149385
  });
149378
- reportBlockSkipped(state3, step.steps, sourceFlow, "when block skipped");
149386
+ reportBlockSkipped(state3, step.steps, inner, "when block skipped");
149379
149387
  return;
149380
149388
  }
149381
- pushReport(state3, {
149382
- index,
149383
- kind: "when",
149384
- status: "pass",
149385
- reason: `condition met (${label})`,
149386
- flow: sourceFlow,
149387
- target
149388
- });
149389
- await execSteps(state3, step.steps, sourceFlow, runStack);
149389
+ pushReport(state3, { ...marker, status: "pass", reason: `condition met (${label})` });
149390
+ await execSteps(state3, step.steps, inner);
149390
149391
  }
149391
- async function execRunStep(state3, step, runStack) {
149392
+ async function execRunStep(state3, step, scope) {
149392
149393
  const index = state3.reports.length;
149393
149394
  const target = step.flow;
149394
149395
  const fail = (reason) => {
149395
- pushReport(state3, { index, kind: "run", status: "error", flow: target, reason });
149396
+ pushReport(state3, {
149397
+ index,
149398
+ kind: "run",
149399
+ status: "error",
149400
+ flow: target,
149401
+ reason,
149402
+ ...depthOf(scope)
149403
+ });
149396
149404
  state3.stopped = true;
149397
149405
  };
149398
- if (runStack.includes(target)) {
149399
- return fail(`cyclic flow reference: ${[...runStack, target].join(" \u2192 ")}`);
149406
+ if (scope.runStack.includes(target)) {
149407
+ return fail(`cyclic flow reference: ${[...scope.runStack, target].join(" \u2192 ")}`);
149400
149408
  }
149401
- if (runStack.length >= MAX_RUN_DEPTH) {
149409
+ if (scope.runStack.length >= MAX_RUN_DEPTH) {
149402
149410
  return fail("max run depth exceeded");
149403
149411
  }
149404
149412
  let fragment;
@@ -149409,11 +149417,21 @@ async function execRunStep(state3, step, runStack) {
149409
149417
  } catch (err) {
149410
149418
  return fail(`could not load fragment "${target}": ${errMsg2(err)}`);
149411
149419
  }
149412
- pushReport(state3, { index, kind: "run", status: "pass", flow: target });
149413
- await execSteps(state3, fragment.steps, target, [...runStack, target]);
149420
+ pushReport(state3, { index, kind: "run", status: "pass", flow: target, ...depthOf(scope) });
149421
+ await execSteps(
149422
+ state3,
149423
+ fragment.steps,
149424
+ childScope(scope, { flow: target, runStack: [...scope.runStack, target] })
149425
+ );
149414
149426
  }
149415
- async function execLeafStep(state3, step, index, sourceFlow) {
149416
- const base = { index, kind: step.kind, flow: sourceFlow, target: stepTarget(step) };
149427
+ async function execLeafStep(state3, step, index, scope) {
149428
+ const base = {
149429
+ index,
149430
+ kind: step.kind,
149431
+ flow: scope.flow,
149432
+ target: stepTarget(step),
149433
+ ...depthOf(scope)
149434
+ };
149417
149435
  const { registry: registry2, ctx, device, signal } = state3;
149418
149436
  switch (step.kind) {
149419
149437
  case "echo":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.16.1-next.7",
3
+ "version": "0.16.1-next.9",
4
4
  "description": "MCP server for iOS Simulator and Android Emulator control",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {