@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/app.js CHANGED
@@ -197,7 +197,6 @@ __export(debug_store_exports, {
197
197
  currentDebugSessionDir: () => currentDebugSessionDir,
198
198
  currentSessionDir: () => currentSessionDir,
199
199
  finishDebugRun: () => finishDebugRun,
200
- setDebugRunProgress: () => setDebugRunProgress,
201
200
  startDebugRun: () => startDebugRun,
202
201
  startDebugSessionIn: () => startDebugSessionIn,
203
202
  startImportRun: () => startImportRun
@@ -293,15 +292,11 @@ function startDebugRun({
293
292
  const runId = generateRunId();
294
293
  const startedAt = Date.now();
295
294
  const redactedInputs = redact(inputs);
296
- const run = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
297
- pendingRun = run;
298
- void isDebugModeEnabled().then((enabled) => {
299
- if (!enabled && pendingRun === run) pendingRun = void 0;
295
+ isDebugModeEnabled().then((enabled) => {
296
+ if (!enabled) return;
297
+ pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
300
298
  });
301
299
  }
302
- function setDebugRunProgress(outputs) {
303
- if (pendingRun) pendingRun.progress = outputs;
304
- }
305
300
  async function finishDebugRun({
306
301
  outputs,
307
302
  status,
@@ -310,10 +305,9 @@ async function finishDebugRun({
310
305
  const run = pendingRun;
311
306
  if (!run) return;
312
307
  pendingRun = void 0;
313
- if (!await isDebugModeEnabled()) return;
314
308
  const durationMs = Date.now() - run.startedAt;
315
309
  const log = {
316
- flow: logFolder(run.flow, run.step),
310
+ flow: run.flow,
317
311
  menuOption: run.menuOption,
318
312
  content: renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs })
319
313
  };
@@ -324,9 +318,6 @@ async function finishDebugRun({
324
318
  }
325
319
  await writeLog(root, log);
326
320
  }
327
- function logFolder(flow, step) {
328
- return flow.startsWith("import/") && /^\d+-/.test(step) ? `import/${step}` : flow;
329
- }
330
321
  async function writeLog(root, log) {
331
322
  const dir = join5(root, ...log.flow.split("/"));
332
323
  await mkdir2(dir, { recursive: true });
@@ -383,7 +374,7 @@ ${JSON.stringify(finish.outputs, null, 2)}
383
374
  `;
384
375
  }
385
376
  function handleCrash() {
386
- return finishDebugRun({ outputs: pendingRun?.progress ?? {}, status: "error", exitMethod: "crashed" });
377
+ return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
387
378
  }
388
379
  var pendingRun, sessionDir, WAITING_LIMIT, waiting;
389
380
  var init_debug_store = __esm({
@@ -427,17 +418,11 @@ var init_debug_store = __esm({
427
418
  throw reason;
428
419
  });
429
420
  });
430
- for (const [signal, exitCode] of [
431
- ["SIGINT", 130],
432
- ["SIGTERM", 143],
433
- ["SIGHUP", 129]
434
- ]) {
435
- process.once(signal, () => {
436
- void handleCrash().finally(() => {
437
- process.exit(exitCode);
438
- });
421
+ process.once("SIGINT", () => {
422
+ void handleCrash().finally(() => {
423
+ process.exit(130);
439
424
  });
440
- }
425
+ });
441
426
  }
442
427
  });
443
428
 
@@ -2499,7 +2484,7 @@ var init_cache_keys = __esm({
2499
2484
  });
2500
2485
 
2501
2486
  // packages/experience-design-system-cli/app.tsx
2502
- import { useEffect as useEffect36, useState as useState39 } from "react";
2487
+ import { useEffect as useEffect31, useState as useState39 } from "react";
2503
2488
 
2504
2489
  // packages/experience-design-system-cli/src/tui/home/home.tsx
2505
2490
  import { useEffect as useEffect2, useState as useState2 } from "react";
@@ -3057,8 +3042,8 @@ function progressPercent(progress) {
3057
3042
  }
3058
3043
  function formatElapsed(totalSeconds) {
3059
3044
  const minutes = Math.floor(totalSeconds / 60);
3060
- const seconds2 = totalSeconds % 60;
3061
- return minutes > 0 ? `${minutes}m ${seconds2}s` : `${seconds2}s`;
3045
+ const seconds = totalSeconds % 60;
3046
+ return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
3062
3047
  }
3063
3048
 
3064
3049
  // packages/experience-design-system-cli/src/tui/import/shared/running-step/theme.ts
@@ -3076,12 +3061,12 @@ var PROGRESS_THEME = extendTheme(defaultTheme, {
3076
3061
  // packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts
3077
3062
  import { useEffect as useEffect3, useState as useState3 } from "react";
3078
3063
  function useElapsed() {
3079
- const [seconds2, setSeconds] = useState3(0);
3064
+ const [seconds, setSeconds] = useState3(0);
3080
3065
  useEffect3(() => {
3081
3066
  const timer = setInterval(() => setSeconds((current) => current + 1), 1e3);
3082
3067
  return () => clearInterval(timer);
3083
3068
  }, []);
3084
- return formatElapsed(seconds2);
3069
+ return formatElapsed(seconds);
3085
3070
  }
3086
3071
 
3087
3072
  // packages/experience-design-system-cli/src/tui/import/shared/running-step/running-step.tsx
@@ -15268,8 +15253,8 @@ function retryAfterMs(response) {
15268
15253
  const value = response.headers?.get("retry-after")?.trim();
15269
15254
  if (!value)
15270
15255
  return void 0;
15271
- const seconds2 = Number(value);
15272
- const delayMs = Number.isFinite(seconds2) ? seconds2 * 1e3 : Date.parse(value) - Date.now();
15256
+ const seconds = Number(value);
15257
+ const delayMs = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(value) - Date.now();
15273
15258
  if (!Number.isFinite(delayMs) || delayMs < 0 || delayMs > MAX_RETRY_AFTER_MS)
15274
15259
  return void 0;
15275
15260
  return Math.round(delayMs);
@@ -17417,10 +17402,10 @@ async function readCandidateFiles(components, extraFiles = []) {
17417
17402
  async function selectCompositionPromptFiles(components, sourceFiles) {
17418
17403
  const allFiles = await readCandidateFiles(components, sourceFiles);
17419
17404
  const selectedCandidates = selectCandidateFiles(allFiles).map((c2) => ({ path: c2.path, content: c2.content }));
17420
- const capped3 = capCandidatesToPromptBudget(selectedCandidates);
17421
- const promptFiles = capped3.kept;
17405
+ const capped = capCandidatesToPromptBudget(selectedCandidates);
17406
+ const promptFiles = capped.kept;
17422
17407
  const runtimeFiles = allFiles.map((c2) => ({ path: c2.path, content: c2.content }));
17423
- 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;
17408
+ const droppedWarning = capped.dropped.length > 0 ? `composition \u2014 ${capped.dropped.length} candidate file(s) omitted from the agent prompt to fit the context budget; resolution runs on the ${promptFiles.length} highest-value files.` : void 0;
17424
17409
  return { promptFiles, runtimeFiles, droppedWarning };
17425
17410
  }
17426
17411
 
@@ -18172,9 +18157,8 @@ function PathValidationScreen({
18172
18157
  }
18173
18158
 
18174
18159
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
18175
- import { useEffect as useEffect8, useRef as useRef5, useState as useState9 } from "react";
18160
+ import { useRef as useRef5, useState as useState9 } from "react";
18176
18161
  import { Box as Box14, Text as Text14, useInput as useInput11 } from "ink";
18177
- init_debug_store();
18178
18162
 
18179
18163
  // packages/experience-design-system-cli/src/tui/shared/components/FieldForm.tsx
18180
18164
  import { useState as useState8 } from "react";
@@ -18351,39 +18335,6 @@ function FieldForm({
18351
18335
  ] });
18352
18336
  }
18353
18337
 
18354
- // packages/experience-design-system-cli/src/tui/shared/debug-trail.ts
18355
- init_config();
18356
- import { existsSync as existsSync9 } from "node:fs";
18357
- function diffSnapshots(before, after) {
18358
- const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
18359
- const changed_fields = names.filter((name) => before[name] !== after[name]);
18360
- return { changed: changed_fields.length > 0, changed_fields };
18361
- }
18362
- var DEFAULT_TRAIL_LIMIT = 30;
18363
- function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
18364
- const actions = [];
18365
- return {
18366
- record(action) {
18367
- actions.push(action);
18368
- if (actions.length > limit) actions.shift();
18369
- },
18370
- entries: () => [...actions]
18371
- };
18372
- }
18373
- var MIN_SECRET_LENGTH = 6;
18374
- function scrubError(error, secrets) {
18375
- let message = error instanceof Error ? error.message : String(error);
18376
- for (const secret of secrets) {
18377
- if (secret.length < MIN_SECRET_LENGTH) continue;
18378
- for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
18379
- }
18380
- return message;
18381
- }
18382
- function describeSettingsFile() {
18383
- const path5 = configFilePath();
18384
- return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync9(path5) };
18385
- }
18386
-
18387
18338
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
18388
18339
  var FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
18389
18340
  function credentialsPurpose(tokensOnly) {
@@ -18398,36 +18349,12 @@ function normalize(values) {
18398
18349
  host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
18399
18350
  };
18400
18351
  }
18401
- function missingFields(values) {
18402
- return ["spaceId", "environmentId", "cmaToken"].filter((field) => values[field] === "");
18352
+ function missingField(values) {
18353
+ return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
18403
18354
  }
18404
18355
  function isUnchanged(current, initial) {
18405
18356
  return FIELDS.every((field) => current[field] === initial[field]);
18406
18357
  }
18407
- function rejectedAttempt(reason, credentials) {
18408
- return { host: credentials.host, reason: scrubError(reason, [credentials.cmaToken]) };
18409
- }
18410
- function credentialsLog(credentials) {
18411
- return {
18412
- space_id: credentials.spaceId,
18413
- environment_id: credentials.environmentId,
18414
- host: credentials.host,
18415
- cma_token: credentials.cmaToken
18416
- };
18417
- }
18418
- function credentialsOutputs({
18419
- outcome,
18420
- credentials,
18421
- initial,
18422
- attempts
18423
- }) {
18424
- return {
18425
- outcome,
18426
- ...credentialsLog(credentials),
18427
- changed_fields: diffSnapshots(initial, credentials).changed_fields,
18428
- rejected_attempts: attempts
18429
- };
18430
- }
18431
18358
 
18432
18359
  // packages/experience-design-system-cli/src/tui/user-agent.ts
18433
18360
  init_version();
@@ -18475,9 +18402,7 @@ var MENU = [
18475
18402
  { choice: "continue", label: "Continue", description: "Check the credentials and go on" },
18476
18403
  { choice: "edit", label: "Edit", description: "Change the credentials" }
18477
18404
  ];
18478
- var MAX_LOGGED_ATTEMPTS2 = 10;
18479
18405
  function CredentialsScreen({
18480
- mode,
18481
18406
  onDone,
18482
18407
  onBack,
18483
18408
  initial = {},
@@ -18500,64 +18425,17 @@ function CredentialsScreen({
18500
18425
  const [focus, setFocus] = useState9(0);
18501
18426
  const [active, setActive] = useState9(0);
18502
18427
  const [beforeEdit, setBeforeEdit] = useState9(initialValues);
18503
- const visit = useRef5({ attempts: [], lastReason: "" }).current;
18504
- useEffect8(() => {
18505
- startDebugRun({
18506
- flow: "import/credentials",
18507
- step: "04-credentials",
18508
- menuOption: "Credentials",
18509
- inputs: { import_mode: mode, prefilled, ...credentialsLog(initialValues) }
18510
- });
18511
- }, []);
18512
- const reject = (attempt, text) => {
18513
- if (visit.attempts.length < MAX_LOGGED_ATTEMPTS2) visit.attempts.push(attempt);
18514
- visit.lastReason = attempt.reason;
18515
- setNotice({ kind: "error", text });
18516
- };
18517
- const leave = () => {
18518
- void finishDebugRun({
18519
- outputs: {
18520
- ...credentialsOutputs({
18521
- outcome: "back",
18522
- credentials: normalize(values),
18523
- initial: initialValues,
18524
- attempts: visit.attempts
18525
- }),
18526
- ...notice ? { error: visit.lastReason } : {}
18527
- },
18528
- status: notice ? "error" : "success",
18529
- exitMethod: "discarded"
18530
- });
18531
- onBack();
18532
- };
18533
18428
  const submit = async () => {
18534
18429
  const credentials = normalize(values);
18535
- const missing = missingFields(credentials);
18536
- if (missing.length > 0) {
18537
- reject(
18538
- rejectedAttempt(`Missing required fields: ${missing.join(", ")}`, credentials),
18539
- "Space ID, environment and CMA token are all required."
18540
- );
18430
+ if (missingField(credentials)) {
18431
+ setNotice({ kind: "error", text: "Space ID, environment and CMA token are all required." });
18541
18432
  return;
18542
18433
  }
18543
18434
  setValidating(true);
18544
18435
  const result = await validate3(credentials);
18545
18436
  setValidating(false);
18546
- if (!result.ok) {
18547
- reject(rejectedAttempt(result.error, credentials), result.error);
18548
- return;
18549
- }
18550
- void finishDebugRun({
18551
- outputs: credentialsOutputs({
18552
- outcome: "validated",
18553
- credentials,
18554
- initial: initialValues,
18555
- attempts: visit.attempts
18556
- }),
18557
- status: "success",
18558
- exitMethod: "saved"
18559
- });
18560
- onDone({ skipped: false, credentials });
18437
+ if (result.ok) onDone({ skipped: false, credentials });
18438
+ else setNotice({ kind: "error", text: result.error });
18561
18439
  };
18562
18440
  const choose = (choice) => {
18563
18441
  if (choice === "continue") void submit();
@@ -18566,7 +18444,7 @@ function CredentialsScreen({
18566
18444
  setBeforeEdit(values);
18567
18445
  setActive(0);
18568
18446
  setEditing(true);
18569
- } else leave();
18447
+ } else onBack();
18570
18448
  };
18571
18449
  const stopEditing = () => {
18572
18450
  setEditing(false);
@@ -18576,7 +18454,7 @@ function CredentialsScreen({
18576
18454
  if (validating) return;
18577
18455
  if (editing) {
18578
18456
  if (key.escape) {
18579
- if (!prefilled) leave();
18457
+ if (!prefilled) onBack();
18580
18458
  else {
18581
18459
  setValues(beforeEdit);
18582
18460
  setNotice(null);
@@ -18684,47 +18562,6 @@ function CredentialsScreen({
18684
18562
  }
18685
18563
 
18686
18564
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts
18687
- function extractionLogInputs(input) {
18688
- const { credentials } = input;
18689
- return {
18690
- project_path: input.projectPath,
18691
- out_dir: input.outDir ?? "",
18692
- files_to_scan: input.filePaths.length,
18693
- raw_tokens_path: input.rawTokensPath,
18694
- agent: input.agent,
18695
- agent_model: input.agentModel ?? "",
18696
- prompt_overrides: input.promptOverrides,
18697
- cache: !input.noCache,
18698
- has_credentials: credentials !== null,
18699
- space_id: credentials?.spaceId ?? "",
18700
- environment_id: credentials?.environmentId ?? "",
18701
- host: credentials?.host ?? "",
18702
- cma_token: credentials?.cmaToken ?? ""
18703
- };
18704
- }
18705
- function extractionLogOutputs(result, progress, cmaToken) {
18706
- const last = progress ? { final_progress: progress } : {};
18707
- if (!result.ok) {
18708
- return {
18709
- outputs: { result: "failed", failed_step: result.step, error: scrubError(result.message, [cmaToken]), ...last },
18710
- status: "error"
18711
- };
18712
- }
18713
- const { extraction } = result;
18714
- return {
18715
- outputs: {
18716
- result: "done",
18717
- session_id: extraction.sessionId,
18718
- out_dir: extraction.outDir,
18719
- tokens_path: extraction.tokensPath,
18720
- token_count: extraction.tokenCount,
18721
- existing_entities_status: extraction.existingEntitiesStatus,
18722
- composition_phase: extraction.compositionPhase,
18723
- ...last
18724
- },
18725
- status: "success"
18726
- };
18727
- }
18728
18565
  function initialProgress(input) {
18729
18566
  return {
18730
18567
  scan: null,
@@ -18819,9 +18656,8 @@ function ExtractionScreen({ progress, agent }) {
18819
18656
  }
18820
18657
 
18821
18658
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx
18822
- import { useEffect as useEffect9, useMemo as useMemo2, useState as useState10 } from "react";
18659
+ import { useMemo as useMemo2, useState as useState10 } from "react";
18823
18660
  import { Box as Box15, Text as Text15, useInput as useInput12 } from "ink";
18824
- init_debug_store();
18825
18661
 
18826
18662
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-review/load.ts
18827
18663
  import { readFileSync as readFileSync9 } from "node:fs";
@@ -18885,31 +18721,12 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
18885
18721
  const rows = loaded.ok ? loaded.rows : [];
18886
18722
  const columns = useTerminalWidth();
18887
18723
  const [selected, setSelected] = useState10(0);
18888
- useEffect9(() => {
18889
- startDebugRun({
18890
- flow: "import/token-review",
18891
- step: "05-token-review",
18892
- menuOption: "Token review",
18893
- inputs: { import_mode: "tokens", tokens_path: tokensPath }
18894
- });
18895
- }, []);
18896
- const finish = (outcome) => {
18897
- void finishDebugRun({
18898
- outputs: { outcome, ...loaded.ok ? { tokens: rows.length } : { load_error: loaded.message } },
18899
- status: loaded.ok ? "success" : "error",
18900
- exitMethod: outcome === "continued" ? "saved" : "discarded"
18901
- });
18902
- };
18903
18724
  const move = (to) => setSelected(Math.max(0, Math.min(to, rows.length - 1)));
18904
18725
  const { start, end } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
18905
18726
  useInput12((_input, key) => {
18906
- if (key.return) {
18907
- finish("continued");
18908
- onContinue();
18909
- } else if (key.escape) {
18910
- finish("back");
18911
- onQuit();
18912
- } else if (key.upArrow) move(selected - 1);
18727
+ if (key.return) onContinue();
18728
+ else if (key.escape) onQuit();
18729
+ else if (key.upArrow) move(selected - 1);
18913
18730
  else if (key.downArrow) move(selected + 1);
18914
18731
  else if (key.pageUp) move(selected - VISIBLE_ROWS);
18915
18732
  else if (key.pageDown) move(selected + VISIBLE_ROWS);
@@ -18973,15 +18790,14 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
18973
18790
  init_config();
18974
18791
 
18975
18792
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
18976
- init_debug_store();
18977
- import { useEffect as useEffect10, useRef as useRef6, useState as useState11 } from "react";
18793
+ import { useEffect as useEffect8, useRef as useRef6, useState as useState11 } from "react";
18978
18794
 
18979
18795
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
18980
18796
  import { mkdir as mkdir8 } from "node:fs/promises";
18981
18797
  import { join as join20, resolve as resolve24 } from "node:path";
18982
18798
 
18983
18799
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
18984
- import { existsSync as existsSync10 } from "node:fs";
18800
+ import { existsSync as existsSync9 } from "node:fs";
18985
18801
  import { dirname as dirname16, join as join19, resolve as resolve22 } from "node:path";
18986
18802
  import { fileURLToPath as fileURLToPath4 } from "node:url";
18987
18803
  function findSkillPath(fileName) {
@@ -18989,7 +18805,7 @@ function findSkillPath(fileName) {
18989
18805
  let dir = thisDir;
18990
18806
  for (; ; ) {
18991
18807
  const candidate = join19(dir, "skills", fileName);
18992
- if (existsSync10(candidate)) return candidate;
18808
+ if (existsSync9(candidate)) return candidate;
18993
18809
  const parent = resolve22(dir, "..");
18994
18810
  if (parent === dir) {
18995
18811
  throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
@@ -19231,7 +19047,7 @@ async function resolveSelectionPrompt(overrides) {
19231
19047
  function useExtraction(input) {
19232
19048
  const [state2, setState] = useState11();
19233
19049
  const current = useRef6();
19234
- useEffect10(() => {
19050
+ useEffect8(() => {
19235
19051
  current.current = input;
19236
19052
  if (!input) {
19237
19053
  setState(void 0);
@@ -19244,23 +19060,10 @@ function useExtraction(input) {
19244
19060
  hasRawTokens: input.rawTokensPath !== ""
19245
19061
  })
19246
19062
  });
19247
- let lastProgress;
19248
- startDebugRun({
19249
- flow: "import/extraction",
19250
- step: "06-extraction",
19251
- menuOption: "Extraction",
19252
- inputs: extractionLogInputs(input)
19253
- });
19254
19063
  void runExtraction(input, (progress) => {
19255
- lastProgress = progress;
19256
19064
  if (current.current === input) setState({ status: "running", progress });
19257
19065
  }).then((result) => {
19258
- if (current.current !== input) return;
19259
- void finishDebugRun({
19260
- ...extractionLogOutputs(result, lastProgress, input.credentials?.cmaToken ?? ""),
19261
- exitMethod: result.ok ? "saved" : "discarded"
19262
- });
19263
- setState({ status: "done", result });
19066
+ if (current.current === input) setState({ status: "done", result });
19264
19067
  });
19265
19068
  return () => {
19266
19069
  if (current.current === input) current.current = void 0;
@@ -19270,7 +19073,7 @@ function useExtraction(input) {
19270
19073
  }
19271
19074
 
19272
19075
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-tokens-only.ts
19273
- import { useEffect as useEffect11, useRef as useRef7, useState as useState12 } from "react";
19076
+ import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
19274
19077
 
19275
19078
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run-tokens-only.ts
19276
19079
  var TOKENS_SKILL_PATH2 = findSkillPath("generate-tokens.md");
@@ -19305,7 +19108,7 @@ async function runTokensOnly(input, deps = realDeps2) {
19305
19108
  function useTokensOnly(input) {
19306
19109
  const [state2, setState] = useState12();
19307
19110
  const current = useRef7();
19308
- useEffect11(() => {
19111
+ useEffect9(() => {
19309
19112
  current.current = input;
19310
19113
  if (!input) {
19311
19114
  setState(void 0);
@@ -19323,37 +19126,9 @@ function useTokensOnly(input) {
19323
19126
  }
19324
19127
 
19325
19128
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx
19326
- init_debug_store();
19327
- import { useEffect as useEffect14, useMemo as useMemo4 } from "react";
19129
+ import { useMemo as useMemo4 } from "react";
19328
19130
  import { Box as Box25, Text as Text26 } from "ink";
19329
19131
 
19330
- // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts
19331
- var MAX_NAMES = 20;
19332
- var capped = (names) => {
19333
- const unique = [...new Set(names)];
19334
- return { count: unique.length, names: unique.slice(0, MAX_NAMES) };
19335
- };
19336
- function scopeGateLogInputs(components, tokenCount) {
19337
- const ai = { accepted: 0, rejected: 0, failed: 0, none: 0 };
19338
- for (const component of components) ai[component.aiDecision ?? "none"] += 1;
19339
- return {
19340
- components_found: components.length,
19341
- ai_suggestions: ai,
19342
- needs_review: components.filter((component) => component.needsReview === true).length,
19343
- tokens: tokenCount
19344
- };
19345
- }
19346
- function scopeGateLogOutputs(components, decisions) {
19347
- const suggested = new Map(components.map((component) => [component.name, component.aiDecision]));
19348
- return {
19349
- outcome: "continued",
19350
- accepted: new Set(decisions.accepted).size,
19351
- rejected: new Set(decisions.rejected).size,
19352
- accepted_although_ai_rejected: capped(decisions.accepted.filter((name) => suggested.get(name) === "rejected")),
19353
- not_accepted_although_ai_accepted: capped(decisions.rejected.filter((name) => suggested.get(name) === "accepted"))
19354
- };
19355
- }
19356
-
19357
19132
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/panels/tokens-column.tsx
19358
19133
  import { Box as Box17, Text as Text17 } from "ink";
19359
19134
  import figures2 from "figures";
@@ -20537,7 +20312,7 @@ function useImmediateInput(handler, enabled = true) {
20537
20312
 
20538
20313
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
20539
20314
  import { useStdout as useStdout2 } from "ink";
20540
- import { useEffect as useEffect12, useState as useState13 } from "react";
20315
+ import { useEffect as useEffect10, useState as useState13 } from "react";
20541
20316
  function readTerminalSize(stdout) {
20542
20317
  return {
20543
20318
  columns: stdout?.columns ?? 80,
@@ -20547,7 +20322,7 @@ function readTerminalSize(stdout) {
20547
20322
  function useTerminalSize() {
20548
20323
  const { stdout } = useStdout2();
20549
20324
  const [size, setSize] = useState13(() => readTerminalSize(stdout));
20550
- useEffect12(() => {
20325
+ useEffect10(() => {
20551
20326
  const updateSize = () => setSize(readTerminalSize(stdout));
20552
20327
  stdout?.on("resize", updateSize);
20553
20328
  updateSize();
@@ -20730,7 +20505,7 @@ function createSidebarViewsHelpSection(includeBreaking) {
20730
20505
  }
20731
20506
 
20732
20507
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
20733
- import { useEffect as useEffect13, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
20508
+ import { useEffect as useEffect11, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
20734
20509
 
20735
20510
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/columns.ts
20736
20511
  var TWO_COLUMN_MIN_WIDTH = 100;
@@ -21467,7 +21242,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
21467
21242
  return seed;
21468
21243
  });
21469
21244
  const seededGroupsRef = useRef9(closures.size > 0 || cycleParticipants.size > 0);
21470
- useEffect13(() => {
21245
+ useEffect11(() => {
21471
21246
  if (seededGroupsRef.current) return;
21472
21247
  if (closures.size === 0 && cycleParticipants.size === 0) return;
21473
21248
  seededGroupsRef.current = true;
@@ -21558,7 +21333,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
21558
21333
  entryCount: 0
21559
21334
  });
21560
21335
  const panelLayout = useMemo3(() => computePanelLayout(visibleCount), [visibleCount]);
21561
- useEffect13(() => {
21336
+ useEffect11(() => {
21562
21337
  setNav((prev) => {
21563
21338
  const maxIdx = Math.max(0, visibleRows.length - 1);
21564
21339
  const nextCursor = Math.min(prev.cursor, maxIdx);
@@ -21919,55 +21694,23 @@ var HELP_SECTIONS = [
21919
21694
  }
21920
21695
  ];
21921
21696
  function ScopeGateScreen(props) {
21922
- if (props.components.length === 0) return /* @__PURE__ */ jsx29(NoComponents, {});
21697
+ if (props.components.length === 0) {
21698
+ return /* @__PURE__ */ jsx29(Box25, { paddingX: 2, paddingY: 1, children: /* @__PURE__ */ jsx29(Text26, { color: PALETTE.error, children: "Error: no components found for this session \u2014 please re-run analyze extract." }) });
21699
+ }
21923
21700
  return /* @__PURE__ */ jsx29(ScopeGateView, { ...props });
21924
21701
  }
21925
- function NoComponents() {
21926
- useEffect14(() => {
21927
- startDebugRun({
21928
- flow: "import/scope-gate",
21929
- step: "07-scope-gate",
21930
- menuOption: "Scope gate",
21931
- inputs: scopeGateLogInputs([], 0)
21932
- });
21933
- void finishDebugRun({
21934
- outputs: { outcome: "nothing to decide", error: "No components were found for this session." },
21935
- status: "error",
21936
- exitMethod: "discarded"
21937
- });
21938
- }, []);
21939
- 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." }) });
21940
- }
21941
21702
  function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
21942
21703
  const tokens = useMemo4(() => {
21943
21704
  const loaded = tokensPath ? loadTokenRows(tokensPath) : void 0;
21944
21705
  return loaded?.ok ? loaded.rows : [];
21945
21706
  }, [tokensPath]);
21946
21707
  const longest = useMemo4(() => longestEntries(tokens), [tokens]);
21947
- useEffect14(() => {
21948
- startDebugRun({
21949
- flow: "import/scope-gate",
21950
- step: "07-scope-gate",
21951
- menuOption: "Scope gate",
21952
- inputs: scopeGateLogInputs(components, tokens.length)
21953
- });
21954
- }, []);
21955
21708
  const gate = useScopeGate({
21956
21709
  components,
21957
21710
  tokenCount: tokens.length,
21958
21711
  tokensWidth: longest.path + longest.value + 10,
21959
- onConfirm: (decisions) => {
21960
- void finishDebugRun({
21961
- outputs: scopeGateLogOutputs(components, decisions),
21962
- status: "success",
21963
- exitMethod: "saved"
21964
- });
21965
- onConfirm(decisions);
21966
- },
21967
- onQuit: () => {
21968
- void finishDebugRun({ outputs: { outcome: "quit" }, status: "success", exitMethod: "discarded" });
21969
- onQuit();
21970
- }
21712
+ onConfirm,
21713
+ onQuit
21971
21714
  });
21972
21715
  const { search, graph, columnPlan, panelLayout, counters } = gate;
21973
21716
  if (gate.showHelp) {
@@ -22065,8 +21808,7 @@ function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
22065
21808
  }
22066
21809
 
22067
21810
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
22068
- init_debug_store();
22069
- import { useEffect as useEffect15, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
21811
+ import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
22070
21812
 
22071
21813
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/cache-check.ts
22072
21814
  async function checkGenerationCache(input) {
@@ -22115,21 +21857,7 @@ function useScopeGateFlow(input, deps = realDeps3) {
22115
21857
  const loaded = useMemo5(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
22116
21858
  const cacheCheck = useRef10(void 0);
22117
21859
  const [confirmed, setConfirmed] = useState17();
22118
- useEffect15(() => {
22119
- if (!sessionId || !loaded || loaded.ok) return;
22120
- startDebugRun({
22121
- flow: "import/scope-gate",
22122
- step: "07-scope-gate",
22123
- menuOption: "Scope gate",
22124
- inputs: { session_id: sessionId }
22125
- });
22126
- void finishDebugRun({
22127
- outputs: { outcome: "could not load the components", error: loaded.message },
22128
- status: "error",
22129
- exitMethod: "discarded"
22130
- });
22131
- }, [sessionId, loaded]);
22132
- useEffect15(() => {
21860
+ useEffect12(() => {
22133
21861
  if (!input || !loaded?.ok || cacheCheck.current) return;
22134
21862
  cacheCheck.current = deps.checkCache(input.cache);
22135
21863
  }, [input, loaded]);
@@ -22141,41 +21869,6 @@ function useScopeGateFlow(input, deps = realDeps3) {
22141
21869
  }
22142
21870
 
22143
21871
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/logic.ts
22144
- function generationLogInputs(input) {
22145
- return {
22146
- session_id: input.sessionId,
22147
- accepted: input.decisions.accepted.length,
22148
- rejected: input.decisions.rejected.length,
22149
- tokens_path: input.tokensPath,
22150
- token_session_id: input.tokenSessionId,
22151
- existing_entities_path: input.existingEntitiesPath,
22152
- agent: input.agent,
22153
- agent_model: input.agentModel ?? "",
22154
- prompt_overrides: input.promptOverrides,
22155
- generate_prompt_path: input.generatePromptPath ?? "",
22156
- cache: !input.noCache,
22157
- has_tokens: input.hasTokens
22158
- };
22159
- }
22160
- function generationLogOutputs(result, progress) {
22161
- const last = progress ? { final_progress: progress } : {};
22162
- if (!result.ok) {
22163
- return { outputs: { result: "failed", failed_step: result.step, error: result.message, ...last }, status: "error" };
22164
- }
22165
- const { generation } = result;
22166
- return {
22167
- outputs: generation.route === "review" ? {
22168
- result: "done",
22169
- route: generation.route,
22170
- session_id: generation.sessionId,
22171
- accepted: generation.acceptedCount,
22172
- generated: generation.generatedCount,
22173
- map_tokens_eligible: generation.mapTokensEligible,
22174
- ...last
22175
- } : { result: "done", route: generation.route, accepted: generation.acceptedCount, ...last },
22176
- status: "success"
22177
- };
22178
- }
22179
21872
  function initialProgress2() {
22180
21873
  return { components: null, mapTokens: "idle", mapTokensEligible: null };
22181
21874
  }
@@ -22231,8 +21924,7 @@ function GenerationScreen({
22231
21924
  }
22232
21925
 
22233
21926
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
22234
- init_debug_store();
22235
- import { useEffect as useEffect16, useRef as useRef11, useState as useState18 } from "react";
21927
+ import { useEffect as useEffect13, useRef as useRef11, useState as useState18 } from "react";
22236
21928
 
22237
21929
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
22238
21930
  import { resolve as resolve25 } from "node:path";
@@ -22398,30 +22090,17 @@ function applyProgressEvent2(event, previous, total) {
22398
22090
  function useGeneration(input) {
22399
22091
  const [state2, setState] = useState18();
22400
22092
  const current = useRef11();
22401
- useEffect16(() => {
22093
+ useEffect13(() => {
22402
22094
  current.current = input;
22403
22095
  if (!input) {
22404
22096
  setState(void 0);
22405
22097
  return;
22406
22098
  }
22407
22099
  setState({ status: "running", progress: initialProgress2() });
22408
- let lastProgress;
22409
- startDebugRun({
22410
- flow: "import/generation",
22411
- step: "08-generation",
22412
- menuOption: "Generation",
22413
- inputs: generationLogInputs(input)
22414
- });
22415
22100
  void runGeneration(input, (progress) => {
22416
- lastProgress = progress;
22417
22101
  if (current.current === input) setState({ status: "running", progress });
22418
22102
  }).then((result) => {
22419
- if (current.current !== input) return;
22420
- void finishDebugRun({
22421
- ...generationLogOutputs(result, lastProgress),
22422
- exitMethod: result.ok ? "saved" : "discarded"
22423
- });
22424
- setState({ status: "done", result });
22103
+ if (current.current === input) setState({ status: "done", result });
22425
22104
  });
22426
22105
  return () => {
22427
22106
  if (current.current === input) current.current = void 0;
@@ -22892,7 +22571,7 @@ function PreviewValidationErrorScreen({
22892
22571
  }
22893
22572
 
22894
22573
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
22895
- import { useCallback as useCallback5, useEffect as useEffect24, useMemo as useMemo6, useRef as useRef17, useState as useState26 } from "react";
22574
+ import { useCallback as useCallback5, useEffect as useEffect20, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
22896
22575
  import figures8 from "figures";
22897
22576
 
22898
22577
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/review-json-panel.ts
@@ -23153,7 +22832,7 @@ function enumerateCycleBreaks(cycle, components) {
23153
22832
  import { Box as Box32, Text as Text34 } from "ink";
23154
22833
 
23155
22834
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
23156
- import React13, { useEffect as useEffect17, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
22835
+ import React13, { useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
23157
22836
  import figures6 from "figures";
23158
22837
  import { Box as Box26, measureElement, Text as Text27 } from "ink";
23159
22838
 
@@ -24711,7 +24390,7 @@ function FieldEditor({
24711
24390
  }
24712
24391
  return Math.max(start + 1, end2);
24713
24392
  };
24714
- useEffect17(() => {
24393
+ useEffect14(() => {
24715
24394
  if (focusLevel === "field" || selectedRowIdx < 0) return;
24716
24395
  setListScrollStart((previous) => {
24717
24396
  if (initialFocusTarget && !initialFocusScrollApplied.current) {
@@ -25783,7 +25462,7 @@ function finalizeReviewSession(extractSessionId, components) {
25783
25462
  }
25784
25463
 
25785
25464
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
25786
- import { useCallback as useCallback2, useEffect as useEffect19, useRef as useRef13, useState as useState21 } from "react";
25465
+ import { useCallback as useCallback2, useEffect as useEffect16, useRef as useRef13, useState as useState21 } from "react";
25787
25466
 
25788
25467
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/history.ts
25789
25468
  var DEFAULT_MAX_DEPTH = 50;
@@ -25839,7 +25518,7 @@ function createHistoryStack(seed, maxDepth = DEFAULT_MAX_DEPTH) {
25839
25518
  }
25840
25519
 
25841
25520
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
25842
- import { useEffect as useEffect18, useRef as useRef12, useState as useState20 } from "react";
25521
+ import { useEffect as useEffect15, useRef as useRef12, useState as useState20 } from "react";
25843
25522
 
25844
25523
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/run-live-preview.ts
25845
25524
  var TimeoutError = class extends Error {
@@ -25999,7 +25678,7 @@ function useFinalizePreview(opts) {
25999
25678
  const [scrollOffset, setScrollOffset] = useState20(0);
26000
25679
  const generationRef = useRef12(0);
26001
25680
  const acceptedKey = [...acceptedKeys].sort().join("\0");
26002
- useEffect18(() => {
25681
+ useEffect15(() => {
26003
25682
  if (!open) {
26004
25683
  setStatus("idle");
26005
25684
  setRemoved([]);
@@ -26062,7 +25741,7 @@ function useReviewSession({
26062
25741
  }));
26063
25742
  return { result, catalog };
26064
25743
  }, [loadSession, tokensPath]);
26065
- useEffect19(() => {
25744
+ useEffect16(() => {
26066
25745
  let disposed = false;
26067
25746
  void (async () => {
26068
25747
  try {
@@ -26115,7 +25794,7 @@ function useReviewSession({
26115
25794
  function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
26116
25795
  const [reviewMetadata, setReviewMetadata] = useState21(null);
26117
25796
  const [componentRationale, setComponentRationale] = useState21(null);
26118
- useEffect19(() => {
25797
+ useEffect16(() => {
26119
25798
  const current = components[selectedIdx];
26120
25799
  if (!current) {
26121
25800
  setReviewMetadata(null);
@@ -26144,16 +25823,10 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
26144
25823
  }, [components, extractSessionId, selectedIdx]);
26145
25824
  return { reviewMetadata, componentRationale };
26146
25825
  }
26147
- function useReviewHistory({
26148
- loading,
26149
- components,
26150
- createSnapshot,
26151
- applySnapshot,
26152
- onAction
26153
- }) {
25826
+ function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
26154
25827
  const historyRef = useRef13(null);
26155
25828
  const historySeededRef = useRef13(false);
26156
- useEffect19(() => {
25829
+ useEffect16(() => {
26157
25830
  if (loading || historySeededRef.current) return;
26158
25831
  historySeededRef.current = true;
26159
25832
  historyRef.current = createHistoryStack(createSnapshot(components));
@@ -26161,19 +25834,14 @@ function useReviewHistory({
26161
25834
  const pushHistorySnapshot = (entries, label) => {
26162
25835
  if (!historyRef.current) return;
26163
25836
  historyRef.current.push(createSnapshot(entries), label);
26164
- onAction?.(label);
26165
25837
  };
26166
25838
  const handleUndo = () => {
26167
25839
  const snapshot = historyRef.current?.undo();
26168
- if (!snapshot) return;
26169
- applySnapshot(snapshot);
26170
- onAction?.("undo");
25840
+ if (snapshot) applySnapshot(snapshot);
26171
25841
  };
26172
25842
  const handleRedo = () => {
26173
25843
  const snapshot = historyRef.current?.redo();
26174
- if (!snapshot) return;
26175
- applySnapshot(snapshot);
26176
- onAction?.("redo");
25844
+ if (snapshot) applySnapshot(snapshot);
26177
25845
  };
26178
25846
  const resetHistory = (snapshot) => {
26179
25847
  historyRef.current?.reset(snapshot);
@@ -26209,7 +25877,7 @@ function useReviewFinalize({
26209
25877
  }
26210
25878
 
26211
25879
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
26212
- import { useEffect as useEffect20, useRef as useRef14, useState as useState22 } from "react";
25880
+ import { useEffect as useEffect17, useRef as useRef14, useState as useState22 } from "react";
26213
25881
 
26214
25882
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/token-suggestions.ts
26215
25883
  function collectTokenSuggestions(entry, availableTokens = []) {
@@ -26262,7 +25930,7 @@ function useReviewEditor({
26262
25930
  const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState22(/* @__PURE__ */ new Set());
26263
25931
  const tokenReviewSuggestedRef = useRef14(/* @__PURE__ */ new Map());
26264
25932
  const pendingGRef = useRef14(false);
26265
- useEffect20(() => {
25933
+ useEffect17(() => {
26266
25934
  setTokenReviewRow(0);
26267
25935
  setTokenReviewEditing(false);
26268
25936
  setTokenReviewEditCursor(0);
@@ -26674,7 +26342,7 @@ function handleJsonPanelInput(input, key, state2) {
26674
26342
  }
26675
26343
 
26676
26344
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
26677
- import { useCallback as useCallback4, useEffect as useEffect22, useState as useState25 } from "react";
26345
+ import { useCallback as useCallback4, useEffect as useEffect19, useState as useState25 } from "react";
26678
26346
 
26679
26347
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/preview-annotations.ts
26680
26348
  function applyPreviewAnnotations(preview, localNames) {
@@ -26709,7 +26377,7 @@ function applyPreviewAnnotations(preview, localNames) {
26709
26377
  }
26710
26378
 
26711
26379
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
26712
- import { useCallback as useCallback3, useEffect as useEffect21, useRef as useRef15, useState as useState24 } from "react";
26380
+ import { useCallback as useCallback3, useEffect as useEffect18, useRef as useRef15, useState as useState24 } from "react";
26713
26381
  var DEFAULT_DEBOUNCE_MS = 500;
26714
26382
  function useLivePreview(opts) {
26715
26383
  const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
@@ -26720,14 +26388,14 @@ function useLivePreview(opts) {
26720
26388
  const latestRef = useRef15(0);
26721
26389
  const inflightRef = useRef15(0);
26722
26390
  const optsRef = useRef15(opts);
26723
- useEffect21(() => {
26391
+ useEffect18(() => {
26724
26392
  optsRef.current = opts;
26725
26393
  });
26726
26394
  const disabledRef = useRef15(disabled);
26727
- useEffect21(() => {
26395
+ useEffect18(() => {
26728
26396
  disabledRef.current = disabled;
26729
26397
  }, [disabled]);
26730
- useEffect21(() => {
26398
+ useEffect18(() => {
26731
26399
  return () => {
26732
26400
  if (timerRef.current) {
26733
26401
  clearTimeout(timerRef.current);
@@ -26841,13 +26509,13 @@ function useReviewPreview({
26841
26509
  deleteAllComponents
26842
26510
  });
26843
26511
  const [spinnerTick, setSpinnerTick] = useState25(0);
26844
- useEffect22(() => {
26512
+ useEffect19(() => {
26845
26513
  if (livePreviewHook.status !== "running") return;
26846
26514
  const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
26847
26515
  return () => clearInterval(id);
26848
26516
  }, [livePreviewHook.status]);
26849
26517
  const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
26850
- useEffect22(() => {
26518
+ useEffect19(() => {
26851
26519
  if (loading) return;
26852
26520
  if (!livePreview) return;
26853
26521
  if (components.length === 0) return;
@@ -26856,117 +26524,6 @@ function useReviewPreview({
26856
26524
  return { previewAnnotations, removedComponents, livePreviewHook, livePreviewSpinner };
26857
26525
  }
26858
26526
 
26859
- // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-log.ts
26860
- init_debug_store();
26861
- import { useEffect as useEffect23, useRef as useRef16 } from "react";
26862
-
26863
- // packages/experience-design-system-cli/src/tui/import/steps/09-review/review-log.ts
26864
- var REVIEW_RUN = { flow: "import/review", step: "09-review", menuOption: "Review" };
26865
- var MAX_ACTIONS = 30;
26866
- var MAX_NAMES2 = 20;
26867
- var countStatuses = (components) => {
26868
- const counts = {};
26869
- for (const { status } of components) counts[status] = (counts[status] ?? 0) + 1;
26870
- return counts;
26871
- };
26872
- var capped2 = (keys) => ({
26873
- count: keys.length,
26874
- keys: keys.slice(0, MAX_NAMES2)
26875
- });
26876
- function reviewInputs(components) {
26877
- return { components: components.length, by_status: countStatuses(components) };
26878
- }
26879
- function openReviewTrail(components, now) {
26880
- return {
26881
- startedAt: now,
26882
- start: new Map(components.map((component) => [component.key, component.status])),
26883
- actions: [],
26884
- kinds: {}
26885
- };
26886
- }
26887
- function recordReviewAction(trail, label) {
26888
- const kind = label.split(":")[0] ?? label;
26889
- trail.kinds[kind] = (trail.kinds[kind] ?? 0) + 1;
26890
- if (trail.actions.length < MAX_ACTIONS) trail.actions.push(label);
26891
- }
26892
- function render(trail, components, now, outcome) {
26893
- const acceptedByUser = [];
26894
- const rejectedByUser = [];
26895
- for (const { key, status } of components) {
26896
- const was = trail.start.get(key);
26897
- if (was === status) continue;
26898
- if (status === "accepted") acceptedByUser.push(key);
26899
- if (status === "rejected") rejectedByUser.push(key);
26900
- }
26901
- const total = Object.values(trail.kinds).reduce((sum, count) => sum + count, 0);
26902
- return {
26903
- outcome,
26904
- seconds: Math.round((now - trail.startedAt) / 100) / 10,
26905
- edits: { total, by_kind: trail.kinds, in_order: trail.actions },
26906
- now: countStatuses(components),
26907
- accepted_by_user: capped2(acceptedByUser),
26908
- rejected_by_user: capped2(rejectedByUser)
26909
- };
26910
- }
26911
- function reviewProgress(trail, components, now) {
26912
- return render(trail, components, now, "interrupted");
26913
- }
26914
- function reviewFinish(trail, components, now, final) {
26915
- const outcome = final ? `finalized: ${final.accepted} accepted, ${final.rejected} rejected, ${final.unresolved} unresolved` : "left the review without finishing";
26916
- return {
26917
- outputs: render(trail, components, now, outcome),
26918
- status: "success",
26919
- exitMethod: final ? "saved" : "discarded"
26920
- };
26921
- }
26922
-
26923
- // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-log.ts
26924
- function useReviewLog({
26925
- loading,
26926
- loadError,
26927
- components
26928
- }) {
26929
- const trail = useRef16(void 0);
26930
- const started = useRef16(false);
26931
- const latest = useRef16(components);
26932
- latest.current = components;
26933
- useEffect23(() => {
26934
- if (loading || started.current) return;
26935
- started.current = true;
26936
- startDebugRun({ ...REVIEW_RUN, inputs: reviewInputs(components) });
26937
- if (loadError) {
26938
- void finishDebugRun({
26939
- outputs: { outcome: "could not load the components", error: loadError },
26940
- status: "error",
26941
- exitMethod: "discarded"
26942
- });
26943
- return;
26944
- }
26945
- trail.current = openReviewTrail(components, Date.now());
26946
- setDebugRunProgress(reviewProgress(trail.current, components, Date.now()));
26947
- }, [loading, loadError, components]);
26948
- useEffect23(
26949
- () => () => {
26950
- const open = trail.current;
26951
- trail.current = void 0;
26952
- if (open) void finishDebugRun(reviewFinish(open, latest.current, Date.now(), void 0));
26953
- },
26954
- []
26955
- );
26956
- return {
26957
- record: (label) => {
26958
- if (!trail.current) return;
26959
- recordReviewAction(trail.current, label);
26960
- setDebugRunProgress(reviewProgress(trail.current, latest.current, Date.now()));
26961
- },
26962
- finish: (counts) => {
26963
- const open = trail.current;
26964
- trail.current = void 0;
26965
- if (open) void finishDebugRun(reviewFinish(open, latest.current, Date.now(), counts));
26966
- }
26967
- };
26968
- }
26969
-
26970
26527
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/LivePreviewSummary.tsx
26971
26528
  import { Box as Box37, Text as Text39 } from "ink";
26972
26529
  import { jsx as jsx47, jsxs as jsxs37 } from "react/jsx-runtime";
@@ -27254,7 +26811,6 @@ function GenerateReviewStepView({
27254
26811
  tokensPath,
27255
26812
  onExtraLoaded: setLoadedSlotCycles
27256
26813
  });
27257
- const reviewLog = useReviewLog({ loading, loadError, components });
27258
26814
  const [nav, setNav] = useState26({
27259
26815
  cursorRowIdx: 0,
27260
26816
  sidebarScrollOffset: 0
@@ -27272,7 +26828,7 @@ function GenerateReviewStepView({
27272
26828
  setFinalizeError
27273
26829
  } = reviewSurface;
27274
26830
  const [removedBannerCollapsed, setRemovedBannerCollapsed] = useState26(false);
27275
- const removedBannerDefaultedRef = useRef17(false);
26831
+ const removedBannerDefaultedRef = useRef16(false);
27276
26832
  const [cyclePanelScroll, setCyclePanelScroll] = useState26(0);
27277
26833
  const [cyclesCursor, setCyclesCursor] = useState26(0);
27278
26834
  const cyclePanel = useOverlayPanel({
@@ -27292,7 +26848,7 @@ function GenerateReviewStepView({
27292
26848
  const [breakCursor, setBreakCursor] = useState26(0);
27293
26849
  const [breakConfirm, setBreakConfirm] = useState26(false);
27294
26850
  const [expandedGroups, setExpandedGroups] = useState26(/* @__PURE__ */ new Set());
27295
- const seededGroupsRef = useRef17(false);
26851
+ const seededGroupsRef = useRef16(false);
27296
26852
  const {
27297
26853
  searchOpen,
27298
26854
  setSearchOpen,
@@ -27316,7 +26872,7 @@ function GenerateReviewStepView({
27316
26872
  const [pendingEditorFocus, setPendingEditorFocus] = useState26(null);
27317
26873
  const [autoRejected, setAutoRejected] = useState26([]);
27318
26874
  const [undoSnapshot, setUndoSnapshot] = useState26(null);
27319
- const autoRejectFiredRef = useRef17(false);
26875
+ const autoRejectFiredRef = useRef16(false);
27320
26876
  const [showReloadDialog, setShowReloadDialog] = useState26(false);
27321
26877
  const acceptedCountForPreview = components.filter((c2) => c2.status === "accepted").length;
27322
26878
  const { previewAnnotations, removedComponents, livePreviewHook, livePreviewSpinner } = useReviewPreview({
@@ -27348,10 +26904,7 @@ function GenerateReviewStepView({
27348
26904
  cmaToken,
27349
26905
  host,
27350
26906
  components,
27351
- onFinalize: (accepted, rejected, unresolved) => {
27352
- reviewLog.finish({ accepted, rejected, unresolved });
27353
- onFinalize(accepted, rejected, unresolved);
27354
- }
26907
+ onFinalize
27355
26908
  });
27356
26909
  const recomputeCycles = (currentComponents) => {
27357
26910
  try {
@@ -27382,7 +26935,7 @@ function GenerateReviewStepView({
27382
26935
  [components]
27383
26936
  );
27384
26937
  const closures = useMemo6(() => computeAllClosures(componentGraph), [componentGraph]);
27385
- useEffect24(() => {
26938
+ useEffect20(() => {
27386
26939
  if (seededGroupsRef.current) return;
27387
26940
  if (closures.size === 0 && slotCycles.length === 0) return;
27388
26941
  seededGroupsRef.current = true;
@@ -27409,7 +26962,7 @@ function GenerateReviewStepView({
27409
26962
  suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
27410
26963
  }));
27411
26964
  }, [slotCycles, cycleView]);
27412
- useEffect24(() => {
26965
+ useEffect20(() => {
27413
26966
  const decision = computeAutoRejectDecision({
27414
26967
  loading,
27415
26968
  autoRejectFired: autoRejectFiredRef.current,
@@ -27450,11 +27003,10 @@ function GenerateReviewStepView({
27450
27003
  autoRejected,
27451
27004
  undoSnapshot
27452
27005
  }),
27453
- applySnapshot: applyHistorySnapshot,
27454
- onAction: reviewLog.record
27006
+ applySnapshot: applyHistorySnapshot
27455
27007
  });
27456
- const autoRejectPushedRef = useRef17(false);
27457
- useEffect24(() => {
27008
+ const autoRejectPushedRef = useRef16(false);
27009
+ useEffect20(() => {
27458
27010
  if (loading) return;
27459
27011
  if (!historySeededRef.current) return;
27460
27012
  if (!autoRejectFiredRef.current) return;
@@ -27538,7 +27090,7 @@ function GenerateReviewStepView({
27538
27090
  const panelHeight = leftPanelHeight + 2;
27539
27091
  const panelContentHeight = Math.max(1, panelHeight - 3);
27540
27092
  const cycleViewportHeight = Math.max(1, panelHeight - 4);
27541
- useEffect24(() => {
27093
+ useEffect20(() => {
27542
27094
  if (selectableRowPositions.length === 0) return;
27543
27095
  const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
27544
27096
  const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
@@ -28483,10 +28035,10 @@ function normalizePath(input) {
28483
28035
  }
28484
28036
 
28485
28037
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
28486
- import { useEffect as useEffect25, useState as useState27 } from "react";
28038
+ import { useEffect as useEffect21, useState as useState27 } from "react";
28487
28039
  function useBlinkingCursor() {
28488
28040
  const [visible, setVisible] = useState27(true);
28489
- useEffect25(() => {
28041
+ useEffect21(() => {
28490
28042
  const interval = setInterval(() => setVisible((current) => !current), 500);
28491
28043
  return () => clearInterval(interval);
28492
28044
  }, []);
@@ -28602,12 +28154,12 @@ function countedThings({ components, tokens }, counts = {}) {
28602
28154
  }
28603
28155
 
28604
28156
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
28605
- import { useEffect as useEffect26, useState as useState29 } from "react";
28157
+ import { useEffect as useEffect22, useState as useState29 } from "react";
28606
28158
  import { Spinner as Spinner2 } from "@inkjs/ui";
28607
28159
  import { jsx as jsx53 } from "react/jsx-runtime";
28608
28160
  function useTimedSpinner() {
28609
28161
  const [elapsedSeconds, setElapsedSeconds] = useState29(0);
28610
- useEffect26(() => {
28162
+ useEffect22(() => {
28611
28163
  const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
28612
28164
  return () => {
28613
28165
  clearInterval(timer);
@@ -28665,7 +28217,7 @@ function PushingStep({ progress, produced, counts }) {
28665
28217
  }
28666
28218
 
28667
28219
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
28668
- import { useEffect as useEffect27, useState as useState30, useMemo as useMemo7 } from "react";
28220
+ import { useEffect as useEffect23, useState as useState30, useMemo as useMemo7 } from "react";
28669
28221
  import { Box as Box44, Text as Text46 } from "ink";
28670
28222
 
28671
28223
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/preview-diff.ts
@@ -29060,7 +28612,7 @@ function WizardPreviewStep({
29060
28612
  const activeLines = diffExpanded ? diffLines : summaryLines;
29061
28613
  const maxScroll = Math.max(0, activeLines.length - viewportHeight);
29062
28614
  const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
29063
- useEffect27(() => {
28615
+ useEffect23(() => {
29064
28616
  setScrollOffset((previous) => Math.min(previous, maxScroll));
29065
28617
  }, [maxScroll]);
29066
28618
  useImmediateInput((input, key) => {
@@ -29150,194 +28702,6 @@ function buildRunTeaserLine(runId) {
29150
28702
  return `Run saved as ${runId}.`;
29151
28703
  }
29152
28704
 
29153
- // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
29154
- init_debug_store();
29155
- import { useEffect as useEffect28, useRef as useRef18 } from "react";
29156
-
29157
- // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts
29158
- var FLOW_RUN = { flow: "import/publish", step: "10-publish", menuOption: "Publish" };
29159
- var LABELS = {
29160
- "final-review": "Final review",
29161
- "path-prompt": "Save path",
29162
- printing: "Save files",
29163
- previewing: "Preview",
29164
- "preview-gate": "Preview confirmation",
29165
- pushing: "Push",
29166
- "print-gate": "Files saved",
29167
- done: "Done",
29168
- error: "Error",
29169
- "preview-validation-error": "Preview validation"
29170
- };
29171
- var WORK = ["printing", "previewing", "pushing"];
29172
- var FINISHED = ["done", "error", "preview-validation-error", "final-review"];
29173
- var MAX_LOGGED = 10;
29174
- var MAX_OUTCOME = 200;
29175
- var scrub = (text, state2) => scrubError(text, [state2.cmaToken]);
29176
- var seconds = (ms) => Math.round(ms / 100) / 10;
29177
- var pushHasFailures = (result) => result.componentTypes.failed + result.designTokens.failed > 0 || (result.failures?.length ?? 0) > 0 || (result.summary?.failed ?? 0) > 0;
29178
- function previewSummary(preview) {
29179
- const counts = (group) => ({
29180
- new: group.new.length,
29181
- changed: group.changed.length,
29182
- removed: group.removed.length
29183
- });
29184
- return {
29185
- components: counts(preview.components),
29186
- tokens: counts(preview.tokens),
29187
- breaking_components: preview.components.changed.filter(
29188
- (entry) => entry.changeClassification?.classification === "breaking"
29189
- ).length
29190
- };
29191
- }
29192
- function pushSummary(result, state2) {
29193
- const failures = result.failures ?? [];
29194
- return {
29195
- component_types: result.componentTypes,
29196
- design_tokens: result.designTokens,
29197
- ...result.summary ? { summary: result.summary } : {},
29198
- ...failures.length > 0 ? {
29199
- failure_count: failures.length,
29200
- failures: failures.slice(0, MAX_LOGGED).map((failure) => ({
29201
- entity_type: failure.entityType,
29202
- entity_id: failure.entityId,
29203
- message: scrub(failure.message, state2)
29204
- }))
29205
- } : {}
29206
- };
29207
- }
29208
- function flowContext(state2) {
29209
- return {
29210
- agent: state2.agent,
29211
- space_id: state2.spaceId,
29212
- environment_id: state2.environmentId,
29213
- host: state2.host,
29214
- credentials_skipped: state2.credentialsSkipped,
29215
- components_generated: state2.generatedCount,
29216
- components_accepted: state2.generatedAcceptedCount,
29217
- tokens: state2.tokenCount,
29218
- cma_token: state2.cmaToken
29219
- };
29220
- }
29221
- function arrive(trail, state2) {
29222
- const next = { ...trail, at: state2.step };
29223
- if (state2.step === "error") {
29224
- next.failure = { step: state2.errorStep, message: scrub(state2.errorMessage, state2) };
29225
- }
29226
- if (state2.step === "preview-validation-error") {
29227
- next.validation = {
29228
- count: state2.previewValidationErrors.length,
29229
- errors: state2.previewValidationErrors.slice(0, MAX_LOGGED).map((error) => ({
29230
- component: error.componentName,
29231
- path: error.path,
29232
- message: scrub(error.message, state2)
29233
- })),
29234
- missing_names: state2.previewValidationMissingNames.slice(0, MAX_LOGGED * 2)
29235
- };
29236
- }
29237
- return next;
29238
- }
29239
- function openTrail(state2, now) {
29240
- return arrive({ startedAt: now, stageStartedAt: now, at: state2.step, stages: [] }, state2);
29241
- }
29242
- function advance(trail, from, to, now) {
29243
- const next = { ...trail, stages: [...trail.stages], stageStartedAt: now };
29244
- const failed = to.step === "error" || to.step === "preview-validation-error" || from.step === "pushing" && pushHasFailures(to.pushResult);
29245
- if (WORK.includes(from.step)) {
29246
- next.stages.push(`${LABELS[from.step]}: ${failed ? "failed" : "ok"} (${seconds(now - trail.stageStartedAt)}s)`);
29247
- }
29248
- if (from.step === "previewing" && to.serverPreview) next.preview = previewSummary(to.serverPreview);
29249
- if (from.step === "pushing") {
29250
- next.push = pushSummary(to.pushResult, to);
29251
- next.pushFailed = pushHasFailures(to.pushResult);
29252
- }
29253
- if (from.step === "printing" && !failed) next.saved = { path: to.componentsPath, run_id: to.lastRunId };
29254
- return arrive(next, to);
29255
- }
29256
- var isFlowFinished = (step) => FINISHED.includes(step);
29257
- function render2(trail, now, outcome) {
29258
- return {
29259
- outcome,
29260
- total_seconds: seconds(now - trail.startedAt),
29261
- stages: trail.stages,
29262
- ...trail.preview ? { preview: trail.preview } : {},
29263
- ...trail.push ? { push: trail.push } : {},
29264
- ...trail.saved ? { saved: trail.saved } : {},
29265
- ...trail.failure ? { error: trail.failure } : {},
29266
- ...trail.validation ? { preview_validation: trail.validation } : {}
29267
- };
29268
- }
29269
- function flowProgress(trail, now) {
29270
- return render2(trail, now, `interrupted at ${LABELS[trail.at]}`);
29271
- }
29272
- function flowFinish(trail, final, now) {
29273
- if (!final) {
29274
- const midWork = WORK.includes(trail.at);
29275
- const outcome2 = `left the import ${midWork ? "while" : "at"} ${LABELS[trail.at]}${midWork ? " was running" : ""}`;
29276
- return { outputs: render2(trail, now, outcome2), status: midWork ? "error" : "success", exitMethod: "discarded" };
29277
- }
29278
- if (final.step === "final-review") {
29279
- return {
29280
- outputs: render2(trail, now, "went back to edit the definitions"),
29281
- status: "success",
29282
- exitMethod: "discarded"
29283
- };
29284
- }
29285
- let outcome;
29286
- let failed = true;
29287
- if (trail.validation) {
29288
- outcome = `blocked by ${String(trail.validation["count"])} preview validation error(s)`;
29289
- } else if (trail.failure) {
29290
- outcome = `failed at ${trail.failure.step}: ${trail.failure.message.slice(0, MAX_OUTCOME)}`;
29291
- } else if (trail.pushFailed) {
29292
- outcome = "pushed, but some entities failed";
29293
- } else {
29294
- failed = false;
29295
- outcome = final.credentialsSkipped ? "saved without pushing (credentials skipped)" : "published";
29296
- }
29297
- return {
29298
- outputs: render2(trail, now, outcome),
29299
- status: failed ? "error" : "success",
29300
- exitMethod: failed ? "discarded" : "saved"
29301
- };
29302
- }
29303
-
29304
- // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
29305
- function useFlowLog(state2) {
29306
- const trail = useRef18(void 0);
29307
- const previous = useRef18(void 0);
29308
- useEffect28(() => {
29309
- const before = previous.current;
29310
- previous.current = state2;
29311
- const moved = before !== void 0 && before.step !== state2.step;
29312
- const now = Date.now();
29313
- let open = trail.current;
29314
- if (!open) {
29315
- if (state2.step === "final-review" || before && !moved) return;
29316
- open = openTrail(state2, now);
29317
- startDebugRun({ ...FLOW_RUN, inputs: flowContext(state2) });
29318
- } else if (before && moved) {
29319
- open = advance(open, before, state2, now);
29320
- } else {
29321
- return;
29322
- }
29323
- if (isFlowFinished(state2.step)) {
29324
- trail.current = void 0;
29325
- void finishDebugRun(flowFinish(open, state2, now));
29326
- return;
29327
- }
29328
- trail.current = open;
29329
- setDebugRunProgress(flowProgress(open, now));
29330
- }, [state2]);
29331
- useEffect28(
29332
- () => () => {
29333
- const open = trail.current;
29334
- trail.current = void 0;
29335
- if (open) void finishDebugRun(flowFinish(open, void 0, Date.now()));
29336
- },
29337
- []
29338
- );
29339
- }
29340
-
29341
28705
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
29342
28706
  import { jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
29343
28707
  function canEditFromPreview(cdf) {
@@ -29351,7 +28715,6 @@ function FlowScreen({
29351
28715
  generatePromptPath,
29352
28716
  onExit
29353
28717
  }) {
29354
- useFlowLog(state2);
29355
28718
  const produced = producedOf(state2);
29356
28719
  const counts = { components: state2.generatedAcceptedCount, tokens: state2.tokenCount };
29357
28720
  const things = countedThings(produced, counts);
@@ -29467,7 +28830,7 @@ function FlowScreen({
29467
28830
  }
29468
28831
 
29469
28832
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
29470
- import { useEffect as useEffect29, useRef as useRef19, useSyncExternalStore } from "react";
28833
+ import { useEffect as useEffect24, useRef as useRef17, useSyncExternalStore } from "react";
29471
28834
 
29472
28835
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
29473
28836
  import { appendFileSync, writeFileSync } from "node:fs";
@@ -30209,7 +29572,7 @@ function createFlowController(start, deps) {
30209
29572
 
30210
29573
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
30211
29574
  function useFlow(start, options = {}) {
30212
- const controller = useRef19();
29575
+ const controller = useRef17();
30213
29576
  if (start && !controller.current) {
30214
29577
  try {
30215
29578
  startWizardLog();
@@ -30226,14 +29589,14 @@ function useFlow(start, options = {}) {
30226
29589
  (listener) => current?.subscribe(listener) ?? (() => void 0),
30227
29590
  () => current?.getState()
30228
29591
  );
30229
- useEffect29(() => {
29592
+ useEffect24(() => {
30230
29593
  if (!start) controller.current = void 0;
30231
29594
  }, [start]);
30232
29595
  return current && state2 ? { controller: current, state: state2 } : void 0;
30233
29596
  }
30234
29597
 
30235
29598
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
30236
- import { useEffect as useEffect30, useState as useState31 } from "react";
29599
+ import { useEffect as useEffect25, useState as useState31 } from "react";
30237
29600
  import { Box as Box46, Text as Text47, useInput as useInput13 } from "ink";
30238
29601
  init_debug_store();
30239
29602
 
@@ -30307,7 +29670,7 @@ function Section({ title, rows }) {
30307
29670
  }
30308
29671
  function HelpScreen({ onDone }) {
30309
29672
  const [info, setInfo] = useState31();
30310
- useEffect30(() => {
29673
+ useEffect25(() => {
30311
29674
  startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
30312
29675
  void readHelpInfo().then(setInfo);
30313
29676
  }, []);
@@ -30404,10 +29767,43 @@ import { useState as useState36 } from "react";
30404
29767
  import { Box as Box51, Text as Text53, useInput as useInput17 } from "ink";
30405
29768
 
30406
29769
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
30407
- import { useEffect as useEffect32, useRef as useRef20, useState as useState34 } from "react";
29770
+ import { useEffect as useEffect27, useRef as useRef18, useState as useState34 } from "react";
30408
29771
  import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
30409
29772
  init_debug_store();
30410
29773
 
29774
+ // packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
29775
+ init_config();
29776
+ import { existsSync as existsSync10 } from "node:fs";
29777
+ function diffSnapshots(before, after) {
29778
+ const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
29779
+ const changed_fields = names.filter((name) => before[name] !== after[name]);
29780
+ return { changed: changed_fields.length > 0, changed_fields };
29781
+ }
29782
+ var DEFAULT_TRAIL_LIMIT = 30;
29783
+ function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
29784
+ const actions = [];
29785
+ return {
29786
+ record(action) {
29787
+ actions.push(action);
29788
+ if (actions.length > limit) actions.shift();
29789
+ },
29790
+ entries: () => [...actions]
29791
+ };
29792
+ }
29793
+ var MIN_SECRET_LENGTH = 6;
29794
+ function scrubError(error, secrets) {
29795
+ let message = error instanceof Error ? error.message : String(error);
29796
+ for (const secret of secrets) {
29797
+ if (secret.length < MIN_SECRET_LENGTH) continue;
29798
+ for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
29799
+ }
29800
+ return message;
29801
+ }
29802
+ function describeSettingsFile() {
29803
+ const path5 = configFilePath();
29804
+ return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
29805
+ }
29806
+
30411
29807
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
30412
29808
  import { execFile as execFile2 } from "node:child_process";
30413
29809
  import { access as access5, constants } from "node:fs/promises";
@@ -30492,7 +29888,7 @@ async function testAgent(name, binary, model) {
30492
29888
  timeoutMs: PROMPT_TIMEOUT_MS
30493
29889
  })
30494
29890
  );
30495
- const seconds2 = ((Date.now() - started) / 1e3).toFixed(1);
29891
+ const seconds = ((Date.now() - started) / 1e3).toFixed(1);
30496
29892
  if (result.timedOut) {
30497
29893
  return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
30498
29894
  }
@@ -30500,7 +29896,7 @@ async function testAgent(name, binary, model) {
30500
29896
  const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
30501
29897
  return [...checks, fail3("prompt", reason)];
30502
29898
  }
30503
- return [...checks, pass("prompt", `answered in ${seconds2}s`)];
29899
+ return [...checks, pass("prompt", `answered in ${seconds}s`)];
30504
29900
  }
30505
29901
  function statusFromChecks(name, checks, savedBinary) {
30506
29902
  if (checks.length === 0) return "checking";
@@ -30700,7 +30096,7 @@ async function writeAgentConfig(config) {
30700
30096
  }
30701
30097
 
30702
30098
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
30703
- import { useEffect as useEffect31, useState as useState33 } from "react";
30099
+ import { useEffect as useEffect26, useState as useState33 } from "react";
30704
30100
  import { Box as Box48, Text as Text50 } from "ink";
30705
30101
 
30706
30102
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx
@@ -30763,7 +30159,7 @@ function AgentDetail({
30763
30159
  const [testing, setTesting] = useState33(false);
30764
30160
  const [notice, setNotice] = useState33(null);
30765
30161
  const [checks, setChecks] = useState33(void 0);
30766
- useEffect31(() => {
30162
+ useEffect26(() => {
30767
30163
  let active = true;
30768
30164
  setChecks(void 0);
30769
30165
  const timer = setTimeout(() => {
@@ -30848,7 +30244,7 @@ function AgentsScreen({ onDone }) {
30848
30244
  const [saving, setSaving] = useState34(false);
30849
30245
  const [loadError, setLoadError] = useState34(null);
30850
30246
  const [checks, setChecks] = useState34({});
30851
- const visit = useRef20({
30247
+ const visit = useRef18({
30852
30248
  trail: createTrail(),
30853
30249
  before: void 0,
30854
30250
  environment: void 0,
@@ -30861,7 +30257,7 @@ function AgentsScreen({ onDone }) {
30861
30257
  );
30862
30258
  }
30863
30259
  };
30864
- useEffect32(() => {
30260
+ useEffect27(() => {
30865
30261
  readAgentConfig().then((loaded) => {
30866
30262
  setConfig(loaded);
30867
30263
  inspectAll(loaded);
@@ -31029,7 +30425,7 @@ function AgentsScreen({ onDone }) {
31029
30425
  hints: [
31030
30426
  { keys: "\u2191/\u2193", label: "move" },
31031
30427
  { keys: "\u23CE", label: "make default" },
31032
- { keys: "\u2192", label: "settings and test" },
30428
+ { keys: "\u2192", label: "settings" },
31033
30429
  { keys: "Esc/q", label: "back" }
31034
30430
  ]
31035
30431
  }
@@ -31038,7 +30434,7 @@ function AgentsScreen({ onDone }) {
31038
30434
  }
31039
30435
 
31040
30436
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
31041
- import { useEffect as useEffect33, useRef as useRef21, useState as useState35 } from "react";
30437
+ import { useEffect as useEffect28, useRef as useRef19, useState as useState35 } from "react";
31042
30438
  import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
31043
30439
  init_debug_store();
31044
30440
 
@@ -31096,14 +30492,14 @@ function ProjectScreen({ onDone }) {
31096
30492
  const [saving, setSaving] = useState35(false);
31097
30493
  const [notice, setNotice] = useState35(null);
31098
30494
  const [loadError, setLoadError] = useState35(null);
31099
- const visit = useRef21({
30495
+ const visit = useRef19({
31100
30496
  trail: createTrail(),
31101
30497
  before: void 0,
31102
30498
  persisted: void 0,
31103
30499
  error: ""
31104
30500
  }).current;
31105
- const scrub2 = (err) => scrubError(err, [config?.cmaToken ?? ""]);
31106
- useEffect33(() => {
30501
+ const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
30502
+ useEffect28(() => {
31107
30503
  readCredentials().then((cfg) => {
31108
30504
  setConfig(cfg);
31109
30505
  visit.before = snapshotOf(cfg);
@@ -31170,7 +30566,7 @@ function ProjectScreen({ onDone }) {
31170
30566
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
31171
30567
  setNotice({ kind: "success", text: "Project settings saved" });
31172
30568
  }).catch((err) => {
31173
- visit.error = scrub2(err);
30569
+ visit.error = scrub(err);
31174
30570
  visit.trail.record("save failed");
31175
30571
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
31176
30572
  }).finally(() => setSaving(false));
@@ -31255,7 +30651,7 @@ function ConfigurationScreen({ onDone }) {
31255
30651
  }
31256
30652
 
31257
30653
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
31258
- import { useEffect as useEffect34, useState as useState37 } from "react";
30654
+ import { useEffect as useEffect29, useState as useState37 } from "react";
31259
30655
  import { Box as Box52, Text as Text54, useInput as useInput18 } from "ink";
31260
30656
 
31261
30657
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
@@ -31279,7 +30675,7 @@ import { Fragment as Fragment20, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-
31279
30675
  function OptInAnalyticsScreen({ onDone }) {
31280
30676
  const [loading, setLoading] = useState37(true);
31281
30677
  const [enabled, setEnabled] = useState37(true);
31282
- useEffect34(() => {
30678
+ useEffect29(() => {
31283
30679
  readAnalyticsSetting().then((setting) => {
31284
30680
  setEnabled(setting.enabled);
31285
30681
  setLoading(false);
@@ -31333,7 +30729,7 @@ function OptInAnalyticsScreen({ onDone }) {
31333
30729
  }
31334
30730
 
31335
30731
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
31336
- import { useEffect as useEffect35, useRef as useRef22, useState as useState38 } from "react";
30732
+ import { useEffect as useEffect30, useRef as useRef20, useState as useState38 } from "react";
31337
30733
  import { Box as Box53, Text as Text55, useInput as useInput19 } from "ink";
31338
30734
  init_debug_mode_store();
31339
30735
  init_debug_store();
@@ -31350,8 +30746,8 @@ function DebugModeScreen({ onDone }) {
31350
30746
  RETENTION_CHOICES[RETENTION_CHOICES.length - 1]
31351
30747
  );
31352
30748
  const [notice, setNotice] = useState38(null);
31353
- const visit = useRef22({ trail: createTrail(), before: void 0, error: "" }).current;
31354
- useEffect35(() => {
30749
+ const visit = useRef20({ trail: createTrail(), before: void 0, error: "" }).current;
30750
+ useEffect30(() => {
31355
30751
  readDebugModeSetting().then((loaded) => {
31356
30752
  setSetting(loaded);
31357
30753
  setPending(loaded.retentionDays);
@@ -31506,7 +30902,7 @@ function App({ importOptions, inkClear }) {
31506
30902
  const [flowStart, setFlowStart] = useState39();
31507
30903
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
31508
30904
  const [importDefaults, setImportDefaults] = useState39();
31509
- useEffect36(() => {
30905
+ useEffect31(() => {
31510
30906
  if (screen !== "import") {
31511
30907
  setImportDefaults(void 0);
31512
30908
  return;
@@ -31579,7 +30975,7 @@ function App({ importOptions, inkClear }) {
31579
30975
  }
31580
30976
  });
31581
30977
  };
31582
- useEffect36(() => {
30978
+ useEffect31(() => {
31583
30979
  if (!tokensOnlyRun || tokensOnly?.status !== "done" || !tokensOnly.result.ok) return;
31584
30980
  const { credentialsSkipped, input, tokens } = tokensOnlyRun;
31585
30981
  const { tokensPath, tokenSessionId, tokenCount } = tokensOnly.result;
@@ -31601,12 +30997,12 @@ function App({ importOptions, inkClear }) {
31601
30997
  }
31602
30998
  });
31603
30999
  }, [tokensOnly, tokensOnlyRun]);
31604
- useEffect36(() => {
31000
+ useEffect31(() => {
31605
31001
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
31606
31002
  setExtractionRun(void 0);
31607
31003
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
31608
31004
  }, [extraction, extractionRun]);
31609
- useEffect36(() => {
31005
+ useEffect31(() => {
31610
31006
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
31611
31007
  const { extraction: produced, input, generatePromptPath } = scopeRun;
31612
31008
  setGenerationInput({
@@ -31624,7 +31020,7 @@ function App({ importOptions, inkClear }) {
31624
31020
  ...generatePromptPath ? { generatePromptPath } : {}
31625
31021
  });
31626
31022
  }, [scopeFlow, scopeRun, generationInput]);
31627
- useEffect36(() => {
31023
+ useEffect31(() => {
31628
31024
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
31629
31025
  const { credentialsSkipped, extraction: produced, input, generatePromptPath } = scopeRun;
31630
31026
  inkClear();
@@ -31793,7 +31189,6 @@ function App({ importOptions, inkClear }) {
31793
31189
  return /* @__PURE__ */ jsx66(
31794
31190
  CredentialsScreen,
31795
31191
  {
31796
- mode: target,
31797
31192
  initial: importDefaults.credentials,
31798
31193
  tokensOnly: target === "tokens",
31799
31194
  onBack: () => goBackFrom("credentials"),