@contentful/experience-design-system-cli 2.37.1-dev-build-a6ad74de.0 → 2.37.1-dev-build-ed4a0d5c.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
@@ -2082,7 +2082,7 @@ var init_cache_keys = __esm({
2082
2082
  });
2083
2083
 
2084
2084
  // packages/experience-design-system-types/dist/src/config/index.js
2085
- import { randomBytes as randomBytes3 } from "node:crypto";
2085
+ import { randomBytes as randomBytes4 } from "node:crypto";
2086
2086
  import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
2087
2087
  import { homedir as homedir3 } from "node:os";
2088
2088
  import { dirname as dirname13, join as join17 } from "node:path";
@@ -2099,7 +2099,7 @@ async function readSettings2() {
2099
2099
  async function writeSettings2(settings) {
2100
2100
  const path5 = configFilePath2();
2101
2101
  await mkdir6(dirname13(path5), { recursive: true });
2102
- const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
2102
+ const tmp = `${path5}.${process.pid}.${randomBytes4(4).toString("hex")}.tmp`;
2103
2103
  await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
2104
2104
  `, { mode: 384 });
2105
2105
  await rename2(tmp, path5);
@@ -4993,7 +4993,7 @@ async function getCliCacheVersion() {
4993
4993
  return _cliCacheVersionCache;
4994
4994
  }
4995
4995
  }
4996
- function storeExtractCache(db, filePath, fileHash, cliVersion, components) {
4996
+ function storeExtractCache(db, filePath, fileHash, cliVersion2, components) {
4997
4997
  const now = (/* @__PURE__ */ new Date()).toISOString();
4998
4998
  const componentsJson = JSON.stringify(components);
4999
4999
  db.prepare(`INSERT INTO extract_cache (file_path, file_hash, cli_version, created_at, updated_at, components_json)
@@ -5001,12 +5001,12 @@ function storeExtractCache(db, filePath, fileHash, cliVersion, components) {
5001
5001
  ON CONFLICT(file_hash, cli_version) DO UPDATE SET
5002
5002
  file_path = excluded.file_path,
5003
5003
  updated_at = excluded.updated_at,
5004
- components_json = excluded.components_json`).run(filePath, fileHash, cliVersion, now, now, componentsJson);
5004
+ components_json = excluded.components_json`).run(filePath, fileHash, cliVersion2, now, now, componentsJson);
5005
5005
  }
5006
- function lookupExtractCache(db, fileHash, cliVersion) {
5006
+ function lookupExtractCache(db, fileHash, cliVersion2) {
5007
5007
  const row = db.prepare(`SELECT file_path, file_hash, cli_version, created_at, updated_at, components_json
5008
5008
  FROM extract_cache
5009
- WHERE file_hash = ? AND cli_version = ?`).get(fileHash, cliVersion);
5009
+ WHERE file_hash = ? AND cli_version = ?`).get(fileHash, cliVersion2);
5010
5010
  if (!row)
5011
5011
  return null;
5012
5012
  let components = [];
@@ -5024,31 +5024,31 @@ function lookupExtractCache(db, fileHash, cliVersion) {
5024
5024
  components
5025
5025
  };
5026
5026
  }
5027
- function storeCompositionCache(db, inputHash, cliVersion, agentOutput) {
5027
+ function storeCompositionCache(db, inputHash, cliVersion2, agentOutput) {
5028
5028
  const now = (/* @__PURE__ */ new Date()).toISOString();
5029
5029
  db.prepare(`INSERT INTO composition_cache (input_hash, cli_version, agent_output, created_at, updated_at)
5030
5030
  VALUES (?, ?, ?, ?, ?)
5031
5031
  ON CONFLICT(input_hash, cli_version) DO UPDATE SET
5032
5032
  agent_output = excluded.agent_output,
5033
- updated_at = excluded.updated_at`).run(inputHash, cliVersion, agentOutput, now, now);
5033
+ updated_at = excluded.updated_at`).run(inputHash, cliVersion2, agentOutput, now, now);
5034
5034
  }
5035
- function lookupCompositionCache(db, inputHash, cliVersion) {
5036
- const row = db.prepare(`SELECT agent_output FROM composition_cache WHERE input_hash = ? AND cli_version = ?`).get(inputHash, cliVersion);
5035
+ function lookupCompositionCache(db, inputHash, cliVersion2) {
5036
+ const row = db.prepare(`SELECT agent_output FROM composition_cache WHERE input_hash = ? AND cli_version = ?`).get(inputHash, cliVersion2);
5037
5037
  return row ? row.agent_output : null;
5038
5038
  }
5039
- function storeSelectCache(db, componentHash, promptHash, cliVersion, decision, reason) {
5039
+ function storeSelectCache(db, componentHash, promptHash, cliVersion2, decision, reason) {
5040
5040
  const now = (/* @__PURE__ */ new Date()).toISOString();
5041
5041
  db.prepare(`INSERT INTO select_cache (component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at)
5042
5042
  VALUES (?, ?, ?, ?, ?, ?, ?)
5043
5043
  ON CONFLICT(component_hash, prompt_hash, cli_version) DO UPDATE SET
5044
5044
  decision = excluded.decision,
5045
5045
  reason = excluded.reason,
5046
- updated_at = excluded.updated_at`).run(componentHash, promptHash, cliVersion, decision, reason, now, now);
5046
+ updated_at = excluded.updated_at`).run(componentHash, promptHash, cliVersion2, decision, reason, now, now);
5047
5047
  }
5048
- function lookupSelectCache(db, componentHash, promptHash, cliVersion) {
5048
+ function lookupSelectCache(db, componentHash, promptHash, cliVersion2) {
5049
5049
  const row = db.prepare(`SELECT component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at
5050
5050
  FROM select_cache
5051
- WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`).get(componentHash, promptHash, cliVersion);
5051
+ WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`).get(componentHash, promptHash, cliVersion2);
5052
5052
  if (!row)
5053
5053
  return null;
5054
5054
  return {
@@ -13140,6 +13140,60 @@ async function loadAcceptedNames(sessionId) {
13140
13140
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/index.js
13141
13141
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
13142
13142
 
13143
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/helpers/generate-session-id.js
13144
+ import { randomBytes as randomBytes3 } from "node:crypto";
13145
+ var ADJECTIVES2 = [
13146
+ "bright",
13147
+ "calm",
13148
+ "dark",
13149
+ "fast",
13150
+ "green",
13151
+ "happy",
13152
+ "keen",
13153
+ "light",
13154
+ "long",
13155
+ "loud",
13156
+ "pale",
13157
+ "quick",
13158
+ "sharp",
13159
+ "slow",
13160
+ "soft",
13161
+ "warm",
13162
+ "wild",
13163
+ "wise"
13164
+ ];
13165
+ var NOUNS2 = [
13166
+ "cloud",
13167
+ "creek",
13168
+ "dawn",
13169
+ "dusk",
13170
+ "field",
13171
+ "flame",
13172
+ "frost",
13173
+ "grove",
13174
+ "hill",
13175
+ "lake",
13176
+ "leaf",
13177
+ "moon",
13178
+ "peak",
13179
+ "rain",
13180
+ "river",
13181
+ "rock",
13182
+ "snow",
13183
+ "star",
13184
+ "storm",
13185
+ "tide",
13186
+ "tree",
13187
+ "wave",
13188
+ "wind"
13189
+ ];
13190
+ function generateSessionId2() {
13191
+ const adj = ADJECTIVES2[Math.floor(Math.random() * ADJECTIVES2.length)];
13192
+ const noun = NOUNS2[Math.floor(Math.random() * NOUNS2.length)];
13193
+ const hex = randomBytes3(2).toString("hex");
13194
+ return `${adj}-${noun}-${hex}`;
13195
+ }
13196
+
13143
13197
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/migration.js
13144
13198
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
13145
13199
 
@@ -14945,6 +14999,201 @@ function loadTokenLeaves(db, sessionId) {
14945
14999
  return db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId);
14946
15000
  }
14947
15001
 
15002
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/client/cli-info.js
15003
+ var cliVersionString = "0.0.0-unknown";
15004
+ function cliVersion() {
15005
+ return cliVersionString;
15006
+ }
15007
+
15008
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/client/opt-out.js
15009
+ var persistedDisabled = false;
15010
+ function analyticsEnabled() {
15011
+ return !persistedDisabled && !process.env["DISABLE_ANALYTICS"];
15012
+ }
15013
+
15014
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/client/segment-client.js
15015
+ import { Analytics } from "@segment/analytics-node";
15016
+ var DEFAULT_WRITE_KEY = "6DmxiEPN3SV1vbRTTMcNqDzCvkfwT06N";
15017
+ var analyticsClient = null;
15018
+ function resolveWriteKey() {
15019
+ const key = (process.env["SEGMENT_WRITE_KEY"] ?? "").trim();
15020
+ return key.length > 0 ? key : DEFAULT_WRITE_KEY;
15021
+ }
15022
+ function getClient() {
15023
+ if (!analyticsEnabled())
15024
+ return null;
15025
+ const writeKey = resolveWriteKey();
15026
+ if (!writeKey)
15027
+ return null;
15028
+ if (!analyticsClient) {
15029
+ analyticsClient = new Analytics({ writeKey });
15030
+ analyticsClient.on("error", () => {
15031
+ });
15032
+ }
15033
+ return analyticsClient;
15034
+ }
15035
+ async function trackEvent(event, properties, anonymousId, options) {
15036
+ const client2 = getClient();
15037
+ if (!client2)
15038
+ return;
15039
+ try {
15040
+ client2.track({
15041
+ event,
15042
+ properties,
15043
+ anonymousId,
15044
+ timestamp: /* @__PURE__ */ new Date()
15045
+ });
15046
+ if (options?.flush)
15047
+ await flushAnalytics();
15048
+ } catch {
15049
+ }
15050
+ }
15051
+ async function flushAnalytics() {
15052
+ if (!analyticsClient)
15053
+ return;
15054
+ try {
15055
+ await analyticsClient.closeAndFlush();
15056
+ } catch {
15057
+ } finally {
15058
+ analyticsClient = null;
15059
+ }
15060
+ }
15061
+
15062
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/constants.js
15063
+ var ANALYTICS_SESSION_ENV = "EDS_ANALYTICS_SESSION_ID";
15064
+ var IMPORT_PIPELINE_ENV = "EDS_IMPORT_PIPELINE";
15065
+
15066
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/session.js
15067
+ function resolveAnalyticsSessionId(explicit) {
15068
+ const inherited = process.env[ANALYTICS_SESSION_ENV]?.trim();
15069
+ if (inherited)
15070
+ return inherited;
15071
+ const passed = explicit?.trim();
15072
+ if (passed)
15073
+ return passed;
15074
+ return generateSessionId2();
15075
+ }
15076
+ function isPipelineAnalyticsChild() {
15077
+ return Boolean(process.env[ANALYTICS_SESSION_ENV]?.trim());
15078
+ }
15079
+
15080
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/tracker/pending-command.js
15081
+ var state = {
15082
+ pending: null,
15083
+ sessionId: void 0,
15084
+ sessionStartedEmitted: false
15085
+ };
15086
+ function isPipelineStep() {
15087
+ return process.env[IMPORT_PIPELINE_ENV] === "1";
15088
+ }
15089
+ function buildBaseProps(command) {
15090
+ return {
15091
+ dsi_session_id: state.sessionId,
15092
+ command,
15093
+ ...isPipelineStep() ? { is_pipeline_step: true } : {}
15094
+ };
15095
+ }
15096
+ function mergeContext(target, source) {
15097
+ if (source.space_key !== void 0)
15098
+ target.space_key = source.space_key;
15099
+ if (source.environment_key !== void 0)
15100
+ target.environment_key = source.environment_key;
15101
+ if (source.x_contentful_request_id !== void 0) {
15102
+ target.x_contentful_request_id = source.x_contentful_request_id;
15103
+ }
15104
+ }
15105
+ function setCommandContext(context) {
15106
+ if (!state.pending)
15107
+ return;
15108
+ mergeContext(state.pending.context, context);
15109
+ mergeContext(state.pending.completion, context);
15110
+ }
15111
+ function enrichCommandResult(fields) {
15112
+ if (!state.pending)
15113
+ return;
15114
+ Object.assign(state.pending.completion, fields);
15115
+ mergeContext(state.pending.context, fields);
15116
+ }
15117
+
15118
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/os.js
15119
+ var OS_NAMES2 = {
15120
+ android: "Android",
15121
+ aix: "Linux",
15122
+ darwin: "macOS",
15123
+ freebsd: "Linux",
15124
+ linux: "Linux",
15125
+ openbsd: "Linux",
15126
+ sunos: "Linux",
15127
+ win32: "Windows"
15128
+ };
15129
+ function getOsName() {
15130
+ return OS_NAMES2[process.platform] ?? "other";
15131
+ }
15132
+
15133
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/tracker/emit-events.js
15134
+ async function bindAnalyticsSessionId(explicit, context) {
15135
+ const id = resolveAnalyticsSessionId(explicit);
15136
+ await bindAnalyticsSession(id, context);
15137
+ return id;
15138
+ }
15139
+ async function bindAnalyticsSession(id, context) {
15140
+ state.sessionId = id;
15141
+ if (context)
15142
+ setCommandContext(context);
15143
+ await emitInvokedIfReady();
15144
+ }
15145
+ async function emitSessionStarted(entryCommand) {
15146
+ if (!state.sessionId || state.sessionStartedEmitted)
15147
+ return;
15148
+ state.sessionStartedEmitted = true;
15149
+ await trackEvent("dsi_cli_session_started", {
15150
+ dsi_session_id: state.sessionId,
15151
+ entry_command: entryCommand,
15152
+ cli_version: cliVersion(),
15153
+ node_version: process.version,
15154
+ os_name: getOsName()
15155
+ }, state.sessionId, { flush: true });
15156
+ await emitInvokedIfReady();
15157
+ }
15158
+ async function emitInvokedIfReady() {
15159
+ if (!state.pending || state.pending.invoked || !state.sessionId)
15160
+ return;
15161
+ state.pending.invoked = true;
15162
+ await trackEvent("dsi_cli_command_invoked", {
15163
+ ...buildBaseProps(state.pending.command),
15164
+ ...state.pending.context
15165
+ }, state.sessionId, { flush: true });
15166
+ }
15167
+
15168
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/apply.js
15169
+ function countWriteResult(items, entityType) {
15170
+ const subset = items.filter((item) => item.entityType === entityType);
15171
+ return {
15172
+ created_count: subset.filter((item) => item.action === "create" && item.status === "succeeded").length,
15173
+ updated_count: subset.filter((item) => item.action === "update" && item.status === "succeeded").length,
15174
+ failed_count: subset.filter((item) => item.status === "failed").length
15175
+ };
15176
+ }
15177
+ function recordApplyOutcome(client2, spaceId, environmentId, operation) {
15178
+ setCommandContext({
15179
+ space_key: spaceId,
15180
+ environment_key: environmentId,
15181
+ x_contentful_request_id: client2.getLastRequestId()
15182
+ });
15183
+ enrichCommandResult({
15184
+ dsi_operation_id: operation.sys.id,
15185
+ component_type_result: countWriteResult(operation.items ?? [], "ComponentType"),
15186
+ design_token_result: countWriteResult(operation.items ?? [], "DesignToken")
15187
+ });
15188
+ }
15189
+ function recordContentfulContext(client2, spaceId, environmentId) {
15190
+ setCommandContext({
15191
+ space_key: spaceId,
15192
+ environment_key: environmentId,
15193
+ x_contentful_request_id: client2.getLastRequestId()
15194
+ });
15195
+ }
15196
+
14948
15197
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/run-map-tokens.js
14949
15198
  var DEFAULT_TIMEOUT_MS2 = 5 * 60 * 1e3;
14950
15199
  var MapTokensRunFailure = class _MapTokensRunFailure extends Error {
@@ -14974,6 +15223,7 @@ async function runMapTokens(request) {
14974
15223
  if (!sessionId) {
14975
15224
  throw new MapTokensRunFailure({ type: "no-session" });
14976
15225
  }
15226
+ await bindAnalyticsSessionId(sessionId);
14977
15227
  const tokenLeaves = loadTokenLeaves(db, sessionId);
14978
15228
  const knownTokenPaths = new Set(tokenLeaves.map((t) => t.path));
14979
15229
  if (request.tokenMapInline) {
@@ -16287,6 +16537,9 @@ async function runExtractAndComposeSession(request) {
16287
16537
  outDir
16288
16538
  });
16289
16539
  await onSessionCreated?.(sessionId);
16540
+ await bindAnalyticsSessionId(sessionId);
16541
+ if (!isPipelineAnalyticsChild())
16542
+ await emitSessionStarted("import");
16290
16543
  const stepId = createStep(db, sessionId, "analyze extract", { project: projectPath });
16291
16544
  if (cacheHits === 0 && !noCache) {
16292
16545
  await persistExtractCache(db, sourceFiles, extraction.components, cacheVersion);
@@ -16314,6 +16567,7 @@ async function runExtractAndComposeSession(request) {
16314
16567
  await persistSlotCycles(db, sessionId, composition.components);
16315
16568
  storeScannedFiles(db, sessionId, sourceFiles.map((f) => relative2(projectPath, f)));
16316
16569
  await retryDatabaseWrite(() => updateStep(db, stepId, "complete", { sessionId }));
16570
+ enrichCommandResult({ extracted_component_count: composition.components.length });
16317
16571
  return {
16318
16572
  sessionId,
16319
16573
  compositionPhase: composition.phase,
@@ -16376,6 +16630,7 @@ async function runGenerateTokensSession(request) {
16376
16630
  outDir
16377
16631
  });
16378
16632
  await onSessionCreated?.(tokenSessionId);
16633
+ await bindAnalyticsSessionId(tokenSessionId);
16379
16634
  const tokenPromptHash = await hashPromptForSkill("tokens", agent, agentModel, skillPath);
16380
16635
  const warnings = [];
16381
16636
  onProgress?.({ kind: "resolving" });
@@ -16752,6 +17007,7 @@ async function runGenerateComponentsSession(request) {
16752
17007
  const existingTokensHash = existingTokensInline ? [hashContent(existingTokensInline)] : [];
16753
17008
  const agent = request.agent;
16754
17009
  const promptHash = await hashPromptForSkill("components", agent, request.agentModel, effectiveSkillPath, existingTokensHash, prompt.text);
17010
+ await bindAnalyticsSessionId(request.sessionId);
16755
17011
  const db = openPipelineDb();
16756
17012
  try {
16757
17013
  const acceptedNames = await loadAcceptedNames(request.sessionId);
@@ -17514,13 +17770,13 @@ async function runSelection(options) {
17514
17770
  const db = openPipelineDb();
17515
17771
  let components;
17516
17772
  const cachedDecisions = /* @__PURE__ */ new Map();
17517
- const cliVersion = await getCliCacheVersion();
17773
+ const cliVersion2 = await getCliCacheVersion();
17518
17774
  const promptHash = await hashSelectPrompt(options);
17519
17775
  try {
17520
17776
  components = loadRawComponents(db, options.sessionId);
17521
17777
  if (!options.noCache) {
17522
17778
  for (const component of components) {
17523
- const cached = lookupSelectCache(db, hashComponentShape(component), promptHash, cliVersion);
17779
+ const cached = lookupSelectCache(db, hashComponentShape(component), promptHash, cliVersion2);
17524
17780
  if (cached) cachedDecisions.set(component.name, { decision: cached.decision, reason: cached.reason });
17525
17781
  }
17526
17782
  }
@@ -17575,7 +17831,7 @@ async function runSelection(options) {
17575
17831
  writeDb,
17576
17832
  hashComponentShape(component),
17577
17833
  promptHash,
17578
- cliVersion,
17834
+ cliVersion2,
17579
17835
  rejected ? "rejected" : "accepted",
17580
17836
  rejected ? reason : null
17581
17837
  );
@@ -17735,7 +17991,7 @@ async function resolveSelectionPrompt(overrides) {
17735
17991
 
17736
17992
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
17737
17993
  function useExtraction(input) {
17738
- const [state, setState] = useState8();
17994
+ const [state2, setState] = useState8();
17739
17995
  const current = useRef2();
17740
17996
  useEffect5(() => {
17741
17997
  current.current = input;
@@ -17760,7 +18016,7 @@ function useExtraction(input) {
17760
18016
  if (current.current === input) current.current = void 0;
17761
18017
  };
17762
18018
  }, [input]);
17763
- return state;
18019
+ return state2;
17764
18020
  }
17765
18021
 
17766
18022
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx
@@ -19867,62 +20123,62 @@ function buildFlatDimPredicate(input) {
19867
20123
  }
19868
20124
 
19869
20125
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/state.ts
19870
- function apply(state, entries) {
19871
- const next = new Map(state);
20126
+ function apply(state2, entries) {
20127
+ const next = new Map(state2);
19872
20128
  for (const [name, decision] of entries) next.set(name, decision);
19873
20129
  return next;
19874
20130
  }
19875
- function reduceDecisions(state, action, components, graph) {
20131
+ function reduceDecisions(state2, action, components, graph) {
19876
20132
  switch (action.type) {
19877
20133
  case "accept": {
19878
- if (state.get(action.name) === "accepted") return state;
20134
+ if (state2.get(action.name) === "accepted") return state2;
19879
20135
  return apply(
19880
- state,
20136
+ state2,
19881
20137
  acceptCascade(graph, action.name).map((name) => [name, "accepted"])
19882
20138
  );
19883
20139
  }
19884
20140
  case "reject": {
19885
- if (state.get(action.name) === "rejected") return state;
20141
+ if (state2.get(action.name) === "rejected") return state2;
19886
20142
  const { toReject, toDeselect } = rejectCascade(graph, action.name);
19887
- return apply(state, [
20143
+ return apply(state2, [
19888
20144
  ...toReject.map((name) => [name, "rejected"]),
19889
20145
  ...toDeselect.map((name) => [name, "undecided"])
19890
20146
  ]);
19891
20147
  }
19892
20148
  case "toggle-all": {
19893
20149
  const nonCycle = components.filter((c2) => !graph.cycleParticipants.has(c2.name)).map((c2) => c2.name);
19894
- const anyNotAccepted = nonCycle.some((name) => state.get(name) !== "accepted");
20150
+ const anyNotAccepted = nonCycle.some((name) => state2.get(name) !== "accepted");
19895
20151
  if (anyNotAccepted) {
19896
- return apply(state, [
20152
+ return apply(state2, [
19897
20153
  ...nonCycle.map((name) => [name, "accepted"]),
19898
20154
  ...reachableCycleMembers(graph, nonCycle).map((name) => [name, "accepted"])
19899
20155
  ]);
19900
20156
  }
19901
- return apply(state, [
20157
+ return apply(state2, [
19902
20158
  ...nonCycle.map((name) => [name, "rejected"]),
19903
- ...components.filter((c2) => graph.cycleParticipants.has(c2.name) && state.get(c2.name) === "accepted").map((c2) => [c2.name, "undecided"])
20159
+ ...components.filter((c2) => graph.cycleParticipants.has(c2.name) && state2.get(c2.name) === "accepted").map((c2) => [c2.name, "undecided"])
19904
20160
  ]);
19905
20161
  }
19906
20162
  case "accept-unflagged": {
19907
20163
  const seeds = components.filter((c2) => !graph.cycleParticipants.has(c2.name) && !isAiFlagged(c2)).map((c2) => c2.name);
19908
- return apply(state, [
20164
+ return apply(state2, [
19909
20165
  ...seeds.map((name) => [name, "accepted"]),
19910
20166
  ...reachableCycleMembers(graph, seeds).map((name) => [name, "accepted"])
19911
20167
  ]);
19912
20168
  }
19913
20169
  }
19914
20170
  }
19915
- function rejectNeedsConfirmation(graph, name, state) {
19916
- if (state.get(name) === "rejected") return false;
20171
+ function rejectNeedsConfirmation(graph, name, state2) {
20172
+ if (state2.get(name) === "rejected") return false;
19917
20173
  const { toReject, toDeselect } = rejectCascade(graph, name);
19918
20174
  const ancestors = toReject.filter((n) => n !== name);
19919
20175
  return ancestors.length + toDeselect.length >= 2;
19920
20176
  }
19921
- function partitionDecisions(components, state) {
20177
+ function partitionDecisions(components, state2) {
19922
20178
  const accepted = [];
19923
20179
  const rejected = [];
19924
20180
  for (const c2 of components) {
19925
- if (state.get(c2.name) === "accepted") accepted.push(c2.name);
20181
+ if (state2.get(c2.name) === "accepted") accepted.push(c2.name);
19926
20182
  else rejected.push(c2.name);
19927
20183
  }
19928
20184
  return { accepted, rejected };
@@ -20817,7 +21073,7 @@ function applyProgressEvent2(event, previous, total) {
20817
21073
 
20818
21074
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
20819
21075
  function useGeneration(input) {
20820
- const [state, setState] = useState14();
21076
+ const [state2, setState] = useState14();
20821
21077
  const current = useRef6();
20822
21078
  useEffect9(() => {
20823
21079
  current.current = input;
@@ -20835,7 +21091,7 @@ function useGeneration(input) {
20835
21091
  if (current.current === input) current.current = void 0;
20836
21092
  };
20837
21093
  }, [input]);
20838
- return state;
21094
+ return state2;
20839
21095
  }
20840
21096
 
20841
21097
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
@@ -21600,7 +21856,7 @@ function parseToState(json) {
21600
21856
  });
21601
21857
  return { state: { componentDescription, props, slots }, error: null };
21602
21858
  }
21603
- function serializeState(state, originalJson) {
21859
+ function serializeState(state2, originalJson) {
21604
21860
  let wrapperKey = null;
21605
21861
  try {
21606
21862
  const orig = JSON.parse(originalJson);
@@ -21614,7 +21870,7 @@ function serializeState(state, originalJson) {
21614
21870
  } catch {
21615
21871
  }
21616
21872
  const $properties = {};
21617
- for (const p of state.props) {
21873
+ for (const p of state2.props) {
21618
21874
  const def = {
21619
21875
  $type: p.type,
21620
21876
  $category: p.category
@@ -21637,10 +21893,10 @@ function serializeState(state, originalJson) {
21637
21893
  $type: "component",
21638
21894
  $properties
21639
21895
  };
21640
- if (state.componentDescription) entry.$description = state.componentDescription;
21641
- if (state.slots.length > 0) {
21896
+ if (state2.componentDescription) entry.$description = state2.componentDescription;
21897
+ if (state2.slots.length > 0) {
21642
21898
  entry.$slots = {};
21643
- for (const s of state.slots) {
21899
+ for (const s of state2.slots) {
21644
21900
  const slotDef = {};
21645
21901
  if (s.description) slotDef.$description = s.description;
21646
21902
  if (s.required) slotDef.$required = true;
@@ -24730,71 +24986,71 @@ function ReviewReloadDialog({ open }) {
24730
24986
 
24731
24987
  // packages/experience-design-system-cli/src/tui/import/steps/09-review/review-input.ts
24732
24988
  var PANEL_CONTENT_HEIGHT = 12;
24733
- function handleReviewOverlayInput(input, key, state) {
24734
- if (state.loading) return true;
24735
- if (state.loadError) {
24736
- if (input === "q" || key.escape || key.return) state.onQuit();
24989
+ function handleReviewOverlayInput(input, key, state2) {
24990
+ if (state2.loading) return true;
24991
+ if (state2.loadError) {
24992
+ if (input === "q" || key.escape || key.return) state2.onQuit();
24737
24993
  return true;
24738
24994
  }
24739
- if (state.showFinalize) {
24995
+ if (state2.showFinalize) {
24740
24996
  if (key.downArrow) {
24741
- state.finalizePreview.scrollBy(1);
24997
+ state2.finalizePreview.scrollBy(1);
24742
24998
  return true;
24743
24999
  }
24744
25000
  if (key.upArrow) {
24745
- state.finalizePreview.scrollBy(-1);
25001
+ state2.finalizePreview.scrollBy(-1);
24746
25002
  return true;
24747
25003
  }
24748
25004
  return true;
24749
25005
  }
24750
- if (state.dialogOpen || state.showHelp) return true;
24751
- if (state.showReloadDialog) {
25006
+ if (state2.dialogOpen || state2.showHelp) return true;
25007
+ if (state2.showReloadDialog) {
24752
25008
  if (key.return) {
24753
- state.reloadFromSave();
24754
- state.setShowReloadDialog(false);
25009
+ state2.reloadFromSave();
25010
+ state2.setShowReloadDialog(false);
24755
25011
  return true;
24756
25012
  }
24757
25013
  if (key.escape) {
24758
- state.setShowReloadDialog(false);
25014
+ state2.setShowReloadDialog(false);
24759
25015
  return true;
24760
25016
  }
24761
25017
  return true;
24762
25018
  }
24763
25019
  if (key.ctrl && input === "z") {
24764
- state.handleUndo();
25020
+ state2.handleUndo();
24765
25021
  return true;
24766
25022
  }
24767
25023
  if (key.ctrl && input === "y") {
24768
- state.handleRedo();
25024
+ state2.handleRedo();
24769
25025
  return true;
24770
25026
  }
24771
25027
  if (key.ctrl && input === "r") {
24772
- state.setShowReloadDialog(true);
25028
+ state2.setShowReloadDialog(true);
24773
25029
  return true;
24774
25030
  }
24775
25031
  return false;
24776
25032
  }
24777
- function handleTokenReviewInput(input, key, state) {
24778
- if (state.panelOpen !== "token-review") return false;
24779
- const suggestions = state.currentTokenSuggestions();
24780
- const row = suggestions[state.tokenReviewRow];
24781
- if (state.tokenReviewEditing) {
25033
+ function handleTokenReviewInput(input, key, state2) {
25034
+ if (state2.panelOpen !== "token-review") return false;
25035
+ const suggestions = state2.currentTokenSuggestions();
25036
+ const row = suggestions[state2.tokenReviewRow];
25037
+ if (state2.tokenReviewEditing) {
24782
25038
  if (key.ctrl && input === "s" && row) {
24783
- state.handleTokenEditSave(row);
25039
+ state2.handleTokenEditSave(row);
24784
25040
  return true;
24785
25041
  }
24786
25042
  if (row && row.paths.length > 0) {
24787
25043
  if (key.upArrow || input === "k") {
24788
- state.setTokenReviewEditCursor((cursor) => Math.max(0, cursor - 1));
25044
+ state2.setTokenReviewEditCursor((cursor) => Math.max(0, cursor - 1));
24789
25045
  return true;
24790
25046
  }
24791
25047
  if (key.downArrow || input === "j") {
24792
- state.setTokenReviewEditCursor((cursor) => Math.min(row.paths.length - 1, cursor + 1));
25048
+ state2.setTokenReviewEditCursor((cursor) => Math.min(row.paths.length - 1, cursor + 1));
24793
25049
  return true;
24794
25050
  }
24795
25051
  if (input === " " || key.return) {
24796
- const path5 = row.paths[state.tokenReviewEditCursor];
24797
- state.setTokenReviewEditSelection((previous) => {
25052
+ const path5 = row.paths[state2.tokenReviewEditCursor];
25053
+ state2.setTokenReviewEditSelection((previous) => {
24798
25054
  const next = new Set(previous);
24799
25055
  if (next.has(path5) && next.size === 1) return next;
24800
25056
  if (next.has(path5)) next.delete(path5);
@@ -24805,34 +25061,34 @@ function handleTokenReviewInput(input, key, state) {
24805
25061
  }
24806
25062
  }
24807
25063
  if (key.escape) {
24808
- state.setTokenReviewEditing(false);
25064
+ state2.setTokenReviewEditing(false);
24809
25065
  return true;
24810
25066
  }
24811
25067
  return true;
24812
25068
  }
24813
25069
  if (key.upArrow || input === "k") {
24814
- state.setTokenReviewRow((rowIndex) => Math.max(0, rowIndex - 1));
25070
+ state2.setTokenReviewRow((rowIndex) => Math.max(0, rowIndex - 1));
24815
25071
  return true;
24816
25072
  }
24817
25073
  if (key.downArrow || input === "j") {
24818
- state.setTokenReviewRow((rowIndex) => Math.min(Math.max(0, suggestions.length - 1), rowIndex + 1));
25074
+ state2.setTokenReviewRow((rowIndex) => Math.min(Math.max(0, suggestions.length - 1), rowIndex + 1));
24819
25075
  return true;
24820
25076
  }
24821
25077
  if (key.return && row) {
24822
- state.setTokenReviewEditCursor(0);
24823
- state.setTokenReviewEditSelection(new Set(row.allowed));
24824
- state.setTokenReviewEditing(true);
25078
+ state2.setTokenReviewEditCursor(0);
25079
+ state2.setTokenReviewEditSelection(new Set(row.allowed));
25080
+ state2.setTokenReviewEditing(true);
24825
25081
  return true;
24826
25082
  }
24827
25083
  if (key.escape || input === "t") {
24828
- state.setPanelOpen("none");
25084
+ state2.setPanelOpen("none");
24829
25085
  return true;
24830
25086
  }
24831
25087
  return true;
24832
25088
  }
24833
- function setReviewPanel(state, panel) {
24834
- state.setPanelOpen(panel);
24835
- state.setPanelScrollOffset(() => 0);
25089
+ function setReviewPanel(state2, panel) {
25090
+ state2.setPanelOpen(panel);
25091
+ state2.setPanelScrollOffset(() => 0);
24836
25092
  }
24837
25093
  function rationalePanelForInput(input, propKey, componentKey) {
24838
25094
  if (input === propKey) return "prop-rationale";
@@ -24840,70 +25096,70 @@ function rationalePanelForInput(input, propKey, componentKey) {
24840
25096
  if (input === "s") return "source";
24841
25097
  return null;
24842
25098
  }
24843
- function handleRationalePanelInput(input, key, state) {
24844
- if (state.panelOpen === "none" || state.panelOpen === "token-review") return false;
24845
- const next = computeNextScrollOffset(state.panelScrollOffset, input, key, 9999, PANEL_CONTENT_HEIGHT);
25099
+ function handleRationalePanelInput(input, key, state2) {
25100
+ if (state2.panelOpen === "none" || state2.panelOpen === "token-review") return false;
25101
+ const next = computeNextScrollOffset(state2.panelScrollOffset, input, key, 9999, PANEL_CONTENT_HEIGHT);
24846
25102
  if (next !== null) {
24847
- state.setPanelScrollOffset(() => next);
25103
+ state2.setPanelScrollOffset(() => next);
24848
25104
  return true;
24849
25105
  }
24850
25106
  if (key.escape) {
24851
- setReviewPanel(state, "none");
25107
+ setReviewPanel(state2, "none");
24852
25108
  return true;
24853
25109
  }
24854
25110
  const togglable = !key.ctrl && !key.tab && !key.meta && !key.return;
24855
25111
  if (!togglable) return true;
24856
- const panel = rationalePanelForInput(input, state.propKey, state.componentKey);
24857
- if (panel) setReviewPanel(state, state.panelOpen === panel ? "none" : panel);
25112
+ const panel = rationalePanelForInput(input, state2.propKey, state2.componentKey);
25113
+ if (panel) setReviewPanel(state2, state2.panelOpen === panel ? "none" : panel);
24858
25114
  return true;
24859
25115
  }
24860
- function handleReviewPanelShortcuts(input, key, state) {
24861
- if (handleTokenReviewInput(input, key, state)) return true;
24862
- if (handleRationalePanelInput(input, key, state)) return true;
24863
- const rationaleKeyOk = !state.textEntryActive && !state.showJson && !key.ctrl && !key.tab && !key.meta && !key.return;
25116
+ function handleReviewPanelShortcuts(input, key, state2) {
25117
+ if (handleTokenReviewInput(input, key, state2)) return true;
25118
+ if (handleRationalePanelInput(input, key, state2)) return true;
25119
+ const rationaleKeyOk = !state2.textEntryActive && !state2.showJson && !key.ctrl && !key.tab && !key.meta && !key.return;
24864
25120
  if (!rationaleKeyOk) return false;
24865
- const panel = rationalePanelForInput(input, state.propKey, state.componentKey);
25121
+ const panel = rationalePanelForInput(input, state2.propKey, state2.componentKey);
24866
25122
  if (panel) {
24867
- setReviewPanel(state, panel);
25123
+ setReviewPanel(state2, panel);
24868
25124
  return true;
24869
25125
  }
24870
- if (input === "t" && state.currentTokenSuggestions().length > 0) {
24871
- state.setPanelOpen("token-review");
24872
- state.setTokenReviewRow(0);
25126
+ if (input === "t" && state2.currentTokenSuggestions().length > 0) {
25127
+ state2.setPanelOpen("token-review");
25128
+ state2.setTokenReviewRow(0);
24873
25129
  return true;
24874
25130
  }
24875
25131
  return false;
24876
25132
  }
24877
- function handleReviewViewToggleInput(input, state) {
25133
+ function handleReviewViewToggleInput(input, state2) {
24878
25134
  if (input === "J") {
24879
- state.setShowJson((previous) => !previous);
24880
- state.setJsonScrollOffset(0);
24881
- state.pendingGRef.current = false;
25135
+ state2.setShowJson((previous) => !previous);
25136
+ state2.setJsonScrollOffset(0);
25137
+ state2.pendingGRef.current = false;
24882
25138
  return true;
24883
25139
  }
24884
25140
  return false;
24885
25141
  }
24886
- function handleJsonPanelInput(input, key, state) {
24887
- if (state.sidebarFocused || !state.showJson) return false;
24888
- const totalLines = state.jsonValue.split("\n").length;
24889
- const maxOffset = Math.max(0, totalLines - state.height);
25142
+ function handleJsonPanelInput(input, key, state2) {
25143
+ if (state2.sidebarFocused || !state2.showJson) return false;
25144
+ const totalLines = state2.jsonValue.split("\n").length;
25145
+ const maxOffset = Math.max(0, totalLines - state2.height);
24890
25146
  if (input === "g" && !key.ctrl) {
24891
- if (state.pendingGRef.current) {
24892
- state.pendingGRef.current = false;
24893
- state.setJsonScrollOffset(() => 0);
25147
+ if (state2.pendingGRef.current) {
25148
+ state2.pendingGRef.current = false;
25149
+ state2.setJsonScrollOffset(() => 0);
24894
25150
  return true;
24895
25151
  }
24896
- state.pendingGRef.current = true;
25152
+ state2.pendingGRef.current = true;
24897
25153
  return true;
24898
25154
  }
24899
- const next = computeNextScrollOffset(state.jsonScrollOffset, input, key, totalLines, state.height);
25155
+ const next = computeNextScrollOffset(state2.jsonScrollOffset, input, key, totalLines, state2.height);
24900
25156
  if (next !== null) {
24901
- state.pendingGRef.current = false;
25157
+ state2.pendingGRef.current = false;
24902
25158
  const clamped = Math.min(maxOffset, Math.max(0, next));
24903
- state.setJsonScrollOffset(() => clamped);
25159
+ state2.setJsonScrollOffset(() => clamped);
24904
25160
  return true;
24905
25161
  }
24906
- state.pendingGRef.current = false;
25162
+ state2.pendingGRef.current = false;
24907
25163
  return true;
24908
25164
  }
24909
25165
 
@@ -27253,38 +27509,38 @@ function buildRunTeaserLine(runId) {
27253
27509
 
27254
27510
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
27255
27511
  import { jsx as jsx52, jsxs as jsxs42 } from "react/jsx-runtime";
27256
- function totalStepsFor(state) {
27257
- const hasTokenStage = !!state.tokensPath || !!state.rawTokensPath;
27258
- return 3 + (hasTokenStage ? 1 : 0) + 2 + (state.mapTokensEligible === true ? 1 : 0);
27512
+ function totalStepsFor(state2) {
27513
+ const hasTokenStage = !!state2.tokensPath || !!state2.rawTokensPath;
27514
+ return 3 + (hasTokenStage ? 1 : 0) + 2 + (state2.mapTokensEligible === true ? 1 : 0);
27259
27515
  }
27260
27516
  function canEditFromPreview(cdf) {
27261
27517
  if (!cdf) return false;
27262
27518
  return parseCDFComponents(cdf).components.length > 0;
27263
27519
  }
27264
27520
  function FlowScreen({
27265
- state,
27521
+ state: state2,
27266
27522
  controller,
27267
27523
  livePreview = true,
27268
27524
  generatePromptPath,
27269
27525
  onExit
27270
27526
  }) {
27271
- const totalSteps = totalStepsFor(state);
27527
+ const totalSteps = totalStepsFor(state2);
27272
27528
  const quit = () => onExit(0);
27273
27529
  const content = (() => {
27274
- switch (state.step) {
27530
+ switch (state2.step) {
27275
27531
  case "final-review":
27276
27532
  return /* @__PURE__ */ jsx52(
27277
27533
  GenerateReviewStep,
27278
27534
  {
27279
- extractSessionId: state.extractSessionId,
27280
- tokenSessionId: state.tokenSessionId,
27535
+ extractSessionId: state2.extractSessionId,
27536
+ tokenSessionId: state2.tokenSessionId,
27281
27537
  livePreview,
27282
- spaceId: state.spaceId,
27283
- environmentId: state.environmentId,
27284
- cmaToken: state.cmaToken,
27285
- host: state.host,
27286
- tokensPath: state.tokensPath,
27287
- initialFinalizeError: state.finalizeErrorBanner,
27538
+ spaceId: state2.spaceId,
27539
+ environmentId: state2.environmentId,
27540
+ cmaToken: state2.cmaToken,
27541
+ host: state2.host,
27542
+ tokensPath: state2.tokensPath,
27543
+ initialFinalizeError: state2.finalizeErrorBanner,
27288
27544
  onFinalize: controller.finalize,
27289
27545
  onQuit: quit
27290
27546
  }
@@ -27300,27 +27556,27 @@ function FlowScreen({
27300
27556
  }
27301
27557
  );
27302
27558
  case "preview-gate":
27303
- if (!state.serverPreview) return null;
27559
+ if (!state2.serverPreview) return null;
27304
27560
  return /* @__PURE__ */ jsx52(
27305
27561
  WizardPreviewStep,
27306
27562
  {
27307
- preview: state.serverPreview,
27308
- spaceId: state.spaceId,
27309
- environmentId: state.environmentId,
27563
+ preview: state2.serverPreview,
27564
+ spaceId: state2.spaceId,
27565
+ environmentId: state2.environmentId,
27310
27566
  stepNumber: totalSteps,
27311
27567
  totalSteps,
27312
27568
  onConfirm: controller.confirmPreview,
27313
- ...canEditFromPreview(state.cdf) ? { onEdit: controller.editDefinitions } : {},
27569
+ ...canEditFromPreview(state2.cdf) ? { onEdit: controller.editDefinitions } : {},
27314
27570
  onQuit: quit
27315
27571
  }
27316
27572
  );
27317
27573
  case "pushing":
27318
- return /* @__PURE__ */ jsx52(PushingStep, { stepNumber: totalSteps, totalSteps, progress: state.pushProgress });
27574
+ return /* @__PURE__ */ jsx52(PushingStep, { stepNumber: totalSteps, totalSteps, progress: state2.pushProgress });
27319
27575
  case "path-prompt":
27320
27576
  return /* @__PURE__ */ jsx52(
27321
27577
  PathPrompt,
27322
27578
  {
27323
- defaultPath: state.outDir,
27579
+ defaultPath: state2.outDir,
27324
27580
  onSubmit: (submitted) => void controller.submitPath(submitted),
27325
27581
  onCancel: quit
27326
27582
  }
@@ -27336,12 +27592,12 @@ function FlowScreen({
27336
27592
  }
27337
27593
  );
27338
27594
  case "print-gate": {
27339
- const teaser = buildRunTeaserLine(state.lastRunId);
27595
+ const teaser = buildRunTeaserLine(state2.lastRunId);
27340
27596
  return /* @__PURE__ */ jsx52(
27341
27597
  GateStep,
27342
27598
  {
27343
27599
  message: "Files saved",
27344
- summary: state.componentsPath ? `components.json \u2192 ${state.componentsPath}` : void 0,
27600
+ summary: state2.componentsPath ? `components.json \u2192 ${state2.componentsPath}` : void 0,
27345
27601
  context: teaser ? `Your files are saved to disk. ${teaser}` : "Your files are saved to disk. Run `experiences import` again when you're ready to push to Contentful.",
27346
27602
  continueLabel: "Exit",
27347
27603
  onContinue: quit,
@@ -27350,17 +27606,17 @@ function FlowScreen({
27350
27606
  );
27351
27607
  }
27352
27608
  case "done": {
27353
- const totalFailed = state.pushResult.componentTypes.failed + state.pushResult.designTokens.failed;
27609
+ const totalFailed = state2.pushResult.componentTypes.failed + state2.pushResult.designTokens.failed;
27354
27610
  return /* @__PURE__ */ jsx52(
27355
27611
  DoneStep,
27356
27612
  {
27357
- componentTypes: state.pushResult.componentTypes,
27358
- designTokens: state.pushResult.designTokens,
27359
- summary: state.pushResult.summary,
27360
- failures: state.pushResult.failures,
27361
- spaceId: state.spaceId,
27362
- environmentId: state.environmentId,
27363
- host: state.host,
27613
+ componentTypes: state2.pushResult.componentTypes,
27614
+ designTokens: state2.pushResult.designTokens,
27615
+ summary: state2.pushResult.summary,
27616
+ failures: state2.pushResult.failures,
27617
+ spaceId: state2.spaceId,
27618
+ environmentId: state2.environmentId,
27619
+ host: state2.host,
27364
27620
  onExit: () => onExit(totalFailed > 0 ? 1 : 0)
27365
27621
  }
27366
27622
  );
@@ -27369,8 +27625,8 @@ function FlowScreen({
27369
27625
  return /* @__PURE__ */ jsx52(
27370
27626
  PreviewValidationErrorScreen,
27371
27627
  {
27372
- errors: state.previewValidationErrors,
27373
- missingNames: state.previewValidationMissingNames,
27628
+ errors: state2.previewValidationErrors,
27629
+ missingNames: state2.previewValidationMissingNames,
27374
27630
  onEdit: controller.editDefinitions,
27375
27631
  onSkip: () => void controller.skipValidationErrors(),
27376
27632
  onQuit: quit
@@ -27380,10 +27636,10 @@ function FlowScreen({
27380
27636
  return /* @__PURE__ */ jsx52(
27381
27637
  ErrorStep,
27382
27638
  {
27383
- stepName: state.errorStep,
27384
- message: state.errorMessage,
27639
+ stepName: state2.errorStep,
27640
+ message: state2.errorMessage,
27385
27641
  onExit: () => onExit(1),
27386
- onAcknowledgeBreakingChanges: state.errorAllowBreakingChangeAcknowledgment && state.cdf ? controller.acknowledgeBreakingChanges : void 0
27642
+ onAcknowledgeBreakingChanges: state2.errorAllowBreakingChangeAcknowledgment && state2.cdf ? controller.acknowledgeBreakingChanges : void 0
27387
27643
  }
27388
27644
  );
27389
27645
  }
@@ -27404,8 +27660,8 @@ import { tmpdir } from "node:os";
27404
27660
  import { join as join23, resolve as resolve25 } from "node:path";
27405
27661
 
27406
27662
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
27407
- function shouldBypassPreview(state) {
27408
- return state.credentialsSkipped === true;
27663
+ function shouldBypassPreview(state2) {
27664
+ return state2.credentialsSkipped === true;
27409
27665
  }
27410
27666
  function buildSkippedPreviewTransition() {
27411
27667
  return { step: "done", serverPreview: null };
@@ -27414,8 +27670,8 @@ function resolveCycleGateAction(opts) {
27414
27670
  if (!opts.hasCycles) return "proceed";
27415
27671
  return "block";
27416
27672
  }
27417
- function shouldRefusePush(state) {
27418
- return state.credentialsSkipped === true;
27673
+ function shouldRefusePush(state2) {
27674
+ return state2.credentialsSkipped === true;
27419
27675
  }
27420
27676
  function buildSkippedPushTransition() {
27421
27677
  return { step: "print-gate" };
@@ -27445,6 +27701,7 @@ function clearedValidationErrorState() {
27445
27701
  }
27446
27702
  async function runPreview(input, deps) {
27447
27703
  if (shouldBypassPreview(input.state)) return buildSkippedPreviewTransition();
27704
+ setCommandContext({ space_key: input.spaceId, environment_key: input.environmentId });
27448
27705
  try {
27449
27706
  const client2 = deps.createClient({
27450
27707
  cmaToken: input.cmaToken,
@@ -27493,6 +27750,7 @@ async function runPreview(input, deps) {
27493
27750
  db.close();
27494
27751
  }
27495
27752
  }
27753
+ recordContentfulContext(client2, input.spaceId, input.environmentId);
27496
27754
  if (isEmptyPreview(preview)) {
27497
27755
  return {
27498
27756
  step: "done",
@@ -27658,6 +27916,7 @@ async function runPush(input, deps, onPatch) {
27658
27916
  } catch (logErr) {
27659
27917
  safeLog(deps, { pollLogError: String(logErr) });
27660
27918
  }
27919
+ recordApplyOutcome(client2, input.spaceId, input.environmentId, operation);
27661
27920
  const pushResult = resultOf(operation, preview);
27662
27921
  const pushSucceeded = pushResult.componentTypes.failed === 0 && pushResult.designTokens.failed === 0 && operation.sys.status !== "failed";
27663
27922
  if (pushSucceeded && input.state.lastRunId) {
@@ -27810,17 +28069,17 @@ async function runPrintFiles(input, deps, onPatch) {
27810
28069
  return { ok: true, patch: nextStateAfterPrint({ skipGate: input.skipGate, componentsPath }) };
27811
28070
  }
27812
28071
  async function recordRun(input, deps) {
27813
- const { state } = input;
28072
+ const { state: state2 } = input;
27814
28073
  try {
27815
28074
  let sourceFingerprint = null;
27816
28075
  try {
27817
- if (state.extractSessionId) {
28076
+ if (state2.extractSessionId) {
27818
28077
  const db = deps.openDb();
27819
28078
  try {
27820
28079
  sourceFingerprint = await deps.buildSourceFingerprint({
27821
28080
  db,
27822
- extractSessionId: state.extractSessionId,
27823
- rawTokensPath: state.rawTokensPath || null
28081
+ extractSessionId: state2.extractSessionId,
28082
+ rawTokensPath: state2.rawTokensPath || null
27824
28083
  });
27825
28084
  } finally {
27826
28085
  db.close();
@@ -27831,16 +28090,16 @@ async function recordRun(input, deps) {
27831
28090
  `);
27832
28091
  }
27833
28092
  const record3 = await deps.appendRun({
27834
- projectPath: state.projectPath,
28093
+ projectPath: state2.projectPath,
27835
28094
  savePath: input.savePath,
27836
- componentCount: state.generatedAcceptedCount || state.generatedCount,
27837
- tokenCount: state.tokenCount,
27838
- tokensPath: (state.tokenSessionId ? state.tokensPath || null : null) || null,
27839
- tokenSessionId: state.tokenSessionId,
27840
- agent: state.agent,
28095
+ componentCount: state2.generatedAcceptedCount || state2.generatedCount,
28096
+ tokenCount: state2.tokenCount,
28097
+ tokensPath: (state2.tokenSessionId ? state2.tokensPath || null : null) || null,
28098
+ tokenSessionId: state2.tokenSessionId,
28099
+ agent: state2.agent,
27841
28100
  pushedTo: null,
27842
- extractSessionId: state.extractSessionId ?? "",
27843
- generateSessionId: state.generateSessionId,
28101
+ extractSessionId: state2.extractSessionId ?? "",
28102
+ generateSessionId: state2.generateSessionId,
27844
28103
  sourceFingerprint
27845
28104
  });
27846
28105
  return record3.id;
@@ -27976,7 +28235,7 @@ function namesToSkip(errors) {
27976
28235
  return [...new Set(errors.map((e) => e.componentName))];
27977
28236
  }
27978
28237
  function createFlowController(start, deps) {
27979
- let state = initialFlowState(start);
28238
+ let state2 = initialFlowState(start);
27980
28239
  const listeners = /* @__PURE__ */ new Set();
27981
28240
  let allowEmptyDeleteAll = false;
27982
28241
  let pendingSave = {};
@@ -27985,27 +28244,27 @@ function createFlowController(start, deps) {
27985
28244
  deps.log({ update: sanitizeForLog(patch) });
27986
28245
  } catch {
27987
28246
  }
27988
- if (patch.step !== void 0 && patch.step !== state.step) {
28247
+ if (patch.step !== void 0 && patch.step !== state2.step) {
27989
28248
  try {
27990
28249
  deps.beforeStepChange?.();
27991
28250
  } catch {
27992
28251
  }
27993
28252
  }
27994
- state = { ...state, ...patch };
28253
+ state2 = { ...state2, ...patch };
27995
28254
  for (const listener of listeners) listener();
27996
28255
  };
27997
28256
  const preview = async () => {
27998
- if (!state.credentialsSkipped) update({ step: "previewing" });
28257
+ if (!state2.credentialsSkipped) update({ step: "previewing" });
27999
28258
  update(
28000
28259
  await runPreview(
28001
28260
  {
28002
- state,
28003
- extractSessionId: state.extractSessionId,
28004
- tokensPath: state.tokensPath,
28005
- spaceId: state.spaceId,
28006
- environmentId: state.environmentId,
28007
- cmaToken: state.cmaToken,
28008
- host: state.host,
28261
+ state: state2,
28262
+ extractSessionId: state2.extractSessionId,
28263
+ tokensPath: state2.tokensPath,
28264
+ spaceId: state2.spaceId,
28265
+ environmentId: state2.environmentId,
28266
+ cmaToken: state2.cmaToken,
28267
+ host: state2.host,
28009
28268
  deleteAll: allowEmptyDeleteAll
28010
28269
  },
28011
28270
  deps.preview
@@ -28013,18 +28272,18 @@ function createFlowController(start, deps) {
28013
28272
  );
28014
28273
  };
28015
28274
  const push = async (acknowledgeBreakingChanges) => {
28016
- if (!state.cdf) return;
28275
+ if (!state2.cdf) return;
28017
28276
  update(
28018
28277
  await runPush(
28019
28278
  {
28020
- state,
28021
- cdf: state.cdf,
28022
- spaceId: state.spaceId,
28023
- environmentId: state.environmentId,
28024
- cmaToken: state.cmaToken,
28025
- host: state.host,
28279
+ state: state2,
28280
+ cdf: state2.cdf,
28281
+ spaceId: state2.spaceId,
28282
+ environmentId: state2.environmentId,
28283
+ cmaToken: state2.cmaToken,
28284
+ host: state2.host,
28026
28285
  acknowledgeBreakingChanges,
28027
- preview: state.serverPreview
28286
+ preview: state2.serverPreview
28028
28287
  },
28029
28288
  deps.push,
28030
28289
  update
@@ -28040,11 +28299,11 @@ function createFlowController(start, deps) {
28040
28299
  const { skipGate, andPush } = pendingSave;
28041
28300
  const written = await runPrintFiles(
28042
28301
  {
28043
- extractSessionId: state.extractSessionId,
28302
+ extractSessionId: state2.extractSessionId,
28044
28303
  outDir: path5,
28045
28304
  ...skipGate ? { skipGate: true } : {},
28046
- ...state.tokenSessionId ? { tokenSessionId: state.tokenSessionId } : {},
28047
- ...state.tokensPath ? { tokensPath: state.tokensPath } : {},
28305
+ ...state2.tokenSessionId ? { tokenSessionId: state2.tokenSessionId } : {},
28306
+ ...state2.tokensPath ? { tokensPath: state2.tokensPath } : {},
28048
28307
  ...allowEmptyDeleteAll ? { allowEmpty: true } : {}
28049
28308
  },
28050
28309
  deps.save,
@@ -28052,21 +28311,21 @@ function createFlowController(start, deps) {
28052
28311
  );
28053
28312
  update(written.patch);
28054
28313
  if (!written.ok) return;
28055
- const runId = await recordRun({ state, savePath: path5 }, deps.save);
28314
+ const runId = await recordRun({ state: state2, savePath: path5 }, deps.save);
28056
28315
  if (runId) update({ lastRunId: runId });
28057
28316
  if (andPush) await preview();
28058
28317
  };
28059
28318
  const detectAcceptedCycles = () => {
28060
- if (!state.extractSessionId) return [];
28319
+ if (!state2.extractSessionId) return [];
28061
28320
  try {
28062
- const accepted = deps.loadAcceptedComponents(state.extractSessionId);
28321
+ const accepted = deps.loadAcceptedComponents(state2.extractSessionId);
28063
28322
  return findSlotCycles3(buildComponentGraph3(accepted));
28064
28323
  } catch {
28065
28324
  return [];
28066
28325
  }
28067
28326
  };
28068
28327
  const begin = () => {
28069
- if (!state.extractSessionId || !start.handoff.generation) {
28328
+ if (!state2.extractSessionId || !start.handoff.generation) {
28070
28329
  update({
28071
28330
  step: "error",
28072
28331
  errorStep: "start import",
@@ -28083,7 +28342,7 @@ function createFlowController(start, deps) {
28083
28342
  };
28084
28343
  begin();
28085
28344
  return {
28086
- getState: () => state,
28345
+ getState: () => state2,
28087
28346
  subscribe: (listener) => {
28088
28347
  listeners.add(listener);
28089
28348
  return () => listeners.delete(listener);
@@ -28106,7 +28365,7 @@ function createFlowController(start, deps) {
28106
28365
  },
28107
28366
  async submitPath(submitted) {
28108
28367
  await deps.mkdir(submitted);
28109
- if (resolve25(submitted) !== resolve25(state.outDir) && await deps.detectSaveConflict(submitted)) {
28368
+ if (resolve25(submitted) !== resolve25(state2.outDir) && await deps.detectSaveConflict(submitted)) {
28110
28369
  const subdir = deps.buildTimestampedSubdir(submitted);
28111
28370
  await deps.mkdir(subdir);
28112
28371
  await proceedToWrite(subdir);
@@ -28118,9 +28377,9 @@ function createFlowController(start, deps) {
28118
28377
  acknowledgeBreakingChanges: () => void push(true),
28119
28378
  editDefinitions: () => update({ step: "final-review" }),
28120
28379
  async skipValidationErrors() {
28121
- if (state.extractSessionId) {
28122
- const names = namesToSkip(state.previewValidationErrors);
28123
- if (names.length > 0) await deps.rejectComponentsByName(state.extractSessionId, names);
28380
+ if (state2.extractSessionId) {
28381
+ const names = namesToSkip(state2.previewValidationErrors);
28382
+ if (names.length > 0) await deps.rejectComponentsByName(state2.extractSessionId, names);
28124
28383
  }
28125
28384
  await preview();
28126
28385
  }
@@ -28142,14 +28401,14 @@ function useFlow(start, options = {}) {
28142
28401
  });
28143
28402
  }
28144
28403
  const current = controller.current;
28145
- const state = useSyncExternalStore(
28404
+ const state2 = useSyncExternalStore(
28146
28405
  (listener) => current?.subscribe(listener) ?? (() => void 0),
28147
28406
  () => current?.getState()
28148
28407
  );
28149
28408
  useEffect20(() => {
28150
28409
  if (!start) controller.current = void 0;
28151
28410
  }, [start]);
28152
- return current && state ? { controller: current, state } : void 0;
28411
+ return current && state2 ? { controller: current, state: state2 } : void 0;
28153
28412
  }
28154
28413
 
28155
28414
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
@@ -28757,16 +29016,16 @@ function App({ importOptions, inkClear }) {
28757
29016
  const finishCredentials = async (result, projectPath2, tokens, filePaths) => {
28758
29017
  if (!result.skipped) await writeCredentials({ ...result.credentials });
28759
29018
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
28760
- const state = await inspectTokens({
29019
+ const state2 = await inspectTokens({
28761
29020
  rawTokensPath: tokens,
28762
29021
  contentfulDir: join25(resolveUserPath(projectPath2), ".contentful"),
28763
29022
  cache: importOptions.cache
28764
29023
  });
28765
- if (state.kind === "cached") {
29024
+ if (state2.kind === "cached") {
28766
29025
  setPendingLaunch({
28767
29026
  launch,
28768
29027
  credentials: result,
28769
- cached: { tokensPath: state.tokensPath, sourceChanged: state.sourceChanged }
29028
+ cached: { tokensPath: state2.tokensPath, sourceChanged: state2.sourceChanged }
28770
29029
  });
28771
29030
  return;
28772
29031
  }