@contentful/experience-design-system-cli 2.37.1-dev-build-f57f8147.0 → 2.37.1-dev-build-20346727.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -263,9 +263,14 @@ var init_home = __esm({
263
263
  });
264
264
 
265
265
  // packages/experience-design-system-cli/src/tui/import/PageContainer.tsx
266
- import { Box as Box2, Text as Text3, useInput as useInput2 } from "ink";
266
+ import { useEffect as useEffect3 } from "react";
267
+ import { Box as Box2, Text as Text3, useInput as useInput2, useStdout as useStdout2 } from "ink";
267
268
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
268
269
  function ImportScreen({ exitCode, onDone }) {
270
+ const { stdout } = useStdout2();
271
+ useEffect3(() => {
272
+ stdout.write("\x1B[H\x1B[0J");
273
+ }, [stdout]);
269
274
  useInput2((input, key) => {
270
275
  if (key.return || key.escape || input === "q") {
271
276
  onDone();
@@ -2121,7 +2126,7 @@ async function runAgent(options) {
2121
2126
  promptLen: prompt.length,
2122
2127
  promptHead: prompt.slice(0, 500)
2123
2128
  });
2124
- return new Promise((resolve27) => {
2129
+ return new Promise((resolve25) => {
2125
2130
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
2126
2131
  const child = spawn3(binary, args, {
2127
2132
  stdio: ["pipe", "pipe", "pipe"],
@@ -2170,7 +2175,7 @@ async function runAgent(options) {
2170
2175
  stderrLen: stderr.length,
2171
2176
  stderrTail: stderr.slice(-1e3)
2172
2177
  });
2173
- resolve27(result);
2178
+ resolve25(result);
2174
2179
  });
2175
2180
  });
2176
2181
  }
@@ -2192,7 +2197,7 @@ async function checkAgentAuth(agent) {
2192
2197
  return "not-found";
2193
2198
  if (agent !== "claude")
2194
2199
  return "ok";
2195
- return new Promise((resolve27) => {
2200
+ return new Promise((resolve25) => {
2196
2201
  const child = spawn4(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
2197
2202
  let stdout = "";
2198
2203
  let done = false;
@@ -2201,7 +2206,7 @@ async function checkAgentAuth(agent) {
2201
2206
  return;
2202
2207
  done = true;
2203
2208
  child.kill("SIGTERM");
2204
- resolve27("unauthenticated");
2209
+ resolve25("unauthenticated");
2205
2210
  }, 5e3);
2206
2211
  child.stdout?.on("data", (chunk) => {
2207
2212
  stdout += chunk.toString();
@@ -2212,14 +2217,14 @@ async function checkAgentAuth(agent) {
2212
2217
  done = true;
2213
2218
  clearTimeout(timer);
2214
2219
  if (code !== 0) {
2215
- resolve27("unauthenticated");
2220
+ resolve25("unauthenticated");
2216
2221
  return;
2217
2222
  }
2218
2223
  try {
2219
2224
  const status = JSON.parse(stdout);
2220
- resolve27(status.loggedIn ? "ok" : "unauthenticated");
2225
+ resolve25(status.loggedIn ? "ok" : "unauthenticated");
2221
2226
  } catch {
2222
- resolve27("unauthenticated");
2227
+ resolve25("unauthenticated");
2223
2228
  }
2224
2229
  });
2225
2230
  });
@@ -2229,9 +2234,9 @@ async function binaryIsOnPath(binary) {
2229
2234
  const fs = await import("node:fs/promises");
2230
2235
  return fs.access(binary).then(() => true, () => false);
2231
2236
  }
2232
- return new Promise((resolve27) => {
2237
+ return new Promise((resolve25) => {
2233
2238
  const child = spawn4(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
2234
- child.on("close", (code) => resolve27(code === 0));
2239
+ child.on("close", (code) => resolve25(code === 0));
2235
2240
  });
2236
2241
  }
2237
2242
  var init_check_agent_auth = __esm({
@@ -13144,11 +13149,11 @@ var init_load_and_validate_for_review = __esm({
13144
13149
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
13145
13150
  import { resolve as resolve15 } from "node:path";
13146
13151
  async function getRefineSessionPaths(sessionId, artifactsRoot) {
13147
- const sessionDir2 = resolve15(artifactsRoot, sessionId);
13152
+ const sessionDir = resolve15(artifactsRoot, sessionId);
13148
13153
  return {
13149
- sessionDir: sessionDir2,
13150
- eventsPath: resolve15(sessionDir2, "events.jsonl"),
13151
- statePath: resolve15(sessionDir2, "current-review-state.json")
13154
+ sessionDir,
13155
+ eventsPath: resolve15(sessionDir, "events.jsonl"),
13156
+ statePath: resolve15(sessionDir, "current-review-state.json")
13152
13157
  };
13153
13158
  }
13154
13159
  var init_review_session_paths = __esm({
@@ -14901,7 +14906,7 @@ function errorMessage(error) {
14901
14906
  return error instanceof Error && error.message ? error.message : String(error);
14902
14907
  }
14903
14908
  function defaultSleep(delayMs) {
14904
- return new Promise((resolve27) => setTimeout(resolve27, delayMs));
14909
+ return new Promise((resolve25) => setTimeout(resolve25, delayMs));
14905
14910
  }
14906
14911
  var MAX_RETRY_AFTER_MS;
14907
14912
  var init_http_utils = __esm({
@@ -15177,7 +15182,7 @@ var init_api_client = __esm({
15177
15182
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
15178
15183
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
15179
15184
  const jitter = Math.random() * baseDelay * 0.15;
15180
- await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
15185
+ await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
15181
15186
  }
15182
15187
  }
15183
15188
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -18734,7 +18739,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
18734
18739
  const message = error instanceof Error ? error.message : String(error);
18735
18740
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
18736
18741
  throw error;
18737
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
18742
+ await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
18738
18743
  }
18739
18744
  }
18740
18745
  }
@@ -19716,7 +19721,7 @@ var init_scan_files = __esm({
19716
19721
  });
19717
19722
 
19718
19723
  // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/screen.tsx
19719
- import { useEffect as useEffect3, useMemo, useState as useState5 } from "react";
19724
+ import { useEffect as useEffect4, useMemo, useState as useState5 } from "react";
19720
19725
  import { Box as Box5, Text as Text6 } from "ink";
19721
19726
  import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
19722
19727
  function Row({ row }) {
@@ -19767,7 +19772,7 @@ function PathValidationScreen({
19767
19772
  }) {
19768
19773
  const resolvedPath = useMemo(() => resolveUserPath(projectPath), [projectPath]);
19769
19774
  const [scan, setScan] = useState5();
19770
- useEffect3(() => {
19775
+ useEffect4(() => {
19771
19776
  setScan(scanFiles(resolvedPath));
19772
19777
  }, [resolvedPath]);
19773
19778
  const phase = phaseOf(scan);
@@ -20217,10 +20222,10 @@ var init_theme = __esm({
20217
20222
  });
20218
20223
 
20219
20224
  // packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts
20220
- import { useEffect as useEffect4, useState as useState7 } from "react";
20225
+ import { useEffect as useEffect5, useState as useState7 } from "react";
20221
20226
  function useElapsed() {
20222
20227
  const [seconds, setSeconds] = useState7(0);
20223
- useEffect4(() => {
20228
+ useEffect5(() => {
20224
20229
  const timer = setInterval(() => setSeconds((current) => current + 1), 1e3);
20225
20230
  return () => clearInterval(timer);
20226
20231
  }, []);
@@ -20301,34 +20306,11 @@ var init_shared2 = __esm({
20301
20306
  });
20302
20307
 
20303
20308
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-reuse/logic.ts
20304
- import { access as access5, readdir as readdir2, stat as stat4 } from "node:fs/promises";
20309
+ import { access as access5, stat as stat4 } from "node:fs/promises";
20305
20310
  import { join as join18 } from "node:path";
20306
- async function findLatestTokens(contentfulDir) {
20307
- const candidates = [join18(contentfulDir, "tokens.json")];
20308
- try {
20309
- for (const session of await readdir2(contentfulDir, { withFileTypes: true })) {
20310
- if (!session.isDirectory()) continue;
20311
- for (const run of await readdir2(join18(contentfulDir, session.name), { withFileTypes: true }).catch(() => [])) {
20312
- if (run.isDirectory() && /^dsi-import-\d+$/.test(run.name)) {
20313
- candidates.push(join18(contentfulDir, session.name, run.name, "tokens.json"));
20314
- }
20315
- }
20316
- }
20317
- } catch {
20318
- }
20319
- const found = [];
20320
- for (const path5 of candidates) {
20321
- try {
20322
- found.push({ path: path5, mtimeMs: (await stat4(path5)).mtimeMs });
20323
- } catch {
20324
- }
20325
- }
20326
- return found.sort((a, b) => b.mtimeMs - a.mtimeMs)[0]?.path ?? null;
20327
- }
20328
- async function inspectTokens({ rawTokensPath, contentfulDir, cache }) {
20311
+ async function inspectTokens({ rawTokensPath, outDir, cache }) {
20329
20312
  if (!cache) return { kind: "none" };
20330
- const tokensPath = await findLatestTokens(contentfulDir);
20331
- if (!tokensPath) return { kind: "none" };
20313
+ const tokensPath = join18(outDir, "tokens.json");
20332
20314
  try {
20333
20315
  await access5(tokensPath);
20334
20316
  } catch {
@@ -20543,12 +20525,13 @@ async function writeSettings2(settings) {
20543
20525
  async function updateSettings2(patch) {
20544
20526
  await writeSettings2({ ...await readSettings2(), ...patch });
20545
20527
  }
20546
- var configFilePath2, runsFilePath2, oldConfigDir2;
20528
+ var configFilePath2, runsFilePath2, debugSessionsDir2, oldConfigDir2;
20547
20529
  var init_config = __esm({
20548
20530
  "packages/experience-design-system-types/dist/src/config/index.js"() {
20549
20531
  "use strict";
20550
20532
  configFilePath2 = () => join19(configRoot2(), "config.json");
20551
20533
  runsFilePath2 = () => join19(configRoot2(), "state", "runs.json");
20534
+ debugSessionsDir2 = () => join19(configRoot2(), "debug", "sessions");
20552
20535
  oldConfigDir2 = () => join19(homedir3(), ".config", "experiences");
20553
20536
  }
20554
20537
  });
@@ -20676,7 +20659,7 @@ var init_selection2 = __esm({
20676
20659
  import { mkdir as mkdir7 } from "node:fs/promises";
20677
20660
  import { join as join21, resolve as resolve22 } from "node:path";
20678
20661
  async function runExtraction(input, onProgress, deps = realDeps) {
20679
- const outDir = input.outDir ?? join21(resolve22(input.projectPath), ".contentful");
20662
+ const outDir = join21(resolve22(input.projectPath), ".contentful");
20680
20663
  let progress = initialProgress({
20681
20664
  hasCredentials: input.credentials !== null,
20682
20665
  hasRawTokens: input.rawTokensPath !== "",
@@ -20828,11 +20811,11 @@ var init_run = __esm({
20828
20811
  });
20829
20812
 
20830
20813
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
20831
- import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
20814
+ import { useEffect as useEffect6, useRef as useRef2, useState as useState8 } from "react";
20832
20815
  function useExtraction(input) {
20833
20816
  const [state, setState] = useState8();
20834
20817
  const current = useRef2();
20835
- useEffect5(() => {
20818
+ useEffect6(() => {
20836
20819
  current.current = input;
20837
20820
  if (!input) {
20838
20821
  setState(void 0);
@@ -21068,7 +21051,7 @@ var init_windowed_panel = __esm({
21068
21051
  });
21069
21052
 
21070
21053
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/panels/added-column.tsx
21071
- import React6 from "react";
21054
+ import React7 from "react";
21072
21055
  import { Box as Box11, Text as Text12 } from "ink";
21073
21056
  import figures from "figures";
21074
21057
  import { jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
@@ -21086,7 +21069,7 @@ function AddedColumn(props) {
21086
21069
  const aiFlagged = aiFlaggedByKey?.get(entry.name) === true;
21087
21070
  const showSeparator = firstNonCycleIdx > 0 && i === firstNonCycleIdx;
21088
21071
  const style = sideColumnLabelStyle({ isCycle: entry.isCycle, isSelected, focused });
21089
- return /* @__PURE__ */ jsxs11(React6.Fragment, { children: [
21072
+ return /* @__PURE__ */ jsxs11(React7.Fragment, { children: [
21090
21073
  showSeparator && /* @__PURE__ */ jsx14(Text12, { dimColor: true, children: "\u2500".repeat(Math.max(0, width - 2)) }),
21091
21074
  /* @__PURE__ */ jsxs11(Box11, { children: [
21092
21075
  isCursor ? /* @__PURE__ */ jsx14(Text12, { color: PALETTE2.info, bold: true, children: figures.pointer }) : /* @__PURE__ */ jsx14(Text12, { children: " " }),
@@ -22267,8 +22250,8 @@ var init_useImmediateInput = __esm({
22267
22250
  });
22268
22251
 
22269
22252
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
22270
- import { useStdout as useStdout2 } from "ink";
22271
- import { useEffect as useEffect6, useState as useState9 } from "react";
22253
+ import { useStdout as useStdout3 } from "ink";
22254
+ import { useEffect as useEffect7, useState as useState9 } from "react";
22272
22255
  function readTerminalSize(stdout) {
22273
22256
  return {
22274
22257
  columns: stdout?.columns ?? 80,
@@ -22276,9 +22259,9 @@ function readTerminalSize(stdout) {
22276
22259
  };
22277
22260
  }
22278
22261
  function useTerminalSize() {
22279
- const { stdout } = useStdout2();
22262
+ const { stdout } = useStdout3();
22280
22263
  const [size, setSize] = useState9(() => readTerminalSize(stdout));
22281
- useEffect6(() => {
22264
+ useEffect7(() => {
22282
22265
  const updateSize = () => setSize(readTerminalSize(stdout));
22283
22266
  stdout?.on("resize", updateSize);
22284
22267
  updateSize();
@@ -22295,7 +22278,7 @@ var init_use_terminal_size = __esm({
22295
22278
  });
22296
22279
 
22297
22280
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/components/HelpOverlay.tsx
22298
- import React7 from "react";
22281
+ import React8 from "react";
22299
22282
  import { Box as Box18, Text as Text20 } from "ink";
22300
22283
  import { Fragment as Fragment2, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
22301
22284
  function HelpOverlay(props) {
@@ -22319,7 +22302,7 @@ function HelpOverlay(props) {
22319
22302
  overflowY: "hidden",
22320
22303
  children: [
22321
22304
  /* @__PURE__ */ jsx22(Text20, { bold: true, children: "\u2500".repeat(titleRule) + " Help " + "\u2500".repeat(titleRule) }),
22322
- props.sections.map((section) => /* @__PURE__ */ jsxs19(React7.Fragment, { children: [
22305
+ props.sections.map((section) => /* @__PURE__ */ jsxs19(React8.Fragment, { children: [
22323
22306
  /* @__PURE__ */ jsx22(Text20, { children: " " }),
22324
22307
  /* @__PURE__ */ jsx22(Text20, { bold: true, children: section.title }),
22325
22308
  section.entries.map((entry) => /* @__PURE__ */ jsx22(Text20, { children: entry.keys ? " " + entry.keys.padEnd(16) + " " + entry.label : " " + entry.label }, entry.keys + entry.label))
@@ -23223,7 +23206,7 @@ var init_state = __esm({
23223
23206
  });
23224
23207
 
23225
23208
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
23226
- import { useEffect as useEffect7, useMemo as useMemo2, useRef as useRef4, useState as useState12 } from "react";
23209
+ import { useEffect as useEffect8, useMemo as useMemo2, useRef as useRef4, useState as useState12 } from "react";
23227
23210
  function useScopeGate({ components, onConfirm, onQuit }) {
23228
23211
  const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
23229
23212
  const columnPlan = useMemo2(() => computeColumnWidths(totalWidth), [totalWidth]);
@@ -23267,7 +23250,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
23267
23250
  return seed;
23268
23251
  });
23269
23252
  const seededGroupsRef = useRef4(closures.size > 0 || cycleParticipants.size > 0);
23270
- useEffect7(() => {
23253
+ useEffect8(() => {
23271
23254
  if (seededGroupsRef.current) return;
23272
23255
  if (closures.size === 0 && cycleParticipants.size === 0) return;
23273
23256
  seededGroupsRef.current = true;
@@ -23357,7 +23340,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
23357
23340
  entryCount: 0
23358
23341
  });
23359
23342
  const panelLayout = useMemo2(() => computePanelLayout(visibleCount), [visibleCount]);
23360
- useEffect7(() => {
23343
+ useEffect8(() => {
23361
23344
  setNav((prev) => {
23362
23345
  const maxIdx = Math.max(0, visibleRows.length - 1);
23363
23346
  const nextCursor = Math.min(prev.cursor, maxIdx);
@@ -23919,13 +23902,13 @@ var init_load = __esm({
23919
23902
  });
23920
23903
 
23921
23904
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
23922
- import { useEffect as useEffect8, useMemo as useMemo3, useRef as useRef5, useState as useState13 } from "react";
23905
+ import { useEffect as useEffect9, useMemo as useMemo3, useRef as useRef5, useState as useState13 } from "react";
23923
23906
  function useScopeGateFlow(input, deps = realDeps2) {
23924
23907
  const sessionId = input?.sessionId;
23925
23908
  const loaded = useMemo3(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
23926
23909
  const cacheCheck = useRef5(void 0);
23927
23910
  const [confirmed, setConfirmed] = useState13();
23928
- useEffect8(() => {
23911
+ useEffect9(() => {
23929
23912
  if (!input || !loaded?.ok || cacheCheck.current) return;
23930
23913
  cacheCheck.current = deps.checkCache(input.cache);
23931
23914
  }, [input, loaded]);
@@ -24200,11 +24183,11 @@ var init_run2 = __esm({
24200
24183
  });
24201
24184
 
24202
24185
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
24203
- import { useEffect as useEffect9, useRef as useRef6, useState as useState14 } from "react";
24186
+ import { useEffect as useEffect10, useRef as useRef6, useState as useState14 } from "react";
24204
24187
  function useGeneration(input) {
24205
24188
  const [state, setState] = useState14();
24206
24189
  const current = useRef6();
24207
- useEffect9(() => {
24190
+ useEffect10(() => {
24208
24191
  current.current = input;
24209
24192
  if (!input) {
24210
24193
  setState(void 0);
@@ -25079,7 +25062,7 @@ var init_scroll_offset = __esm({
25079
25062
  });
25080
25063
 
25081
25064
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
25082
- import React8, { useEffect as useEffect10, useLayoutEffect as useLayoutEffect2, useState as useState15 } from "react";
25065
+ import React9, { useEffect as useEffect11, useLayoutEffect as useLayoutEffect2, useState as useState15 } from "react";
25083
25066
  import figures5 from "figures";
25084
25067
  import { Box as Box21, measureElement, Text as Text23 } from "ink";
25085
25068
  import { Fragment as Fragment5, jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
@@ -25759,9 +25742,9 @@ function FieldEditor({
25759
25742
  const [editorState, setEditorState] = useState15(initialState);
25760
25743
  const [parseErr] = useState15(parseError);
25761
25744
  const [listScrollStart, setListScrollStart] = useState15(0);
25762
- const initialFocusScrollApplied = React8.useRef(false);
25745
+ const initialFocusScrollApplied = React9.useRef(false);
25763
25746
  const [rowHeights, setRowHeights] = useState15({});
25764
- const rowMeasureRefs = React8.useRef(/* @__PURE__ */ new Map());
25747
+ const rowMeasureRefs = React9.useRef(/* @__PURE__ */ new Map());
25765
25748
  const initialFocus = (() => {
25766
25749
  if (initialFocusTarget?.kind === "description") {
25767
25750
  return {
@@ -25848,23 +25831,23 @@ function FieldEditor({
25848
25831
  const [showHelp, setShowHelp] = useState15(false);
25849
25832
  const props = editorState.props;
25850
25833
  const slots = editorState.slots;
25851
- const contentPropIndexes = React8.useMemo(
25834
+ const contentPropIndexes = React9.useMemo(
25852
25835
  () => props.flatMap((prop, index) => prop.category === "content" ? [index] : []),
25853
25836
  [props]
25854
25837
  );
25855
- const designPropIndexes = React8.useMemo(
25838
+ const designPropIndexes = React9.useMemo(
25856
25839
  () => props.flatMap((prop, index) => prop.category === "design" ? [index] : []),
25857
25840
  [props]
25858
25841
  );
25859
- const hiddenPropIndexes = React8.useMemo(
25842
+ const hiddenPropIndexes = React9.useMemo(
25860
25843
  () => showHiddenProps ? props.flatMap((prop, index) => prop.category === "state" || prop.category === "unattached" ? [index] : []) : [],
25861
25844
  [props, showHiddenProps]
25862
25845
  );
25863
- const visiblePropIndexes = React8.useMemo(
25846
+ const visiblePropIndexes = React9.useMemo(
25864
25847
  () => [...contentPropIndexes, ...designPropIndexes, ...hiddenPropIndexes],
25865
25848
  [contentPropIndexes, designPropIndexes, hiddenPropIndexes]
25866
25849
  );
25867
- const propGroups = React8.useMemo(
25850
+ const propGroups = React9.useMemo(
25868
25851
  () => [
25869
25852
  {
25870
25853
  kind: "content",
@@ -25884,7 +25867,7 @@ function FieldEditor({
25884
25867
  ],
25885
25868
  [contentPropIndexes, designPropIndexes, hiddenPropIndexes]
25886
25869
  );
25887
- const selectableRows = React8.useMemo(
25870
+ const selectableRows = React9.useMemo(
25888
25871
  () => [
25889
25872
  ...contentPropIndexes.map((idx) => ({ kind: "prop", idx })),
25890
25873
  ...designPropIndexes.map((idx) => ({ kind: "prop", idx })),
@@ -25894,7 +25877,7 @@ function FieldEditor({
25894
25877
  [contentPropIndexes, designPropIndexes, hiddenPropIndexes, slots]
25895
25878
  );
25896
25879
  const visiblePropPosition = visiblePropIndexes.indexOf(propIdx);
25897
- const selectedSelectableIndex = React8.useMemo(
25880
+ const selectedSelectableIndex = React9.useMemo(
25898
25881
  () => selectableRows.findIndex(
25899
25882
  (row) => inSlots ? row.kind === "slot" && row.idx === slotIdx : row.kind === "prop" && row.idx === propIdx
25900
25883
  ),
@@ -25913,12 +25896,12 @@ function FieldEditor({
25913
25896
  }
25914
25897
  };
25915
25898
  const textEntryActive = focusLevel === "field" && editingField && activeField === "description" || focusLevel === "field" && editingField && activeField === "default" && (editorState.props[propIdx]?.type === "string" || editorState.props[propIdx]?.type === "token") || editingValue != null;
25916
- React8.useEffect(() => {
25899
+ React9.useEffect(() => {
25917
25900
  onTextEntryActiveChange?.(textEntryActive);
25918
25901
  }, [textEntryActive, onTextEntryActiveChange]);
25919
25902
  const currentProp = props[propIdx] ?? null;
25920
25903
  const currentSlot = slots[slotIdx] ?? null;
25921
- React8.useEffect(() => {
25904
+ React9.useEffect(() => {
25922
25905
  if (showHiddenProps || inSlots || inComponentDesc || visiblePropPosition >= 0) return;
25923
25906
  if (visiblePropIndexes.length > 0) {
25924
25907
  setPropIdx(visiblePropIndexes[0]);
@@ -25937,22 +25920,22 @@ function FieldEditor({
25937
25920
  setEditorState(next);
25938
25921
  onChange(serializeState(next, value));
25939
25922
  };
25940
- const canonicalize = React8.useCallback((json) => {
25923
+ const canonicalize = React9.useCallback((json) => {
25941
25924
  try {
25942
25925
  return JSON.stringify(JSON.parse(json));
25943
25926
  } catch {
25944
25927
  return `__unparseable__:${json}`;
25945
25928
  }
25946
25929
  }, []);
25947
- const initialStateRef = React8.useRef(initialState);
25930
+ const initialStateRef = React9.useRef(initialState);
25948
25931
  const baselineCanonical = canonicalize(serializeState(initialStateRef.current, value));
25949
25932
  const currentCanonical = canonicalize(serializeState(editorState, value));
25950
25933
  const isDirty = currentCanonical !== baselineCanonical;
25951
- React8.useEffect(() => {
25934
+ React9.useEffect(() => {
25952
25935
  onDirtyChange?.(isDirty);
25953
25936
  }, [isDirty, onDirtyChange]);
25954
- const lastDiscardTriggerRef = React8.useRef(discardTrigger);
25955
- React8.useEffect(() => {
25937
+ const lastDiscardTriggerRef = React9.useRef(discardTrigger);
25938
+ React9.useEffect(() => {
25956
25939
  if (discardTrigger === void 0) return;
25957
25940
  if (discardTrigger === lastDiscardTriggerRef.current) return;
25958
25941
  lastDiscardTriggerRef.current = discardTrigger;
@@ -26551,7 +26534,7 @@ function FieldEditor({
26551
26534
  }
26552
26535
  return Math.max(start + 1, end2);
26553
26536
  };
26554
- useEffect10(() => {
26537
+ useEffect11(() => {
26555
26538
  if (focusLevel === "field" || selectedRowIdx < 0) return;
26556
26539
  setListScrollStart((previous) => {
26557
26540
  if (initialFocusTarget && !initialFocusScrollApplied.current) {
@@ -27922,7 +27905,7 @@ var init_FinalizeDialog = __esm({
27922
27905
  });
27923
27906
 
27924
27907
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
27925
- import { useEffect as useEffect11, useRef as useRef7, useState as useState16 } from "react";
27908
+ import { useEffect as useEffect12, useRef as useRef7, useState as useState16 } from "react";
27926
27909
  function useReviewFinalizePreview({
27927
27910
  components,
27928
27911
  ...options
@@ -27939,7 +27922,7 @@ function useFinalizePreview(opts) {
27939
27922
  const [scrollOffset, setScrollOffset] = useState16(0);
27940
27923
  const generationRef = useRef7(0);
27941
27924
  const acceptedKey = [...acceptedKeys].sort().join("\0");
27942
- useEffect11(() => {
27925
+ useEffect12(() => {
27943
27926
  if (!open) {
27944
27927
  setStatus("idle");
27945
27928
  setRemoved([]);
@@ -27991,7 +27974,7 @@ var init_use_finalize_preview = __esm({
27991
27974
  });
27992
27975
 
27993
27976
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
27994
- import { useCallback as useCallback2, useEffect as useEffect12, useRef as useRef8, useState as useState17 } from "react";
27977
+ import { useCallback as useCallback2, useEffect as useEffect13, useRef as useRef8, useState as useState17 } from "react";
27995
27978
  function useReviewSession({
27996
27979
  loadSession,
27997
27980
  tokensPath,
@@ -28010,7 +27993,7 @@ function useReviewSession({
28010
27993
  }));
28011
27994
  return { result, catalog };
28012
27995
  }, [loadSession, tokensPath]);
28013
- useEffect12(() => {
27996
+ useEffect13(() => {
28014
27997
  let disposed = false;
28015
27998
  void (async () => {
28016
27999
  try {
@@ -28063,7 +28046,7 @@ function useReviewSession({
28063
28046
  function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
28064
28047
  const [reviewMetadata, setReviewMetadata] = useState17(null);
28065
28048
  const [componentRationale, setComponentRationale] = useState17(null);
28066
- useEffect12(() => {
28049
+ useEffect13(() => {
28067
28050
  const current = components[selectedIdx];
28068
28051
  if (!current) {
28069
28052
  setReviewMetadata(null);
@@ -28095,7 +28078,7 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
28095
28078
  function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
28096
28079
  const historyRef = useRef8(null);
28097
28080
  const historySeededRef = useRef8(false);
28098
- useEffect12(() => {
28081
+ useEffect13(() => {
28099
28082
  if (loading || historySeededRef.current) return;
28100
28083
  historySeededRef.current = true;
28101
28084
  historyRef.current = createHistoryStack(createSnapshot(components));
@@ -28177,7 +28160,7 @@ var init_token_suggestions = __esm({
28177
28160
  });
28178
28161
 
28179
28162
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
28180
- import { useEffect as useEffect13, useRef as useRef9, useState as useState18 } from "react";
28163
+ import { useEffect as useEffect14, useRef as useRef9, useState as useState18 } from "react";
28181
28164
  function parseReviewEntry(draftValue) {
28182
28165
  const parsed = JSON.parse(draftValue);
28183
28166
  const keys = Object.keys(parsed);
@@ -28211,7 +28194,7 @@ function useReviewEditor({
28211
28194
  const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState18(/* @__PURE__ */ new Set());
28212
28195
  const tokenReviewSuggestedRef = useRef9(/* @__PURE__ */ new Map());
28213
28196
  const pendingGRef = useRef9(false);
28214
- useEffect13(() => {
28197
+ useEffect14(() => {
28215
28198
  setTokenReviewRow(0);
28216
28199
  setTokenReviewEditing(false);
28217
28200
  setTokenReviewEditCursor(0);
@@ -28684,7 +28667,7 @@ var init_preview_annotations = __esm({
28684
28667
  });
28685
28668
 
28686
28669
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
28687
- import { useCallback as useCallback3, useEffect as useEffect14, useRef as useRef10, useState as useState20 } from "react";
28670
+ import { useCallback as useCallback3, useEffect as useEffect15, useRef as useRef10, useState as useState20 } from "react";
28688
28671
  function useLivePreview(opts) {
28689
28672
  const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
28690
28673
  const [status, setStatus] = useState20("idle");
@@ -28694,14 +28677,14 @@ function useLivePreview(opts) {
28694
28677
  const latestRef = useRef10(0);
28695
28678
  const inflightRef = useRef10(0);
28696
28679
  const optsRef = useRef10(opts);
28697
- useEffect14(() => {
28680
+ useEffect15(() => {
28698
28681
  optsRef.current = opts;
28699
28682
  });
28700
28683
  const disabledRef = useRef10(disabled);
28701
- useEffect14(() => {
28684
+ useEffect15(() => {
28702
28685
  disabledRef.current = disabled;
28703
28686
  }, [disabled]);
28704
- useEffect14(() => {
28687
+ useEffect15(() => {
28705
28688
  return () => {
28706
28689
  if (timerRef.current) {
28707
28690
  clearTimeout(timerRef.current);
@@ -28782,7 +28765,7 @@ var init_use_live_preview = __esm({
28782
28765
  });
28783
28766
 
28784
28767
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
28785
- import { useCallback as useCallback4, useEffect as useEffect15, useState as useState21 } from "react";
28768
+ import { useCallback as useCallback4, useEffect as useEffect16, useState as useState21 } from "react";
28786
28769
  function useReviewPreview({
28787
28770
  components,
28788
28771
  loading,
@@ -28824,13 +28807,13 @@ function useReviewPreview({
28824
28807
  deleteAllComponents
28825
28808
  });
28826
28809
  const [spinnerTick, setSpinnerTick] = useState21(0);
28827
- useEffect15(() => {
28810
+ useEffect16(() => {
28828
28811
  if (livePreviewHook.status !== "running") return;
28829
28812
  const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
28830
28813
  return () => clearInterval(id);
28831
28814
  }, [livePreviewHook.status]);
28832
28815
  const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
28833
- useEffect15(() => {
28816
+ useEffect16(() => {
28834
28817
  if (loading) return;
28835
28818
  if (!livePreview) return;
28836
28819
  if (components.length === 0) return;
@@ -28887,7 +28870,7 @@ var init_LivePreviewSummary = __esm({
28887
28870
  });
28888
28871
 
28889
28872
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
28890
- import { useCallback as useCallback5, useEffect as useEffect16, useMemo as useMemo4, useRef as useRef11, useState as useState22 } from "react";
28873
+ import { useCallback as useCallback5, useEffect as useEffect17, useMemo as useMemo4, useRef as useRef11, useState as useState22 } from "react";
28891
28874
  import figures7 from "figures";
28892
28875
  import { Box as Box33, Text as Text36 } from "ink";
28893
28876
  import { Fragment as Fragment13, jsx as jsx43, jsxs as jsxs34 } from "react/jsx-runtime";
@@ -29208,7 +29191,7 @@ function GenerateReviewStepView({
29208
29191
  [components]
29209
29192
  );
29210
29193
  const closures = useMemo4(() => computeAllClosures(componentGraph), [componentGraph]);
29211
- useEffect16(() => {
29194
+ useEffect17(() => {
29212
29195
  if (seededGroupsRef.current) return;
29213
29196
  if (closures.size === 0 && slotCycles.length === 0) return;
29214
29197
  seededGroupsRef.current = true;
@@ -29235,7 +29218,7 @@ function GenerateReviewStepView({
29235
29218
  suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
29236
29219
  }));
29237
29220
  }, [slotCycles, cycleView]);
29238
- useEffect16(() => {
29221
+ useEffect17(() => {
29239
29222
  const decision = computeAutoRejectDecision({
29240
29223
  loading,
29241
29224
  autoRejectFired: autoRejectFiredRef.current,
@@ -29279,7 +29262,7 @@ function GenerateReviewStepView({
29279
29262
  applySnapshot: applyHistorySnapshot
29280
29263
  });
29281
29264
  const autoRejectPushedRef = useRef11(false);
29282
- useEffect16(() => {
29265
+ useEffect17(() => {
29283
29266
  if (loading) return;
29284
29267
  if (!historySeededRef.current) return;
29285
29268
  if (!autoRejectFiredRef.current) return;
@@ -29363,7 +29346,7 @@ function GenerateReviewStepView({
29363
29346
  const panelHeight = leftPanelHeight + 2;
29364
29347
  const panelContentHeight = Math.max(1, panelHeight - 3);
29365
29348
  const cycleViewportHeight = Math.max(1, panelHeight - 4);
29366
- useEffect16(() => {
29349
+ useEffect17(() => {
29367
29350
  if (selectableRowPositions.length === 0) return;
29368
29351
  const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
29369
29352
  const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
@@ -30463,10 +30446,10 @@ var init_path_utils = __esm({
30463
30446
  });
30464
30447
 
30465
30448
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
30466
- import { useEffect as useEffect17, useState as useState23 } from "react";
30449
+ import { useEffect as useEffect18, useState as useState23 } from "react";
30467
30450
  function useBlinkingCursor() {
30468
30451
  const [visible, setVisible] = useState23(true);
30469
- useEffect17(() => {
30452
+ useEffect18(() => {
30470
30453
  const interval = setInterval(() => setVisible((current) => !current), 500);
30471
30454
  return () => clearInterval(interval);
30472
30455
  }, []);
@@ -30593,12 +30576,12 @@ var init_StepHeader = __esm({
30593
30576
  });
30594
30577
 
30595
30578
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
30596
- import { useEffect as useEffect18, useState as useState25 } from "react";
30579
+ import { useEffect as useEffect19, useState as useState25 } from "react";
30597
30580
  import { Spinner as Spinner2 } from "@inkjs/ui";
30598
30581
  import { jsx as jsx49 } from "react/jsx-runtime";
30599
30582
  function useTimedSpinner() {
30600
30583
  const [elapsedSeconds, setElapsedSeconds] = useState25(0);
30601
- useEffect18(() => {
30584
+ useEffect19(() => {
30602
30585
  const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
30603
30586
  return () => {
30604
30587
  clearInterval(timer);
@@ -30844,7 +30827,7 @@ var init_preview_confirmation_input = __esm({
30844
30827
  });
30845
30828
 
30846
30829
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
30847
- import { useEffect as useEffect19, useState as useState26, useMemo as useMemo5 } from "react";
30830
+ import { useEffect as useEffect20, useState as useState26, useMemo as useMemo5 } from "react";
30848
30831
  import { Box as Box40, Text as Text43 } from "ink";
30849
30832
  import { Fragment as Fragment15, jsx as jsx51, jsxs as jsxs41 } from "react/jsx-runtime";
30850
30833
  function buildPreviewSummaryLines(preview) {
@@ -31056,7 +31039,7 @@ function WizardPreviewStep({
31056
31039
  const activeLines = diffExpanded ? diffLines : summaryLines;
31057
31040
  const maxScroll = Math.max(0, activeLines.length - viewportHeight);
31058
31041
  const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
31059
- useEffect19(() => {
31042
+ useEffect20(() => {
31060
31043
  setScrollOffset((previous) => Math.min(previous, maxScroll));
31061
31044
  }, [maxScroll]);
31062
31045
  useImmediateInput((input, key) => {
@@ -31160,7 +31143,7 @@ var init_run_teaser = __esm({
31160
31143
  });
31161
31144
 
31162
31145
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
31163
- import { useEffect as useEffect20, useRef as useRef12 } from "react";
31146
+ import { useEffect as useEffect21, useRef as useRef12 } from "react";
31164
31147
  import { Box as Box41 } from "ink";
31165
31148
  import { jsx as jsx52, jsxs as jsxs42 } from "react/jsx-runtime";
31166
31149
  function totalStepsFor(state) {
@@ -31182,7 +31165,7 @@ function FlowScreen({
31182
31165
  const totalSteps = totalStepsFor(state);
31183
31166
  const quit = () => onExit(0);
31184
31167
  const previousStep = useRef12(state.step);
31185
- useEffect20(() => {
31168
+ useEffect21(() => {
31186
31169
  if (previousStep.current !== state.step) {
31187
31170
  onStepChange?.();
31188
31171
  previousStep.current = state.step;
@@ -31806,7 +31789,7 @@ var init_save = __esm({
31806
31789
  writeFile: (path5, contents) => writeFile7(path5, contents),
31807
31790
  appendRun,
31808
31791
  buildSourceFingerprint,
31809
- sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
31792
+ sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
31810
31793
  warn: (message) => process.stderr.write(message)
31811
31794
  });
31812
31795
  }
@@ -31828,7 +31811,7 @@ var init_types9 = __esm({
31828
31811
  import { appendFileSync, writeFileSync } from "node:fs";
31829
31812
  import { mkdir as mkdir8 } from "node:fs/promises";
31830
31813
  import { tmpdir } from "node:os";
31831
- import { join as join25, resolve as resolve25 } from "node:path";
31814
+ import { join as join25 } from "node:path";
31832
31815
  function appendWizardLog(entry) {
31833
31816
  appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
31834
31817
  }
@@ -32070,7 +32053,7 @@ function createFlowController(start, deps) {
32070
32053
  },
32071
32054
  async submitPath(submitted) {
32072
32055
  await deps.mkdir(submitted);
32073
- if (resolve25(submitted) !== resolve25(state.outDir) && await deps.detectSaveConflict(submitted)) {
32056
+ if (await deps.detectSaveConflict(submitted)) {
32074
32057
  const subdir = deps.buildTimestampedSubdir(submitted);
32075
32058
  await deps.mkdir(subdir);
32076
32059
  await proceedToWrite(subdir);
@@ -32107,7 +32090,7 @@ var init_controller = __esm({
32107
32090
  });
32108
32091
 
32109
32092
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
32110
- import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } from "react";
32093
+ import { useEffect as useEffect22, useRef as useRef13, useSyncExternalStore } from "react";
32111
32094
  function useFlow(start, deps = realFlowDeps) {
32112
32095
  const controller = useRef13();
32113
32096
  if (start && !controller.current) {
@@ -32122,7 +32105,7 @@ function useFlow(start, deps = realFlowDeps) {
32122
32105
  (listener) => current?.subscribe(listener) ?? (() => void 0),
32123
32106
  () => current?.getState()
32124
32107
  );
32125
- useEffect21(() => {
32108
+ useEffect22(() => {
32126
32109
  if (!start) controller.current = void 0;
32127
32110
  }, [start]);
32128
32111
  return current && state ? { controller: current, state } : void 0;
@@ -32154,18 +32137,9 @@ var init_debug_mode_store = __esm({
32154
32137
  });
32155
32138
 
32156
32139
  // packages/experience-design-system-cli/src/tui/debug-store.ts
32157
- var debug_store_exports = {};
32158
- __export(debug_store_exports, {
32159
- currentDebugSessionDir: () => currentDebugSessionDir,
32160
- currentSessionDir: () => currentSessionDir,
32161
- finishDebugRun: () => finishDebugRun,
32162
- startDebugRun: () => startDebugRun,
32163
- startDebugSessionIn: () => startDebugSessionIn,
32164
- startImportRun: () => startImportRun
32165
- });
32166
32140
  import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
32167
32141
  import { existsSync as existsSync11, readdirSync as readdirSync4 } from "node:fs";
32168
- import { join as join26, resolve as resolve26 } from "node:path";
32142
+ import { join as join26 } from "node:path";
32169
32143
  function generateRunId() {
32170
32144
  const now = /* @__PURE__ */ new Date();
32171
32145
  const pad = (n) => String(n).padStart(2, "0");
@@ -32178,17 +32152,10 @@ function datePrefix(now = /* @__PURE__ */ new Date()) {
32178
32152
  function slugify(value) {
32179
32153
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
32180
32154
  }
32181
- async function readBaseDir() {
32182
- try {
32183
- const dir = (await readSettings2())["contentfulBaseDir"];
32184
- return typeof dir === "string" && dir !== "" ? resolve26(dir) : void 0;
32185
- } catch {
32186
- return void 0;
32187
- }
32188
- }
32189
- function nextSessionId(contentfulDir) {
32155
+ function generateSessionId3() {
32190
32156
  const today = datePrefix();
32191
- const existing = existsSync11(contentfulDir) ? readdirSync4(contentfulDir) : [];
32157
+ const root = debugSessionsDir2();
32158
+ const existing = existsSync11(root) ? readdirSync4(root) : [];
32192
32159
  const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
32193
32160
  const maxSeq = existing.reduce((max, entry) => {
32194
32161
  const match2 = seqPattern.exec(entry);
@@ -32196,38 +32163,11 @@ function nextSessionId(contentfulDir) {
32196
32163
  }, 0);
32197
32164
  return `${today}-session-${maxSeq + 1}`;
32198
32165
  }
32199
- function startSession(base, { replace }) {
32200
- const contentfulDir = join26(base, ".contentful");
32201
- if (replace || !sessionDir) sessionDir = join26(contentfulDir, nextSessionId(contentfulDir));
32202
- return sessionDir;
32166
+ function sessionDebugDir() {
32167
+ return join26(debugSessionsDir2(), SESSION_ID);
32203
32168
  }
32204
32169
  function currentDebugSessionDir() {
32205
- return sessionDir && join26(sessionDir, "debug");
32206
- }
32207
- function currentSessionDir() {
32208
- return sessionDir;
32209
- }
32210
- async function startDebugSessionIn(base, { replace = false } = {}) {
32211
- try {
32212
- if (!await isDebugModeEnabled()) return;
32213
- await mkdir9(join26(startSession(resolve26(base), { replace }), "debug"), { recursive: true });
32214
- } catch {
32215
- }
32216
- }
32217
- function nextImportRunDir(session) {
32218
- const existing = existsSync11(session) ? readdirSync4(session) : [];
32219
- const maxRun = existing.reduce((max, entry) => {
32220
- const match2 = /^dsi-import-(\d+)$/.exec(entry);
32221
- return match2 ? Math.max(max, Number(match2[1])) : max;
32222
- }, 0);
32223
- return join26(session, `dsi-import-${maxRun + 1}`);
32224
- }
32225
- async function startImportRun(projectPath) {
32226
- await startDebugSessionIn(projectPath);
32227
- if (!sessionDir) return join26(resolve26(projectPath), ".contentful");
32228
- const dir = nextImportRunDir(sessionDir);
32229
- await mkdir9(dir, { recursive: true });
32230
- return dir;
32170
+ return sessionDebugDir();
32231
32171
  }
32232
32172
  async function isDebugModeEnabled() {
32233
32173
  try {
@@ -32268,10 +32208,8 @@ async function finishDebugRun({
32268
32208
  pendingRun = void 0;
32269
32209
  const durationMs = Date.now() - run.startedAt;
32270
32210
  const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
32271
- const root = currentDebugSessionDir();
32272
- if (!root) return;
32273
32211
  const flowSegments = run.flow.split("/");
32274
- const dir = join26(root, ...flowSegments);
32212
+ const dir = join26(sessionDebugDir(), ...flowSegments);
32275
32213
  await mkdir9(dir, { recursive: true });
32276
32214
  const filename = nextAttemptFilename(dir, run.menuOption);
32277
32215
  await writeFile8(join26(dir, filename), content, { mode: 384 });
@@ -32318,16 +32256,17 @@ ${JSON.stringify(finish.outputs, null, 2)}
32318
32256
  function handleCrash() {
32319
32257
  return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
32320
32258
  }
32321
- var pendingRun, sessionDir;
32259
+ var pendingRun, SESSION_ID;
32322
32260
  var init_debug_store = __esm({
32323
32261
  "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
32324
32262
  "use strict";
32325
32263
  init_config();
32326
32264
  init_version();
32327
32265
  init_debug_mode_store();
32328
- void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
32329
- if (!enabled || !base) return void 0;
32330
- return mkdir9(join26(startSession(base, { replace: false }), "debug"), { recursive: true });
32266
+ SESSION_ID = generateSessionId3();
32267
+ void isDebugModeEnabled().then((enabled) => {
32268
+ if (!enabled) return void 0;
32269
+ return mkdir9(sessionDebugDir(), { recursive: true });
32331
32270
  });
32332
32271
  process.once("uncaughtException", (err) => {
32333
32272
  void handleCrash().finally(() => {
@@ -32353,7 +32292,8 @@ async function readHelpInfo() {
32353
32292
  return {
32354
32293
  storage: [
32355
32294
  { label: "Config folder", value: configRoot2() },
32356
- { label: "Settings file", value: configFilePath2() }
32295
+ { label: "Settings file", value: configFilePath2() },
32296
+ { label: "Debug logs", value: debugSessionsDir2() }
32357
32297
  ],
32358
32298
  troubleshooting: [
32359
32299
  { label: "CLI version", value: readPackageVersion() },
@@ -32362,7 +32302,7 @@ async function readHelpInfo() {
32362
32302
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
32363
32303
  {
32364
32304
  label: "This session",
32365
- value: !debugMode.enabled ? "no logs written while Debug Mode is off" : currentDebugSessionDir() ?? "not started: set the Root Project Directory in Settings, or start an import"
32305
+ value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
32366
32306
  }
32367
32307
  ]
32368
32308
  };
@@ -32378,7 +32318,7 @@ var init_help_info = __esm({
32378
32318
  });
32379
32319
 
32380
32320
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
32381
- import { useEffect as useEffect22, useState as useState27 } from "react";
32321
+ import { useEffect as useEffect23, useState as useState27 } from "react";
32382
32322
  import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
32383
32323
  import { Fragment as Fragment16, jsx as jsx53, jsxs as jsxs43 } from "react/jsx-runtime";
32384
32324
  function Section({ title, rows }) {
@@ -32392,7 +32332,7 @@ function Section({ title, rows }) {
32392
32332
  }
32393
32333
  function HelpScreen({ onDone }) {
32394
32334
  const [info, setInfo] = useState27();
32395
- useEffect22(() => {
32335
+ useEffect23(() => {
32396
32336
  startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
32397
32337
  void readHelpInfo().then(setInfo);
32398
32338
  }, []);
@@ -32519,8 +32459,7 @@ async function readCredentials() {
32519
32459
  cmaToken: store.cmaToken || "",
32520
32460
  host: store.host || "",
32521
32461
  defaultComponentDir: store.defaultComponentDir || "",
32522
- defaultTokenFile: store.defaultTokenFile || "",
32523
- contentfulBaseDir: store.contentfulBaseDir || ""
32462
+ defaultTokenFile: store.defaultTokenFile || ""
32524
32463
  };
32525
32464
  }
32526
32465
  async function writeCredentials(config) {
@@ -32542,7 +32481,7 @@ var init_config_store = __esm({
32542
32481
  });
32543
32482
 
32544
32483
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
32545
- import { useEffect as useEffect23, useState as useState29 } from "react";
32484
+ import { useEffect as useEffect24, useState as useState29 } from "react";
32546
32485
  import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
32547
32486
  import TextInput4 from "ink-text-input";
32548
32487
  import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
@@ -32553,8 +32492,7 @@ function debugFields(config) {
32553
32492
  cma_token: config?.cmaToken ?? "",
32554
32493
  host: config?.host ?? "",
32555
32494
  default_component_dir: config?.defaultComponentDir ?? "",
32556
- default_token_file: config?.defaultTokenFile ?? "",
32557
- contentful_base_dir: config?.contentfulBaseDir ?? ""
32495
+ default_token_file: config?.defaultTokenFile ?? ""
32558
32496
  };
32559
32497
  }
32560
32498
  function ConfigurationScreen({ onDone }) {
@@ -32565,7 +32503,7 @@ function ConfigurationScreen({ onDone }) {
32565
32503
  const [lastSaved, setLastSaved] = useState29(null);
32566
32504
  const [editing, setEditing] = useState29(false);
32567
32505
  const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
32568
- useEffect23(() => {
32506
+ useEffect24(() => {
32569
32507
  readCredentials().then((cfg) => {
32570
32508
  setConfig(cfg);
32571
32509
  setStage("form");
@@ -32592,7 +32530,6 @@ function ConfigurationScreen({ onDone }) {
32592
32530
  setNotice(null);
32593
32531
  writeCredentials(config).then(() => {
32594
32532
  setLastSaved(config);
32595
- if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
32596
32533
  setNotice({ kind: "success", text: "Configuration saved" });
32597
32534
  setStage("form");
32598
32535
  }).catch((err) => {
@@ -32658,7 +32595,10 @@ function ConfigurationScreen({ onDone }) {
32658
32595
  const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
32659
32596
  return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
32660
32597
  /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
32661
- /* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
32598
+ /* @__PURE__ */ jsxs45(Text46, { bold: isActive, children: [
32599
+ FIELD_LABELS[field],
32600
+ ":"
32601
+ ] }),
32662
32602
  isActive && editing ? /* @__PURE__ */ jsx55(
32663
32603
  TextInput4,
32664
32604
  {
@@ -32667,8 +32607,7 @@ function ConfigurationScreen({ onDone }) {
32667
32607
  onSubmit: () => setEditing(false),
32668
32608
  mask: field === "cmaToken" ? "\u2022" : void 0
32669
32609
  }
32670
- ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
32671
- FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
32610
+ ) : /* @__PURE__ */ jsx55(Text46, { children: display || /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" }) })
32672
32611
  ] }, field);
32673
32612
  }) }),
32674
32613
  notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
@@ -32699,7 +32638,7 @@ function ConfigurationScreen({ onDone }) {
32699
32638
  )
32700
32639
  ] });
32701
32640
  }
32702
- var FIELD_ORDER, FIELD_LABELS, FIELD_HINTS, LABEL_WIDTH;
32641
+ var FIELD_ORDER, FIELD_LABELS;
32703
32642
  var init_ContentfulConfigScreen = __esm({
32704
32643
  "packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx"() {
32705
32644
  "use strict";
@@ -32713,22 +32652,16 @@ var init_ContentfulConfigScreen = __esm({
32713
32652
  "cmaToken",
32714
32653
  "host",
32715
32654
  "defaultComponentDir",
32716
- "defaultTokenFile",
32717
- "contentfulBaseDir"
32655
+ "defaultTokenFile"
32718
32656
  ];
32719
32657
  FIELD_LABELS = {
32720
32658
  spaceId: "Space ID",
32721
32659
  environmentId: "Environment ID",
32722
32660
  cmaToken: "CMA Token",
32723
- host: "API Host",
32724
- defaultComponentDir: "Default component directory",
32725
- defaultTokenFile: "Default token file",
32726
- contentfulBaseDir: "Root Project Directory"
32661
+ host: "API Host (optional)",
32662
+ defaultComponentDir: "Default component directory (optional)",
32663
+ defaultTokenFile: "Default token file (optional)"
32727
32664
  };
32728
- FIELD_HINTS = {
32729
- contentfulBaseDir: "(where .contentful goes)"
32730
- };
32731
- LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
32732
32665
  }
32733
32666
  });
32734
32667
 
@@ -32754,13 +32687,13 @@ var init_analytics_store = __esm({
32754
32687
  });
32755
32688
 
32756
32689
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
32757
- import { useEffect as useEffect24, useState as useState30 } from "react";
32690
+ import { useEffect as useEffect25, useState as useState30 } from "react";
32758
32691
  import { Box as Box45, Text as Text47, useInput as useInput12 } from "ink";
32759
32692
  import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
32760
32693
  function OptInAnalyticsScreen({ onDone }) {
32761
32694
  const [loading, setLoading] = useState30(true);
32762
32695
  const [enabled, setEnabled] = useState30(true);
32763
- useEffect24(() => {
32696
+ useEffect25(() => {
32764
32697
  readAnalyticsSetting().then((setting) => {
32765
32698
  setEnabled(setting.enabled);
32766
32699
  setLoading(false);
@@ -32823,12 +32756,12 @@ var init_screen11 = __esm({
32823
32756
  });
32824
32757
 
32825
32758
  // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
32826
- import { useEffect as useEffect25, useState as useState31 } from "react";
32759
+ import { useEffect as useEffect26, useState as useState31 } from "react";
32827
32760
  import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
32828
32761
  import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
32829
32762
  function UpgradeScreen({ onDone }) {
32830
32763
  const [upgradeCheck, setUpgradeCheck] = useState31();
32831
- useEffect25(() => {
32764
+ useEffect26(() => {
32832
32765
  startDebugRun({
32833
32766
  flow: "upgrade",
32834
32767
  step: "01-upgrade",
@@ -32903,13 +32836,13 @@ var init_PageContainer4 = __esm({
32903
32836
  });
32904
32837
 
32905
32838
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
32906
- import { useEffect as useEffect26, useState as useState32 } from "react";
32839
+ import { useEffect as useEffect27, useState as useState32 } from "react";
32907
32840
  import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
32908
32841
  import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
32909
32842
  function DebugModeScreen({ onDone }) {
32910
32843
  const [loading, setLoading] = useState32(true);
32911
32844
  const [enabled, setEnabled] = useState32(true);
32912
- useEffect26(() => {
32845
+ useEffect27(() => {
32913
32846
  readDebugModeSetting().then((setting) => {
32914
32847
  setEnabled(setting.enabled);
32915
32848
  setLoading(false);
@@ -32972,7 +32905,7 @@ __export(app_exports, {
32972
32905
  runApp: () => runApp
32973
32906
  });
32974
32907
  import { join as join27 } from "node:path";
32975
- import { useEffect as useEffect27, useState as useState33 } from "react";
32908
+ import { useEffect as useEffect28, useState as useState33 } from "react";
32976
32909
  import { Fragment as Fragment19, jsx as jsx59 } from "react/jsx-runtime";
32977
32910
  function App({ importOptions, inkClear }) {
32978
32911
  const [screen, setScreen] = useState33("start");
@@ -33004,7 +32937,7 @@ function App({ importOptions, inkClear }) {
33004
32937
  const [flowStart, setFlowStart] = useState33();
33005
32938
  const flow = useFlow(flowStart);
33006
32939
  const [importDefaults, setImportDefaults] = useState33();
33007
- useEffect27(() => {
32940
+ useEffect28(() => {
33008
32941
  if (screen !== "import") {
33009
32942
  setImportDefaults(void 0);
33010
32943
  return;
@@ -33022,7 +32955,7 @@ function App({ importOptions, inkClear }) {
33022
32955
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
33023
32956
  const state = await inspectTokens({
33024
32957
  rawTokensPath: tokens,
33025
- contentfulDir: join27(resolveUserPath(projectPath2), ".contentful"),
32958
+ outDir: join27(resolveUserPath(projectPath2), ".contentful"),
33026
32959
  cache: importOptions.cache
33027
32960
  });
33028
32961
  if (state.kind === "cached") {
@@ -33043,7 +32976,6 @@ function App({ importOptions, inkClear }) {
33043
32976
  const settings = await readSettings2();
33044
32977
  const { agent, agentModel } = resolveAgentChoice(launch.agent, settings);
33045
32978
  const generatePromptPath = typeof settings.generatePromptPath === "string" ? settings.generatePromptPath : void 0;
33046
- const outDir = await (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).startImportRun(resolveUserPath(launch.projectPath ?? ""));
33047
32979
  setExtractionRun({
33048
32980
  ...generatePromptPath ? { generatePromptPath } : {},
33049
32981
  // the later steps get the same agent, so they use what the stage used
@@ -33052,7 +32984,6 @@ function App({ importOptions, inkClear }) {
33052
32984
  tokenStrategy,
33053
32985
  input: {
33054
32986
  projectPath: resolveUserPath(launch.projectPath ?? ""),
33055
- outDir,
33056
32987
  filePaths: launch.filePaths ?? [],
33057
32988
  rawTokensPath: launch.tokens ?? "",
33058
32989
  tokenStrategy,
@@ -33064,12 +32995,12 @@ function App({ importOptions, inkClear }) {
33064
32995
  }
33065
32996
  });
33066
32997
  };
33067
- useEffect27(() => {
32998
+ useEffect28(() => {
33068
32999
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
33069
33000
  setExtractionRun(void 0);
33070
33001
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
33071
33002
  }, [extraction, extractionRun]);
33072
- useEffect27(() => {
33003
+ useEffect28(() => {
33073
33004
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
33074
33005
  const { extraction: produced, input, generatePromptPath } = scopeRun;
33075
33006
  setGenerationInput({
@@ -33087,7 +33018,7 @@ function App({ importOptions, inkClear }) {
33087
33018
  ...generatePromptPath ? { generatePromptPath } : {}
33088
33019
  });
33089
33020
  }, [scopeFlow, scopeRun, generationInput]);
33090
- useEffect27(() => {
33021
+ useEffect28(() => {
33091
33022
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
33092
33023
  const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
33093
33024
  inkClear();
@@ -33400,14 +33331,14 @@ function runDevWatch(args) {
33400
33331
  process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
33401
33332
  return Promise.resolve(1);
33402
33333
  }
33403
- return new Promise((resolve27) => {
33334
+ return new Promise((resolve25) => {
33404
33335
  const child = spawn2(process.execPath, [script, ...args], { stdio: "inherit" });
33405
33336
  process.on("SIGINT", () => void 0);
33406
- child.on("exit", (code) => resolve27(code ?? 0));
33337
+ child.on("exit", (code) => resolve25(code ?? 0));
33407
33338
  child.on("error", (err) => {
33408
33339
  process.stderr.write(`${err.message}
33409
33340
  `);
33410
- resolve27(1);
33341
+ resolve25(1);
33411
33342
  });
33412
33343
  });
33413
33344
  }