@contentful/experience-design-system-cli 2.40.1-dev-build-0aff4b7e.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/index.js CHANGED
@@ -40,14 +40,14 @@ function excerptAroundNames(text, names, maxChars, contextLines = 6) {
40
40
  if (mentioned.length === 0)
41
41
  return;
42
42
  const start = Math.max(0, index - contextLines);
43
- const end = Math.min(lines.length - 1, index + contextLines);
43
+ const end2 = Math.min(lines.length - 1, index + contextLines);
44
44
  const last = windows[windows.length - 1];
45
45
  if (last && start <= last.end + 1) {
46
- last.end = Math.max(last.end, end);
46
+ last.end = Math.max(last.end, end2);
47
47
  for (const name of mentioned)
48
48
  last.names.add(name);
49
49
  } else {
50
- windows.push({ start, end, names: new Set(mentioned) });
50
+ windows.push({ start, end: end2, names: new Set(mentioned) });
51
51
  }
52
52
  });
53
53
  if (windows.length === 0) {
@@ -1232,19 +1232,19 @@ function readToolCallObjects(stdout) {
1232
1232
  const line = raw.trim();
1233
1233
  if (!line.startsWith("{"))
1234
1234
  continue;
1235
- const end = findJsonObjectEnd(line);
1236
- if (end === -1) {
1235
+ const end2 = findJsonObjectEnd(line);
1236
+ if (end2 === -1) {
1237
1237
  warnings.push(`unparseable line: ${line.slice(0, 120)}`);
1238
1238
  continue;
1239
1239
  }
1240
1240
  let parsed;
1241
1241
  try {
1242
- parsed = JSON.parse(line.slice(0, end + 1));
1242
+ parsed = JSON.parse(line.slice(0, end2 + 1));
1243
1243
  } catch {
1244
1244
  warnings.push(`unparseable line: ${line.slice(0, 120)}`);
1245
1245
  continue;
1246
1246
  }
1247
- const trailing = line.slice(end + 1);
1247
+ const trailing = line.slice(end2 + 1);
1248
1248
  if (trailing.trim()) {
1249
1249
  warnings.push(`ignored trailing content after JSON: ${trailing.trim().slice(0, 120)}`);
1250
1250
  }
@@ -10444,10 +10444,10 @@ async function resolveViaTypeChecker(annotation, instance, moduleScript, filePat
10444
10444
  }
10445
10445
  function sliceSource(source, node) {
10446
10446
  const start = node["start"] ?? null;
10447
- const end = node["end"] ?? null;
10448
- if (start == null || end == null)
10447
+ const end2 = node["end"] ?? null;
10448
+ if (start == null || end2 == null)
10449
10449
  return null;
10450
- return source.slice(start, end);
10450
+ return source.slice(start, end2);
10451
10451
  }
10452
10452
  function sliceScriptContent(source, script) {
10453
10453
  if (!script)
@@ -18053,10 +18053,10 @@ var init_read_candidate_files = __esm({
18053
18053
  async function selectCompositionPromptFiles(components, sourceFiles) {
18054
18054
  const allFiles = await readCandidateFiles(components, sourceFiles);
18055
18055
  const selectedCandidates = selectCandidateFiles(allFiles).map((c2) => ({ path: c2.path, content: c2.content }));
18056
- const capped = capCandidatesToPromptBudget(selectedCandidates);
18057
- const promptFiles = capped.kept;
18056
+ const capped2 = capCandidatesToPromptBudget(selectedCandidates);
18057
+ const promptFiles = capped2.kept;
18058
18058
  const runtimeFiles = allFiles.map((c2) => ({ path: c2.path, content: c2.content }));
18059
- 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;
18059
+ 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;
18060
18060
  return { promptFiles, runtimeFiles, droppedWarning };
18061
18061
  }
18062
18062
  var init_select_composition_prompt_files = __esm({
@@ -19592,9 +19592,10 @@ function startDebugRun({
19592
19592
  const runId = generateRunId();
19593
19593
  const startedAt = Date.now();
19594
19594
  const redactedInputs = redact(inputs);
19595
- isDebugModeEnabled().then((enabled) => {
19596
- if (!enabled) return;
19597
- pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
19595
+ const run = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
19596
+ pendingRun = run;
19597
+ void isDebugModeEnabled().then((enabled) => {
19598
+ if (!enabled && pendingRun === run) pendingRun = void 0;
19598
19599
  });
19599
19600
  }
19600
19601
  async function finishDebugRun({
@@ -19605,9 +19606,10 @@ async function finishDebugRun({
19605
19606
  const run = pendingRun;
19606
19607
  if (!run) return;
19607
19608
  pendingRun = void 0;
19609
+ if (!await isDebugModeEnabled()) return;
19608
19610
  const durationMs = Date.now() - run.startedAt;
19609
19611
  const log = {
19610
- flow: run.flow,
19612
+ flow: logFolder(run.flow, run.step),
19611
19613
  menuOption: run.menuOption,
19612
19614
  content: renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs })
19613
19615
  };
@@ -19618,6 +19620,9 @@ async function finishDebugRun({
19618
19620
  }
19619
19621
  await writeLog(root, log);
19620
19622
  }
19623
+ function logFolder(flow, step) {
19624
+ return flow.startsWith("import/") && /^\d+-/.test(step) ? `import/${step}` : flow;
19625
+ }
19621
19626
  async function writeLog(root, log) {
19622
19627
  const dir = join19(root, ...log.flow.split("/"));
19623
19628
  await mkdir7(dir, { recursive: true });
@@ -21077,6 +21082,45 @@ var init_FieldForm = __esm({
21077
21082
  }
21078
21083
  });
21079
21084
 
21085
+ // packages/experience-design-system-cli/src/tui/shared/debug-trail.ts
21086
+ import { existsSync as existsSync10 } from "node:fs";
21087
+ function diffSnapshots(before, after) {
21088
+ const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
21089
+ const changed_fields = names.filter((name) => before[name] !== after[name]);
21090
+ return { changed: changed_fields.length > 0, changed_fields };
21091
+ }
21092
+ function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
21093
+ const actions = [];
21094
+ return {
21095
+ record(action) {
21096
+ actions.push(action);
21097
+ if (actions.length > limit) actions.shift();
21098
+ },
21099
+ entries: () => [...actions]
21100
+ };
21101
+ }
21102
+ function scrubError(error, secrets) {
21103
+ let message = error instanceof Error ? error.message : String(error);
21104
+ for (const secret of secrets) {
21105
+ if (secret.length < MIN_SECRET_LENGTH) continue;
21106
+ for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
21107
+ }
21108
+ return message;
21109
+ }
21110
+ function describeSettingsFile() {
21111
+ const path5 = configFilePath2();
21112
+ return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
21113
+ }
21114
+ var DEFAULT_TRAIL_LIMIT, MIN_SECRET_LENGTH;
21115
+ var init_debug_trail = __esm({
21116
+ "packages/experience-design-system-cli/src/tui/shared/debug-trail.ts"() {
21117
+ "use strict";
21118
+ init_config();
21119
+ DEFAULT_TRAIL_LIMIT = 30;
21120
+ MIN_SECRET_LENGTH = 6;
21121
+ }
21122
+ });
21123
+
21080
21124
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
21081
21125
  function credentialsPurpose(tokensOnly) {
21082
21126
  const use = tokensOnly ? "We use it to push your design tokens" : "We use it to check what components already exist and to push your import";
@@ -21090,17 +21134,42 @@ function normalize(values) {
21090
21134
  host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
21091
21135
  };
21092
21136
  }
21093
- function missingField(values) {
21094
- return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
21137
+ function missingFields(values) {
21138
+ return ["spaceId", "environmentId", "cmaToken"].filter((field) => values[field] === "");
21095
21139
  }
21096
21140
  function isUnchanged(current, initial) {
21097
21141
  return FIELDS.every((field) => current[field] === initial[field]);
21098
21142
  }
21143
+ function rejectedAttempt(reason, credentials) {
21144
+ return { host: credentials.host, reason: scrubError(reason, [credentials.cmaToken]) };
21145
+ }
21146
+ function credentialsLog(credentials) {
21147
+ return {
21148
+ space_id: credentials.spaceId,
21149
+ environment_id: credentials.environmentId,
21150
+ host: credentials.host,
21151
+ cma_token: credentials.cmaToken
21152
+ };
21153
+ }
21154
+ function credentialsOutputs({
21155
+ outcome,
21156
+ credentials,
21157
+ initial,
21158
+ attempts
21159
+ }) {
21160
+ return {
21161
+ outcome,
21162
+ ...credentialsLog(credentials),
21163
+ changed_fields: diffSnapshots(initial, credentials).changed_fields,
21164
+ rejected_attempts: attempts
21165
+ };
21166
+ }
21099
21167
  var FIELDS;
21100
21168
  var init_logic8 = __esm({
21101
21169
  "packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts"() {
21102
21170
  "use strict";
21103
21171
  init_src3();
21172
+ init_debug_trail();
21104
21173
  FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
21105
21174
  }
21106
21175
  });
@@ -21153,10 +21222,11 @@ var init_validate4 = __esm({
21153
21222
  });
21154
21223
 
21155
21224
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
21156
- import { useRef as useRef5, useState as useState9 } from "react";
21225
+ import { useEffect as useEffect8, useRef as useRef5, useState as useState9 } from "react";
21157
21226
  import { Box as Box14, Text as Text14, useInput as useInput11 } from "ink";
21158
21227
  import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
21159
21228
  function CredentialsScreen({
21229
+ mode,
21160
21230
  onDone,
21161
21231
  onBack,
21162
21232
  initial = {},
@@ -21179,17 +21249,64 @@ function CredentialsScreen({
21179
21249
  const [focus, setFocus] = useState9(0);
21180
21250
  const [active, setActive] = useState9(0);
21181
21251
  const [beforeEdit, setBeforeEdit] = useState9(initialValues);
21252
+ const visit = useRef5({ attempts: [], lastReason: "" }).current;
21253
+ useEffect8(() => {
21254
+ startDebugRun({
21255
+ flow: "import/credentials",
21256
+ step: "04-credentials",
21257
+ menuOption: "Credentials",
21258
+ inputs: { import_mode: mode, prefilled, ...credentialsLog(initialValues) }
21259
+ });
21260
+ }, []);
21261
+ const reject = (attempt, text) => {
21262
+ if (visit.attempts.length < MAX_LOGGED_ATTEMPTS2) visit.attempts.push(attempt);
21263
+ visit.lastReason = attempt.reason;
21264
+ setNotice({ kind: "error", text });
21265
+ };
21266
+ const leave = () => {
21267
+ void finishDebugRun({
21268
+ outputs: {
21269
+ ...credentialsOutputs({
21270
+ outcome: "back",
21271
+ credentials: normalize(values),
21272
+ initial: initialValues,
21273
+ attempts: visit.attempts
21274
+ }),
21275
+ ...notice ? { error: visit.lastReason } : {}
21276
+ },
21277
+ status: notice ? "error" : "success",
21278
+ exitMethod: "discarded"
21279
+ });
21280
+ onBack();
21281
+ };
21182
21282
  const submit = async () => {
21183
21283
  const credentials = normalize(values);
21184
- if (missingField(credentials)) {
21185
- setNotice({ kind: "error", text: "Space ID, environment and CMA token are all required." });
21284
+ const missing = missingFields(credentials);
21285
+ if (missing.length > 0) {
21286
+ reject(
21287
+ rejectedAttempt(`Missing required fields: ${missing.join(", ")}`, credentials),
21288
+ "Space ID, environment and CMA token are all required."
21289
+ );
21186
21290
  return;
21187
21291
  }
21188
21292
  setValidating(true);
21189
21293
  const result = await validate3(credentials);
21190
21294
  setValidating(false);
21191
- if (result.ok) onDone({ skipped: false, credentials });
21192
- else setNotice({ kind: "error", text: result.error });
21295
+ if (!result.ok) {
21296
+ reject(rejectedAttempt(result.error, credentials), result.error);
21297
+ return;
21298
+ }
21299
+ void finishDebugRun({
21300
+ outputs: credentialsOutputs({
21301
+ outcome: "validated",
21302
+ credentials,
21303
+ initial: initialValues,
21304
+ attempts: visit.attempts
21305
+ }),
21306
+ status: "success",
21307
+ exitMethod: "saved"
21308
+ });
21309
+ onDone({ skipped: false, credentials });
21193
21310
  };
21194
21311
  const choose = (choice) => {
21195
21312
  if (choice === "continue") void submit();
@@ -21198,7 +21315,7 @@ function CredentialsScreen({
21198
21315
  setBeforeEdit(values);
21199
21316
  setActive(0);
21200
21317
  setEditing(true);
21201
- } else onBack();
21318
+ } else leave();
21202
21319
  };
21203
21320
  const stopEditing = () => {
21204
21321
  setEditing(false);
@@ -21208,7 +21325,7 @@ function CredentialsScreen({
21208
21325
  if (validating) return;
21209
21326
  if (editing) {
21210
21327
  if (key.escape) {
21211
- if (!prefilled) onBack();
21328
+ if (!prefilled) leave();
21212
21329
  else {
21213
21330
  setValues(beforeEdit);
21214
21331
  setNotice(null);
@@ -21314,11 +21431,12 @@ function CredentialsScreen({
21314
21431
  ] })
21315
21432
  ] });
21316
21433
  }
21317
- var FIELDS2, MENU;
21434
+ var FIELDS2, MENU, MAX_LOGGED_ATTEMPTS2;
21318
21435
  var init_screen5 = __esm({
21319
21436
  "packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx"() {
21320
21437
  "use strict";
21321
21438
  init_theme();
21439
+ init_debug_store();
21322
21440
  init_FieldForm();
21323
21441
  init_ClearableTextInput();
21324
21442
  init_ControlHints();
@@ -21335,10 +21453,52 @@ var init_screen5 = __esm({
21335
21453
  { choice: "continue", label: "Continue", description: "Check the credentials and go on" },
21336
21454
  { choice: "edit", label: "Edit", description: "Change the credentials" }
21337
21455
  ];
21456
+ MAX_LOGGED_ATTEMPTS2 = 10;
21338
21457
  }
21339
21458
  });
21340
21459
 
21341
21460
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts
21461
+ function extractionLogInputs(input) {
21462
+ const { credentials } = input;
21463
+ return {
21464
+ project_path: input.projectPath,
21465
+ out_dir: input.outDir ?? "",
21466
+ files_to_scan: input.filePaths.length,
21467
+ raw_tokens_path: input.rawTokensPath,
21468
+ agent: input.agent,
21469
+ agent_model: input.agentModel ?? "",
21470
+ prompt_overrides: input.promptOverrides,
21471
+ cache: !input.noCache,
21472
+ has_credentials: credentials !== null,
21473
+ space_id: credentials?.spaceId ?? "",
21474
+ environment_id: credentials?.environmentId ?? "",
21475
+ host: credentials?.host ?? "",
21476
+ cma_token: credentials?.cmaToken ?? ""
21477
+ };
21478
+ }
21479
+ function extractionLogOutputs(result, progress, cmaToken) {
21480
+ const last = progress ? { final_progress: progress } : {};
21481
+ if (!result.ok) {
21482
+ return {
21483
+ outputs: { result: "failed", failed_step: result.step, error: scrubError(result.message, [cmaToken]), ...last },
21484
+ status: "error"
21485
+ };
21486
+ }
21487
+ const { extraction } = result;
21488
+ return {
21489
+ outputs: {
21490
+ result: "done",
21491
+ session_id: extraction.sessionId,
21492
+ out_dir: extraction.outDir,
21493
+ tokens_path: extraction.tokensPath,
21494
+ token_count: extraction.tokenCount,
21495
+ existing_entities_status: extraction.existingEntitiesStatus,
21496
+ composition_phase: extraction.compositionPhase,
21497
+ ...last
21498
+ },
21499
+ status: "success"
21500
+ };
21501
+ }
21342
21502
  function initialProgress(input) {
21343
21503
  return {
21344
21504
  scan: null,
@@ -21422,6 +21582,7 @@ var init_logic9 = __esm({
21422
21582
  "packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts"() {
21423
21583
  "use strict";
21424
21584
  init_src3();
21585
+ init_debug_trail();
21425
21586
  }
21426
21587
  });
21427
21588
 
@@ -21477,8 +21638,8 @@ function computeColumnWindow(total, cursor, visibleCount) {
21477
21638
  if (total <= visibleCount) return { start: 0, end: total, above: 0, below: 0 };
21478
21639
  let start = Math.max(0, cursor - Math.floor(visibleCount / 2));
21479
21640
  start = Math.min(start, total - visibleCount);
21480
- const end = start + visibleCount;
21481
- return { start, end, above: start, below: total - end };
21641
+ const end2 = start + visibleCount;
21642
+ return { start, end: end2, above: start, below: total - end2 };
21482
21643
  }
21483
21644
  var TOKEN_REVIEW_CONTROLS;
21484
21645
  var init_logic10 = __esm({
@@ -21509,7 +21670,7 @@ var init_load = __esm({
21509
21670
  });
21510
21671
 
21511
21672
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx
21512
- import { useMemo as useMemo2, useState as useState10 } from "react";
21673
+ import { useEffect as useEffect9, useMemo as useMemo2, useState as useState10 } from "react";
21513
21674
  import { Box as Box15, Text as Text15, useInput as useInput12 } from "ink";
21514
21675
  import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
21515
21676
  function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
@@ -21517,12 +21678,31 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
21517
21678
  const rows = loaded.ok ? loaded.rows : [];
21518
21679
  const columns = useTerminalWidth();
21519
21680
  const [selected, setSelected] = useState10(0);
21681
+ useEffect9(() => {
21682
+ startDebugRun({
21683
+ flow: "import/token-review",
21684
+ step: "05-token-review",
21685
+ menuOption: "Token review",
21686
+ inputs: { import_mode: "tokens", tokens_path: tokensPath }
21687
+ });
21688
+ }, []);
21689
+ const finish = (outcome) => {
21690
+ void finishDebugRun({
21691
+ outputs: { outcome, ...loaded.ok ? { tokens: rows.length } : { load_error: loaded.message } },
21692
+ status: loaded.ok ? "success" : "error",
21693
+ exitMethod: outcome === "continued" ? "saved" : "discarded"
21694
+ });
21695
+ };
21520
21696
  const move = (to) => setSelected(Math.max(0, Math.min(to, rows.length - 1)));
21521
- const { start, end } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
21697
+ const { start, end: end2 } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
21522
21698
  useInput12((_input, key) => {
21523
- if (key.return) onContinue();
21524
- else if (key.escape) onQuit();
21525
- else if (key.upArrow) move(selected - 1);
21699
+ if (key.return) {
21700
+ finish("continued");
21701
+ onContinue();
21702
+ } else if (key.escape) {
21703
+ finish("back");
21704
+ onQuit();
21705
+ } else if (key.upArrow) move(selected - 1);
21526
21706
  else if (key.downArrow) move(selected + 1);
21527
21707
  else if (key.pageUp) move(selected - VISIBLE_ROWS);
21528
21708
  else if (key.pageDown) move(selected + VISIBLE_ROWS);
@@ -21558,7 +21738,7 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
21558
21738
  " ",
21559
21739
  clip("Value", valueWidth)
21560
21740
  ] }),
21561
- rows.slice(start, end).map((row, offset) => {
21741
+ rows.slice(start, end2).map((row, offset) => {
21562
21742
  const active = start + offset === selected;
21563
21743
  return /* @__PURE__ */ jsxs15(Text15, { color: active ? PALETTE.accent : void 0, bold: active, wrap: "truncate-end", children: [
21564
21744
  active ? "\u203A " : " ",
@@ -21573,7 +21753,7 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
21573
21753
  rows.length > VISIBLE_ROWS && /* @__PURE__ */ jsx17(Box15, { marginTop: 1, children: /* @__PURE__ */ jsxs15(Text15, { color: PALETTE.muted, children: [
21574
21754
  start + 1,
21575
21755
  "-",
21576
- end,
21756
+ end2,
21577
21757
  " of ",
21578
21758
  rows.length
21579
21759
  ] }) }),
@@ -21586,6 +21766,7 @@ var init_screen7 = __esm({
21586
21766
  "packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx"() {
21587
21767
  "use strict";
21588
21768
  init_theme();
21769
+ init_debug_store();
21589
21770
  init_ControlHints();
21590
21771
  init_StepHeader();
21591
21772
  init_use_terminal_width();
@@ -21611,7 +21792,7 @@ var init_steps = __esm({
21611
21792
  });
21612
21793
 
21613
21794
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
21614
- import { existsSync as existsSync10 } from "node:fs";
21795
+ import { existsSync as existsSync11 } from "node:fs";
21615
21796
  import { dirname as dirname16, join as join20, resolve as resolve22 } from "node:path";
21616
21797
  import { fileURLToPath as fileURLToPath4 } from "node:url";
21617
21798
  function findSkillPath(fileName) {
@@ -21619,7 +21800,7 @@ function findSkillPath(fileName) {
21619
21800
  let dir = thisDir;
21620
21801
  for (; ; ) {
21621
21802
  const candidate = join20(dir, "skills", fileName);
21622
- if (existsSync10(candidate)) return candidate;
21803
+ if (existsSync11(candidate)) return candidate;
21623
21804
  const parent = resolve22(dir, "..");
21624
21805
  if (parent === dir) {
21625
21806
  throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
@@ -21883,11 +22064,11 @@ var init_run = __esm({
21883
22064
  });
21884
22065
 
21885
22066
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
21886
- import { useEffect as useEffect8, useRef as useRef6, useState as useState11 } from "react";
22067
+ import { useEffect as useEffect10, useRef as useRef6, useState as useState11 } from "react";
21887
22068
  function useExtraction(input) {
21888
22069
  const [state2, setState] = useState11();
21889
22070
  const current = useRef6();
21890
- useEffect8(() => {
22071
+ useEffect10(() => {
21891
22072
  current.current = input;
21892
22073
  if (!input) {
21893
22074
  setState(void 0);
@@ -21900,10 +22081,23 @@ function useExtraction(input) {
21900
22081
  hasRawTokens: input.rawTokensPath !== ""
21901
22082
  })
21902
22083
  });
22084
+ let lastProgress;
22085
+ startDebugRun({
22086
+ flow: "import/extraction",
22087
+ step: "06-extraction",
22088
+ menuOption: "Extraction",
22089
+ inputs: extractionLogInputs(input)
22090
+ });
21903
22091
  void runExtraction(input, (progress) => {
22092
+ lastProgress = progress;
21904
22093
  if (current.current === input) setState({ status: "running", progress });
21905
22094
  }).then((result) => {
21906
- if (current.current === input) setState({ status: "done", result });
22095
+ if (current.current !== input) return;
22096
+ void finishDebugRun({
22097
+ ...extractionLogOutputs(result, lastProgress, input.credentials?.cmaToken ?? ""),
22098
+ exitMethod: result.ok ? "saved" : "discarded"
22099
+ });
22100
+ setState({ status: "done", result });
21907
22101
  });
21908
22102
  return () => {
21909
22103
  if (current.current === input) current.current = void 0;
@@ -21914,6 +22108,7 @@ function useExtraction(input) {
21914
22108
  var init_use_extraction = __esm({
21915
22109
  "packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts"() {
21916
22110
  "use strict";
22111
+ init_debug_store();
21917
22112
  init_logic9();
21918
22113
  init_run();
21919
22114
  }
@@ -21958,11 +22153,11 @@ var init_run_tokens_only = __esm({
21958
22153
  });
21959
22154
 
21960
22155
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-tokens-only.ts
21961
- import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
22156
+ import { useEffect as useEffect11, useRef as useRef7, useState as useState12 } from "react";
21962
22157
  function useTokensOnly(input) {
21963
22158
  const [state2, setState] = useState12();
21964
22159
  const current = useRef7();
21965
- useEffect9(() => {
22160
+ useEffect11(() => {
21966
22161
  current.current = input;
21967
22162
  if (!input) {
21968
22163
  setState(void 0);
@@ -21985,6 +22180,39 @@ var init_use_tokens_only = __esm({
21985
22180
  }
21986
22181
  });
21987
22182
 
22183
+ // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts
22184
+ function scopeGateLogInputs(components, tokenCount) {
22185
+ const ai = { accepted: 0, rejected: 0, failed: 0, none: 0 };
22186
+ for (const component of components) ai[component.aiDecision ?? "none"] += 1;
22187
+ return {
22188
+ components_found: components.length,
22189
+ ai_suggestions: ai,
22190
+ needs_review: components.filter((component) => component.needsReview === true).length,
22191
+ tokens: tokenCount
22192
+ };
22193
+ }
22194
+ function scopeGateLogOutputs(components, decisions) {
22195
+ const suggested = new Map(components.map((component) => [component.name, component.aiDecision]));
22196
+ return {
22197
+ outcome: "continued",
22198
+ accepted: new Set(decisions.accepted).size,
22199
+ rejected: new Set(decisions.rejected).size,
22200
+ accepted_although_ai_rejected: capped(decisions.accepted.filter((name) => suggested.get(name) === "rejected")),
22201
+ not_accepted_although_ai_accepted: capped(decisions.rejected.filter((name) => suggested.get(name) === "accepted"))
22202
+ };
22203
+ }
22204
+ var MAX_NAMES, capped;
22205
+ var init_log = __esm({
22206
+ "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts"() {
22207
+ "use strict";
22208
+ MAX_NAMES = 20;
22209
+ capped = (names) => {
22210
+ const unique = [...new Set(names)];
22211
+ return { count: unique.length, names: unique.slice(0, MAX_NAMES) };
22212
+ };
22213
+ }
22214
+ });
22215
+
21988
22216
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/components/windowed-panel.tsx
21989
22217
  import { Box as Box16, Text as Text16 } from "ink";
21990
22218
  import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
@@ -22248,10 +22476,10 @@ function GotoBanner({
22248
22476
  }) {
22249
22477
  const highlightIndex = cursorRowIndex ?? cursor;
22250
22478
  const start = windowStart(rows.length, highlightIndex, maxRows);
22251
- const end = Math.min(rows.length, start + maxRows);
22252
- const visible = rows.slice(start, end);
22479
+ const end2 = Math.min(rows.length, start + maxRows);
22480
+ const visible = rows.slice(start, end2);
22253
22481
  const moreAbove = start;
22254
- const moreBelow = rows.length - end;
22482
+ const moreBelow = rows.length - end2;
22255
22483
  return /* @__PURE__ */ jsxs21(
22256
22484
  Box21,
22257
22485
  {
@@ -23083,8 +23311,8 @@ function GroupedSidebar(props) {
23083
23311
  });
23084
23312
  const windowed = scrollOffset !== void 0 && visibleCount !== void 0;
23085
23313
  const start = windowed ? Math.max(0, scrollOffset ?? 0) : 0;
23086
- const end = windowed ? start + (visibleCount ?? allRows.length) + 1 : allRows.length;
23087
- const rows = windowed ? allRows.slice(start, end) : allRows;
23314
+ const end2 = windowed ? start + (visibleCount ?? allRows.length) + 1 : allRows.length;
23315
+ const rows = windowed ? allRows.slice(start, end2) : allRows;
23088
23316
  return /* @__PURE__ */ jsxs22(WindowedPanel, { width, height: props.height, title, focused, children: [
23089
23317
  allRows.length === 0 && emptyMessage !== void 0 && /* @__PURE__ */ jsxs22(Text23, { color: PALETTE.warning, children: [
23090
23318
  " ",
@@ -23138,7 +23366,7 @@ function GroupedSidebar(props) {
23138
23366
  inheritanceStyle.glyph && /* @__PURE__ */ jsx26(Text23, { color: inheritanceStyle.dim ? PALETTE.muted : inheritanceStyle.color, bold: inheritanceStyle.bold, children: " " + inheritanceStyle.glyph })
23139
23367
  ] }, row.key);
23140
23368
  }),
23141
- windowed && /* @__PURE__ */ jsx26(WindowFooter, { above: start, below: Math.max(0, allRows.length - end) })
23369
+ windowed && /* @__PURE__ */ jsx26(WindowFooter, { above: start, below: Math.max(0, allRows.length - end2) })
23142
23370
  ] });
23143
23371
  }
23144
23372
  var GLYPH_EXPAND_COLLAPSED, GLYPH_EXPAND_EXPANDED, GLYPH_TREE_MID, GLYPH_TREE_LAST, GLYPH_WARN, GLYPH_ERROR;
@@ -23239,7 +23467,7 @@ var init_useImmediateInput = __esm({
23239
23467
 
23240
23468
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
23241
23469
  import { useStdout as useStdout2 } from "ink";
23242
- import { useEffect as useEffect10, useState as useState13 } from "react";
23470
+ import { useEffect as useEffect12, useState as useState13 } from "react";
23243
23471
  function readTerminalSize(stdout) {
23244
23472
  return {
23245
23473
  columns: stdout?.columns ?? 80,
@@ -23249,7 +23477,7 @@ function readTerminalSize(stdout) {
23249
23477
  function useTerminalSize() {
23250
23478
  const { stdout } = useStdout2();
23251
23479
  const [size, setSize] = useState13(() => readTerminalSize(stdout));
23252
- useEffect10(() => {
23480
+ useEffect12(() => {
23253
23481
  const updateSize = () => setSize(readTerminalSize(stdout));
23254
23482
  stdout?.on("resize", updateSize);
23255
23483
  updateSize();
@@ -24251,7 +24479,7 @@ var init_state = __esm({
24251
24479
  });
24252
24480
 
24253
24481
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
24254
- import { useEffect as useEffect11, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
24482
+ import { useEffect as useEffect13, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
24255
24483
  function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }) {
24256
24484
  const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
24257
24485
  const columnPlan = useMemo3(
@@ -24298,7 +24526,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
24298
24526
  return seed;
24299
24527
  });
24300
24528
  const seededGroupsRef = useRef9(closures.size > 0 || cycleParticipants.size > 0);
24301
- useEffect11(() => {
24529
+ useEffect13(() => {
24302
24530
  if (seededGroupsRef.current) return;
24303
24531
  if (closures.size === 0 && cycleParticipants.size === 0) return;
24304
24532
  seededGroupsRef.current = true;
@@ -24389,7 +24617,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
24389
24617
  entryCount: 0
24390
24618
  });
24391
24619
  const panelLayout = useMemo3(() => computePanelLayout(visibleCount), [visibleCount]);
24392
- useEffect11(() => {
24620
+ useEffect13(() => {
24393
24621
  setNav((prev) => {
24394
24622
  const maxIdx = Math.max(0, visibleRows.length - 1);
24395
24623
  const nextCursor = Math.min(prev.cursor, maxIdx);
@@ -24734,27 +24962,59 @@ var init_use_scope_gate = __esm({
24734
24962
  });
24735
24963
 
24736
24964
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx
24737
- import { useMemo as useMemo4 } from "react";
24965
+ import { useEffect as useEffect14, useMemo as useMemo4 } from "react";
24738
24966
  import { Box as Box25, Text as Text26 } from "ink";
24739
24967
  import { Fragment as Fragment5, jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
24740
24968
  function ScopeGateScreen(props) {
24741
- if (props.components.length === 0) {
24742
- 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." }) });
24743
- }
24969
+ if (props.components.length === 0) return /* @__PURE__ */ jsx29(NoComponents, {});
24744
24970
  return /* @__PURE__ */ jsx29(ScopeGateView, { ...props });
24745
24971
  }
24972
+ function NoComponents() {
24973
+ useEffect14(() => {
24974
+ startDebugRun({
24975
+ flow: "import/scope-gate",
24976
+ step: "07-scope-gate",
24977
+ menuOption: "Scope gate",
24978
+ inputs: scopeGateLogInputs([], 0)
24979
+ });
24980
+ void finishDebugRun({
24981
+ outputs: { outcome: "nothing to decide", error: "No components were found for this session." },
24982
+ status: "error",
24983
+ exitMethod: "discarded"
24984
+ });
24985
+ }, []);
24986
+ 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." }) });
24987
+ }
24746
24988
  function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
24747
24989
  const tokens = useMemo4(() => {
24748
24990
  const loaded = tokensPath ? loadTokenRows(tokensPath) : void 0;
24749
24991
  return loaded?.ok ? loaded.rows : [];
24750
24992
  }, [tokensPath]);
24751
24993
  const longest = useMemo4(() => longestEntries(tokens), [tokens]);
24994
+ useEffect14(() => {
24995
+ startDebugRun({
24996
+ flow: "import/scope-gate",
24997
+ step: "07-scope-gate",
24998
+ menuOption: "Scope gate",
24999
+ inputs: scopeGateLogInputs(components, tokens.length)
25000
+ });
25001
+ }, []);
24752
25002
  const gate = useScopeGate({
24753
25003
  components,
24754
25004
  tokenCount: tokens.length,
24755
25005
  tokensWidth: longest.path + longest.value + 10,
24756
- onConfirm,
24757
- onQuit
25006
+ onConfirm: (decisions) => {
25007
+ void finishDebugRun({
25008
+ outputs: scopeGateLogOutputs(components, decisions),
25009
+ status: "success",
25010
+ exitMethod: "saved"
25011
+ });
25012
+ onConfirm(decisions);
25013
+ },
25014
+ onQuit: () => {
25015
+ void finishDebugRun({ outputs: { outcome: "quit" }, status: "success", exitMethod: "discarded" });
25016
+ onQuit();
25017
+ }
24758
25018
  });
24759
25019
  const { search, graph, columnPlan, panelLayout, counters } = gate;
24760
25020
  if (gate.showHelp) {
@@ -24854,7 +25114,9 @@ var HELP_SECTIONS;
24854
25114
  var init_screen8 = __esm({
24855
25115
  "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx"() {
24856
25116
  "use strict";
25117
+ init_debug_store();
24857
25118
  init_StepHeader();
25119
+ init_log();
24858
25120
  init_tokens_column();
24859
25121
  init_load();
24860
25122
  init_logic10();
@@ -24962,13 +25224,27 @@ var init_load2 = __esm({
24962
25224
  });
24963
25225
 
24964
25226
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
24965
- import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
25227
+ import { useEffect as useEffect15, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
24966
25228
  function useScopeGateFlow(input, deps = realDeps3) {
24967
25229
  const sessionId = input?.sessionId;
24968
25230
  const loaded = useMemo5(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
24969
25231
  const cacheCheck = useRef10(void 0);
24970
25232
  const [confirmed, setConfirmed] = useState17();
24971
- useEffect12(() => {
25233
+ useEffect15(() => {
25234
+ if (!sessionId || !loaded || loaded.ok) return;
25235
+ startDebugRun({
25236
+ flow: "import/scope-gate",
25237
+ step: "07-scope-gate",
25238
+ menuOption: "Scope gate",
25239
+ inputs: { session_id: sessionId }
25240
+ });
25241
+ void finishDebugRun({
25242
+ outputs: { outcome: "could not load the components", error: loaded.message },
25243
+ status: "error",
25244
+ exitMethod: "discarded"
25245
+ });
25246
+ }, [sessionId, loaded]);
25247
+ useEffect15(() => {
24972
25248
  if (!input || !loaded?.ok || cacheCheck.current) return;
24973
25249
  cacheCheck.current = deps.checkCache(input.cache);
24974
25250
  }, [input, loaded]);
@@ -24982,6 +25258,7 @@ var realDeps3;
24982
25258
  var init_use_scope_gate_flow = __esm({
24983
25259
  "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts"() {
24984
25260
  "use strict";
25261
+ init_debug_store();
24985
25262
  init_cache_check();
24986
25263
  init_load2();
24987
25264
  realDeps3 = { load: loadScopeGate, checkCache: checkGenerationCache };
@@ -24989,6 +25266,41 @@ var init_use_scope_gate_flow = __esm({
24989
25266
  });
24990
25267
 
24991
25268
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/logic.ts
25269
+ function generationLogInputs(input) {
25270
+ return {
25271
+ session_id: input.sessionId,
25272
+ accepted: input.decisions.accepted.length,
25273
+ rejected: input.decisions.rejected.length,
25274
+ tokens_path: input.tokensPath,
25275
+ token_session_id: input.tokenSessionId,
25276
+ existing_entities_path: input.existingEntitiesPath,
25277
+ agent: input.agent,
25278
+ agent_model: input.agentModel ?? "",
25279
+ prompt_overrides: input.promptOverrides,
25280
+ generate_prompt_path: input.generatePromptPath ?? "",
25281
+ cache: !input.noCache,
25282
+ has_tokens: input.hasTokens
25283
+ };
25284
+ }
25285
+ function generationLogOutputs(result, progress) {
25286
+ const last = progress ? { final_progress: progress } : {};
25287
+ if (!result.ok) {
25288
+ return { outputs: { result: "failed", failed_step: result.step, error: result.message, ...last }, status: "error" };
25289
+ }
25290
+ const { generation } = result;
25291
+ return {
25292
+ outputs: generation.route === "review" ? {
25293
+ result: "done",
25294
+ route: generation.route,
25295
+ session_id: generation.sessionId,
25296
+ accepted: generation.acceptedCount,
25297
+ generated: generation.generatedCount,
25298
+ map_tokens_eligible: generation.mapTokensEligible,
25299
+ ...last
25300
+ } : { result: "done", route: generation.route, accepted: generation.acceptedCount, ...last },
25301
+ status: "success"
25302
+ };
25303
+ }
24992
25304
  function initialProgress2() {
24993
25305
  return { components: null, mapTokens: "idle", mapTokensEligible: null };
24994
25306
  }
@@ -25239,21 +25551,34 @@ var init_run2 = __esm({
25239
25551
  });
25240
25552
 
25241
25553
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
25242
- import { useEffect as useEffect13, useRef as useRef11, useState as useState18 } from "react";
25554
+ import { useEffect as useEffect16, useRef as useRef11, useState as useState18 } from "react";
25243
25555
  function useGeneration(input) {
25244
25556
  const [state2, setState] = useState18();
25245
25557
  const current = useRef11();
25246
- useEffect13(() => {
25558
+ useEffect16(() => {
25247
25559
  current.current = input;
25248
25560
  if (!input) {
25249
25561
  setState(void 0);
25250
25562
  return;
25251
25563
  }
25252
25564
  setState({ status: "running", progress: initialProgress2() });
25565
+ let lastProgress;
25566
+ startDebugRun({
25567
+ flow: "import/generation",
25568
+ step: "08-generation",
25569
+ menuOption: "Generation",
25570
+ inputs: generationLogInputs(input)
25571
+ });
25253
25572
  void runGeneration(input, (progress) => {
25573
+ lastProgress = progress;
25254
25574
  if (current.current === input) setState({ status: "running", progress });
25255
25575
  }).then((result) => {
25256
- if (current.current === input) setState({ status: "done", result });
25576
+ if (current.current !== input) return;
25577
+ void finishDebugRun({
25578
+ ...generationLogOutputs(result, lastProgress),
25579
+ exitMethod: result.ok ? "saved" : "discarded"
25580
+ });
25581
+ setState({ status: "done", result });
25257
25582
  });
25258
25583
  return () => {
25259
25584
  if (current.current === input) current.current = void 0;
@@ -25264,6 +25589,7 @@ function useGeneration(input) {
25264
25589
  var init_use_generation = __esm({
25265
25590
  "packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts"() {
25266
25591
  "use strict";
25592
+ init_debug_store();
25267
25593
  init_logic11();
25268
25594
  init_run2();
25269
25595
  }
@@ -26230,7 +26556,7 @@ var init_scroll_offset = __esm({
26230
26556
  });
26231
26557
 
26232
26558
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
26233
- import React13, { useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
26559
+ import React13, { useEffect as useEffect17, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
26234
26560
  import figures6 from "figures";
26235
26561
  import { Box as Box26, measureElement, Text as Text27 } from "ink";
26236
26562
  import { Fragment as Fragment6, jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
@@ -27748,16 +28074,16 @@ function FieldEditor({
27748
28074
  const visibleEnd = (start) => {
27749
28075
  if (focusLevel === "field") return Math.min(rows.length, start + 1);
27750
28076
  let used = 0;
27751
- let end2 = start;
27752
- while (end2 < rows.length) {
27753
- const nextHeight = rowHeight(rows[end2], end2);
27754
- if (end2 > start && used + nextHeight > contentHeight) break;
28077
+ let end3 = start;
28078
+ while (end3 < rows.length) {
28079
+ const nextHeight = rowHeight(rows[end3], end3);
28080
+ if (end3 > start && used + nextHeight > contentHeight) break;
27755
28081
  used += nextHeight;
27756
- end2 += 1;
28082
+ end3 += 1;
27757
28083
  }
27758
- return Math.max(start + 1, end2);
28084
+ return Math.max(start + 1, end3);
27759
28085
  };
27760
- useEffect14(() => {
28086
+ useEffect17(() => {
27761
28087
  if (focusLevel === "field" || selectedRowIdx < 0) return;
27762
28088
  setListScrollStart((previous) => {
27763
28089
  if (initialFocusTarget && !initialFocusScrollApplied.current) {
@@ -27765,9 +28091,9 @@ function FieldEditor({
27765
28091
  return Math.min(selectedRowIdx, Math.max(0, rows.length - 1));
27766
28092
  }
27767
28093
  const clamped = Math.min(previous, Math.max(0, rows.length - 1));
27768
- const end2 = visibleEnd(clamped);
28094
+ const end3 = visibleEnd(clamped);
27769
28095
  if (selectedRowIdx < clamped) return selectedRowIdx;
27770
- if (selectedRowIdx >= end2) {
28096
+ if (selectedRowIdx >= end3) {
27771
28097
  let start = selectedRowIdx;
27772
28098
  let used = rowHeight(rows[selectedRowIdx], selectedRowIdx);
27773
28099
  while (start > 0) {
@@ -27782,10 +28108,10 @@ function FieldEditor({
27782
28108
  });
27783
28109
  }, [contentHeight, focusLevel, rowHeights, rows, selectedRowIdx]);
27784
28110
  const scrollStart = Math.min(listScrollStart, Math.max(0, rows.length - 1));
27785
- const end = visibleEnd(scrollStart);
27786
- const nextHeader = rows.slice(end).find((row) => row.kind === "header");
28111
+ const end2 = visibleEnd(scrollStart);
28112
+ const nextHeader = rows.slice(end2).find((row) => row.kind === "header");
27787
28113
  const categoryBelow = focusLevel !== "field" && nextHeader?.kind === "header" ? nextHeader.label.replace(/^──\s*/, "").trim() : null;
27788
- const visibleRowSlice = rows.slice(scrollStart, end);
28114
+ const visibleRowSlice = rows.slice(scrollStart, end2);
27789
28115
  useLayoutEffect2(() => {
27790
28116
  const nextHeights = {};
27791
28117
  for (const [key, node] of rowMeasureRefs.current) {
@@ -27947,20 +28273,20 @@ function FieldEditor({
27947
28273
  sourceOpen && !onToggleSourceExternal && (() => {
27948
28274
  const propMeta = !inSlots && !inComponentDesc && currentProp ? metadata?.props?.[currentProp.name] : void 0;
27949
28275
  const start = propMeta?.sourceStartLine ?? null;
27950
- const end2 = propMeta?.sourceEndLine ?? null;
28276
+ const end3 = propMeta?.sourceEndLine ?? null;
27951
28277
  const path5 = metadata?.sourcePath ?? null;
27952
28278
  const src = metadata?.componentSource ?? null;
27953
28279
  const headerPath = path5 ?? "<unknown source path>";
27954
- if (!start || !end2 || !src) {
28280
+ if (!start || !end3 || !src) {
27955
28281
  return /* @__PURE__ */ jsxs26(Box26, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [
27956
28282
  /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, bold: true, children: `source: ${headerPath}` }),
27957
28283
  /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, children: "(no source location captured for this prop)" }),
27958
28284
  /* @__PURE__ */ jsx32(Text27, { children: "[s] close" })
27959
28285
  ] });
27960
28286
  }
27961
- const lines = src.split("\n").slice(Math.max(0, start - 1), end2);
28287
+ const lines = src.split("\n").slice(Math.max(0, start - 1), end3);
27962
28288
  return /* @__PURE__ */ jsxs26(Box26, { flexDirection: "column", borderStyle: "single", borderColor: "gray", paddingX: 1, children: [
27963
- /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, bold: true, children: `${headerPath}: lines ${start}\u2013${end2}` }),
28289
+ /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, bold: true, children: `${headerPath}: lines ${start}\u2013${end3}` }),
27964
28290
  lines.map((ln, i) => /* @__PURE__ */ jsx32(Text27, { color: PALETTE.muted, children: ln }, `source-line-${i}`)),
27965
28291
  /* @__PURE__ */ jsx32(Text27, { children: "[s] close \xB7 [Esc] close" })
27966
28292
  ] });
@@ -29152,7 +29478,7 @@ var init_FinalizeDialog = __esm({
29152
29478
  });
29153
29479
 
29154
29480
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
29155
- import { useEffect as useEffect15, useRef as useRef12, useState as useState20 } from "react";
29481
+ import { useEffect as useEffect18, useRef as useRef12, useState as useState20 } from "react";
29156
29482
  function useReviewFinalizePreview({
29157
29483
  components,
29158
29484
  ...options
@@ -29169,7 +29495,7 @@ function useFinalizePreview(opts) {
29169
29495
  const [scrollOffset, setScrollOffset] = useState20(0);
29170
29496
  const generationRef = useRef12(0);
29171
29497
  const acceptedKey = [...acceptedKeys].sort().join("\0");
29172
- useEffect15(() => {
29498
+ useEffect18(() => {
29173
29499
  if (!open) {
29174
29500
  setStatus("idle");
29175
29501
  setRemoved([]);
@@ -29221,7 +29547,7 @@ var init_use_finalize_preview = __esm({
29221
29547
  });
29222
29548
 
29223
29549
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
29224
- import { useCallback as useCallback2, useEffect as useEffect16, useRef as useRef13, useState as useState21 } from "react";
29550
+ import { useCallback as useCallback2, useEffect as useEffect19, useRef as useRef13, useState as useState21 } from "react";
29225
29551
  function useReviewSession({
29226
29552
  loadSession,
29227
29553
  tokensPath,
@@ -29240,7 +29566,7 @@ function useReviewSession({
29240
29566
  }));
29241
29567
  return { result, catalog };
29242
29568
  }, [loadSession, tokensPath]);
29243
- useEffect16(() => {
29569
+ useEffect19(() => {
29244
29570
  let disposed = false;
29245
29571
  void (async () => {
29246
29572
  try {
@@ -29293,7 +29619,7 @@ function useReviewSession({
29293
29619
  function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
29294
29620
  const [reviewMetadata, setReviewMetadata] = useState21(null);
29295
29621
  const [componentRationale, setComponentRationale] = useState21(null);
29296
- useEffect16(() => {
29622
+ useEffect19(() => {
29297
29623
  const current = components[selectedIdx];
29298
29624
  if (!current) {
29299
29625
  setReviewMetadata(null);
@@ -29325,7 +29651,7 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
29325
29651
  function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
29326
29652
  const historyRef = useRef13(null);
29327
29653
  const historySeededRef = useRef13(false);
29328
- useEffect16(() => {
29654
+ useEffect19(() => {
29329
29655
  if (loading || historySeededRef.current) return;
29330
29656
  historySeededRef.current = true;
29331
29657
  historyRef.current = createHistoryStack(createSnapshot(components));
@@ -29407,7 +29733,7 @@ var init_token_suggestions = __esm({
29407
29733
  });
29408
29734
 
29409
29735
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
29410
- import { useEffect as useEffect17, useRef as useRef14, useState as useState22 } from "react";
29736
+ import { useEffect as useEffect20, useRef as useRef14, useState as useState22 } from "react";
29411
29737
  function parseReviewEntry(draftValue) {
29412
29738
  const parsed = JSON.parse(draftValue);
29413
29739
  const keys = Object.keys(parsed);
@@ -29441,7 +29767,7 @@ function useReviewEditor({
29441
29767
  const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState22(/* @__PURE__ */ new Set());
29442
29768
  const tokenReviewSuggestedRef = useRef14(/* @__PURE__ */ new Map());
29443
29769
  const pendingGRef = useRef14(false);
29444
- useEffect17(() => {
29770
+ useEffect20(() => {
29445
29771
  setTokenReviewRow(0);
29446
29772
  setTokenReviewEditing(false);
29447
29773
  setTokenReviewEditCursor(0);
@@ -29923,7 +30249,7 @@ var init_preview_annotations = __esm({
29923
30249
  });
29924
30250
 
29925
30251
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
29926
- import { useCallback as useCallback3, useEffect as useEffect18, useRef as useRef15, useState as useState24 } from "react";
30252
+ import { useCallback as useCallback3, useEffect as useEffect21, useRef as useRef15, useState as useState24 } from "react";
29927
30253
  function useLivePreview(opts) {
29928
30254
  const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
29929
30255
  const [status, setStatus] = useState24("idle");
@@ -29933,14 +30259,14 @@ function useLivePreview(opts) {
29933
30259
  const latestRef = useRef15(0);
29934
30260
  const inflightRef = useRef15(0);
29935
30261
  const optsRef = useRef15(opts);
29936
- useEffect18(() => {
30262
+ useEffect21(() => {
29937
30263
  optsRef.current = opts;
29938
30264
  });
29939
30265
  const disabledRef = useRef15(disabled);
29940
- useEffect18(() => {
30266
+ useEffect21(() => {
29941
30267
  disabledRef.current = disabled;
29942
30268
  }, [disabled]);
29943
- useEffect18(() => {
30269
+ useEffect21(() => {
29944
30270
  return () => {
29945
30271
  if (timerRef.current) {
29946
30272
  clearTimeout(timerRef.current);
@@ -30021,7 +30347,7 @@ var init_use_live_preview = __esm({
30021
30347
  });
30022
30348
 
30023
30349
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
30024
- import { useCallback as useCallback4, useEffect as useEffect19, useState as useState25 } from "react";
30350
+ import { useCallback as useCallback4, useEffect as useEffect22, useState as useState25 } from "react";
30025
30351
  function useReviewPreview({
30026
30352
  components,
30027
30353
  loading,
@@ -30063,13 +30389,13 @@ function useReviewPreview({
30063
30389
  deleteAllComponents
30064
30390
  });
30065
30391
  const [spinnerTick, setSpinnerTick] = useState25(0);
30066
- useEffect19(() => {
30392
+ useEffect22(() => {
30067
30393
  if (livePreviewHook.status !== "running") return;
30068
30394
  const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
30069
30395
  return () => clearInterval(id);
30070
30396
  }, [livePreviewHook.status]);
30071
30397
  const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
30072
- useEffect19(() => {
30398
+ useEffect22(() => {
30073
30399
  if (loading) return;
30074
30400
  if (!livePreview) return;
30075
30401
  if (components.length === 0) return;
@@ -30126,7 +30452,7 @@ var init_LivePreviewSummary = __esm({
30126
30452
  });
30127
30453
 
30128
30454
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
30129
- import { useCallback as useCallback5, useEffect as useEffect20, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
30455
+ import { useCallback as useCallback5, useEffect as useEffect23, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
30130
30456
  import figures8 from "figures";
30131
30457
  import { Box as Box38, Text as Text40 } from "ink";
30132
30458
  import { Fragment as Fragment14, jsx as jsx48, jsxs as jsxs38 } from "react/jsx-runtime";
@@ -30447,7 +30773,7 @@ function GenerateReviewStepView({
30447
30773
  [components]
30448
30774
  );
30449
30775
  const closures = useMemo6(() => computeAllClosures(componentGraph), [componentGraph]);
30450
- useEffect20(() => {
30776
+ useEffect23(() => {
30451
30777
  if (seededGroupsRef.current) return;
30452
30778
  if (closures.size === 0 && slotCycles.length === 0) return;
30453
30779
  seededGroupsRef.current = true;
@@ -30474,7 +30800,7 @@ function GenerateReviewStepView({
30474
30800
  suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
30475
30801
  }));
30476
30802
  }, [slotCycles, cycleView]);
30477
- useEffect20(() => {
30803
+ useEffect23(() => {
30478
30804
  const decision = computeAutoRejectDecision({
30479
30805
  loading,
30480
30806
  autoRejectFired: autoRejectFiredRef.current,
@@ -30518,7 +30844,7 @@ function GenerateReviewStepView({
30518
30844
  applySnapshot: applyHistorySnapshot
30519
30845
  });
30520
30846
  const autoRejectPushedRef = useRef16(false);
30521
- useEffect20(() => {
30847
+ useEffect23(() => {
30522
30848
  if (loading) return;
30523
30849
  if (!historySeededRef.current) return;
30524
30850
  if (!autoRejectFiredRef.current) return;
@@ -30602,7 +30928,7 @@ function GenerateReviewStepView({
30602
30928
  const panelHeight = leftPanelHeight + 2;
30603
30929
  const panelContentHeight = Math.max(1, panelHeight - 3);
30604
30930
  const cycleViewportHeight = Math.max(1, panelHeight - 4);
30605
- useEffect20(() => {
30931
+ useEffect23(() => {
30606
30932
  if (selectableRowPositions.length === 0) return;
30607
30933
  const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
30608
30934
  const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
@@ -31684,10 +32010,10 @@ var init_path_utils = __esm({
31684
32010
  });
31685
32011
 
31686
32012
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
31687
- import { useEffect as useEffect21, useState as useState27 } from "react";
32013
+ import { useEffect as useEffect24, useState as useState27 } from "react";
31688
32014
  function useBlinkingCursor() {
31689
32015
  const [visible, setVisible] = useState27(true);
31690
- useEffect21(() => {
32016
+ useEffect24(() => {
31691
32017
  const interval = setInterval(() => setVisible((current) => !current), 500);
31692
32018
  return () => clearInterval(interval);
31693
32019
  }, []);
@@ -31824,12 +32150,12 @@ var init_produced = __esm({
31824
32150
  });
31825
32151
 
31826
32152
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
31827
- import { useEffect as useEffect22, useState as useState29 } from "react";
32153
+ import { useEffect as useEffect25, useState as useState29 } from "react";
31828
32154
  import { Spinner as Spinner2 } from "@inkjs/ui";
31829
32155
  import { jsx as jsx53 } from "react/jsx-runtime";
31830
32156
  function useTimedSpinner() {
31831
32157
  const [elapsedSeconds, setElapsedSeconds] = useState29(0);
31832
- useEffect22(() => {
32158
+ useEffect25(() => {
31833
32159
  const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
31834
32160
  return () => {
31835
32161
  clearInterval(timer);
@@ -32098,7 +32424,7 @@ var init_preview_confirmation_input = __esm({
32098
32424
  });
32099
32425
 
32100
32426
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
32101
- import { useEffect as useEffect23, useState as useState30, useMemo as useMemo7 } from "react";
32427
+ import { useEffect as useEffect26, useState as useState30, useMemo as useMemo7 } from "react";
32102
32428
  import { Box as Box44, Text as Text46 } from "ink";
32103
32429
  import { Fragment as Fragment16, jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
32104
32430
  function buildPreviewSummaryLines(preview) {
@@ -32308,7 +32634,7 @@ function WizardPreviewStep({
32308
32634
  const activeLines = diffExpanded ? diffLines : summaryLines;
32309
32635
  const maxScroll = Math.max(0, activeLines.length - viewportHeight);
32310
32636
  const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
32311
- useEffect23(() => {
32637
+ useEffect26(() => {
32312
32638
  setScrollOffset((previous) => Math.min(previous, maxScroll));
32313
32639
  }, [maxScroll]);
32314
32640
  useImmediateInput((input, key) => {
@@ -32418,6 +32744,154 @@ var init_run_teaser = __esm({
32418
32744
  }
32419
32745
  });
32420
32746
 
32747
+ // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts
32748
+ function flowStepRun(step) {
32749
+ const { number, label } = STEPS2[step];
32750
+ return { flow: `import/${step}`, step: `${number}-${step}`, menuOption: label };
32751
+ }
32752
+ function pushSummary(result, state2) {
32753
+ const failures = result.failures ?? [];
32754
+ return {
32755
+ component_types: result.componentTypes,
32756
+ design_tokens: result.designTokens,
32757
+ ...result.summary ? { summary: result.summary } : {},
32758
+ ...failures.length > 0 ? {
32759
+ failure_count: failures.length,
32760
+ failures: failures.slice(0, MAX_LOGGED).map((failure) => ({
32761
+ entity_type: failure.entityType,
32762
+ entity_id: failure.entityId,
32763
+ message: scrub(failure.message, state2)
32764
+ }))
32765
+ } : {}
32766
+ };
32767
+ }
32768
+ function flowStepInputs(state2) {
32769
+ const inputs = {
32770
+ agent: state2.agent,
32771
+ space_id: state2.spaceId,
32772
+ environment_id: state2.environmentId,
32773
+ host: state2.host,
32774
+ credentials_skipped: state2.credentialsSkipped,
32775
+ components_generated: state2.generatedCount,
32776
+ components_accepted: state2.generatedAcceptedCount,
32777
+ tokens: state2.tokenCount,
32778
+ cma_token: state2.cmaToken
32779
+ };
32780
+ switch (state2.step) {
32781
+ case "final-review":
32782
+ if (state2.finalizeErrorBanner) inputs["finalize_error"] = scrub(state2.finalizeErrorBanner, state2);
32783
+ break;
32784
+ case "path-prompt":
32785
+ inputs["default_path"] = state2.outDir;
32786
+ break;
32787
+ case "error":
32788
+ inputs["error_step"] = state2.errorStep;
32789
+ inputs["error"] = scrub(state2.errorMessage, state2);
32790
+ inputs["can_retry_credentials"] = state2.errorAllowCredentialRetry;
32791
+ inputs["can_acknowledge_breaking_changes"] = state2.errorAllowBreakingChangeAcknowledgment;
32792
+ break;
32793
+ case "preview-validation-error":
32794
+ inputs["validation_error_count"] = state2.previewValidationErrors.length;
32795
+ inputs["validation_errors"] = state2.previewValidationErrors.slice(0, MAX_LOGGED).map((error) => ({
32796
+ component: error.componentName,
32797
+ path: error.path,
32798
+ message: scrub(error.message, state2)
32799
+ }));
32800
+ inputs["missing_names"] = state2.previewValidationMissingNames.slice(0, MAX_LOGGED * 2);
32801
+ break;
32802
+ case "done":
32803
+ Object.assign(inputs, { push_result: pushSummary(state2.pushResult, state2) });
32804
+ break;
32805
+ default:
32806
+ break;
32807
+ }
32808
+ return inputs;
32809
+ }
32810
+ function flowStepOutputs(from, to) {
32811
+ const outputs = { next_step: to?.step ?? "exited" };
32812
+ let failed = from.step === "error" || from.step === "preview-validation-error";
32813
+ if (to?.step === "error") {
32814
+ failed = true;
32815
+ outputs["error_step"] = to.errorStep;
32816
+ outputs["error"] = scrub(to.errorMessage, to);
32817
+ }
32818
+ if (from.step === "final-review" && to?.finalizeErrorBanner) {
32819
+ outputs["finalize_error"] = scrub(to.finalizeErrorBanner, to);
32820
+ }
32821
+ if (from.step === "pushing" && to) {
32822
+ outputs["push_result"] = pushSummary(to.pushResult, to);
32823
+ if (to.pushResult.componentTypes.failed + to.pushResult.designTokens.failed > 0) failed = true;
32824
+ }
32825
+ if (from.step === "path-prompt" && to?.componentsPath) outputs["saved_to"] = to.componentsPath;
32826
+ if (from.step === "printing" && to) {
32827
+ outputs["saved_to"] = to.componentsPath;
32828
+ outputs["run_id"] = to.lastRunId;
32829
+ }
32830
+ const forward = to ? FORWARD.indexOf(to.step) > FORWARD.indexOf(from.step) && FORWARD.includes(from.step) : false;
32831
+ const finished = to === void 0 && (from.step === "done" || from.step === "print-gate");
32832
+ return { outputs, status: failed ? "error" : "success", exitMethod: forward || finished ? "saved" : "discarded" };
32833
+ }
32834
+ var STEPS2, FORWARD, MAX_LOGGED, scrub;
32835
+ var init_flow_log = __esm({
32836
+ "packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts"() {
32837
+ "use strict";
32838
+ init_debug_trail();
32839
+ STEPS2 = {
32840
+ "final-review": { number: "09", label: "Final review" },
32841
+ previewing: { number: "10", label: "Previewing" },
32842
+ "preview-gate": { number: "10", label: "Preview gate" },
32843
+ pushing: { number: "10", label: "Pushing" },
32844
+ "path-prompt": { number: "10", label: "Save path" },
32845
+ printing: { number: "10", label: "Writing files" },
32846
+ "print-gate": { number: "10", label: "Files saved" },
32847
+ done: { number: "10", label: "Done" },
32848
+ error: { number: "10", label: "Error" },
32849
+ "preview-validation-error": { number: "10", label: "Preview validation error" }
32850
+ };
32851
+ FORWARD = [
32852
+ "final-review",
32853
+ "previewing",
32854
+ "preview-gate",
32855
+ "pushing",
32856
+ "path-prompt",
32857
+ "printing",
32858
+ "print-gate",
32859
+ "done"
32860
+ ];
32861
+ MAX_LOGGED = 10;
32862
+ scrub = (text, state2) => scrubError(text, [state2.cmaToken]);
32863
+ }
32864
+ });
32865
+
32866
+ // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
32867
+ import { useEffect as useEffect27, useRef as useRef17 } from "react";
32868
+ function end(from, to) {
32869
+ void finishDebugRun(flowStepOutputs(from, to));
32870
+ }
32871
+ function useFlowLog(state2) {
32872
+ const open = useRef17(void 0);
32873
+ useEffect27(() => {
32874
+ if (open.current?.step === state2.step) return;
32875
+ if (open.current) end(open.current, state2);
32876
+ startDebugRun({ ...flowStepRun(state2.step), inputs: flowStepInputs(state2) });
32877
+ open.current = state2;
32878
+ }, [state2]);
32879
+ useEffect27(
32880
+ () => () => {
32881
+ if (open.current) end(open.current, void 0);
32882
+ open.current = void 0;
32883
+ },
32884
+ []
32885
+ );
32886
+ }
32887
+ var init_use_flow_log = __esm({
32888
+ "packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts"() {
32889
+ "use strict";
32890
+ init_debug_store();
32891
+ init_flow_log();
32892
+ }
32893
+ });
32894
+
32421
32895
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
32422
32896
  import { Box as Box45 } from "ink";
32423
32897
  import { jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
@@ -32432,6 +32906,7 @@ function FlowScreen({
32432
32906
  generatePromptPath,
32433
32907
  onExit
32434
32908
  }) {
32909
+ useFlowLog(state2);
32435
32910
  const produced = producedOf(state2);
32436
32911
  const counts = { components: state2.generatedAcceptedCount, tokens: state2.tokenCount };
32437
32912
  const things = countedThings(produced, counts);
@@ -32559,6 +33034,7 @@ var init_screen11 = __esm({
32559
33034
  init_WizardPreviewStep();
32560
33035
  init_produced();
32561
33036
  init_run_teaser();
33037
+ init_use_flow_log();
32562
33038
  }
32563
33039
  });
32564
33040
 
@@ -33356,9 +33832,9 @@ var init_controller = __esm({
33356
33832
  });
33357
33833
 
33358
33834
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
33359
- import { useEffect as useEffect24, useRef as useRef17, useSyncExternalStore } from "react";
33835
+ import { useEffect as useEffect28, useRef as useRef18, useSyncExternalStore } from "react";
33360
33836
  function useFlow(start, options = {}) {
33361
- const controller = useRef17();
33837
+ const controller = useRef18();
33362
33838
  if (start && !controller.current) {
33363
33839
  try {
33364
33840
  startWizardLog();
@@ -33375,7 +33851,7 @@ function useFlow(start, options = {}) {
33375
33851
  (listener) => current?.subscribe(listener) ?? (() => void 0),
33376
33852
  () => current?.getState()
33377
33853
  );
33378
- useEffect24(() => {
33854
+ useEffect28(() => {
33379
33855
  if (!start) controller.current = void 0;
33380
33856
  }, [start]);
33381
33857
  return current && state2 ? { controller: current, state: state2 } : void 0;
@@ -33454,7 +33930,7 @@ var init_help_info = __esm({
33454
33930
  });
33455
33931
 
33456
33932
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
33457
- import { useEffect as useEffect25, useState as useState31 } from "react";
33933
+ import { useEffect as useEffect29, useState as useState31 } from "react";
33458
33934
  import { Box as Box46, Text as Text47, useInput as useInput13 } from "ink";
33459
33935
  import { Fragment as Fragment17, jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
33460
33936
  function Section({ title, rows }) {
@@ -33468,7 +33944,7 @@ function Section({ title, rows }) {
33468
33944
  }
33469
33945
  function HelpScreen({ onDone }) {
33470
33946
  const [info, setInfo] = useState31();
33471
- useEffect25(() => {
33947
+ useEffect29(() => {
33472
33948
  startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
33473
33949
  void readHelpInfo().then(setInfo);
33474
33950
  }, []);
@@ -33576,45 +34052,6 @@ var init_PageContainer3 = __esm({
33576
34052
  }
33577
34053
  });
33578
34054
 
33579
- // packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
33580
- import { existsSync as existsSync11 } from "node:fs";
33581
- function diffSnapshots(before, after) {
33582
- const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
33583
- const changed_fields = names.filter((name) => before[name] !== after[name]);
33584
- return { changed: changed_fields.length > 0, changed_fields };
33585
- }
33586
- function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
33587
- const actions = [];
33588
- return {
33589
- record(action) {
33590
- actions.push(action);
33591
- if (actions.length > limit) actions.shift();
33592
- },
33593
- entries: () => [...actions]
33594
- };
33595
- }
33596
- function scrubError(error, secrets) {
33597
- let message = error instanceof Error ? error.message : String(error);
33598
- for (const secret of secrets) {
33599
- if (secret.length < MIN_SECRET_LENGTH) continue;
33600
- for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
33601
- }
33602
- return message;
33603
- }
33604
- function describeSettingsFile() {
33605
- const path5 = configFilePath2();
33606
- return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync11(path5) };
33607
- }
33608
- var DEFAULT_TRAIL_LIMIT, MIN_SECRET_LENGTH;
33609
- var init_debug_trail = __esm({
33610
- "packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts"() {
33611
- "use strict";
33612
- init_config();
33613
- DEFAULT_TRAIL_LIMIT = 30;
33614
- MIN_SECRET_LENGTH = 6;
33615
- }
33616
- });
33617
-
33618
34055
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
33619
34056
  import { execFile as execFile2 } from "node:child_process";
33620
34057
  import { access as access5, constants } from "node:fs/promises";
@@ -33889,7 +34326,7 @@ var init_AgentStatusBadge = __esm({
33889
34326
  });
33890
34327
 
33891
34328
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
33892
- import { useEffect as useEffect26, useState as useState33 } from "react";
34329
+ import { useEffect as useEffect30, useState as useState33 } from "react";
33893
34330
  import { Box as Box48, Text as Text50 } from "ink";
33894
34331
  import { jsx as jsx60, jsxs as jsxs48 } from "react/jsx-runtime";
33895
34332
  function StatusHeading() {
@@ -33910,7 +34347,7 @@ function AgentDetail({
33910
34347
  const [testing, setTesting] = useState33(false);
33911
34348
  const [notice, setNotice] = useState33(null);
33912
34349
  const [checks, setChecks] = useState33(void 0);
33913
- useEffect26(() => {
34350
+ useEffect30(() => {
33914
34351
  let active = true;
33915
34352
  setChecks(void 0);
33916
34353
  const timer = setTimeout(() => {
@@ -34002,7 +34439,7 @@ var init_AgentDetail = __esm({
34002
34439
  });
34003
34440
 
34004
34441
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
34005
- import { useEffect as useEffect27, useRef as useRef18, useState as useState34 } from "react";
34442
+ import { useEffect as useEffect31, useRef as useRef19, useState as useState34 } from "react";
34006
34443
  import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
34007
34444
  import { Fragment as Fragment18, jsx as jsx61, jsxs as jsxs49 } from "react/jsx-runtime";
34008
34445
  function AgentsScreen({ onDone }) {
@@ -34013,7 +34450,7 @@ function AgentsScreen({ onDone }) {
34013
34450
  const [saving, setSaving] = useState34(false);
34014
34451
  const [loadError, setLoadError] = useState34(null);
34015
34452
  const [checks, setChecks] = useState34({});
34016
- const visit = useRef18({
34453
+ const visit = useRef19({
34017
34454
  trail: createTrail(),
34018
34455
  before: void 0,
34019
34456
  environment: void 0,
@@ -34026,7 +34463,7 @@ function AgentsScreen({ onDone }) {
34026
34463
  );
34027
34464
  }
34028
34465
  };
34029
- useEffect27(() => {
34466
+ useEffect31(() => {
34030
34467
  readAgentConfig().then((loaded) => {
34031
34468
  setConfig(loaded);
34032
34469
  inspectAll(loaded);
@@ -34252,7 +34689,7 @@ var init_project_store = __esm({
34252
34689
  });
34253
34690
 
34254
34691
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
34255
- import { useEffect as useEffect28, useRef as useRef19, useState as useState35 } from "react";
34692
+ import { useEffect as useEffect32, useRef as useRef20, useState as useState35 } from "react";
34256
34693
  import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
34257
34694
  import { Fragment as Fragment19, jsx as jsx62, jsxs as jsxs50 } from "react/jsx-runtime";
34258
34695
  function debugFields(config) {
@@ -34271,14 +34708,14 @@ function ProjectScreen({ onDone }) {
34271
34708
  const [saving, setSaving] = useState35(false);
34272
34709
  const [notice, setNotice] = useState35(null);
34273
34710
  const [loadError, setLoadError] = useState35(null);
34274
- const visit = useRef19({
34711
+ const visit = useRef20({
34275
34712
  trail: createTrail(),
34276
34713
  before: void 0,
34277
34714
  persisted: void 0,
34278
34715
  error: ""
34279
34716
  }).current;
34280
- const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
34281
- useEffect28(() => {
34717
+ const scrub2 = (err) => scrubError(err, [config?.cmaToken ?? ""]);
34718
+ useEffect32(() => {
34282
34719
  readCredentials().then((cfg) => {
34283
34720
  setConfig(cfg);
34284
34721
  visit.before = snapshotOf(cfg);
@@ -34345,7 +34782,7 @@ function ProjectScreen({ onDone }) {
34345
34782
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
34346
34783
  setNotice({ kind: "success", text: "Project settings saved" });
34347
34784
  }).catch((err) => {
34348
- visit.error = scrub(err);
34785
+ visit.error = scrub2(err);
34349
34786
  visit.trail.record("save failed");
34350
34787
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
34351
34788
  }).finally(() => setSaving(false));
@@ -34465,13 +34902,13 @@ var init_ConfigurationScreen = __esm({
34465
34902
  });
34466
34903
 
34467
34904
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
34468
- import { useEffect as useEffect29, useState as useState37 } from "react";
34905
+ import { useEffect as useEffect33, useState as useState37 } from "react";
34469
34906
  import { Box as Box52, Text as Text54, useInput as useInput18 } from "ink";
34470
34907
  import { Fragment as Fragment20, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-runtime";
34471
34908
  function OptInAnalyticsScreen({ onDone }) {
34472
34909
  const [loading, setLoading] = useState37(true);
34473
34910
  const [enabled, setEnabled] = useState37(true);
34474
- useEffect29(() => {
34911
+ useEffect33(() => {
34475
34912
  readAnalyticsSetting().then((setting) => {
34476
34913
  setEnabled(setting.enabled);
34477
34914
  setLoading(false);
@@ -34534,7 +34971,7 @@ var init_screen12 = __esm({
34534
34971
  });
34535
34972
 
34536
34973
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
34537
- import { useEffect as useEffect30, useRef as useRef20, useState as useState38 } from "react";
34974
+ import { useEffect as useEffect34, useRef as useRef21, useState as useState38 } from "react";
34538
34975
  import { Box as Box53, Text as Text55, useInput as useInput19 } from "ink";
34539
34976
  import { Fragment as Fragment21, jsx as jsx65, jsxs as jsxs53 } from "react/jsx-runtime";
34540
34977
  function DebugModeScreen({ onDone }) {
@@ -34544,8 +34981,8 @@ function DebugModeScreen({ onDone }) {
34544
34981
  RETENTION_CHOICES[RETENTION_CHOICES.length - 1]
34545
34982
  );
34546
34983
  const [notice, setNotice] = useState38(null);
34547
- const visit = useRef20({ trail: createTrail(), before: void 0, error: "" }).current;
34548
- useEffect30(() => {
34984
+ const visit = useRef21({ trail: createTrail(), before: void 0, error: "" }).current;
34985
+ useEffect34(() => {
34549
34986
  readDebugModeSetting().then((loaded) => {
34550
34987
  setSetting(loaded);
34551
34988
  setPending(loaded.retentionDays);
@@ -34686,7 +35123,7 @@ var app_exports = {};
34686
35123
  __export(app_exports, {
34687
35124
  runApp: () => runApp
34688
35125
  });
34689
- import { useEffect as useEffect31, useState as useState39 } from "react";
35126
+ import { useEffect as useEffect35, useState as useState39 } from "react";
34690
35127
  import { Fragment as Fragment22, jsx as jsx66 } from "react/jsx-runtime";
34691
35128
  function App({ importOptions, inkClear }) {
34692
35129
  const [screen, setScreen] = useState39("start");
@@ -34720,7 +35157,7 @@ function App({ importOptions, inkClear }) {
34720
35157
  const [flowStart, setFlowStart] = useState39();
34721
35158
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
34722
35159
  const [importDefaults, setImportDefaults] = useState39();
34723
- useEffect31(() => {
35160
+ useEffect35(() => {
34724
35161
  if (screen !== "import") {
34725
35162
  setImportDefaults(void 0);
34726
35163
  return;
@@ -34793,7 +35230,7 @@ function App({ importOptions, inkClear }) {
34793
35230
  }
34794
35231
  });
34795
35232
  };
34796
- useEffect31(() => {
35233
+ useEffect35(() => {
34797
35234
  if (!tokensOnlyRun || tokensOnly?.status !== "done" || !tokensOnly.result.ok) return;
34798
35235
  const { credentialsSkipped, input, tokens } = tokensOnlyRun;
34799
35236
  const { tokensPath, tokenSessionId, tokenCount } = tokensOnly.result;
@@ -34815,12 +35252,12 @@ function App({ importOptions, inkClear }) {
34815
35252
  }
34816
35253
  });
34817
35254
  }, [tokensOnly, tokensOnlyRun]);
34818
- useEffect31(() => {
35255
+ useEffect35(() => {
34819
35256
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
34820
35257
  setExtractionRun(void 0);
34821
35258
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
34822
35259
  }, [extraction, extractionRun]);
34823
- useEffect31(() => {
35260
+ useEffect35(() => {
34824
35261
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
34825
35262
  const { extraction: produced, input, generatePromptPath } = scopeRun;
34826
35263
  setGenerationInput({
@@ -34838,7 +35275,7 @@ function App({ importOptions, inkClear }) {
34838
35275
  ...generatePromptPath ? { generatePromptPath } : {}
34839
35276
  });
34840
35277
  }, [scopeFlow, scopeRun, generationInput]);
34841
- useEffect31(() => {
35278
+ useEffect35(() => {
34842
35279
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
34843
35280
  const { credentialsSkipped, extraction: produced, input, generatePromptPath } = scopeRun;
34844
35281
  inkClear();
@@ -35007,6 +35444,7 @@ function App({ importOptions, inkClear }) {
35007
35444
  return /* @__PURE__ */ jsx66(
35008
35445
  CredentialsScreen,
35009
35446
  {
35447
+ mode: target,
35010
35448
  initial: importDefaults.credentials,
35011
35449
  tokensOnly: target === "tokens",
35012
35450
  onBack: () => goBackFrom("credentials"),