@contentful/experience-design-system-cli 2.40.1-dev-build-54dd0c33.0 → 2.40.1-dev-build-58bdf9b8.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
@@ -2484,7 +2484,7 @@ var init_cache_keys = __esm({
2484
2484
  });
2485
2485
 
2486
2486
  // packages/experience-design-system-cli/app.tsx
2487
- import { useEffect as useEffect31, useState as useState39 } from "react";
2487
+ import { useEffect as useEffect32, useState as useState39 } from "react";
2488
2488
 
2489
2489
  // packages/experience-design-system-cli/src/tui/home/home.tsx
2490
2490
  import { useEffect as useEffect2, useState as useState2 } from "react";
@@ -18157,8 +18157,9 @@ function PathValidationScreen({
18157
18157
  }
18158
18158
 
18159
18159
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
18160
- import { useRef as useRef5, useState as useState9 } from "react";
18160
+ import { useEffect as useEffect8, useRef as useRef5, useState as useState9 } from "react";
18161
18161
  import { Box as Box14, Text as Text14, useInput as useInput11 } from "ink";
18162
+ init_debug_store();
18162
18163
 
18163
18164
  // packages/experience-design-system-cli/src/tui/shared/components/FieldForm.tsx
18164
18165
  import { useState as useState8 } from "react";
@@ -18335,6 +18336,39 @@ function FieldForm({
18335
18336
  ] });
18336
18337
  }
18337
18338
 
18339
+ // packages/experience-design-system-cli/src/tui/shared/debug-trail.ts
18340
+ init_config();
18341
+ import { existsSync as existsSync9 } from "node:fs";
18342
+ function diffSnapshots(before, after) {
18343
+ const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
18344
+ const changed_fields = names.filter((name) => before[name] !== after[name]);
18345
+ return { changed: changed_fields.length > 0, changed_fields };
18346
+ }
18347
+ var DEFAULT_TRAIL_LIMIT = 30;
18348
+ function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
18349
+ const actions = [];
18350
+ return {
18351
+ record(action) {
18352
+ actions.push(action);
18353
+ if (actions.length > limit) actions.shift();
18354
+ },
18355
+ entries: () => [...actions]
18356
+ };
18357
+ }
18358
+ var MIN_SECRET_LENGTH = 6;
18359
+ function scrubError(error, secrets) {
18360
+ let message = error instanceof Error ? error.message : String(error);
18361
+ for (const secret of secrets) {
18362
+ if (secret.length < MIN_SECRET_LENGTH) continue;
18363
+ for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
18364
+ }
18365
+ return message;
18366
+ }
18367
+ function describeSettingsFile() {
18368
+ const path5 = configFilePath();
18369
+ return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync9(path5) };
18370
+ }
18371
+
18338
18372
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
18339
18373
  var FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
18340
18374
  function credentialsPurpose(tokensOnly) {
@@ -18349,12 +18383,36 @@ function normalize(values) {
18349
18383
  host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
18350
18384
  };
18351
18385
  }
18352
- function missingField(values) {
18353
- return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
18386
+ function missingFields(values) {
18387
+ return ["spaceId", "environmentId", "cmaToken"].filter((field) => values[field] === "");
18354
18388
  }
18355
18389
  function isUnchanged(current, initial) {
18356
18390
  return FIELDS.every((field) => current[field] === initial[field]);
18357
18391
  }
18392
+ function rejectedAttempt(reason, credentials) {
18393
+ return { host: credentials.host, reason: scrubError(reason, [credentials.cmaToken]) };
18394
+ }
18395
+ function credentialsLog(credentials) {
18396
+ return {
18397
+ space_id: credentials.spaceId,
18398
+ environment_id: credentials.environmentId,
18399
+ host: credentials.host,
18400
+ cma_token: credentials.cmaToken
18401
+ };
18402
+ }
18403
+ function credentialsOutputs({
18404
+ outcome,
18405
+ credentials,
18406
+ initial,
18407
+ attempts
18408
+ }) {
18409
+ return {
18410
+ outcome,
18411
+ ...credentialsLog(credentials),
18412
+ changed_fields: diffSnapshots(initial, credentials).changed_fields,
18413
+ rejected_attempts: attempts
18414
+ };
18415
+ }
18358
18416
 
18359
18417
  // packages/experience-design-system-cli/src/tui/user-agent.ts
18360
18418
  init_version();
@@ -18402,7 +18460,9 @@ var MENU = [
18402
18460
  { choice: "continue", label: "Continue", description: "Check the credentials and go on" },
18403
18461
  { choice: "edit", label: "Edit", description: "Change the credentials" }
18404
18462
  ];
18463
+ var MAX_LOGGED_ATTEMPTS2 = 10;
18405
18464
  function CredentialsScreen({
18465
+ mode,
18406
18466
  onDone,
18407
18467
  onBack,
18408
18468
  initial = {},
@@ -18425,17 +18485,64 @@ function CredentialsScreen({
18425
18485
  const [focus, setFocus] = useState9(0);
18426
18486
  const [active, setActive] = useState9(0);
18427
18487
  const [beforeEdit, setBeforeEdit] = useState9(initialValues);
18488
+ const visit = useRef5({ attempts: [], lastReason: "" }).current;
18489
+ useEffect8(() => {
18490
+ startDebugRun({
18491
+ flow: "import/credentials",
18492
+ step: "04-credentials",
18493
+ menuOption: "Credentials",
18494
+ inputs: { import_mode: mode, prefilled, ...credentialsLog(initialValues) }
18495
+ });
18496
+ }, []);
18497
+ const reject = (attempt, text) => {
18498
+ if (visit.attempts.length < MAX_LOGGED_ATTEMPTS2) visit.attempts.push(attempt);
18499
+ visit.lastReason = attempt.reason;
18500
+ setNotice({ kind: "error", text });
18501
+ };
18502
+ const leave = () => {
18503
+ void finishDebugRun({
18504
+ outputs: {
18505
+ ...credentialsOutputs({
18506
+ outcome: "back",
18507
+ credentials: normalize(values),
18508
+ initial: initialValues,
18509
+ attempts: visit.attempts
18510
+ }),
18511
+ ...notice ? { error: visit.lastReason } : {}
18512
+ },
18513
+ status: notice ? "error" : "success",
18514
+ exitMethod: "discarded"
18515
+ });
18516
+ onBack();
18517
+ };
18428
18518
  const submit = async () => {
18429
18519
  const credentials = normalize(values);
18430
- if (missingField(credentials)) {
18431
- setNotice({ kind: "error", text: "Space ID, environment and CMA token are all required." });
18520
+ const missing = missingFields(credentials);
18521
+ if (missing.length > 0) {
18522
+ reject(
18523
+ rejectedAttempt(`Missing required fields: ${missing.join(", ")}`, credentials),
18524
+ "Space ID, environment and CMA token are all required."
18525
+ );
18432
18526
  return;
18433
18527
  }
18434
18528
  setValidating(true);
18435
18529
  const result = await validate3(credentials);
18436
18530
  setValidating(false);
18437
- if (result.ok) onDone({ skipped: false, credentials });
18438
- else setNotice({ kind: "error", text: result.error });
18531
+ if (!result.ok) {
18532
+ reject(rejectedAttempt(result.error, credentials), result.error);
18533
+ return;
18534
+ }
18535
+ void finishDebugRun({
18536
+ outputs: credentialsOutputs({
18537
+ outcome: "validated",
18538
+ credentials,
18539
+ initial: initialValues,
18540
+ attempts: visit.attempts
18541
+ }),
18542
+ status: "success",
18543
+ exitMethod: "saved"
18544
+ });
18545
+ onDone({ skipped: false, credentials });
18439
18546
  };
18440
18547
  const choose = (choice) => {
18441
18548
  if (choice === "continue") void submit();
@@ -18444,7 +18551,7 @@ function CredentialsScreen({
18444
18551
  setBeforeEdit(values);
18445
18552
  setActive(0);
18446
18553
  setEditing(true);
18447
- } else onBack();
18554
+ } else leave();
18448
18555
  };
18449
18556
  const stopEditing = () => {
18450
18557
  setEditing(false);
@@ -18454,7 +18561,7 @@ function CredentialsScreen({
18454
18561
  if (validating) return;
18455
18562
  if (editing) {
18456
18563
  if (key.escape) {
18457
- if (!prefilled) onBack();
18564
+ if (!prefilled) leave();
18458
18565
  else {
18459
18566
  setValues(beforeEdit);
18460
18567
  setNotice(null);
@@ -18790,14 +18897,14 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
18790
18897
  init_config();
18791
18898
 
18792
18899
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
18793
- import { useEffect as useEffect8, useRef as useRef6, useState as useState11 } from "react";
18900
+ import { useEffect as useEffect9, useRef as useRef6, useState as useState11 } from "react";
18794
18901
 
18795
18902
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
18796
18903
  import { mkdir as mkdir8 } from "node:fs/promises";
18797
18904
  import { join as join20, resolve as resolve24 } from "node:path";
18798
18905
 
18799
18906
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
18800
- import { existsSync as existsSync9 } from "node:fs";
18907
+ import { existsSync as existsSync10 } from "node:fs";
18801
18908
  import { dirname as dirname16, join as join19, resolve as resolve22 } from "node:path";
18802
18909
  import { fileURLToPath as fileURLToPath4 } from "node:url";
18803
18910
  function findSkillPath(fileName) {
@@ -18805,7 +18912,7 @@ function findSkillPath(fileName) {
18805
18912
  let dir = thisDir;
18806
18913
  for (; ; ) {
18807
18914
  const candidate = join19(dir, "skills", fileName);
18808
- if (existsSync9(candidate)) return candidate;
18915
+ if (existsSync10(candidate)) return candidate;
18809
18916
  const parent = resolve22(dir, "..");
18810
18917
  if (parent === dir) {
18811
18918
  throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
@@ -19047,7 +19154,7 @@ async function resolveSelectionPrompt(overrides) {
19047
19154
  function useExtraction(input) {
19048
19155
  const [state2, setState] = useState11();
19049
19156
  const current = useRef6();
19050
- useEffect8(() => {
19157
+ useEffect9(() => {
19051
19158
  current.current = input;
19052
19159
  if (!input) {
19053
19160
  setState(void 0);
@@ -19073,7 +19180,7 @@ function useExtraction(input) {
19073
19180
  }
19074
19181
 
19075
19182
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-tokens-only.ts
19076
- import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
19183
+ import { useEffect as useEffect10, useRef as useRef7, useState as useState12 } from "react";
19077
19184
 
19078
19185
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run-tokens-only.ts
19079
19186
  var TOKENS_SKILL_PATH2 = findSkillPath("generate-tokens.md");
@@ -19108,7 +19215,7 @@ async function runTokensOnly(input, deps = realDeps2) {
19108
19215
  function useTokensOnly(input) {
19109
19216
  const [state2, setState] = useState12();
19110
19217
  const current = useRef7();
19111
- useEffect9(() => {
19218
+ useEffect10(() => {
19112
19219
  current.current = input;
19113
19220
  if (!input) {
19114
19221
  setState(void 0);
@@ -20312,7 +20419,7 @@ function useImmediateInput(handler, enabled = true) {
20312
20419
 
20313
20420
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
20314
20421
  import { useStdout as useStdout2 } from "ink";
20315
- import { useEffect as useEffect10, useState as useState13 } from "react";
20422
+ import { useEffect as useEffect11, useState as useState13 } from "react";
20316
20423
  function readTerminalSize(stdout) {
20317
20424
  return {
20318
20425
  columns: stdout?.columns ?? 80,
@@ -20322,7 +20429,7 @@ function readTerminalSize(stdout) {
20322
20429
  function useTerminalSize() {
20323
20430
  const { stdout } = useStdout2();
20324
20431
  const [size, setSize] = useState13(() => readTerminalSize(stdout));
20325
- useEffect10(() => {
20432
+ useEffect11(() => {
20326
20433
  const updateSize = () => setSize(readTerminalSize(stdout));
20327
20434
  stdout?.on("resize", updateSize);
20328
20435
  updateSize();
@@ -20505,7 +20612,7 @@ function createSidebarViewsHelpSection(includeBreaking) {
20505
20612
  }
20506
20613
 
20507
20614
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
20508
- import { useEffect as useEffect11, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
20615
+ import { useEffect as useEffect12, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
20509
20616
 
20510
20617
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/columns.ts
20511
20618
  var TWO_COLUMN_MIN_WIDTH = 100;
@@ -21242,7 +21349,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
21242
21349
  return seed;
21243
21350
  });
21244
21351
  const seededGroupsRef = useRef9(closures.size > 0 || cycleParticipants.size > 0);
21245
- useEffect11(() => {
21352
+ useEffect12(() => {
21246
21353
  if (seededGroupsRef.current) return;
21247
21354
  if (closures.size === 0 && cycleParticipants.size === 0) return;
21248
21355
  seededGroupsRef.current = true;
@@ -21333,7 +21440,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
21333
21440
  entryCount: 0
21334
21441
  });
21335
21442
  const panelLayout = useMemo3(() => computePanelLayout(visibleCount), [visibleCount]);
21336
- useEffect11(() => {
21443
+ useEffect12(() => {
21337
21444
  setNav((prev) => {
21338
21445
  const maxIdx = Math.max(0, visibleRows.length - 1);
21339
21446
  const nextCursor = Math.min(prev.cursor, maxIdx);
@@ -21808,7 +21915,7 @@ function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
21808
21915
  }
21809
21916
 
21810
21917
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
21811
- import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
21918
+ import { useEffect as useEffect13, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
21812
21919
 
21813
21920
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/cache-check.ts
21814
21921
  async function checkGenerationCache(input) {
@@ -21857,7 +21964,7 @@ function useScopeGateFlow(input, deps = realDeps3) {
21857
21964
  const loaded = useMemo5(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
21858
21965
  const cacheCheck = useRef10(void 0);
21859
21966
  const [confirmed, setConfirmed] = useState17();
21860
- useEffect12(() => {
21967
+ useEffect13(() => {
21861
21968
  if (!input || !loaded?.ok || cacheCheck.current) return;
21862
21969
  cacheCheck.current = deps.checkCache(input.cache);
21863
21970
  }, [input, loaded]);
@@ -21924,7 +22031,7 @@ function GenerationScreen({
21924
22031
  }
21925
22032
 
21926
22033
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
21927
- import { useEffect as useEffect13, useRef as useRef11, useState as useState18 } from "react";
22034
+ import { useEffect as useEffect14, useRef as useRef11, useState as useState18 } from "react";
21928
22035
 
21929
22036
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
21930
22037
  import { resolve as resolve25 } from "node:path";
@@ -22090,7 +22197,7 @@ function applyProgressEvent2(event, previous, total) {
22090
22197
  function useGeneration(input) {
22091
22198
  const [state2, setState] = useState18();
22092
22199
  const current = useRef11();
22093
- useEffect13(() => {
22200
+ useEffect14(() => {
22094
22201
  current.current = input;
22095
22202
  if (!input) {
22096
22203
  setState(void 0);
@@ -22571,7 +22678,7 @@ function PreviewValidationErrorScreen({
22571
22678
  }
22572
22679
 
22573
22680
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
22574
- import { useCallback as useCallback5, useEffect as useEffect20, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
22681
+ import { useCallback as useCallback5, useEffect as useEffect21, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
22575
22682
  import figures8 from "figures";
22576
22683
 
22577
22684
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/review-json-panel.ts
@@ -22832,7 +22939,7 @@ function enumerateCycleBreaks(cycle, components) {
22832
22939
  import { Box as Box32, Text as Text34 } from "ink";
22833
22940
 
22834
22941
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
22835
- import React13, { useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
22942
+ import React13, { useEffect as useEffect15, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
22836
22943
  import figures6 from "figures";
22837
22944
  import { Box as Box26, measureElement, Text as Text27 } from "ink";
22838
22945
 
@@ -24390,7 +24497,7 @@ function FieldEditor({
24390
24497
  }
24391
24498
  return Math.max(start + 1, end2);
24392
24499
  };
24393
- useEffect14(() => {
24500
+ useEffect15(() => {
24394
24501
  if (focusLevel === "field" || selectedRowIdx < 0) return;
24395
24502
  setListScrollStart((previous) => {
24396
24503
  if (initialFocusTarget && !initialFocusScrollApplied.current) {
@@ -25462,7 +25569,7 @@ function finalizeReviewSession(extractSessionId, components) {
25462
25569
  }
25463
25570
 
25464
25571
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
25465
- import { useCallback as useCallback2, useEffect as useEffect16, useRef as useRef13, useState as useState21 } from "react";
25572
+ import { useCallback as useCallback2, useEffect as useEffect17, useRef as useRef13, useState as useState21 } from "react";
25466
25573
 
25467
25574
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/history.ts
25468
25575
  var DEFAULT_MAX_DEPTH = 50;
@@ -25518,7 +25625,7 @@ function createHistoryStack(seed, maxDepth = DEFAULT_MAX_DEPTH) {
25518
25625
  }
25519
25626
 
25520
25627
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
25521
- import { useEffect as useEffect15, useRef as useRef12, useState as useState20 } from "react";
25628
+ import { useEffect as useEffect16, useRef as useRef12, useState as useState20 } from "react";
25522
25629
 
25523
25630
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/run-live-preview.ts
25524
25631
  var TimeoutError = class extends Error {
@@ -25678,7 +25785,7 @@ function useFinalizePreview(opts) {
25678
25785
  const [scrollOffset, setScrollOffset] = useState20(0);
25679
25786
  const generationRef = useRef12(0);
25680
25787
  const acceptedKey = [...acceptedKeys].sort().join("\0");
25681
- useEffect15(() => {
25788
+ useEffect16(() => {
25682
25789
  if (!open) {
25683
25790
  setStatus("idle");
25684
25791
  setRemoved([]);
@@ -25741,7 +25848,7 @@ function useReviewSession({
25741
25848
  }));
25742
25849
  return { result, catalog };
25743
25850
  }, [loadSession, tokensPath]);
25744
- useEffect16(() => {
25851
+ useEffect17(() => {
25745
25852
  let disposed = false;
25746
25853
  void (async () => {
25747
25854
  try {
@@ -25794,7 +25901,7 @@ function useReviewSession({
25794
25901
  function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
25795
25902
  const [reviewMetadata, setReviewMetadata] = useState21(null);
25796
25903
  const [componentRationale, setComponentRationale] = useState21(null);
25797
- useEffect16(() => {
25904
+ useEffect17(() => {
25798
25905
  const current = components[selectedIdx];
25799
25906
  if (!current) {
25800
25907
  setReviewMetadata(null);
@@ -25826,7 +25933,7 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
25826
25933
  function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
25827
25934
  const historyRef = useRef13(null);
25828
25935
  const historySeededRef = useRef13(false);
25829
- useEffect16(() => {
25936
+ useEffect17(() => {
25830
25937
  if (loading || historySeededRef.current) return;
25831
25938
  historySeededRef.current = true;
25832
25939
  historyRef.current = createHistoryStack(createSnapshot(components));
@@ -25877,7 +25984,7 @@ function useReviewFinalize({
25877
25984
  }
25878
25985
 
25879
25986
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
25880
- import { useEffect as useEffect17, useRef as useRef14, useState as useState22 } from "react";
25987
+ import { useEffect as useEffect18, useRef as useRef14, useState as useState22 } from "react";
25881
25988
 
25882
25989
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/token-suggestions.ts
25883
25990
  function collectTokenSuggestions(entry, availableTokens = []) {
@@ -25930,7 +26037,7 @@ function useReviewEditor({
25930
26037
  const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState22(/* @__PURE__ */ new Set());
25931
26038
  const tokenReviewSuggestedRef = useRef14(/* @__PURE__ */ new Map());
25932
26039
  const pendingGRef = useRef14(false);
25933
- useEffect17(() => {
26040
+ useEffect18(() => {
25934
26041
  setTokenReviewRow(0);
25935
26042
  setTokenReviewEditing(false);
25936
26043
  setTokenReviewEditCursor(0);
@@ -26342,7 +26449,7 @@ function handleJsonPanelInput(input, key, state2) {
26342
26449
  }
26343
26450
 
26344
26451
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
26345
- import { useCallback as useCallback4, useEffect as useEffect19, useState as useState25 } from "react";
26452
+ import { useCallback as useCallback4, useEffect as useEffect20, useState as useState25 } from "react";
26346
26453
 
26347
26454
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/preview-annotations.ts
26348
26455
  function applyPreviewAnnotations(preview, localNames) {
@@ -26377,7 +26484,7 @@ function applyPreviewAnnotations(preview, localNames) {
26377
26484
  }
26378
26485
 
26379
26486
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
26380
- import { useCallback as useCallback3, useEffect as useEffect18, useRef as useRef15, useState as useState24 } from "react";
26487
+ import { useCallback as useCallback3, useEffect as useEffect19, useRef as useRef15, useState as useState24 } from "react";
26381
26488
  var DEFAULT_DEBOUNCE_MS = 500;
26382
26489
  function useLivePreview(opts) {
26383
26490
  const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
@@ -26388,14 +26495,14 @@ function useLivePreview(opts) {
26388
26495
  const latestRef = useRef15(0);
26389
26496
  const inflightRef = useRef15(0);
26390
26497
  const optsRef = useRef15(opts);
26391
- useEffect18(() => {
26498
+ useEffect19(() => {
26392
26499
  optsRef.current = opts;
26393
26500
  });
26394
26501
  const disabledRef = useRef15(disabled);
26395
- useEffect18(() => {
26502
+ useEffect19(() => {
26396
26503
  disabledRef.current = disabled;
26397
26504
  }, [disabled]);
26398
- useEffect18(() => {
26505
+ useEffect19(() => {
26399
26506
  return () => {
26400
26507
  if (timerRef.current) {
26401
26508
  clearTimeout(timerRef.current);
@@ -26509,13 +26616,13 @@ function useReviewPreview({
26509
26616
  deleteAllComponents
26510
26617
  });
26511
26618
  const [spinnerTick, setSpinnerTick] = useState25(0);
26512
- useEffect19(() => {
26619
+ useEffect20(() => {
26513
26620
  if (livePreviewHook.status !== "running") return;
26514
26621
  const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
26515
26622
  return () => clearInterval(id);
26516
26623
  }, [livePreviewHook.status]);
26517
26624
  const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
26518
- useEffect19(() => {
26625
+ useEffect20(() => {
26519
26626
  if (loading) return;
26520
26627
  if (!livePreview) return;
26521
26628
  if (components.length === 0) return;
@@ -26935,7 +27042,7 @@ function GenerateReviewStepView({
26935
27042
  [components]
26936
27043
  );
26937
27044
  const closures = useMemo6(() => computeAllClosures(componentGraph), [componentGraph]);
26938
- useEffect20(() => {
27045
+ useEffect21(() => {
26939
27046
  if (seededGroupsRef.current) return;
26940
27047
  if (closures.size === 0 && slotCycles.length === 0) return;
26941
27048
  seededGroupsRef.current = true;
@@ -26962,7 +27069,7 @@ function GenerateReviewStepView({
26962
27069
  suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
26963
27070
  }));
26964
27071
  }, [slotCycles, cycleView]);
26965
- useEffect20(() => {
27072
+ useEffect21(() => {
26966
27073
  const decision = computeAutoRejectDecision({
26967
27074
  loading,
26968
27075
  autoRejectFired: autoRejectFiredRef.current,
@@ -27006,7 +27113,7 @@ function GenerateReviewStepView({
27006
27113
  applySnapshot: applyHistorySnapshot
27007
27114
  });
27008
27115
  const autoRejectPushedRef = useRef16(false);
27009
- useEffect20(() => {
27116
+ useEffect21(() => {
27010
27117
  if (loading) return;
27011
27118
  if (!historySeededRef.current) return;
27012
27119
  if (!autoRejectFiredRef.current) return;
@@ -27090,7 +27197,7 @@ function GenerateReviewStepView({
27090
27197
  const panelHeight = leftPanelHeight + 2;
27091
27198
  const panelContentHeight = Math.max(1, panelHeight - 3);
27092
27199
  const cycleViewportHeight = Math.max(1, panelHeight - 4);
27093
- useEffect20(() => {
27200
+ useEffect21(() => {
27094
27201
  if (selectableRowPositions.length === 0) return;
27095
27202
  const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
27096
27203
  const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
@@ -28035,10 +28142,10 @@ function normalizePath(input) {
28035
28142
  }
28036
28143
 
28037
28144
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
28038
- import { useEffect as useEffect21, useState as useState27 } from "react";
28145
+ import { useEffect as useEffect22, useState as useState27 } from "react";
28039
28146
  function useBlinkingCursor() {
28040
28147
  const [visible, setVisible] = useState27(true);
28041
- useEffect21(() => {
28148
+ useEffect22(() => {
28042
28149
  const interval = setInterval(() => setVisible((current) => !current), 500);
28043
28150
  return () => clearInterval(interval);
28044
28151
  }, []);
@@ -28154,12 +28261,12 @@ function countedThings({ components, tokens }, counts = {}) {
28154
28261
  }
28155
28262
 
28156
28263
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
28157
- import { useEffect as useEffect22, useState as useState29 } from "react";
28264
+ import { useEffect as useEffect23, useState as useState29 } from "react";
28158
28265
  import { Spinner as Spinner2 } from "@inkjs/ui";
28159
28266
  import { jsx as jsx53 } from "react/jsx-runtime";
28160
28267
  function useTimedSpinner() {
28161
28268
  const [elapsedSeconds, setElapsedSeconds] = useState29(0);
28162
- useEffect22(() => {
28269
+ useEffect23(() => {
28163
28270
  const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
28164
28271
  return () => {
28165
28272
  clearInterval(timer);
@@ -28217,7 +28324,7 @@ function PushingStep({ progress, produced, counts }) {
28217
28324
  }
28218
28325
 
28219
28326
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
28220
- import { useEffect as useEffect23, useState as useState30, useMemo as useMemo7 } from "react";
28327
+ import { useEffect as useEffect24, useState as useState30, useMemo as useMemo7 } from "react";
28221
28328
  import { Box as Box44, Text as Text46 } from "ink";
28222
28329
 
28223
28330
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/preview-diff.ts
@@ -28612,7 +28719,7 @@ function WizardPreviewStep({
28612
28719
  const activeLines = diffExpanded ? diffLines : summaryLines;
28613
28720
  const maxScroll = Math.max(0, activeLines.length - viewportHeight);
28614
28721
  const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
28615
- useEffect23(() => {
28722
+ useEffect24(() => {
28616
28723
  setScrollOffset((previous) => Math.min(previous, maxScroll));
28617
28724
  }, [maxScroll]);
28618
28725
  useImmediateInput((input, key) => {
@@ -28830,7 +28937,7 @@ function FlowScreen({
28830
28937
  }
28831
28938
 
28832
28939
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
28833
- import { useEffect as useEffect24, useRef as useRef17, useSyncExternalStore } from "react";
28940
+ import { useEffect as useEffect25, useRef as useRef17, useSyncExternalStore } from "react";
28834
28941
 
28835
28942
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
28836
28943
  import { appendFileSync, writeFileSync } from "node:fs";
@@ -29589,14 +29696,14 @@ function useFlow(start, options = {}) {
29589
29696
  (listener) => current?.subscribe(listener) ?? (() => void 0),
29590
29697
  () => current?.getState()
29591
29698
  );
29592
- useEffect24(() => {
29699
+ useEffect25(() => {
29593
29700
  if (!start) controller.current = void 0;
29594
29701
  }, [start]);
29595
29702
  return current && state2 ? { controller: current, state: state2 } : void 0;
29596
29703
  }
29597
29704
 
29598
29705
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
29599
- import { useEffect as useEffect25, useState as useState31 } from "react";
29706
+ import { useEffect as useEffect26, useState as useState31 } from "react";
29600
29707
  import { Box as Box46, Text as Text47, useInput as useInput13 } from "ink";
29601
29708
  init_debug_store();
29602
29709
 
@@ -29670,7 +29777,7 @@ function Section({ title, rows }) {
29670
29777
  }
29671
29778
  function HelpScreen({ onDone }) {
29672
29779
  const [info, setInfo] = useState31();
29673
- useEffect25(() => {
29780
+ useEffect26(() => {
29674
29781
  startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
29675
29782
  void readHelpInfo().then(setInfo);
29676
29783
  }, []);
@@ -29767,43 +29874,10 @@ import { useState as useState36 } from "react";
29767
29874
  import { Box as Box51, Text as Text53, useInput as useInput17 } from "ink";
29768
29875
 
29769
29876
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
29770
- import { useEffect as useEffect27, useRef as useRef18, useState as useState34 } from "react";
29877
+ import { useEffect as useEffect28, useRef as useRef18, useState as useState34 } from "react";
29771
29878
  import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
29772
29879
  init_debug_store();
29773
29880
 
29774
- // packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
29775
- init_config();
29776
- import { existsSync as existsSync10 } from "node:fs";
29777
- function diffSnapshots(before, after) {
29778
- const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
29779
- const changed_fields = names.filter((name) => before[name] !== after[name]);
29780
- return { changed: changed_fields.length > 0, changed_fields };
29781
- }
29782
- var DEFAULT_TRAIL_LIMIT = 30;
29783
- function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
29784
- const actions = [];
29785
- return {
29786
- record(action) {
29787
- actions.push(action);
29788
- if (actions.length > limit) actions.shift();
29789
- },
29790
- entries: () => [...actions]
29791
- };
29792
- }
29793
- var MIN_SECRET_LENGTH = 6;
29794
- function scrubError(error, secrets) {
29795
- let message = error instanceof Error ? error.message : String(error);
29796
- for (const secret of secrets) {
29797
- if (secret.length < MIN_SECRET_LENGTH) continue;
29798
- for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
29799
- }
29800
- return message;
29801
- }
29802
- function describeSettingsFile() {
29803
- const path5 = configFilePath();
29804
- return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
29805
- }
29806
-
29807
29881
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
29808
29882
  import { execFile as execFile2 } from "node:child_process";
29809
29883
  import { access as access5, constants } from "node:fs/promises";
@@ -30096,7 +30170,7 @@ async function writeAgentConfig(config) {
30096
30170
  }
30097
30171
 
30098
30172
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
30099
- import { useEffect as useEffect26, useState as useState33 } from "react";
30173
+ import { useEffect as useEffect27, useState as useState33 } from "react";
30100
30174
  import { Box as Box48, Text as Text50 } from "ink";
30101
30175
 
30102
30176
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx
@@ -30159,7 +30233,7 @@ function AgentDetail({
30159
30233
  const [testing, setTesting] = useState33(false);
30160
30234
  const [notice, setNotice] = useState33(null);
30161
30235
  const [checks, setChecks] = useState33(void 0);
30162
- useEffect26(() => {
30236
+ useEffect27(() => {
30163
30237
  let active = true;
30164
30238
  setChecks(void 0);
30165
30239
  const timer = setTimeout(() => {
@@ -30257,7 +30331,7 @@ function AgentsScreen({ onDone }) {
30257
30331
  );
30258
30332
  }
30259
30333
  };
30260
- useEffect27(() => {
30334
+ useEffect28(() => {
30261
30335
  readAgentConfig().then((loaded) => {
30262
30336
  setConfig(loaded);
30263
30337
  inspectAll(loaded);
@@ -30434,7 +30508,7 @@ function AgentsScreen({ onDone }) {
30434
30508
  }
30435
30509
 
30436
30510
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
30437
- import { useEffect as useEffect28, useRef as useRef19, useState as useState35 } from "react";
30511
+ import { useEffect as useEffect29, useRef as useRef19, useState as useState35 } from "react";
30438
30512
  import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
30439
30513
  init_debug_store();
30440
30514
 
@@ -30499,7 +30573,7 @@ function ProjectScreen({ onDone }) {
30499
30573
  error: ""
30500
30574
  }).current;
30501
30575
  const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
30502
- useEffect28(() => {
30576
+ useEffect29(() => {
30503
30577
  readCredentials().then((cfg) => {
30504
30578
  setConfig(cfg);
30505
30579
  visit.before = snapshotOf(cfg);
@@ -30651,7 +30725,7 @@ function ConfigurationScreen({ onDone }) {
30651
30725
  }
30652
30726
 
30653
30727
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
30654
- import { useEffect as useEffect29, useState as useState37 } from "react";
30728
+ import { useEffect as useEffect30, useState as useState37 } from "react";
30655
30729
  import { Box as Box52, Text as Text54, useInput as useInput18 } from "ink";
30656
30730
 
30657
30731
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
@@ -30675,7 +30749,7 @@ import { Fragment as Fragment20, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-
30675
30749
  function OptInAnalyticsScreen({ onDone }) {
30676
30750
  const [loading, setLoading] = useState37(true);
30677
30751
  const [enabled, setEnabled] = useState37(true);
30678
- useEffect29(() => {
30752
+ useEffect30(() => {
30679
30753
  readAnalyticsSetting().then((setting) => {
30680
30754
  setEnabled(setting.enabled);
30681
30755
  setLoading(false);
@@ -30729,7 +30803,7 @@ function OptInAnalyticsScreen({ onDone }) {
30729
30803
  }
30730
30804
 
30731
30805
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
30732
- import { useEffect as useEffect30, useRef as useRef20, useState as useState38 } from "react";
30806
+ import { useEffect as useEffect31, useRef as useRef20, useState as useState38 } from "react";
30733
30807
  import { Box as Box53, Text as Text55, useInput as useInput19 } from "ink";
30734
30808
  init_debug_mode_store();
30735
30809
  init_debug_store();
@@ -30747,7 +30821,7 @@ function DebugModeScreen({ onDone }) {
30747
30821
  );
30748
30822
  const [notice, setNotice] = useState38(null);
30749
30823
  const visit = useRef20({ trail: createTrail(), before: void 0, error: "" }).current;
30750
- useEffect30(() => {
30824
+ useEffect31(() => {
30751
30825
  readDebugModeSetting().then((loaded) => {
30752
30826
  setSetting(loaded);
30753
30827
  setPending(loaded.retentionDays);
@@ -30902,7 +30976,7 @@ function App({ importOptions, inkClear }) {
30902
30976
  const [flowStart, setFlowStart] = useState39();
30903
30977
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
30904
30978
  const [importDefaults, setImportDefaults] = useState39();
30905
- useEffect31(() => {
30979
+ useEffect32(() => {
30906
30980
  if (screen !== "import") {
30907
30981
  setImportDefaults(void 0);
30908
30982
  return;
@@ -30975,7 +31049,7 @@ function App({ importOptions, inkClear }) {
30975
31049
  }
30976
31050
  });
30977
31051
  };
30978
- useEffect31(() => {
31052
+ useEffect32(() => {
30979
31053
  if (!tokensOnlyRun || tokensOnly?.status !== "done" || !tokensOnly.result.ok) return;
30980
31054
  const { credentialsSkipped, input, tokens } = tokensOnlyRun;
30981
31055
  const { tokensPath, tokenSessionId, tokenCount } = tokensOnly.result;
@@ -30997,12 +31071,12 @@ function App({ importOptions, inkClear }) {
30997
31071
  }
30998
31072
  });
30999
31073
  }, [tokensOnly, tokensOnlyRun]);
31000
- useEffect31(() => {
31074
+ useEffect32(() => {
31001
31075
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
31002
31076
  setExtractionRun(void 0);
31003
31077
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
31004
31078
  }, [extraction, extractionRun]);
31005
- useEffect31(() => {
31079
+ useEffect32(() => {
31006
31080
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
31007
31081
  const { extraction: produced, input, generatePromptPath } = scopeRun;
31008
31082
  setGenerationInput({
@@ -31020,7 +31094,7 @@ function App({ importOptions, inkClear }) {
31020
31094
  ...generatePromptPath ? { generatePromptPath } : {}
31021
31095
  });
31022
31096
  }, [scopeFlow, scopeRun, generationInput]);
31023
- useEffect31(() => {
31097
+ useEffect32(() => {
31024
31098
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
31025
31099
  const { credentialsSkipped, extraction: produced, input, generatePromptPath } = scopeRun;
31026
31100
  inkClear();
@@ -31189,6 +31263,7 @@ function App({ importOptions, inkClear }) {
31189
31263
  return /* @__PURE__ */ jsx66(
31190
31264
  CredentialsScreen,
31191
31265
  {
31266
+ mode: target,
31192
31267
  initial: importDefaults.credentials,
31193
31268
  tokensOnly: target === "tokens",
31194
31269
  onBack: () => goBackFrom("credentials"),