@contentful/experience-design-system-cli 2.40.1-dev-build-46595419.0 → 2.40.1-dev-build-d17741e4.0

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/app.js CHANGED
@@ -292,9 +292,10 @@ function startDebugRun({
292
292
  const runId = generateRunId();
293
293
  const startedAt = Date.now();
294
294
  const redactedInputs = redact(inputs);
295
- isDebugModeEnabled().then((enabled) => {
296
- if (!enabled) return;
297
- pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
295
+ const run = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
296
+ pendingRun = run;
297
+ void isDebugModeEnabled().then((enabled) => {
298
+ if (!enabled && pendingRun === run) pendingRun = void 0;
298
299
  });
299
300
  }
300
301
  async function finishDebugRun({
@@ -305,9 +306,10 @@ async function finishDebugRun({
305
306
  const run = pendingRun;
306
307
  if (!run) return;
307
308
  pendingRun = void 0;
309
+ if (!await isDebugModeEnabled()) return;
308
310
  const durationMs = Date.now() - run.startedAt;
309
311
  const log = {
310
- flow: run.flow,
312
+ flow: logFolder(run.flow, run.step),
311
313
  menuOption: run.menuOption,
312
314
  content: renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs })
313
315
  };
@@ -318,6 +320,9 @@ async function finishDebugRun({
318
320
  }
319
321
  await writeLog(root, log);
320
322
  }
323
+ function logFolder(flow, step) {
324
+ return flow.startsWith("import/") && /^\d+-/.test(step) ? `import/${step}` : flow;
325
+ }
321
326
  async function writeLog(root, log) {
322
327
  const dir = join5(root, ...log.flow.split("/"));
323
328
  await mkdir2(dir, { recursive: true });
@@ -922,19 +927,19 @@ function readToolCallObjects(stdout) {
922
927
  const line = raw.trim();
923
928
  if (!line.startsWith("{"))
924
929
  continue;
925
- const end = findJsonObjectEnd(line);
926
- if (end === -1) {
930
+ const end2 = findJsonObjectEnd(line);
931
+ if (end2 === -1) {
927
932
  warnings.push(`unparseable line: ${line.slice(0, 120)}`);
928
933
  continue;
929
934
  }
930
935
  let parsed;
931
936
  try {
932
- parsed = JSON.parse(line.slice(0, end + 1));
937
+ parsed = JSON.parse(line.slice(0, end2 + 1));
933
938
  } catch {
934
939
  warnings.push(`unparseable line: ${line.slice(0, 120)}`);
935
940
  continue;
936
941
  }
937
- const trailing = line.slice(end + 1);
942
+ const trailing = line.slice(end2 + 1);
938
943
  if (trailing.trim()) {
939
944
  warnings.push(`ignored trailing content after JSON: ${trailing.trim().slice(0, 120)}`);
940
945
  }
@@ -2484,7 +2489,7 @@ var init_cache_keys = __esm({
2484
2489
  });
2485
2490
 
2486
2491
  // packages/experience-design-system-cli/app.tsx
2487
- import { useEffect as useEffect31, useState as useState39 } from "react";
2492
+ import { useEffect as useEffect35, useState as useState39 } from "react";
2488
2493
 
2489
2494
  // packages/experience-design-system-cli/src/tui/home/home.tsx
2490
2495
  import { useEffect as useEffect2, useState as useState2 } from "react";
@@ -3587,14 +3592,14 @@ function excerptAroundNames(text, names, maxChars, contextLines = 6) {
3587
3592
  if (mentioned.length === 0)
3588
3593
  return;
3589
3594
  const start = Math.max(0, index - contextLines);
3590
- const end = Math.min(lines.length - 1, index + contextLines);
3595
+ const end2 = Math.min(lines.length - 1, index + contextLines);
3591
3596
  const last = windows[windows.length - 1];
3592
3597
  if (last && start <= last.end + 1) {
3593
- last.end = Math.max(last.end, end);
3598
+ last.end = Math.max(last.end, end2);
3594
3599
  for (const name of mentioned)
3595
3600
  last.names.add(name);
3596
3601
  } else {
3597
- windows.push({ start, end, names: new Set(mentioned) });
3602
+ windows.push({ start, end: end2, names: new Set(mentioned) });
3598
3603
  }
3599
3604
  });
3600
3605
  if (windows.length === 0) {
@@ -11599,10 +11604,10 @@ async function resolveViaTypeChecker(annotation, instance, moduleScript, filePat
11599
11604
  }
11600
11605
  function sliceSource(source, node) {
11601
11606
  const start = node["start"] ?? null;
11602
- const end = node["end"] ?? null;
11603
- if (start == null || end == null)
11607
+ const end2 = node["end"] ?? null;
11608
+ if (start == null || end2 == null)
11604
11609
  return null;
11605
- return source.slice(start, end);
11610
+ return source.slice(start, end2);
11606
11611
  }
11607
11612
  function sliceScriptContent(source, script) {
11608
11613
  if (!script)
@@ -17402,10 +17407,10 @@ async function readCandidateFiles(components, extraFiles = []) {
17402
17407
  async function selectCompositionPromptFiles(components, sourceFiles) {
17403
17408
  const allFiles = await readCandidateFiles(components, sourceFiles);
17404
17409
  const selectedCandidates = selectCandidateFiles(allFiles).map((c2) => ({ path: c2.path, content: c2.content }));
17405
- const capped = capCandidatesToPromptBudget(selectedCandidates);
17406
- const promptFiles = capped.kept;
17410
+ const capped2 = capCandidatesToPromptBudget(selectedCandidates);
17411
+ const promptFiles = capped2.kept;
17407
17412
  const runtimeFiles = allFiles.map((c2) => ({ path: c2.path, content: c2.content }));
17408
- const droppedWarning = capped.dropped.length > 0 ? `composition \u2014 ${capped.dropped.length} candidate file(s) omitted from the agent prompt to fit the context budget; resolution runs on the ${promptFiles.length} highest-value files.` : void 0;
17413
+ const droppedWarning = capped2.dropped.length > 0 ? `composition \u2014 ${capped2.dropped.length} candidate file(s) omitted from the agent prompt to fit the context budget; resolution runs on the ${promptFiles.length} highest-value files.` : void 0;
17409
17414
  return { promptFiles, runtimeFiles, droppedWarning };
17410
17415
  }
17411
17416
 
@@ -18157,8 +18162,9 @@ function PathValidationScreen({
18157
18162
  }
18158
18163
 
18159
18164
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
18160
- import { useRef as useRef5, useState as useState9 } from "react";
18165
+ import { useEffect as useEffect8, useRef as useRef5, useState as useState9 } from "react";
18161
18166
  import { Box as Box14, Text as Text14, useInput as useInput11 } from "ink";
18167
+ init_debug_store();
18162
18168
 
18163
18169
  // packages/experience-design-system-cli/src/tui/shared/components/FieldForm.tsx
18164
18170
  import { useState as useState8 } from "react";
@@ -18191,7 +18197,7 @@ function FieldForm({
18191
18197
  onSkip,
18192
18198
  skipLabel: skipLabel2 = "skip",
18193
18199
  onQuit,
18194
- quitLabel = "back (unsaved changes are lost)",
18200
+ quitLabel = "back without saving",
18195
18201
  actions = [],
18196
18202
  notice,
18197
18203
  busy = false,
@@ -18254,7 +18260,7 @@ function FieldForm({
18254
18260
  }
18255
18261
  if (isLastField) {
18256
18262
  setEditing(false);
18257
- setActive(0);
18263
+ onSave();
18258
18264
  return;
18259
18265
  }
18260
18266
  const next = fields2[active + 1];
@@ -18318,7 +18324,7 @@ function FieldForm({
18318
18324
  hints: editing ? [
18319
18325
  { keys: "type", label: "edit" },
18320
18326
  { keys: "\u2190/\u2192", label: "move cursor" },
18321
- { keys: "\u23CE", label: enterAdvances && !isLastField ? "next" : "done" },
18327
+ { keys: "\u23CE", label: enterAdvances ? isLastField ? saveLabel : "next" : "done" },
18322
18328
  { keys: "Ctrl+D", label: "clear" },
18323
18329
  { keys: "Esc", label: "cancel edit" }
18324
18330
  ] : [
@@ -18335,6 +18341,39 @@ function FieldForm({
18335
18341
  ] });
18336
18342
  }
18337
18343
 
18344
+ // packages/experience-design-system-cli/src/tui/shared/debug-trail.ts
18345
+ init_config();
18346
+ import { existsSync as existsSync9 } from "node:fs";
18347
+ function diffSnapshots(before, after) {
18348
+ const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
18349
+ const changed_fields = names.filter((name) => before[name] !== after[name]);
18350
+ return { changed: changed_fields.length > 0, changed_fields };
18351
+ }
18352
+ var DEFAULT_TRAIL_LIMIT = 30;
18353
+ function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
18354
+ const actions = [];
18355
+ return {
18356
+ record(action) {
18357
+ actions.push(action);
18358
+ if (actions.length > limit) actions.shift();
18359
+ },
18360
+ entries: () => [...actions]
18361
+ };
18362
+ }
18363
+ var MIN_SECRET_LENGTH = 6;
18364
+ function scrubError(error, secrets) {
18365
+ let message = error instanceof Error ? error.message : String(error);
18366
+ for (const secret of secrets) {
18367
+ if (secret.length < MIN_SECRET_LENGTH) continue;
18368
+ for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
18369
+ }
18370
+ return message;
18371
+ }
18372
+ function describeSettingsFile() {
18373
+ const path5 = configFilePath();
18374
+ return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync9(path5) };
18375
+ }
18376
+
18338
18377
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
18339
18378
  var FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
18340
18379
  function credentialsPurpose(tokensOnly) {
@@ -18349,12 +18388,36 @@ function normalize(values) {
18349
18388
  host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
18350
18389
  };
18351
18390
  }
18352
- function missingField(values) {
18353
- return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
18391
+ function missingFields(values) {
18392
+ return ["spaceId", "environmentId", "cmaToken"].filter((field) => values[field] === "");
18354
18393
  }
18355
18394
  function isUnchanged(current, initial) {
18356
18395
  return FIELDS.every((field) => current[field] === initial[field]);
18357
18396
  }
18397
+ function rejectedAttempt(reason, credentials) {
18398
+ return { host: credentials.host, reason: scrubError(reason, [credentials.cmaToken]) };
18399
+ }
18400
+ function credentialsLog(credentials) {
18401
+ return {
18402
+ space_id: credentials.spaceId,
18403
+ environment_id: credentials.environmentId,
18404
+ host: credentials.host,
18405
+ cma_token: credentials.cmaToken
18406
+ };
18407
+ }
18408
+ function credentialsOutputs({
18409
+ outcome,
18410
+ credentials,
18411
+ initial,
18412
+ attempts
18413
+ }) {
18414
+ return {
18415
+ outcome,
18416
+ ...credentialsLog(credentials),
18417
+ changed_fields: diffSnapshots(initial, credentials).changed_fields,
18418
+ rejected_attempts: attempts
18419
+ };
18420
+ }
18358
18421
 
18359
18422
  // packages/experience-design-system-cli/src/tui/user-agent.ts
18360
18423
  init_version();
@@ -18402,7 +18465,9 @@ var MENU = [
18402
18465
  { choice: "continue", label: "Continue", description: "Check the credentials and go on" },
18403
18466
  { choice: "edit", label: "Edit", description: "Change the credentials" }
18404
18467
  ];
18468
+ var MAX_LOGGED_ATTEMPTS2 = 10;
18405
18469
  function CredentialsScreen({
18470
+ mode,
18406
18471
  onDone,
18407
18472
  onBack,
18408
18473
  initial = {},
@@ -18425,17 +18490,64 @@ function CredentialsScreen({
18425
18490
  const [focus, setFocus] = useState9(0);
18426
18491
  const [active, setActive] = useState9(0);
18427
18492
  const [beforeEdit, setBeforeEdit] = useState9(initialValues);
18493
+ const visit = useRef5({ attempts: [], lastReason: "" }).current;
18494
+ useEffect8(() => {
18495
+ startDebugRun({
18496
+ flow: "import/credentials",
18497
+ step: "04-credentials",
18498
+ menuOption: "Credentials",
18499
+ inputs: { import_mode: mode, prefilled, ...credentialsLog(initialValues) }
18500
+ });
18501
+ }, []);
18502
+ const reject = (attempt, text) => {
18503
+ if (visit.attempts.length < MAX_LOGGED_ATTEMPTS2) visit.attempts.push(attempt);
18504
+ visit.lastReason = attempt.reason;
18505
+ setNotice({ kind: "error", text });
18506
+ };
18507
+ const leave = () => {
18508
+ void finishDebugRun({
18509
+ outputs: {
18510
+ ...credentialsOutputs({
18511
+ outcome: "back",
18512
+ credentials: normalize(values),
18513
+ initial: initialValues,
18514
+ attempts: visit.attempts
18515
+ }),
18516
+ ...notice ? { error: visit.lastReason } : {}
18517
+ },
18518
+ status: notice ? "error" : "success",
18519
+ exitMethod: "discarded"
18520
+ });
18521
+ onBack();
18522
+ };
18428
18523
  const submit = async () => {
18429
18524
  const credentials = normalize(values);
18430
- if (missingField(credentials)) {
18431
- setNotice({ kind: "error", text: "Space ID, environment and CMA token are all required." });
18525
+ const missing = missingFields(credentials);
18526
+ if (missing.length > 0) {
18527
+ reject(
18528
+ rejectedAttempt(`Missing required fields: ${missing.join(", ")}`, credentials),
18529
+ "Space ID, environment and CMA token are all required."
18530
+ );
18432
18531
  return;
18433
18532
  }
18434
18533
  setValidating(true);
18435
18534
  const result = await validate3(credentials);
18436
18535
  setValidating(false);
18437
- if (result.ok) onDone({ skipped: false, credentials });
18438
- else setNotice({ kind: "error", text: result.error });
18536
+ if (!result.ok) {
18537
+ reject(rejectedAttempt(result.error, credentials), result.error);
18538
+ return;
18539
+ }
18540
+ void finishDebugRun({
18541
+ outputs: credentialsOutputs({
18542
+ outcome: "validated",
18543
+ credentials,
18544
+ initial: initialValues,
18545
+ attempts: visit.attempts
18546
+ }),
18547
+ status: "success",
18548
+ exitMethod: "saved"
18549
+ });
18550
+ onDone({ skipped: false, credentials });
18439
18551
  };
18440
18552
  const choose = (choice) => {
18441
18553
  if (choice === "continue") void submit();
@@ -18444,7 +18556,7 @@ function CredentialsScreen({
18444
18556
  setBeforeEdit(values);
18445
18557
  setActive(0);
18446
18558
  setEditing(true);
18447
- } else onBack();
18559
+ } else leave();
18448
18560
  };
18449
18561
  const stopEditing = () => {
18450
18562
  setEditing(false);
@@ -18454,7 +18566,7 @@ function CredentialsScreen({
18454
18566
  if (validating) return;
18455
18567
  if (editing) {
18456
18568
  if (key.escape) {
18457
- if (!prefilled) onBack();
18569
+ if (!prefilled) leave();
18458
18570
  else {
18459
18571
  setValues(beforeEdit);
18460
18572
  setNotice(null);
@@ -18562,6 +18674,47 @@ function CredentialsScreen({
18562
18674
  }
18563
18675
 
18564
18676
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts
18677
+ function extractionLogInputs(input) {
18678
+ const { credentials } = input;
18679
+ return {
18680
+ project_path: input.projectPath,
18681
+ out_dir: input.outDir ?? "",
18682
+ files_to_scan: input.filePaths.length,
18683
+ raw_tokens_path: input.rawTokensPath,
18684
+ agent: input.agent,
18685
+ agent_model: input.agentModel ?? "",
18686
+ prompt_overrides: input.promptOverrides,
18687
+ cache: !input.noCache,
18688
+ has_credentials: credentials !== null,
18689
+ space_id: credentials?.spaceId ?? "",
18690
+ environment_id: credentials?.environmentId ?? "",
18691
+ host: credentials?.host ?? "",
18692
+ cma_token: credentials?.cmaToken ?? ""
18693
+ };
18694
+ }
18695
+ function extractionLogOutputs(result, progress, cmaToken) {
18696
+ const last = progress ? { final_progress: progress } : {};
18697
+ if (!result.ok) {
18698
+ return {
18699
+ outputs: { result: "failed", failed_step: result.step, error: scrubError(result.message, [cmaToken]), ...last },
18700
+ status: "error"
18701
+ };
18702
+ }
18703
+ const { extraction } = result;
18704
+ return {
18705
+ outputs: {
18706
+ result: "done",
18707
+ session_id: extraction.sessionId,
18708
+ out_dir: extraction.outDir,
18709
+ tokens_path: extraction.tokensPath,
18710
+ token_count: extraction.tokenCount,
18711
+ existing_entities_status: extraction.existingEntitiesStatus,
18712
+ composition_phase: extraction.compositionPhase,
18713
+ ...last
18714
+ },
18715
+ status: "success"
18716
+ };
18717
+ }
18565
18718
  function initialProgress(input) {
18566
18719
  return {
18567
18720
  scan: null,
@@ -18656,8 +18809,9 @@ function ExtractionScreen({ progress, agent }) {
18656
18809
  }
18657
18810
 
18658
18811
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx
18659
- import { useMemo as useMemo2, useState as useState10 } from "react";
18812
+ import { useEffect as useEffect9, useMemo as useMemo2, useState as useState10 } from "react";
18660
18813
  import { Box as Box15, Text as Text15, useInput as useInput12 } from "ink";
18814
+ init_debug_store();
18661
18815
 
18662
18816
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-review/load.ts
18663
18817
  import { readFileSync as readFileSync9 } from "node:fs";
@@ -18694,8 +18848,8 @@ function computeColumnWindow(total, cursor, visibleCount) {
18694
18848
  if (total <= visibleCount) return { start: 0, end: total, above: 0, below: 0 };
18695
18849
  let start = Math.max(0, cursor - Math.floor(visibleCount / 2));
18696
18850
  start = Math.min(start, total - visibleCount);
18697
- const end = start + visibleCount;
18698
- return { start, end, above: start, below: total - end };
18851
+ const end2 = start + visibleCount;
18852
+ return { start, end: end2, above: start, below: total - end2 };
18699
18853
  }
18700
18854
  var TOKEN_REVIEW_CONTROLS = [
18701
18855
  { keys: "\u2191/\u2193", label: "Scroll" },
@@ -18721,12 +18875,31 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
18721
18875
  const rows = loaded.ok ? loaded.rows : [];
18722
18876
  const columns = useTerminalWidth();
18723
18877
  const [selected, setSelected] = useState10(0);
18878
+ useEffect9(() => {
18879
+ startDebugRun({
18880
+ flow: "import/token-review",
18881
+ step: "05-token-review",
18882
+ menuOption: "Token review",
18883
+ inputs: { import_mode: "tokens", tokens_path: tokensPath }
18884
+ });
18885
+ }, []);
18886
+ const finish = (outcome) => {
18887
+ void finishDebugRun({
18888
+ outputs: { outcome, ...loaded.ok ? { tokens: rows.length } : { load_error: loaded.message } },
18889
+ status: loaded.ok ? "success" : "error",
18890
+ exitMethod: outcome === "continued" ? "saved" : "discarded"
18891
+ });
18892
+ };
18724
18893
  const move = (to) => setSelected(Math.max(0, Math.min(to, rows.length - 1)));
18725
- const { start, end } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
18894
+ const { start, end: end2 } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
18726
18895
  useInput12((_input, key) => {
18727
- if (key.return) onContinue();
18728
- else if (key.escape) onQuit();
18729
- else if (key.upArrow) move(selected - 1);
18896
+ if (key.return) {
18897
+ finish("continued");
18898
+ onContinue();
18899
+ } else if (key.escape) {
18900
+ finish("back");
18901
+ onQuit();
18902
+ } else if (key.upArrow) move(selected - 1);
18730
18903
  else if (key.downArrow) move(selected + 1);
18731
18904
  else if (key.pageUp) move(selected - VISIBLE_ROWS);
18732
18905
  else if (key.pageDown) move(selected + VISIBLE_ROWS);
@@ -18762,7 +18935,7 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
18762
18935
  " ",
18763
18936
  clip("Value", valueWidth)
18764
18937
  ] }),
18765
- rows.slice(start, end).map((row, offset) => {
18938
+ rows.slice(start, end2).map((row, offset) => {
18766
18939
  const active = start + offset === selected;
18767
18940
  return /* @__PURE__ */ jsxs15(Text15, { color: active ? PALETTE.accent : void 0, bold: active, wrap: "truncate-end", children: [
18768
18941
  active ? "\u203A " : " ",
@@ -18777,7 +18950,7 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
18777
18950
  rows.length > VISIBLE_ROWS && /* @__PURE__ */ jsx17(Box15, { marginTop: 1, children: /* @__PURE__ */ jsxs15(Text15, { color: PALETTE.muted, children: [
18778
18951
  start + 1,
18779
18952
  "-",
18780
- end,
18953
+ end2,
18781
18954
  " of ",
18782
18955
  rows.length
18783
18956
  ] }) }),
@@ -18790,14 +18963,15 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
18790
18963
  init_config();
18791
18964
 
18792
18965
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
18793
- import { useEffect as useEffect8, useRef as useRef6, useState as useState11 } from "react";
18966
+ init_debug_store();
18967
+ import { useEffect as useEffect10, useRef as useRef6, useState as useState11 } from "react";
18794
18968
 
18795
18969
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
18796
18970
  import { mkdir as mkdir8 } from "node:fs/promises";
18797
18971
  import { join as join20, resolve as resolve24 } from "node:path";
18798
18972
 
18799
18973
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
18800
- import { existsSync as existsSync9 } from "node:fs";
18974
+ import { existsSync as existsSync10 } from "node:fs";
18801
18975
  import { dirname as dirname16, join as join19, resolve as resolve22 } from "node:path";
18802
18976
  import { fileURLToPath as fileURLToPath4 } from "node:url";
18803
18977
  function findSkillPath(fileName) {
@@ -18805,7 +18979,7 @@ function findSkillPath(fileName) {
18805
18979
  let dir = thisDir;
18806
18980
  for (; ; ) {
18807
18981
  const candidate = join19(dir, "skills", fileName);
18808
- if (existsSync9(candidate)) return candidate;
18982
+ if (existsSync10(candidate)) return candidate;
18809
18983
  const parent = resolve22(dir, "..");
18810
18984
  if (parent === dir) {
18811
18985
  throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
@@ -19047,7 +19221,7 @@ async function resolveSelectionPrompt(overrides) {
19047
19221
  function useExtraction(input) {
19048
19222
  const [state2, setState] = useState11();
19049
19223
  const current = useRef6();
19050
- useEffect8(() => {
19224
+ useEffect10(() => {
19051
19225
  current.current = input;
19052
19226
  if (!input) {
19053
19227
  setState(void 0);
@@ -19060,10 +19234,23 @@ function useExtraction(input) {
19060
19234
  hasRawTokens: input.rawTokensPath !== ""
19061
19235
  })
19062
19236
  });
19237
+ let lastProgress;
19238
+ startDebugRun({
19239
+ flow: "import/extraction",
19240
+ step: "06-extraction",
19241
+ menuOption: "Extraction",
19242
+ inputs: extractionLogInputs(input)
19243
+ });
19063
19244
  void runExtraction(input, (progress) => {
19245
+ lastProgress = progress;
19064
19246
  if (current.current === input) setState({ status: "running", progress });
19065
19247
  }).then((result) => {
19066
- if (current.current === input) setState({ status: "done", result });
19248
+ if (current.current !== input) return;
19249
+ void finishDebugRun({
19250
+ ...extractionLogOutputs(result, lastProgress, input.credentials?.cmaToken ?? ""),
19251
+ exitMethod: result.ok ? "saved" : "discarded"
19252
+ });
19253
+ setState({ status: "done", result });
19067
19254
  });
19068
19255
  return () => {
19069
19256
  if (current.current === input) current.current = void 0;
@@ -19073,7 +19260,7 @@ function useExtraction(input) {
19073
19260
  }
19074
19261
 
19075
19262
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-tokens-only.ts
19076
- import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
19263
+ import { useEffect as useEffect11, useRef as useRef7, useState as useState12 } from "react";
19077
19264
 
19078
19265
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run-tokens-only.ts
19079
19266
  var TOKENS_SKILL_PATH2 = findSkillPath("generate-tokens.md");
@@ -19108,7 +19295,7 @@ async function runTokensOnly(input, deps = realDeps2) {
19108
19295
  function useTokensOnly(input) {
19109
19296
  const [state2, setState] = useState12();
19110
19297
  const current = useRef7();
19111
- useEffect9(() => {
19298
+ useEffect11(() => {
19112
19299
  current.current = input;
19113
19300
  if (!input) {
19114
19301
  setState(void 0);
@@ -19126,9 +19313,37 @@ function useTokensOnly(input) {
19126
19313
  }
19127
19314
 
19128
19315
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx
19129
- import { useMemo as useMemo4 } from "react";
19316
+ init_debug_store();
19317
+ import { useEffect as useEffect14, useMemo as useMemo4 } from "react";
19130
19318
  import { Box as Box25, Text as Text26 } from "ink";
19131
19319
 
19320
+ // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts
19321
+ var MAX_NAMES = 20;
19322
+ var capped = (names) => {
19323
+ const unique = [...new Set(names)];
19324
+ return { count: unique.length, names: unique.slice(0, MAX_NAMES) };
19325
+ };
19326
+ function scopeGateLogInputs(components, tokenCount) {
19327
+ const ai = { accepted: 0, rejected: 0, failed: 0, none: 0 };
19328
+ for (const component of components) ai[component.aiDecision ?? "none"] += 1;
19329
+ return {
19330
+ components_found: components.length,
19331
+ ai_suggestions: ai,
19332
+ needs_review: components.filter((component) => component.needsReview === true).length,
19333
+ tokens: tokenCount
19334
+ };
19335
+ }
19336
+ function scopeGateLogOutputs(components, decisions) {
19337
+ const suggested = new Map(components.map((component) => [component.name, component.aiDecision]));
19338
+ return {
19339
+ outcome: "continued",
19340
+ accepted: new Set(decisions.accepted).size,
19341
+ rejected: new Set(decisions.rejected).size,
19342
+ accepted_although_ai_rejected: capped(decisions.accepted.filter((name) => suggested.get(name) === "rejected")),
19343
+ not_accepted_although_ai_accepted: capped(decisions.rejected.filter((name) => suggested.get(name) === "accepted"))
19344
+ };
19345
+ }
19346
+
19132
19347
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/panels/tokens-column.tsx
19133
19348
  import { Box as Box17, Text as Text17 } from "ink";
19134
19349
  import figures2 from "figures";
@@ -19356,10 +19571,10 @@ function GotoBanner({
19356
19571
  }) {
19357
19572
  const highlightIndex = cursorRowIndex ?? cursor;
19358
19573
  const start = windowStart(rows.length, highlightIndex, maxRows);
19359
- const end = Math.min(rows.length, start + maxRows);
19360
- const visible = rows.slice(start, end);
19574
+ const end2 = Math.min(rows.length, start + maxRows);
19575
+ const visible = rows.slice(start, end2);
19361
19576
  const moreAbove = start;
19362
- const moreBelow = rows.length - end;
19577
+ const moreBelow = rows.length - end2;
19363
19578
  return /* @__PURE__ */ jsxs21(
19364
19579
  Box21,
19365
19580
  {
@@ -20174,8 +20389,8 @@ function GroupedSidebar(props) {
20174
20389
  });
20175
20390
  const windowed = scrollOffset !== void 0 && visibleCount !== void 0;
20176
20391
  const start = windowed ? Math.max(0, scrollOffset ?? 0) : 0;
20177
- const end = windowed ? start + (visibleCount ?? allRows.length) + 1 : allRows.length;
20178
- const rows = windowed ? allRows.slice(start, end) : allRows;
20392
+ const end2 = windowed ? start + (visibleCount ?? allRows.length) + 1 : allRows.length;
20393
+ const rows = windowed ? allRows.slice(start, end2) : allRows;
20179
20394
  return /* @__PURE__ */ jsxs22(WindowedPanel, { width, height: props.height, title, focused, children: [
20180
20395
  allRows.length === 0 && emptyMessage !== void 0 && /* @__PURE__ */ jsxs22(Text23, { color: PALETTE.warning, children: [
20181
20396
  " ",
@@ -20229,7 +20444,7 @@ function GroupedSidebar(props) {
20229
20444
  inheritanceStyle.glyph && /* @__PURE__ */ jsx26(Text23, { color: inheritanceStyle.dim ? PALETTE.muted : inheritanceStyle.color, bold: inheritanceStyle.bold, children: " " + inheritanceStyle.glyph })
20230
20445
  ] }, row.key);
20231
20446
  }),
20232
- windowed && /* @__PURE__ */ jsx26(WindowFooter, { above: start, below: Math.max(0, allRows.length - end) })
20447
+ windowed && /* @__PURE__ */ jsx26(WindowFooter, { above: start, below: Math.max(0, allRows.length - end2) })
20233
20448
  ] });
20234
20449
  }
20235
20450
 
@@ -20312,7 +20527,7 @@ function useImmediateInput(handler, enabled = true) {
20312
20527
 
20313
20528
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
20314
20529
  import { useStdout as useStdout2 } from "ink";
20315
- import { useEffect as useEffect10, useState as useState13 } from "react";
20530
+ import { useEffect as useEffect12, useState as useState13 } from "react";
20316
20531
  function readTerminalSize(stdout) {
20317
20532
  return {
20318
20533
  columns: stdout?.columns ?? 80,
@@ -20322,7 +20537,7 @@ function readTerminalSize(stdout) {
20322
20537
  function useTerminalSize() {
20323
20538
  const { stdout } = useStdout2();
20324
20539
  const [size, setSize] = useState13(() => readTerminalSize(stdout));
20325
- useEffect10(() => {
20540
+ useEffect12(() => {
20326
20541
  const updateSize = () => setSize(readTerminalSize(stdout));
20327
20542
  stdout?.on("resize", updateSize);
20328
20543
  updateSize();
@@ -20505,7 +20720,7 @@ function createSidebarViewsHelpSection(includeBreaking) {
20505
20720
  }
20506
20721
 
20507
20722
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
20508
- import { useEffect as useEffect11, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
20723
+ import { useEffect as useEffect13, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
20509
20724
 
20510
20725
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/columns.ts
20511
20726
  var TWO_COLUMN_MIN_WIDTH = 100;
@@ -21242,7 +21457,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
21242
21457
  return seed;
21243
21458
  });
21244
21459
  const seededGroupsRef = useRef9(closures.size > 0 || cycleParticipants.size > 0);
21245
- useEffect11(() => {
21460
+ useEffect13(() => {
21246
21461
  if (seededGroupsRef.current) return;
21247
21462
  if (closures.size === 0 && cycleParticipants.size === 0) return;
21248
21463
  seededGroupsRef.current = true;
@@ -21333,7 +21548,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
21333
21548
  entryCount: 0
21334
21549
  });
21335
21550
  const panelLayout = useMemo3(() => computePanelLayout(visibleCount), [visibleCount]);
21336
- useEffect11(() => {
21551
+ useEffect13(() => {
21337
21552
  setNav((prev) => {
21338
21553
  const maxIdx = Math.max(0, visibleRows.length - 1);
21339
21554
  const nextCursor = Math.min(prev.cursor, maxIdx);
@@ -21694,23 +21909,55 @@ var HELP_SECTIONS = [
21694
21909
  }
21695
21910
  ];
21696
21911
  function ScopeGateScreen(props) {
21697
- if (props.components.length === 0) {
21698
- return /* @__PURE__ */ jsx29(Box25, { paddingX: 2, paddingY: 1, children: /* @__PURE__ */ jsx29(Text26, { color: PALETTE.error, children: "Error: no components found for this session \u2014 please re-run analyze extract." }) });
21699
- }
21912
+ if (props.components.length === 0) return /* @__PURE__ */ jsx29(NoComponents, {});
21700
21913
  return /* @__PURE__ */ jsx29(ScopeGateView, { ...props });
21701
21914
  }
21915
+ function NoComponents() {
21916
+ useEffect14(() => {
21917
+ startDebugRun({
21918
+ flow: "import/scope-gate",
21919
+ step: "07-scope-gate",
21920
+ menuOption: "Scope gate",
21921
+ inputs: scopeGateLogInputs([], 0)
21922
+ });
21923
+ void finishDebugRun({
21924
+ outputs: { outcome: "nothing to decide", error: "No components were found for this session." },
21925
+ status: "error",
21926
+ exitMethod: "discarded"
21927
+ });
21928
+ }, []);
21929
+ return /* @__PURE__ */ jsx29(Box25, { paddingX: 2, paddingY: 1, children: /* @__PURE__ */ jsx29(Text26, { color: PALETTE.error, children: "Error: no components found for this session \u2014 please re-run analyze extract." }) });
21930
+ }
21702
21931
  function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
21703
21932
  const tokens = useMemo4(() => {
21704
21933
  const loaded = tokensPath ? loadTokenRows(tokensPath) : void 0;
21705
21934
  return loaded?.ok ? loaded.rows : [];
21706
21935
  }, [tokensPath]);
21707
21936
  const longest = useMemo4(() => longestEntries(tokens), [tokens]);
21937
+ useEffect14(() => {
21938
+ startDebugRun({
21939
+ flow: "import/scope-gate",
21940
+ step: "07-scope-gate",
21941
+ menuOption: "Scope gate",
21942
+ inputs: scopeGateLogInputs(components, tokens.length)
21943
+ });
21944
+ }, []);
21708
21945
  const gate = useScopeGate({
21709
21946
  components,
21710
21947
  tokenCount: tokens.length,
21711
21948
  tokensWidth: longest.path + longest.value + 10,
21712
- onConfirm,
21713
- onQuit
21949
+ onConfirm: (decisions) => {
21950
+ void finishDebugRun({
21951
+ outputs: scopeGateLogOutputs(components, decisions),
21952
+ status: "success",
21953
+ exitMethod: "saved"
21954
+ });
21955
+ onConfirm(decisions);
21956
+ },
21957
+ onQuit: () => {
21958
+ void finishDebugRun({ outputs: { outcome: "quit" }, status: "success", exitMethod: "discarded" });
21959
+ onQuit();
21960
+ }
21714
21961
  });
21715
21962
  const { search, graph, columnPlan, panelLayout, counters } = gate;
21716
21963
  if (gate.showHelp) {
@@ -21808,7 +22055,8 @@ function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
21808
22055
  }
21809
22056
 
21810
22057
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
21811
- import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
22058
+ init_debug_store();
22059
+ import { useEffect as useEffect15, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
21812
22060
 
21813
22061
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/cache-check.ts
21814
22062
  async function checkGenerationCache(input) {
@@ -21857,7 +22105,21 @@ function useScopeGateFlow(input, deps = realDeps3) {
21857
22105
  const loaded = useMemo5(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
21858
22106
  const cacheCheck = useRef10(void 0);
21859
22107
  const [confirmed, setConfirmed] = useState17();
21860
- useEffect12(() => {
22108
+ useEffect15(() => {
22109
+ if (!sessionId || !loaded || loaded.ok) return;
22110
+ startDebugRun({
22111
+ flow: "import/scope-gate",
22112
+ step: "07-scope-gate",
22113
+ menuOption: "Scope gate",
22114
+ inputs: { session_id: sessionId }
22115
+ });
22116
+ void finishDebugRun({
22117
+ outputs: { outcome: "could not load the components", error: loaded.message },
22118
+ status: "error",
22119
+ exitMethod: "discarded"
22120
+ });
22121
+ }, [sessionId, loaded]);
22122
+ useEffect15(() => {
21861
22123
  if (!input || !loaded?.ok || cacheCheck.current) return;
21862
22124
  cacheCheck.current = deps.checkCache(input.cache);
21863
22125
  }, [input, loaded]);
@@ -21869,6 +22131,41 @@ function useScopeGateFlow(input, deps = realDeps3) {
21869
22131
  }
21870
22132
 
21871
22133
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/logic.ts
22134
+ function generationLogInputs(input) {
22135
+ return {
22136
+ session_id: input.sessionId,
22137
+ accepted: input.decisions.accepted.length,
22138
+ rejected: input.decisions.rejected.length,
22139
+ tokens_path: input.tokensPath,
22140
+ token_session_id: input.tokenSessionId,
22141
+ existing_entities_path: input.existingEntitiesPath,
22142
+ agent: input.agent,
22143
+ agent_model: input.agentModel ?? "",
22144
+ prompt_overrides: input.promptOverrides,
22145
+ generate_prompt_path: input.generatePromptPath ?? "",
22146
+ cache: !input.noCache,
22147
+ has_tokens: input.hasTokens
22148
+ };
22149
+ }
22150
+ function generationLogOutputs(result, progress) {
22151
+ const last = progress ? { final_progress: progress } : {};
22152
+ if (!result.ok) {
22153
+ return { outputs: { result: "failed", failed_step: result.step, error: result.message, ...last }, status: "error" };
22154
+ }
22155
+ const { generation } = result;
22156
+ return {
22157
+ outputs: generation.route === "review" ? {
22158
+ result: "done",
22159
+ route: generation.route,
22160
+ session_id: generation.sessionId,
22161
+ accepted: generation.acceptedCount,
22162
+ generated: generation.generatedCount,
22163
+ map_tokens_eligible: generation.mapTokensEligible,
22164
+ ...last
22165
+ } : { result: "done", route: generation.route, accepted: generation.acceptedCount, ...last },
22166
+ status: "success"
22167
+ };
22168
+ }
21872
22169
  function initialProgress2() {
21873
22170
  return { components: null, mapTokens: "idle", mapTokensEligible: null };
21874
22171
  }
@@ -21924,7 +22221,8 @@ function GenerationScreen({
21924
22221
  }
21925
22222
 
21926
22223
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
21927
- import { useEffect as useEffect13, useRef as useRef11, useState as useState18 } from "react";
22224
+ init_debug_store();
22225
+ import { useEffect as useEffect16, useRef as useRef11, useState as useState18 } from "react";
21928
22226
 
21929
22227
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
21930
22228
  import { resolve as resolve25 } from "node:path";
@@ -22090,17 +22388,30 @@ function applyProgressEvent2(event, previous, total) {
22090
22388
  function useGeneration(input) {
22091
22389
  const [state2, setState] = useState18();
22092
22390
  const current = useRef11();
22093
- useEffect13(() => {
22391
+ useEffect16(() => {
22094
22392
  current.current = input;
22095
22393
  if (!input) {
22096
22394
  setState(void 0);
22097
22395
  return;
22098
22396
  }
22099
22397
  setState({ status: "running", progress: initialProgress2() });
22398
+ let lastProgress;
22399
+ startDebugRun({
22400
+ flow: "import/generation",
22401
+ step: "08-generation",
22402
+ menuOption: "Generation",
22403
+ inputs: generationLogInputs(input)
22404
+ });
22100
22405
  void runGeneration(input, (progress) => {
22406
+ lastProgress = progress;
22101
22407
  if (current.current === input) setState({ status: "running", progress });
22102
22408
  }).then((result) => {
22103
- if (current.current === input) setState({ status: "done", result });
22409
+ if (current.current !== input) return;
22410
+ void finishDebugRun({
22411
+ ...generationLogOutputs(result, lastProgress),
22412
+ exitMethod: result.ok ? "saved" : "discarded"
22413
+ });
22414
+ setState({ status: "done", result });
22104
22415
  });
22105
22416
  return () => {
22106
22417
  if (current.current === input) current.current = void 0;
@@ -22571,7 +22882,7 @@ function PreviewValidationErrorScreen({
22571
22882
  }
22572
22883
 
22573
22884
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
22574
- import { useCallback as useCallback5, useEffect as useEffect20, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
22885
+ import { useCallback as useCallback5, useEffect as useEffect23, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
22575
22886
  import figures8 from "figures";
22576
22887
 
22577
22888
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/review-json-panel.ts
@@ -22832,7 +23143,7 @@ function enumerateCycleBreaks(cycle, components) {
22832
23143
  import { Box as Box32, Text as Text34 } from "ink";
22833
23144
 
22834
23145
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
22835
- import React13, { useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
23146
+ import React13, { useEffect as useEffect17, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
22836
23147
  import figures6 from "figures";
22837
23148
  import { Box as Box26, measureElement, Text as Text27 } from "ink";
22838
23149
 
@@ -24381,16 +24692,16 @@ function FieldEditor({
24381
24692
  const visibleEnd = (start) => {
24382
24693
  if (focusLevel === "field") return Math.min(rows.length, start + 1);
24383
24694
  let used = 0;
24384
- let end2 = start;
24385
- while (end2 < rows.length) {
24386
- const nextHeight = rowHeight(rows[end2], end2);
24387
- if (end2 > start && used + nextHeight > contentHeight) break;
24695
+ let end3 = start;
24696
+ while (end3 < rows.length) {
24697
+ const nextHeight = rowHeight(rows[end3], end3);
24698
+ if (end3 > start && used + nextHeight > contentHeight) break;
24388
24699
  used += nextHeight;
24389
- end2 += 1;
24700
+ end3 += 1;
24390
24701
  }
24391
- return Math.max(start + 1, end2);
24702
+ return Math.max(start + 1, end3);
24392
24703
  };
24393
- useEffect14(() => {
24704
+ useEffect17(() => {
24394
24705
  if (focusLevel === "field" || selectedRowIdx < 0) return;
24395
24706
  setListScrollStart((previous) => {
24396
24707
  if (initialFocusTarget && !initialFocusScrollApplied.current) {
@@ -24398,9 +24709,9 @@ function FieldEditor({
24398
24709
  return Math.min(selectedRowIdx, Math.max(0, rows.length - 1));
24399
24710
  }
24400
24711
  const clamped = Math.min(previous, Math.max(0, rows.length - 1));
24401
- const end2 = visibleEnd(clamped);
24712
+ const end3 = visibleEnd(clamped);
24402
24713
  if (selectedRowIdx < clamped) return selectedRowIdx;
24403
- if (selectedRowIdx >= end2) {
24714
+ if (selectedRowIdx >= end3) {
24404
24715
  let start = selectedRowIdx;
24405
24716
  let used = rowHeight(rows[selectedRowIdx], selectedRowIdx);
24406
24717
  while (start > 0) {
@@ -24415,10 +24726,10 @@ function FieldEditor({
24415
24726
  });
24416
24727
  }, [contentHeight, focusLevel, rowHeights, rows, selectedRowIdx]);
24417
24728
  const scrollStart = Math.min(listScrollStart, Math.max(0, rows.length - 1));
24418
- const end = visibleEnd(scrollStart);
24419
- const nextHeader = rows.slice(end).find((row) => row.kind === "header");
24729
+ const end2 = visibleEnd(scrollStart);
24730
+ const nextHeader = rows.slice(end2).find((row) => row.kind === "header");
24420
24731
  const categoryBelow = focusLevel !== "field" && nextHeader?.kind === "header" ? nextHeader.label.replace(/^──\s*/, "").trim() : null;
24421
- const visibleRowSlice = rows.slice(scrollStart, end);
24732
+ const visibleRowSlice = rows.slice(scrollStart, end2);
24422
24733
  useLayoutEffect2(() => {
24423
24734
  const nextHeights = {};
24424
24735
  for (const [key, node] of rowMeasureRefs.current) {
@@ -24580,20 +24891,20 @@ function FieldEditor({
24580
24891
  sourceOpen && !onToggleSourceExternal && (() => {
24581
24892
  const propMeta = !inSlots && !inComponentDesc && currentProp ? metadata?.props?.[currentProp.name] : void 0;
24582
24893
  const start = propMeta?.sourceStartLine ?? null;
24583
- const end2 = propMeta?.sourceEndLine ?? null;
24894
+ const end3 = propMeta?.sourceEndLine ?? null;
24584
24895
  const path5 = metadata?.sourcePath ?? null;
24585
24896
  const src = metadata?.componentSource ?? null;
24586
24897
  const headerPath = path5 ?? "<unknown source path>";
24587
- if (!start || !end2 || !src) {
24898
+ if (!start || !end3 || !src) {
24588
24899
  return /* @__PURE__ */ jsxs26(Box26, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [
24589
24900
  /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, bold: true, children: `source: ${headerPath}` }),
24590
24901
  /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, children: "(no source location captured for this prop)" }),
24591
24902
  /* @__PURE__ */ jsx32(Text27, { children: "[s] close" })
24592
24903
  ] });
24593
24904
  }
24594
- const lines = src.split("\n").slice(Math.max(0, start - 1), end2);
24905
+ const lines = src.split("\n").slice(Math.max(0, start - 1), end3);
24595
24906
  return /* @__PURE__ */ jsxs26(Box26, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [
24596
- /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, bold: true, children: `${headerPath}: lines ${start}\u2013${end2}` }),
24907
+ /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, bold: true, children: `${headerPath}: lines ${start}\u2013${end3}` }),
24597
24908
  lines.map((ln, i) => /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, children: ln }, `source-line-${i}`)),
24598
24909
  /* @__PURE__ */ jsx32(Text27, { children: "[s] close \xB7 [Esc] close" })
24599
24910
  ] });
@@ -25462,7 +25773,7 @@ function finalizeReviewSession(extractSessionId, components) {
25462
25773
  }
25463
25774
 
25464
25775
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
25465
- import { useCallback as useCallback2, useEffect as useEffect16, useRef as useRef13, useState as useState21 } from "react";
25776
+ import { useCallback as useCallback2, useEffect as useEffect19, useRef as useRef13, useState as useState21 } from "react";
25466
25777
 
25467
25778
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/history.ts
25468
25779
  var DEFAULT_MAX_DEPTH = 50;
@@ -25518,7 +25829,7 @@ function createHistoryStack(seed, maxDepth = DEFAULT_MAX_DEPTH) {
25518
25829
  }
25519
25830
 
25520
25831
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
25521
- import { useEffect as useEffect15, useRef as useRef12, useState as useState20 } from "react";
25832
+ import { useEffect as useEffect18, useRef as useRef12, useState as useState20 } from "react";
25522
25833
 
25523
25834
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/run-live-preview.ts
25524
25835
  var TimeoutError = class extends Error {
@@ -25678,7 +25989,7 @@ function useFinalizePreview(opts) {
25678
25989
  const [scrollOffset, setScrollOffset] = useState20(0);
25679
25990
  const generationRef = useRef12(0);
25680
25991
  const acceptedKey = [...acceptedKeys].sort().join("\0");
25681
- useEffect15(() => {
25992
+ useEffect18(() => {
25682
25993
  if (!open) {
25683
25994
  setStatus("idle");
25684
25995
  setRemoved([]);
@@ -25741,7 +26052,7 @@ function useReviewSession({
25741
26052
  }));
25742
26053
  return { result, catalog };
25743
26054
  }, [loadSession, tokensPath]);
25744
- useEffect16(() => {
26055
+ useEffect19(() => {
25745
26056
  let disposed = false;
25746
26057
  void (async () => {
25747
26058
  try {
@@ -25794,7 +26105,7 @@ function useReviewSession({
25794
26105
  function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
25795
26106
  const [reviewMetadata, setReviewMetadata] = useState21(null);
25796
26107
  const [componentRationale, setComponentRationale] = useState21(null);
25797
- useEffect16(() => {
26108
+ useEffect19(() => {
25798
26109
  const current = components[selectedIdx];
25799
26110
  if (!current) {
25800
26111
  setReviewMetadata(null);
@@ -25826,7 +26137,7 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
25826
26137
  function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
25827
26138
  const historyRef = useRef13(null);
25828
26139
  const historySeededRef = useRef13(false);
25829
- useEffect16(() => {
26140
+ useEffect19(() => {
25830
26141
  if (loading || historySeededRef.current) return;
25831
26142
  historySeededRef.current = true;
25832
26143
  historyRef.current = createHistoryStack(createSnapshot(components));
@@ -25877,7 +26188,7 @@ function useReviewFinalize({
25877
26188
  }
25878
26189
 
25879
26190
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
25880
- import { useEffect as useEffect17, useRef as useRef14, useState as useState22 } from "react";
26191
+ import { useEffect as useEffect20, useRef as useRef14, useState as useState22 } from "react";
25881
26192
 
25882
26193
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/token-suggestions.ts
25883
26194
  function collectTokenSuggestions(entry, availableTokens = []) {
@@ -25930,7 +26241,7 @@ function useReviewEditor({
25930
26241
  const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState22(/* @__PURE__ */ new Set());
25931
26242
  const tokenReviewSuggestedRef = useRef14(/* @__PURE__ */ new Map());
25932
26243
  const pendingGRef = useRef14(false);
25933
- useEffect17(() => {
26244
+ useEffect20(() => {
25934
26245
  setTokenReviewRow(0);
25935
26246
  setTokenReviewEditing(false);
25936
26247
  setTokenReviewEditCursor(0);
@@ -26342,7 +26653,7 @@ function handleJsonPanelInput(input, key, state2) {
26342
26653
  }
26343
26654
 
26344
26655
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
26345
- import { useCallback as useCallback4, useEffect as useEffect19, useState as useState25 } from "react";
26656
+ import { useCallback as useCallback4, useEffect as useEffect22, useState as useState25 } from "react";
26346
26657
 
26347
26658
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/preview-annotations.ts
26348
26659
  function applyPreviewAnnotations(preview, localNames) {
@@ -26377,7 +26688,7 @@ function applyPreviewAnnotations(preview, localNames) {
26377
26688
  }
26378
26689
 
26379
26690
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
26380
- import { useCallback as useCallback3, useEffect as useEffect18, useRef as useRef15, useState as useState24 } from "react";
26691
+ import { useCallback as useCallback3, useEffect as useEffect21, useRef as useRef15, useState as useState24 } from "react";
26381
26692
  var DEFAULT_DEBOUNCE_MS = 500;
26382
26693
  function useLivePreview(opts) {
26383
26694
  const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
@@ -26388,14 +26699,14 @@ function useLivePreview(opts) {
26388
26699
  const latestRef = useRef15(0);
26389
26700
  const inflightRef = useRef15(0);
26390
26701
  const optsRef = useRef15(opts);
26391
- useEffect18(() => {
26702
+ useEffect21(() => {
26392
26703
  optsRef.current = opts;
26393
26704
  });
26394
26705
  const disabledRef = useRef15(disabled);
26395
- useEffect18(() => {
26706
+ useEffect21(() => {
26396
26707
  disabledRef.current = disabled;
26397
26708
  }, [disabled]);
26398
- useEffect18(() => {
26709
+ useEffect21(() => {
26399
26710
  return () => {
26400
26711
  if (timerRef.current) {
26401
26712
  clearTimeout(timerRef.current);
@@ -26509,13 +26820,13 @@ function useReviewPreview({
26509
26820
  deleteAllComponents
26510
26821
  });
26511
26822
  const [spinnerTick, setSpinnerTick] = useState25(0);
26512
- useEffect19(() => {
26823
+ useEffect22(() => {
26513
26824
  if (livePreviewHook.status !== "running") return;
26514
26825
  const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
26515
26826
  return () => clearInterval(id);
26516
26827
  }, [livePreviewHook.status]);
26517
26828
  const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
26518
- useEffect19(() => {
26829
+ useEffect22(() => {
26519
26830
  if (loading) return;
26520
26831
  if (!livePreview) return;
26521
26832
  if (components.length === 0) return;
@@ -26935,7 +27246,7 @@ function GenerateReviewStepView({
26935
27246
  [components]
26936
27247
  );
26937
27248
  const closures = useMemo6(() => computeAllClosures(componentGraph), [componentGraph]);
26938
- useEffect20(() => {
27249
+ useEffect23(() => {
26939
27250
  if (seededGroupsRef.current) return;
26940
27251
  if (closures.size === 0 && slotCycles.length === 0) return;
26941
27252
  seededGroupsRef.current = true;
@@ -26962,7 +27273,7 @@ function GenerateReviewStepView({
26962
27273
  suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
26963
27274
  }));
26964
27275
  }, [slotCycles, cycleView]);
26965
- useEffect20(() => {
27276
+ useEffect23(() => {
26966
27277
  const decision = computeAutoRejectDecision({
26967
27278
  loading,
26968
27279
  autoRejectFired: autoRejectFiredRef.current,
@@ -27006,7 +27317,7 @@ function GenerateReviewStepView({
27006
27317
  applySnapshot: applyHistorySnapshot
27007
27318
  });
27008
27319
  const autoRejectPushedRef = useRef16(false);
27009
- useEffect20(() => {
27320
+ useEffect23(() => {
27010
27321
  if (loading) return;
27011
27322
  if (!historySeededRef.current) return;
27012
27323
  if (!autoRejectFiredRef.current) return;
@@ -27090,7 +27401,7 @@ function GenerateReviewStepView({
27090
27401
  const panelHeight = leftPanelHeight + 2;
27091
27402
  const panelContentHeight = Math.max(1, panelHeight - 3);
27092
27403
  const cycleViewportHeight = Math.max(1, panelHeight - 4);
27093
- useEffect20(() => {
27404
+ useEffect23(() => {
27094
27405
  if (selectableRowPositions.length === 0) return;
27095
27406
  const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
27096
27407
  const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
@@ -28035,10 +28346,10 @@ function normalizePath(input) {
28035
28346
  }
28036
28347
 
28037
28348
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
28038
- import { useEffect as useEffect21, useState as useState27 } from "react";
28349
+ import { useEffect as useEffect24, useState as useState27 } from "react";
28039
28350
  function useBlinkingCursor() {
28040
28351
  const [visible, setVisible] = useState27(true);
28041
- useEffect21(() => {
28352
+ useEffect24(() => {
28042
28353
  const interval = setInterval(() => setVisible((current) => !current), 500);
28043
28354
  return () => clearInterval(interval);
28044
28355
  }, []);
@@ -28154,12 +28465,12 @@ function countedThings({ components, tokens }, counts = {}) {
28154
28465
  }
28155
28466
 
28156
28467
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
28157
- import { useEffect as useEffect22, useState as useState29 } from "react";
28468
+ import { useEffect as useEffect25, useState as useState29 } from "react";
28158
28469
  import { Spinner as Spinner2 } from "@inkjs/ui";
28159
28470
  import { jsx as jsx53 } from "react/jsx-runtime";
28160
28471
  function useTimedSpinner() {
28161
28472
  const [elapsedSeconds, setElapsedSeconds] = useState29(0);
28162
- useEffect22(() => {
28473
+ useEffect25(() => {
28163
28474
  const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
28164
28475
  return () => {
28165
28476
  clearInterval(timer);
@@ -28217,7 +28528,7 @@ function PushingStep({ progress, produced, counts }) {
28217
28528
  }
28218
28529
 
28219
28530
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
28220
- import { useEffect as useEffect23, useState as useState30, useMemo as useMemo7 } from "react";
28531
+ import { useEffect as useEffect26, useState as useState30, useMemo as useMemo7 } from "react";
28221
28532
  import { Box as Box44, Text as Text46 } from "ink";
28222
28533
 
28223
28534
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/preview-diff.ts
@@ -28612,7 +28923,7 @@ function WizardPreviewStep({
28612
28923
  const activeLines = diffExpanded ? diffLines : summaryLines;
28613
28924
  const maxScroll = Math.max(0, activeLines.length - viewportHeight);
28614
28925
  const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
28615
- useEffect23(() => {
28926
+ useEffect26(() => {
28616
28927
  setScrollOffset((previous) => Math.min(previous, maxScroll));
28617
28928
  }, [maxScroll]);
28618
28929
  useImmediateInput((input, key) => {
@@ -28702,6 +29013,143 @@ function buildRunTeaserLine(runId) {
28702
29013
  return `Run saved as ${runId}.`;
28703
29014
  }
28704
29015
 
29016
+ // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
29017
+ init_debug_store();
29018
+ import { useEffect as useEffect27, useRef as useRef17 } from "react";
29019
+
29020
+ // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts
29021
+ var STEPS2 = {
29022
+ "final-review": { number: "09", label: "Final review" },
29023
+ previewing: { number: "10", label: "Previewing" },
29024
+ "preview-gate": { number: "10", label: "Preview gate" },
29025
+ pushing: { number: "10", label: "Pushing" },
29026
+ "path-prompt": { number: "10", label: "Save path" },
29027
+ printing: { number: "10", label: "Writing files" },
29028
+ "print-gate": { number: "10", label: "Files saved" },
29029
+ done: { number: "10", label: "Done" },
29030
+ error: { number: "10", label: "Error" },
29031
+ "preview-validation-error": { number: "10", label: "Preview validation error" }
29032
+ };
29033
+ var FORWARD = [
29034
+ "final-review",
29035
+ "previewing",
29036
+ "preview-gate",
29037
+ "pushing",
29038
+ "path-prompt",
29039
+ "printing",
29040
+ "print-gate",
29041
+ "done"
29042
+ ];
29043
+ var MAX_LOGGED = 10;
29044
+ var scrub = (text, state2) => scrubError(text, [state2.cmaToken]);
29045
+ function flowStepRun(step) {
29046
+ const { number, label } = STEPS2[step];
29047
+ return { flow: `import/${step}`, step: `${number}-${step}`, menuOption: label };
29048
+ }
29049
+ function pushSummary(result, state2) {
29050
+ const failures = result.failures ?? [];
29051
+ return {
29052
+ component_types: result.componentTypes,
29053
+ design_tokens: result.designTokens,
29054
+ ...result.summary ? { summary: result.summary } : {},
29055
+ ...failures.length > 0 ? {
29056
+ failure_count: failures.length,
29057
+ failures: failures.slice(0, MAX_LOGGED).map((failure) => ({
29058
+ entity_type: failure.entityType,
29059
+ entity_id: failure.entityId,
29060
+ message: scrub(failure.message, state2)
29061
+ }))
29062
+ } : {}
29063
+ };
29064
+ }
29065
+ function flowStepInputs(state2) {
29066
+ const inputs = {
29067
+ agent: state2.agent,
29068
+ space_id: state2.spaceId,
29069
+ environment_id: state2.environmentId,
29070
+ host: state2.host,
29071
+ credentials_skipped: state2.credentialsSkipped,
29072
+ components_generated: state2.generatedCount,
29073
+ components_accepted: state2.generatedAcceptedCount,
29074
+ tokens: state2.tokenCount,
29075
+ cma_token: state2.cmaToken
29076
+ };
29077
+ switch (state2.step) {
29078
+ case "final-review":
29079
+ if (state2.finalizeErrorBanner) inputs["finalize_error"] = scrub(state2.finalizeErrorBanner, state2);
29080
+ break;
29081
+ case "path-prompt":
29082
+ inputs["default_path"] = state2.outDir;
29083
+ break;
29084
+ case "error":
29085
+ inputs["error_step"] = state2.errorStep;
29086
+ inputs["error"] = scrub(state2.errorMessage, state2);
29087
+ inputs["can_retry_credentials"] = state2.errorAllowCredentialRetry;
29088
+ inputs["can_acknowledge_breaking_changes"] = state2.errorAllowBreakingChangeAcknowledgment;
29089
+ break;
29090
+ case "preview-validation-error":
29091
+ inputs["validation_error_count"] = state2.previewValidationErrors.length;
29092
+ inputs["validation_errors"] = state2.previewValidationErrors.slice(0, MAX_LOGGED).map((error) => ({
29093
+ component: error.componentName,
29094
+ path: error.path,
29095
+ message: scrub(error.message, state2)
29096
+ }));
29097
+ inputs["missing_names"] = state2.previewValidationMissingNames.slice(0, MAX_LOGGED * 2);
29098
+ break;
29099
+ case "done":
29100
+ Object.assign(inputs, { push_result: pushSummary(state2.pushResult, state2) });
29101
+ break;
29102
+ default:
29103
+ break;
29104
+ }
29105
+ return inputs;
29106
+ }
29107
+ function flowStepOutputs(from, to) {
29108
+ const outputs = { next_step: to?.step ?? "exited" };
29109
+ let failed = from.step === "error" || from.step === "preview-validation-error";
29110
+ if (to?.step === "error") {
29111
+ failed = true;
29112
+ outputs["error_step"] = to.errorStep;
29113
+ outputs["error"] = scrub(to.errorMessage, to);
29114
+ }
29115
+ if (from.step === "final-review" && to?.finalizeErrorBanner) {
29116
+ outputs["finalize_error"] = scrub(to.finalizeErrorBanner, to);
29117
+ }
29118
+ if (from.step === "pushing" && to) {
29119
+ outputs["push_result"] = pushSummary(to.pushResult, to);
29120
+ if (to.pushResult.componentTypes.failed + to.pushResult.designTokens.failed > 0) failed = true;
29121
+ }
29122
+ if (from.step === "path-prompt" && to?.componentsPath) outputs["saved_to"] = to.componentsPath;
29123
+ if (from.step === "printing" && to) {
29124
+ outputs["saved_to"] = to.componentsPath;
29125
+ outputs["run_id"] = to.lastRunId;
29126
+ }
29127
+ const forward = to ? FORWARD.indexOf(to.step) > FORWARD.indexOf(from.step) && FORWARD.includes(from.step) : false;
29128
+ const finished = to === void 0 && (from.step === "done" || from.step === "print-gate");
29129
+ return { outputs, status: failed ? "error" : "success", exitMethod: forward || finished ? "saved" : "discarded" };
29130
+ }
29131
+
29132
+ // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
29133
+ function end(from, to) {
29134
+ void finishDebugRun(flowStepOutputs(from, to));
29135
+ }
29136
+ function useFlowLog(state2) {
29137
+ const open = useRef17(void 0);
29138
+ useEffect27(() => {
29139
+ if (open.current?.step === state2.step) return;
29140
+ if (open.current) end(open.current, state2);
29141
+ startDebugRun({ ...flowStepRun(state2.step), inputs: flowStepInputs(state2) });
29142
+ open.current = state2;
29143
+ }, [state2]);
29144
+ useEffect27(
29145
+ () => () => {
29146
+ if (open.current) end(open.current, void 0);
29147
+ open.current = void 0;
29148
+ },
29149
+ []
29150
+ );
29151
+ }
29152
+
28705
29153
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
28706
29154
  import { jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
28707
29155
  function canEditFromPreview(cdf) {
@@ -28715,6 +29163,7 @@ function FlowScreen({
28715
29163
  generatePromptPath,
28716
29164
  onExit
28717
29165
  }) {
29166
+ useFlowLog(state2);
28718
29167
  const produced = producedOf(state2);
28719
29168
  const counts = { components: state2.generatedAcceptedCount, tokens: state2.tokenCount };
28720
29169
  const things = countedThings(produced, counts);
@@ -28830,7 +29279,7 @@ function FlowScreen({
28830
29279
  }
28831
29280
 
28832
29281
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
28833
- import { useEffect as useEffect24, useRef as useRef17, useSyncExternalStore } from "react";
29282
+ import { useEffect as useEffect28, useRef as useRef18, useSyncExternalStore } from "react";
28834
29283
 
28835
29284
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
28836
29285
  import { appendFileSync, writeFileSync } from "node:fs";
@@ -29572,7 +30021,7 @@ function createFlowController(start, deps) {
29572
30021
 
29573
30022
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
29574
30023
  function useFlow(start, options = {}) {
29575
- const controller = useRef17();
30024
+ const controller = useRef18();
29576
30025
  if (start && !controller.current) {
29577
30026
  try {
29578
30027
  startWizardLog();
@@ -29589,14 +30038,14 @@ function useFlow(start, options = {}) {
29589
30038
  (listener) => current?.subscribe(listener) ?? (() => void 0),
29590
30039
  () => current?.getState()
29591
30040
  );
29592
- useEffect24(() => {
30041
+ useEffect28(() => {
29593
30042
  if (!start) controller.current = void 0;
29594
30043
  }, [start]);
29595
30044
  return current && state2 ? { controller: current, state: state2 } : void 0;
29596
30045
  }
29597
30046
 
29598
30047
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
29599
- import { useEffect as useEffect25, useState as useState31 } from "react";
30048
+ import { useEffect as useEffect29, useState as useState31 } from "react";
29600
30049
  import { Box as Box46, Text as Text47, useInput as useInput13 } from "ink";
29601
30050
  init_debug_store();
29602
30051
 
@@ -29670,7 +30119,7 @@ function Section({ title, rows }) {
29670
30119
  }
29671
30120
  function HelpScreen({ onDone }) {
29672
30121
  const [info, setInfo] = useState31();
29673
- useEffect25(() => {
30122
+ useEffect29(() => {
29674
30123
  startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
29675
30124
  void readHelpInfo().then(setInfo);
29676
30125
  }, []);
@@ -29767,43 +30216,10 @@ import { useState as useState36 } from "react";
29767
30216
  import { Box as Box51, Text as Text53, useInput as useInput17 } from "ink";
29768
30217
 
29769
30218
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
29770
- import { useEffect as useEffect27, useRef as useRef18, useState as useState34 } from "react";
30219
+ import { useEffect as useEffect31, useRef as useRef19, useState as useState34 } from "react";
29771
30220
  import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
29772
30221
  init_debug_store();
29773
30222
 
29774
- // packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
29775
- init_config();
29776
- import { existsSync as existsSync10 } from "node:fs";
29777
- function diffSnapshots(before, after) {
29778
- const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
29779
- const changed_fields = names.filter((name) => before[name] !== after[name]);
29780
- return { changed: changed_fields.length > 0, changed_fields };
29781
- }
29782
- var DEFAULT_TRAIL_LIMIT = 30;
29783
- function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
29784
- const actions = [];
29785
- return {
29786
- record(action) {
29787
- actions.push(action);
29788
- if (actions.length > limit) actions.shift();
29789
- },
29790
- entries: () => [...actions]
29791
- };
29792
- }
29793
- var MIN_SECRET_LENGTH = 6;
29794
- function scrubError(error, secrets) {
29795
- let message = error instanceof Error ? error.message : String(error);
29796
- for (const secret of secrets) {
29797
- if (secret.length < MIN_SECRET_LENGTH) continue;
29798
- for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
29799
- }
29800
- return message;
29801
- }
29802
- function describeSettingsFile() {
29803
- const path5 = configFilePath();
29804
- return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
29805
- }
29806
-
29807
30223
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
29808
30224
  import { execFile as execFile2 } from "node:child_process";
29809
30225
  import { access as access5, constants } from "node:fs/promises";
@@ -30096,7 +30512,7 @@ async function writeAgentConfig(config) {
30096
30512
  }
30097
30513
 
30098
30514
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
30099
- import { useEffect as useEffect26, useState as useState33 } from "react";
30515
+ import { useEffect as useEffect30, useState as useState33 } from "react";
30100
30516
  import { Box as Box48, Text as Text50 } from "ink";
30101
30517
 
30102
30518
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx
@@ -30159,7 +30575,7 @@ function AgentDetail({
30159
30575
  const [testing, setTesting] = useState33(false);
30160
30576
  const [notice, setNotice] = useState33(null);
30161
30577
  const [checks, setChecks] = useState33(void 0);
30162
- useEffect26(() => {
30578
+ useEffect30(() => {
30163
30579
  let active = true;
30164
30580
  setChecks(void 0);
30165
30581
  const timer = setTimeout(() => {
@@ -30244,7 +30660,7 @@ function AgentsScreen({ onDone }) {
30244
30660
  const [saving, setSaving] = useState34(false);
30245
30661
  const [loadError, setLoadError] = useState34(null);
30246
30662
  const [checks, setChecks] = useState34({});
30247
- const visit = useRef18({
30663
+ const visit = useRef19({
30248
30664
  trail: createTrail(),
30249
30665
  before: void 0,
30250
30666
  environment: void 0,
@@ -30257,7 +30673,7 @@ function AgentsScreen({ onDone }) {
30257
30673
  );
30258
30674
  }
30259
30675
  };
30260
- useEffect27(() => {
30676
+ useEffect31(() => {
30261
30677
  readAgentConfig().then((loaded) => {
30262
30678
  setConfig(loaded);
30263
30679
  inspectAll(loaded);
@@ -30434,7 +30850,7 @@ function AgentsScreen({ onDone }) {
30434
30850
  }
30435
30851
 
30436
30852
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
30437
- import { useEffect as useEffect28, useRef as useRef19, useState as useState35 } from "react";
30853
+ import { useEffect as useEffect32, useRef as useRef20, useState as useState35 } from "react";
30438
30854
  import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
30439
30855
  init_debug_store();
30440
30856
 
@@ -30492,14 +30908,14 @@ function ProjectScreen({ onDone }) {
30492
30908
  const [saving, setSaving] = useState35(false);
30493
30909
  const [notice, setNotice] = useState35(null);
30494
30910
  const [loadError, setLoadError] = useState35(null);
30495
- const visit = useRef19({
30911
+ const visit = useRef20({
30496
30912
  trail: createTrail(),
30497
30913
  before: void 0,
30498
30914
  persisted: void 0,
30499
30915
  error: ""
30500
30916
  }).current;
30501
- const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
30502
- useEffect28(() => {
30917
+ const scrub2 = (err) => scrubError(err, [config?.cmaToken ?? ""]);
30918
+ useEffect32(() => {
30503
30919
  readCredentials().then((cfg) => {
30504
30920
  setConfig(cfg);
30505
30921
  visit.before = snapshotOf(cfg);
@@ -30566,7 +30982,7 @@ function ProjectScreen({ onDone }) {
30566
30982
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
30567
30983
  setNotice({ kind: "success", text: "Project settings saved" });
30568
30984
  }).catch((err) => {
30569
- visit.error = scrub(err);
30985
+ visit.error = scrub2(err);
30570
30986
  visit.trail.record("save failed");
30571
30987
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
30572
30988
  }).finally(() => setSaving(false));
@@ -30651,7 +31067,7 @@ function ConfigurationScreen({ onDone }) {
30651
31067
  }
30652
31068
 
30653
31069
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
30654
- import { useEffect as useEffect29, useState as useState37 } from "react";
31070
+ import { useEffect as useEffect33, useState as useState37 } from "react";
30655
31071
  import { Box as Box52, Text as Text54, useInput as useInput18 } from "ink";
30656
31072
 
30657
31073
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
@@ -30675,7 +31091,7 @@ import { Fragment as Fragment20, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-
30675
31091
  function OptInAnalyticsScreen({ onDone }) {
30676
31092
  const [loading, setLoading] = useState37(true);
30677
31093
  const [enabled, setEnabled] = useState37(true);
30678
- useEffect29(() => {
31094
+ useEffect33(() => {
30679
31095
  readAnalyticsSetting().then((setting) => {
30680
31096
  setEnabled(setting.enabled);
30681
31097
  setLoading(false);
@@ -30729,7 +31145,7 @@ function OptInAnalyticsScreen({ onDone }) {
30729
31145
  }
30730
31146
 
30731
31147
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
30732
- import { useEffect as useEffect30, useRef as useRef20, useState as useState38 } from "react";
31148
+ import { useEffect as useEffect34, useRef as useRef21, useState as useState38 } from "react";
30733
31149
  import { Box as Box53, Text as Text55, useInput as useInput19 } from "ink";
30734
31150
  init_debug_mode_store();
30735
31151
  init_debug_store();
@@ -30746,8 +31162,8 @@ function DebugModeScreen({ onDone }) {
30746
31162
  RETENTION_CHOICES[RETENTION_CHOICES.length - 1]
30747
31163
  );
30748
31164
  const [notice, setNotice] = useState38(null);
30749
- const visit = useRef20({ trail: createTrail(), before: void 0, error: "" }).current;
30750
- useEffect30(() => {
31165
+ const visit = useRef21({ trail: createTrail(), before: void 0, error: "" }).current;
31166
+ useEffect34(() => {
30751
31167
  readDebugModeSetting().then((loaded) => {
30752
31168
  setSetting(loaded);
30753
31169
  setPending(loaded.retentionDays);
@@ -30902,7 +31318,7 @@ function App({ importOptions, inkClear }) {
30902
31318
  const [flowStart, setFlowStart] = useState39();
30903
31319
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
30904
31320
  const [importDefaults, setImportDefaults] = useState39();
30905
- useEffect31(() => {
31321
+ useEffect35(() => {
30906
31322
  if (screen !== "import") {
30907
31323
  setImportDefaults(void 0);
30908
31324
  return;
@@ -30975,7 +31391,7 @@ function App({ importOptions, inkClear }) {
30975
31391
  }
30976
31392
  });
30977
31393
  };
30978
- useEffect31(() => {
31394
+ useEffect35(() => {
30979
31395
  if (!tokensOnlyRun || tokensOnly?.status !== "done" || !tokensOnly.result.ok) return;
30980
31396
  const { credentialsSkipped, input, tokens } = tokensOnlyRun;
30981
31397
  const { tokensPath, tokenSessionId, tokenCount } = tokensOnly.result;
@@ -30997,12 +31413,12 @@ function App({ importOptions, inkClear }) {
30997
31413
  }
30998
31414
  });
30999
31415
  }, [tokensOnly, tokensOnlyRun]);
31000
- useEffect31(() => {
31416
+ useEffect35(() => {
31001
31417
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
31002
31418
  setExtractionRun(void 0);
31003
31419
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
31004
31420
  }, [extraction, extractionRun]);
31005
- useEffect31(() => {
31421
+ useEffect35(() => {
31006
31422
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
31007
31423
  const { extraction: produced, input, generatePromptPath } = scopeRun;
31008
31424
  setGenerationInput({
@@ -31020,7 +31436,7 @@ function App({ importOptions, inkClear }) {
31020
31436
  ...generatePromptPath ? { generatePromptPath } : {}
31021
31437
  });
31022
31438
  }, [scopeFlow, scopeRun, generationInput]);
31023
- useEffect31(() => {
31439
+ useEffect35(() => {
31024
31440
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
31025
31441
  const { credentialsSkipped, extraction: produced, input, generatePromptPath } = scopeRun;
31026
31442
  inkClear();
@@ -31189,6 +31605,7 @@ function App({ importOptions, inkClear }) {
31189
31605
  return /* @__PURE__ */ jsx66(
31190
31606
  CredentialsScreen,
31191
31607
  {
31608
+ mode: target,
31192
31609
  initial: importDefaults.credentials,
31193
31610
  tokensOnly: target === "tokens",
31194
31611
  onBack: () => goBackFrom("credentials"),