@contentful/experience-design-system-cli 2.37.1-dev-build-7652d7c0.0 → 2.37.1-dev-build-6fb2b08b.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,6 +8,71 @@ 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
+
11
76
  // packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-name.js
12
77
  var AGENT_NAMES;
13
78
  var init_agent_name = __esm({
@@ -772,7 +837,7 @@ async function runAgent(options) {
772
837
  promptLen: prompt.length,
773
838
  promptHead: prompt.slice(0, 500)
774
839
  });
775
- return new Promise((resolve25) => {
840
+ return new Promise((resolve27) => {
776
841
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
777
842
  const child = spawn(binary, args, {
778
843
  stdio: ["pipe", "pipe", "pipe"],
@@ -821,7 +886,7 @@ async function runAgent(options) {
821
886
  stderrLen: stderr.length,
822
887
  stderrTail: stderr.slice(-1e3)
823
888
  });
824
- resolve25(result);
889
+ resolve27(result);
825
890
  });
826
891
  });
827
892
  }
@@ -843,7 +908,7 @@ async function checkAgentAuth(agent) {
843
908
  return "not-found";
844
909
  if (agent !== "claude")
845
910
  return "ok";
846
- return new Promise((resolve25) => {
911
+ return new Promise((resolve27) => {
847
912
  const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
848
913
  let stdout = "";
849
914
  let done = false;
@@ -852,7 +917,7 @@ async function checkAgentAuth(agent) {
852
917
  return;
853
918
  done = true;
854
919
  child.kill("SIGTERM");
855
- resolve25("unauthenticated");
920
+ resolve27("unauthenticated");
856
921
  }, 5e3);
857
922
  child.stdout?.on("data", (chunk) => {
858
923
  stdout += chunk.toString();
@@ -863,14 +928,14 @@ async function checkAgentAuth(agent) {
863
928
  done = true;
864
929
  clearTimeout(timer);
865
930
  if (code !== 0) {
866
- resolve25("unauthenticated");
931
+ resolve27("unauthenticated");
867
932
  return;
868
933
  }
869
934
  try {
870
935
  const status = JSON.parse(stdout);
871
- resolve25(status.loggedIn ? "ok" : "unauthenticated");
936
+ resolve27(status.loggedIn ? "ok" : "unauthenticated");
872
937
  } catch {
873
- resolve25("unauthenticated");
938
+ resolve27("unauthenticated");
874
939
  }
875
940
  });
876
941
  });
@@ -880,9 +945,9 @@ async function binaryIsOnPath(binary) {
880
945
  const fs = await import("node:fs/promises");
881
946
  return fs.access(binary).then(() => true, () => false);
882
947
  }
883
- return new Promise((resolve25) => {
948
+ return new Promise((resolve27) => {
884
949
  const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
885
- child.on("close", (code) => resolve25(code === 0));
950
+ child.on("close", (code) => resolve27(code === 0));
886
951
  });
887
952
  }
888
953
  var init_check_agent_auth = __esm({
@@ -2016,6 +2081,253 @@ var init_cache_keys = __esm({
2016
2081
  }
2017
2082
  });
2018
2083
 
2084
+ // packages/experience-design-system-types/dist/src/config/index.js
2085
+ import { randomBytes as randomBytes4 } 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}.${randomBytes4(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
+
2019
2331
  // packages/experience-design-system-cli/app.tsx
2020
2332
  import { join as join25 } from "node:path";
2021
2333
  import { useEffect as useEffect26, useState as useState33 } from "react";
@@ -2055,60 +2367,8 @@ function brandBar(width, ramp = BRAND_RAMP) {
2055
2367
  }
2056
2368
  var FOCUS_MARKER = "\u276F";
2057
2369
 
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
- }
2370
+ // packages/experience-design-system-cli/src/tui/home/home.tsx
2371
+ init_version();
2112
2372
 
2113
2373
  // packages/experience-design-system-cli/src/tui/use-terminal-width.ts
2114
2374
  import { useEffect, useState } from "react";
@@ -12307,11 +12567,11 @@ import { access as access2, mkdir, readFile as readFile7, writeFile } from "node
12307
12567
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
12308
12568
  import { resolve as resolve15 } from "node:path";
12309
12569
  async function getRefineSessionPaths(sessionId, artifactsRoot) {
12310
- const sessionDir = resolve15(artifactsRoot, sessionId);
12570
+ const sessionDir2 = resolve15(artifactsRoot, sessionId);
12311
12571
  return {
12312
- sessionDir,
12313
- eventsPath: resolve15(sessionDir, "events.jsonl"),
12314
- statePath: resolve15(sessionDir, "current-review-state.json")
12572
+ sessionDir: sessionDir2,
12573
+ eventsPath: resolve15(sessionDir2, "events.jsonl"),
12574
+ statePath: resolve15(sessionDir2, "current-review-state.json")
12315
12575
  };
12316
12576
  }
12317
12577
 
@@ -13564,7 +13824,7 @@ function errorMessage(error) {
13564
13824
  return error instanceof Error && error.message ? error.message : String(error);
13565
13825
  }
13566
13826
  function defaultSleep(delayMs) {
13567
- return new Promise((resolve25) => setTimeout(resolve25, delayMs));
13827
+ return new Promise((resolve27) => setTimeout(resolve27, delayMs));
13568
13828
  }
13569
13829
 
13570
13830
  // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
@@ -13805,7 +14065,7 @@ var ApiClient = class {
13805
14065
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
13806
14066
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
13807
14067
  const jitter = Math.random() * baseDelay * 0.15;
13808
- await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
14068
+ await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
13809
14069
  }
13810
14070
  }
13811
14071
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -14937,31 +15197,21 @@ async function runMapTokens(request) {
14937
15197
  await bindAnalyticsSessionId(sessionId);
14938
15198
  const tokenLeaves = loadTokenLeaves(db, sessionId);
14939
15199
  const knownTokenPaths = new Set(tokenLeaves.map((t) => t.path));
14940
- const diagnostics = [];
14941
15200
  if (request.tokenMapInline) {
14942
15201
  const validMappings = {};
14943
15202
  for (const [rawName, path5] of Object.entries(request.tokenMapInline)) {
14944
- if (knownTokenPaths.has(path5)) {
15203
+ if (knownTokenPaths.has(path5))
14945
15204
  validMappings[rawName] = path5;
14946
- } else {
14947
- diagnostics.push(`Token map '${rawName}' -> '${path5}': path not found in session tokens \u2014 skipped.`);
14948
- }
14949
15205
  }
14950
15206
  replaceRawTokenNamePaths(db, sessionId, validMappings, "manual");
14951
15207
  }
14952
15208
  const rawDefaults = loadRawDefaults(db, sessionId);
14953
15209
  const defaultResolution = resolveTokenDefaults(rawDefaults.map((row) => ({ rawDefault: row.default_reference, tokenKind: row.cdf_token_kind })), tokenLeaves);
14954
- for (const diagnostic of defaultResolution.diagnostics)
14955
- diagnostics.push(diagnostic.message);
14956
15210
  const manualMappings = new Map(getRawTokenNamePathRows(db, sessionId).filter((row) => row.source === "manual").map((row) => [row.rawName, row.path]));
14957
15211
  const automaticMappings = {};
14958
15212
  for (const [rawName, path5] of Object.entries(defaultResolution.mappings)) {
14959
- const manualPath = manualMappings.get(rawName);
14960
- if (manualPath === void 0) {
15213
+ if (manualMappings.get(rawName) === void 0)
14961
15214
  automaticMappings[rawName] = path5;
14962
- } else if (manualPath !== path5) {
14963
- diagnostics.push(`Token default '${rawName}' automatically resolves to '${path5}', but manual mapping '${manualPath}' is retained.`);
14964
- }
14965
15215
  }
14966
15216
  replaceRawTokenNamePaths(db, sessionId, automaticMappings, "automatic");
14967
15217
  const cdfEntries = loadCDFComponents(db, sessionId);
@@ -14972,7 +15222,7 @@ async function runMapTokens(request) {
14972
15222
  const { groups, tokens } = getDtcgTokensForSession(db, sessionId);
14973
15223
  const tokenCount = tokens.length;
14974
15224
  if (mappablePropCount === 0 || tokenCount === 0) {
14975
- return { type: "nothing-to-map", sessionId, mappablePropCount, tokenCount, diagnostics };
15225
+ return { type: "nothing-to-map", sessionId, mappablePropCount, tokenCount };
14976
15226
  }
14977
15227
  const generatedCdf = Object.fromEntries(cdfEntries.map((c2) => [c2.key, c2.entry]));
14978
15228
  const tokenTree = rebuildDTCGTree(groups, tokens);
@@ -14990,7 +15240,7 @@ async function runMapTokens(request) {
14990
15240
  });
14991
15241
  if (request.printPrompt) {
14992
15242
  const prompt2 = await buildMapPrompt();
14993
- return { type: "printed-prompt", sessionId, prompt: prompt2, diagnostics };
15243
+ return { type: "printed-prompt", sessionId, prompt: prompt2 };
14994
15244
  }
14995
15245
  if (request.skipAgent) {
14996
15246
  const stepId2 = createStep(db, sessionId, "map tokens", {
@@ -14999,7 +15249,7 @@ async function runMapTokens(request) {
14999
15249
  skipAgent: "true"
15000
15250
  });
15001
15251
  updateStep(db, stepId2, "complete", { applied: "0", skipAgent: "true" });
15002
- return { type: "skipped", sessionId, stepId: stepId2, diagnostics };
15252
+ return { type: "skipped", sessionId, stepId: stepId2 };
15003
15253
  }
15004
15254
  const agent = request.agent;
15005
15255
  const noCache = request.cache === false || process.env["EDS_NO_CACHE"] === "1";
@@ -15011,7 +15261,7 @@ async function runMapTokens(request) {
15011
15261
  const applied2 = copyMapTokensFromCache(db, cached.sourceSessionId, sessionId);
15012
15262
  const stepId2 = createStep(db, sessionId, "map tokens", { agent, model: request.model ?? "" });
15013
15263
  updateStep(db, stepId2, "complete", { cached: "true", applied: String(applied2) });
15014
- return { type: "cached", sessionId, applied: applied2, stepId: stepId2, diagnostics };
15264
+ return { type: "cached", sessionId, applied: applied2, stepId: stepId2 };
15015
15265
  }
15016
15266
  }
15017
15267
  const binary = resolveBinary(agent);
@@ -15038,7 +15288,7 @@ async function runMapTokens(request) {
15038
15288
  storeCache(db, inputHash, "token_mapping", "__map_tokens__", sessionId, false, promptHash);
15039
15289
  }
15040
15290
  updateStep(db, stepId, "complete", { applied: String(applied), warnings: String(warnings.length) });
15041
- return { type: "applied", sessionId, applied, warnings, stepId, diagnostics };
15291
+ return { type: "applied", sessionId, applied, warnings, stepId };
15042
15292
  } finally {
15043
15293
  db.close();
15044
15294
  }
@@ -16095,7 +16345,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
16095
16345
  const message = error instanceof Error ? error.message : String(error);
16096
16346
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
16097
16347
  throw error;
16098
- await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
16348
+ await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
16099
16349
  }
16100
16350
  }
16101
16351
  }
@@ -16928,6 +17178,7 @@ function useCredentialsControls(handlers) {
16928
17178
  }
16929
17179
 
16930
17180
  // packages/experience-design-system-cli/src/tui/user-agent.ts
17181
+ init_version();
16931
17182
  function cliUserAgent() {
16932
17183
  return buildUserAgent(readPackageVersion());
16933
17184
  }
@@ -17272,11 +17523,34 @@ function RunningStep({
17272
17523
  }
17273
17524
 
17274
17525
  // packages/experience-design-system-cli/src/tui/import/steps/05-token-reuse/logic.ts
17275
- import { access as access5, stat as stat4 } from "node:fs/promises";
17526
+ import { access as access5, readdir as readdir2, stat as stat4 } from "node:fs/promises";
17276
17527
  import { join as join16 } from "node:path";
17277
- async function inspectTokens({ rawTokensPath, outDir, cache }) {
17528
+ async function findLatestTokens(contentfulDir) {
17529
+ const candidates = [join16(contentfulDir, "tokens.json")];
17530
+ try {
17531
+ for (const session of await readdir2(contentfulDir, { withFileTypes: true })) {
17532
+ if (!session.isDirectory()) continue;
17533
+ for (const run of await readdir2(join16(contentfulDir, session.name), { withFileTypes: true }).catch(() => [])) {
17534
+ if (run.isDirectory() && /^dsi-import-\d+$/.test(run.name)) {
17535
+ candidates.push(join16(contentfulDir, session.name, run.name, "tokens.json"));
17536
+ }
17537
+ }
17538
+ }
17539
+ } catch {
17540
+ }
17541
+ const found = [];
17542
+ for (const path5 of candidates) {
17543
+ try {
17544
+ found.push({ path: path5, mtimeMs: (await stat4(path5)).mtimeMs });
17545
+ } catch {
17546
+ }
17547
+ }
17548
+ return found.sort((a, b) => b.mtimeMs - a.mtimeMs)[0]?.path ?? null;
17549
+ }
17550
+ async function inspectTokens({ rawTokensPath, contentfulDir, cache }) {
17278
17551
  if (!cache) return { kind: "none" };
17279
- const tokensPath = join16(outDir, "tokens.json");
17552
+ const tokensPath = await findLatestTokens(contentfulDir);
17553
+ if (!tokensPath) return { kind: "none" };
17280
17554
  try {
17281
17555
  await access5(tokensPath);
17282
17556
  } catch {
@@ -17427,34 +17701,8 @@ function ExtractionScreen({
17427
17701
  );
17428
17702
  }
17429
17703
 
17430
- // packages/experience-design-system-types/dist/src/config/index.js
17431
- import { randomBytes as randomBytes4 } from "node:crypto";
17432
- import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
17433
- import { homedir as homedir3 } from "node:os";
17434
- import { dirname as dirname13, join as join17 } from "node:path";
17435
- function configRoot2() {
17436
- return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
17437
- }
17438
- var configFilePath2 = () => join17(configRoot2(), "config.json");
17439
- var debugSessionsDir2 = () => join17(configRoot2(), "debug", "sessions");
17440
- async function readSettings2() {
17441
- try {
17442
- return JSON.parse(await readFile18(configFilePath2(), "utf8"));
17443
- } catch {
17444
- return {};
17445
- }
17446
- }
17447
- async function writeSettings2(settings) {
17448
- const path5 = configFilePath2();
17449
- await mkdir6(dirname13(path5), { recursive: true });
17450
- const tmp = `${path5}.${process.pid}.${randomBytes4(4).toString("hex")}.tmp`;
17451
- await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
17452
- `, { mode: 384 });
17453
- await rename2(tmp, path5);
17454
- }
17455
- async function updateSettings2(patch) {
17456
- await writeSettings2({ ...await readSettings2(), ...patch });
17457
- }
17704
+ // packages/experience-design-system-cli/app.tsx
17705
+ init_config();
17458
17706
 
17459
17707
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
17460
17708
  import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
@@ -17581,7 +17829,7 @@ var realDeps = {
17581
17829
  var fail = (step, message) => ({ ok: false, step, message });
17582
17830
  var errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
17583
17831
  async function runExtraction(input, onProgress, deps = realDeps) {
17584
- const outDir = join19(resolve22(input.projectPath), ".contentful");
17832
+ const outDir = input.outDir ?? join19(resolve22(input.projectPath), ".contentful");
17585
17833
  let progress = initialProgress({
17586
17834
  hasCredentials: input.credentials !== null,
17587
17835
  hasRawTokens: input.rawTokensPath !== "",
@@ -20716,7 +20964,7 @@ async function runGeneration(input, onProgress, deps = realDeps3) {
20716
20964
  update({ mapTokens: "running" });
20717
20965
  try {
20718
20966
  const mapTokensOptions = await buildMapTokensOptions(input);
20719
- const mapResult = await deps.runMapTokens({
20967
+ await deps.runMapTokens({
20720
20968
  sessionId: input.sessionId,
20721
20969
  agent: input.agent,
20722
20970
  ...input.agentModel ? { model: input.agentModel } : {},
@@ -20724,11 +20972,6 @@ async function runGeneration(input, onProgress, deps = realDeps3) {
20724
20972
  skillPathOverride: MAP_TOKENS_SKILL_PATH,
20725
20973
  ...mapTokensOptions
20726
20974
  });
20727
- if (mapResult.diagnostics.length > 0) {
20728
- process.stderr.write(`Unresolved token defaults:
20729
- ${mapResult.diagnostics.map((d) => ` ${d}`).join("\n")}
20730
- `);
20731
- }
20732
20975
  } catch (error) {
20733
20976
  const message = error instanceof MapTokensRunFailure ? error.message : error instanceof Error ? error.message : String(error);
20734
20977
  return fail2("map tokens", message);
@@ -27365,7 +27608,7 @@ import { useEffect as useEffect20, useRef as useRef12, useSyncExternalStore } fr
27365
27608
  import { appendFileSync, writeFileSync } from "node:fs";
27366
27609
  import { mkdir as mkdir8 } from "node:fs/promises";
27367
27610
  import { tmpdir } from "node:os";
27368
- import { join as join23 } from "node:path";
27611
+ import { join as join23, resolve as resolve25 } from "node:path";
27369
27612
 
27370
27613
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
27371
27614
  function shouldBypassPreview(state2) {
@@ -27736,7 +27979,7 @@ var realSaveDeps = () => ({
27736
27979
  writeFile: (path5, contents) => writeFile7(path5, contents),
27737
27980
  appendRun,
27738
27981
  buildSourceFingerprint,
27739
- sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
27982
+ sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
27740
27983
  warn: (message) => process.stderr.write(message)
27741
27984
  });
27742
27985
  async function runPrintFiles(input, deps, onPatch) {
@@ -28070,7 +28313,7 @@ function createFlowController(start, deps) {
28070
28313
  },
28071
28314
  async submitPath(submitted) {
28072
28315
  await deps.mkdir(submitted);
28073
- if (await deps.detectSaveConflict(submitted)) {
28316
+ if (resolve25(submitted) !== resolve25(state2.outDir) && await deps.detectSaveConflict(submitted)) {
28074
28317
  const subdir = deps.buildTimestampedSubdir(submitted);
28075
28318
  await deps.mkdir(subdir);
28076
28319
  await proceedToWrite(subdir);
@@ -28119,171 +28362,19 @@ function useFlow(start, options = {}) {
28119
28362
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
28120
28363
  import { useEffect as useEffect21, useState as useState27 } from "react";
28121
28364
  import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
28122
-
28123
- // packages/experience-design-system-cli/src/tui/debug-store.ts
28124
- import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
28125
- import { existsSync as existsSync9, readdirSync as readdirSync4 } from "node:fs";
28126
- import { join as join24 } from "node:path";
28127
-
28128
- // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
28129
- var DEFAULT_DEBUG_MODE_SETTING = {
28130
- enabled: true
28131
- };
28132
- async function readDebugModeSetting() {
28133
- const { debugMode } = await readSettings2();
28134
- return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
28135
- }
28136
- async function writeDebugModeSetting(setting) {
28137
- await updateSettings2({ debugMode: setting });
28138
- }
28139
-
28140
- // packages/experience-design-system-cli/src/tui/debug-store.ts
28141
- var pendingRun;
28142
- function generateRunId() {
28143
- const now = /* @__PURE__ */ new Date();
28144
- const pad = (n) => String(n).padStart(2, "0");
28145
- return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
28146
- }
28147
- function datePrefix(now = /* @__PURE__ */ new Date()) {
28148
- const pad = (n) => String(n).padStart(2, "0");
28149
- return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
28150
- }
28151
- function slugify(value) {
28152
- return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
28153
- }
28154
- function generateSessionId3() {
28155
- const today = datePrefix();
28156
- const root = debugSessionsDir2();
28157
- const existing = existsSync9(root) ? readdirSync4(root) : [];
28158
- const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
28159
- const maxSeq = existing.reduce((max, entry) => {
28160
- const match2 = seqPattern.exec(entry);
28161
- return match2 ? Math.max(max, Number(match2[1])) : max;
28162
- }, 0);
28163
- return `${today}-session-${maxSeq + 1}`;
28164
- }
28165
- var SESSION_ID = generateSessionId3();
28166
- function sessionDebugDir() {
28167
- return join24(debugSessionsDir2(), SESSION_ID);
28168
- }
28169
- function currentDebugSessionDir() {
28170
- return sessionDebugDir();
28171
- }
28172
- void isDebugModeEnabled().then((enabled) => {
28173
- if (!enabled) return void 0;
28174
- return mkdir9(sessionDebugDir(), { recursive: true });
28175
- });
28176
- async function isDebugModeEnabled() {
28177
- try {
28178
- return (await readDebugModeSetting()).enabled;
28179
- } catch {
28180
- return true;
28181
- }
28182
- }
28183
- function redact(value) {
28184
- const clone = { ...value };
28185
- if ("cma_token" in clone) {
28186
- const raw = clone.cma_token;
28187
- clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
28188
- }
28189
- return clone;
28190
- }
28191
- function startDebugRun({
28192
- flow,
28193
- step,
28194
- menuOption,
28195
- inputs
28196
- }) {
28197
- const runId = generateRunId();
28198
- const startedAt = Date.now();
28199
- const redactedInputs = redact(inputs);
28200
- isDebugModeEnabled().then((enabled) => {
28201
- if (!enabled) return;
28202
- pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
28203
- });
28204
- }
28205
- async function finishDebugRun({
28206
- outputs,
28207
- status,
28208
- exitMethod
28209
- }) {
28210
- const run = pendingRun;
28211
- if (!run) return;
28212
- pendingRun = void 0;
28213
- const durationMs = Date.now() - run.startedAt;
28214
- const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
28215
- const flowSegments = run.flow.split("/");
28216
- const dir = join24(sessionDebugDir(), ...flowSegments);
28217
- await mkdir9(dir, { recursive: true });
28218
- const filename = nextAttemptFilename(dir, run.menuOption);
28219
- await writeFile8(join24(dir, filename), content, { mode: 384 });
28220
- }
28221
- function nextAttemptFilename(dir, menuOption) {
28222
- const today = datePrefix();
28223
- const optionSlug = slugify(menuOption);
28224
- const existing = existsSync9(dir) ? readdirSync4(dir) : [];
28225
- const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
28226
- const maxAttempt = existing.reduce((max, entry) => {
28227
- const match2 = attemptPattern.exec(entry);
28228
- return match2 ? Math.max(max, Number(match2[1])) : max;
28229
- }, 0);
28230
- return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
28231
- }
28232
- function renderMarkdown(run, finish) {
28233
- const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
28234
- const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
28235
- const flowSlug = run.flow.split("/").join("-");
28236
- return `# Debug Log
28237
-
28238
- - Run ID: ${run.runId}
28239
- - Flow: ${flowSlug}
28240
- - Step: ${stepLabel2}
28241
- - Menu option: ${run.menuOption}
28242
- - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
28243
- - CLI version: ${readPackageVersion()}
28244
- - Platform: ${process.platform} / Node ${process.version}
28245
- - Duration on screen: ${finish.durationMs}ms
28246
- - Status: ${finish.status}
28247
- - Exit method: ${finish.exitMethod}
28248
-
28249
- ## Inputs
28250
- \`\`\`json
28251
- ${JSON.stringify(run.inputs, null, 2)}
28252
- \`\`\`
28253
-
28254
- ## Outputs
28255
- \`\`\`json
28256
- ${JSON.stringify(finish.outputs, null, 2)}
28257
- \`\`\`
28258
- `;
28259
- }
28260
- function handleCrash() {
28261
- return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
28262
- }
28263
- process.once("uncaughtException", (err) => {
28264
- void handleCrash().finally(() => {
28265
- throw err;
28266
- });
28267
- });
28268
- process.once("unhandledRejection", (reason) => {
28269
- void handleCrash().finally(() => {
28270
- throw reason;
28271
- });
28272
- });
28273
- process.once("SIGINT", () => {
28274
- void handleCrash().finally(() => {
28275
- process.exit(130);
28276
- });
28277
- });
28365
+ init_debug_store();
28278
28366
 
28279
28367
  // packages/experience-design-system-cli/src/tui/help/help-info.ts
28368
+ init_config();
28369
+ init_debug_store();
28370
+ init_debug_mode_store();
28371
+ init_version();
28280
28372
  async function readHelpInfo() {
28281
28373
  const debugMode = await readDebugModeSetting();
28282
28374
  return {
28283
28375
  storage: [
28284
28376
  { label: "Config folder", value: configRoot2() },
28285
- { label: "Settings file", value: configFilePath2() },
28286
- { label: "Debug logs", value: debugSessionsDir2() }
28377
+ { label: "Settings file", value: configFilePath2() }
28287
28378
  ],
28288
28379
  troubleshooting: [
28289
28380
  { label: "CLI version", value: readPackageVersion() },
@@ -28292,7 +28383,7 @@ async function readHelpInfo() {
28292
28383
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
28293
28384
  {
28294
28385
  label: "This session",
28295
- value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
28386
+ 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"
28296
28387
  }
28297
28388
  ]
28298
28389
  };
@@ -28409,6 +28500,7 @@ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
28409
28500
  import TextInput4 from "ink-text-input";
28410
28501
 
28411
28502
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
28503
+ init_config();
28412
28504
  var readV1Store = readSettings2;
28413
28505
  var writeV1Store = writeSettings2;
28414
28506
 
@@ -28421,7 +28513,8 @@ async function readCredentials() {
28421
28513
  cmaToken: store.cmaToken || "",
28422
28514
  host: store.host || "",
28423
28515
  defaultComponentDir: store.defaultComponentDir || "",
28424
- defaultTokenFile: store.defaultTokenFile || ""
28516
+ defaultTokenFile: store.defaultTokenFile || "",
28517
+ contentfulBaseDir: store.contentfulBaseDir || ""
28425
28518
  };
28426
28519
  }
28427
28520
  async function writeCredentials(config) {
@@ -28437,6 +28530,7 @@ async function writeCredentials(config) {
28437
28530
  }
28438
28531
 
28439
28532
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28533
+ init_debug_store();
28440
28534
  import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
28441
28535
  var FIELD_ORDER = [
28442
28536
  "spaceId",
@@ -28444,7 +28538,8 @@ var FIELD_ORDER = [
28444
28538
  "cmaToken",
28445
28539
  "host",
28446
28540
  "defaultComponentDir",
28447
- "defaultTokenFile"
28541
+ "defaultTokenFile",
28542
+ "contentfulBaseDir"
28448
28543
  ];
28449
28544
  function debugFields(config) {
28450
28545
  return {
@@ -28453,17 +28548,23 @@ function debugFields(config) {
28453
28548
  cma_token: config?.cmaToken ?? "",
28454
28549
  host: config?.host ?? "",
28455
28550
  default_component_dir: config?.defaultComponentDir ?? "",
28456
- default_token_file: config?.defaultTokenFile ?? ""
28551
+ default_token_file: config?.defaultTokenFile ?? "",
28552
+ contentful_base_dir: config?.contentfulBaseDir ?? ""
28457
28553
  };
28458
28554
  }
28459
28555
  var FIELD_LABELS = {
28460
28556
  spaceId: "Space ID",
28461
28557
  environmentId: "Environment ID",
28462
28558
  cmaToken: "CMA Token",
28463
- host: "API Host (optional)",
28464
- defaultComponentDir: "Default component directory (optional)",
28465
- defaultTokenFile: "Default token file (optional)"
28559
+ host: "API Host",
28560
+ defaultComponentDir: "Default component directory",
28561
+ defaultTokenFile: "Default token file",
28562
+ contentfulBaseDir: "Root Project Directory"
28563
+ };
28564
+ var FIELD_HINTS = {
28565
+ contentfulBaseDir: "(where .contentful goes)"
28466
28566
  };
28567
+ var LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
28467
28568
  function ConfigurationScreen({ onDone }) {
28468
28569
  const [stage, setStage] = useState29("loading");
28469
28570
  const [config, setConfig] = useState29(null);
@@ -28499,6 +28600,7 @@ function ConfigurationScreen({ onDone }) {
28499
28600
  setNotice(null);
28500
28601
  writeCredentials(config).then(() => {
28501
28602
  setLastSaved(config);
28603
+ if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
28502
28604
  setNotice({ kind: "success", text: "Configuration saved" });
28503
28605
  setStage("form");
28504
28606
  }).catch((err) => {
@@ -28564,10 +28666,7 @@ function ConfigurationScreen({ onDone }) {
28564
28666
  const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
28565
28667
  return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
28566
28668
  /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
28567
- /* @__PURE__ */ jsxs45(Text46, { bold: isActive, children: [
28568
- FIELD_LABELS[field],
28569
- ":"
28570
- ] }),
28669
+ /* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
28571
28670
  isActive && editing ? /* @__PURE__ */ jsx55(
28572
28671
  TextInput4,
28573
28672
  {
@@ -28576,7 +28675,8 @@ function ConfigurationScreen({ onDone }) {
28576
28675
  onSubmit: () => setEditing(false),
28577
28676
  mask: field === "cmaToken" ? "\u2022" : void 0
28578
28677
  }
28579
- ) : /* @__PURE__ */ jsx55(Text46, { children: display || /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" }) })
28678
+ ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
28679
+ FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
28580
28680
  ] }, field);
28581
28681
  }) }),
28582
28682
  notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
@@ -28628,6 +28728,7 @@ async function writeAnalyticsSetting(setting) {
28628
28728
  }
28629
28729
 
28630
28730
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
28731
+ init_debug_store();
28631
28732
  import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
28632
28733
  function OptInAnalyticsScreen({ onDone }) {
28633
28734
  const [loading, setLoading] = useState30(true);
@@ -28688,6 +28789,8 @@ function OptInAnalyticsScreen({ onDone }) {
28688
28789
  // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
28689
28790
  import { useEffect as useEffect24, useState as useState31 } from "react";
28690
28791
  import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
28792
+ init_version();
28793
+ init_debug_store();
28691
28794
  import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
28692
28795
  var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
28693
28796
  function UpgradeScreen({ onDone }) {
@@ -28759,6 +28862,8 @@ function renderBody(upgradeCheck) {
28759
28862
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
28760
28863
  import { useEffect as useEffect25, useState as useState32 } from "react";
28761
28864
  import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
28865
+ init_debug_mode_store();
28866
+ init_debug_store();
28762
28867
  import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
28763
28868
  function DebugModeScreen({ onDone }) {
28764
28869
  const [loading, setLoading] = useState32(true);
@@ -28861,7 +28966,7 @@ function App({ importOptions, inkClear }) {
28861
28966
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
28862
28967
  const state2 = await inspectTokens({
28863
28968
  rawTokensPath: tokens,
28864
- outDir: join25(resolveUserPath(projectPath2), ".contentful"),
28969
+ contentfulDir: join25(resolveUserPath(projectPath2), ".contentful"),
28865
28970
  cache: importOptions.cache
28866
28971
  });
28867
28972
  if (state2.kind === "cached") {
@@ -28882,6 +28987,7 @@ function App({ importOptions, inkClear }) {
28882
28987
  const settings = await readSettings2();
28883
28988
  const { agent, agentModel } = resolveAgentChoice(launch.agent, settings);
28884
28989
  const generatePromptPath = typeof settings.generatePromptPath === "string" ? settings.generatePromptPath : void 0;
28990
+ const outDir = await (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).startImportRun(resolveUserPath(launch.projectPath ?? ""));
28885
28991
  setExtractionRun({
28886
28992
  ...generatePromptPath ? { generatePromptPath } : {},
28887
28993
  // the later steps get the same agent, so they use what the stage used
@@ -28890,6 +28996,7 @@ function App({ importOptions, inkClear }) {
28890
28996
  tokenStrategy,
28891
28997
  input: {
28892
28998
  projectPath: resolveUserPath(launch.projectPath ?? ""),
28999
+ outDir,
28893
29000
  filePaths: launch.filePaths ?? [],
28894
29001
  rawTokensPath: launch.tokens ?? "",
28895
29002
  tokenStrategy,