@contentful/experience-design-system-cli 2.41.1-dev-build-c9e39919.0 → 2.41.1-dev-build-36ec74af.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
@@ -15180,8 +15180,8 @@ function retryAfterMs(response) {
15180
15180
  const value = response.headers?.get("retry-after")?.trim();
15181
15181
  if (!value)
15182
15182
  return void 0;
15183
- const seconds2 = Number(value);
15184
- const delayMs = Number.isFinite(seconds2) ? seconds2 * 1e3 : Date.parse(value) - Date.now();
15183
+ const seconds = Number(value);
15184
+ const delayMs = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(value) - Date.now();
15185
15185
  if (!Number.isFinite(delayMs) || delayMs < 0 || delayMs > MAX_RETRY_AFTER_MS)
15186
15186
  return void 0;
15187
15187
  return Math.round(delayMs);
@@ -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 capped3 = capCandidatesToPromptBudget(selectedCandidates);
18057
- const promptFiles = capped3.kept;
18056
+ const capped = capCandidatesToPromptBudget(selectedCandidates);
18057
+ const promptFiles = capped.kept;
18058
18058
  const runtimeFiles = allFiles.map((c2) => ({ path: c2.path, content: c2.content }));
18059
- const droppedWarning = capped3.dropped.length > 0 ? `composition \u2014 ${capped3.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 = 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;
18060
18060
  return { promptFiles, runtimeFiles, droppedWarning };
18061
18061
  }
18062
18062
  var init_select_composition_prompt_files = __esm({
@@ -19497,7 +19497,6 @@ __export(debug_store_exports, {
19497
19497
  currentDebugSessionDir: () => currentDebugSessionDir,
19498
19498
  currentSessionDir: () => currentSessionDir,
19499
19499
  finishDebugRun: () => finishDebugRun,
19500
- setDebugRunProgress: () => setDebugRunProgress,
19501
19500
  startDebugRun: () => startDebugRun,
19502
19501
  startDebugSessionIn: () => startDebugSessionIn,
19503
19502
  startImportRun: () => startImportRun
@@ -19593,15 +19592,11 @@ function startDebugRun({
19593
19592
  const runId = generateRunId();
19594
19593
  const startedAt = Date.now();
19595
19594
  const redactedInputs = redact(inputs);
19596
- const run = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
19597
- pendingRun = run;
19598
- void isDebugModeEnabled().then((enabled) => {
19599
- if (!enabled && pendingRun === run) pendingRun = void 0;
19595
+ isDebugModeEnabled().then((enabled) => {
19596
+ if (!enabled) return;
19597
+ pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
19600
19598
  });
19601
19599
  }
19602
- function setDebugRunProgress(outputs) {
19603
- if (pendingRun) pendingRun.progress = outputs;
19604
- }
19605
19600
  async function finishDebugRun({
19606
19601
  outputs,
19607
19602
  status,
@@ -19610,10 +19605,9 @@ async function finishDebugRun({
19610
19605
  const run = pendingRun;
19611
19606
  if (!run) return;
19612
19607
  pendingRun = void 0;
19613
- if (!await isDebugModeEnabled()) return;
19614
19608
  const durationMs = Date.now() - run.startedAt;
19615
19609
  const log = {
19616
- flow: logFolder(run.flow, run.step),
19610
+ flow: run.flow,
19617
19611
  menuOption: run.menuOption,
19618
19612
  content: renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs })
19619
19613
  };
@@ -19624,9 +19618,6 @@ async function finishDebugRun({
19624
19618
  }
19625
19619
  await writeLog(root, log);
19626
19620
  }
19627
- function logFolder(flow, step) {
19628
- return flow.startsWith("import/") && /^\d+-/.test(step) ? `import/${step}` : flow;
19629
- }
19630
19621
  async function writeLog(root, log) {
19631
19622
  const dir = join19(root, ...log.flow.split("/"));
19632
19623
  await mkdir7(dir, { recursive: true });
@@ -19683,7 +19674,7 @@ ${JSON.stringify(finish.outputs, null, 2)}
19683
19674
  `;
19684
19675
  }
19685
19676
  function handleCrash() {
19686
- return finishDebugRun({ outputs: pendingRun?.progress ?? {}, status: "error", exitMethod: "crashed" });
19677
+ return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
19687
19678
  }
19688
19679
  var pendingRun, sessionDir, WAITING_LIMIT, waiting;
19689
19680
  var init_debug_store = __esm({
@@ -19727,17 +19718,11 @@ var init_debug_store = __esm({
19727
19718
  throw reason;
19728
19719
  });
19729
19720
  });
19730
- for (const [signal, exitCode] of [
19731
- ["SIGINT", 130],
19732
- ["SIGTERM", 143],
19733
- ["SIGHUP", 129]
19734
- ]) {
19735
- process.once(signal, () => {
19736
- void handleCrash().finally(() => {
19737
- process.exit(exitCode);
19738
- });
19721
+ process.once("SIGINT", () => {
19722
+ void handleCrash().finally(() => {
19723
+ process.exit(130);
19739
19724
  });
19740
- }
19725
+ });
19741
19726
  }
19742
19727
  });
19743
19728
 
@@ -20141,8 +20126,8 @@ function progressPercent(progress) {
20141
20126
  }
20142
20127
  function formatElapsed(totalSeconds) {
20143
20128
  const minutes = Math.floor(totalSeconds / 60);
20144
- const seconds2 = totalSeconds % 60;
20145
- return minutes > 0 ? `${minutes}m ${seconds2}s` : `${seconds2}s`;
20129
+ const seconds = totalSeconds % 60;
20130
+ return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
20146
20131
  }
20147
20132
  var init_logic4 = __esm({
20148
20133
  "packages/experience-design-system-cli/src/tui/import/shared/running-step/logic.ts"() {
@@ -20172,12 +20157,12 @@ var init_theme2 = __esm({
20172
20157
  // packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts
20173
20158
  import { useEffect as useEffect3, useState as useState3 } from "react";
20174
20159
  function useElapsed() {
20175
- const [seconds2, setSeconds] = useState3(0);
20160
+ const [seconds, setSeconds] = useState3(0);
20176
20161
  useEffect3(() => {
20177
20162
  const timer = setInterval(() => setSeconds((current) => current + 1), 1e3);
20178
20163
  return () => clearInterval(timer);
20179
20164
  }, []);
20180
- return formatElapsed(seconds2);
20165
+ return formatElapsed(seconds);
20181
20166
  }
20182
20167
  var init_use_elapsed = __esm({
20183
20168
  "packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts"() {
@@ -21092,45 +21077,6 @@ var init_FieldForm = __esm({
21092
21077
  }
21093
21078
  });
21094
21079
 
21095
- // packages/experience-design-system-cli/src/tui/shared/debug-trail.ts
21096
- import { existsSync as existsSync10 } from "node:fs";
21097
- function diffSnapshots(before, after) {
21098
- const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
21099
- const changed_fields = names.filter((name) => before[name] !== after[name]);
21100
- return { changed: changed_fields.length > 0, changed_fields };
21101
- }
21102
- function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
21103
- const actions = [];
21104
- return {
21105
- record(action) {
21106
- actions.push(action);
21107
- if (actions.length > limit) actions.shift();
21108
- },
21109
- entries: () => [...actions]
21110
- };
21111
- }
21112
- function scrubError(error, secrets) {
21113
- let message = error instanceof Error ? error.message : String(error);
21114
- for (const secret of secrets) {
21115
- if (secret.length < MIN_SECRET_LENGTH) continue;
21116
- for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
21117
- }
21118
- return message;
21119
- }
21120
- function describeSettingsFile() {
21121
- const path5 = configFilePath2();
21122
- return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
21123
- }
21124
- var DEFAULT_TRAIL_LIMIT, MIN_SECRET_LENGTH;
21125
- var init_debug_trail = __esm({
21126
- "packages/experience-design-system-cli/src/tui/shared/debug-trail.ts"() {
21127
- "use strict";
21128
- init_config();
21129
- DEFAULT_TRAIL_LIMIT = 30;
21130
- MIN_SECRET_LENGTH = 6;
21131
- }
21132
- });
21133
-
21134
21080
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
21135
21081
  function credentialsPurpose(tokensOnly) {
21136
21082
  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";
@@ -21144,42 +21090,17 @@ function normalize(values) {
21144
21090
  host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
21145
21091
  };
21146
21092
  }
21147
- function missingFields(values) {
21148
- return ["spaceId", "environmentId", "cmaToken"].filter((field) => values[field] === "");
21093
+ function missingField(values) {
21094
+ return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
21149
21095
  }
21150
21096
  function isUnchanged(current, initial) {
21151
21097
  return FIELDS.every((field) => current[field] === initial[field]);
21152
21098
  }
21153
- function rejectedAttempt(reason, credentials) {
21154
- return { host: credentials.host, reason: scrubError(reason, [credentials.cmaToken]) };
21155
- }
21156
- function credentialsLog(credentials) {
21157
- return {
21158
- space_id: credentials.spaceId,
21159
- environment_id: credentials.environmentId,
21160
- host: credentials.host,
21161
- cma_token: credentials.cmaToken
21162
- };
21163
- }
21164
- function credentialsOutputs({
21165
- outcome,
21166
- credentials,
21167
- initial,
21168
- attempts
21169
- }) {
21170
- return {
21171
- outcome,
21172
- ...credentialsLog(credentials),
21173
- changed_fields: diffSnapshots(initial, credentials).changed_fields,
21174
- rejected_attempts: attempts
21175
- };
21176
- }
21177
21099
  var FIELDS;
21178
21100
  var init_logic8 = __esm({
21179
21101
  "packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts"() {
21180
21102
  "use strict";
21181
21103
  init_src3();
21182
- init_debug_trail();
21183
21104
  FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
21184
21105
  }
21185
21106
  });
@@ -21232,11 +21153,10 @@ var init_validate4 = __esm({
21232
21153
  });
21233
21154
 
21234
21155
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
21235
- import { useEffect as useEffect8, useRef as useRef5, useState as useState9 } from "react";
21156
+ import { useRef as useRef5, useState as useState9 } from "react";
21236
21157
  import { Box as Box14, Text as Text14, useInput as useInput11 } from "ink";
21237
21158
  import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
21238
21159
  function CredentialsScreen({
21239
- mode,
21240
21160
  onDone,
21241
21161
  onBack,
21242
21162
  initial = {},
@@ -21259,64 +21179,17 @@ function CredentialsScreen({
21259
21179
  const [focus, setFocus] = useState9(0);
21260
21180
  const [active, setActive] = useState9(0);
21261
21181
  const [beforeEdit, setBeforeEdit] = useState9(initialValues);
21262
- const visit = useRef5({ attempts: [], lastReason: "" }).current;
21263
- useEffect8(() => {
21264
- startDebugRun({
21265
- flow: "import/credentials",
21266
- step: "04-credentials",
21267
- menuOption: "Credentials",
21268
- inputs: { import_mode: mode, prefilled, ...credentialsLog(initialValues) }
21269
- });
21270
- }, []);
21271
- const reject = (attempt, text) => {
21272
- if (visit.attempts.length < MAX_LOGGED_ATTEMPTS2) visit.attempts.push(attempt);
21273
- visit.lastReason = attempt.reason;
21274
- setNotice({ kind: "error", text });
21275
- };
21276
- const leave = () => {
21277
- void finishDebugRun({
21278
- outputs: {
21279
- ...credentialsOutputs({
21280
- outcome: "back",
21281
- credentials: normalize(values),
21282
- initial: initialValues,
21283
- attempts: visit.attempts
21284
- }),
21285
- ...notice ? { error: visit.lastReason } : {}
21286
- },
21287
- status: notice ? "error" : "success",
21288
- exitMethod: "discarded"
21289
- });
21290
- onBack();
21291
- };
21292
21182
  const submit = async () => {
21293
21183
  const credentials = normalize(values);
21294
- const missing = missingFields(credentials);
21295
- if (missing.length > 0) {
21296
- reject(
21297
- rejectedAttempt(`Missing required fields: ${missing.join(", ")}`, credentials),
21298
- "Space ID, environment and CMA token are all required."
21299
- );
21184
+ if (missingField(credentials)) {
21185
+ setNotice({ kind: "error", text: "Space ID, environment and CMA token are all required." });
21300
21186
  return;
21301
21187
  }
21302
21188
  setValidating(true);
21303
21189
  const result = await validate3(credentials);
21304
21190
  setValidating(false);
21305
- if (!result.ok) {
21306
- reject(rejectedAttempt(result.error, credentials), result.error);
21307
- return;
21308
- }
21309
- void finishDebugRun({
21310
- outputs: credentialsOutputs({
21311
- outcome: "validated",
21312
- credentials,
21313
- initial: initialValues,
21314
- attempts: visit.attempts
21315
- }),
21316
- status: "success",
21317
- exitMethod: "saved"
21318
- });
21319
- onDone({ skipped: false, credentials });
21191
+ if (result.ok) onDone({ skipped: false, credentials });
21192
+ else setNotice({ kind: "error", text: result.error });
21320
21193
  };
21321
21194
  const choose = (choice) => {
21322
21195
  if (choice === "continue") void submit();
@@ -21325,7 +21198,7 @@ function CredentialsScreen({
21325
21198
  setBeforeEdit(values);
21326
21199
  setActive(0);
21327
21200
  setEditing(true);
21328
- } else leave();
21201
+ } else onBack();
21329
21202
  };
21330
21203
  const stopEditing = () => {
21331
21204
  setEditing(false);
@@ -21335,7 +21208,7 @@ function CredentialsScreen({
21335
21208
  if (validating) return;
21336
21209
  if (editing) {
21337
21210
  if (key.escape) {
21338
- if (!prefilled) leave();
21211
+ if (!prefilled) onBack();
21339
21212
  else {
21340
21213
  setValues(beforeEdit);
21341
21214
  setNotice(null);
@@ -21441,12 +21314,11 @@ function CredentialsScreen({
21441
21314
  ] })
21442
21315
  ] });
21443
21316
  }
21444
- var FIELDS2, MENU, MAX_LOGGED_ATTEMPTS2;
21317
+ var FIELDS2, MENU;
21445
21318
  var init_screen5 = __esm({
21446
21319
  "packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx"() {
21447
21320
  "use strict";
21448
21321
  init_theme();
21449
- init_debug_store();
21450
21322
  init_FieldForm();
21451
21323
  init_ClearableTextInput();
21452
21324
  init_ControlHints();
@@ -21463,52 +21335,10 @@ var init_screen5 = __esm({
21463
21335
  { choice: "continue", label: "Continue", description: "Check the credentials and go on" },
21464
21336
  { choice: "edit", label: "Edit", description: "Change the credentials" }
21465
21337
  ];
21466
- MAX_LOGGED_ATTEMPTS2 = 10;
21467
21338
  }
21468
21339
  });
21469
21340
 
21470
21341
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts
21471
- function extractionLogInputs(input) {
21472
- const { credentials } = input;
21473
- return {
21474
- project_path: input.projectPath,
21475
- out_dir: input.outDir ?? "",
21476
- files_to_scan: input.filePaths.length,
21477
- raw_tokens_path: input.rawTokensPath,
21478
- agent: input.agent,
21479
- agent_model: input.agentModel ?? "",
21480
- prompt_overrides: input.promptOverrides,
21481
- cache: !input.noCache,
21482
- has_credentials: credentials !== null,
21483
- space_id: credentials?.spaceId ?? "",
21484
- environment_id: credentials?.environmentId ?? "",
21485
- host: credentials?.host ?? "",
21486
- cma_token: credentials?.cmaToken ?? ""
21487
- };
21488
- }
21489
- function extractionLogOutputs(result, progress, cmaToken) {
21490
- const last = progress ? { final_progress: progress } : {};
21491
- if (!result.ok) {
21492
- return {
21493
- outputs: { result: "failed", failed_step: result.step, error: scrubError(result.message, [cmaToken]), ...last },
21494
- status: "error"
21495
- };
21496
- }
21497
- const { extraction } = result;
21498
- return {
21499
- outputs: {
21500
- result: "done",
21501
- session_id: extraction.sessionId,
21502
- out_dir: extraction.outDir,
21503
- tokens_path: extraction.tokensPath,
21504
- token_count: extraction.tokenCount,
21505
- existing_entities_status: extraction.existingEntitiesStatus,
21506
- composition_phase: extraction.compositionPhase,
21507
- ...last
21508
- },
21509
- status: "success"
21510
- };
21511
- }
21512
21342
  function initialProgress(input) {
21513
21343
  return {
21514
21344
  scan: null,
@@ -21592,7 +21422,6 @@ var init_logic9 = __esm({
21592
21422
  "packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts"() {
21593
21423
  "use strict";
21594
21424
  init_src3();
21595
- init_debug_trail();
21596
21425
  }
21597
21426
  });
21598
21427
 
@@ -21680,7 +21509,7 @@ var init_load = __esm({
21680
21509
  });
21681
21510
 
21682
21511
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx
21683
- import { useEffect as useEffect9, useMemo as useMemo2, useState as useState10 } from "react";
21512
+ import { useMemo as useMemo2, useState as useState10 } from "react";
21684
21513
  import { Box as Box15, Text as Text15, useInput as useInput12 } from "ink";
21685
21514
  import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
21686
21515
  function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
@@ -21688,31 +21517,12 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
21688
21517
  const rows = loaded.ok ? loaded.rows : [];
21689
21518
  const columns = useTerminalWidth();
21690
21519
  const [selected, setSelected] = useState10(0);
21691
- useEffect9(() => {
21692
- startDebugRun({
21693
- flow: "import/token-review",
21694
- step: "05-token-review",
21695
- menuOption: "Token review",
21696
- inputs: { import_mode: "tokens", tokens_path: tokensPath }
21697
- });
21698
- }, []);
21699
- const finish = (outcome) => {
21700
- void finishDebugRun({
21701
- outputs: { outcome, ...loaded.ok ? { tokens: rows.length } : { load_error: loaded.message } },
21702
- status: loaded.ok ? "success" : "error",
21703
- exitMethod: outcome === "continued" ? "saved" : "discarded"
21704
- });
21705
- };
21706
21520
  const move = (to) => setSelected(Math.max(0, Math.min(to, rows.length - 1)));
21707
21521
  const { start, end } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
21708
21522
  useInput12((_input, key) => {
21709
- if (key.return) {
21710
- finish("continued");
21711
- onContinue();
21712
- } else if (key.escape) {
21713
- finish("back");
21714
- onQuit();
21715
- } else if (key.upArrow) move(selected - 1);
21523
+ if (key.return) onContinue();
21524
+ else if (key.escape) onQuit();
21525
+ else if (key.upArrow) move(selected - 1);
21716
21526
  else if (key.downArrow) move(selected + 1);
21717
21527
  else if (key.pageUp) move(selected - VISIBLE_ROWS);
21718
21528
  else if (key.pageDown) move(selected + VISIBLE_ROWS);
@@ -21776,7 +21586,6 @@ var init_screen7 = __esm({
21776
21586
  "packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx"() {
21777
21587
  "use strict";
21778
21588
  init_theme();
21779
- init_debug_store();
21780
21589
  init_ControlHints();
21781
21590
  init_StepHeader();
21782
21591
  init_use_terminal_width();
@@ -21802,7 +21611,7 @@ var init_steps = __esm({
21802
21611
  });
21803
21612
 
21804
21613
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
21805
- import { existsSync as existsSync11 } from "node:fs";
21614
+ import { existsSync as existsSync10 } from "node:fs";
21806
21615
  import { dirname as dirname16, join as join20, resolve as resolve22 } from "node:path";
21807
21616
  import { fileURLToPath as fileURLToPath4 } from "node:url";
21808
21617
  function findSkillPath(fileName) {
@@ -21810,7 +21619,7 @@ function findSkillPath(fileName) {
21810
21619
  let dir = thisDir;
21811
21620
  for (; ; ) {
21812
21621
  const candidate = join20(dir, "skills", fileName);
21813
- if (existsSync11(candidate)) return candidate;
21622
+ if (existsSync10(candidate)) return candidate;
21814
21623
  const parent = resolve22(dir, "..");
21815
21624
  if (parent === dir) {
21816
21625
  throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
@@ -22074,11 +21883,11 @@ var init_run = __esm({
22074
21883
  });
22075
21884
 
22076
21885
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
22077
- import { useEffect as useEffect10, useRef as useRef6, useState as useState11 } from "react";
21886
+ import { useEffect as useEffect8, useRef as useRef6, useState as useState11 } from "react";
22078
21887
  function useExtraction(input) {
22079
21888
  const [state2, setState] = useState11();
22080
21889
  const current = useRef6();
22081
- useEffect10(() => {
21890
+ useEffect8(() => {
22082
21891
  current.current = input;
22083
21892
  if (!input) {
22084
21893
  setState(void 0);
@@ -22091,23 +21900,10 @@ function useExtraction(input) {
22091
21900
  hasRawTokens: input.rawTokensPath !== ""
22092
21901
  })
22093
21902
  });
22094
- let lastProgress;
22095
- startDebugRun({
22096
- flow: "import/extraction",
22097
- step: "06-extraction",
22098
- menuOption: "Extraction",
22099
- inputs: extractionLogInputs(input)
22100
- });
22101
21903
  void runExtraction(input, (progress) => {
22102
- lastProgress = progress;
22103
21904
  if (current.current === input) setState({ status: "running", progress });
22104
21905
  }).then((result) => {
22105
- if (current.current !== input) return;
22106
- void finishDebugRun({
22107
- ...extractionLogOutputs(result, lastProgress, input.credentials?.cmaToken ?? ""),
22108
- exitMethod: result.ok ? "saved" : "discarded"
22109
- });
22110
- setState({ status: "done", result });
21906
+ if (current.current === input) setState({ status: "done", result });
22111
21907
  });
22112
21908
  return () => {
22113
21909
  if (current.current === input) current.current = void 0;
@@ -22118,7 +21914,6 @@ function useExtraction(input) {
22118
21914
  var init_use_extraction = __esm({
22119
21915
  "packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts"() {
22120
21916
  "use strict";
22121
- init_debug_store();
22122
21917
  init_logic9();
22123
21918
  init_run();
22124
21919
  }
@@ -22163,11 +21958,11 @@ var init_run_tokens_only = __esm({
22163
21958
  });
22164
21959
 
22165
21960
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-tokens-only.ts
22166
- import { useEffect as useEffect11, useRef as useRef7, useState as useState12 } from "react";
21961
+ import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
22167
21962
  function useTokensOnly(input) {
22168
21963
  const [state2, setState] = useState12();
22169
21964
  const current = useRef7();
22170
- useEffect11(() => {
21965
+ useEffect9(() => {
22171
21966
  current.current = input;
22172
21967
  if (!input) {
22173
21968
  setState(void 0);
@@ -22190,39 +21985,6 @@ var init_use_tokens_only = __esm({
22190
21985
  }
22191
21986
  });
22192
21987
 
22193
- // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts
22194
- function scopeGateLogInputs(components, tokenCount) {
22195
- const ai = { accepted: 0, rejected: 0, failed: 0, none: 0 };
22196
- for (const component of components) ai[component.aiDecision ?? "none"] += 1;
22197
- return {
22198
- components_found: components.length,
22199
- ai_suggestions: ai,
22200
- needs_review: components.filter((component) => component.needsReview === true).length,
22201
- tokens: tokenCount
22202
- };
22203
- }
22204
- function scopeGateLogOutputs(components, decisions) {
22205
- const suggested = new Map(components.map((component) => [component.name, component.aiDecision]));
22206
- return {
22207
- outcome: "continued",
22208
- accepted: new Set(decisions.accepted).size,
22209
- rejected: new Set(decisions.rejected).size,
22210
- accepted_although_ai_rejected: capped(decisions.accepted.filter((name) => suggested.get(name) === "rejected")),
22211
- not_accepted_although_ai_accepted: capped(decisions.rejected.filter((name) => suggested.get(name) === "accepted"))
22212
- };
22213
- }
22214
- var MAX_NAMES, capped;
22215
- var init_log = __esm({
22216
- "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts"() {
22217
- "use strict";
22218
- MAX_NAMES = 20;
22219
- capped = (names) => {
22220
- const unique = [...new Set(names)];
22221
- return { count: unique.length, names: unique.slice(0, MAX_NAMES) };
22222
- };
22223
- }
22224
- });
22225
-
22226
21988
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/components/windowed-panel.tsx
22227
21989
  import { Box as Box16, Text as Text16 } from "ink";
22228
21990
  import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
@@ -23477,7 +23239,7 @@ var init_useImmediateInput = __esm({
23477
23239
 
23478
23240
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
23479
23241
  import { useStdout as useStdout2 } from "ink";
23480
- import { useEffect as useEffect12, useState as useState13 } from "react";
23242
+ import { useEffect as useEffect10, useState as useState13 } from "react";
23481
23243
  function readTerminalSize(stdout) {
23482
23244
  return {
23483
23245
  columns: stdout?.columns ?? 80,
@@ -23487,7 +23249,7 @@ function readTerminalSize(stdout) {
23487
23249
  function useTerminalSize() {
23488
23250
  const { stdout } = useStdout2();
23489
23251
  const [size, setSize] = useState13(() => readTerminalSize(stdout));
23490
- useEffect12(() => {
23252
+ useEffect10(() => {
23491
23253
  const updateSize = () => setSize(readTerminalSize(stdout));
23492
23254
  stdout?.on("resize", updateSize);
23493
23255
  updateSize();
@@ -24489,7 +24251,7 @@ var init_state = __esm({
24489
24251
  });
24490
24252
 
24491
24253
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
24492
- import { useEffect as useEffect13, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
24254
+ import { useEffect as useEffect11, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
24493
24255
  function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }) {
24494
24256
  const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
24495
24257
  const columnPlan = useMemo3(
@@ -24536,7 +24298,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
24536
24298
  return seed;
24537
24299
  });
24538
24300
  const seededGroupsRef = useRef9(closures.size > 0 || cycleParticipants.size > 0);
24539
- useEffect13(() => {
24301
+ useEffect11(() => {
24540
24302
  if (seededGroupsRef.current) return;
24541
24303
  if (closures.size === 0 && cycleParticipants.size === 0) return;
24542
24304
  seededGroupsRef.current = true;
@@ -24627,7 +24389,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
24627
24389
  entryCount: 0
24628
24390
  });
24629
24391
  const panelLayout = useMemo3(() => computePanelLayout(visibleCount), [visibleCount]);
24630
- useEffect13(() => {
24392
+ useEffect11(() => {
24631
24393
  setNav((prev) => {
24632
24394
  const maxIdx = Math.max(0, visibleRows.length - 1);
24633
24395
  const nextCursor = Math.min(prev.cursor, maxIdx);
@@ -24972,59 +24734,27 @@ var init_use_scope_gate = __esm({
24972
24734
  });
24973
24735
 
24974
24736
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx
24975
- import { useEffect as useEffect14, useMemo as useMemo4 } from "react";
24737
+ import { useMemo as useMemo4 } from "react";
24976
24738
  import { Box as Box25, Text as Text26 } from "ink";
24977
24739
  import { Fragment as Fragment5, jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
24978
24740
  function ScopeGateScreen(props) {
24979
- if (props.components.length === 0) return /* @__PURE__ */ jsx29(NoComponents, {});
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
+ }
24980
24744
  return /* @__PURE__ */ jsx29(ScopeGateView, { ...props });
24981
24745
  }
24982
- function NoComponents() {
24983
- useEffect14(() => {
24984
- startDebugRun({
24985
- flow: "import/scope-gate",
24986
- step: "07-scope-gate",
24987
- menuOption: "Scope gate",
24988
- inputs: scopeGateLogInputs([], 0)
24989
- });
24990
- void finishDebugRun({
24991
- outputs: { outcome: "nothing to decide", error: "No components were found for this session." },
24992
- status: "error",
24993
- exitMethod: "discarded"
24994
- });
24995
- }, []);
24996
- 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." }) });
24997
- }
24998
24746
  function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
24999
24747
  const tokens = useMemo4(() => {
25000
24748
  const loaded = tokensPath ? loadTokenRows(tokensPath) : void 0;
25001
24749
  return loaded?.ok ? loaded.rows : [];
25002
24750
  }, [tokensPath]);
25003
24751
  const longest = useMemo4(() => longestEntries(tokens), [tokens]);
25004
- useEffect14(() => {
25005
- startDebugRun({
25006
- flow: "import/scope-gate",
25007
- step: "07-scope-gate",
25008
- menuOption: "Scope gate",
25009
- inputs: scopeGateLogInputs(components, tokens.length)
25010
- });
25011
- }, []);
25012
24752
  const gate = useScopeGate({
25013
24753
  components,
25014
24754
  tokenCount: tokens.length,
25015
24755
  tokensWidth: longest.path + longest.value + 10,
25016
- onConfirm: (decisions) => {
25017
- void finishDebugRun({
25018
- outputs: scopeGateLogOutputs(components, decisions),
25019
- status: "success",
25020
- exitMethod: "saved"
25021
- });
25022
- onConfirm(decisions);
25023
- },
25024
- onQuit: () => {
25025
- void finishDebugRun({ outputs: { outcome: "quit" }, status: "success", exitMethod: "discarded" });
25026
- onQuit();
25027
- }
24756
+ onConfirm,
24757
+ onQuit
25028
24758
  });
25029
24759
  const { search, graph, columnPlan, panelLayout, counters } = gate;
25030
24760
  if (gate.showHelp) {
@@ -25124,9 +24854,7 @@ var HELP_SECTIONS;
25124
24854
  var init_screen8 = __esm({
25125
24855
  "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx"() {
25126
24856
  "use strict";
25127
- init_debug_store();
25128
24857
  init_StepHeader();
25129
- init_log();
25130
24858
  init_tokens_column();
25131
24859
  init_load();
25132
24860
  init_logic10();
@@ -25234,27 +24962,13 @@ var init_load2 = __esm({
25234
24962
  });
25235
24963
 
25236
24964
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
25237
- import { useEffect as useEffect15, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
24965
+ import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
25238
24966
  function useScopeGateFlow(input, deps = realDeps3) {
25239
24967
  const sessionId = input?.sessionId;
25240
24968
  const loaded = useMemo5(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
25241
24969
  const cacheCheck = useRef10(void 0);
25242
24970
  const [confirmed, setConfirmed] = useState17();
25243
- useEffect15(() => {
25244
- if (!sessionId || !loaded || loaded.ok) return;
25245
- startDebugRun({
25246
- flow: "import/scope-gate",
25247
- step: "07-scope-gate",
25248
- menuOption: "Scope gate",
25249
- inputs: { session_id: sessionId }
25250
- });
25251
- void finishDebugRun({
25252
- outputs: { outcome: "could not load the components", error: loaded.message },
25253
- status: "error",
25254
- exitMethod: "discarded"
25255
- });
25256
- }, [sessionId, loaded]);
25257
- useEffect15(() => {
24971
+ useEffect12(() => {
25258
24972
  if (!input || !loaded?.ok || cacheCheck.current) return;
25259
24973
  cacheCheck.current = deps.checkCache(input.cache);
25260
24974
  }, [input, loaded]);
@@ -25268,7 +24982,6 @@ var realDeps3;
25268
24982
  var init_use_scope_gate_flow = __esm({
25269
24983
  "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts"() {
25270
24984
  "use strict";
25271
- init_debug_store();
25272
24985
  init_cache_check();
25273
24986
  init_load2();
25274
24987
  realDeps3 = { load: loadScopeGate, checkCache: checkGenerationCache };
@@ -25276,41 +24989,6 @@ var init_use_scope_gate_flow = __esm({
25276
24989
  });
25277
24990
 
25278
24991
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/logic.ts
25279
- function generationLogInputs(input) {
25280
- return {
25281
- session_id: input.sessionId,
25282
- accepted: input.decisions.accepted.length,
25283
- rejected: input.decisions.rejected.length,
25284
- tokens_path: input.tokensPath,
25285
- token_session_id: input.tokenSessionId,
25286
- existing_entities_path: input.existingEntitiesPath,
25287
- agent: input.agent,
25288
- agent_model: input.agentModel ?? "",
25289
- prompt_overrides: input.promptOverrides,
25290
- generate_prompt_path: input.generatePromptPath ?? "",
25291
- cache: !input.noCache,
25292
- has_tokens: input.hasTokens
25293
- };
25294
- }
25295
- function generationLogOutputs(result, progress) {
25296
- const last = progress ? { final_progress: progress } : {};
25297
- if (!result.ok) {
25298
- return { outputs: { result: "failed", failed_step: result.step, error: result.message, ...last }, status: "error" };
25299
- }
25300
- const { generation } = result;
25301
- return {
25302
- outputs: generation.route === "review" ? {
25303
- result: "done",
25304
- route: generation.route,
25305
- session_id: generation.sessionId,
25306
- accepted: generation.acceptedCount,
25307
- generated: generation.generatedCount,
25308
- map_tokens_eligible: generation.mapTokensEligible,
25309
- ...last
25310
- } : { result: "done", route: generation.route, accepted: generation.acceptedCount, ...last },
25311
- status: "success"
25312
- };
25313
- }
25314
24992
  function initialProgress2() {
25315
24993
  return { components: null, mapTokens: "idle", mapTokensEligible: null };
25316
24994
  }
@@ -25561,34 +25239,21 @@ var init_run2 = __esm({
25561
25239
  });
25562
25240
 
25563
25241
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
25564
- import { useEffect as useEffect16, useRef as useRef11, useState as useState18 } from "react";
25242
+ import { useEffect as useEffect13, useRef as useRef11, useState as useState18 } from "react";
25565
25243
  function useGeneration(input) {
25566
25244
  const [state2, setState] = useState18();
25567
25245
  const current = useRef11();
25568
- useEffect16(() => {
25246
+ useEffect13(() => {
25569
25247
  current.current = input;
25570
25248
  if (!input) {
25571
25249
  setState(void 0);
25572
25250
  return;
25573
25251
  }
25574
25252
  setState({ status: "running", progress: initialProgress2() });
25575
- let lastProgress;
25576
- startDebugRun({
25577
- flow: "import/generation",
25578
- step: "08-generation",
25579
- menuOption: "Generation",
25580
- inputs: generationLogInputs(input)
25581
- });
25582
25253
  void runGeneration(input, (progress) => {
25583
- lastProgress = progress;
25584
25254
  if (current.current === input) setState({ status: "running", progress });
25585
25255
  }).then((result) => {
25586
- if (current.current !== input) return;
25587
- void finishDebugRun({
25588
- ...generationLogOutputs(result, lastProgress),
25589
- exitMethod: result.ok ? "saved" : "discarded"
25590
- });
25591
- setState({ status: "done", result });
25256
+ if (current.current === input) setState({ status: "done", result });
25592
25257
  });
25593
25258
  return () => {
25594
25259
  if (current.current === input) current.current = void 0;
@@ -25599,7 +25264,6 @@ function useGeneration(input) {
25599
25264
  var init_use_generation = __esm({
25600
25265
  "packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts"() {
25601
25266
  "use strict";
25602
- init_debug_store();
25603
25267
  init_logic11();
25604
25268
  init_run2();
25605
25269
  }
@@ -26566,7 +26230,7 @@ var init_scroll_offset = __esm({
26566
26230
  });
26567
26231
 
26568
26232
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
26569
- import React13, { useEffect as useEffect17, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
26233
+ import React13, { useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
26570
26234
  import figures6 from "figures";
26571
26235
  import { Box as Box26, measureElement, Text as Text27 } from "ink";
26572
26236
  import { Fragment as Fragment6, jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
@@ -28093,7 +27757,7 @@ function FieldEditor({
28093
27757
  }
28094
27758
  return Math.max(start + 1, end2);
28095
27759
  };
28096
- useEffect17(() => {
27760
+ useEffect14(() => {
28097
27761
  if (focusLevel === "field" || selectedRowIdx < 0) return;
28098
27762
  setListScrollStart((previous) => {
28099
27763
  if (initialFocusTarget && !initialFocusScrollApplied.current) {
@@ -29488,7 +29152,7 @@ var init_FinalizeDialog = __esm({
29488
29152
  });
29489
29153
 
29490
29154
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
29491
- import { useEffect as useEffect18, useRef as useRef12, useState as useState20 } from "react";
29155
+ import { useEffect as useEffect15, useRef as useRef12, useState as useState20 } from "react";
29492
29156
  function useReviewFinalizePreview({
29493
29157
  components,
29494
29158
  ...options
@@ -29505,7 +29169,7 @@ function useFinalizePreview(opts) {
29505
29169
  const [scrollOffset, setScrollOffset] = useState20(0);
29506
29170
  const generationRef = useRef12(0);
29507
29171
  const acceptedKey = [...acceptedKeys].sort().join("\0");
29508
- useEffect18(() => {
29172
+ useEffect15(() => {
29509
29173
  if (!open) {
29510
29174
  setStatus("idle");
29511
29175
  setRemoved([]);
@@ -29557,7 +29221,7 @@ var init_use_finalize_preview = __esm({
29557
29221
  });
29558
29222
 
29559
29223
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
29560
- import { useCallback as useCallback2, useEffect as useEffect19, useRef as useRef13, useState as useState21 } from "react";
29224
+ import { useCallback as useCallback2, useEffect as useEffect16, useRef as useRef13, useState as useState21 } from "react";
29561
29225
  function useReviewSession({
29562
29226
  loadSession,
29563
29227
  tokensPath,
@@ -29576,7 +29240,7 @@ function useReviewSession({
29576
29240
  }));
29577
29241
  return { result, catalog };
29578
29242
  }, [loadSession, tokensPath]);
29579
- useEffect19(() => {
29243
+ useEffect16(() => {
29580
29244
  let disposed = false;
29581
29245
  void (async () => {
29582
29246
  try {
@@ -29629,7 +29293,7 @@ function useReviewSession({
29629
29293
  function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
29630
29294
  const [reviewMetadata, setReviewMetadata] = useState21(null);
29631
29295
  const [componentRationale, setComponentRationale] = useState21(null);
29632
- useEffect19(() => {
29296
+ useEffect16(() => {
29633
29297
  const current = components[selectedIdx];
29634
29298
  if (!current) {
29635
29299
  setReviewMetadata(null);
@@ -29658,16 +29322,10 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
29658
29322
  }, [components, extractSessionId, selectedIdx]);
29659
29323
  return { reviewMetadata, componentRationale };
29660
29324
  }
29661
- function useReviewHistory({
29662
- loading,
29663
- components,
29664
- createSnapshot,
29665
- applySnapshot,
29666
- onAction
29667
- }) {
29325
+ function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
29668
29326
  const historyRef = useRef13(null);
29669
29327
  const historySeededRef = useRef13(false);
29670
- useEffect19(() => {
29328
+ useEffect16(() => {
29671
29329
  if (loading || historySeededRef.current) return;
29672
29330
  historySeededRef.current = true;
29673
29331
  historyRef.current = createHistoryStack(createSnapshot(components));
@@ -29675,19 +29333,14 @@ function useReviewHistory({
29675
29333
  const pushHistorySnapshot = (entries, label) => {
29676
29334
  if (!historyRef.current) return;
29677
29335
  historyRef.current.push(createSnapshot(entries), label);
29678
- onAction?.(label);
29679
29336
  };
29680
29337
  const handleUndo = () => {
29681
29338
  const snapshot = historyRef.current?.undo();
29682
- if (!snapshot) return;
29683
- applySnapshot(snapshot);
29684
- onAction?.("undo");
29339
+ if (snapshot) applySnapshot(snapshot);
29685
29340
  };
29686
29341
  const handleRedo = () => {
29687
29342
  const snapshot = historyRef.current?.redo();
29688
- if (!snapshot) return;
29689
- applySnapshot(snapshot);
29690
- onAction?.("redo");
29343
+ if (snapshot) applySnapshot(snapshot);
29691
29344
  };
29692
29345
  const resetHistory = (snapshot) => {
29693
29346
  historyRef.current?.reset(snapshot);
@@ -29754,7 +29407,7 @@ var init_token_suggestions = __esm({
29754
29407
  });
29755
29408
 
29756
29409
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
29757
- import { useEffect as useEffect20, useRef as useRef14, useState as useState22 } from "react";
29410
+ import { useEffect as useEffect17, useRef as useRef14, useState as useState22 } from "react";
29758
29411
  function parseReviewEntry(draftValue) {
29759
29412
  const parsed = JSON.parse(draftValue);
29760
29413
  const keys = Object.keys(parsed);
@@ -29788,7 +29441,7 @@ function useReviewEditor({
29788
29441
  const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState22(/* @__PURE__ */ new Set());
29789
29442
  const tokenReviewSuggestedRef = useRef14(/* @__PURE__ */ new Map());
29790
29443
  const pendingGRef = useRef14(false);
29791
- useEffect20(() => {
29444
+ useEffect17(() => {
29792
29445
  setTokenReviewRow(0);
29793
29446
  setTokenReviewEditing(false);
29794
29447
  setTokenReviewEditCursor(0);
@@ -30270,7 +29923,7 @@ var init_preview_annotations = __esm({
30270
29923
  });
30271
29924
 
30272
29925
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
30273
- import { useCallback as useCallback3, useEffect as useEffect21, useRef as useRef15, useState as useState24 } from "react";
29926
+ import { useCallback as useCallback3, useEffect as useEffect18, useRef as useRef15, useState as useState24 } from "react";
30274
29927
  function useLivePreview(opts) {
30275
29928
  const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
30276
29929
  const [status, setStatus] = useState24("idle");
@@ -30280,14 +29933,14 @@ function useLivePreview(opts) {
30280
29933
  const latestRef = useRef15(0);
30281
29934
  const inflightRef = useRef15(0);
30282
29935
  const optsRef = useRef15(opts);
30283
- useEffect21(() => {
29936
+ useEffect18(() => {
30284
29937
  optsRef.current = opts;
30285
29938
  });
30286
29939
  const disabledRef = useRef15(disabled);
30287
- useEffect21(() => {
29940
+ useEffect18(() => {
30288
29941
  disabledRef.current = disabled;
30289
29942
  }, [disabled]);
30290
- useEffect21(() => {
29943
+ useEffect18(() => {
30291
29944
  return () => {
30292
29945
  if (timerRef.current) {
30293
29946
  clearTimeout(timerRef.current);
@@ -30368,7 +30021,7 @@ var init_use_live_preview = __esm({
30368
30021
  });
30369
30022
 
30370
30023
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
30371
- import { useCallback as useCallback4, useEffect as useEffect22, useState as useState25 } from "react";
30024
+ import { useCallback as useCallback4, useEffect as useEffect19, useState as useState25 } from "react";
30372
30025
  function useReviewPreview({
30373
30026
  components,
30374
30027
  loading,
@@ -30410,13 +30063,13 @@ function useReviewPreview({
30410
30063
  deleteAllComponents
30411
30064
  });
30412
30065
  const [spinnerTick, setSpinnerTick] = useState25(0);
30413
- useEffect22(() => {
30066
+ useEffect19(() => {
30414
30067
  if (livePreviewHook.status !== "running") return;
30415
30068
  const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
30416
30069
  return () => clearInterval(id);
30417
30070
  }, [livePreviewHook.status]);
30418
30071
  const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
30419
- useEffect22(() => {
30072
+ useEffect19(() => {
30420
30073
  if (loading) return;
30421
30074
  if (!livePreview) return;
30422
30075
  if (components.length === 0) return;
@@ -30434,127 +30087,6 @@ var init_use_review_preview = __esm({
30434
30087
  }
30435
30088
  });
30436
30089
 
30437
- // packages/experience-design-system-cli/src/tui/import/steps/09-review/review-log.ts
30438
- function reviewInputs(components) {
30439
- return { components: components.length, by_status: countStatuses(components) };
30440
- }
30441
- function openReviewTrail(components, now) {
30442
- return {
30443
- startedAt: now,
30444
- start: new Map(components.map((component) => [component.key, component.status])),
30445
- actions: [],
30446
- kinds: {}
30447
- };
30448
- }
30449
- function recordReviewAction(trail, label) {
30450
- const kind = label.split(":")[0] ?? label;
30451
- trail.kinds[kind] = (trail.kinds[kind] ?? 0) + 1;
30452
- if (trail.actions.length < MAX_ACTIONS) trail.actions.push(label);
30453
- }
30454
- function render(trail, components, now, outcome) {
30455
- const acceptedByUser = [];
30456
- const rejectedByUser = [];
30457
- for (const { key, status } of components) {
30458
- const was = trail.start.get(key);
30459
- if (was === status) continue;
30460
- if (status === "accepted") acceptedByUser.push(key);
30461
- if (status === "rejected") rejectedByUser.push(key);
30462
- }
30463
- const total = Object.values(trail.kinds).reduce((sum, count) => sum + count, 0);
30464
- return {
30465
- outcome,
30466
- seconds: Math.round((now - trail.startedAt) / 100) / 10,
30467
- edits: { total, by_kind: trail.kinds, in_order: trail.actions },
30468
- now: countStatuses(components),
30469
- accepted_by_user: capped2(acceptedByUser),
30470
- rejected_by_user: capped2(rejectedByUser)
30471
- };
30472
- }
30473
- function reviewProgress(trail, components, now) {
30474
- return render(trail, components, now, "interrupted");
30475
- }
30476
- function reviewFinish(trail, components, now, final) {
30477
- const outcome = final ? `finalized: ${final.accepted} accepted, ${final.rejected} rejected, ${final.unresolved} unresolved` : "left the review without finishing";
30478
- return {
30479
- outputs: render(trail, components, now, outcome),
30480
- status: "success",
30481
- exitMethod: final ? "saved" : "discarded"
30482
- };
30483
- }
30484
- var REVIEW_RUN, MAX_ACTIONS, MAX_NAMES2, countStatuses, capped2;
30485
- var init_review_log = __esm({
30486
- "packages/experience-design-system-cli/src/tui/import/steps/09-review/review-log.ts"() {
30487
- "use strict";
30488
- REVIEW_RUN = { flow: "import/review", step: "09-review", menuOption: "Review" };
30489
- MAX_ACTIONS = 30;
30490
- MAX_NAMES2 = 20;
30491
- countStatuses = (components) => {
30492
- const counts = {};
30493
- for (const { status } of components) counts[status] = (counts[status] ?? 0) + 1;
30494
- return counts;
30495
- };
30496
- capped2 = (keys) => ({
30497
- count: keys.length,
30498
- keys: keys.slice(0, MAX_NAMES2)
30499
- });
30500
- }
30501
- });
30502
-
30503
- // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-log.ts
30504
- import { useEffect as useEffect23, useRef as useRef16 } from "react";
30505
- function useReviewLog({
30506
- loading,
30507
- loadError,
30508
- components
30509
- }) {
30510
- const trail = useRef16(void 0);
30511
- const started = useRef16(false);
30512
- const latest = useRef16(components);
30513
- latest.current = components;
30514
- useEffect23(() => {
30515
- if (loading || started.current) return;
30516
- started.current = true;
30517
- startDebugRun({ ...REVIEW_RUN, inputs: reviewInputs(components) });
30518
- if (loadError) {
30519
- void finishDebugRun({
30520
- outputs: { outcome: "could not load the components", error: loadError },
30521
- status: "error",
30522
- exitMethod: "discarded"
30523
- });
30524
- return;
30525
- }
30526
- trail.current = openReviewTrail(components, Date.now());
30527
- setDebugRunProgress(reviewProgress(trail.current, components, Date.now()));
30528
- }, [loading, loadError, components]);
30529
- useEffect23(
30530
- () => () => {
30531
- const open = trail.current;
30532
- trail.current = void 0;
30533
- if (open) void finishDebugRun(reviewFinish(open, latest.current, Date.now(), void 0));
30534
- },
30535
- []
30536
- );
30537
- return {
30538
- record: (label) => {
30539
- if (!trail.current) return;
30540
- recordReviewAction(trail.current, label);
30541
- setDebugRunProgress(reviewProgress(trail.current, latest.current, Date.now()));
30542
- },
30543
- finish: (counts) => {
30544
- const open = trail.current;
30545
- trail.current = void 0;
30546
- if (open) void finishDebugRun(reviewFinish(open, latest.current, Date.now(), counts));
30547
- }
30548
- };
30549
- }
30550
- var init_use_review_log = __esm({
30551
- "packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-log.ts"() {
30552
- "use strict";
30553
- init_debug_store();
30554
- init_review_log();
30555
- }
30556
- });
30557
-
30558
30090
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/LivePreviewSummary.tsx
30559
30091
  import { Box as Box37, Text as Text39 } from "ink";
30560
30092
  import { jsx as jsx47, jsxs as jsxs37 } from "react/jsx-runtime";
@@ -30594,7 +30126,7 @@ var init_LivePreviewSummary = __esm({
30594
30126
  });
30595
30127
 
30596
30128
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
30597
- import { useCallback as useCallback5, useEffect as useEffect24, useMemo as useMemo6, useRef as useRef17, useState as useState26 } from "react";
30129
+ import { useCallback as useCallback5, useEffect as useEffect20, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
30598
30130
  import figures8 from "figures";
30599
30131
  import { Box as Box38, Text as Text40 } from "ink";
30600
30132
  import { Fragment as Fragment14, jsx as jsx48, jsxs as jsxs38 } from "react/jsx-runtime";
@@ -30791,7 +30323,6 @@ function GenerateReviewStepView({
30791
30323
  tokensPath,
30792
30324
  onExtraLoaded: setLoadedSlotCycles
30793
30325
  });
30794
- const reviewLog = useReviewLog({ loading, loadError, components });
30795
30326
  const [nav, setNav] = useState26({
30796
30327
  cursorRowIdx: 0,
30797
30328
  sidebarScrollOffset: 0
@@ -30809,7 +30340,7 @@ function GenerateReviewStepView({
30809
30340
  setFinalizeError
30810
30341
  } = reviewSurface;
30811
30342
  const [removedBannerCollapsed, setRemovedBannerCollapsed] = useState26(false);
30812
- const removedBannerDefaultedRef = useRef17(false);
30343
+ const removedBannerDefaultedRef = useRef16(false);
30813
30344
  const [cyclePanelScroll, setCyclePanelScroll] = useState26(0);
30814
30345
  const [cyclesCursor, setCyclesCursor] = useState26(0);
30815
30346
  const cyclePanel = useOverlayPanel({
@@ -30829,7 +30360,7 @@ function GenerateReviewStepView({
30829
30360
  const [breakCursor, setBreakCursor] = useState26(0);
30830
30361
  const [breakConfirm, setBreakConfirm] = useState26(false);
30831
30362
  const [expandedGroups, setExpandedGroups] = useState26(/* @__PURE__ */ new Set());
30832
- const seededGroupsRef = useRef17(false);
30363
+ const seededGroupsRef = useRef16(false);
30833
30364
  const {
30834
30365
  searchOpen,
30835
30366
  setSearchOpen,
@@ -30853,7 +30384,7 @@ function GenerateReviewStepView({
30853
30384
  const [pendingEditorFocus, setPendingEditorFocus] = useState26(null);
30854
30385
  const [autoRejected, setAutoRejected] = useState26([]);
30855
30386
  const [undoSnapshot, setUndoSnapshot] = useState26(null);
30856
- const autoRejectFiredRef = useRef17(false);
30387
+ const autoRejectFiredRef = useRef16(false);
30857
30388
  const [showReloadDialog, setShowReloadDialog] = useState26(false);
30858
30389
  const acceptedCountForPreview = components.filter((c2) => c2.status === "accepted").length;
30859
30390
  const { previewAnnotations, removedComponents, livePreviewHook, livePreviewSpinner } = useReviewPreview({
@@ -30885,10 +30416,7 @@ function GenerateReviewStepView({
30885
30416
  cmaToken,
30886
30417
  host,
30887
30418
  components,
30888
- onFinalize: (accepted, rejected, unresolved) => {
30889
- reviewLog.finish({ accepted, rejected, unresolved });
30890
- onFinalize(accepted, rejected, unresolved);
30891
- }
30419
+ onFinalize
30892
30420
  });
30893
30421
  const recomputeCycles = (currentComponents) => {
30894
30422
  try {
@@ -30919,7 +30447,7 @@ function GenerateReviewStepView({
30919
30447
  [components]
30920
30448
  );
30921
30449
  const closures = useMemo6(() => computeAllClosures(componentGraph), [componentGraph]);
30922
- useEffect24(() => {
30450
+ useEffect20(() => {
30923
30451
  if (seededGroupsRef.current) return;
30924
30452
  if (closures.size === 0 && slotCycles.length === 0) return;
30925
30453
  seededGroupsRef.current = true;
@@ -30946,7 +30474,7 @@ function GenerateReviewStepView({
30946
30474
  suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
30947
30475
  }));
30948
30476
  }, [slotCycles, cycleView]);
30949
- useEffect24(() => {
30477
+ useEffect20(() => {
30950
30478
  const decision = computeAutoRejectDecision({
30951
30479
  loading,
30952
30480
  autoRejectFired: autoRejectFiredRef.current,
@@ -30987,11 +30515,10 @@ function GenerateReviewStepView({
30987
30515
  autoRejected,
30988
30516
  undoSnapshot
30989
30517
  }),
30990
- applySnapshot: applyHistorySnapshot,
30991
- onAction: reviewLog.record
30518
+ applySnapshot: applyHistorySnapshot
30992
30519
  });
30993
- const autoRejectPushedRef = useRef17(false);
30994
- useEffect24(() => {
30520
+ const autoRejectPushedRef = useRef16(false);
30521
+ useEffect20(() => {
30995
30522
  if (loading) return;
30996
30523
  if (!historySeededRef.current) return;
30997
30524
  if (!autoRejectFiredRef.current) return;
@@ -31075,7 +30602,7 @@ function GenerateReviewStepView({
31075
30602
  const panelHeight = leftPanelHeight + 2;
31076
30603
  const panelContentHeight = Math.max(1, panelHeight - 3);
31077
30604
  const cycleViewportHeight = Math.max(1, panelHeight - 4);
31078
- useEffect24(() => {
30605
+ useEffect20(() => {
31079
30606
  if (selectableRowPositions.length === 0) return;
31080
30607
  const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
31081
30608
  const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
@@ -31904,7 +31431,6 @@ var init_generate_review_step = __esm({
31904
31431
  init_ReviewDialogs();
31905
31432
  init_review_input();
31906
31433
  init_use_review_preview();
31907
- init_use_review_log();
31908
31434
  init_LivePreviewSummary();
31909
31435
  HELP_SECTIONS2 = [
31910
31436
  {
@@ -32158,10 +31684,10 @@ var init_path_utils = __esm({
32158
31684
  });
32159
31685
 
32160
31686
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
32161
- import { useEffect as useEffect25, useState as useState27 } from "react";
31687
+ import { useEffect as useEffect21, useState as useState27 } from "react";
32162
31688
  function useBlinkingCursor() {
32163
31689
  const [visible, setVisible] = useState27(true);
32164
- useEffect25(() => {
31690
+ useEffect21(() => {
32165
31691
  const interval = setInterval(() => setVisible((current) => !current), 500);
32166
31692
  return () => clearInterval(interval);
32167
31693
  }, []);
@@ -32298,12 +31824,12 @@ var init_produced = __esm({
32298
31824
  });
32299
31825
 
32300
31826
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
32301
- import { useEffect as useEffect26, useState as useState29 } from "react";
31827
+ import { useEffect as useEffect22, useState as useState29 } from "react";
32302
31828
  import { Spinner as Spinner2 } from "@inkjs/ui";
32303
31829
  import { jsx as jsx53 } from "react/jsx-runtime";
32304
31830
  function useTimedSpinner() {
32305
31831
  const [elapsedSeconds, setElapsedSeconds] = useState29(0);
32306
- useEffect26(() => {
31832
+ useEffect22(() => {
32307
31833
  const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
32308
31834
  return () => {
32309
31835
  clearInterval(timer);
@@ -32572,7 +32098,7 @@ var init_preview_confirmation_input = __esm({
32572
32098
  });
32573
32099
 
32574
32100
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
32575
- import { useEffect as useEffect27, useState as useState30, useMemo as useMemo7 } from "react";
32101
+ import { useEffect as useEffect23, useState as useState30, useMemo as useMemo7 } from "react";
32576
32102
  import { Box as Box44, Text as Text46 } from "ink";
32577
32103
  import { Fragment as Fragment16, jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
32578
32104
  function buildPreviewSummaryLines(preview) {
@@ -32782,7 +32308,7 @@ function WizardPreviewStep({
32782
32308
  const activeLines = diffExpanded ? diffLines : summaryLines;
32783
32309
  const maxScroll = Math.max(0, activeLines.length - viewportHeight);
32784
32310
  const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
32785
- useEffect27(() => {
32311
+ useEffect23(() => {
32786
32312
  setScrollOffset((previous) => Math.min(previous, maxScroll));
32787
32313
  }, [maxScroll]);
32788
32314
  useImmediateInput((input, key) => {
@@ -32892,205 +32418,6 @@ var init_run_teaser = __esm({
32892
32418
  }
32893
32419
  });
32894
32420
 
32895
- // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts
32896
- function previewSummary(preview) {
32897
- const counts = (group) => ({
32898
- new: group.new.length,
32899
- changed: group.changed.length,
32900
- removed: group.removed.length
32901
- });
32902
- return {
32903
- components: counts(preview.components),
32904
- tokens: counts(preview.tokens),
32905
- breaking_components: preview.components.changed.filter(
32906
- (entry) => entry.changeClassification?.classification === "breaking"
32907
- ).length
32908
- };
32909
- }
32910
- function pushSummary(result, state2) {
32911
- const failures = result.failures ?? [];
32912
- return {
32913
- component_types: result.componentTypes,
32914
- design_tokens: result.designTokens,
32915
- ...result.summary ? { summary: result.summary } : {},
32916
- ...failures.length > 0 ? {
32917
- failure_count: failures.length,
32918
- failures: failures.slice(0, MAX_LOGGED).map((failure) => ({
32919
- entity_type: failure.entityType,
32920
- entity_id: failure.entityId,
32921
- message: scrub(failure.message, state2)
32922
- }))
32923
- } : {}
32924
- };
32925
- }
32926
- function flowContext(state2) {
32927
- return {
32928
- agent: state2.agent,
32929
- space_id: state2.spaceId,
32930
- environment_id: state2.environmentId,
32931
- host: state2.host,
32932
- credentials_skipped: state2.credentialsSkipped,
32933
- components_generated: state2.generatedCount,
32934
- components_accepted: state2.generatedAcceptedCount,
32935
- tokens: state2.tokenCount,
32936
- cma_token: state2.cmaToken
32937
- };
32938
- }
32939
- function arrive(trail, state2) {
32940
- const next = { ...trail, at: state2.step };
32941
- if (state2.step === "error") {
32942
- next.failure = { step: state2.errorStep, message: scrub(state2.errorMessage, state2) };
32943
- }
32944
- if (state2.step === "preview-validation-error") {
32945
- next.validation = {
32946
- count: state2.previewValidationErrors.length,
32947
- errors: state2.previewValidationErrors.slice(0, MAX_LOGGED).map((error) => ({
32948
- component: error.componentName,
32949
- path: error.path,
32950
- message: scrub(error.message, state2)
32951
- })),
32952
- missing_names: state2.previewValidationMissingNames.slice(0, MAX_LOGGED * 2)
32953
- };
32954
- }
32955
- return next;
32956
- }
32957
- function openTrail(state2, now) {
32958
- return arrive({ startedAt: now, stageStartedAt: now, at: state2.step, stages: [] }, state2);
32959
- }
32960
- function advance(trail, from, to, now) {
32961
- const next = { ...trail, stages: [...trail.stages], stageStartedAt: now };
32962
- const failed = to.step === "error" || to.step === "preview-validation-error" || from.step === "pushing" && pushHasFailures(to.pushResult);
32963
- if (WORK.includes(from.step)) {
32964
- next.stages.push(`${LABELS[from.step]}: ${failed ? "failed" : "ok"} (${seconds(now - trail.stageStartedAt)}s)`);
32965
- }
32966
- if (from.step === "previewing" && to.serverPreview) next.preview = previewSummary(to.serverPreview);
32967
- if (from.step === "pushing") {
32968
- next.push = pushSummary(to.pushResult, to);
32969
- next.pushFailed = pushHasFailures(to.pushResult);
32970
- }
32971
- if (from.step === "printing" && !failed) next.saved = { path: to.componentsPath, run_id: to.lastRunId };
32972
- return arrive(next, to);
32973
- }
32974
- function render2(trail, now, outcome) {
32975
- return {
32976
- outcome,
32977
- total_seconds: seconds(now - trail.startedAt),
32978
- stages: trail.stages,
32979
- ...trail.preview ? { preview: trail.preview } : {},
32980
- ...trail.push ? { push: trail.push } : {},
32981
- ...trail.saved ? { saved: trail.saved } : {},
32982
- ...trail.failure ? { error: trail.failure } : {},
32983
- ...trail.validation ? { preview_validation: trail.validation } : {}
32984
- };
32985
- }
32986
- function flowProgress(trail, now) {
32987
- return render2(trail, now, `interrupted at ${LABELS[trail.at]}`);
32988
- }
32989
- function flowFinish(trail, final, now) {
32990
- if (!final) {
32991
- const midWork = WORK.includes(trail.at);
32992
- const outcome2 = `left the import ${midWork ? "while" : "at"} ${LABELS[trail.at]}${midWork ? " was running" : ""}`;
32993
- return { outputs: render2(trail, now, outcome2), status: midWork ? "error" : "success", exitMethod: "discarded" };
32994
- }
32995
- if (final.step === "final-review") {
32996
- return {
32997
- outputs: render2(trail, now, "went back to edit the definitions"),
32998
- status: "success",
32999
- exitMethod: "discarded"
33000
- };
33001
- }
33002
- let outcome;
33003
- let failed = true;
33004
- if (trail.validation) {
33005
- outcome = `blocked by ${String(trail.validation["count"])} preview validation error(s)`;
33006
- } else if (trail.failure) {
33007
- outcome = `failed at ${trail.failure.step}: ${trail.failure.message.slice(0, MAX_OUTCOME)}`;
33008
- } else if (trail.pushFailed) {
33009
- outcome = "pushed, but some entities failed";
33010
- } else {
33011
- failed = false;
33012
- outcome = final.credentialsSkipped ? "saved without pushing (credentials skipped)" : "published";
33013
- }
33014
- return {
33015
- outputs: render2(trail, now, outcome),
33016
- status: failed ? "error" : "success",
33017
- exitMethod: failed ? "discarded" : "saved"
33018
- };
33019
- }
33020
- var FLOW_RUN, LABELS, WORK, FINISHED, MAX_LOGGED, MAX_OUTCOME, scrub, seconds, pushHasFailures, isFlowFinished;
33021
- var init_flow_log = __esm({
33022
- "packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts"() {
33023
- "use strict";
33024
- init_debug_trail();
33025
- FLOW_RUN = { flow: "import/publish", step: "10-publish", menuOption: "Publish" };
33026
- LABELS = {
33027
- "final-review": "Final review",
33028
- "path-prompt": "Save path",
33029
- printing: "Save files",
33030
- previewing: "Preview",
33031
- "preview-gate": "Preview confirmation",
33032
- pushing: "Push",
33033
- "print-gate": "Files saved",
33034
- done: "Done",
33035
- error: "Error",
33036
- "preview-validation-error": "Preview validation"
33037
- };
33038
- WORK = ["printing", "previewing", "pushing"];
33039
- FINISHED = ["done", "error", "preview-validation-error", "final-review"];
33040
- MAX_LOGGED = 10;
33041
- MAX_OUTCOME = 200;
33042
- scrub = (text, state2) => scrubError(text, [state2.cmaToken]);
33043
- seconds = (ms) => Math.round(ms / 100) / 10;
33044
- pushHasFailures = (result) => result.componentTypes.failed + result.designTokens.failed > 0 || (result.failures?.length ?? 0) > 0 || (result.summary?.failed ?? 0) > 0;
33045
- isFlowFinished = (step) => FINISHED.includes(step);
33046
- }
33047
- });
33048
-
33049
- // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
33050
- import { useEffect as useEffect28, useRef as useRef18 } from "react";
33051
- function useFlowLog(state2) {
33052
- const trail = useRef18(void 0);
33053
- const previous = useRef18(void 0);
33054
- useEffect28(() => {
33055
- const before = previous.current;
33056
- previous.current = state2;
33057
- const moved = before !== void 0 && before.step !== state2.step;
33058
- const now = Date.now();
33059
- let open = trail.current;
33060
- if (!open) {
33061
- if (state2.step === "final-review" || before && !moved) return;
33062
- open = openTrail(state2, now);
33063
- startDebugRun({ ...FLOW_RUN, inputs: flowContext(state2) });
33064
- } else if (before && moved) {
33065
- open = advance(open, before, state2, now);
33066
- } else {
33067
- return;
33068
- }
33069
- if (isFlowFinished(state2.step)) {
33070
- trail.current = void 0;
33071
- void finishDebugRun(flowFinish(open, state2, now));
33072
- return;
33073
- }
33074
- trail.current = open;
33075
- setDebugRunProgress(flowProgress(open, now));
33076
- }, [state2]);
33077
- useEffect28(
33078
- () => () => {
33079
- const open = trail.current;
33080
- trail.current = void 0;
33081
- if (open) void finishDebugRun(flowFinish(open, void 0, Date.now()));
33082
- },
33083
- []
33084
- );
33085
- }
33086
- var init_use_flow_log = __esm({
33087
- "packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts"() {
33088
- "use strict";
33089
- init_debug_store();
33090
- init_flow_log();
33091
- }
33092
- });
33093
-
33094
32421
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
33095
32422
  import { Box as Box45 } from "ink";
33096
32423
  import { jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
@@ -33105,7 +32432,6 @@ function FlowScreen({
33105
32432
  generatePromptPath,
33106
32433
  onExit
33107
32434
  }) {
33108
- useFlowLog(state2);
33109
32435
  const produced = producedOf(state2);
33110
32436
  const counts = { components: state2.generatedAcceptedCount, tokens: state2.tokenCount };
33111
32437
  const things = countedThings(produced, counts);
@@ -33233,7 +32559,6 @@ var init_screen11 = __esm({
33233
32559
  init_WizardPreviewStep();
33234
32560
  init_produced();
33235
32561
  init_run_teaser();
33236
- init_use_flow_log();
33237
32562
  }
33238
32563
  });
33239
32564
 
@@ -34031,9 +33356,9 @@ var init_controller = __esm({
34031
33356
  });
34032
33357
 
34033
33358
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
34034
- import { useEffect as useEffect29, useRef as useRef19, useSyncExternalStore } from "react";
33359
+ import { useEffect as useEffect24, useRef as useRef17, useSyncExternalStore } from "react";
34035
33360
  function useFlow(start, options = {}) {
34036
- const controller = useRef19();
33361
+ const controller = useRef17();
34037
33362
  if (start && !controller.current) {
34038
33363
  try {
34039
33364
  startWizardLog();
@@ -34050,7 +33375,7 @@ function useFlow(start, options = {}) {
34050
33375
  (listener) => current?.subscribe(listener) ?? (() => void 0),
34051
33376
  () => current?.getState()
34052
33377
  );
34053
- useEffect29(() => {
33378
+ useEffect24(() => {
34054
33379
  if (!start) controller.current = void 0;
34055
33380
  }, [start]);
34056
33381
  return current && state2 ? { controller: current, state: state2 } : void 0;
@@ -34129,7 +33454,7 @@ var init_help_info = __esm({
34129
33454
  });
34130
33455
 
34131
33456
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
34132
- import { useEffect as useEffect30, useState as useState31 } from "react";
33457
+ import { useEffect as useEffect25, useState as useState31 } from "react";
34133
33458
  import { Box as Box46, Text as Text47, useInput as useInput13 } from "ink";
34134
33459
  import { Fragment as Fragment17, jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
34135
33460
  function Section({ title, rows }) {
@@ -34143,7 +33468,7 @@ function Section({ title, rows }) {
34143
33468
  }
34144
33469
  function HelpScreen({ onDone }) {
34145
33470
  const [info, setInfo] = useState31();
34146
- useEffect30(() => {
33471
+ useEffect25(() => {
34147
33472
  startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
34148
33473
  void readHelpInfo().then(setInfo);
34149
33474
  }, []);
@@ -34251,6 +33576,45 @@ var init_PageContainer3 = __esm({
34251
33576
  }
34252
33577
  });
34253
33578
 
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
+
34254
33618
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
34255
33619
  import { execFile as execFile2 } from "node:child_process";
34256
33620
  import { access as access5, constants } from "node:fs/promises";
@@ -34316,7 +33680,7 @@ async function testAgent(name, binary, model) {
34316
33680
  timeoutMs: PROMPT_TIMEOUT_MS
34317
33681
  })
34318
33682
  );
34319
- const seconds2 = ((Date.now() - started) / 1e3).toFixed(1);
33683
+ const seconds = ((Date.now() - started) / 1e3).toFixed(1);
34320
33684
  if (result.timedOut) {
34321
33685
  return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
34322
33686
  }
@@ -34324,7 +33688,7 @@ async function testAgent(name, binary, model) {
34324
33688
  const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
34325
33689
  return [...checks, fail3("prompt", reason)];
34326
33690
  }
34327
- return [...checks, pass("prompt", `answered in ${seconds2}s`)];
33691
+ return [...checks, pass("prompt", `answered in ${seconds}s`)];
34328
33692
  }
34329
33693
  function statusFromChecks(name, checks, savedBinary) {
34330
33694
  if (checks.length === 0) return "checking";
@@ -34525,7 +33889,7 @@ var init_AgentStatusBadge = __esm({
34525
33889
  });
34526
33890
 
34527
33891
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
34528
- import { useEffect as useEffect31, useState as useState33 } from "react";
33892
+ import { useEffect as useEffect26, useState as useState33 } from "react";
34529
33893
  import { Box as Box48, Text as Text50 } from "ink";
34530
33894
  import { jsx as jsx60, jsxs as jsxs48 } from "react/jsx-runtime";
34531
33895
  function StatusHeading() {
@@ -34546,7 +33910,7 @@ function AgentDetail({
34546
33910
  const [testing, setTesting] = useState33(false);
34547
33911
  const [notice, setNotice] = useState33(null);
34548
33912
  const [checks, setChecks] = useState33(void 0);
34549
- useEffect31(() => {
33913
+ useEffect26(() => {
34550
33914
  let active = true;
34551
33915
  setChecks(void 0);
34552
33916
  const timer = setTimeout(() => {
@@ -34638,7 +34002,7 @@ var init_AgentDetail = __esm({
34638
34002
  });
34639
34003
 
34640
34004
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
34641
- import { useEffect as useEffect32, useRef as useRef20, useState as useState34 } from "react";
34005
+ import { useEffect as useEffect27, useRef as useRef18, useState as useState34 } from "react";
34642
34006
  import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
34643
34007
  import { Fragment as Fragment18, jsx as jsx61, jsxs as jsxs49 } from "react/jsx-runtime";
34644
34008
  function AgentsScreen({ onDone }) {
@@ -34649,7 +34013,7 @@ function AgentsScreen({ onDone }) {
34649
34013
  const [saving, setSaving] = useState34(false);
34650
34014
  const [loadError, setLoadError] = useState34(null);
34651
34015
  const [checks, setChecks] = useState34({});
34652
- const visit = useRef20({
34016
+ const visit = useRef18({
34653
34017
  trail: createTrail(),
34654
34018
  before: void 0,
34655
34019
  environment: void 0,
@@ -34662,7 +34026,7 @@ function AgentsScreen({ onDone }) {
34662
34026
  );
34663
34027
  }
34664
34028
  };
34665
- useEffect32(() => {
34029
+ useEffect27(() => {
34666
34030
  readAgentConfig().then((loaded) => {
34667
34031
  setConfig(loaded);
34668
34032
  inspectAll(loaded);
@@ -34830,7 +34194,7 @@ function AgentsScreen({ onDone }) {
34830
34194
  hints: [
34831
34195
  { keys: "\u2191/\u2193", label: "move" },
34832
34196
  { keys: "\u23CE", label: "make default" },
34833
- { keys: "\u2192", label: "settings and test" },
34197
+ { keys: "\u2192", label: "settings" },
34834
34198
  { keys: "Esc/q", label: "back" }
34835
34199
  ]
34836
34200
  }
@@ -34888,7 +34252,7 @@ var init_project_store = __esm({
34888
34252
  });
34889
34253
 
34890
34254
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
34891
- import { useEffect as useEffect33, useRef as useRef21, useState as useState35 } from "react";
34255
+ import { useEffect as useEffect28, useRef as useRef19, useState as useState35 } from "react";
34892
34256
  import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
34893
34257
  import { Fragment as Fragment19, jsx as jsx62, jsxs as jsxs50 } from "react/jsx-runtime";
34894
34258
  function debugFields(config) {
@@ -34907,14 +34271,14 @@ function ProjectScreen({ onDone }) {
34907
34271
  const [saving, setSaving] = useState35(false);
34908
34272
  const [notice, setNotice] = useState35(null);
34909
34273
  const [loadError, setLoadError] = useState35(null);
34910
- const visit = useRef21({
34274
+ const visit = useRef19({
34911
34275
  trail: createTrail(),
34912
34276
  before: void 0,
34913
34277
  persisted: void 0,
34914
34278
  error: ""
34915
34279
  }).current;
34916
- const scrub2 = (err) => scrubError(err, [config?.cmaToken ?? ""]);
34917
- useEffect33(() => {
34280
+ const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
34281
+ useEffect28(() => {
34918
34282
  readCredentials().then((cfg) => {
34919
34283
  setConfig(cfg);
34920
34284
  visit.before = snapshotOf(cfg);
@@ -34981,7 +34345,7 @@ function ProjectScreen({ onDone }) {
34981
34345
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
34982
34346
  setNotice({ kind: "success", text: "Project settings saved" });
34983
34347
  }).catch((err) => {
34984
- visit.error = scrub2(err);
34348
+ visit.error = scrub(err);
34985
34349
  visit.trail.record("save failed");
34986
34350
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
34987
34351
  }).finally(() => setSaving(false));
@@ -35101,13 +34465,13 @@ var init_ConfigurationScreen = __esm({
35101
34465
  });
35102
34466
 
35103
34467
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
35104
- import { useEffect as useEffect34, useState as useState37 } from "react";
34468
+ import { useEffect as useEffect29, useState as useState37 } from "react";
35105
34469
  import { Box as Box52, Text as Text54, useInput as useInput18 } from "ink";
35106
34470
  import { Fragment as Fragment20, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-runtime";
35107
34471
  function OptInAnalyticsScreen({ onDone }) {
35108
34472
  const [loading, setLoading] = useState37(true);
35109
34473
  const [enabled, setEnabled] = useState37(true);
35110
- useEffect34(() => {
34474
+ useEffect29(() => {
35111
34475
  readAnalyticsSetting().then((setting) => {
35112
34476
  setEnabled(setting.enabled);
35113
34477
  setLoading(false);
@@ -35170,7 +34534,7 @@ var init_screen12 = __esm({
35170
34534
  });
35171
34535
 
35172
34536
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
35173
- import { useEffect as useEffect35, useRef as useRef22, useState as useState38 } from "react";
34537
+ import { useEffect as useEffect30, useRef as useRef20, useState as useState38 } from "react";
35174
34538
  import { Box as Box53, Text as Text55, useInput as useInput19 } from "ink";
35175
34539
  import { Fragment as Fragment21, jsx as jsx65, jsxs as jsxs53 } from "react/jsx-runtime";
35176
34540
  function DebugModeScreen({ onDone }) {
@@ -35180,8 +34544,8 @@ function DebugModeScreen({ onDone }) {
35180
34544
  RETENTION_CHOICES[RETENTION_CHOICES.length - 1]
35181
34545
  );
35182
34546
  const [notice, setNotice] = useState38(null);
35183
- const visit = useRef22({ trail: createTrail(), before: void 0, error: "" }).current;
35184
- useEffect35(() => {
34547
+ const visit = useRef20({ trail: createTrail(), before: void 0, error: "" }).current;
34548
+ useEffect30(() => {
35185
34549
  readDebugModeSetting().then((loaded) => {
35186
34550
  setSetting(loaded);
35187
34551
  setPending(loaded.retentionDays);
@@ -35322,7 +34686,7 @@ var app_exports = {};
35322
34686
  __export(app_exports, {
35323
34687
  runApp: () => runApp
35324
34688
  });
35325
- import { useEffect as useEffect36, useState as useState39 } from "react";
34689
+ import { useEffect as useEffect31, useState as useState39 } from "react";
35326
34690
  import { Fragment as Fragment22, jsx as jsx66 } from "react/jsx-runtime";
35327
34691
  function App({ importOptions, inkClear }) {
35328
34692
  const [screen, setScreen] = useState39("start");
@@ -35356,7 +34720,7 @@ function App({ importOptions, inkClear }) {
35356
34720
  const [flowStart, setFlowStart] = useState39();
35357
34721
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
35358
34722
  const [importDefaults, setImportDefaults] = useState39();
35359
- useEffect36(() => {
34723
+ useEffect31(() => {
35360
34724
  if (screen !== "import") {
35361
34725
  setImportDefaults(void 0);
35362
34726
  return;
@@ -35429,7 +34793,7 @@ function App({ importOptions, inkClear }) {
35429
34793
  }
35430
34794
  });
35431
34795
  };
35432
- useEffect36(() => {
34796
+ useEffect31(() => {
35433
34797
  if (!tokensOnlyRun || tokensOnly?.status !== "done" || !tokensOnly.result.ok) return;
35434
34798
  const { credentialsSkipped, input, tokens } = tokensOnlyRun;
35435
34799
  const { tokensPath, tokenSessionId, tokenCount } = tokensOnly.result;
@@ -35451,12 +34815,12 @@ function App({ importOptions, inkClear }) {
35451
34815
  }
35452
34816
  });
35453
34817
  }, [tokensOnly, tokensOnlyRun]);
35454
- useEffect36(() => {
34818
+ useEffect31(() => {
35455
34819
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
35456
34820
  setExtractionRun(void 0);
35457
34821
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
35458
34822
  }, [extraction, extractionRun]);
35459
- useEffect36(() => {
34823
+ useEffect31(() => {
35460
34824
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
35461
34825
  const { extraction: produced, input, generatePromptPath } = scopeRun;
35462
34826
  setGenerationInput({
@@ -35474,7 +34838,7 @@ function App({ importOptions, inkClear }) {
35474
34838
  ...generatePromptPath ? { generatePromptPath } : {}
35475
34839
  });
35476
34840
  }, [scopeFlow, scopeRun, generationInput]);
35477
- useEffect36(() => {
34841
+ useEffect31(() => {
35478
34842
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
35479
34843
  const { credentialsSkipped, extraction: produced, input, generatePromptPath } = scopeRun;
35480
34844
  inkClear();
@@ -35643,7 +35007,6 @@ function App({ importOptions, inkClear }) {
35643
35007
  return /* @__PURE__ */ jsx66(
35644
35008
  CredentialsScreen,
35645
35009
  {
35646
- mode: target,
35647
35010
  initial: importDefaults.credentials,
35648
35011
  tokensOnly: target === "tokens",
35649
35012
  onBack: () => goBackFrom("credentials"),
@@ -35781,9 +35144,9 @@ var pkg = JSON.parse(
35781
35144
  function createProgram() {
35782
35145
  const program = new Command().name("experiences").description("Contentful Experiences design system import CLI").version(pkg.version, "--version", "Print version number");
35783
35146
  registerImportCommand(program, async (options) => {
35784
- const { render: render3 } = await import("ink");
35147
+ const { render } = await import("ink");
35785
35148
  const { runApp: runApp2 } = await Promise.resolve().then(() => (init_app(), app_exports));
35786
- await runApp2(render3, options);
35149
+ await runApp2(render, options);
35787
35150
  });
35788
35151
  program.hook("preAction", async (_thisCommand, actionCommand) => {
35789
35152
  const chain = [];