@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/app.js CHANGED
@@ -8,71 +8,6 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // packages/experience-design-system-cli/src/tui/package-root.ts
12
- import { existsSync, readFileSync } from "node:fs";
13
- import { dirname, join } from "node:path";
14
- import { fileURLToPath } from "node:url";
15
- function findPackageRoot(startUrl, packageName) {
16
- let dir = dirname(fileURLToPath(startUrl));
17
- let found;
18
- while (true) {
19
- const manifestPath = join(dir, "package.json");
20
- if (existsSync(manifestPath)) {
21
- const pkg = JSON.parse(readFileSync(manifestPath, "utf8"));
22
- if (pkg.name === packageName) found = dir;
23
- }
24
- const parent = dirname(dir);
25
- if (parent === dir) return found ?? dir;
26
- dir = parent;
27
- }
28
- }
29
- var init_package_root = __esm({
30
- "packages/experience-design-system-cli/src/tui/package-root.ts"() {
31
- "use strict";
32
- }
33
- });
34
-
35
- // packages/experience-design-system-cli/src/tui/upgrade/version.ts
36
- import { readFileSync as readFileSync2 } from "node:fs";
37
- import { join as join2 } from "node:path";
38
- import semver from "semver";
39
- function readPackageVersion() {
40
- const root = findPackageRoot(import.meta.url, PACKAGE_NAME);
41
- const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
42
- return pkg.version ?? "unknown";
43
- }
44
- function parseVersionTag(tag) {
45
- const match2 = /^v(\d+\.\d+\.\d+)$/.exec(tag);
46
- return match2 ? match2[1] : void 0;
47
- }
48
- async function checkForUpgrade() {
49
- const current = readPackageVersion();
50
- try {
51
- const response = await fetch(TAGS_URL);
52
- if (!response.ok) return { status: "error" };
53
- const tags = await response.json();
54
- const versions = tags.map((tag) => tag.name ? parseVersionTag(tag.name) : void 0).filter((v) => v !== void 0);
55
- if (versions.length === 0) return { status: "error" };
56
- const latest = versions.reduce((best, v) => semver.gt(v, best) ? v : best);
57
- if (!semver.valid(current)) return { status: "error" };
58
- if (semver.gt(latest, current)) {
59
- return { status: "update-available", current, latest };
60
- }
61
- return { status: "up-to-date", current };
62
- } catch {
63
- return { status: "error" };
64
- }
65
- }
66
- var PACKAGE_NAME, TAGS_URL;
67
- var init_version = __esm({
68
- "packages/experience-design-system-cli/src/tui/upgrade/version.ts"() {
69
- "use strict";
70
- init_package_root();
71
- PACKAGE_NAME = "@contentful/experience-design-system-cli";
72
- TAGS_URL = "https://api.github.com/repos/contentful/experience-design-system-sdk-public/tags?per_page=10";
73
- }
74
- });
75
-
76
11
  // packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-name.js
77
12
  var AGENT_NAMES;
78
13
  var init_agent_name = __esm({
@@ -837,7 +772,7 @@ async function runAgent(options) {
837
772
  promptLen: prompt.length,
838
773
  promptHead: prompt.slice(0, 500)
839
774
  });
840
- return new Promise((resolve27) => {
775
+ return new Promise((resolve25) => {
841
776
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
842
777
  const child = spawn(binary, args, {
843
778
  stdio: ["pipe", "pipe", "pipe"],
@@ -886,7 +821,7 @@ async function runAgent(options) {
886
821
  stderrLen: stderr.length,
887
822
  stderrTail: stderr.slice(-1e3)
888
823
  });
889
- resolve27(result);
824
+ resolve25(result);
890
825
  });
891
826
  });
892
827
  }
@@ -908,7 +843,7 @@ async function checkAgentAuth(agent) {
908
843
  return "not-found";
909
844
  if (agent !== "claude")
910
845
  return "ok";
911
- return new Promise((resolve27) => {
846
+ return new Promise((resolve25) => {
912
847
  const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
913
848
  let stdout = "";
914
849
  let done = false;
@@ -917,7 +852,7 @@ async function checkAgentAuth(agent) {
917
852
  return;
918
853
  done = true;
919
854
  child.kill("SIGTERM");
920
- resolve27("unauthenticated");
855
+ resolve25("unauthenticated");
921
856
  }, 5e3);
922
857
  child.stdout?.on("data", (chunk) => {
923
858
  stdout += chunk.toString();
@@ -928,14 +863,14 @@ async function checkAgentAuth(agent) {
928
863
  done = true;
929
864
  clearTimeout(timer);
930
865
  if (code !== 0) {
931
- resolve27("unauthenticated");
866
+ resolve25("unauthenticated");
932
867
  return;
933
868
  }
934
869
  try {
935
870
  const status = JSON.parse(stdout);
936
- resolve27(status.loggedIn ? "ok" : "unauthenticated");
871
+ resolve25(status.loggedIn ? "ok" : "unauthenticated");
937
872
  } catch {
938
- resolve27("unauthenticated");
873
+ resolve25("unauthenticated");
939
874
  }
940
875
  });
941
876
  });
@@ -945,9 +880,9 @@ async function binaryIsOnPath(binary) {
945
880
  const fs = await import("node:fs/promises");
946
881
  return fs.access(binary).then(() => true, () => false);
947
882
  }
948
- return new Promise((resolve27) => {
883
+ return new Promise((resolve25) => {
949
884
  const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
950
- child.on("close", (code) => resolve27(code === 0));
885
+ child.on("close", (code) => resolve25(code === 0));
951
886
  });
952
887
  }
953
888
  var init_check_agent_auth = __esm({
@@ -2081,256 +2016,9 @@ var init_cache_keys = __esm({
2081
2016
  }
2082
2017
  });
2083
2018
 
2084
- // packages/experience-design-system-types/dist/src/config/index.js
2085
- import { randomBytes as randomBytes3 } from "node:crypto";
2086
- import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
2087
- import { homedir as homedir3 } from "node:os";
2088
- import { dirname as dirname13, join as join17 } from "node:path";
2089
- function configRoot2() {
2090
- return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
2091
- }
2092
- async function readSettings2() {
2093
- try {
2094
- return JSON.parse(await readFile18(configFilePath2(), "utf8"));
2095
- } catch {
2096
- return {};
2097
- }
2098
- }
2099
- async function writeSettings2(settings) {
2100
- const path5 = configFilePath2();
2101
- await mkdir6(dirname13(path5), { recursive: true });
2102
- const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
2103
- await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
2104
- `, { mode: 384 });
2105
- await rename2(tmp, path5);
2106
- }
2107
- async function updateSettings2(patch) {
2108
- await writeSettings2({ ...await readSettings2(), ...patch });
2109
- }
2110
- var configFilePath2;
2111
- var init_config = __esm({
2112
- "packages/experience-design-system-types/dist/src/config/index.js"() {
2113
- "use strict";
2114
- configFilePath2 = () => join17(configRoot2(), "config.json");
2115
- }
2116
- });
2117
-
2118
- // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
2119
- async function readDebugModeSetting() {
2120
- const { debugMode } = await readSettings2();
2121
- return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
2122
- }
2123
- async function writeDebugModeSetting(setting) {
2124
- await updateSettings2({ debugMode: setting });
2125
- }
2126
- var DEFAULT_DEBUG_MODE_SETTING;
2127
- var init_debug_mode_store = __esm({
2128
- "packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
2129
- "use strict";
2130
- init_config();
2131
- DEFAULT_DEBUG_MODE_SETTING = {
2132
- enabled: true
2133
- };
2134
- }
2135
- });
2136
-
2137
- // packages/experience-design-system-cli/src/tui/debug-store.ts
2138
- var debug_store_exports = {};
2139
- __export(debug_store_exports, {
2140
- currentDebugSessionDir: () => currentDebugSessionDir,
2141
- currentSessionDir: () => currentSessionDir,
2142
- finishDebugRun: () => finishDebugRun,
2143
- startDebugRun: () => startDebugRun,
2144
- startDebugSessionIn: () => startDebugSessionIn,
2145
- startImportRun: () => startImportRun
2146
- });
2147
- import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
2148
- import { existsSync as existsSync9, readdirSync as readdirSync4 } from "node:fs";
2149
- import { join as join24, resolve as resolve26 } from "node:path";
2150
- function generateRunId() {
2151
- const now = /* @__PURE__ */ new Date();
2152
- const pad = (n) => String(n).padStart(2, "0");
2153
- return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
2154
- }
2155
- function datePrefix(now = /* @__PURE__ */ new Date()) {
2156
- const pad = (n) => String(n).padStart(2, "0");
2157
- return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
2158
- }
2159
- function slugify(value) {
2160
- return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
2161
- }
2162
- async function readBaseDir() {
2163
- try {
2164
- const dir = (await readSettings2())["contentfulBaseDir"];
2165
- return typeof dir === "string" && dir !== "" ? resolve26(dir) : void 0;
2166
- } catch {
2167
- return void 0;
2168
- }
2169
- }
2170
- function nextSessionId(contentfulDir) {
2171
- const today = datePrefix();
2172
- const existing = existsSync9(contentfulDir) ? readdirSync4(contentfulDir) : [];
2173
- const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
2174
- const maxSeq = existing.reduce((max, entry) => {
2175
- const match2 = seqPattern.exec(entry);
2176
- return match2 ? Math.max(max, Number(match2[1])) : max;
2177
- }, 0);
2178
- return `${today}-session-${maxSeq + 1}`;
2179
- }
2180
- function startSession(base, { replace }) {
2181
- const contentfulDir = join24(base, ".contentful");
2182
- if (replace || !sessionDir) sessionDir = join24(contentfulDir, nextSessionId(contentfulDir));
2183
- return sessionDir;
2184
- }
2185
- function currentDebugSessionDir() {
2186
- return sessionDir && join24(sessionDir, "debug");
2187
- }
2188
- function currentSessionDir() {
2189
- return sessionDir;
2190
- }
2191
- async function startDebugSessionIn(base, { replace = false } = {}) {
2192
- try {
2193
- if (!await isDebugModeEnabled()) return;
2194
- await mkdir9(join24(startSession(resolve26(base), { replace }), "debug"), { recursive: true });
2195
- } catch {
2196
- }
2197
- }
2198
- function nextImportRunDir(session) {
2199
- const existing = existsSync9(session) ? readdirSync4(session) : [];
2200
- const maxRun = existing.reduce((max, entry) => {
2201
- const match2 = /^dsi-import-(\d+)$/.exec(entry);
2202
- return match2 ? Math.max(max, Number(match2[1])) : max;
2203
- }, 0);
2204
- return join24(session, `dsi-import-${maxRun + 1}`);
2205
- }
2206
- async function startImportRun(projectPath) {
2207
- await startDebugSessionIn(projectPath);
2208
- if (!sessionDir) return join24(resolve26(projectPath), ".contentful");
2209
- const dir = nextImportRunDir(sessionDir);
2210
- await mkdir9(dir, { recursive: true });
2211
- return dir;
2212
- }
2213
- async function isDebugModeEnabled() {
2214
- try {
2215
- return (await readDebugModeSetting()).enabled;
2216
- } catch {
2217
- return true;
2218
- }
2219
- }
2220
- function redact(value) {
2221
- const clone = { ...value };
2222
- if ("cma_token" in clone) {
2223
- const raw = clone.cma_token;
2224
- clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
2225
- }
2226
- return clone;
2227
- }
2228
- function startDebugRun({
2229
- flow,
2230
- step,
2231
- menuOption,
2232
- inputs
2233
- }) {
2234
- const runId = generateRunId();
2235
- const startedAt = Date.now();
2236
- const redactedInputs = redact(inputs);
2237
- isDebugModeEnabled().then((enabled) => {
2238
- if (!enabled) return;
2239
- pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
2240
- });
2241
- }
2242
- async function finishDebugRun({
2243
- outputs,
2244
- status,
2245
- exitMethod
2246
- }) {
2247
- const run = pendingRun;
2248
- if (!run) return;
2249
- pendingRun = void 0;
2250
- const durationMs = Date.now() - run.startedAt;
2251
- const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
2252
- const root = currentDebugSessionDir();
2253
- if (!root) return;
2254
- const flowSegments = run.flow.split("/");
2255
- const dir = join24(root, ...flowSegments);
2256
- await mkdir9(dir, { recursive: true });
2257
- const filename = nextAttemptFilename(dir, run.menuOption);
2258
- await writeFile8(join24(dir, filename), content, { mode: 384 });
2259
- }
2260
- function nextAttemptFilename(dir, menuOption) {
2261
- const today = datePrefix();
2262
- const optionSlug = slugify(menuOption);
2263
- const existing = existsSync9(dir) ? readdirSync4(dir) : [];
2264
- const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
2265
- const maxAttempt = existing.reduce((max, entry) => {
2266
- const match2 = attemptPattern.exec(entry);
2267
- return match2 ? Math.max(max, Number(match2[1])) : max;
2268
- }, 0);
2269
- return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
2270
- }
2271
- function renderMarkdown(run, finish) {
2272
- const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
2273
- const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
2274
- const flowSlug = run.flow.split("/").join("-");
2275
- return `# Debug Log
2276
-
2277
- - Run ID: ${run.runId}
2278
- - Flow: ${flowSlug}
2279
- - Step: ${stepLabel2}
2280
- - Menu option: ${run.menuOption}
2281
- - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
2282
- - CLI version: ${readPackageVersion()}
2283
- - Platform: ${process.platform} / Node ${process.version}
2284
- - Duration on screen: ${finish.durationMs}ms
2285
- - Status: ${finish.status}
2286
- - Exit method: ${finish.exitMethod}
2287
-
2288
- ## Inputs
2289
- \`\`\`json
2290
- ${JSON.stringify(run.inputs, null, 2)}
2291
- \`\`\`
2292
-
2293
- ## Outputs
2294
- \`\`\`json
2295
- ${JSON.stringify(finish.outputs, null, 2)}
2296
- \`\`\`
2297
- `;
2298
- }
2299
- function handleCrash() {
2300
- return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
2301
- }
2302
- var pendingRun, sessionDir;
2303
- var init_debug_store = __esm({
2304
- "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
2305
- "use strict";
2306
- init_config();
2307
- init_version();
2308
- init_debug_mode_store();
2309
- void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
2310
- if (!enabled || !base) return void 0;
2311
- return mkdir9(join24(startSession(base, { replace: false }), "debug"), { recursive: true });
2312
- });
2313
- process.once("uncaughtException", (err) => {
2314
- void handleCrash().finally(() => {
2315
- throw err;
2316
- });
2317
- });
2318
- process.once("unhandledRejection", (reason) => {
2319
- void handleCrash().finally(() => {
2320
- throw reason;
2321
- });
2322
- });
2323
- process.once("SIGINT", () => {
2324
- void handleCrash().finally(() => {
2325
- process.exit(130);
2326
- });
2327
- });
2328
- }
2329
- });
2330
-
2331
2019
  // packages/experience-design-system-cli/app.tsx
2332
2020
  import { join as join25 } from "node:path";
2333
- import { useEffect as useEffect27, useState as useState33 } from "react";
2021
+ import { useEffect as useEffect28, useState as useState33 } from "react";
2334
2022
 
2335
2023
  // packages/experience-design-system-cli/src/tui/home/home.tsx
2336
2024
  import { useEffect as useEffect2, useState as useState2 } from "react";
@@ -2365,10 +2053,62 @@ function brandBar(width, ramp = BRAND_RAMP) {
2365
2053
  color
2366
2054
  })).filter((segment) => segment.text.length > 0);
2367
2055
  }
2368
- var FOCUS_MARKER = "\u276F";
2369
-
2370
- // packages/experience-design-system-cli/src/tui/home/home.tsx
2371
- init_version();
2056
+ var FOCUS_MARKER = "\u276F";
2057
+
2058
+ // packages/experience-design-system-cli/src/tui/upgrade/version.ts
2059
+ import { readFileSync as readFileSync2 } from "node:fs";
2060
+ import { join as join2 } from "node:path";
2061
+ import semver from "semver";
2062
+
2063
+ // packages/experience-design-system-cli/src/tui/package-root.ts
2064
+ import { existsSync, readFileSync } from "node:fs";
2065
+ import { dirname, join } from "node:path";
2066
+ import { fileURLToPath } from "node:url";
2067
+ function findPackageRoot(startUrl, packageName) {
2068
+ let dir = dirname(fileURLToPath(startUrl));
2069
+ let found;
2070
+ while (true) {
2071
+ const manifestPath = join(dir, "package.json");
2072
+ if (existsSync(manifestPath)) {
2073
+ const pkg = JSON.parse(readFileSync(manifestPath, "utf8"));
2074
+ if (pkg.name === packageName) found = dir;
2075
+ }
2076
+ const parent = dirname(dir);
2077
+ if (parent === dir) return found ?? dir;
2078
+ dir = parent;
2079
+ }
2080
+ }
2081
+
2082
+ // packages/experience-design-system-cli/src/tui/upgrade/version.ts
2083
+ var PACKAGE_NAME = "@contentful/experience-design-system-cli";
2084
+ var TAGS_URL = "https://api.github.com/repos/contentful/experience-design-system-sdk-public/tags?per_page=10";
2085
+ function readPackageVersion() {
2086
+ const root = findPackageRoot(import.meta.url, PACKAGE_NAME);
2087
+ const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
2088
+ return pkg.version ?? "unknown";
2089
+ }
2090
+ function parseVersionTag(tag) {
2091
+ const match2 = /^v(\d+\.\d+\.\d+)$/.exec(tag);
2092
+ return match2 ? match2[1] : void 0;
2093
+ }
2094
+ async function checkForUpgrade() {
2095
+ const current = readPackageVersion();
2096
+ try {
2097
+ const response = await fetch(TAGS_URL);
2098
+ if (!response.ok) return { status: "error" };
2099
+ const tags = await response.json();
2100
+ const versions = tags.map((tag) => tag.name ? parseVersionTag(tag.name) : void 0).filter((v) => v !== void 0);
2101
+ if (versions.length === 0) return { status: "error" };
2102
+ const latest = versions.reduce((best, v) => semver.gt(v, best) ? v : best);
2103
+ if (!semver.valid(current)) return { status: "error" };
2104
+ if (semver.gt(latest, current)) {
2105
+ return { status: "update-available", current, latest };
2106
+ }
2107
+ return { status: "up-to-date", current };
2108
+ } catch {
2109
+ return { status: "error" };
2110
+ }
2111
+ }
2372
2112
 
2373
2113
  // packages/experience-design-system-cli/src/tui/use-terminal-width.ts
2374
2114
  import { useEffect, useState } from "react";
@@ -2500,9 +2240,14 @@ function HomeScreen({ onNavigate }) {
2500
2240
  }
2501
2241
 
2502
2242
  // packages/experience-design-system-cli/src/tui/import/PageContainer.tsx
2503
- import { Box as Box2, Text as Text3, useInput as useInput2 } from "ink";
2243
+ import { useEffect as useEffect3 } from "react";
2244
+ import { Box as Box2, Text as Text3, useInput as useInput2, useStdout as useStdout2 } from "ink";
2504
2245
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
2505
2246
  function ImportScreen({ exitCode, onDone }) {
2247
+ const { stdout } = useStdout2();
2248
+ useEffect3(() => {
2249
+ stdout.write("\x1B[H\x1B[0J");
2250
+ }, [stdout]);
2506
2251
  useInput2((input, key) => {
2507
2252
  if (key.return || key.escape || input === "q") {
2508
2253
  onDone();
@@ -2710,7 +2455,7 @@ function TokenInputScreen({ onConfirm, onBack, initialPath = "" }) {
2710
2455
  }
2711
2456
 
2712
2457
  // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/screen.tsx
2713
- import { useEffect as useEffect3, useMemo, useState as useState5 } from "react";
2458
+ import { useEffect as useEffect4, useMemo, useState as useState5 } from "react";
2714
2459
  import { Box as Box5, Text as Text6 } from "ink";
2715
2460
 
2716
2461
  // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/controls.ts
@@ -12567,11 +12312,11 @@ import { access as access2, mkdir, readFile as readFile7, writeFile } from "node
12567
12312
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
12568
12313
  import { resolve as resolve15 } from "node:path";
12569
12314
  async function getRefineSessionPaths(sessionId, artifactsRoot) {
12570
- const sessionDir2 = resolve15(artifactsRoot, sessionId);
12315
+ const sessionDir = resolve15(artifactsRoot, sessionId);
12571
12316
  return {
12572
- sessionDir: sessionDir2,
12573
- eventsPath: resolve15(sessionDir2, "events.jsonl"),
12574
- statePath: resolve15(sessionDir2, "current-review-state.json")
12317
+ sessionDir,
12318
+ eventsPath: resolve15(sessionDir, "events.jsonl"),
12319
+ statePath: resolve15(sessionDir, "current-review-state.json")
12575
12320
  };
12576
12321
  }
12577
12322
 
@@ -13770,7 +13515,7 @@ function errorMessage(error) {
13770
13515
  return error instanceof Error && error.message ? error.message : String(error);
13771
13516
  }
13772
13517
  function defaultSleep(delayMs) {
13773
- return new Promise((resolve27) => setTimeout(resolve27, delayMs));
13518
+ return new Promise((resolve25) => setTimeout(resolve25, delayMs));
13774
13519
  }
13775
13520
 
13776
13521
  // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
@@ -14011,7 +13756,7 @@ var ApiClient = class {
14011
13756
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
14012
13757
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
14013
13758
  const jitter = Math.random() * baseDelay * 0.15;
14014
- await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
13759
+ await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
14015
13760
  }
14016
13761
  }
14017
13762
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -16124,7 +15869,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
16124
15869
  const message = error instanceof Error ? error.message : String(error);
16125
15870
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
16126
15871
  throw error;
16127
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
15872
+ await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
16128
15873
  }
16129
15874
  }
16130
15875
  }
@@ -16871,7 +16616,7 @@ function PathValidationScreen({
16871
16616
  }) {
16872
16617
  const resolvedPath = useMemo(() => resolveUserPath(projectPath), [projectPath]);
16873
16618
  const [scan, setScan] = useState5();
16874
- useEffect3(() => {
16619
+ useEffect4(() => {
16875
16620
  setScan(scanFiles(resolvedPath));
16876
16621
  }, [resolvedPath]);
16877
16622
  const phase = phaseOf(scan);
@@ -16951,7 +16696,6 @@ function useCredentialsControls(handlers) {
16951
16696
  }
16952
16697
 
16953
16698
  // packages/experience-design-system-cli/src/tui/user-agent.ts
16954
- init_version();
16955
16699
  function cliUserAgent() {
16956
16700
  return buildUserAgent(readPackageVersion());
16957
16701
  }
@@ -17240,10 +16984,10 @@ var PROGRESS_THEME = extendTheme(defaultTheme, {
17240
16984
  });
17241
16985
 
17242
16986
  // packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts
17243
- import { useEffect as useEffect4, useState as useState7 } from "react";
16987
+ import { useEffect as useEffect5, useState as useState7 } from "react";
17244
16988
  function useElapsed() {
17245
16989
  const [seconds, setSeconds] = useState7(0);
17246
- useEffect4(() => {
16990
+ useEffect5(() => {
17247
16991
  const timer = setInterval(() => setSeconds((current) => current + 1), 1e3);
17248
16992
  return () => clearInterval(timer);
17249
16993
  }, []);
@@ -17296,34 +17040,11 @@ function RunningStep({
17296
17040
  }
17297
17041
 
17298
17042
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-reuse/logic.ts
17299
- import { access as access5, readdir as readdir2, stat as stat4 } from "node:fs/promises";
17043
+ import { access as access5, stat as stat4 } from "node:fs/promises";
17300
17044
  import { join as join16 } from "node:path";
17301
- async function findLatestTokens(contentfulDir) {
17302
- const candidates = [join16(contentfulDir, "tokens.json")];
17303
- try {
17304
- for (const session of await readdir2(contentfulDir, { withFileTypes: true })) {
17305
- if (!session.isDirectory()) continue;
17306
- for (const run of await readdir2(join16(contentfulDir, session.name), { withFileTypes: true }).catch(() => [])) {
17307
- if (run.isDirectory() && /^dsi-import-\d+$/.test(run.name)) {
17308
- candidates.push(join16(contentfulDir, session.name, run.name, "tokens.json"));
17309
- }
17310
- }
17311
- }
17312
- } catch {
17313
- }
17314
- const found = [];
17315
- for (const path5 of candidates) {
17316
- try {
17317
- found.push({ path: path5, mtimeMs: (await stat4(path5)).mtimeMs });
17318
- } catch {
17319
- }
17320
- }
17321
- return found.sort((a, b) => b.mtimeMs - a.mtimeMs)[0]?.path ?? null;
17322
- }
17323
- async function inspectTokens({ rawTokensPath, contentfulDir, cache }) {
17045
+ async function inspectTokens({ rawTokensPath, outDir, cache }) {
17324
17046
  if (!cache) return { kind: "none" };
17325
- const tokensPath = await findLatestTokens(contentfulDir);
17326
- if (!tokensPath) return { kind: "none" };
17047
+ const tokensPath = join16(outDir, "tokens.json");
17327
17048
  try {
17328
17049
  await access5(tokensPath);
17329
17050
  } catch {
@@ -17474,11 +17195,37 @@ function ExtractionScreen({
17474
17195
  );
17475
17196
  }
17476
17197
 
17477
- // packages/experience-design-system-cli/app.tsx
17478
- init_config();
17198
+ // packages/experience-design-system-types/dist/src/config/index.js
17199
+ import { randomBytes as randomBytes3 } from "node:crypto";
17200
+ import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
17201
+ import { homedir as homedir3 } from "node:os";
17202
+ import { dirname as dirname13, join as join17 } from "node:path";
17203
+ function configRoot2() {
17204
+ return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
17205
+ }
17206
+ var configFilePath2 = () => join17(configRoot2(), "config.json");
17207
+ var debugSessionsDir2 = () => join17(configRoot2(), "debug", "sessions");
17208
+ async function readSettings2() {
17209
+ try {
17210
+ return JSON.parse(await readFile18(configFilePath2(), "utf8"));
17211
+ } catch {
17212
+ return {};
17213
+ }
17214
+ }
17215
+ async function writeSettings2(settings) {
17216
+ const path5 = configFilePath2();
17217
+ await mkdir6(dirname13(path5), { recursive: true });
17218
+ const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
17219
+ await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
17220
+ `, { mode: 384 });
17221
+ await rename2(tmp, path5);
17222
+ }
17223
+ async function updateSettings2(patch) {
17224
+ await writeSettings2({ ...await readSettings2(), ...patch });
17225
+ }
17479
17226
 
17480
17227
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
17481
- import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
17228
+ import { useEffect as useEffect6, useRef as useRef2, useState as useState8 } from "react";
17482
17229
 
17483
17230
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
17484
17231
  import { mkdir as mkdir7 } from "node:fs/promises";
@@ -17602,7 +17349,7 @@ var realDeps = {
17602
17349
  var fail = (step, message) => ({ ok: false, step, message });
17603
17350
  var errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
17604
17351
  async function runExtraction(input, onProgress, deps = realDeps) {
17605
- const outDir = input.outDir ?? join19(resolve22(input.projectPath), ".contentful");
17352
+ const outDir = join19(resolve22(input.projectPath), ".contentful");
17606
17353
  let progress = initialProgress({
17607
17354
  hasCredentials: input.credentials !== null,
17608
17355
  hasRawTokens: input.rawTokensPath !== "",
@@ -17737,7 +17484,7 @@ async function resolveSelectionPrompt(overrides) {
17737
17484
  function useExtraction(input) {
17738
17485
  const [state, setState] = useState8();
17739
17486
  const current = useRef2();
17740
- useEffect5(() => {
17487
+ useEffect6(() => {
17741
17488
  current.current = input;
17742
17489
  if (!input) {
17743
17490
  setState(void 0);
@@ -17767,7 +17514,7 @@ function useExtraction(input) {
17767
17514
  import { Box as Box20, Text as Text22 } from "ink";
17768
17515
 
17769
17516
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/panels/added-column.tsx
17770
- import React6 from "react";
17517
+ import React7 from "react";
17771
17518
  import { Box as Box11, Text as Text12 } from "ink";
17772
17519
  import figures from "figures";
17773
17520
 
@@ -17968,7 +17715,7 @@ function AddedColumn(props) {
17968
17715
  const aiFlagged = aiFlaggedByKey?.get(entry.name) === true;
17969
17716
  const showSeparator = firstNonCycleIdx > 0 && i === firstNonCycleIdx;
17970
17717
  const style = sideColumnLabelStyle({ isCycle: entry.isCycle, isSelected, focused });
17971
- return /* @__PURE__ */ jsxs11(React6.Fragment, { children: [
17718
+ return /* @__PURE__ */ jsxs11(React7.Fragment, { children: [
17972
17719
  showSeparator && /* @__PURE__ */ jsx14(Text12, { dimColor: true, children: "\u2500".repeat(Math.max(0, width - 2)) }),
17973
17720
  /* @__PURE__ */ jsxs11(Box11, { children: [
17974
17721
  isCursor ? /* @__PURE__ */ jsx14(Text12, { color: PALETTE2.info, bold: true, children: figures.pointer }) : /* @__PURE__ */ jsx14(Text12, { children: " " }),
@@ -19001,7 +18748,7 @@ function GroupedSidebar(props) {
19001
18748
  }
19002
18749
 
19003
18750
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/components/HelpOverlay.tsx
19004
- import React7 from "react";
18751
+ import React8 from "react";
19005
18752
  import { Box as Box18, Text as Text20 } from "ink";
19006
18753
 
19007
18754
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/useImmediateInput.ts
@@ -19078,8 +18825,8 @@ function useImmediateInput(handler, enabled = true) {
19078
18825
  }
19079
18826
 
19080
18827
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
19081
- import { useStdout as useStdout2 } from "ink";
19082
- import { useEffect as useEffect6, useState as useState9 } from "react";
18828
+ import { useStdout as useStdout3 } from "ink";
18829
+ import { useEffect as useEffect7, useState as useState9 } from "react";
19083
18830
  function readTerminalSize(stdout) {
19084
18831
  return {
19085
18832
  columns: stdout?.columns ?? 80,
@@ -19087,9 +18834,9 @@ function readTerminalSize(stdout) {
19087
18834
  };
19088
18835
  }
19089
18836
  function useTerminalSize() {
19090
- const { stdout } = useStdout2();
18837
+ const { stdout } = useStdout3();
19091
18838
  const [size, setSize] = useState9(() => readTerminalSize(stdout));
19092
- useEffect6(() => {
18839
+ useEffect7(() => {
19093
18840
  const updateSize = () => setSize(readTerminalSize(stdout));
19094
18841
  stdout?.on("resize", updateSize);
19095
18842
  updateSize();
@@ -19123,7 +18870,7 @@ function HelpOverlay(props) {
19123
18870
  overflowY: "hidden",
19124
18871
  children: [
19125
18872
  /* @__PURE__ */ jsx22(Text20, { bold: true, children: "\u2500".repeat(titleRule) + " Help " + "\u2500".repeat(titleRule) }),
19126
- props.sections.map((section) => /* @__PURE__ */ jsxs19(React7.Fragment, { children: [
18873
+ props.sections.map((section) => /* @__PURE__ */ jsxs19(React8.Fragment, { children: [
19127
18874
  /* @__PURE__ */ jsx22(Text20, { children: " " }),
19128
18875
  /* @__PURE__ */ jsx22(Text20, { bold: true, children: section.title }),
19129
18876
  section.entries.map((entry) => /* @__PURE__ */ jsx22(Text20, { children: entry.keys ? " " + entry.keys.padEnd(16) + " " + entry.label : " " + entry.label }, entry.keys + entry.label))
@@ -19272,7 +19019,7 @@ function createSidebarViewsHelpSection(includeBreaking) {
19272
19019
  }
19273
19020
 
19274
19021
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
19275
- import { useEffect as useEffect7, useMemo as useMemo2, useRef as useRef4, useState as useState12 } from "react";
19022
+ import { useEffect as useEffect8, useMemo as useMemo2, useRef as useRef4, useState as useState12 } from "react";
19276
19023
 
19277
19024
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/graph/search-neighborhood.ts
19278
19025
  function computeDirectNeighborhood(matches, graph) {
@@ -19956,7 +19703,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
19956
19703
  return seed;
19957
19704
  });
19958
19705
  const seededGroupsRef = useRef4(closures.size > 0 || cycleParticipants.size > 0);
19959
- useEffect7(() => {
19706
+ useEffect8(() => {
19960
19707
  if (seededGroupsRef.current) return;
19961
19708
  if (closures.size === 0 && cycleParticipants.size === 0) return;
19962
19709
  seededGroupsRef.current = true;
@@ -20046,7 +19793,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
20046
19793
  entryCount: 0
20047
19794
  });
20048
19795
  const panelLayout = useMemo2(() => computePanelLayout(visibleCount), [visibleCount]);
20049
- useEffect7(() => {
19796
+ useEffect8(() => {
20050
19797
  setNav((prev) => {
20051
19798
  const maxIdx = Math.max(0, visibleRows.length - 1);
20052
19799
  const nextCursor = Math.min(prev.cursor, maxIdx);
@@ -20514,7 +20261,7 @@ function ScopeGateView({ components, onConfirm, onQuit }) {
20514
20261
  }
20515
20262
 
20516
20263
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
20517
- import { useEffect as useEffect8, useMemo as useMemo3, useRef as useRef5, useState as useState13 } from "react";
20264
+ import { useEffect as useEffect9, useMemo as useMemo3, useRef as useRef5, useState as useState13 } from "react";
20518
20265
 
20519
20266
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/cache-check.ts
20520
20267
  async function checkGenerationCache(input) {
@@ -20563,7 +20310,7 @@ function useScopeGateFlow(input, deps = realDeps2) {
20563
20310
  const loaded = useMemo3(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
20564
20311
  const cacheCheck = useRef5(void 0);
20565
20312
  const [confirmed, setConfirmed] = useState13();
20566
- useEffect8(() => {
20313
+ useEffect9(() => {
20567
20314
  if (!input || !loaded?.ok || cacheCheck.current) return;
20568
20315
  cacheCheck.current = deps.checkCache(input.cache);
20569
20316
  }, [input, loaded]);
@@ -20634,7 +20381,7 @@ function GenerationScreen({
20634
20381
  }
20635
20382
 
20636
20383
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
20637
- import { useEffect as useEffect9, useRef as useRef6, useState as useState14 } from "react";
20384
+ import { useEffect as useEffect10, useRef as useRef6, useState as useState14 } from "react";
20638
20385
 
20639
20386
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
20640
20387
  import { resolve as resolve23 } from "node:path";
@@ -20800,7 +20547,7 @@ function applyProgressEvent2(event, previous, total) {
20800
20547
  function useGeneration(input) {
20801
20548
  const [state, setState] = useState14();
20802
20549
  const current = useRef6();
20803
- useEffect9(() => {
20550
+ useEffect10(() => {
20804
20551
  current.current = input;
20805
20552
  if (!input) {
20806
20553
  setState(void 0);
@@ -20846,7 +20593,7 @@ function buildFlowStart(input) {
20846
20593
  }
20847
20594
 
20848
20595
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
20849
- import { useEffect as useEffect20, useRef as useRef12 } from "react";
20596
+ import { useEffect as useEffect21, useRef as useRef12 } from "react";
20850
20597
  import { Box as Box41 } from "ink";
20851
20598
 
20852
20599
  // packages/experience-design-system-types/dist/src/cdf/validate.js
@@ -21193,7 +20940,7 @@ function PreviewValidationErrorScreen({
21193
20940
  }
21194
20941
 
21195
20942
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
21196
- import { useCallback as useCallback5, useEffect as useEffect16, useMemo as useMemo4, useRef as useRef11, useState as useState22 } from "react";
20943
+ import { useCallback as useCallback5, useEffect as useEffect17, useMemo as useMemo4, useRef as useRef11, useState as useState22 } from "react";
21197
20944
  import figures7 from "figures";
21198
20945
 
21199
20946
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/theme.ts
@@ -21465,7 +21212,7 @@ function enumerateCycleBreaks(cycle, components) {
21465
21212
  import { Box as Box27, Text as Text30 } from "ink";
21466
21213
 
21467
21214
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
21468
- import React8, { useEffect as useEffect10, useLayoutEffect as useLayoutEffect2, useState as useState15 } from "react";
21215
+ import React9, { useEffect as useEffect11, useLayoutEffect as useLayoutEffect2, useState as useState15 } from "react";
21469
21216
  import figures5 from "figures";
21470
21217
  import { Box as Box21, measureElement, Text as Text23 } from "ink";
21471
21218
 
@@ -22176,9 +21923,9 @@ function FieldEditor({
22176
21923
  const [editorState, setEditorState] = useState15(initialState);
22177
21924
  const [parseErr] = useState15(parseError);
22178
21925
  const [listScrollStart, setListScrollStart] = useState15(0);
22179
- const initialFocusScrollApplied = React8.useRef(false);
21926
+ const initialFocusScrollApplied = React9.useRef(false);
22180
21927
  const [rowHeights, setRowHeights] = useState15({});
22181
- const rowMeasureRefs = React8.useRef(/* @__PURE__ */ new Map());
21928
+ const rowMeasureRefs = React9.useRef(/* @__PURE__ */ new Map());
22182
21929
  const initialFocus = (() => {
22183
21930
  if (initialFocusTarget?.kind === "description") {
22184
21931
  return {
@@ -22265,23 +22012,23 @@ function FieldEditor({
22265
22012
  const [showHelp, setShowHelp] = useState15(false);
22266
22013
  const props = editorState.props;
22267
22014
  const slots = editorState.slots;
22268
- const contentPropIndexes = React8.useMemo(
22015
+ const contentPropIndexes = React9.useMemo(
22269
22016
  () => props.flatMap((prop, index) => prop.category === "content" ? [index] : []),
22270
22017
  [props]
22271
22018
  );
22272
- const designPropIndexes = React8.useMemo(
22019
+ const designPropIndexes = React9.useMemo(
22273
22020
  () => props.flatMap((prop, index) => prop.category === "design" ? [index] : []),
22274
22021
  [props]
22275
22022
  );
22276
- const hiddenPropIndexes = React8.useMemo(
22023
+ const hiddenPropIndexes = React9.useMemo(
22277
22024
  () => showHiddenProps ? props.flatMap((prop, index) => prop.category === "state" || prop.category === "unattached" ? [index] : []) : [],
22278
22025
  [props, showHiddenProps]
22279
22026
  );
22280
- const visiblePropIndexes = React8.useMemo(
22027
+ const visiblePropIndexes = React9.useMemo(
22281
22028
  () => [...contentPropIndexes, ...designPropIndexes, ...hiddenPropIndexes],
22282
22029
  [contentPropIndexes, designPropIndexes, hiddenPropIndexes]
22283
22030
  );
22284
- const propGroups = React8.useMemo(
22031
+ const propGroups = React9.useMemo(
22285
22032
  () => [
22286
22033
  {
22287
22034
  kind: "content",
@@ -22301,7 +22048,7 @@ function FieldEditor({
22301
22048
  ],
22302
22049
  [contentPropIndexes, designPropIndexes, hiddenPropIndexes]
22303
22050
  );
22304
- const selectableRows = React8.useMemo(
22051
+ const selectableRows = React9.useMemo(
22305
22052
  () => [
22306
22053
  ...contentPropIndexes.map((idx) => ({ kind: "prop", idx })),
22307
22054
  ...designPropIndexes.map((idx) => ({ kind: "prop", idx })),
@@ -22311,7 +22058,7 @@ function FieldEditor({
22311
22058
  [contentPropIndexes, designPropIndexes, hiddenPropIndexes, slots]
22312
22059
  );
22313
22060
  const visiblePropPosition = visiblePropIndexes.indexOf(propIdx);
22314
- const selectedSelectableIndex = React8.useMemo(
22061
+ const selectedSelectableIndex = React9.useMemo(
22315
22062
  () => selectableRows.findIndex(
22316
22063
  (row) => inSlots ? row.kind === "slot" && row.idx === slotIdx : row.kind === "prop" && row.idx === propIdx
22317
22064
  ),
@@ -22330,12 +22077,12 @@ function FieldEditor({
22330
22077
  }
22331
22078
  };
22332
22079
  const textEntryActive = focusLevel === "field" && editingField && activeField === "description" || focusLevel === "field" && editingField && activeField === "default" && (editorState.props[propIdx]?.type === "string" || editorState.props[propIdx]?.type === "token") || editingValue != null;
22333
- React8.useEffect(() => {
22080
+ React9.useEffect(() => {
22334
22081
  onTextEntryActiveChange?.(textEntryActive);
22335
22082
  }, [textEntryActive, onTextEntryActiveChange]);
22336
22083
  const currentProp = props[propIdx] ?? null;
22337
22084
  const currentSlot = slots[slotIdx] ?? null;
22338
- React8.useEffect(() => {
22085
+ React9.useEffect(() => {
22339
22086
  if (showHiddenProps || inSlots || inComponentDesc || visiblePropPosition >= 0) return;
22340
22087
  if (visiblePropIndexes.length > 0) {
22341
22088
  setPropIdx(visiblePropIndexes[0]);
@@ -22354,22 +22101,22 @@ function FieldEditor({
22354
22101
  setEditorState(next);
22355
22102
  onChange(serializeState(next, value));
22356
22103
  };
22357
- const canonicalize = React8.useCallback((json) => {
22104
+ const canonicalize = React9.useCallback((json) => {
22358
22105
  try {
22359
22106
  return JSON.stringify(JSON.parse(json));
22360
22107
  } catch {
22361
22108
  return `__unparseable__:${json}`;
22362
22109
  }
22363
22110
  }, []);
22364
- const initialStateRef = React8.useRef(initialState);
22111
+ const initialStateRef = React9.useRef(initialState);
22365
22112
  const baselineCanonical = canonicalize(serializeState(initialStateRef.current, value));
22366
22113
  const currentCanonical = canonicalize(serializeState(editorState, value));
22367
22114
  const isDirty = currentCanonical !== baselineCanonical;
22368
- React8.useEffect(() => {
22115
+ React9.useEffect(() => {
22369
22116
  onDirtyChange?.(isDirty);
22370
22117
  }, [isDirty, onDirtyChange]);
22371
- const lastDiscardTriggerRef = React8.useRef(discardTrigger);
22372
- React8.useEffect(() => {
22118
+ const lastDiscardTriggerRef = React9.useRef(discardTrigger);
22119
+ React9.useEffect(() => {
22373
22120
  if (discardTrigger === void 0) return;
22374
22121
  if (discardTrigger === lastDiscardTriggerRef.current) return;
22375
22122
  lastDiscardTriggerRef.current = discardTrigger;
@@ -22968,7 +22715,7 @@ function FieldEditor({
22968
22715
  }
22969
22716
  return Math.max(start + 1, end2);
22970
22717
  };
22971
- useEffect10(() => {
22718
+ useEffect11(() => {
22972
22719
  if (focusLevel === "field" || selectedRowIdx < 0) return;
22973
22720
  setListScrollStart((previous) => {
22974
22721
  if (initialFocusTarget && !initialFocusScrollApplied.current) {
@@ -24026,7 +23773,7 @@ function finalizeReviewSession(extractSessionId, components) {
24026
23773
  }
24027
23774
 
24028
23775
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
24029
- import { useCallback as useCallback2, useEffect as useEffect12, useRef as useRef8, useState as useState17 } from "react";
23776
+ import { useCallback as useCallback2, useEffect as useEffect13, useRef as useRef8, useState as useState17 } from "react";
24030
23777
 
24031
23778
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/history.ts
24032
23779
  var DEFAULT_MAX_DEPTH = 50;
@@ -24082,7 +23829,7 @@ function createHistoryStack(seed, maxDepth = DEFAULT_MAX_DEPTH) {
24082
23829
  }
24083
23830
 
24084
23831
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
24085
- import { useEffect as useEffect11, useRef as useRef7, useState as useState16 } from "react";
23832
+ import { useEffect as useEffect12, useRef as useRef7, useState as useState16 } from "react";
24086
23833
 
24087
23834
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/run-live-preview.ts
24088
23835
  var TimeoutError = class extends Error {
@@ -24234,7 +23981,7 @@ function useFinalizePreview(opts) {
24234
23981
  const [scrollOffset, setScrollOffset] = useState16(0);
24235
23982
  const generationRef = useRef7(0);
24236
23983
  const acceptedKey = [...acceptedKeys].sort().join("\0");
24237
- useEffect11(() => {
23984
+ useEffect12(() => {
24238
23985
  if (!open) {
24239
23986
  setStatus("idle");
24240
23987
  setRemoved([]);
@@ -24297,7 +24044,7 @@ function useReviewSession({
24297
24044
  }));
24298
24045
  return { result, catalog };
24299
24046
  }, [loadSession, tokensPath]);
24300
- useEffect12(() => {
24047
+ useEffect13(() => {
24301
24048
  let disposed = false;
24302
24049
  void (async () => {
24303
24050
  try {
@@ -24350,7 +24097,7 @@ function useReviewSession({
24350
24097
  function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
24351
24098
  const [reviewMetadata, setReviewMetadata] = useState17(null);
24352
24099
  const [componentRationale, setComponentRationale] = useState17(null);
24353
- useEffect12(() => {
24100
+ useEffect13(() => {
24354
24101
  const current = components[selectedIdx];
24355
24102
  if (!current) {
24356
24103
  setReviewMetadata(null);
@@ -24382,7 +24129,7 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
24382
24129
  function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
24383
24130
  const historyRef = useRef8(null);
24384
24131
  const historySeededRef = useRef8(false);
24385
- useEffect12(() => {
24132
+ useEffect13(() => {
24386
24133
  if (loading || historySeededRef.current) return;
24387
24134
  historySeededRef.current = true;
24388
24135
  historyRef.current = createHistoryStack(createSnapshot(components));
@@ -24433,7 +24180,7 @@ function useReviewFinalize({
24433
24180
  }
24434
24181
 
24435
24182
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
24436
- import { useEffect as useEffect13, useRef as useRef9, useState as useState18 } from "react";
24183
+ import { useEffect as useEffect14, useRef as useRef9, useState as useState18 } from "react";
24437
24184
 
24438
24185
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/token-suggestions.ts
24439
24186
  function collectTokenSuggestions(entry, availableTokens = []) {
@@ -24486,7 +24233,7 @@ function useReviewEditor({
24486
24233
  const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState18(/* @__PURE__ */ new Set());
24487
24234
  const tokenReviewSuggestedRef = useRef9(/* @__PURE__ */ new Map());
24488
24235
  const pendingGRef = useRef9(false);
24489
- useEffect13(() => {
24236
+ useEffect14(() => {
24490
24237
  setTokenReviewRow(0);
24491
24238
  setTokenReviewEditing(false);
24492
24239
  setTokenReviewEditCursor(0);
@@ -24890,7 +24637,7 @@ function handleJsonPanelInput(input, key, state) {
24890
24637
  }
24891
24638
 
24892
24639
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
24893
- import { useCallback as useCallback4, useEffect as useEffect15, useState as useState21 } from "react";
24640
+ import { useCallback as useCallback4, useEffect as useEffect16, useState as useState21 } from "react";
24894
24641
 
24895
24642
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/preview-annotations.ts
24896
24643
  function applyPreviewAnnotations(preview, localNames) {
@@ -24925,7 +24672,7 @@ function applyPreviewAnnotations(preview, localNames) {
24925
24672
  }
24926
24673
 
24927
24674
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
24928
- import { useCallback as useCallback3, useEffect as useEffect14, useRef as useRef10, useState as useState20 } from "react";
24675
+ import { useCallback as useCallback3, useEffect as useEffect15, useRef as useRef10, useState as useState20 } from "react";
24929
24676
  var DEFAULT_DEBOUNCE_MS = 500;
24930
24677
  function useLivePreview(opts) {
24931
24678
  const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
@@ -24936,14 +24683,14 @@ function useLivePreview(opts) {
24936
24683
  const latestRef = useRef10(0);
24937
24684
  const inflightRef = useRef10(0);
24938
24685
  const optsRef = useRef10(opts);
24939
- useEffect14(() => {
24686
+ useEffect15(() => {
24940
24687
  optsRef.current = opts;
24941
24688
  });
24942
24689
  const disabledRef = useRef10(disabled);
24943
- useEffect14(() => {
24690
+ useEffect15(() => {
24944
24691
  disabledRef.current = disabled;
24945
24692
  }, [disabled]);
24946
- useEffect14(() => {
24693
+ useEffect15(() => {
24947
24694
  return () => {
24948
24695
  if (timerRef.current) {
24949
24696
  clearTimeout(timerRef.current);
@@ -25057,13 +24804,13 @@ function useReviewPreview({
25057
24804
  deleteAllComponents
25058
24805
  });
25059
24806
  const [spinnerTick, setSpinnerTick] = useState21(0);
25060
- useEffect15(() => {
24807
+ useEffect16(() => {
25061
24808
  if (livePreviewHook.status !== "running") return;
25062
24809
  const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
25063
24810
  return () => clearInterval(id);
25064
24811
  }, [livePreviewHook.status]);
25065
24812
  const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
25066
- useEffect15(() => {
24813
+ useEffect16(() => {
25067
24814
  if (loading) return;
25068
24815
  if (!livePreview) return;
25069
24816
  if (components.length === 0) return;
@@ -25483,7 +25230,7 @@ function GenerateReviewStepView({
25483
25230
  [components]
25484
25231
  );
25485
25232
  const closures = useMemo4(() => computeAllClosures(componentGraph), [componentGraph]);
25486
- useEffect16(() => {
25233
+ useEffect17(() => {
25487
25234
  if (seededGroupsRef.current) return;
25488
25235
  if (closures.size === 0 && slotCycles.length === 0) return;
25489
25236
  seededGroupsRef.current = true;
@@ -25510,7 +25257,7 @@ function GenerateReviewStepView({
25510
25257
  suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
25511
25258
  }));
25512
25259
  }, [slotCycles, cycleView]);
25513
- useEffect16(() => {
25260
+ useEffect17(() => {
25514
25261
  const decision = computeAutoRejectDecision({
25515
25262
  loading,
25516
25263
  autoRejectFired: autoRejectFiredRef.current,
@@ -25554,7 +25301,7 @@ function GenerateReviewStepView({
25554
25301
  applySnapshot: applyHistorySnapshot
25555
25302
  });
25556
25303
  const autoRejectPushedRef = useRef11(false);
25557
- useEffect16(() => {
25304
+ useEffect17(() => {
25558
25305
  if (loading) return;
25559
25306
  if (!historySeededRef.current) return;
25560
25307
  if (!autoRejectFiredRef.current) return;
@@ -25638,7 +25385,7 @@ function GenerateReviewStepView({
25638
25385
  const panelHeight = leftPanelHeight + 2;
25639
25386
  const panelContentHeight = Math.max(1, panelHeight - 3);
25640
25387
  const cycleViewportHeight = Math.max(1, panelHeight - 4);
25641
- useEffect16(() => {
25388
+ useEffect17(() => {
25642
25389
  if (selectableRowPositions.length === 0) return;
25643
25390
  const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
25644
25391
  const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
@@ -26598,10 +26345,10 @@ function normalizePath(input) {
26598
26345
  }
26599
26346
 
26600
26347
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
26601
- import { useEffect as useEffect17, useState as useState23 } from "react";
26348
+ import { useEffect as useEffect18, useState as useState23 } from "react";
26602
26349
  function useBlinkingCursor() {
26603
26350
  const [visible, setVisible] = useState23(true);
26604
- useEffect17(() => {
26351
+ useEffect18(() => {
26605
26352
  const interval = setInterval(() => setVisible((current) => !current), 500);
26606
26353
  return () => clearInterval(interval);
26607
26354
  }, []);
@@ -26709,12 +26456,12 @@ function StepHeader({ stepNumber, totalSteps, title }) {
26709
26456
  }
26710
26457
 
26711
26458
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
26712
- import { useEffect as useEffect18, useState as useState25 } from "react";
26459
+ import { useEffect as useEffect19, useState as useState25 } from "react";
26713
26460
  import { Spinner as Spinner2 } from "@inkjs/ui";
26714
26461
  import { jsx as jsx49 } from "react/jsx-runtime";
26715
26462
  function useTimedSpinner() {
26716
26463
  const [elapsedSeconds, setElapsedSeconds] = useState25(0);
26717
- useEffect18(() => {
26464
+ useEffect19(() => {
26718
26465
  const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
26719
26466
  return () => {
26720
26467
  clearInterval(timer);
@@ -26763,7 +26510,7 @@ function PushingStep({ stepNumber, totalSteps, progress }) {
26763
26510
  }
26764
26511
 
26765
26512
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
26766
- import { useEffect as useEffect19, useState as useState26, useMemo as useMemo5 } from "react";
26513
+ import { useEffect as useEffect20, useState as useState26, useMemo as useMemo5 } from "react";
26767
26514
  import { Box as Box40, Text as Text43 } from "ink";
26768
26515
 
26769
26516
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/preview-diff.ts
@@ -27148,7 +26895,7 @@ function WizardPreviewStep({
27148
26895
  const activeLines = diffExpanded ? diffLines : summaryLines;
27149
26896
  const maxScroll = Math.max(0, activeLines.length - viewportHeight);
27150
26897
  const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
27151
- useEffect19(() => {
26898
+ useEffect20(() => {
27152
26899
  setScrollOffset((previous) => Math.min(previous, maxScroll));
27153
26900
  }, [maxScroll]);
27154
26901
  useImmediateInput((input, key) => {
@@ -27253,7 +27000,7 @@ function FlowScreen({
27253
27000
  const totalSteps = totalStepsFor(state);
27254
27001
  const quit = () => onExit(0);
27255
27002
  const previousStep = useRef12(state.step);
27256
- useEffect20(() => {
27003
+ useEffect21(() => {
27257
27004
  if (previousStep.current !== state.step) {
27258
27005
  onStepChange?.();
27259
27006
  previousStep.current = state.step;
@@ -27384,13 +27131,13 @@ function FlowScreen({
27384
27131
  }
27385
27132
 
27386
27133
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
27387
- import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } from "react";
27134
+ import { useEffect as useEffect22, useRef as useRef13, useSyncExternalStore } from "react";
27388
27135
 
27389
27136
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
27390
27137
  import { appendFileSync, writeFileSync } from "node:fs";
27391
27138
  import { mkdir as mkdir8 } from "node:fs/promises";
27392
27139
  import { tmpdir } from "node:os";
27393
- import { join as join23, resolve as resolve25 } from "node:path";
27140
+ import { join as join23 } from "node:path";
27394
27141
 
27395
27142
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
27396
27143
  function shouldBypassPreview(state) {
@@ -27761,7 +27508,7 @@ var realSaveDeps = () => ({
27761
27508
  writeFile: (path5, contents) => writeFile7(path5, contents),
27762
27509
  appendRun,
27763
27510
  buildSourceFingerprint,
27764
- sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
27511
+ sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
27765
27512
  warn: (message) => process.stderr.write(message)
27766
27513
  });
27767
27514
  async function runPrintFiles(input, deps, onPatch) {
@@ -28089,7 +27836,7 @@ function createFlowController(start, deps) {
28089
27836
  },
28090
27837
  async submitPath(submitted) {
28091
27838
  await deps.mkdir(submitted);
28092
- if (resolve25(submitted) !== resolve25(state.outDir) && await deps.detectSaveConflict(submitted)) {
27839
+ if (await deps.detectSaveConflict(submitted)) {
28093
27840
  const subdir = deps.buildTimestampedSubdir(submitted);
28094
27841
  await deps.mkdir(subdir);
28095
27842
  await proceedToWrite(subdir);
@@ -28125,28 +27872,180 @@ function useFlow(start, deps = realFlowDeps) {
28125
27872
  (listener) => current?.subscribe(listener) ?? (() => void 0),
28126
27873
  () => current?.getState()
28127
27874
  );
28128
- useEffect21(() => {
27875
+ useEffect22(() => {
28129
27876
  if (!start) controller.current = void 0;
28130
27877
  }, [start]);
28131
27878
  return current && state ? { controller: current, state } : void 0;
28132
27879
  }
28133
27880
 
28134
27881
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
28135
- import { useEffect as useEffect22, useState as useState27 } from "react";
27882
+ import { useEffect as useEffect23, useState as useState27 } from "react";
28136
27883
  import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
28137
- init_debug_store();
27884
+
27885
+ // packages/experience-design-system-cli/src/tui/debug-store.ts
27886
+ import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
27887
+ import { existsSync as existsSync9, readdirSync as readdirSync4 } from "node:fs";
27888
+ import { join as join24 } from "node:path";
27889
+
27890
+ // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
27891
+ var DEFAULT_DEBUG_MODE_SETTING = {
27892
+ enabled: true
27893
+ };
27894
+ async function readDebugModeSetting() {
27895
+ const { debugMode } = await readSettings2();
27896
+ return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
27897
+ }
27898
+ async function writeDebugModeSetting(setting) {
27899
+ await updateSettings2({ debugMode: setting });
27900
+ }
27901
+
27902
+ // packages/experience-design-system-cli/src/tui/debug-store.ts
27903
+ var pendingRun;
27904
+ function generateRunId() {
27905
+ const now = /* @__PURE__ */ new Date();
27906
+ const pad = (n) => String(n).padStart(2, "0");
27907
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
27908
+ }
27909
+ function datePrefix(now = /* @__PURE__ */ new Date()) {
27910
+ const pad = (n) => String(n).padStart(2, "0");
27911
+ return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
27912
+ }
27913
+ function slugify(value) {
27914
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
27915
+ }
27916
+ function generateSessionId3() {
27917
+ const today = datePrefix();
27918
+ const root = debugSessionsDir2();
27919
+ const existing = existsSync9(root) ? readdirSync4(root) : [];
27920
+ const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
27921
+ const maxSeq = existing.reduce((max, entry) => {
27922
+ const match2 = seqPattern.exec(entry);
27923
+ return match2 ? Math.max(max, Number(match2[1])) : max;
27924
+ }, 0);
27925
+ return `${today}-session-${maxSeq + 1}`;
27926
+ }
27927
+ var SESSION_ID = generateSessionId3();
27928
+ function sessionDebugDir() {
27929
+ return join24(debugSessionsDir2(), SESSION_ID);
27930
+ }
27931
+ function currentDebugSessionDir() {
27932
+ return sessionDebugDir();
27933
+ }
27934
+ void isDebugModeEnabled().then((enabled) => {
27935
+ if (!enabled) return void 0;
27936
+ return mkdir9(sessionDebugDir(), { recursive: true });
27937
+ });
27938
+ async function isDebugModeEnabled() {
27939
+ try {
27940
+ return (await readDebugModeSetting()).enabled;
27941
+ } catch {
27942
+ return true;
27943
+ }
27944
+ }
27945
+ function redact(value) {
27946
+ const clone = { ...value };
27947
+ if ("cma_token" in clone) {
27948
+ const raw = clone.cma_token;
27949
+ clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
27950
+ }
27951
+ return clone;
27952
+ }
27953
+ function startDebugRun({
27954
+ flow,
27955
+ step,
27956
+ menuOption,
27957
+ inputs
27958
+ }) {
27959
+ const runId = generateRunId();
27960
+ const startedAt = Date.now();
27961
+ const redactedInputs = redact(inputs);
27962
+ isDebugModeEnabled().then((enabled) => {
27963
+ if (!enabled) return;
27964
+ pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
27965
+ });
27966
+ }
27967
+ async function finishDebugRun({
27968
+ outputs,
27969
+ status,
27970
+ exitMethod
27971
+ }) {
27972
+ const run = pendingRun;
27973
+ if (!run) return;
27974
+ pendingRun = void 0;
27975
+ const durationMs = Date.now() - run.startedAt;
27976
+ const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
27977
+ const flowSegments = run.flow.split("/");
27978
+ const dir = join24(sessionDebugDir(), ...flowSegments);
27979
+ await mkdir9(dir, { recursive: true });
27980
+ const filename = nextAttemptFilename(dir, run.menuOption);
27981
+ await writeFile8(join24(dir, filename), content, { mode: 384 });
27982
+ }
27983
+ function nextAttemptFilename(dir, menuOption) {
27984
+ const today = datePrefix();
27985
+ const optionSlug = slugify(menuOption);
27986
+ const existing = existsSync9(dir) ? readdirSync4(dir) : [];
27987
+ const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
27988
+ const maxAttempt = existing.reduce((max, entry) => {
27989
+ const match2 = attemptPattern.exec(entry);
27990
+ return match2 ? Math.max(max, Number(match2[1])) : max;
27991
+ }, 0);
27992
+ return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
27993
+ }
27994
+ function renderMarkdown(run, finish) {
27995
+ const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
27996
+ const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
27997
+ const flowSlug = run.flow.split("/").join("-");
27998
+ return `# Debug Log
27999
+
28000
+ - Run ID: ${run.runId}
28001
+ - Flow: ${flowSlug}
28002
+ - Step: ${stepLabel2}
28003
+ - Menu option: ${run.menuOption}
28004
+ - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
28005
+ - CLI version: ${readPackageVersion()}
28006
+ - Platform: ${process.platform} / Node ${process.version}
28007
+ - Duration on screen: ${finish.durationMs}ms
28008
+ - Status: ${finish.status}
28009
+ - Exit method: ${finish.exitMethod}
28010
+
28011
+ ## Inputs
28012
+ \`\`\`json
28013
+ ${JSON.stringify(run.inputs, null, 2)}
28014
+ \`\`\`
28015
+
28016
+ ## Outputs
28017
+ \`\`\`json
28018
+ ${JSON.stringify(finish.outputs, null, 2)}
28019
+ \`\`\`
28020
+ `;
28021
+ }
28022
+ function handleCrash() {
28023
+ return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
28024
+ }
28025
+ process.once("uncaughtException", (err) => {
28026
+ void handleCrash().finally(() => {
28027
+ throw err;
28028
+ });
28029
+ });
28030
+ process.once("unhandledRejection", (reason) => {
28031
+ void handleCrash().finally(() => {
28032
+ throw reason;
28033
+ });
28034
+ });
28035
+ process.once("SIGINT", () => {
28036
+ void handleCrash().finally(() => {
28037
+ process.exit(130);
28038
+ });
28039
+ });
28138
28040
 
28139
28041
  // packages/experience-design-system-cli/src/tui/help/help-info.ts
28140
- init_config();
28141
- init_debug_store();
28142
- init_debug_mode_store();
28143
- init_version();
28144
28042
  async function readHelpInfo() {
28145
28043
  const debugMode = await readDebugModeSetting();
28146
28044
  return {
28147
28045
  storage: [
28148
28046
  { label: "Config folder", value: configRoot2() },
28149
- { label: "Settings file", value: configFilePath2() }
28047
+ { label: "Settings file", value: configFilePath2() },
28048
+ { label: "Debug logs", value: debugSessionsDir2() }
28150
28049
  ],
28151
28050
  troubleshooting: [
28152
28051
  { label: "CLI version", value: readPackageVersion() },
@@ -28155,7 +28054,7 @@ async function readHelpInfo() {
28155
28054
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
28156
28055
  {
28157
28056
  label: "This session",
28158
- 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"
28057
+ value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
28159
28058
  }
28160
28059
  ]
28161
28060
  };
@@ -28174,7 +28073,7 @@ function Section({ title, rows }) {
28174
28073
  }
28175
28074
  function HelpScreen({ onDone }) {
28176
28075
  const [info, setInfo] = useState27();
28177
- useEffect22(() => {
28076
+ useEffect23(() => {
28178
28077
  startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
28179
28078
  void readHelpInfo().then(setInfo);
28180
28079
  }, []);
@@ -28267,12 +28166,11 @@ function SettingsScreen({
28267
28166
  }
28268
28167
 
28269
28168
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28270
- import { useEffect as useEffect23, useState as useState29 } from "react";
28169
+ import { useEffect as useEffect24, useState as useState29 } from "react";
28271
28170
  import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
28272
28171
  import TextInput4 from "ink-text-input";
28273
28172
 
28274
28173
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
28275
- init_config();
28276
28174
  var readV1Store = readSettings2;
28277
28175
  var writeV1Store = writeSettings2;
28278
28176
 
@@ -28285,8 +28183,7 @@ async function readCredentials() {
28285
28183
  cmaToken: store.cmaToken || "",
28286
28184
  host: store.host || "",
28287
28185
  defaultComponentDir: store.defaultComponentDir || "",
28288
- defaultTokenFile: store.defaultTokenFile || "",
28289
- contentfulBaseDir: store.contentfulBaseDir || ""
28186
+ defaultTokenFile: store.defaultTokenFile || ""
28290
28187
  };
28291
28188
  }
28292
28189
  async function writeCredentials(config) {
@@ -28302,7 +28199,6 @@ async function writeCredentials(config) {
28302
28199
  }
28303
28200
 
28304
28201
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28305
- init_debug_store();
28306
28202
  import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
28307
28203
  var FIELD_ORDER = [
28308
28204
  "spaceId",
@@ -28310,8 +28206,7 @@ var FIELD_ORDER = [
28310
28206
  "cmaToken",
28311
28207
  "host",
28312
28208
  "defaultComponentDir",
28313
- "defaultTokenFile",
28314
- "contentfulBaseDir"
28209
+ "defaultTokenFile"
28315
28210
  ];
28316
28211
  function debugFields(config) {
28317
28212
  return {
@@ -28320,23 +28215,17 @@ function debugFields(config) {
28320
28215
  cma_token: config?.cmaToken ?? "",
28321
28216
  host: config?.host ?? "",
28322
28217
  default_component_dir: config?.defaultComponentDir ?? "",
28323
- default_token_file: config?.defaultTokenFile ?? "",
28324
- contentful_base_dir: config?.contentfulBaseDir ?? ""
28218
+ default_token_file: config?.defaultTokenFile ?? ""
28325
28219
  };
28326
28220
  }
28327
28221
  var FIELD_LABELS = {
28328
28222
  spaceId: "Space ID",
28329
28223
  environmentId: "Environment ID",
28330
28224
  cmaToken: "CMA Token",
28331
- host: "API Host",
28332
- defaultComponentDir: "Default component directory",
28333
- defaultTokenFile: "Default token file",
28334
- contentfulBaseDir: "Root Project Directory"
28225
+ host: "API Host (optional)",
28226
+ defaultComponentDir: "Default component directory (optional)",
28227
+ defaultTokenFile: "Default token file (optional)"
28335
28228
  };
28336
- var FIELD_HINTS = {
28337
- contentfulBaseDir: "(where .contentful goes)"
28338
- };
28339
- var LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
28340
28229
  function ConfigurationScreen({ onDone }) {
28341
28230
  const [stage, setStage] = useState29("loading");
28342
28231
  const [config, setConfig] = useState29(null);
@@ -28345,7 +28234,7 @@ function ConfigurationScreen({ onDone }) {
28345
28234
  const [lastSaved, setLastSaved] = useState29(null);
28346
28235
  const [editing, setEditing] = useState29(false);
28347
28236
  const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
28348
- useEffect23(() => {
28237
+ useEffect24(() => {
28349
28238
  readCredentials().then((cfg) => {
28350
28239
  setConfig(cfg);
28351
28240
  setStage("form");
@@ -28372,7 +28261,6 @@ function ConfigurationScreen({ onDone }) {
28372
28261
  setNotice(null);
28373
28262
  writeCredentials(config).then(() => {
28374
28263
  setLastSaved(config);
28375
- if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
28376
28264
  setNotice({ kind: "success", text: "Configuration saved" });
28377
28265
  setStage("form");
28378
28266
  }).catch((err) => {
@@ -28438,7 +28326,10 @@ function ConfigurationScreen({ onDone }) {
28438
28326
  const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
28439
28327
  return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
28440
28328
  /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
28441
- /* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
28329
+ /* @__PURE__ */ jsxs45(Text46, { bold: isActive, children: [
28330
+ FIELD_LABELS[field],
28331
+ ":"
28332
+ ] }),
28442
28333
  isActive && editing ? /* @__PURE__ */ jsx55(
28443
28334
  TextInput4,
28444
28335
  {
@@ -28447,8 +28338,7 @@ function ConfigurationScreen({ onDone }) {
28447
28338
  onSubmit: () => setEditing(false),
28448
28339
  mask: field === "cmaToken" ? "\u2022" : void 0
28449
28340
  }
28450
- ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
28451
- FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
28341
+ ) : /* @__PURE__ */ jsx55(Text46, { children: display || /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" }) })
28452
28342
  ] }, field);
28453
28343
  }) }),
28454
28344
  notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
@@ -28481,7 +28371,7 @@ function ConfigurationScreen({ onDone }) {
28481
28371
  }
28482
28372
 
28483
28373
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
28484
- import { useEffect as useEffect24, useState as useState30 } from "react";
28374
+ import { useEffect as useEffect25, useState as useState30 } from "react";
28485
28375
  import { Box as Box45, Text as Text47, useInput as useInput12 } from "ink";
28486
28376
 
28487
28377
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
@@ -28500,12 +28390,11 @@ async function writeAnalyticsSetting(setting) {
28500
28390
  }
28501
28391
 
28502
28392
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
28503
- init_debug_store();
28504
28393
  import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
28505
28394
  function OptInAnalyticsScreen({ onDone }) {
28506
28395
  const [loading, setLoading] = useState30(true);
28507
28396
  const [enabled, setEnabled] = useState30(true);
28508
- useEffect24(() => {
28397
+ useEffect25(() => {
28509
28398
  readAnalyticsSetting().then((setting) => {
28510
28399
  setEnabled(setting.enabled);
28511
28400
  setLoading(false);
@@ -28559,15 +28448,13 @@ function OptInAnalyticsScreen({ onDone }) {
28559
28448
  }
28560
28449
 
28561
28450
  // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
28562
- import { useEffect as useEffect25, useState as useState31 } from "react";
28451
+ import { useEffect as useEffect26, useState as useState31 } from "react";
28563
28452
  import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
28564
- init_version();
28565
- init_debug_store();
28566
28453
  import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
28567
28454
  var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
28568
28455
  function UpgradeScreen({ onDone }) {
28569
28456
  const [upgradeCheck, setUpgradeCheck] = useState31();
28570
- useEffect25(() => {
28457
+ useEffect26(() => {
28571
28458
  startDebugRun({
28572
28459
  flow: "upgrade",
28573
28460
  step: "01-upgrade",
@@ -28632,15 +28519,13 @@ function renderBody(upgradeCheck) {
28632
28519
  }
28633
28520
 
28634
28521
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
28635
- import { useEffect as useEffect26, useState as useState32 } from "react";
28522
+ import { useEffect as useEffect27, useState as useState32 } from "react";
28636
28523
  import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
28637
- init_debug_mode_store();
28638
- init_debug_store();
28639
28524
  import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
28640
28525
  function DebugModeScreen({ onDone }) {
28641
28526
  const [loading, setLoading] = useState32(true);
28642
28527
  const [enabled, setEnabled] = useState32(true);
28643
- useEffect26(() => {
28528
+ useEffect27(() => {
28644
28529
  readDebugModeSetting().then((setting) => {
28645
28530
  setEnabled(setting.enabled);
28646
28531
  setLoading(false);
@@ -28720,7 +28605,7 @@ function App({ importOptions, inkClear }) {
28720
28605
  const [flowStart, setFlowStart] = useState33();
28721
28606
  const flow = useFlow(flowStart);
28722
28607
  const [importDefaults, setImportDefaults] = useState33();
28723
- useEffect27(() => {
28608
+ useEffect28(() => {
28724
28609
  if (screen !== "import") {
28725
28610
  setImportDefaults(void 0);
28726
28611
  return;
@@ -28738,7 +28623,7 @@ function App({ importOptions, inkClear }) {
28738
28623
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
28739
28624
  const state = await inspectTokens({
28740
28625
  rawTokensPath: tokens,
28741
- contentfulDir: join25(resolveUserPath(projectPath2), ".contentful"),
28626
+ outDir: join25(resolveUserPath(projectPath2), ".contentful"),
28742
28627
  cache: importOptions.cache
28743
28628
  });
28744
28629
  if (state.kind === "cached") {
@@ -28759,7 +28644,6 @@ function App({ importOptions, inkClear }) {
28759
28644
  const settings = await readSettings2();
28760
28645
  const { agent, agentModel } = resolveAgentChoice(launch.agent, settings);
28761
28646
  const generatePromptPath = typeof settings.generatePromptPath === "string" ? settings.generatePromptPath : void 0;
28762
- const outDir = await (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).startImportRun(resolveUserPath(launch.projectPath ?? ""));
28763
28647
  setExtractionRun({
28764
28648
  ...generatePromptPath ? { generatePromptPath } : {},
28765
28649
  // the later steps get the same agent, so they use what the stage used
@@ -28768,7 +28652,6 @@ function App({ importOptions, inkClear }) {
28768
28652
  tokenStrategy,
28769
28653
  input: {
28770
28654
  projectPath: resolveUserPath(launch.projectPath ?? ""),
28771
- outDir,
28772
28655
  filePaths: launch.filePaths ?? [],
28773
28656
  rawTokensPath: launch.tokens ?? "",
28774
28657
  tokenStrategy,
@@ -28780,12 +28663,12 @@ function App({ importOptions, inkClear }) {
28780
28663
  }
28781
28664
  });
28782
28665
  };
28783
- useEffect27(() => {
28666
+ useEffect28(() => {
28784
28667
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
28785
28668
  setExtractionRun(void 0);
28786
28669
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
28787
28670
  }, [extraction, extractionRun]);
28788
- useEffect27(() => {
28671
+ useEffect28(() => {
28789
28672
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
28790
28673
  const { extraction: produced, input, generatePromptPath } = scopeRun;
28791
28674
  setGenerationInput({
@@ -28803,7 +28686,7 @@ function App({ importOptions, inkClear }) {
28803
28686
  ...generatePromptPath ? { generatePromptPath } : {}
28804
28687
  });
28805
28688
  }, [scopeFlow, scopeRun, generationInput]);
28806
- useEffect27(() => {
28689
+ useEffect28(() => {
28807
28690
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
28808
28691
  const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
28809
28692
  inkClear();