@swmansion/argent 0.16.1-next.8 → 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
  }
@@ -149132,7 +149132,11 @@ returns a notice with the prerequisite instead of running.`,
149132
149132
  };
149133
149133
  let aborted2;
149134
149134
  try {
149135
- 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
+ });
149136
149140
  } finally {
149137
149141
  aborted2 = state3.signal?.aborted === true;
149138
149142
  if (state3.pinned) await restoreStatusBar(device);
@@ -149267,7 +149271,13 @@ function stepTarget(step) {
149267
149271
  return void 0;
149268
149272
  }
149269
149273
  }
149270
- 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) {
149271
149281
  for (const step of steps) {
149272
149282
  const index = state3.reports.length;
149273
149283
  if (state3.stopped) {
@@ -149275,13 +149285,14 @@ async function execSteps(state3, steps, sourceFlow, runStack) {
149275
149285
  index,
149276
149286
  kind: step.kind,
149277
149287
  status: "skip",
149278
- flow: sourceFlow,
149288
+ flow: scope.flow,
149279
149289
  target: stepTarget(step),
149290
+ ...depthOf(scope),
149280
149291
  // Carry the echo's message so a skipped narration renders as a skip
149281
149292
  // line rather than vanishing — matching reportBlockSkipped.
149282
149293
  ...step.kind === "echo" ? { message: step.message } : {}
149283
149294
  });
149284
- if (step.kind === "when") reportBlockSkipped(state3, step.steps, sourceFlow);
149295
+ if (step.kind === "when") reportBlockSkipped(state3, step.steps, childScope(scope));
149285
149296
  continue;
149286
149297
  }
149287
149298
  if (state3.signal?.aborted) {
@@ -149291,22 +149302,25 @@ async function execSteps(state3, steps, sourceFlow, runStack) {
149291
149302
  kind: step.kind,
149292
149303
  status: "skip",
149293
149304
  reason: "run aborted",
149294
- flow: sourceFlow,
149305
+ flow: scope.flow,
149295
149306
  target: stepTarget(step),
149307
+ ...depthOf(scope),
149296
149308
  ...step.kind === "echo" ? { message: step.message } : {}
149297
149309
  });
149298
- 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
+ }
149299
149313
  continue;
149300
149314
  }
149301
149315
  if (step.kind === "run") {
149302
- await execRunStep(state3, step, runStack);
149316
+ await execRunStep(state3, step, scope);
149303
149317
  continue;
149304
149318
  }
149305
149319
  if (step.kind === "when") {
149306
- await execWhenStep(state3, step, sourceFlow, runStack);
149320
+ await execWhenStep(state3, step, scope);
149307
149321
  continue;
149308
149322
  }
149309
- const report = await execLeafStep(state3, step, index, sourceFlow);
149323
+ const report = await execLeafStep(state3, step, index, scope);
149310
149324
  pushReport(state3, report);
149311
149325
  if (report.status === "fail" || report.status === "error") state3.stopped = true;
149312
149326
  }
@@ -149315,7 +149329,7 @@ function describeWhenCondition(cond) {
149315
149329
  if (cond.kind === "platform") return `platform ${cond.platform}`;
149316
149330
  return conditionLabel(cond, describeSelector);
149317
149331
  }
149318
- function reportBlockSkipped(state3, steps, sourceFlow, reason) {
149332
+ function reportBlockSkipped(state3, steps, scope, reason) {
149319
149333
  for (const step of steps) {
149320
149334
  pushReport(state3, {
149321
149335
  index: state3.reports.length,
@@ -149325,17 +149339,20 @@ function reportBlockSkipped(state3, steps, sourceFlow, reason) {
149325
149339
  // A `run:` line is attributed to the fragment it names, matching the
149326
149340
  // executed marker in execRunStep; everything else belongs to the
149327
149341
  // enclosing flow.
149328
- flow: step.kind === "run" ? step.flow : sourceFlow,
149342
+ flow: step.kind === "run" ? step.flow : scope.flow,
149329
149343
  target: stepTarget(step),
149344
+ ...depthOf(scope),
149330
149345
  ...step.kind === "echo" ? { message: step.message } : {}
149331
149346
  });
149332
- if (step.kind === "when") reportBlockSkipped(state3, step.steps, sourceFlow, reason);
149347
+ if (step.kind === "when") reportBlockSkipped(state3, step.steps, childScope(scope), reason);
149333
149348
  }
149334
149349
  }
149335
- async function execWhenStep(state3, step, sourceFlow, runStack) {
149350
+ async function execWhenStep(state3, step, scope) {
149336
149351
  const index = state3.reports.length;
149337
149352
  const label = describeWhenCondition(step.condition);
149338
149353
  const target = stepTarget(step);
149354
+ const marker = { index, kind: "when", flow: scope.flow, target, ...depthOf(scope) };
149355
+ const inner = childScope(scope);
149339
149356
  let met;
149340
149357
  if (step.condition.kind === "platform") {
149341
149358
  const platform = state3.device.platform === "ios-remote" ? "ios" : state3.device.platform;
@@ -149343,28 +149360,18 @@ async function execWhenStep(state3, step, sourceFlow, runStack) {
149343
149360
  } else {
149344
149361
  const probe3 = await probeWhenCondition(state3, step.condition);
149345
149362
  if (probe3.aborted) {
149346
- pushReport(state3, {
149347
- index,
149348
- kind: "when",
149349
- status: "skip",
149350
- reason: "run aborted",
149351
- flow: sourceFlow,
149352
- target
149353
- });
149354
- reportBlockSkipped(state3, step.steps, sourceFlow, "run aborted");
149363
+ pushReport(state3, { ...marker, status: "skip", reason: "run aborted" });
149364
+ reportBlockSkipped(state3, step.steps, inner, "run aborted");
149355
149365
  return;
149356
149366
  }
149357
149367
  if (!probe3.ok && probe3.indeterminate) {
149358
149368
  pushReport(state3, {
149359
- index,
149360
- kind: "when",
149369
+ ...marker,
149361
149370
  status: "error",
149362
- reason: `could not evaluate when guard (${label}): ${probe3.reason}`,
149363
- flow: sourceFlow,
149364
- target
149371
+ reason: `could not evaluate when guard (${label}): ${probe3.reason}`
149365
149372
  });
149366
149373
  state3.stopped = true;
149367
- reportBlockSkipped(state3, step.steps, sourceFlow, "when guard errored");
149374
+ reportBlockSkipped(state3, step.steps, inner, "when guard errored");
149368
149375
  return;
149369
149376
  }
149370
149377
  met = probe3.ok;
@@ -149372,37 +149379,34 @@ async function execWhenStep(state3, step, sourceFlow, runStack) {
149372
149379
  if (!met) {
149373
149380
  const n = step.steps.length;
149374
149381
  pushReport(state3, {
149375
- index,
149376
- kind: "when",
149382
+ ...marker,
149377
149383
  status: "skip",
149378
- reason: `condition not met (${label}) \u2014 block skipped (${n} step${n === 1 ? "" : "s"})`,
149379
- flow: sourceFlow,
149380
- target
149384
+ reason: `condition not met (${label}) \u2014 block skipped (${n} step${n === 1 ? "" : "s"})`
149381
149385
  });
149382
- reportBlockSkipped(state3, step.steps, sourceFlow, "when block skipped");
149386
+ reportBlockSkipped(state3, step.steps, inner, "when block skipped");
149383
149387
  return;
149384
149388
  }
149385
- pushReport(state3, {
149386
- index,
149387
- kind: "when",
149388
- status: "pass",
149389
- reason: `condition met (${label})`,
149390
- flow: sourceFlow,
149391
- target
149392
- });
149393
- await execSteps(state3, step.steps, sourceFlow, runStack);
149389
+ pushReport(state3, { ...marker, status: "pass", reason: `condition met (${label})` });
149390
+ await execSteps(state3, step.steps, inner);
149394
149391
  }
149395
- async function execRunStep(state3, step, runStack) {
149392
+ async function execRunStep(state3, step, scope) {
149396
149393
  const index = state3.reports.length;
149397
149394
  const target = step.flow;
149398
149395
  const fail = (reason) => {
149399
- 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
+ });
149400
149404
  state3.stopped = true;
149401
149405
  };
149402
- if (runStack.includes(target)) {
149403
- 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 ")}`);
149404
149408
  }
149405
- if (runStack.length >= MAX_RUN_DEPTH) {
149409
+ if (scope.runStack.length >= MAX_RUN_DEPTH) {
149406
149410
  return fail("max run depth exceeded");
149407
149411
  }
149408
149412
  let fragment;
@@ -149413,11 +149417,21 @@ async function execRunStep(state3, step, runStack) {
149413
149417
  } catch (err) {
149414
149418
  return fail(`could not load fragment "${target}": ${errMsg2(err)}`);
149415
149419
  }
149416
- pushReport(state3, { index, kind: "run", status: "pass", flow: target });
149417
- 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
+ );
149418
149426
  }
149419
- async function execLeafStep(state3, step, index, sourceFlow) {
149420
- 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
+ };
149421
149435
  const { registry: registry2, ctx, device, signal } = state3;
149422
149436
  switch (step.kind) {
149423
149437
  case "echo":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.16.1-next.8",
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": {