@contentful/experience-design-system-cli 2.37.1-dev-build-cffd984a.0 → 2.37.1-dev-build-36f90a5a.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -837,7 +837,7 @@ async function runAgent(options) {
837
837
  promptLen: prompt.length,
838
838
  promptHead: prompt.slice(0, 500)
839
839
  });
840
- return new Promise((resolve27) => {
840
+ return new Promise((resolve26) => {
841
841
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
842
842
  const child = spawn(binary, args, {
843
843
  stdio: ["pipe", "pipe", "pipe"],
@@ -886,7 +886,7 @@ async function runAgent(options) {
886
886
  stderrLen: stderr.length,
887
887
  stderrTail: stderr.slice(-1e3)
888
888
  });
889
- resolve27(result);
889
+ resolve26(result);
890
890
  });
891
891
  });
892
892
  }
@@ -908,7 +908,7 @@ async function checkAgentAuth(agent) {
908
908
  return "not-found";
909
909
  if (agent !== "claude")
910
910
  return "ok";
911
- return new Promise((resolve27) => {
911
+ return new Promise((resolve26) => {
912
912
  const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
913
913
  let stdout = "";
914
914
  let done = false;
@@ -917,7 +917,7 @@ async function checkAgentAuth(agent) {
917
917
  return;
918
918
  done = true;
919
919
  child.kill("SIGTERM");
920
- resolve27("unauthenticated");
920
+ resolve26("unauthenticated");
921
921
  }, 5e3);
922
922
  child.stdout?.on("data", (chunk) => {
923
923
  stdout += chunk.toString();
@@ -928,14 +928,14 @@ async function checkAgentAuth(agent) {
928
928
  done = true;
929
929
  clearTimeout(timer);
930
930
  if (code !== 0) {
931
- resolve27("unauthenticated");
931
+ resolve26("unauthenticated");
932
932
  return;
933
933
  }
934
934
  try {
935
935
  const status = JSON.parse(stdout);
936
- resolve27(status.loggedIn ? "ok" : "unauthenticated");
936
+ resolve26(status.loggedIn ? "ok" : "unauthenticated");
937
937
  } catch {
938
- resolve27("unauthenticated");
938
+ resolve26("unauthenticated");
939
939
  }
940
940
  });
941
941
  });
@@ -945,9 +945,9 @@ async function binaryIsOnPath(binary) {
945
945
  const fs = await import("node:fs/promises");
946
946
  return fs.access(binary).then(() => true, () => false);
947
947
  }
948
- return new Promise((resolve27) => {
948
+ return new Promise((resolve26) => {
949
949
  const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
950
- child.on("close", (code) => resolve27(code === 0));
950
+ child.on("close", (code) => resolve26(code === 0));
951
951
  });
952
952
  }
953
953
  var init_check_agent_auth = __esm({
@@ -2107,12 +2107,11 @@ async function writeSettings2(settings) {
2107
2107
  async function updateSettings2(patch) {
2108
2108
  await writeSettings2({ ...await readSettings2(), ...patch });
2109
2109
  }
2110
- var configFilePath2, debugSessionsDir2;
2110
+ var configFilePath2;
2111
2111
  var init_config = __esm({
2112
2112
  "packages/experience-design-system-types/dist/src/config/index.js"() {
2113
2113
  "use strict";
2114
2114
  configFilePath2 = () => join17(configRoot2(), "config.json");
2115
- debugSessionsDir2 = () => join17(configRoot2(), "debug", "sessions");
2116
2115
  }
2117
2116
  });
2118
2117
 
@@ -2140,10 +2139,10 @@ var debug_store_exports = {};
2140
2139
  __export(debug_store_exports, {
2141
2140
  currentDebugSessionDir: () => currentDebugSessionDir,
2142
2141
  finishDebugRun: () => finishDebugRun,
2143
- setDebugOutDir: () => setDebugOutDir,
2144
- startDebugRun: () => startDebugRun
2142
+ startDebugRun: () => startDebugRun,
2143
+ startDebugSessionIn: () => startDebugSessionIn
2145
2144
  });
2146
- import { cp, mkdir as mkdir8, rename as rename3, rm, writeFile as writeFile7 } from "node:fs/promises";
2145
+ import { mkdir as mkdir8, writeFile as writeFile7 } from "node:fs/promises";
2147
2146
  import { existsSync as existsSync9, readdirSync as readdirSync3 } from "node:fs";
2148
2147
  import { join as join20, resolve as resolve23 } from "node:path";
2149
2148
  function generateRunId() {
@@ -2158,10 +2157,17 @@ function datePrefix(now = /* @__PURE__ */ new Date()) {
2158
2157
  function slugify(value) {
2159
2158
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
2160
2159
  }
2161
- function generateSessionId3() {
2160
+ async function readBaseDir() {
2161
+ try {
2162
+ const dir = (await readSettings2())["contentfulBaseDir"];
2163
+ return typeof dir === "string" && dir !== "" ? resolve23(dir) : void 0;
2164
+ } catch {
2165
+ return void 0;
2166
+ }
2167
+ }
2168
+ function nextSessionId(contentfulDir) {
2162
2169
  const today = datePrefix();
2163
- const root = debugSessionsDir2();
2164
- const existing = existsSync9(root) ? readdirSync3(root) : [];
2170
+ const existing = existsSync9(contentfulDir) ? readdirSync3(contentfulDir) : [];
2165
2171
  const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
2166
2172
  const maxSeq = existing.reduce((max, entry) => {
2167
2173
  const match2 = seqPattern.exec(entry);
@@ -2169,31 +2175,18 @@ function generateSessionId3() {
2169
2175
  }, 0);
2170
2176
  return `${today}-session-${maxSeq + 1}`;
2171
2177
  }
2172
- function sessionDebugDir() {
2173
- return join20(projectSessionsRoot ?? debugSessionsDir2(), SESSION_ID);
2178
+ function startSession(base) {
2179
+ const contentfulDir = join20(base, ".contentful");
2180
+ sessionDir ??= join20(contentfulDir, nextSessionId(contentfulDir));
2181
+ return sessionDir;
2174
2182
  }
2175
2183
  function currentDebugSessionDir() {
2176
- return sessionDebugDir();
2177
- }
2178
- async function setDebugOutDir(outDir) {
2179
- if (!await isDebugModeEnabled()) return;
2180
- const nextRoot = join20(resolve23(outDir), "debug", "sessions");
2181
- const from = sessionDebugDir();
2182
- const to = join20(nextRoot, SESSION_ID);
2183
- if (from === to) return;
2184
+ return sessionDir && join20(sessionDir, "debug");
2185
+ }
2186
+ async function startDebugSessionIn(base) {
2184
2187
  try {
2185
- await mkdir8(nextRoot, { recursive: true });
2186
- if (existsSync9(from)) {
2187
- try {
2188
- await rename3(from, to);
2189
- } catch {
2190
- await cp(from, to, { recursive: true });
2191
- await rm(from, { recursive: true, force: true });
2192
- }
2193
- } else {
2194
- await mkdir8(to, { recursive: true });
2195
- }
2196
- projectSessionsRoot = nextRoot;
2188
+ if (!await isDebugModeEnabled()) return;
2189
+ await mkdir8(join20(startSession(resolve23(base)), "debug"), { recursive: true });
2197
2190
  } catch {
2198
2191
  }
2199
2192
  }
@@ -2236,8 +2229,10 @@ async function finishDebugRun({
2236
2229
  pendingRun = void 0;
2237
2230
  const durationMs = Date.now() - run.startedAt;
2238
2231
  const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
2232
+ const root = currentDebugSessionDir();
2233
+ if (!root) return;
2239
2234
  const flowSegments = run.flow.split("/");
2240
- const dir = join20(sessionDebugDir(), ...flowSegments);
2235
+ const dir = join20(root, ...flowSegments);
2241
2236
  await mkdir8(dir, { recursive: true });
2242
2237
  const filename = nextAttemptFilename(dir, run.menuOption);
2243
2238
  await writeFile7(join20(dir, filename), content, { mode: 384 });
@@ -2284,17 +2279,16 @@ ${JSON.stringify(finish.outputs, null, 2)}
2284
2279
  function handleCrash() {
2285
2280
  return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
2286
2281
  }
2287
- var pendingRun, SESSION_ID, projectSessionsRoot;
2282
+ var pendingRun, sessionDir;
2288
2283
  var init_debug_store = __esm({
2289
2284
  "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
2290
2285
  "use strict";
2291
2286
  init_config();
2292
2287
  init_version();
2293
2288
  init_debug_mode_store();
2294
- SESSION_ID = generateSessionId3();
2295
- void isDebugModeEnabled().then((enabled) => {
2296
- if (!enabled) return void 0;
2297
- return mkdir8(sessionDebugDir(), { recursive: true });
2289
+ void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
2290
+ if (!enabled || !base) return void 0;
2291
+ return mkdir8(join20(startSession(base), "debug"), { recursive: true });
2298
2292
  });
2299
2293
  process.once("uncaughtException", (err) => {
2300
2294
  void handleCrash().finally(() => {
@@ -2315,7 +2309,7 @@ var init_debug_store = __esm({
2315
2309
  });
2316
2310
 
2317
2311
  // packages/experience-design-system-cli/app.tsx
2318
- import { join as join26 } from "node:path";
2312
+ import { join as join25 } from "node:path";
2319
2313
  import { useEffect as useEffect27, useState as useState33 } from "react";
2320
2314
 
2321
2315
  // packages/experience-design-system-cli/src/tui/home/home.tsx
@@ -4378,12 +4372,12 @@ function renameEmptySlots(db, sessionId, componentId, componentName, slotCount)
4378
4372
  return { renames: [], warnings: [] };
4379
4373
  const renames = [];
4380
4374
  const warnings = [];
4381
- const rename4 = db.prepare(`UPDATE raw_slots SET name = ? WHERE session_id = ? AND component_id = ? AND name = ? AND position = ?`);
4375
+ const rename3 = db.prepare(`UPDATE raw_slots SET name = ? WHERE session_id = ? AND component_id = ? AND name = ? AND position = ?`);
4382
4376
  db.exec("BEGIN");
4383
4377
  try {
4384
4378
  for (const slot of emptySlots) {
4385
4379
  const newName = slotCount === 1 ? "children" : `slot_${slot.position}`;
4386
- rename4.run(newName, sessionId, componentId, slot.name, slot.position);
4380
+ rename3.run(newName, sessionId, componentId, slot.name, slot.position);
4387
4381
  renames.push({ oldName: slot.name, newName });
4388
4382
  warnings.push(`${componentName}: slot at position ${slot.position} had empty name \u2014 renamed to "${newName}" for classification`);
4389
4383
  }
@@ -12553,11 +12547,11 @@ import { access as access2, mkdir, readFile as readFile7, writeFile } from "node
12553
12547
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
12554
12548
  import { resolve as resolve15 } from "node:path";
12555
12549
  async function getRefineSessionPaths(sessionId, artifactsRoot) {
12556
- const sessionDir = resolve15(artifactsRoot, sessionId);
12550
+ const sessionDir2 = resolve15(artifactsRoot, sessionId);
12557
12551
  return {
12558
- sessionDir,
12559
- eventsPath: resolve15(sessionDir, "events.jsonl"),
12560
- statePath: resolve15(sessionDir, "current-review-state.json")
12552
+ sessionDir: sessionDir2,
12553
+ eventsPath: resolve15(sessionDir2, "events.jsonl"),
12554
+ statePath: resolve15(sessionDir2, "current-review-state.json")
12561
12555
  };
12562
12556
  }
12563
12557
 
@@ -13756,7 +13750,7 @@ function errorMessage(error) {
13756
13750
  return error instanceof Error && error.message ? error.message : String(error);
13757
13751
  }
13758
13752
  function defaultSleep(delayMs) {
13759
- return new Promise((resolve27) => setTimeout(resolve27, delayMs));
13753
+ return new Promise((resolve26) => setTimeout(resolve26, delayMs));
13760
13754
  }
13761
13755
 
13762
13756
  // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
@@ -13997,7 +13991,7 @@ var ApiClient = class {
13997
13991
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
13998
13992
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
13999
13993
  const jitter = Math.random() * baseDelay * 0.15;
14000
- await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
13994
+ await new Promise((resolve26) => setTimeout(resolve26, baseDelay + jitter));
14001
13995
  }
14002
13996
  }
14003
13997
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -16110,7 +16104,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
16110
16104
  const message = error instanceof Error ? error.message : String(error);
16111
16105
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
16112
16106
  throw error;
16113
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
16107
+ await new Promise((resolve26) => setTimeout(resolve26, Math.min(250 * attempt, 2e3)));
16114
16108
  }
16115
16109
  }
16116
16110
  }
@@ -16527,12 +16521,12 @@ async function runOneGenerateComponent(options, component, index, total) {
16527
16521
  if (renames.length > 0) {
16528
16522
  const renameMap = new Map(renames.map((r) => [r.oldName, r.newName]));
16529
16523
  effectiveSlots = component.slots.map((s) => renameMap.has(s.name) ? { ...s, name: renameMap.get(s.name) } : s);
16530
- for (const rename4 of renames) {
16524
+ for (const rename3 of renames) {
16531
16525
  onProgress?.({
16532
16526
  kind: "component:slot-renamed",
16533
16527
  componentName: component.name,
16534
- oldName: rename4.oldName,
16535
- newName: rename4.newName
16528
+ oldName: rename3.oldName,
16529
+ newName: rename3.newName
16536
16530
  });
16537
16531
  }
16538
16532
  }
@@ -16658,7 +16652,7 @@ async function runWithPool(items, concurrency, worker) {
16658
16652
  init_cache_keys();
16659
16653
 
16660
16654
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/restore-cached-components.js
16661
- function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
16655
+ async function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
16662
16656
  const restorations = [];
16663
16657
  const rekeyed = [];
16664
16658
  const componentStatus = db.prepare("SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?");
@@ -16673,6 +16667,7 @@ function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, al
16673
16667
  componentId: component.component_id
16674
16668
  });
16675
16669
  rekeyed.push({ component, cached: resolution.entry });
16670
+ await new Promise((r) => setImmediate(r));
16676
16671
  }
16677
16672
  copyComponentsFromCache(db, restorations, { allowedComponentNames: allowedComponentNames2 });
16678
16673
  storeCaches(db, rekeyed.map(({ component, cached }) => ({
@@ -16706,12 +16701,15 @@ async function checkGenerateComponentsCache(request) {
16706
16701
  ...components.map((component) => component.name),
16707
16702
  ...(existingEntities?.components ?? []).map((component) => component.name)
16708
16703
  ]);
16709
- const cachedComponents = components.flatMap((component) => {
16704
+ const cachedComponents = [];
16705
+ for (const component of components) {
16710
16706
  const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
16711
- return resolution ? [{ component, resolution }] : [];
16712
- });
16707
+ if (resolution)
16708
+ cachedComponents.push({ component, resolution });
16709
+ await new Promise((r) => setImmediate(r));
16710
+ }
16713
16711
  if (request.restoreCache) {
16714
- restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
16712
+ await restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
16715
16713
  }
16716
16714
  return {
16717
16715
  sessionId: request.sessionId,
@@ -17437,7 +17435,6 @@ function ExtractionScreen({
17437
17435
  init_config();
17438
17436
 
17439
17437
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
17440
- import { join as join21, resolve as resolve24 } from "node:path";
17441
17438
  import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
17442
17439
 
17443
17440
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
@@ -17711,9 +17708,7 @@ function useExtraction(input) {
17711
17708
  reuseTokens: input.tokenStrategy === "reuse"
17712
17709
  })
17713
17710
  });
17714
- void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then(
17715
- (store) => store.setDebugOutDir(join21(resolve24(input.projectPath), ".contentful"))
17716
- );
17711
+ void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((store) => store.startDebugSessionIn(input.projectPath));
17717
17712
  void runExtraction(input, (progress) => {
17718
17713
  if (current.current === input) setState({ status: "running", progress });
17719
17714
  }).then((result) => {
@@ -20600,7 +20595,7 @@ function GenerationScreen({
20600
20595
  import { useEffect as useEffect9, useRef as useRef6, useState as useState14 } from "react";
20601
20596
 
20602
20597
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
20603
- import { resolve as resolve25 } from "node:path";
20598
+ import { resolve as resolve24 } from "node:path";
20604
20599
 
20605
20600
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/map-tokens.ts
20606
20601
  async function prepareMapTokens(input, generatedSessionId) {
@@ -20735,7 +20730,7 @@ async function buildMapTokensOptions(input) {
20735
20730
  if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
20736
20731
  if (mapOverride?.kind === "path") {
20737
20732
  await resolvePromptOverride(mapOverride);
20738
- prompt.skillPathOverride = resolve25(mapOverride.value);
20733
+ prompt.skillPathOverride = resolve24(mapOverride.value);
20739
20734
  }
20740
20735
  if (input.existingEntitiesPath) {
20741
20736
  const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
@@ -20783,7 +20778,7 @@ function useGeneration(input) {
20783
20778
  }
20784
20779
 
20785
20780
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
20786
- import { join as join22 } from "node:path";
20781
+ import { join as join21 } from "node:path";
20787
20782
  function buildFlowStart(input) {
20788
20783
  const { extraction, handoff, saved, generatePromptPath } = input;
20789
20784
  const credentials = extraction.credentials ?? {
@@ -20796,7 +20791,7 @@ function buildFlowStart(input) {
20796
20791
  handoff,
20797
20792
  agent: extraction.agent,
20798
20793
  projectPath: extraction.projectPath,
20799
- outDir: extraction.projectPath ? join22(extraction.projectPath, ".contentful") : "",
20794
+ outDir: extraction.projectPath ? join21(extraction.projectPath, ".contentful") : "",
20800
20795
  rawTokensPath: extraction.rawTokensPath,
20801
20796
  credentials: {
20802
20797
  spaceId: credentials.spaceId,
@@ -26540,10 +26535,10 @@ function DoneStep({
26540
26535
  import { useState as useState24 } from "react";
26541
26536
  import { Box as Box37, Text as Text40 } from "ink";
26542
26537
  import { readdirSync as readdirSync4 } from "node:fs";
26543
- import { dirname as dirname15, basename as basename6, join as join23 } from "node:path";
26538
+ import { dirname as dirname15, basename as basename6, join as join22 } from "node:path";
26544
26539
 
26545
26540
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
26546
- import { resolve as resolve26 } from "node:path";
26541
+ import { resolve as resolve25 } from "node:path";
26547
26542
  import { homedir as homedir4 } from "node:os";
26548
26543
  function expandTilde(input) {
26549
26544
  if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
@@ -26557,7 +26552,7 @@ function normalizePath(input) {
26557
26552
  p = p.slice(1, -1);
26558
26553
  }
26559
26554
  p = expandTilde(p);
26560
- return resolve26(p);
26555
+ return resolve25(p);
26561
26556
  }
26562
26557
 
26563
26558
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
@@ -26586,13 +26581,13 @@ function autocomplete(partial) {
26586
26581
  }
26587
26582
  const matches = entries.filter((e) => e.startsWith(base));
26588
26583
  if (matches.length === 0) return null;
26589
- if (matches.length === 1) return join23(dir, matches[0]);
26584
+ if (matches.length === 1) return join22(dir, matches[0]);
26590
26585
  let prefix = matches[0];
26591
26586
  for (const m of matches) {
26592
26587
  while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
26593
26588
  if (!prefix) break;
26594
26589
  }
26595
- return prefix.length > base.length ? join23(dir, prefix) : null;
26590
+ return prefix.length > base.length ? join22(dir, prefix) : null;
26596
26591
  }
26597
26592
  function PathPrompt({
26598
26593
  defaultPath,
@@ -27353,7 +27348,7 @@ import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } fr
27353
27348
  import { appendFileSync, writeFileSync } from "node:fs";
27354
27349
  import { mkdir as mkdir9 } from "node:fs/promises";
27355
27350
  import { tmpdir } from "node:os";
27356
- import { join as join25 } from "node:path";
27351
+ import { join as join24 } from "node:path";
27357
27352
 
27358
27353
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
27359
27354
  function shouldBypassPreview(state) {
@@ -27698,7 +27693,7 @@ function pushFailure(e, deps) {
27698
27693
 
27699
27694
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
27700
27695
  import { writeFile as writeFile8 } from "node:fs/promises";
27701
- import { join as join24 } from "node:path";
27696
+ import { join as join23 } from "node:path";
27702
27697
 
27703
27698
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/run-print-files-helpers.ts
27704
27699
  function nextStateAfterPrint(opts) {
@@ -27724,12 +27719,12 @@ var realSaveDeps = () => ({
27724
27719
  writeFile: (path5, contents) => writeFile8(path5, contents),
27725
27720
  appendRun,
27726
27721
  buildSourceFingerprint,
27727
- sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
27722
+ sleep: (ms) => new Promise((resolve26) => setTimeout(resolve26, ms)),
27728
27723
  warn: (message) => process.stderr.write(message)
27729
27724
  });
27730
27725
  async function runPrintFiles(input, deps, onPatch) {
27731
27726
  onPatch({ step: "printing" });
27732
- const componentsPath = join24(input.outDir, "components.json");
27727
+ const componentsPath = join23(input.outDir, "components.json");
27733
27728
  try {
27734
27729
  const db = deps.openDb();
27735
27730
  let components = [];
@@ -27810,7 +27805,7 @@ var EMPTY_PUSH_RESULT = {
27810
27805
  };
27811
27806
 
27812
27807
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
27813
- var WIZARD_LOG = join25(tmpdir(), "experiences-import-wizard.log");
27808
+ var WIZARD_LOG = join24(tmpdir(), "experiences-import-wizard.log");
27814
27809
  function appendWizardLog(entry) {
27815
27810
  appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
27816
27811
  }
@@ -28109,8 +28104,7 @@ async function readHelpInfo() {
28109
28104
  return {
28110
28105
  storage: [
28111
28106
  { label: "Config folder", value: configRoot2() },
28112
- { label: "Settings file", value: configFilePath2() },
28113
- { label: "Debug logs", value: "<project>/.contentful/debug/sessions, next to components.json" }
28107
+ { label: "Settings file", value: configFilePath2() }
28114
28108
  ],
28115
28109
  troubleshooting: [
28116
28110
  { label: "CLI version", value: readPackageVersion() },
@@ -28119,7 +28113,7 @@ async function readHelpInfo() {
28119
28113
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
28120
28114
  {
28121
28115
  label: "This session",
28122
- value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
28116
+ 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"
28123
28117
  }
28124
28118
  ]
28125
28119
  };
@@ -28249,7 +28243,8 @@ async function readCredentials() {
28249
28243
  cmaToken: store.cmaToken || "",
28250
28244
  host: store.host || "",
28251
28245
  defaultComponentDir: store.defaultComponentDir || "",
28252
- defaultTokenFile: store.defaultTokenFile || ""
28246
+ defaultTokenFile: store.defaultTokenFile || "",
28247
+ contentfulBaseDir: store.contentfulBaseDir || ""
28253
28248
  };
28254
28249
  }
28255
28250
  async function writeCredentials(config) {
@@ -28273,7 +28268,8 @@ var FIELD_ORDER = [
28273
28268
  "cmaToken",
28274
28269
  "host",
28275
28270
  "defaultComponentDir",
28276
- "defaultTokenFile"
28271
+ "defaultTokenFile",
28272
+ "contentfulBaseDir"
28277
28273
  ];
28278
28274
  function debugFields(config) {
28279
28275
  return {
@@ -28282,7 +28278,8 @@ function debugFields(config) {
28282
28278
  cma_token: config?.cmaToken ?? "",
28283
28279
  host: config?.host ?? "",
28284
28280
  default_component_dir: config?.defaultComponentDir ?? "",
28285
- default_token_file: config?.defaultTokenFile ?? ""
28281
+ default_token_file: config?.defaultTokenFile ?? "",
28282
+ contentful_base_dir: config?.contentfulBaseDir ?? ""
28286
28283
  };
28287
28284
  }
28288
28285
  var FIELD_LABELS = {
@@ -28291,7 +28288,8 @@ var FIELD_LABELS = {
28291
28288
  cmaToken: "CMA Token",
28292
28289
  host: "API Host (optional)",
28293
28290
  defaultComponentDir: "Default component directory (optional)",
28294
- defaultTokenFile: "Default token file (optional)"
28291
+ defaultTokenFile: "Default token file (optional)",
28292
+ contentfulBaseDir: "Default project directory, where .contentful goes (optional)"
28295
28293
  };
28296
28294
  function ConfigurationScreen({ onDone }) {
28297
28295
  const [stage, setStage] = useState29("loading");
@@ -28328,6 +28326,7 @@ function ConfigurationScreen({ onDone }) {
28328
28326
  setNotice(null);
28329
28327
  writeCredentials(config).then(() => {
28330
28328
  setLastSaved(config);
28329
+ if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir);
28331
28330
  setNotice({ kind: "success", text: "Configuration saved" });
28332
28331
  setStage("form");
28333
28332
  }).catch((err) => {
@@ -28695,7 +28694,7 @@ function App({ importOptions, inkClear }) {
28695
28694
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
28696
28695
  const state = await inspectTokens({
28697
28696
  rawTokensPath: tokens,
28698
- outDir: join26(resolveUserPath(projectPath2), ".contentful"),
28697
+ outDir: join25(resolveUserPath(projectPath2), ".contentful"),
28699
28698
  cache: importOptions.cache
28700
28699
  });
28701
28700
  if (state.kind === "cached") {
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((resolve27) => {
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
- resolve27(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((resolve27) => {
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
- resolve27("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
- resolve27("unauthenticated");
2215
+ resolve26("unauthenticated");
2216
2216
  return;
2217
2217
  }
2218
2218
  try {
2219
2219
  const status = JSON.parse(stdout);
2220
- resolve27(status.loggedIn ? "ok" : "unauthenticated");
2220
+ resolve26(status.loggedIn ? "ok" : "unauthenticated");
2221
2221
  } catch {
2222
- resolve27("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((resolve27) => {
2232
+ return new Promise((resolve26) => {
2233
2233
  const child = spawn4(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
2234
- child.on("close", (code) => resolve27(code === 0));
2234
+ child.on("close", (code) => resolve26(code === 0));
2235
2235
  });
2236
2236
  }
2237
2237
  var init_check_agent_auth = __esm({
@@ -4153,12 +4153,12 @@ function renameEmptySlots(db, sessionId, componentId, componentName, slotCount)
4153
4153
  return { renames: [], warnings: [] };
4154
4154
  const renames = [];
4155
4155
  const warnings = [];
4156
- const rename5 = db.prepare(`UPDATE raw_slots SET name = ? WHERE session_id = ? AND component_id = ? AND name = ? AND position = ?`);
4156
+ const rename4 = db.prepare(`UPDATE raw_slots SET name = ? WHERE session_id = ? AND component_id = ? AND name = ? AND position = ?`);
4157
4157
  db.exec("BEGIN");
4158
4158
  try {
4159
4159
  for (const slot of emptySlots) {
4160
4160
  const newName = slotCount === 1 ? "children" : `slot_${slot.position}`;
4161
- rename5.run(newName, sessionId, componentId, slot.name, slot.position);
4161
+ rename4.run(newName, sessionId, componentId, slot.name, slot.position);
4162
4162
  renames.push({ oldName: slot.name, newName });
4163
4163
  warnings.push(`${componentName}: slot at position ${slot.position} had empty name \u2014 renamed to "${newName}" for classification`);
4164
4164
  }
@@ -13144,11 +13144,11 @@ var init_load_and_validate_for_review = __esm({
13144
13144
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
13145
13145
  import { resolve as resolve15 } from "node:path";
13146
13146
  async function getRefineSessionPaths(sessionId, artifactsRoot) {
13147
- const sessionDir = resolve15(artifactsRoot, sessionId);
13147
+ const sessionDir2 = resolve15(artifactsRoot, sessionId);
13148
13148
  return {
13149
- sessionDir,
13150
- eventsPath: resolve15(sessionDir, "events.jsonl"),
13151
- statePath: resolve15(sessionDir, "current-review-state.json")
13149
+ sessionDir: sessionDir2,
13150
+ eventsPath: resolve15(sessionDir2, "events.jsonl"),
13151
+ statePath: resolve15(sessionDir2, "current-review-state.json")
13152
13152
  };
13153
13153
  }
13154
13154
  var init_review_session_paths = __esm({
@@ -14901,7 +14901,7 @@ function errorMessage(error) {
14901
14901
  return error instanceof Error && error.message ? error.message : String(error);
14902
14902
  }
14903
14903
  function defaultSleep(delayMs) {
14904
- return new Promise((resolve27) => setTimeout(resolve27, delayMs));
14904
+ return new Promise((resolve26) => setTimeout(resolve26, delayMs));
14905
14905
  }
14906
14906
  var MAX_RETRY_AFTER_MS;
14907
14907
  var init_http_utils = __esm({
@@ -15177,7 +15177,7 @@ var init_api_client = __esm({
15177
15177
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
15178
15178
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
15179
15179
  const jitter = Math.random() * baseDelay * 0.15;
15180
- await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
15180
+ await new Promise((resolve26) => setTimeout(resolve26, baseDelay + jitter));
15181
15181
  }
15182
15182
  }
15183
15183
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -18734,7 +18734,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
18734
18734
  const message = error instanceof Error ? error.message : String(error);
18735
18735
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
18736
18736
  throw error;
18737
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
18737
+ await new Promise((resolve26) => setTimeout(resolve26, Math.min(250 * attempt, 2e3)));
18738
18738
  }
18739
18739
  }
18740
18740
  }
@@ -19251,12 +19251,12 @@ async function runOneGenerateComponent(options, component, index, total) {
19251
19251
  if (renames.length > 0) {
19252
19252
  const renameMap = new Map(renames.map((r) => [r.oldName, r.newName]));
19253
19253
  effectiveSlots = component.slots.map((s) => renameMap.has(s.name) ? { ...s, name: renameMap.get(s.name) } : s);
19254
- for (const rename5 of renames) {
19254
+ for (const rename4 of renames) {
19255
19255
  onProgress?.({
19256
19256
  kind: "component:slot-renamed",
19257
19257
  componentName: component.name,
19258
- oldName: rename5.oldName,
19259
- newName: rename5.newName
19258
+ oldName: rename4.oldName,
19259
+ newName: rename4.newName
19260
19260
  });
19261
19261
  }
19262
19262
  }
@@ -19402,7 +19402,7 @@ var init_run_with_pool = __esm({
19402
19402
  });
19403
19403
 
19404
19404
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/restore-cached-components.js
19405
- function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
19405
+ async function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
19406
19406
  const restorations = [];
19407
19407
  const rekeyed = [];
19408
19408
  const componentStatus = db.prepare("SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?");
@@ -19417,6 +19417,7 @@ function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, al
19417
19417
  componentId: component.component_id
19418
19418
  });
19419
19419
  rekeyed.push({ component, cached: resolution.entry });
19420
+ await new Promise((r) => setImmediate(r));
19420
19421
  }
19421
19422
  copyComponentsFromCache(db, restorations, { allowedComponentNames: allowedComponentNames2 });
19422
19423
  storeCaches(db, rekeyed.map(({ component, cached }) => ({
@@ -19457,12 +19458,15 @@ async function checkGenerateComponentsCache(request) {
19457
19458
  ...components.map((component) => component.name),
19458
19459
  ...(existingEntities?.components ?? []).map((component) => component.name)
19459
19460
  ]);
19460
- const cachedComponents = components.flatMap((component) => {
19461
+ const cachedComponents = [];
19462
+ for (const component of components) {
19461
19463
  const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
19462
- return resolution ? [{ component, resolution }] : [];
19463
- });
19464
+ if (resolution)
19465
+ cachedComponents.push({ component, resolution });
19466
+ await new Promise((r) => setImmediate(r));
19467
+ }
19464
19468
  if (request.restoreCache) {
19465
- restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
19469
+ await restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
19466
19470
  }
19467
19471
  return {
19468
19472
  sessionId: request.sessionId,
@@ -20516,13 +20520,12 @@ async function writeSettings2(settings) {
20516
20520
  async function updateSettings2(patch) {
20517
20521
  await writeSettings2({ ...await readSettings2(), ...patch });
20518
20522
  }
20519
- var configFilePath2, runsFilePath2, debugSessionsDir2, oldConfigDir2;
20523
+ var configFilePath2, runsFilePath2, oldConfigDir2;
20520
20524
  var init_config = __esm({
20521
20525
  "packages/experience-design-system-types/dist/src/config/index.js"() {
20522
20526
  "use strict";
20523
20527
  configFilePath2 = () => join19(configRoot2(), "config.json");
20524
20528
  runsFilePath2 = () => join19(configRoot2(), "state", "runs.json");
20525
- debugSessionsDir2 = () => join19(configRoot2(), "debug", "sessions");
20526
20529
  oldConfigDir2 = () => join19(homedir3(), ".config", "experiences");
20527
20530
  }
20528
20531
  });
@@ -20825,10 +20828,10 @@ var debug_store_exports = {};
20825
20828
  __export(debug_store_exports, {
20826
20829
  currentDebugSessionDir: () => currentDebugSessionDir,
20827
20830
  finishDebugRun: () => finishDebugRun,
20828
- setDebugOutDir: () => setDebugOutDir,
20829
- startDebugRun: () => startDebugRun
20831
+ startDebugRun: () => startDebugRun,
20832
+ startDebugSessionIn: () => startDebugSessionIn
20830
20833
  });
20831
- import { cp, mkdir as mkdir8, rename as rename3, rm, writeFile as writeFile7 } from "node:fs/promises";
20834
+ import { mkdir as mkdir8, writeFile as writeFile7 } from "node:fs/promises";
20832
20835
  import { existsSync as existsSync11, readdirSync as readdirSync3 } from "node:fs";
20833
20836
  import { join as join22, resolve as resolve23 } from "node:path";
20834
20837
  function generateRunId() {
@@ -20843,10 +20846,17 @@ function datePrefix(now = /* @__PURE__ */ new Date()) {
20843
20846
  function slugify(value) {
20844
20847
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
20845
20848
  }
20846
- function generateSessionId3() {
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) {
20847
20858
  const today = datePrefix();
20848
- const root = debugSessionsDir2();
20849
- const existing = existsSync11(root) ? readdirSync3(root) : [];
20859
+ const existing = existsSync11(contentfulDir) ? readdirSync3(contentfulDir) : [];
20850
20860
  const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
20851
20861
  const maxSeq = existing.reduce((max, entry) => {
20852
20862
  const match2 = seqPattern.exec(entry);
@@ -20854,31 +20864,18 @@ function generateSessionId3() {
20854
20864
  }, 0);
20855
20865
  return `${today}-session-${maxSeq + 1}`;
20856
20866
  }
20857
- function sessionDebugDir() {
20858
- return join22(projectSessionsRoot ?? debugSessionsDir2(), SESSION_ID);
20867
+ function startSession(base) {
20868
+ const contentfulDir = join22(base, ".contentful");
20869
+ sessionDir ??= join22(contentfulDir, nextSessionId(contentfulDir));
20870
+ return sessionDir;
20859
20871
  }
20860
20872
  function currentDebugSessionDir() {
20861
- return sessionDebugDir();
20862
- }
20863
- async function setDebugOutDir(outDir) {
20864
- if (!await isDebugModeEnabled()) return;
20865
- const nextRoot = join22(resolve23(outDir), "debug", "sessions");
20866
- const from = sessionDebugDir();
20867
- const to = join22(nextRoot, SESSION_ID);
20868
- if (from === to) return;
20873
+ return sessionDir && join22(sessionDir, "debug");
20874
+ }
20875
+ async function startDebugSessionIn(base) {
20869
20876
  try {
20870
- await mkdir8(nextRoot, { recursive: true });
20871
- if (existsSync11(from)) {
20872
- try {
20873
- await rename3(from, to);
20874
- } catch {
20875
- await cp(from, to, { recursive: true });
20876
- await rm(from, { recursive: true, force: true });
20877
- }
20878
- } else {
20879
- await mkdir8(to, { recursive: true });
20880
- }
20881
- projectSessionsRoot = nextRoot;
20877
+ if (!await isDebugModeEnabled()) return;
20878
+ await mkdir8(join22(startSession(resolve23(base)), "debug"), { recursive: true });
20882
20879
  } catch {
20883
20880
  }
20884
20881
  }
@@ -20921,8 +20918,10 @@ async function finishDebugRun({
20921
20918
  pendingRun = void 0;
20922
20919
  const durationMs = Date.now() - run.startedAt;
20923
20920
  const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
20921
+ const root = currentDebugSessionDir();
20922
+ if (!root) return;
20924
20923
  const flowSegments = run.flow.split("/");
20925
- const dir = join22(sessionDebugDir(), ...flowSegments);
20924
+ const dir = join22(root, ...flowSegments);
20926
20925
  await mkdir8(dir, { recursive: true });
20927
20926
  const filename = nextAttemptFilename(dir, run.menuOption);
20928
20927
  await writeFile7(join22(dir, filename), content, { mode: 384 });
@@ -20969,17 +20968,16 @@ ${JSON.stringify(finish.outputs, null, 2)}
20969
20968
  function handleCrash() {
20970
20969
  return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
20971
20970
  }
20972
- var pendingRun, SESSION_ID, projectSessionsRoot;
20971
+ var pendingRun, sessionDir;
20973
20972
  var init_debug_store = __esm({
20974
20973
  "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
20975
20974
  "use strict";
20976
20975
  init_config();
20977
20976
  init_version();
20978
20977
  init_debug_mode_store();
20979
- SESSION_ID = generateSessionId3();
20980
- void isDebugModeEnabled().then((enabled) => {
20981
- if (!enabled) return void 0;
20982
- return mkdir8(sessionDebugDir(), { recursive: true });
20978
+ void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
20979
+ if (!enabled || !base) return void 0;
20980
+ return mkdir8(join22(startSession(base), "debug"), { recursive: true });
20983
20981
  });
20984
20982
  process.once("uncaughtException", (err) => {
20985
20983
  void handleCrash().finally(() => {
@@ -21000,7 +20998,6 @@ var init_debug_store = __esm({
21000
20998
  });
21001
20999
 
21002
21000
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
21003
- import { join as join23, resolve as resolve24 } from "node:path";
21004
21001
  import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
21005
21002
  function useExtraction(input) {
21006
21003
  const [state, setState] = useState8();
@@ -21019,9 +21016,7 @@ function useExtraction(input) {
21019
21016
  reuseTokens: input.tokenStrategy === "reuse"
21020
21017
  })
21021
21018
  });
21022
- void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then(
21023
- (store) => store.setDebugOutDir(join23(resolve24(input.projectPath), ".contentful"))
21024
- );
21019
+ void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((store) => store.startDebugSessionIn(input.projectPath));
21025
21020
  void runExtraction(input, (progress) => {
21026
21021
  if (current.current === input) setState({ status: "running", progress });
21027
21022
  }).then((result) => {
@@ -24243,7 +24238,7 @@ var init_save_decisions = __esm({
24243
24238
  });
24244
24239
 
24245
24240
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
24246
- import { resolve as resolve25 } from "node:path";
24241
+ import { resolve as resolve24 } from "node:path";
24247
24242
  async function runGeneration(input, onProgress, deps = realDeps3) {
24248
24243
  let progress = { components: null, mapTokens: "idle", mapTokensEligible: null };
24249
24244
  const update = (change) => {
@@ -24329,7 +24324,7 @@ async function buildMapTokensOptions(input) {
24329
24324
  if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
24330
24325
  if (mapOverride?.kind === "path") {
24331
24326
  await resolvePromptOverride(mapOverride);
24332
- prompt.skillPathOverride = resolve25(mapOverride.value);
24327
+ prompt.skillPathOverride = resolve24(mapOverride.value);
24333
24328
  }
24334
24329
  if (input.existingEntitiesPath) {
24335
24330
  const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
@@ -24407,7 +24402,7 @@ var init_use_generation = __esm({
24407
24402
  });
24408
24403
 
24409
24404
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
24410
- import { join as join24 } from "node:path";
24405
+ import { join as join23 } from "node:path";
24411
24406
  function buildFlowStart(input) {
24412
24407
  const { extraction, handoff, saved, generatePromptPath } = input;
24413
24408
  const credentials = extraction.credentials ?? {
@@ -24420,7 +24415,7 @@ function buildFlowStart(input) {
24420
24415
  handoff,
24421
24416
  agent: extraction.agent,
24422
24417
  projectPath: extraction.projectPath,
24423
- outDir: extraction.projectPath ? join24(extraction.projectPath, ".contentful") : "",
24418
+ outDir: extraction.projectPath ? join23(extraction.projectPath, ".contentful") : "",
24424
24419
  rawTokensPath: extraction.rawTokensPath,
24425
24420
  credentials: {
24426
24421
  spaceId: credentials.spaceId,
@@ -30616,7 +30611,7 @@ var init_DoneStep = __esm({
30616
30611
  });
30617
30612
 
30618
30613
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
30619
- import { resolve as resolve26 } from "node:path";
30614
+ import { resolve as resolve25 } from "node:path";
30620
30615
  import { homedir as homedir4 } from "node:os";
30621
30616
  function expandTilde(input) {
30622
30617
  if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
@@ -30630,7 +30625,7 @@ function normalizePath(input) {
30630
30625
  p = p.slice(1, -1);
30631
30626
  }
30632
30627
  p = expandTilde(p);
30633
- return resolve26(p);
30628
+ return resolve25(p);
30634
30629
  }
30635
30630
  var init_path_utils = __esm({
30636
30631
  "packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts"() {
@@ -30658,7 +30653,7 @@ var init_use_blinking_cursor = __esm({
30658
30653
  import { useState as useState24 } from "react";
30659
30654
  import { Box as Box37, Text as Text40 } from "ink";
30660
30655
  import { readdirSync as readdirSync4 } from "node:fs";
30661
- import { dirname as dirname15, basename as basename6, join as join25 } from "node:path";
30656
+ import { dirname as dirname15, basename as basename6, join as join24 } from "node:path";
30662
30657
  import { jsx as jsx47, jsxs as jsxs38 } from "react/jsx-runtime";
30663
30658
  function autocomplete(partial) {
30664
30659
  if (!partial) return null;
@@ -30673,13 +30668,13 @@ function autocomplete(partial) {
30673
30668
  }
30674
30669
  const matches = entries.filter((e) => e.startsWith(base));
30675
30670
  if (matches.length === 0) return null;
30676
- if (matches.length === 1) return join25(dir, matches[0]);
30671
+ if (matches.length === 1) return join24(dir, matches[0]);
30677
30672
  let prefix = matches[0];
30678
30673
  for (const m of matches) {
30679
30674
  while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
30680
30675
  if (!prefix) break;
30681
30676
  }
30682
- return prefix.length > base.length ? join25(dir, prefix) : null;
30677
+ return prefix.length > base.length ? join24(dir, prefix) : null;
30683
30678
  }
30684
30679
  function PathPrompt({
30685
30680
  defaultPath,
@@ -31883,7 +31878,7 @@ var init_run_print_files_helpers = __esm({
31883
31878
 
31884
31879
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
31885
31880
  import { writeFile as writeFile8 } from "node:fs/promises";
31886
- import { join as join26 } from "node:path";
31881
+ import { join as join25 } from "node:path";
31887
31882
  function buildSavedCDF(components, tokens, opts = {}) {
31888
31883
  const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
31889
31884
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
@@ -31895,7 +31890,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
31895
31890
  }
31896
31891
  async function runPrintFiles(input, deps, onPatch) {
31897
31892
  onPatch({ step: "printing" });
31898
- const componentsPath = join26(input.outDir, "components.json");
31893
+ const componentsPath = join25(input.outDir, "components.json");
31899
31894
  try {
31900
31895
  const db = deps.openDb();
31901
31896
  let components = [];
@@ -31982,7 +31977,7 @@ var init_save = __esm({
31982
31977
  writeFile: (path5, contents) => writeFile8(path5, contents),
31983
31978
  appendRun,
31984
31979
  buildSourceFingerprint,
31985
- sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
31980
+ sleep: (ms) => new Promise((resolve26) => setTimeout(resolve26, ms)),
31986
31981
  warn: (message) => process.stderr.write(message)
31987
31982
  });
31988
31983
  }
@@ -32004,7 +31999,7 @@ var init_types9 = __esm({
32004
31999
  import { appendFileSync, writeFileSync } from "node:fs";
32005
32000
  import { mkdir as mkdir9 } from "node:fs/promises";
32006
32001
  import { tmpdir } from "node:os";
32007
- import { join as join27 } from "node:path";
32002
+ import { join as join26 } from "node:path";
32008
32003
  function appendWizardLog(entry) {
32009
32004
  appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
32010
32005
  }
@@ -32278,7 +32273,7 @@ var init_controller = __esm({
32278
32273
  init_push();
32279
32274
  init_save();
32280
32275
  init_types9();
32281
- WIZARD_LOG = join27(tmpdir(), "experiences-import-wizard.log");
32276
+ WIZARD_LOG = join26(tmpdir(), "experiences-import-wizard.log");
32282
32277
  }
32283
32278
  });
32284
32279
 
@@ -32316,8 +32311,7 @@ async function readHelpInfo() {
32316
32311
  return {
32317
32312
  storage: [
32318
32313
  { label: "Config folder", value: configRoot2() },
32319
- { label: "Settings file", value: configFilePath2() },
32320
- { label: "Debug logs", value: "<project>/.contentful/debug/sessions, next to components.json" }
32314
+ { label: "Settings file", value: configFilePath2() }
32321
32315
  ],
32322
32316
  troubleshooting: [
32323
32317
  { label: "CLI version", value: readPackageVersion() },
@@ -32326,7 +32320,7 @@ async function readHelpInfo() {
32326
32320
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
32327
32321
  {
32328
32322
  label: "This session",
32329
- 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"
32330
32324
  }
32331
32325
  ]
32332
32326
  };
@@ -32483,7 +32477,8 @@ async function readCredentials() {
32483
32477
  cmaToken: store.cmaToken || "",
32484
32478
  host: store.host || "",
32485
32479
  defaultComponentDir: store.defaultComponentDir || "",
32486
- defaultTokenFile: store.defaultTokenFile || ""
32480
+ defaultTokenFile: store.defaultTokenFile || "",
32481
+ contentfulBaseDir: store.contentfulBaseDir || ""
32487
32482
  };
32488
32483
  }
32489
32484
  async function writeCredentials(config) {
@@ -32516,7 +32511,8 @@ function debugFields(config) {
32516
32511
  cma_token: config?.cmaToken ?? "",
32517
32512
  host: config?.host ?? "",
32518
32513
  default_component_dir: config?.defaultComponentDir ?? "",
32519
- default_token_file: config?.defaultTokenFile ?? ""
32514
+ default_token_file: config?.defaultTokenFile ?? "",
32515
+ contentful_base_dir: config?.contentfulBaseDir ?? ""
32520
32516
  };
32521
32517
  }
32522
32518
  function ConfigurationScreen({ onDone }) {
@@ -32554,6 +32550,7 @@ function ConfigurationScreen({ onDone }) {
32554
32550
  setNotice(null);
32555
32551
  writeCredentials(config).then(() => {
32556
32552
  setLastSaved(config);
32553
+ if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir);
32557
32554
  setNotice({ kind: "success", text: "Configuration saved" });
32558
32555
  setStage("form");
32559
32556
  }).catch((err) => {
@@ -32676,7 +32673,8 @@ var init_ContentfulConfigScreen = __esm({
32676
32673
  "cmaToken",
32677
32674
  "host",
32678
32675
  "defaultComponentDir",
32679
- "defaultTokenFile"
32676
+ "defaultTokenFile",
32677
+ "contentfulBaseDir"
32680
32678
  ];
32681
32679
  FIELD_LABELS = {
32682
32680
  spaceId: "Space ID",
@@ -32684,7 +32682,8 @@ var init_ContentfulConfigScreen = __esm({
32684
32682
  cmaToken: "CMA Token",
32685
32683
  host: "API Host (optional)",
32686
32684
  defaultComponentDir: "Default component directory (optional)",
32687
- defaultTokenFile: "Default token file (optional)"
32685
+ defaultTokenFile: "Default token file (optional)",
32686
+ contentfulBaseDir: "Default project directory, where .contentful goes (optional)"
32688
32687
  };
32689
32688
  }
32690
32689
  });
@@ -32928,7 +32927,7 @@ var app_exports = {};
32928
32927
  __export(app_exports, {
32929
32928
  runApp: () => runApp
32930
32929
  });
32931
- import { join as join28 } from "node:path";
32930
+ import { join as join27 } from "node:path";
32932
32931
  import { useEffect as useEffect27, useState as useState33 } from "react";
32933
32932
  import { Fragment as Fragment19, jsx as jsx59 } from "react/jsx-runtime";
32934
32933
  function App({ importOptions, inkClear }) {
@@ -32979,7 +32978,7 @@ function App({ importOptions, inkClear }) {
32979
32978
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
32980
32979
  const state = await inspectTokens({
32981
32980
  rawTokensPath: tokens,
32982
- outDir: join28(resolveUserPath(projectPath2), ".contentful"),
32981
+ outDir: join27(resolveUserPath(projectPath2), ".contentful"),
32983
32982
  cache: importOptions.cache
32984
32983
  });
32985
32984
  if (state.kind === "cached") {
@@ -33251,7 +33250,7 @@ var init_app = __esm({
33251
33250
 
33252
33251
  // packages/experience-design-system-cli/program.ts
33253
33252
  import { readFileSync as readFileSync9 } from "node:fs";
33254
- import { join as join29 } from "node:path";
33253
+ import { join as join28 } from "node:path";
33255
33254
  import { Command } from "commander";
33256
33255
 
33257
33256
  // packages/experience-design-system-cli/src/legacy/run-legacy.ts
@@ -33355,14 +33354,14 @@ function runDevWatch(args) {
33355
33354
  process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
33356
33355
  return Promise.resolve(1);
33357
33356
  }
33358
- return new Promise((resolve27) => {
33357
+ return new Promise((resolve26) => {
33359
33358
  const child = spawn2(process.execPath, [script, ...args], { stdio: "inherit" });
33360
33359
  process.on("SIGINT", () => void 0);
33361
- child.on("exit", (code) => resolve27(code ?? 0));
33360
+ child.on("exit", (code) => resolve26(code ?? 0));
33362
33361
  child.on("error", (err) => {
33363
33362
  process.stderr.write(`${err.message}
33364
33363
  `);
33365
- resolve27(1);
33364
+ resolve26(1);
33366
33365
  });
33367
33366
  });
33368
33367
  }
@@ -33387,7 +33386,7 @@ function registerImportCommand(program, openTui) {
33387
33386
  init_package_root();
33388
33387
  var pkg = JSON.parse(
33389
33388
  readFileSync9(
33390
- join29(findPackageRoot(import.meta.url, "@contentful/experience-design-system-cli"), "package.json"),
33389
+ join28(findPackageRoot(import.meta.url, "@contentful/experience-design-system-cli"), "package.json"),
33391
33390
  "utf8"
33392
33391
  )
33393
33392
  );
@@ -33406,8 +33405,8 @@ function createProgram() {
33406
33405
  init_config();
33407
33406
  init_package_root();
33408
33407
  import { existsSync as existsSync12 } from "node:fs";
33409
- import { mkdir as mkdir10, readFile as readFile19, rename as rename4, rmdir, unlink } from "node:fs/promises";
33410
- import { dirname as dirname16, join as join30 } from "node:path";
33408
+ import { mkdir as mkdir10, readFile as readFile19, rename as rename3, rmdir, unlink } from "node:fs/promises";
33409
+ import { dirname as dirname16, join as join29 } from "node:path";
33411
33410
  var PACKAGE_NAME4 = "@contentful/experience-design-system-cli";
33412
33411
  async function readJson(path5) {
33413
33412
  try {
@@ -33418,9 +33417,9 @@ async function readJson(path5) {
33418
33417
  }
33419
33418
  async function migrateOldConfig() {
33420
33419
  try {
33421
- const oldCredentials = join30(oldConfigDir2(), "credentials.json");
33422
- const oldRuns = join30(oldConfigDir2(), "runs.json");
33423
- const oldDebugMode = join30(
33420
+ const oldCredentials = join29(oldConfigDir2(), "credentials.json");
33421
+ const oldRuns = join29(oldConfigDir2(), "runs.json");
33422
+ const oldDebugMode = join29(
33424
33423
  findPackageRoot(import.meta.url, PACKAGE_NAME4),
33425
33424
  ".contentful",
33426
33425
  "config",
@@ -33434,7 +33433,7 @@ async function migrateOldConfig() {
33434
33433
  if (existsSync12(oldRuns)) {
33435
33434
  if (!existsSync12(runsFilePath2())) {
33436
33435
  await mkdir10(dirname16(runsFilePath2()), { recursive: true });
33437
- await rename4(oldRuns, runsFilePath2());
33436
+ await rename3(oldRuns, runsFilePath2());
33438
33437
  } else {
33439
33438
  await unlink(oldRuns);
33440
33439
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.37.1-dev-build-cffd984a.0",
3
+ "version": "2.37.1-dev-build-36f90a5a.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,12 +1,11 @@
1
1
  type Status = 'success' | 'error';
2
2
  type ExitMethod = 'saved' | 'discarded' | 'crashed';
3
- export declare function currentDebugSessionDir(): string;
3
+ export declare function currentDebugSessionDir(): string | undefined;
4
4
  /**
5
- * Moves this session's logs to `<outDir>/debug/sessions/<session>/`, next to the CDF, and writes there from now on.
6
- * Logs written before the project was known come along. Safe to call repeatedly; a different outDir moves them again.
7
- * Fail-open like the rest of the logger: if the move fails the logs stay where they were.
5
+ * Starts this terminal session's folder in `base`, unless a session already started somewhere else. Called when the
6
+ * user saves the base directory setting and when the import starts without one. Fail-open like the rest of the logger.
8
7
  */
9
- export declare function setDebugOutDir(outDir: string): Promise<void>;
8
+ export declare function startDebugSessionIn(base: string): Promise<void>;
10
9
  export declare function startDebugRun({ flow, step, menuOption, inputs, }: {
11
10
  flow: string;
12
11
  step: string;
@@ -5,6 +5,7 @@ export type V1Credentials = {
5
5
  host?: string;
6
6
  defaultComponentDir?: string;
7
7
  defaultTokenFile?: string;
8
+ contentfulBaseDir?: string;
8
9
  [key: string]: string | undefined;
9
10
  };
10
11
  export declare function readCredentials(): Promise<V1Credentials>;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.37.1-dev-build-cffd984a.0",
3
+ "version": "2.37.1-dev-build-36f90a5a.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.37.1-dev-build-cffd984a.0",
3
+ "version": "2.37.1-dev-build-36f90a5a.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,8 +45,8 @@
45
45
  "ts-morph": "^27.0.2",
46
46
  "typescript": "^5.9.3",
47
47
  "zod": "^4.6.5",
48
- "@contentful/experience-design-system-backend-pipeline": "2.37.1-dev-build-cffd984a.0",
49
- "@contentful/experience-design-system-types": "2.37.1-dev-build-cffd984a.0"
48
+ "@contentful/experience-design-system-types": "2.37.1-dev-build-36f90a5a.0",
49
+ "@contentful/experience-design-system-backend-pipeline": "2.37.1-dev-build-36f90a5a.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@tsconfig/node24": "^24.0.4",