@contentful/experience-design-system-cli 2.37.1-dev-build-ced30421.0 → 2.37.1-dev-build-4ce44f69.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,203 @@ 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
+ currentSessionDir: () => currentSessionDir,
20831
+ finishDebugRun: () => finishDebugRun,
20832
+ startDebugRun: () => startDebugRun,
20833
+ startDebugSessionIn: () => startDebugSessionIn
20834
+ });
20835
+ import { mkdir as mkdir8, writeFile as writeFile7 } from "node:fs/promises";
20836
+ import { existsSync as existsSync11, readdirSync as readdirSync3 } from "node:fs";
20837
+ import { join as join22, resolve as resolve23 } from "node:path";
20838
+ function generateRunId() {
20839
+ const now = /* @__PURE__ */ new Date();
20840
+ const pad = (n) => String(n).padStart(2, "0");
20841
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
20842
+ }
20843
+ function datePrefix(now = /* @__PURE__ */ new Date()) {
20844
+ const pad = (n) => String(n).padStart(2, "0");
20845
+ return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
20846
+ }
20847
+ function slugify(value) {
20848
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
20849
+ }
20850
+ async function readBaseDir() {
20851
+ try {
20852
+ const dir = (await readSettings2())["contentfulBaseDir"];
20853
+ return typeof dir === "string" && dir !== "" ? resolve23(dir) : void 0;
20854
+ } catch {
20855
+ return void 0;
20856
+ }
20857
+ }
20858
+ function nextSessionId(contentfulDir) {
20859
+ const today = datePrefix();
20860
+ const existing = existsSync11(contentfulDir) ? readdirSync3(contentfulDir) : [];
20861
+ const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
20862
+ const maxSeq = existing.reduce((max, entry) => {
20863
+ const match2 = seqPattern.exec(entry);
20864
+ return match2 ? Math.max(max, Number(match2[1])) : max;
20865
+ }, 0);
20866
+ return `${today}-session-${maxSeq + 1}`;
20867
+ }
20868
+ function startSession(base, { replace }) {
20869
+ const contentfulDir = join22(base, ".contentful");
20870
+ if (replace || !sessionDir) sessionDir = join22(contentfulDir, nextSessionId(contentfulDir));
20871
+ return sessionDir;
20872
+ }
20873
+ function currentDebugSessionDir() {
20874
+ return sessionDir && join22(sessionDir, "debug");
20875
+ }
20876
+ function currentSessionDir() {
20877
+ return sessionDir;
20878
+ }
20879
+ async function startDebugSessionIn(base, { replace = false } = {}) {
20880
+ try {
20881
+ if (!await isDebugModeEnabled()) return;
20882
+ await mkdir8(join22(startSession(resolve23(base), { replace }), "debug"), { recursive: true });
20883
+ } catch {
20884
+ }
20885
+ }
20886
+ async function isDebugModeEnabled() {
20887
+ try {
20888
+ return (await readDebugModeSetting()).enabled;
20889
+ } catch {
20890
+ return true;
20891
+ }
20892
+ }
20893
+ function redact(value) {
20894
+ const clone = { ...value };
20895
+ if ("cma_token" in clone) {
20896
+ const raw = clone.cma_token;
20897
+ clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
20898
+ }
20899
+ return clone;
20900
+ }
20901
+ function startDebugRun({
20902
+ flow,
20903
+ step,
20904
+ menuOption,
20905
+ inputs
20906
+ }) {
20907
+ const runId = generateRunId();
20908
+ const startedAt = Date.now();
20909
+ const redactedInputs = redact(inputs);
20910
+ isDebugModeEnabled().then((enabled) => {
20911
+ if (!enabled) return;
20912
+ pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
20913
+ });
20914
+ }
20915
+ async function finishDebugRun({
20916
+ outputs,
20917
+ status,
20918
+ exitMethod
20919
+ }) {
20920
+ const run = pendingRun;
20921
+ if (!run) return;
20922
+ pendingRun = void 0;
20923
+ const durationMs = Date.now() - run.startedAt;
20924
+ const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
20925
+ const root = currentDebugSessionDir();
20926
+ if (!root) return;
20927
+ const flowSegments = run.flow.split("/");
20928
+ const dir = join22(root, ...flowSegments);
20929
+ await mkdir8(dir, { recursive: true });
20930
+ const filename = nextAttemptFilename(dir, run.menuOption);
20931
+ await writeFile7(join22(dir, filename), content, { mode: 384 });
20932
+ }
20933
+ function nextAttemptFilename(dir, menuOption) {
20934
+ const today = datePrefix();
20935
+ const optionSlug = slugify(menuOption);
20936
+ const existing = existsSync11(dir) ? readdirSync3(dir) : [];
20937
+ const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
20938
+ const maxAttempt = existing.reduce((max, entry) => {
20939
+ const match2 = attemptPattern.exec(entry);
20940
+ return match2 ? Math.max(max, Number(match2[1])) : max;
20941
+ }, 0);
20942
+ return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
20943
+ }
20944
+ function renderMarkdown(run, finish) {
20945
+ const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
20946
+ const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
20947
+ const flowSlug = run.flow.split("/").join("-");
20948
+ return `# Debug Log
20949
+
20950
+ - Run ID: ${run.runId}
20951
+ - Flow: ${flowSlug}
20952
+ - Step: ${stepLabel2}
20953
+ - Menu option: ${run.menuOption}
20954
+ - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
20955
+ - CLI version: ${readPackageVersion()}
20956
+ - Platform: ${process.platform} / Node ${process.version}
20957
+ - Duration on screen: ${finish.durationMs}ms
20958
+ - Status: ${finish.status}
20959
+ - Exit method: ${finish.exitMethod}
20960
+
20961
+ ## Inputs
20962
+ \`\`\`json
20963
+ ${JSON.stringify(run.inputs, null, 2)}
20964
+ \`\`\`
20965
+
20966
+ ## Outputs
20967
+ \`\`\`json
20968
+ ${JSON.stringify(finish.outputs, null, 2)}
20969
+ \`\`\`
20970
+ `;
20971
+ }
20972
+ function handleCrash() {
20973
+ return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
20974
+ }
20975
+ var pendingRun, sessionDir;
20976
+ var init_debug_store = __esm({
20977
+ "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
20978
+ "use strict";
20979
+ init_config();
20980
+ init_version();
20981
+ init_debug_mode_store();
20982
+ void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
20983
+ if (!enabled || !base) return void 0;
20984
+ return mkdir8(join22(startSession(base, { replace: false }), "debug"), { recursive: true });
20985
+ });
20986
+ process.once("uncaughtException", (err) => {
20987
+ void handleCrash().finally(() => {
20988
+ throw err;
20989
+ });
20990
+ });
20991
+ process.once("unhandledRejection", (reason) => {
20992
+ void handleCrash().finally(() => {
20993
+ throw reason;
20994
+ });
20995
+ });
20996
+ process.once("SIGINT", () => {
20997
+ void handleCrash().finally(() => {
20998
+ process.exit(130);
20999
+ });
21000
+ });
21001
+ }
21002
+ });
21003
+
20830
21004
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
20831
21005
  import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
20832
21006
  function useExtraction(input) {
@@ -20846,6 +21020,7 @@ function useExtraction(input) {
20846
21020
  reuseTokens: input.tokenStrategy === "reuse"
20847
21021
  })
20848
21022
  });
21023
+ void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((store) => store.startDebugSessionIn(input.projectPath));
20849
21024
  void runExtraction(input, (progress) => {
20850
21025
  if (current.current === input) setState({ status: "running", progress });
20851
21026
  }).then((result) => {
@@ -21803,7 +21978,7 @@ function buildVisibleRows(props) {
21803
21978
  if (visited.has(target)) continue;
21804
21979
  visited.add(target);
21805
21980
  const isCycleMember = cycleParticipants.has(target);
21806
- out.push({ name: target, depth: cur.depth + 1, isCycleMember, parent: cur.name });
21981
+ out.push({ name: target, depth: cur.depth + 1, isCycleMember });
21807
21982
  queue.push({ name: target, depth: cur.depth + 1 });
21808
21983
  }
21809
21984
  }
@@ -21850,8 +22025,7 @@ function buildVisibleRows(props) {
21850
22025
  sharedSuffix,
21851
22026
  cycleChild: child.isCycleMember || void 0,
21852
22027
  itemIdx: childRec?.idx ?? -1,
21853
- rootName: key,
21854
- parentName: child.parent
22028
+ rootName: key
21855
22029
  });
21856
22030
  });
21857
22031
  }
@@ -21934,19 +22108,13 @@ function buildVisibleRows(props) {
21934
22108
  injectedChildren.push({
21935
22109
  name: target,
21936
22110
  depth: parentDepth + 1,
21937
- isCycleChild: true,
21938
- parent: parentName
22111
+ isCycleChild: true
21939
22112
  });
21940
22113
  }
21941
22114
  };
21942
22115
  emitCycleChildrenOf(root, 0);
21943
22116
  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
- });
22117
+ injectedChildren.push({ name: c2.name, depth: c2.depth, isCycleChild: false });
21950
22118
  emitCycleChildrenOf(c2.name, c2.depth);
21951
22119
  }
21952
22120
  const isLastAtDepth = (idx) => {
@@ -21980,8 +22148,7 @@ function buildVisibleRows(props) {
21980
22148
  sharedSuffix,
21981
22149
  cycleChild: child.isCycleChild || void 0,
21982
22150
  itemIdx: childRec?.idx ?? -1,
21983
- rootName: root,
21984
- parentName: child.parent
22151
+ rootName: root
21985
22152
  });
21986
22153
  });
21987
22154
  }
@@ -22134,7 +22301,7 @@ function GroupedSidebar(props) {
22134
22301
  const rs = itemName ? renderStatusByKey?.get(itemName) : void 0;
22135
22302
  const badge = itemName ? previewBadge(previewAnnotationByKey?.get(itemName)) : null;
22136
22303
  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");
22304
+ 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
22305
  const selState = supportsSelectionGlyph ? selectionStateByKey.get(itemName) ?? "undecided" : void 0;
22139
22306
  const isCycleRow = row.kind === "cycle";
22140
22307
  const selStyle = selectionGlyphStyleFor(selState, isCycleRow);
@@ -22164,7 +22331,7 @@ function GroupedSidebar(props) {
22164
22331
  color: isSelected ? PALETTE2.info : labelStyle.dim ? PALETTE2.muted : labelStyle.color,
22165
22332
  bold: isSelected || labelStyle.bold,
22166
22333
  inverse: false,
22167
- underline: isSelected && focused,
22334
+ underline: isSelected && !focused,
22168
22335
  wrap: wrapLabels ? "wrap" : "truncate",
22169
22336
  children: [
22170
22337
  " ",
@@ -22915,7 +23082,6 @@ function resolveKey(mode, key, ctx) {
22915
23082
  function resolveMain(key, ctx) {
22916
23083
  const { input } = key;
22917
23084
  const inMain = ctx.focusedColumn === "main";
22918
- if (key.ctrl && input === "z") return { type: "undo" };
22919
23085
  if (input === "q" || key.escape) {
22920
23086
  if (key.escape && ctx.jumpFilterActive) return { type: "clear-jump-filter" };
22921
23087
  if (key.escape && ctx.searchActive) return { type: "clear-search" };
@@ -23214,30 +23380,14 @@ function rejectNeedsConfirmation(graph, name, state) {
23214
23380
  const ancestors = toReject.filter((n) => n !== name);
23215
23381
  return ancestors.length + toDeselect.length >= 2;
23216
23382
  }
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) {
23383
+ function partitionDecisions(components, state) {
23232
23384
  const accepted = [];
23233
23385
  const rejected = [];
23234
23386
  for (const c2 of components) {
23235
23387
  if (state.get(c2.name) === "accepted") accepted.push(c2.name);
23236
23388
  else rejected.push(c2.name);
23237
23389
  }
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 };
23390
+ return { accepted, rejected };
23241
23391
  }
23242
23392
  var init_state = __esm({
23243
23393
  "packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/state.ts"() {
@@ -23249,15 +23399,10 @@ var init_state = __esm({
23249
23399
 
23250
23400
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
23251
23401
  import { useEffect as useEffect7, useMemo as useMemo2, useRef as useRef4, useState as useState12 } from "react";
23252
- function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23402
+ function useScopeGate({ components, onConfirm, onQuit }) {
23253
23403
  const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
23254
23404
  const columnPlan = useMemo2(() => computeColumnWidths(totalWidth), [totalWidth]);
23255
23405
  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
23406
  const [nav, setNav] = useState12({ cursor: 0, scrollOffset: 0 });
23262
23407
  const [focusedColumn, setFocusedColumn] = useState12("main");
23263
23408
  const [addedComponentsCursor, setAddedComponentsCursor] = useState12(0);
@@ -23429,14 +23574,6 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23429
23574
  return void 0;
23430
23575
  }
23431
23576
  };
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
23577
  const jumpCursorTo = (name) => {
23441
23578
  let idx = -1;
23442
23579
  for (let i = 0; i < visibleRows.length; i++) {
@@ -23536,7 +23673,7 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23536
23673
  onQuit();
23537
23674
  return;
23538
23675
  case "confirm":
23539
- onConfirm(partitionDecisions(components, decisions, removedEdges));
23676
+ onConfirm(partitionDecisions(components, decisions));
23540
23677
  return;
23541
23678
  case "close-help":
23542
23679
  setShowHelp(false);
@@ -23589,11 +23726,6 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23589
23726
  return;
23590
23727
  }
23591
23728
  case "reject": {
23592
- const edge = focusedColumn === "main" ? focusedNestedEdge() : void 0;
23593
- if (edge) {
23594
- removeFromParentSlot(edge);
23595
- return;
23596
- }
23597
23729
  const key = focusedColumn === "added-components" ? addedComponents[safeAddedComponentsCursor]?.name : focusedRowKey();
23598
23730
  if (key) requestReject(key);
23599
23731
  return;
@@ -23601,9 +23733,6 @@ function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
23601
23733
  case "toggle-all":
23602
23734
  decide({ type: "toggle-all" });
23603
23735
  return;
23604
- case "undo":
23605
- undoSlotRemoval();
23606
- return;
23607
23736
  case "accept-unflagged":
23608
23737
  decide({ type: "accept-unflagged" });
23609
23738
  return;
@@ -24113,7 +24242,7 @@ var init_save_decisions = __esm({
24113
24242
  });
24114
24243
 
24115
24244
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
24116
- import { resolve as resolve23 } from "node:path";
24245
+ import { resolve as resolve24 } from "node:path";
24117
24246
  async function runGeneration(input, onProgress, deps = realDeps3) {
24118
24247
  let progress = { components: null, mapTokens: "idle", mapTokensEligible: null };
24119
24248
  const update = (change) => {
@@ -24199,7 +24328,7 @@ async function buildMapTokensOptions(input) {
24199
24328
  if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
24200
24329
  if (mapOverride?.kind === "path") {
24201
24330
  await resolvePromptOverride(mapOverride);
24202
- prompt.skillPathOverride = resolve23(mapOverride.value);
24331
+ prompt.skillPathOverride = resolve24(mapOverride.value);
24203
24332
  }
24204
24333
  if (input.existingEntitiesPath) {
24205
24334
  const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
@@ -24277,7 +24406,7 @@ var init_use_generation = __esm({
24277
24406
  });
24278
24407
 
24279
24408
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
24280
- import { join as join22 } from "node:path";
24409
+ import { join as join23 } from "node:path";
24281
24410
  function buildFlowStart(input) {
24282
24411
  const { extraction, handoff, saved, generatePromptPath } = input;
24283
24412
  const credentials = extraction.credentials ?? {
@@ -24290,7 +24419,7 @@ function buildFlowStart(input) {
24290
24419
  handoff,
24291
24420
  agent: extraction.agent,
24292
24421
  projectPath: extraction.projectPath,
24293
- outDir: extraction.projectPath ? join22(extraction.projectPath, ".contentful") : "",
24422
+ outDir: extraction.projectPath ? join23(extraction.projectPath, ".contentful") : "",
24294
24423
  rawTokensPath: extraction.rawTokensPath,
24295
24424
  credentials: {
24296
24425
  spaceId: credentials.spaceId,
@@ -26518,8 +26647,8 @@ function FieldEditor({
26518
26647
  return /* @__PURE__ */ jsxs22(Box21, { flexDirection: "column", width, borderStyle: "single", borderColor: PALETTE3.warning, children: [
26519
26648
  /* @__PURE__ */ jsx27(Text23, { bold: true, color: PALETTE3.warning, children: "FIELD EDITOR \u2014 no fields" }),
26520
26649
  /* @__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" })
26650
+ /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "You can add fields manually below or reject this component." }),
26651
+ /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "Enter to save \xB7 Esc to discard" })
26523
26652
  ] });
26524
26653
  }
26525
26654
  const hasEmptyProperties = props.length === 0 && slots.length === 0;
@@ -26734,7 +26863,7 @@ function FieldEditor({
26734
26863
  children: [
26735
26864
  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
26865
  header,
26737
- /* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && !inSlots && currentProp ? /* @__PURE__ */ jsx27(
26866
+ /* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && currentProp ? /* @__PURE__ */ jsx27(
26738
26867
  PropRow,
26739
26868
  {
26740
26869
  prop: currentProp,
@@ -27738,7 +27867,6 @@ function finalizeReviewSession(extractSessionId, components) {
27738
27867
  db.exec("ROLLBACK");
27739
27868
  throw error;
27740
27869
  }
27741
- removeSlotAllowedComponents(db, extractSessionId, [], toReject);
27742
27870
  } finally {
27743
27871
  db.close();
27744
27872
  }
@@ -29517,50 +29645,33 @@ function GenerateReviewStepView({
29517
29645
  const cycle = cycleRows[cyclesCursor];
29518
29646
  return cycle ? enumerateCycleBreaks(cycle, components) : [];
29519
29647
  }, [cycleRows, cyclesCursor, components]);
29520
- const saveSlotChange = (parentKey, nextEntry, historyLabel) => {
29648
+ const handleBreakEdge = (edge) => {
29649
+ const target = components.find((component) => component.key === edge.fromComponent);
29650
+ const slot = target?.entry.$slots?.[edge.slotName];
29651
+ if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
29652
+ const nextEntry = {
29653
+ ...target.entry,
29654
+ $slots: {
29655
+ ...target.entry.$slots,
29656
+ [edge.slotName]: {
29657
+ ...slot,
29658
+ $allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
29659
+ }
29660
+ }
29661
+ };
29521
29662
  const next = components.map(
29522
- (component) => component.key === parentKey ? { ...component, entry: nextEntry } : component
29663
+ (component) => component.key === target.key ? { ...component, entry: nextEntry } : component
29523
29664
  );
29524
29665
  setComponents(next);
29525
29666
  const db = openPipelineDb();
29526
29667
  try {
29527
- storeCDFComponents(db, extractSessionId, [{ key: parentKey, entry: nextEntry }]);
29668
+ storeCDFComponents(db, extractSessionId, [{ key: target.key, entry: nextEntry }]);
29528
29669
  } finally {
29529
29670
  db.close();
29530
29671
  }
29531
29672
  recomputeCycles(next);
29532
29673
  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");
29674
+ pushHistorySnapshot(next, "break-cycle-edge");
29564
29675
  };
29565
29676
  const handleRejectComponent = (key) => {
29566
29677
  const rejectCascade2 = computeRejectCascade(key, componentGraph);
@@ -29890,11 +30001,6 @@ function GenerateReviewStepView({
29890
30001
  if (input === "r") {
29891
30002
  const current = components[selectedIdx];
29892
30003
  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
30004
  handleRejectComponent(current.key);
29899
30005
  return;
29900
30006
  }
@@ -30509,7 +30615,7 @@ var init_DoneStep = __esm({
30509
30615
  });
30510
30616
 
30511
30617
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
30512
- import { resolve as resolve24 } from "node:path";
30618
+ import { resolve as resolve25 } from "node:path";
30513
30619
  import { homedir as homedir4 } from "node:os";
30514
30620
  function expandTilde(input) {
30515
30621
  if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
@@ -30523,7 +30629,7 @@ function normalizePath(input) {
30523
30629
  p = p.slice(1, -1);
30524
30630
  }
30525
30631
  p = expandTilde(p);
30526
- return resolve24(p);
30632
+ return resolve25(p);
30527
30633
  }
30528
30634
  var init_path_utils = __esm({
30529
30635
  "packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts"() {
@@ -30550,8 +30656,8 @@ var init_use_blinking_cursor = __esm({
30550
30656
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
30551
30657
  import { useState as useState24 } from "react";
30552
30658
  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";
30659
+ import { readdirSync as readdirSync4 } from "node:fs";
30660
+ import { dirname as dirname15, basename as basename6, join as join24 } from "node:path";
30555
30661
  import { jsx as jsx47, jsxs as jsxs38 } from "react/jsx-runtime";
30556
30662
  function autocomplete(partial) {
30557
30663
  if (!partial) return null;
@@ -30560,19 +30666,19 @@ function autocomplete(partial) {
30560
30666
  const base = basename6(normalized);
30561
30667
  let entries;
30562
30668
  try {
30563
- entries = readdirSync3(dir);
30669
+ entries = readdirSync4(dir);
30564
30670
  } catch {
30565
30671
  return null;
30566
30672
  }
30567
30673
  const matches = entries.filter((e) => e.startsWith(base));
30568
30674
  if (matches.length === 0) return null;
30569
- if (matches.length === 1) return join23(dir, matches[0]);
30675
+ if (matches.length === 1) return join24(dir, matches[0]);
30570
30676
  let prefix = matches[0];
30571
30677
  for (const m of matches) {
30572
30678
  while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
30573
30679
  if (!prefix) break;
30574
30680
  }
30575
- return prefix.length > base.length ? join23(dir, prefix) : null;
30681
+ return prefix.length > base.length ? join24(dir, prefix) : null;
30576
30682
  }
30577
30683
  function PathPrompt({
30578
30684
  defaultPath,
@@ -31775,8 +31881,8 @@ var init_run_print_files_helpers = __esm({
31775
31881
  });
31776
31882
 
31777
31883
  // 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";
31884
+ import { writeFile as writeFile8 } from "node:fs/promises";
31885
+ import { join as join25 } from "node:path";
31780
31886
  function buildSavedCDF(components, tokens, opts = {}) {
31781
31887
  const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
31782
31888
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
@@ -31788,7 +31894,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
31788
31894
  }
31789
31895
  async function runPrintFiles(input, deps, onPatch) {
31790
31896
  onPatch({ step: "printing" });
31791
- const componentsPath = join24(input.outDir, "components.json");
31897
+ const componentsPath = join25(input.outDir, "components.json");
31792
31898
  try {
31793
31899
  const db = deps.openDb();
31794
31900
  let components = [];
@@ -31872,10 +31978,10 @@ var init_save = __esm({
31872
31978
  realSaveDeps = () => ({
31873
31979
  openDb: openPipelineDb,
31874
31980
  readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
31875
- writeFile: (path5, contents) => writeFile7(path5, contents),
31981
+ writeFile: (path5, contents) => writeFile8(path5, contents),
31876
31982
  appendRun,
31877
31983
  buildSourceFingerprint,
31878
- sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
31984
+ sleep: (ms) => new Promise((resolve26) => setTimeout(resolve26, ms)),
31879
31985
  warn: (message) => process.stderr.write(message)
31880
31986
  });
31881
31987
  }
@@ -31895,9 +32001,9 @@ var init_types9 = __esm({
31895
32001
 
31896
32002
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
31897
32003
  import { appendFileSync, writeFileSync } from "node:fs";
31898
- import { mkdir as mkdir8 } from "node:fs/promises";
32004
+ import { mkdir as mkdir9 } from "node:fs/promises";
31899
32005
  import { tmpdir } from "node:os";
31900
- import { join as join25 } from "node:path";
32006
+ import { join as join26 } from "node:path";
31901
32007
  function appendWizardLog(entry) {
31902
32008
  appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
31903
32009
  }
@@ -31905,6 +32011,9 @@ function startWizardLog() {
31905
32011
  writeFileSync(WIZARD_LOG, `--- experiences import session ${(/* @__PURE__ */ new Date()).toISOString()} ---
31906
32012
  `);
31907
32013
  }
32014
+ async function realSessionDir() {
32015
+ return (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).currentSessionDir();
32016
+ }
31908
32017
  function realFlowDeps() {
31909
32018
  const log = (entry) => appendWizardLog(entry);
31910
32019
  return {
@@ -31920,13 +32029,14 @@ function realFlowDeps() {
31920
32029
  }
31921
32030
  },
31922
32031
  mkdir: async (path5) => {
31923
- await mkdir8(path5, { recursive: true });
32032
+ await mkdir9(path5, { recursive: true });
31924
32033
  },
31925
32034
  detectSaveConflict,
31926
32035
  buildTimestampedSubdir,
31927
32036
  rejectComponentsByName,
31928
32037
  log,
31929
- stderr: (text) => process.stderr.write(text)
32038
+ stderr: (text) => process.stderr.write(text),
32039
+ sessionDir: realSessionDir
31930
32040
  };
31931
32041
  }
31932
32042
  function initialFlowState(start) {
@@ -32067,6 +32177,9 @@ function createFlowController(start, deps) {
32067
32177
  const startSave = (opts, patch = {}) => {
32068
32178
  pendingSave = opts;
32069
32179
  update({ ...patch, step: "path-prompt" });
32180
+ void deps.sessionDir?.().then((session) => {
32181
+ if (session && state.step === "path-prompt") update({ outDir: join26(session, "dsi-import") });
32182
+ });
32070
32183
  };
32071
32184
  const proceedToWrite = async (path5) => {
32072
32185
  update({ outDir: path5 });
@@ -32171,7 +32284,7 @@ var init_controller = __esm({
32171
32284
  init_push();
32172
32285
  init_save();
32173
32286
  init_types9();
32174
- WIZARD_LOG = join25(tmpdir(), "experiences-import-wizard.log");
32287
+ WIZARD_LOG = join26(tmpdir(), "experiences-import-wizard.log");
32175
32288
  }
32176
32289
  });
32177
32290
 
@@ -32203,183 +32316,13 @@ var init_use_flow = __esm({
32203
32316
  }
32204
32317
  });
32205
32318
 
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
32319
  // packages/experience-design-system-cli/src/tui/help/help-info.ts
32376
32320
  async function readHelpInfo() {
32377
32321
  const debugMode = await readDebugModeSetting();
32378
32322
  return {
32379
32323
  storage: [
32380
32324
  { label: "Config folder", value: configRoot2() },
32381
- { label: "Settings file", value: configFilePath2() },
32382
- { label: "Debug logs", value: debugSessionsDir2() }
32325
+ { label: "Settings file", value: configFilePath2() }
32383
32326
  ],
32384
32327
  troubleshooting: [
32385
32328
  { label: "CLI version", value: readPackageVersion() },
@@ -32388,7 +32331,7 @@ async function readHelpInfo() {
32388
32331
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
32389
32332
  {
32390
32333
  label: "This session",
32391
- value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
32334
+ 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"
32392
32335
  }
32393
32336
  ]
32394
32337
  };
@@ -32545,7 +32488,8 @@ async function readCredentials() {
32545
32488
  cmaToken: store.cmaToken || "",
32546
32489
  host: store.host || "",
32547
32490
  defaultComponentDir: store.defaultComponentDir || "",
32548
- defaultTokenFile: store.defaultTokenFile || ""
32491
+ defaultTokenFile: store.defaultTokenFile || "",
32492
+ contentfulBaseDir: store.contentfulBaseDir || ""
32549
32493
  };
32550
32494
  }
32551
32495
  async function writeCredentials(config) {
@@ -32578,7 +32522,8 @@ function debugFields(config) {
32578
32522
  cma_token: config?.cmaToken ?? "",
32579
32523
  host: config?.host ?? "",
32580
32524
  default_component_dir: config?.defaultComponentDir ?? "",
32581
- default_token_file: config?.defaultTokenFile ?? ""
32525
+ default_token_file: config?.defaultTokenFile ?? "",
32526
+ contentful_base_dir: config?.contentfulBaseDir ?? ""
32582
32527
  };
32583
32528
  }
32584
32529
  function ConfigurationScreen({ onDone }) {
@@ -32616,6 +32561,7 @@ function ConfigurationScreen({ onDone }) {
32616
32561
  setNotice(null);
32617
32562
  writeCredentials(config).then(() => {
32618
32563
  setLastSaved(config);
32564
+ if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
32619
32565
  setNotice({ kind: "success", text: "Configuration saved" });
32620
32566
  setStage("form");
32621
32567
  }).catch((err) => {
@@ -32681,10 +32627,7 @@ function ConfigurationScreen({ onDone }) {
32681
32627
  const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
32682
32628
  return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
32683
32629
  /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
32684
- /* @__PURE__ */ jsxs45(Text46, { bold: isActive, children: [
32685
- FIELD_LABELS[field],
32686
- ":"
32687
- ] }),
32630
+ /* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
32688
32631
  isActive && editing ? /* @__PURE__ */ jsx55(
32689
32632
  TextInput4,
32690
32633
  {
@@ -32693,7 +32636,8 @@ function ConfigurationScreen({ onDone }) {
32693
32636
  onSubmit: () => setEditing(false),
32694
32637
  mask: field === "cmaToken" ? "\u2022" : void 0
32695
32638
  }
32696
- ) : /* @__PURE__ */ jsx55(Text46, { children: display || /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" }) })
32639
+ ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
32640
+ FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
32697
32641
  ] }, field);
32698
32642
  }) }),
32699
32643
  notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
@@ -32724,7 +32668,7 @@ function ConfigurationScreen({ onDone }) {
32724
32668
  )
32725
32669
  ] });
32726
32670
  }
32727
- var FIELD_ORDER, FIELD_LABELS;
32671
+ var FIELD_ORDER, FIELD_LABELS, FIELD_HINTS, LABEL_WIDTH;
32728
32672
  var init_ContentfulConfigScreen = __esm({
32729
32673
  "packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx"() {
32730
32674
  "use strict";
@@ -32738,16 +32682,22 @@ var init_ContentfulConfigScreen = __esm({
32738
32682
  "cmaToken",
32739
32683
  "host",
32740
32684
  "defaultComponentDir",
32741
- "defaultTokenFile"
32685
+ "defaultTokenFile",
32686
+ "contentfulBaseDir"
32742
32687
  ];
32743
32688
  FIELD_LABELS = {
32744
32689
  spaceId: "Space ID",
32745
32690
  environmentId: "Environment ID",
32746
32691
  cmaToken: "CMA Token",
32747
- host: "API Host (optional)",
32748
- defaultComponentDir: "Default component directory (optional)",
32749
- defaultTokenFile: "Default token file (optional)"
32692
+ host: "API Host",
32693
+ defaultComponentDir: "Default component directory",
32694
+ defaultTokenFile: "Default token file",
32695
+ contentfulBaseDir: "Root Project Directory"
32696
+ };
32697
+ FIELD_HINTS = {
32698
+ contentfulBaseDir: "(where .contentful goes)"
32750
32699
  };
32700
+ LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
32751
32701
  }
32752
32702
  });
32753
32703
 
@@ -33417,14 +33367,14 @@ function runDevWatch(args) {
33417
33367
  process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
33418
33368
  return Promise.resolve(1);
33419
33369
  }
33420
- return new Promise((resolve25) => {
33370
+ return new Promise((resolve26) => {
33421
33371
  const child = spawn2(process.execPath, [script, ...args], { stdio: "inherit" });
33422
33372
  process.on("SIGINT", () => void 0);
33423
- child.on("exit", (code) => resolve25(code ?? 0));
33373
+ child.on("exit", (code) => resolve26(code ?? 0));
33424
33374
  child.on("error", (err) => {
33425
33375
  process.stderr.write(`${err.message}
33426
33376
  `);
33427
- resolve25(1);
33377
+ resolve26(1);
33428
33378
  });
33429
33379
  });
33430
33380
  }