@contentful/experience-design-system-cli 2.37.1-dev-build-ced30421.0 → 2.37.1-dev-build-a2454a09.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2121,7 +2121,7 @@ async function runAgent(options) {
2121
2121
  promptLen: prompt.length,
2122
2122
  promptHead: prompt.slice(0, 500)
2123
2123
  });
2124
- return new Promise((resolve25) => {
2124
+ return new Promise((resolve26) => {
2125
2125
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
2126
2126
  const child = spawn3(binary, args, {
2127
2127
  stdio: ["pipe", "pipe", "pipe"],
@@ -2170,7 +2170,7 @@ async function runAgent(options) {
2170
2170
  stderrLen: stderr.length,
2171
2171
  stderrTail: stderr.slice(-1e3)
2172
2172
  });
2173
- resolve25(result);
2173
+ resolve26(result);
2174
2174
  });
2175
2175
  });
2176
2176
  }
@@ -2192,7 +2192,7 @@ async function checkAgentAuth(agent) {
2192
2192
  return "not-found";
2193
2193
  if (agent !== "claude")
2194
2194
  return "ok";
2195
- return new Promise((resolve25) => {
2195
+ return new Promise((resolve26) => {
2196
2196
  const child = spawn4(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
2197
2197
  let stdout = "";
2198
2198
  let done = false;
@@ -2201,7 +2201,7 @@ async function checkAgentAuth(agent) {
2201
2201
  return;
2202
2202
  done = true;
2203
2203
  child.kill("SIGTERM");
2204
- resolve25("unauthenticated");
2204
+ resolve26("unauthenticated");
2205
2205
  }, 5e3);
2206
2206
  child.stdout?.on("data", (chunk) => {
2207
2207
  stdout += chunk.toString();
@@ -2212,14 +2212,14 @@ async function checkAgentAuth(agent) {
2212
2212
  done = true;
2213
2213
  clearTimeout(timer);
2214
2214
  if (code !== 0) {
2215
- resolve25("unauthenticated");
2215
+ resolve26("unauthenticated");
2216
2216
  return;
2217
2217
  }
2218
2218
  try {
2219
2219
  const status = JSON.parse(stdout);
2220
- resolve25(status.loggedIn ? "ok" : "unauthenticated");
2220
+ resolve26(status.loggedIn ? "ok" : "unauthenticated");
2221
2221
  } catch {
2222
- resolve25("unauthenticated");
2222
+ resolve26("unauthenticated");
2223
2223
  }
2224
2224
  });
2225
2225
  });
@@ -2229,9 +2229,9 @@ async function binaryIsOnPath(binary) {
2229
2229
  const fs = await import("node:fs/promises");
2230
2230
  return fs.access(binary).then(() => true, () => false);
2231
2231
  }
2232
- return new Promise((resolve25) => {
2232
+ return new Promise((resolve26) => {
2233
2233
  const child = spawn4(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
2234
- child.on("close", (code) => resolve25(code === 0));
2234
+ child.on("close", (code) => resolve26(code === 0));
2235
2235
  });
2236
2236
  }
2237
2237
  var init_check_agent_auth = __esm({
@@ -4386,30 +4386,8 @@ function applyScopeDecisions(db, sessionId, decisions) {
4386
4386
  const placeholders = accepted.map(() => "?").join(",");
4387
4387
  db.prepare(`UPDATE raw_components SET status = 'generated' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...accepted);
4388
4388
  }
4389
- removeSlotAllowedComponents(db, sessionId, decisions.excludedSlotEdges ?? [], rejected);
4390
4389
  db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
4391
4390
  }
4392
- function removeSlotAllowedComponents(db, sessionId, edges, rejectedNames) {
4393
- if (edges.length === 0 && rejectedNames.length === 0)
4394
- return;
4395
- const componentId = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?");
4396
- const removeEdge = db.prepare("DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ? AND allowed_component = ?");
4397
- const removeEverywhere = db.prepare("DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND allowed_component = ?");
4398
- db.exec("BEGIN");
4399
- try {
4400
- for (const edge of edges) {
4401
- const row = componentId.get(sessionId, edge.parent);
4402
- if (row)
4403
- removeEdge.run(sessionId, row.component_id, edge.child);
4404
- }
4405
- for (const name of rejectedNames)
4406
- removeEverywhere.run(sessionId, name);
4407
- db.exec("COMMIT");
4408
- } catch (e) {
4409
- db.exec("ROLLBACK");
4410
- throw e;
4411
- }
4412
- }
4413
4391
  function findLatestSessionForCommand(db, command) {
4414
4392
  return getLatestCompletedSessionForCommand(db, command);
4415
4393
  }
@@ -13166,11 +13144,11 @@ var init_load_and_validate_for_review = __esm({
13166
13144
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
13167
13145
  import { resolve as resolve15 } from "node:path";
13168
13146
  async function getRefineSessionPaths(sessionId, artifactsRoot) {
13169
- const sessionDir = resolve15(artifactsRoot, sessionId);
13147
+ const sessionDir2 = resolve15(artifactsRoot, sessionId);
13170
13148
  return {
13171
- sessionDir,
13172
- eventsPath: resolve15(sessionDir, "events.jsonl"),
13173
- statePath: resolve15(sessionDir, "current-review-state.json")
13149
+ sessionDir: sessionDir2,
13150
+ eventsPath: resolve15(sessionDir2, "events.jsonl"),
13151
+ statePath: resolve15(sessionDir2, "current-review-state.json")
13174
13152
  };
13175
13153
  }
13176
13154
  var init_review_session_paths = __esm({
@@ -14923,7 +14901,7 @@ function errorMessage(error) {
14923
14901
  return error instanceof Error && error.message ? error.message : String(error);
14924
14902
  }
14925
14903
  function defaultSleep(delayMs) {
14926
- return new Promise((resolve25) => setTimeout(resolve25, delayMs));
14904
+ return new Promise((resolve26) => setTimeout(resolve26, delayMs));
14927
14905
  }
14928
14906
  var MAX_RETRY_AFTER_MS;
14929
14907
  var init_http_utils = __esm({
@@ -15199,7 +15177,7 @@ var init_api_client = __esm({
15199
15177
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
15200
15178
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
15201
15179
  const jitter = Math.random() * baseDelay * 0.15;
15202
- await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
15180
+ await new Promise((resolve26) => setTimeout(resolve26, baseDelay + jitter));
15203
15181
  }
15204
15182
  }
15205
15183
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -18756,7 +18734,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
18756
18734
  const message = error instanceof Error ? error.message : String(error);
18757
18735
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
18758
18736
  throw error;
18759
- await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
18737
+ await new Promise((resolve26) => setTimeout(resolve26, Math.min(250 * attempt, 2e3)));
18760
18738
  }
18761
18739
  }
18762
18740
  }
@@ -20542,13 +20520,12 @@ async function writeSettings2(settings) {
20542
20520
  async function updateSettings2(patch) {
20543
20521
  await writeSettings2({ ...await readSettings2(), ...patch });
20544
20522
  }
20545
- var configFilePath2, runsFilePath2, debugSessionsDir2, oldConfigDir2;
20523
+ var configFilePath2, runsFilePath2, oldConfigDir2;
20546
20524
  var init_config = __esm({
20547
20525
  "packages/experience-design-system-types/dist/src/config/index.js"() {
20548
20526
  "use strict";
20549
20527
  configFilePath2 = () => join19(configRoot2(), "config.json");
20550
20528
  runsFilePath2 = () => join19(configRoot2(), "state", "runs.json");
20551
- debugSessionsDir2 = () => join19(configRoot2(), "debug", "sessions");
20552
20529
  oldConfigDir2 = () => join19(homedir3(), ".config", "experiences");
20553
20530
  }
20554
20531
  });
@@ -20827,6 +20804,199 @@ var init_run = __esm({
20827
20804
  }
20828
20805
  });
20829
20806
 
20807
+ // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
20808
+ async function readDebugModeSetting() {
20809
+ const { debugMode } = await readSettings2();
20810
+ return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
20811
+ }
20812
+ async function writeDebugModeSetting(setting) {
20813
+ await updateSettings2({ debugMode: setting });
20814
+ }
20815
+ var DEFAULT_DEBUG_MODE_SETTING;
20816
+ var init_debug_mode_store = __esm({
20817
+ "packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
20818
+ "use strict";
20819
+ init_config();
20820
+ DEFAULT_DEBUG_MODE_SETTING = {
20821
+ enabled: true
20822
+ };
20823
+ }
20824
+ });
20825
+
20826
+ // packages/experience-design-system-cli/src/tui/debug-store.ts
20827
+ var debug_store_exports = {};
20828
+ __export(debug_store_exports, {
20829
+ currentDebugSessionDir: () => currentDebugSessionDir,
20830
+ finishDebugRun: () => finishDebugRun,
20831
+ startDebugRun: () => startDebugRun,
20832
+ startDebugSessionIn: () => startDebugSessionIn
20833
+ });
20834
+ import { mkdir as mkdir8, writeFile as writeFile7 } from "node:fs/promises";
20835
+ import { existsSync as existsSync11, readdirSync as readdirSync3 } from "node:fs";
20836
+ import { join as join22, resolve as resolve23 } from "node:path";
20837
+ function generateRunId() {
20838
+ const now = /* @__PURE__ */ new Date();
20839
+ const pad = (n) => String(n).padStart(2, "0");
20840
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
20841
+ }
20842
+ function datePrefix(now = /* @__PURE__ */ new Date()) {
20843
+ const pad = (n) => String(n).padStart(2, "0");
20844
+ return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
20845
+ }
20846
+ function slugify(value) {
20847
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
20848
+ }
20849
+ async function readBaseDir() {
20850
+ try {
20851
+ const dir = (await readSettings2())["contentfulBaseDir"];
20852
+ return typeof dir === "string" && dir !== "" ? resolve23(dir) : void 0;
20853
+ } catch {
20854
+ return void 0;
20855
+ }
20856
+ }
20857
+ function nextSessionId(contentfulDir) {
20858
+ const today = datePrefix();
20859
+ const existing = existsSync11(contentfulDir) ? readdirSync3(contentfulDir) : [];
20860
+ const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
20861
+ const maxSeq = existing.reduce((max, entry) => {
20862
+ const match2 = seqPattern.exec(entry);
20863
+ return match2 ? Math.max(max, Number(match2[1])) : max;
20864
+ }, 0);
20865
+ return `${today}-session-${maxSeq + 1}`;
20866
+ }
20867
+ function startSession(base, { replace }) {
20868
+ const contentfulDir = join22(base, ".contentful");
20869
+ if (replace || !sessionDir) sessionDir = join22(contentfulDir, nextSessionId(contentfulDir));
20870
+ return sessionDir;
20871
+ }
20872
+ function currentDebugSessionDir() {
20873
+ return sessionDir && join22(sessionDir, "debug");
20874
+ }
20875
+ async function startDebugSessionIn(base, { replace = false } = {}) {
20876
+ try {
20877
+ if (!await isDebugModeEnabled()) return;
20878
+ await mkdir8(join22(startSession(resolve23(base), { replace }), "debug"), { recursive: true });
20879
+ } catch {
20880
+ }
20881
+ }
20882
+ async function isDebugModeEnabled() {
20883
+ try {
20884
+ return (await readDebugModeSetting()).enabled;
20885
+ } catch {
20886
+ return true;
20887
+ }
20888
+ }
20889
+ function redact(value) {
20890
+ const clone = { ...value };
20891
+ if ("cma_token" in clone) {
20892
+ const raw = clone.cma_token;
20893
+ clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
20894
+ }
20895
+ return clone;
20896
+ }
20897
+ function startDebugRun({
20898
+ flow,
20899
+ step,
20900
+ menuOption,
20901
+ inputs
20902
+ }) {
20903
+ const runId = generateRunId();
20904
+ const startedAt = Date.now();
20905
+ const redactedInputs = redact(inputs);
20906
+ isDebugModeEnabled().then((enabled) => {
20907
+ if (!enabled) return;
20908
+ pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
20909
+ });
20910
+ }
20911
+ async function finishDebugRun({
20912
+ outputs,
20913
+ status,
20914
+ exitMethod
20915
+ }) {
20916
+ const run = pendingRun;
20917
+ if (!run) return;
20918
+ pendingRun = void 0;
20919
+ const durationMs = Date.now() - run.startedAt;
20920
+ const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
20921
+ const root = currentDebugSessionDir();
20922
+ if (!root) return;
20923
+ const flowSegments = run.flow.split("/");
20924
+ const dir = join22(root, ...flowSegments);
20925
+ await mkdir8(dir, { recursive: true });
20926
+ const filename = nextAttemptFilename(dir, run.menuOption);
20927
+ await writeFile7(join22(dir, filename), content, { mode: 384 });
20928
+ }
20929
+ function nextAttemptFilename(dir, menuOption) {
20930
+ const today = datePrefix();
20931
+ const optionSlug = slugify(menuOption);
20932
+ const existing = existsSync11(dir) ? readdirSync3(dir) : [];
20933
+ const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
20934
+ const maxAttempt = existing.reduce((max, entry) => {
20935
+ const match2 = attemptPattern.exec(entry);
20936
+ return match2 ? Math.max(max, Number(match2[1])) : max;
20937
+ }, 0);
20938
+ return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
20939
+ }
20940
+ function renderMarkdown(run, finish) {
20941
+ const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
20942
+ const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
20943
+ const flowSlug = run.flow.split("/").join("-");
20944
+ return `# Debug Log
20945
+
20946
+ - Run ID: ${run.runId}
20947
+ - Flow: ${flowSlug}
20948
+ - Step: ${stepLabel2}
20949
+ - Menu option: ${run.menuOption}
20950
+ - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
20951
+ - CLI version: ${readPackageVersion()}
20952
+ - Platform: ${process.platform} / Node ${process.version}
20953
+ - Duration on screen: ${finish.durationMs}ms
20954
+ - Status: ${finish.status}
20955
+ - Exit method: ${finish.exitMethod}
20956
+
20957
+ ## Inputs
20958
+ \`\`\`json
20959
+ ${JSON.stringify(run.inputs, null, 2)}
20960
+ \`\`\`
20961
+
20962
+ ## Outputs
20963
+ \`\`\`json
20964
+ ${JSON.stringify(finish.outputs, null, 2)}
20965
+ \`\`\`
20966
+ `;
20967
+ }
20968
+ function handleCrash() {
20969
+ return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
20970
+ }
20971
+ var pendingRun, sessionDir;
20972
+ var init_debug_store = __esm({
20973
+ "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
20974
+ "use strict";
20975
+ init_config();
20976
+ init_version();
20977
+ init_debug_mode_store();
20978
+ void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
20979
+ if (!enabled || !base) return void 0;
20980
+ return mkdir8(join22(startSession(base, { replace: false }), "debug"), { recursive: true });
20981
+ });
20982
+ process.once("uncaughtException", (err) => {
20983
+ void handleCrash().finally(() => {
20984
+ throw err;
20985
+ });
20986
+ });
20987
+ process.once("unhandledRejection", (reason) => {
20988
+ void handleCrash().finally(() => {
20989
+ throw reason;
20990
+ });
20991
+ });
20992
+ process.once("SIGINT", () => {
20993
+ void handleCrash().finally(() => {
20994
+ process.exit(130);
20995
+ });
20996
+ });
20997
+ }
20998
+ });
20999
+
20830
21000
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
20831
21001
  import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
20832
21002
  function useExtraction(input) {
@@ -20846,6 +21016,7 @@ function useExtraction(input) {
20846
21016
  reuseTokens: input.tokenStrategy === "reuse"
20847
21017
  })
20848
21018
  });
21019
+ void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((store) => store.startDebugSessionIn(input.projectPath));
20849
21020
  void runExtraction(input, (progress) => {
20850
21021
  if (current.current === input) setState({ status: "running", progress });
20851
21022
  }).then((result) => {
@@ -21803,7 +21974,7 @@ function buildVisibleRows(props) {
21803
21974
  if (visited.has(target)) continue;
21804
21975
  visited.add(target);
21805
21976
  const isCycleMember = cycleParticipants.has(target);
21806
- out.push({ name: target, depth: cur.depth + 1, isCycleMember, parent: cur.name });
21977
+ out.push({ name: target, depth: cur.depth + 1, isCycleMember });
21807
21978
  queue.push({ name: target, depth: cur.depth + 1 });
21808
21979
  }
21809
21980
  }
@@ -21850,8 +22021,7 @@ function buildVisibleRows(props) {
21850
22021
  sharedSuffix,
21851
22022
  cycleChild: child.isCycleMember || void 0,
21852
22023
  itemIdx: childRec?.idx ?? -1,
21853
- rootName: key,
21854
- parentName: child.parent
22024
+ rootName: key
21855
22025
  });
21856
22026
  });
21857
22027
  }
@@ -21934,19 +22104,13 @@ function buildVisibleRows(props) {
21934
22104
  injectedChildren.push({
21935
22105
  name: target,
21936
22106
  depth: parentDepth + 1,
21937
- isCycleChild: true,
21938
- parent: parentName
22107
+ isCycleChild: true
21939
22108
  });
21940
22109
  }
21941
22110
  };
21942
22111
  emitCycleChildrenOf(root, 0);
21943
22112
  for (const c2 of closureChildren) {
21944
- injectedChildren.push({
21945
- name: c2.name,
21946
- depth: c2.depth,
21947
- isCycleChild: false,
21948
- parent: c2.path[c2.path.length - 2] ?? root
21949
- });
22113
+ injectedChildren.push({ name: c2.name, depth: c2.depth, isCycleChild: false });
21950
22114
  emitCycleChildrenOf(c2.name, c2.depth);
21951
22115
  }
21952
22116
  const isLastAtDepth = (idx) => {
@@ -21980,8 +22144,7 @@ function buildVisibleRows(props) {
21980
22144
  sharedSuffix,
21981
22145
  cycleChild: child.isCycleChild || void 0,
21982
22146
  itemIdx: childRec?.idx ?? -1,
21983
- rootName: root,
21984
- parentName: child.parent
22147
+ rootName: root
21985
22148
  });
21986
22149
  });
21987
22150
  }
@@ -22134,7 +22297,7 @@ function GroupedSidebar(props) {
22134
22297
  const rs = itemName ? renderStatusByKey?.get(itemName) : void 0;
22135
22298
  const badge = itemName ? previewBadge(previewAnnotationByKey?.get(itemName)) : null;
22136
22299
  const showInheritance = rs !== void 0 && row.kind !== "cycle" && row.kind !== "empty" && row.kind !== "group-root";
22137
- const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "empty" || row.kind === "cycle");
22300
+ const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "cycle");
22138
22301
  const selState = supportsSelectionGlyph ? selectionStateByKey.get(itemName) ?? "undecided" : void 0;
22139
22302
  const isCycleRow = row.kind === "cycle";
22140
22303
  const selStyle = selectionGlyphStyleFor(selState, isCycleRow);
@@ -22164,7 +22327,7 @@ function GroupedSidebar(props) {
22164
22327
  color: isSelected ? PALETTE2.info : labelStyle.dim ? PALETTE2.muted : labelStyle.color,
22165
22328
  bold: isSelected || labelStyle.bold,
22166
22329
  inverse: false,
22167
- underline: isSelected && focused,
22330
+ underline: isSelected && !focused,
22168
22331
  wrap: wrapLabels ? "wrap" : "truncate",
22169
22332
  children: [
22170
22333
  " ",
@@ -22915,7 +23078,6 @@ function resolveKey(mode, key, ctx) {
22915
23078
  function resolveMain(key, ctx) {
22916
23079
  const { input } = key;
22917
23080
  const inMain = ctx.focusedColumn === "main";
22918
- if (key.ctrl && input === "z") return { type: "undo" };
22919
23081
  if (input === "q" || key.escape) {
22920
23082
  if (key.escape && ctx.jumpFilterActive) return { type: "clear-jump-filter" };
22921
23083
  if (key.escape && ctx.searchActive) return { type: "clear-search" };
@@ -23214,30 +23376,14 @@ function rejectNeedsConfirmation(graph, name, state) {
23214
23376
  const ancestors = toReject.filter((n) => n !== name);
23215
23377
  return ancestors.length + toDeselect.length >= 2;
23216
23378
  }
23217
- function removeSlotChild(components, edge) {
23218
- return components.map(
23219
- (component) => component.name === edge.parent ? {
23220
- ...component,
23221
- slots: component.slots?.map((slot) => ({
23222
- ...slot,
23223
- allowedComponents: slot.allowedComponents.filter((name) => name !== edge.child)
23224
- }))
23225
- } : component
23226
- );
23227
- }
23228
- function withoutSlotChildren(components, removedEdges) {
23229
- return removedEdges.reduce(removeSlotChild, components);
23230
- }
23231
- function partitionDecisions(components, state, removedEdges) {
23379
+ function partitionDecisions(components, state) {
23232
23380
  const accepted = [];
23233
23381
  const rejected = [];
23234
23382
  for (const c2 of components) {
23235
23383
  if (state.get(c2.name) === "accepted") accepted.push(c2.name);
23236
23384
  else rejected.push(c2.name);
23237
23385
  }
23238
- const rejectedNames = new Set(rejected);
23239
- const excludedSlotEdges = removedEdges.filter((e) => !rejectedNames.has(e.parent) && !rejectedNames.has(e.child));
23240
- return { accepted, rejected, excludedSlotEdges };
23386
+ return { accepted, rejected };
23241
23387
  }
23242
23388
  var init_state = __esm({
23243
23389
  "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/state.ts"() {
@@ -23249,15 +23395,10 @@ var init_state = __esm({
23249
23395
 
23250
23396
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
23251
23397
  import { useEffect as useEffect7, useMemo as useMemo2, useRef as useRef4, useState as useState12 } from "react";
23252
- function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23398
+ function useScopeGate({ components, onConfirm, onQuit }) {
23253
23399
  const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
23254
23400
  const columnPlan = useMemo2(() => computeColumnWidths(totalWidth), [totalWidth]);
23255
23401
  const [decisions, setDecisions] = useState12(/* @__PURE__ */ new Map());
23256
- const [removedEdges, setRemovedEdges] = useState12([]);
23257
- const components = useMemo2(
23258
- () => withoutSlotChildren(loadedComponents, removedEdges),
23259
- [loadedComponents, removedEdges]
23260
- );
23261
23402
  const [nav, setNav] = useState12({ cursor: 0, scrollOffset: 0 });
23262
23403
  const [focusedColumn, setFocusedColumn] = useState12("main");
23263
23404
  const [addedComponentsCursor, setAddedComponentsCursor] = useState12(0);
@@ -23429,14 +23570,6 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23429
23570
  return void 0;
23430
23571
  }
23431
23572
  };
23432
- const focusedNestedEdge = () => {
23433
- const row = visibleRows[safeCursor];
23434
- if (row?.kind !== "group-child" || !row.parentName || row.itemIdx < 0) return void 0;
23435
- const child = groupedItems[row.itemIdx]?.key;
23436
- return child ? { parent: row.parentName, child } : void 0;
23437
- };
23438
- const removeFromParentSlot = (edge) => setRemovedEdges((edges) => [...edges, edge]);
23439
- const undoSlotRemoval = () => setRemovedEdges((edges) => edges.slice(0, -1));
23440
23573
  const jumpCursorTo = (name) => {
23441
23574
  let idx = -1;
23442
23575
  for (let i = 0; i < visibleRows.length; i++) {
@@ -23536,7 +23669,7 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23536
23669
  onQuit();
23537
23670
  return;
23538
23671
  case "confirm":
23539
- onConfirm(partitionDecisions(components, decisions, removedEdges));
23672
+ onConfirm(partitionDecisions(components, decisions));
23540
23673
  return;
23541
23674
  case "close-help":
23542
23675
  setShowHelp(false);
@@ -23589,11 +23722,6 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23589
23722
  return;
23590
23723
  }
23591
23724
  case "reject": {
23592
- const edge = focusedColumn === "main" ? focusedNestedEdge() : void 0;
23593
- if (edge) {
23594
- removeFromParentSlot(edge);
23595
- return;
23596
- }
23597
23725
  const key = focusedColumn === "added-components" ? addedComponents[safeAddedComponentsCursor]?.name : focusedRowKey();
23598
23726
  if (key) requestReject(key);
23599
23727
  return;
@@ -23601,9 +23729,6 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23601
23729
  case "toggle-all":
23602
23730
  decide({ type: "toggle-all" });
23603
23731
  return;
23604
- case "undo":
23605
- undoSlotRemoval();
23606
- return;
23607
23732
  case "accept-unflagged":
23608
23733
  decide({ type: "accept-unflagged" });
23609
23734
  return;
@@ -24113,7 +24238,7 @@ var init_save_decisions = __esm({
24113
24238
  });
24114
24239
 
24115
24240
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
24116
- import { resolve as resolve23 } from "node:path";
24241
+ import { resolve as resolve24 } from "node:path";
24117
24242
  async function runGeneration(input, onProgress, deps = realDeps3) {
24118
24243
  let progress = { components: null, mapTokens: "idle", mapTokensEligible: null };
24119
24244
  const update = (change) => {
@@ -24199,7 +24324,7 @@ async function buildMapTokensOptions(input) {
24199
24324
  if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
24200
24325
  if (mapOverride?.kind === "path") {
24201
24326
  await resolvePromptOverride(mapOverride);
24202
- prompt.skillPathOverride = resolve23(mapOverride.value);
24327
+ prompt.skillPathOverride = resolve24(mapOverride.value);
24203
24328
  }
24204
24329
  if (input.existingEntitiesPath) {
24205
24330
  const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
@@ -24277,7 +24402,7 @@ var init_use_generation = __esm({
24277
24402
  });
24278
24403
 
24279
24404
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
24280
- import { join as join22 } from "node:path";
24405
+ import { join as join23 } from "node:path";
24281
24406
  function buildFlowStart(input) {
24282
24407
  const { extraction, handoff, saved, generatePromptPath } = input;
24283
24408
  const credentials = extraction.credentials ?? {
@@ -24290,7 +24415,7 @@ function buildFlowStart(input) {
24290
24415
  handoff,
24291
24416
  agent: extraction.agent,
24292
24417
  projectPath: extraction.projectPath,
24293
- outDir: extraction.projectPath ? join22(extraction.projectPath, ".contentful") : "",
24418
+ outDir: extraction.projectPath ? join23(extraction.projectPath, ".contentful") : "",
24294
24419
  rawTokensPath: extraction.rawTokensPath,
24295
24420
  credentials: {
24296
24421
  spaceId: credentials.spaceId,
@@ -26518,8 +26643,8 @@ function FieldEditor({
26518
26643
  return /* @__PURE__ */ jsxs22(Box21, { flexDirection: "column", width, borderStyle: "single", borderColor: PALETTE3.warning, children: [
26519
26644
  /* @__PURE__ */ jsx27(Text23, { bold: true, color: PALETTE3.warning, children: "FIELD EDITOR \u2014 no fields" }),
26520
26645
  /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify." }),
26521
- /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "There is nothing to edit here." }),
26522
- /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: active ? "[Esc] go back to the list" : "In the list: [r] reject this component \xB7 [a] accept it" })
26646
+ /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "You can add fields manually below or reject this component." }),
26647
+ /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "Enter to save \xB7 Esc to discard" })
26523
26648
  ] });
26524
26649
  }
26525
26650
  const hasEmptyProperties = props.length === 0 && slots.length === 0;
@@ -26734,7 +26859,7 @@ function FieldEditor({
26734
26859
  children: [
26735
26860
  hasEmptyProperties && /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify. Reject this component or add fields manually." }),
26736
26861
  header,
26737
- /* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && !inSlots && currentProp ? /* @__PURE__ */ jsx27(
26862
+ /* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && currentProp ? /* @__PURE__ */ jsx27(
26738
26863
  PropRow,
26739
26864
  {
26740
26865
  prop: currentProp,
@@ -27738,7 +27863,6 @@ function finalizeReviewSession(extractSessionId, components) {
27738
27863
  db.exec("ROLLBACK");
27739
27864
  throw error;
27740
27865
  }
27741
- removeSlotAllowedComponents(db, extractSessionId, [], toReject);
27742
27866
  } finally {
27743
27867
  db.close();
27744
27868
  }
@@ -29517,50 +29641,33 @@ function GenerateReviewStepView({
29517
29641
  const cycle = cycleRows[cyclesCursor];
29518
29642
  return cycle ? enumerateCycleBreaks(cycle, components) : [];
29519
29643
  }, [cycleRows, cyclesCursor, components]);
29520
- const saveSlotChange = (parentKey, nextEntry, historyLabel) => {
29644
+ const handleBreakEdge = (edge) => {
29645
+ const target = components.find((component) => component.key === edge.fromComponent);
29646
+ const slot = target?.entry.$slots?.[edge.slotName];
29647
+ if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
29648
+ const nextEntry = {
29649
+ ...target.entry,
29650
+ $slots: {
29651
+ ...target.entry.$slots,
29652
+ [edge.slotName]: {
29653
+ ...slot,
29654
+ $allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
29655
+ }
29656
+ }
29657
+ };
29521
29658
  const next = components.map(
29522
- (component) => component.key === parentKey ? { ...component, entry: nextEntry } : component
29659
+ (component) => component.key === target.key ? { ...component, entry: nextEntry } : component
29523
29660
  );
29524
29661
  setComponents(next);
29525
29662
  const db = openPipelineDb();
29526
29663
  try {
29527
- storeCDFComponents(db, extractSessionId, [{ key: parentKey, entry: nextEntry }]);
29664
+ storeCDFComponents(db, extractSessionId, [{ key: target.key, entry: nextEntry }]);
29528
29665
  } finally {
29529
29666
  db.close();
29530
29667
  }
29531
29668
  recomputeCycles(next);
29532
29669
  livePreviewHook.trigger();
29533
- pushHistorySnapshot(next, historyLabel);
29534
- };
29535
- const handleBreakEdge = (edge) => {
29536
- const target = components.find((component) => component.key === edge.fromComponent);
29537
- const slot = target?.entry.$slots?.[edge.slotName];
29538
- if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
29539
- saveSlotChange(
29540
- target.key,
29541
- {
29542
- ...target.entry,
29543
- $slots: {
29544
- ...target.entry.$slots,
29545
- [edge.slotName]: {
29546
- ...slot,
29547
- $allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
29548
- }
29549
- }
29550
- },
29551
- "break-cycle-edge"
29552
- );
29553
- };
29554
- const handleRemoveSlotChild = (parentKey, childKey) => {
29555
- const parent = components.find((component) => component.key === parentKey);
29556
- if (!parent?.entry.$slots) return;
29557
- const slots = Object.fromEntries(
29558
- Object.entries(parent.entry.$slots).map(([slotName, slot]) => [
29559
- slotName,
29560
- Array.isArray(slot.$allowedComponents) ? { ...slot, $allowedComponents: slot.$allowedComponents.filter((value) => value !== childKey) } : slot
29561
- ])
29562
- );
29563
- saveSlotChange(parentKey, { ...parent.entry, $slots: slots }, "remove-slot-child");
29670
+ pushHistorySnapshot(next, "break-cycle-edge");
29564
29671
  };
29565
29672
  const handleRejectComponent = (key) => {
29566
29673
  const rejectCascade2 = computeRejectCascade(key, componentGraph);
@@ -29890,11 +29997,6 @@ function GenerateReviewStepView({
29890
29997
  if (input === "r") {
29891
29998
  const current = components[selectedIdx];
29892
29999
  if (!current) return;
29893
- const row = visibleRowsMemo[cursorRowIdx];
29894
- if (row?.kind === "group-child" && row.parentName) {
29895
- handleRemoveSlotChild(row.parentName, current.key);
29896
- return;
29897
- }
29898
30000
  handleRejectComponent(current.key);
29899
30001
  return;
29900
30002
  }
@@ -30509,7 +30611,7 @@ var init_DoneStep = __esm({
30509
30611
  });
30510
30612
 
30511
30613
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
30512
- import { resolve as resolve24 } from "node:path";
30614
+ import { resolve as resolve25 } from "node:path";
30513
30615
  import { homedir as homedir4 } from "node:os";
30514
30616
  function expandTilde(input) {
30515
30617
  if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
@@ -30523,7 +30625,7 @@ function normalizePath(input) {
30523
30625
  p = p.slice(1, -1);
30524
30626
  }
30525
30627
  p = expandTilde(p);
30526
- return resolve24(p);
30628
+ return resolve25(p);
30527
30629
  }
30528
30630
  var init_path_utils = __esm({
30529
30631
  "packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts"() {
@@ -30550,8 +30652,8 @@ var init_use_blinking_cursor = __esm({
30550
30652
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
30551
30653
  import { useState as useState24 } from "react";
30552
30654
  import { Box as Box37, Text as Text40 } from "ink";
30553
- import { readdirSync as readdirSync3 } from "node:fs";
30554
- import { dirname as dirname15, basename as basename6, join as join23 } from "node:path";
30655
+ import { readdirSync as readdirSync4 } from "node:fs";
30656
+ import { dirname as dirname15, basename as basename6, join as join24 } from "node:path";
30555
30657
  import { jsx as jsx47, jsxs as jsxs38 } from "react/jsx-runtime";
30556
30658
  function autocomplete(partial) {
30557
30659
  if (!partial) return null;
@@ -30560,19 +30662,19 @@ function autocomplete(partial) {
30560
30662
  const base = basename6(normalized);
30561
30663
  let entries;
30562
30664
  try {
30563
- entries = readdirSync3(dir);
30665
+ entries = readdirSync4(dir);
30564
30666
  } catch {
30565
30667
  return null;
30566
30668
  }
30567
30669
  const matches = entries.filter((e) => e.startsWith(base));
30568
30670
  if (matches.length === 0) return null;
30569
- if (matches.length === 1) return join23(dir, matches[0]);
30671
+ if (matches.length === 1) return join24(dir, matches[0]);
30570
30672
  let prefix = matches[0];
30571
30673
  for (const m of matches) {
30572
30674
  while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
30573
30675
  if (!prefix) break;
30574
30676
  }
30575
- return prefix.length > base.length ? join23(dir, prefix) : null;
30677
+ return prefix.length > base.length ? join24(dir, prefix) : null;
30576
30678
  }
30577
30679
  function PathPrompt({
30578
30680
  defaultPath,
@@ -31775,8 +31877,8 @@ var init_run_print_files_helpers = __esm({
31775
31877
  });
31776
31878
 
31777
31879
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
31778
- import { writeFile as writeFile7 } from "node:fs/promises";
31779
- import { join as join24 } from "node:path";
31880
+ import { writeFile as writeFile8 } from "node:fs/promises";
31881
+ import { join as join25 } from "node:path";
31780
31882
  function buildSavedCDF(components, tokens, opts = {}) {
31781
31883
  const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
31782
31884
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
@@ -31788,7 +31890,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
31788
31890
  }
31789
31891
  async function runPrintFiles(input, deps, onPatch) {
31790
31892
  onPatch({ step: "printing" });
31791
- const componentsPath = join24(input.outDir, "components.json");
31893
+ const componentsPath = join25(input.outDir, "components.json");
31792
31894
  try {
31793
31895
  const db = deps.openDb();
31794
31896
  let components = [];
@@ -31872,10 +31974,10 @@ var init_save = __esm({
31872
31974
  realSaveDeps = () => ({
31873
31975
  openDb: openPipelineDb,
31874
31976
  readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
31875
- writeFile: (path5, contents) => writeFile7(path5, contents),
31977
+ writeFile: (path5, contents) => writeFile8(path5, contents),
31876
31978
  appendRun,
31877
31979
  buildSourceFingerprint,
31878
- sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
31980
+ sleep: (ms) => new Promise((resolve26) => setTimeout(resolve26, ms)),
31879
31981
  warn: (message) => process.stderr.write(message)
31880
31982
  });
31881
31983
  }
@@ -31895,9 +31997,9 @@ var init_types9 = __esm({
31895
31997
 
31896
31998
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
31897
31999
  import { appendFileSync, writeFileSync } from "node:fs";
31898
- import { mkdir as mkdir8 } from "node:fs/promises";
32000
+ import { mkdir as mkdir9 } from "node:fs/promises";
31899
32001
  import { tmpdir } from "node:os";
31900
- import { join as join25 } from "node:path";
32002
+ import { join as join26 } from "node:path";
31901
32003
  function appendWizardLog(entry) {
31902
32004
  appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
31903
32005
  }
@@ -31920,7 +32022,7 @@ function realFlowDeps() {
31920
32022
  }
31921
32023
  },
31922
32024
  mkdir: async (path5) => {
31923
- await mkdir8(path5, { recursive: true });
32025
+ await mkdir9(path5, { recursive: true });
31924
32026
  },
31925
32027
  detectSaveConflict,
31926
32028
  buildTimestampedSubdir,
@@ -32171,7 +32273,7 @@ var init_controller = __esm({
32171
32273
  init_push();
32172
32274
  init_save();
32173
32275
  init_types9();
32174
- WIZARD_LOG = join25(tmpdir(), "experiences-import-wizard.log");
32276
+ WIZARD_LOG = join26(tmpdir(), "experiences-import-wizard.log");
32175
32277
  }
32176
32278
  });
32177
32279
 
@@ -32203,183 +32305,13 @@ var init_use_flow = __esm({
32203
32305
  }
32204
32306
  });
32205
32307
 
32206
- // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
32207
- async function readDebugModeSetting() {
32208
- const { debugMode } = await readSettings2();
32209
- return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
32210
- }
32211
- async function writeDebugModeSetting(setting) {
32212
- await updateSettings2({ debugMode: setting });
32213
- }
32214
- var DEFAULT_DEBUG_MODE_SETTING;
32215
- var init_debug_mode_store = __esm({
32216
- "packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
32217
- "use strict";
32218
- init_config();
32219
- DEFAULT_DEBUG_MODE_SETTING = {
32220
- enabled: true
32221
- };
32222
- }
32223
- });
32224
-
32225
- // packages/experience-design-system-cli/src/tui/debug-store.ts
32226
- import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
32227
- import { existsSync as existsSync11, readdirSync as readdirSync4 } from "node:fs";
32228
- import { join as join26 } from "node:path";
32229
- function generateRunId() {
32230
- const now = /* @__PURE__ */ new Date();
32231
- const pad = (n) => String(n).padStart(2, "0");
32232
- return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
32233
- }
32234
- function datePrefix(now = /* @__PURE__ */ new Date()) {
32235
- const pad = (n) => String(n).padStart(2, "0");
32236
- return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
32237
- }
32238
- function slugify(value) {
32239
- return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
32240
- }
32241
- function generateSessionId3() {
32242
- const today = datePrefix();
32243
- const root = debugSessionsDir2();
32244
- const existing = existsSync11(root) ? readdirSync4(root) : [];
32245
- const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
32246
- const maxSeq = existing.reduce((max, entry) => {
32247
- const match2 = seqPattern.exec(entry);
32248
- return match2 ? Math.max(max, Number(match2[1])) : max;
32249
- }, 0);
32250
- return `${today}-session-${maxSeq + 1}`;
32251
- }
32252
- function sessionDebugDir() {
32253
- return join26(debugSessionsDir2(), SESSION_ID);
32254
- }
32255
- function currentDebugSessionDir() {
32256
- return sessionDebugDir();
32257
- }
32258
- async function isDebugModeEnabled() {
32259
- try {
32260
- return (await readDebugModeSetting()).enabled;
32261
- } catch {
32262
- return true;
32263
- }
32264
- }
32265
- function redact(value) {
32266
- const clone = { ...value };
32267
- if ("cma_token" in clone) {
32268
- const raw = clone.cma_token;
32269
- clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
32270
- }
32271
- return clone;
32272
- }
32273
- function startDebugRun({
32274
- flow,
32275
- step,
32276
- menuOption,
32277
- inputs
32278
- }) {
32279
- const runId = generateRunId();
32280
- const startedAt = Date.now();
32281
- const redactedInputs = redact(inputs);
32282
- isDebugModeEnabled().then((enabled) => {
32283
- if (!enabled) return;
32284
- pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
32285
- });
32286
- }
32287
- async function finishDebugRun({
32288
- outputs,
32289
- status,
32290
- exitMethod
32291
- }) {
32292
- const run = pendingRun;
32293
- if (!run) return;
32294
- pendingRun = void 0;
32295
- const durationMs = Date.now() - run.startedAt;
32296
- const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
32297
- const flowSegments = run.flow.split("/");
32298
- const dir = join26(sessionDebugDir(), ...flowSegments);
32299
- await mkdir9(dir, { recursive: true });
32300
- const filename = nextAttemptFilename(dir, run.menuOption);
32301
- await writeFile8(join26(dir, filename), content, { mode: 384 });
32302
- }
32303
- function nextAttemptFilename(dir, menuOption) {
32304
- const today = datePrefix();
32305
- const optionSlug = slugify(menuOption);
32306
- const existing = existsSync11(dir) ? readdirSync4(dir) : [];
32307
- const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
32308
- const maxAttempt = existing.reduce((max, entry) => {
32309
- const match2 = attemptPattern.exec(entry);
32310
- return match2 ? Math.max(max, Number(match2[1])) : max;
32311
- }, 0);
32312
- return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
32313
- }
32314
- function renderMarkdown(run, finish) {
32315
- const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
32316
- const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
32317
- const flowSlug = run.flow.split("/").join("-");
32318
- return `# Debug Log
32319
-
32320
- - Run ID: ${run.runId}
32321
- - Flow: ${flowSlug}
32322
- - Step: ${stepLabel2}
32323
- - Menu option: ${run.menuOption}
32324
- - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
32325
- - CLI version: ${readPackageVersion()}
32326
- - Platform: ${process.platform} / Node ${process.version}
32327
- - Duration on screen: ${finish.durationMs}ms
32328
- - Status: ${finish.status}
32329
- - Exit method: ${finish.exitMethod}
32330
-
32331
- ## Inputs
32332
- \`\`\`json
32333
- ${JSON.stringify(run.inputs, null, 2)}
32334
- \`\`\`
32335
-
32336
- ## Outputs
32337
- \`\`\`json
32338
- ${JSON.stringify(finish.outputs, null, 2)}
32339
- \`\`\`
32340
- `;
32341
- }
32342
- function handleCrash() {
32343
- return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
32344
- }
32345
- var pendingRun, SESSION_ID;
32346
- var init_debug_store = __esm({
32347
- "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
32348
- "use strict";
32349
- init_config();
32350
- init_version();
32351
- init_debug_mode_store();
32352
- SESSION_ID = generateSessionId3();
32353
- void isDebugModeEnabled().then((enabled) => {
32354
- if (!enabled) return void 0;
32355
- return mkdir9(sessionDebugDir(), { recursive: true });
32356
- });
32357
- process.once("uncaughtException", (err) => {
32358
- void handleCrash().finally(() => {
32359
- throw err;
32360
- });
32361
- });
32362
- process.once("unhandledRejection", (reason) => {
32363
- void handleCrash().finally(() => {
32364
- throw reason;
32365
- });
32366
- });
32367
- process.once("SIGINT", () => {
32368
- void handleCrash().finally(() => {
32369
- process.exit(130);
32370
- });
32371
- });
32372
- }
32373
- });
32374
-
32375
32308
  // packages/experience-design-system-cli/src/tui/help/help-info.ts
32376
32309
  async function readHelpInfo() {
32377
32310
  const debugMode = await readDebugModeSetting();
32378
32311
  return {
32379
32312
  storage: [
32380
32313
  { label: "Config folder", value: configRoot2() },
32381
- { label: "Settings file", value: configFilePath2() },
32382
- { label: "Debug logs", value: debugSessionsDir2() }
32314
+ { label: "Settings file", value: configFilePath2() }
32383
32315
  ],
32384
32316
  troubleshooting: [
32385
32317
  { label: "CLI version", value: readPackageVersion() },
@@ -32388,7 +32320,7 @@ async function readHelpInfo() {
32388
32320
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
32389
32321
  {
32390
32322
  label: "This session",
32391
- value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
32323
+ value: !debugMode.enabled ? "no logs written while Debug Mode is off" : currentDebugSessionDir() ?? "not started: set the default project directory in Settings, or start an import"
32392
32324
  }
32393
32325
  ]
32394
32326
  };
@@ -32545,7 +32477,8 @@ async function readCredentials() {
32545
32477
  cmaToken: store.cmaToken || "",
32546
32478
  host: store.host || "",
32547
32479
  defaultComponentDir: store.defaultComponentDir || "",
32548
- defaultTokenFile: store.defaultTokenFile || ""
32480
+ defaultTokenFile: store.defaultTokenFile || "",
32481
+ contentfulBaseDir: store.contentfulBaseDir || ""
32549
32482
  };
32550
32483
  }
32551
32484
  async function writeCredentials(config) {
@@ -32578,7 +32511,8 @@ function debugFields(config) {
32578
32511
  cma_token: config?.cmaToken ?? "",
32579
32512
  host: config?.host ?? "",
32580
32513
  default_component_dir: config?.defaultComponentDir ?? "",
32581
- default_token_file: config?.defaultTokenFile ?? ""
32514
+ default_token_file: config?.defaultTokenFile ?? "",
32515
+ contentful_base_dir: config?.contentfulBaseDir ?? ""
32582
32516
  };
32583
32517
  }
32584
32518
  function ConfigurationScreen({ onDone }) {
@@ -32616,6 +32550,7 @@ function ConfigurationScreen({ onDone }) {
32616
32550
  setNotice(null);
32617
32551
  writeCredentials(config).then(() => {
32618
32552
  setLastSaved(config);
32553
+ if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
32619
32554
  setNotice({ kind: "success", text: "Configuration saved" });
32620
32555
  setStage("form");
32621
32556
  }).catch((err) => {
@@ -32738,7 +32673,8 @@ var init_ContentfulConfigScreen = __esm({
32738
32673
  "cmaToken",
32739
32674
  "host",
32740
32675
  "defaultComponentDir",
32741
- "defaultTokenFile"
32676
+ "defaultTokenFile",
32677
+ "contentfulBaseDir"
32742
32678
  ];
32743
32679
  FIELD_LABELS = {
32744
32680
  spaceId: "Space ID",
@@ -32746,7 +32682,8 @@ var init_ContentfulConfigScreen = __esm({
32746
32682
  cmaToken: "CMA Token",
32747
32683
  host: "API Host (optional)",
32748
32684
  defaultComponentDir: "Default component directory (optional)",
32749
- defaultTokenFile: "Default token file (optional)"
32685
+ defaultTokenFile: "Default token file (optional)",
32686
+ contentfulBaseDir: "Default project directory, where .contentful goes (optional)"
32750
32687
  };
32751
32688
  }
32752
32689
  });
@@ -33417,14 +33354,14 @@ function runDevWatch(args) {
33417
33354
  process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
33418
33355
  return Promise.resolve(1);
33419
33356
  }
33420
- return new Promise((resolve25) => {
33357
+ return new Promise((resolve26) => {
33421
33358
  const child = spawn2(process.execPath, [script, ...args], { stdio: "inherit" });
33422
33359
  process.on("SIGINT", () => void 0);
33423
- child.on("exit", (code) => resolve25(code ?? 0));
33360
+ child.on("exit", (code) => resolve26(code ?? 0));
33424
33361
  child.on("error", (err) => {
33425
33362
  process.stderr.write(`${err.message}
33426
33363
  `);
33427
- resolve25(1);
33364
+ resolve26(1);
33428
33365
  });
33429
33366
  });
33430
33367
  }