@contentful/experience-design-system-cli 2.37.1-dev-build-2ed60464.0 → 2.37.1-dev-build-fc847476.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((resolve28) => {
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
+ resolve28(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((resolve28) => {
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
+ resolve28("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
+ resolve28("unauthenticated");
932
932
  return;
933
933
  }
934
934
  try {
935
935
  const status = JSON.parse(stdout);
936
- resolve27(status.loggedIn ? "ok" : "unauthenticated");
936
+ resolve28(status.loggedIn ? "ok" : "unauthenticated");
937
937
  } catch {
938
- resolve27("unauthenticated");
938
+ resolve28("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((resolve28) => {
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) => resolve28(code === 0));
951
951
  });
952
952
  }
953
953
  var init_check_agent_auth = __esm({
@@ -2329,8 +2329,8 @@ var init_debug_store = __esm({
2329
2329
  });
2330
2330
 
2331
2331
  // packages/experience-design-system-cli/app.tsx
2332
- import { join as join25 } from "node:path";
2333
- import { useEffect as useEffect26, useState as useState33 } from "react";
2332
+ import { join as join26 } from "node:path";
2333
+ import { useEffect as useEffect27, useState as useState36 } from "react";
2334
2334
 
2335
2335
  // packages/experience-design-system-cli/src/tui/home/home.tsx
2336
2336
  import { useEffect as useEffect2, useState as useState2 } from "react";
@@ -13824,7 +13824,7 @@ function errorMessage(error) {
13824
13824
  return error instanceof Error && error.message ? error.message : String(error);
13825
13825
  }
13826
13826
  function defaultSleep(delayMs) {
13827
- return new Promise((resolve27) => setTimeout(resolve27, delayMs));
13827
+ return new Promise((resolve28) => setTimeout(resolve28, delayMs));
13828
13828
  }
13829
13829
 
13830
13830
  // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
@@ -14065,7 +14065,7 @@ var ApiClient = class {
14065
14065
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
14066
14066
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
14067
14067
  const jitter = Math.random() * baseDelay * 0.15;
14068
- await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
14068
+ await new Promise((resolve28) => setTimeout(resolve28, baseDelay + jitter));
14069
14069
  }
14070
14070
  }
14071
14071
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -15165,6 +15165,35 @@ async function emitInvokedIfReady() {
15165
15165
  }, state.sessionId, { flush: true });
15166
15166
  }
15167
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
+
15168
15197
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/run-map-tokens.js
15169
15198
  var DEFAULT_TIMEOUT_MS2 = 5 * 60 * 1e3;
15170
15199
  var MapTokensRunFailure = class _MapTokensRunFailure extends Error {
@@ -16345,7 +16374,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
16345
16374
  const message = error instanceof Error ? error.message : String(error);
16346
16375
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
16347
16376
  throw error;
16348
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
16377
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(250 * attempt, 2e3)));
16349
16378
  }
16350
16379
  }
16351
16380
  }
@@ -27672,6 +27701,7 @@ function clearedValidationErrorState() {
27672
27701
  }
27673
27702
  async function runPreview(input, deps) {
27674
27703
  if (shouldBypassPreview(input.state)) return buildSkippedPreviewTransition();
27704
+ setCommandContext({ space_key: input.spaceId, environment_key: input.environmentId });
27675
27705
  try {
27676
27706
  const client2 = deps.createClient({
27677
27707
  cmaToken: input.cmaToken,
@@ -27720,6 +27750,7 @@ async function runPreview(input, deps) {
27720
27750
  db.close();
27721
27751
  }
27722
27752
  }
27753
+ recordContentfulContext(client2, input.spaceId, input.environmentId);
27723
27754
  if (isEmptyPreview(preview)) {
27724
27755
  return {
27725
27756
  step: "done",
@@ -27885,6 +27916,7 @@ async function runPush(input, deps, onPatch) {
27885
27916
  } catch (logErr) {
27886
27917
  safeLog(deps, { pollLogError: String(logErr) });
27887
27918
  }
27919
+ recordApplyOutcome(client2, input.spaceId, input.environmentId, operation);
27888
27920
  const pushResult = resultOf(operation, preview);
27889
27921
  const pushSucceeded = pushResult.componentTypes.failed === 0 && pushResult.designTokens.failed === 0 && operation.sys.status !== "failed";
27890
27922
  if (pushSucceeded && input.state.lastRunId) {
@@ -27999,7 +28031,7 @@ var realSaveDeps = () => ({
27999
28031
  writeFile: (path5, contents) => writeFile7(path5, contents),
28000
28032
  appendRun,
28001
28033
  buildSourceFingerprint,
28002
- sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
28034
+ sleep: (ms) => new Promise((resolve28) => setTimeout(resolve28, ms)),
28003
28035
  warn: (message) => process.stderr.write(message)
28004
28036
  });
28005
28037
  async function runPrintFiles(input, deps, onPatch) {
@@ -28389,12 +28421,44 @@ init_config();
28389
28421
  init_debug_store();
28390
28422
  init_debug_mode_store();
28391
28423
  init_version();
28424
+
28425
+ // packages/experience-design-system-cli/src/tui/help/file-locations.ts
28426
+ import { join as join25, resolve as resolve27 } from "node:path";
28427
+ function describeFileLocations({
28428
+ contentfulBaseDir,
28429
+ debugModeEnabled,
28430
+ currentSessionDir: currentSessionDir2
28431
+ }) {
28432
+ if (!debugModeEnabled) {
28433
+ return {
28434
+ debugLogs: "none while Debug Mode is off",
28435
+ importFiles: `${join25("<project>", ".contentful")}/ (tokens.json, components.json)`
28436
+ };
28437
+ }
28438
+ const base = contentfulBaseDir ? resolve27(contentfulBaseDir) : "<project>";
28439
+ const session = currentSessionDir2 ?? join25(base, ".contentful", "<date>-session-<n>");
28440
+ return {
28441
+ debugLogs: join25(session, "debug"),
28442
+ importFiles: `${join25(session, "dsi-import-<n>")}/ (tokens.json, components.json)`
28443
+ };
28444
+ }
28445
+
28446
+ // packages/experience-design-system-cli/src/tui/help/help-info.ts
28392
28447
  async function readHelpInfo() {
28393
- const debugMode = await readDebugModeSetting();
28448
+ const [debugMode, settings] = await Promise.all([readDebugModeSetting(), readSettings2()]);
28449
+ const base = settings["contentfulBaseDir"];
28450
+ const locations = describeFileLocations({
28451
+ contentfulBaseDir: typeof base === "string" ? base : "",
28452
+ debugModeEnabled: debugMode.enabled,
28453
+ currentSessionDir: currentSessionDir()
28454
+ });
28394
28455
  return {
28395
28456
  storage: [
28396
28457
  { label: "Config folder", value: configRoot2() },
28397
- { label: "Settings file", value: configFilePath2() }
28458
+ { label: "Settings file", value: configFilePath2() },
28459
+ { label: "Agent settings", value: `${configFilePath2()} (keys: agent, agentModel, agents)` },
28460
+ { label: "Debug logs", value: locations.debugLogs },
28461
+ { label: "Import files", value: locations.importFiles }
28398
28462
  ],
28399
28463
  troubleshooting: [
28400
28464
  { label: "CLI version", value: readPackageVersion() },
@@ -28415,7 +28479,7 @@ function Section({ title, rows }) {
28415
28479
  return /* @__PURE__ */ jsxs43(Box42, { flexDirection: "column", children: [
28416
28480
  /* @__PURE__ */ jsx53(Text44, { bold: true, color: PALETTE.accent, children: title }),
28417
28481
  rows.map((row) => /* @__PURE__ */ jsxs43(Box42, { gap: 1, children: [
28418
- /* @__PURE__ */ jsx53(Box42, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
28482
+ /* @__PURE__ */ jsx53(Box42, { width: 16, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
28419
28483
  /* @__PURE__ */ jsx53(Text44, { children: row.value })
28420
28484
  ] }, row.label))
28421
28485
  ] });
@@ -28515,15 +28579,338 @@ function SettingsScreen({
28515
28579
  }
28516
28580
 
28517
28581
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28518
- import { useEffect as useEffect22, useState as useState29 } from "react";
28582
+ import { useState as useState32 } from "react";
28583
+ import { Box as Box47, Text as Text49, useInput as useInput13 } from "ink";
28584
+
28585
+ // packages/experience-design-system-cli/src/tui/settings/agents/AgentScreens.tsx
28586
+ import { useEffect as useEffect22, useState as useState30 } from "react";
28587
+ import { Box as Box45, Text as Text47, useInput as useInput12 } from "ink";
28588
+ init_debug_store();
28589
+
28590
+ // packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx
28591
+ import { useState as useState29 } from "react";
28519
28592
  import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
28520
28593
  import TextInput4 from "ink-text-input";
28594
+ import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
28595
+ function FieldForm({
28596
+ title,
28597
+ subtitle,
28598
+ fields,
28599
+ values,
28600
+ onChange,
28601
+ onSave,
28602
+ onQuit,
28603
+ notice,
28604
+ busy = false,
28605
+ footer
28606
+ }) {
28607
+ const [active, setActive] = useState29(0);
28608
+ const [editing, setEditing] = useState29(false);
28609
+ const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
28610
+ const labelWidth = Math.max(...fields.map((field) => field.label.length));
28611
+ const current = fields[active];
28612
+ useInput11((input, key) => {
28613
+ if (busy) return;
28614
+ if (editing) {
28615
+ if (key.escape) {
28616
+ onChange(current.key, valueBeforeEdit);
28617
+ setEditing(false);
28618
+ }
28619
+ return;
28620
+ }
28621
+ if (key.escape || input === "q") {
28622
+ onQuit();
28623
+ return;
28624
+ }
28625
+ if (input === "s") {
28626
+ onSave();
28627
+ return;
28628
+ }
28629
+ if (input === "c") {
28630
+ onChange(current.key, "");
28631
+ return;
28632
+ }
28633
+ if (key.tab || key.downArrow) {
28634
+ setActive((i) => (i + 1) % fields.length);
28635
+ return;
28636
+ }
28637
+ if (key.upArrow) {
28638
+ setActive((i) => (i - 1 + fields.length) % fields.length);
28639
+ return;
28640
+ }
28641
+ if (key.return) {
28642
+ setValueBeforeEdit(values[current.key]);
28643
+ setEditing(true);
28644
+ }
28645
+ });
28646
+ return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28647
+ /* @__PURE__ */ jsx55(Text46, { bold: true, children: title }),
28648
+ subtitle && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: subtitle }),
28649
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
28650
+ /* @__PURE__ */ jsx55(Box44, { flexDirection: "column", children: fields.map((field, index) => {
28651
+ const isActive = index === active;
28652
+ const value = values[field.key];
28653
+ const display = field.masked ? "\u2022".repeat(value.length) : value;
28654
+ return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
28655
+ /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
28656
+ /* @__PURE__ */ jsx55(Box44, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: field.label }) }),
28657
+ isActive && editing ? /* @__PURE__ */ jsx55(
28658
+ TextInput4,
28659
+ {
28660
+ value,
28661
+ onChange: (next) => onChange(field.key, next),
28662
+ onSubmit: () => setEditing(false),
28663
+ mask: field.masked ? "\u2022" : void 0
28664
+ }
28665
+ ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (field.hint ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
28666
+ field.hint && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: field.hint })
28667
+ ] }, field.key);
28668
+ }) }),
28669
+ notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
28670
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
28671
+ /* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
28672
+ notice.kind === "success" ? "\u2713" : "\u2717",
28673
+ " ",
28674
+ notice.text
28675
+ ] })
28676
+ ] }),
28677
+ footer,
28678
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
28679
+ /* @__PURE__ */ jsx55(
28680
+ ControlHints,
28681
+ {
28682
+ hints: editing ? [
28683
+ { keys: "type", label: "edit" },
28684
+ { keys: "\u2190/\u2192", label: "move cursor" },
28685
+ { keys: "\u23CE", label: "done" },
28686
+ { keys: "Esc", label: "cancel edit" }
28687
+ ] : [
28688
+ { keys: "\u2191/\u2193", label: "move" },
28689
+ { keys: "\u23CE", label: "edit" },
28690
+ { keys: "c", label: "clear" },
28691
+ { keys: "s", label: "save" },
28692
+ { keys: "Esc/q", label: "back without saving" }
28693
+ ]
28694
+ }
28695
+ )
28696
+ ] });
28697
+ }
28521
28698
 
28522
28699
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
28523
28700
  init_config();
28524
28701
  var readV1Store = readSettings2;
28525
28702
  var writeV1Store = writeSettings2;
28526
28703
 
28704
+ // packages/experience-design-system-cli/src/tui/settings/agents/agent-store.ts
28705
+ var DEFAULT_AGENT3 = "claude";
28706
+ var AGENT_LABELS = {
28707
+ claude: "Claude Code",
28708
+ codex: "OpenAI Codex",
28709
+ opencode: "OpenCode",
28710
+ cursor: "Cursor",
28711
+ copilot: "GitHub Copilot"
28712
+ };
28713
+ var AGENT_HINTS = {
28714
+ claude: "claude",
28715
+ codex: "codex",
28716
+ opencode: "opencode",
28717
+ cursor: "cursor-agent",
28718
+ copilot: "copilot"
28719
+ };
28720
+ var asString = (value) => typeof value === "string" ? value : "";
28721
+ function emptyAgents() {
28722
+ return Object.fromEntries(AGENT_NAMES.map((name) => [name, { model: "" }]));
28723
+ }
28724
+ async function readAgentConfig() {
28725
+ const store = await readV1Store();
28726
+ const stored = asString(store["agent"]);
28727
+ const defaultAgent = isAgentName(stored) ? stored : DEFAULT_AGENT3;
28728
+ const agents = emptyAgents();
28729
+ const saved = store["agents"];
28730
+ if (saved && typeof saved === "object") {
28731
+ for (const name of AGENT_NAMES) {
28732
+ const entry = saved[name];
28733
+ if (entry && typeof entry === "object")
28734
+ agents[name] = { model: asString(entry["model"]) };
28735
+ }
28736
+ }
28737
+ const legacyModel = asString(store["agentModel"]);
28738
+ if (legacyModel && !agents[defaultAgent].model) agents[defaultAgent] = { model: legacyModel };
28739
+ return { defaultAgent, agents };
28740
+ }
28741
+ async function writeAgentConfig(config) {
28742
+ const existing = await readV1Store();
28743
+ const merged = { ...existing };
28744
+ const agents = {};
28745
+ for (const name of AGENT_NAMES) {
28746
+ const model = config.agents[name].model.trim();
28747
+ if (model) agents[name] = { model };
28748
+ }
28749
+ merged["agent"] = config.defaultAgent;
28750
+ const defaultModel = agents[config.defaultAgent]?.model;
28751
+ if (defaultModel) merged["agentModel"] = defaultModel;
28752
+ else delete merged["agentModel"];
28753
+ if (Object.keys(agents).length > 0) merged["agents"] = agents;
28754
+ else delete merged["agents"];
28755
+ await writeV1Store(merged);
28756
+ }
28757
+
28758
+ // packages/experience-design-system-cli/src/tui/settings/agents/AgentScreens.tsx
28759
+ import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
28760
+ var MODEL_FIELDS = [
28761
+ { key: "model", label: "Model", hint: "(empty: the agent\u2019s own default)" }
28762
+ ];
28763
+ var ROWS = [{ kind: "default" }, ...AGENT_NAMES.map((name) => ({ kind: "agent", name }))];
28764
+ function AgentForm({
28765
+ name,
28766
+ config,
28767
+ setConfig,
28768
+ onBack
28769
+ }) {
28770
+ const [saving, setSaving] = useState30(false);
28771
+ const [notice, setNotice] = useState30(null);
28772
+ const save = () => {
28773
+ setSaving(true);
28774
+ setNotice(null);
28775
+ writeAgentConfig(config).then(() => setNotice({ kind: "success", text: `${AGENT_LABELS[name]} settings saved` })).catch(
28776
+ (err) => setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" })
28777
+ ).finally(() => setSaving(false));
28778
+ };
28779
+ return /* @__PURE__ */ jsx56(
28780
+ FieldForm,
28781
+ {
28782
+ title: AGENT_LABELS[name],
28783
+ subtitle: `Runs the \`${AGENT_HINTS[name]}\` command. ${config.defaultAgent === name ? "This is the default agent." : ""}`.trim(),
28784
+ fields: MODEL_FIELDS,
28785
+ values: { model: config.agents[name].model },
28786
+ onChange: (_key, value) => {
28787
+ setConfig({ ...config, agents: { ...config.agents, [name]: { model: value } } });
28788
+ setNotice(null);
28789
+ },
28790
+ onSave: save,
28791
+ onQuit: onBack,
28792
+ notice,
28793
+ busy: saving
28794
+ }
28795
+ );
28796
+ }
28797
+ function AgentsScreen({ onDone }) {
28798
+ const [config, setConfig] = useState30(null);
28799
+ const [focus, setFocus] = useState30(0);
28800
+ const [open, setOpen] = useState30(null);
28801
+ const [notice, setNotice] = useState30(null);
28802
+ useEffect22(() => {
28803
+ void readAgentConfig().then((loaded) => {
28804
+ setConfig(loaded);
28805
+ startDebugRun({
28806
+ flow: "settings/agents",
28807
+ step: "01-agents",
28808
+ menuOption: "Configuration > Agents",
28809
+ inputs: { default_agent: loaded.defaultAgent }
28810
+ });
28811
+ });
28812
+ }, []);
28813
+ const cycleDefault = (step) => {
28814
+ if (!config) return;
28815
+ const index = AGENT_NAMES.indexOf(config.defaultAgent);
28816
+ const next = { ...config, defaultAgent: AGENT_NAMES[(index + step + AGENT_NAMES.length) % AGENT_NAMES.length] };
28817
+ setConfig(next);
28818
+ writeAgentConfig(next).then(() => setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[next.defaultAgent]}` })).catch(
28819
+ (err) => setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" })
28820
+ );
28821
+ };
28822
+ useInput12((input, key) => {
28823
+ if (!config || open) return;
28824
+ const row = ROWS[focus];
28825
+ if (key.upArrow) {
28826
+ setFocus((i) => (i - 1 + ROWS.length) % ROWS.length);
28827
+ return;
28828
+ }
28829
+ if (key.downArrow || key.tab) {
28830
+ setFocus((i) => (i + 1) % ROWS.length);
28831
+ return;
28832
+ }
28833
+ if (row.kind === "default" && key.leftArrow) {
28834
+ cycleDefault(-1);
28835
+ return;
28836
+ }
28837
+ if (row.kind === "default" && key.rightArrow) {
28838
+ cycleDefault(1);
28839
+ return;
28840
+ }
28841
+ if (key.return) {
28842
+ if (row.kind === "default") cycleDefault(1);
28843
+ else setOpen(row.name);
28844
+ return;
28845
+ }
28846
+ if (key.escape || input === "q") {
28847
+ void finishDebugRun({ outputs: { default_agent: config.defaultAgent }, status: "success", exitMethod: "saved" });
28848
+ onDone();
28849
+ }
28850
+ });
28851
+ if (!config) {
28852
+ return /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28853
+ /* @__PURE__ */ jsx56(Text47, { bold: true, children: "Agents" }),
28854
+ /* @__PURE__ */ jsx56(Text47, { children: " " }),
28855
+ /* @__PURE__ */ jsx56(Text47, { color: PALETTE.accent, children: "Loading..." })
28856
+ ] });
28857
+ }
28858
+ if (open) {
28859
+ return /* @__PURE__ */ jsx56(AgentForm, { name: open, config, setConfig, onBack: () => setOpen(null) });
28860
+ }
28861
+ return /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28862
+ /* @__PURE__ */ jsx56(Text47, { bold: true, children: "Agents" }),
28863
+ /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "The coding agent the CLI runs, and the settings for each one." }),
28864
+ /* @__PURE__ */ jsx56(Text47, { children: " " }),
28865
+ ROWS.map((row, index) => {
28866
+ const isFocused = index === focus;
28867
+ const pointer = /* @__PURE__ */ jsx56(Text47, { color: isFocused ? PALETTE.accent : void 0, children: isFocused ? "\u276F" : " " });
28868
+ if (row.kind === "default") {
28869
+ return /* @__PURE__ */ jsx56(Box45, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs46(Box45, { gap: 1, children: [
28870
+ pointer,
28871
+ /* @__PURE__ */ jsx56(Text47, { bold: isFocused, color: isFocused ? PALETTE.accent : PALETTE.muted, children: "Default agent" }),
28872
+ /* @__PURE__ */ jsx56(Text47, { bold: true, children: `\u2039 ${AGENT_LABELS[config.defaultAgent]} \u203A` })
28873
+ ] }) }, "default");
28874
+ }
28875
+ const model = config.agents[row.name].model;
28876
+ return /* @__PURE__ */ jsxs46(Box45, { gap: 1, children: [
28877
+ pointer,
28878
+ /* @__PURE__ */ jsx56(Box45, { width: 16, flexShrink: 0, children: /* @__PURE__ */ jsx56(Text47, { bold: isFocused, color: isFocused ? PALETTE.accent : void 0, children: AGENT_LABELS[row.name] }) }),
28879
+ /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: model ? `model: ${model}` : "model: default" }),
28880
+ row.name === config.defaultAgent && /* @__PURE__ */ jsx56(Text47, { color: PALETTE.success, children: "(default)" })
28881
+ ] }, row.name);
28882
+ }),
28883
+ notice && /* @__PURE__ */ jsxs46(Fragment18, { children: [
28884
+ /* @__PURE__ */ jsx56(Text47, { children: " " }),
28885
+ /* @__PURE__ */ jsxs46(Text47, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
28886
+ notice.kind === "success" ? "\u2713" : "\u2717",
28887
+ " ",
28888
+ notice.text
28889
+ ] })
28890
+ ] }),
28891
+ /* @__PURE__ */ jsx56(Text47, { children: " " }),
28892
+ /* @__PURE__ */ jsx56(
28893
+ ControlHints,
28894
+ {
28895
+ hints: ROWS[focus].kind === "default" ? [
28896
+ { keys: "\u2191/\u2193", label: "move" },
28897
+ { keys: "\u2190/\u2192", label: "change default agent" },
28898
+ { keys: "Esc/q", label: "back" }
28899
+ ] : [
28900
+ { keys: "\u2191/\u2193", label: "move" },
28901
+ { keys: "\u23CE", label: "open" },
28902
+ { keys: "Esc/q", label: "back" }
28903
+ ]
28904
+ }
28905
+ )
28906
+ ] });
28907
+ }
28908
+
28909
+ // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ProjectConfigScreen.tsx
28910
+ import { useEffect as useEffect23, useState as useState31 } from "react";
28911
+ import { Box as Box46, Text as Text48 } from "ink";
28912
+ init_debug_store();
28913
+
28527
28914
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
28528
28915
  async function readCredentials() {
28529
28916
  const store = await readV1Store();
@@ -28549,17 +28936,16 @@ async function writeCredentials(config) {
28549
28936
  await writeV1Store(merged);
28550
28937
  }
28551
28938
 
28552
- // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28553
- init_debug_store();
28554
- import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
28555
- var FIELD_ORDER = [
28556
- "spaceId",
28557
- "environmentId",
28558
- "cmaToken",
28559
- "host",
28560
- "defaultComponentDir",
28561
- "defaultTokenFile",
28562
- "contentfulBaseDir"
28939
+ // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ProjectConfigScreen.tsx
28940
+ import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
28941
+ var FIELDS2 = [
28942
+ { key: "spaceId", label: "Space ID" },
28943
+ { key: "environmentId", label: "Environment ID" },
28944
+ { key: "cmaToken", label: "CMA Token", masked: true },
28945
+ { key: "host", label: "API Host" },
28946
+ { key: "defaultComponentDir", label: "Default component directory" },
28947
+ { key: "defaultTokenFile", label: "Default token file" },
28948
+ { key: "contentfulBaseDir", label: "Root Project Directory", hint: "(where .contentful goes)" }
28563
28949
  ];
28564
28950
  function debugFields(config) {
28565
28951
  return {
@@ -28572,156 +28958,114 @@ function debugFields(config) {
28572
28958
  contentful_base_dir: config?.contentfulBaseDir ?? ""
28573
28959
  };
28574
28960
  }
28575
- var FIELD_LABELS = {
28576
- spaceId: "Space ID",
28577
- environmentId: "Environment ID",
28578
- cmaToken: "CMA Token",
28579
- host: "API Host",
28580
- defaultComponentDir: "Default component directory",
28581
- defaultTokenFile: "Default token file",
28582
- contentfulBaseDir: "Root Project Directory"
28583
- };
28584
- var FIELD_HINTS = {
28585
- contentfulBaseDir: "(where .contentful goes)"
28586
- };
28587
- var LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
28588
- function ConfigurationScreen({ onDone }) {
28589
- const [stage, setStage] = useState29("loading");
28590
- const [config, setConfig] = useState29(null);
28591
- const [activeField, setActiveField] = useState29("spaceId");
28592
- const [notice, setNotice] = useState29(null);
28593
- const [lastSaved, setLastSaved] = useState29(null);
28594
- const [editing, setEditing] = useState29(false);
28595
- const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
28596
- useEffect22(() => {
28597
- readCredentials().then((cfg) => {
28961
+ var valuesOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
28962
+ function ProjectConfigScreen({ onDone }) {
28963
+ const [config, setConfig] = useState31(null);
28964
+ const [saving, setSaving] = useState31(false);
28965
+ const [notice, setNotice] = useState31(null);
28966
+ const [lastSaved, setLastSaved] = useState31(null);
28967
+ useEffect23(() => {
28968
+ void readCredentials().then((cfg) => {
28598
28969
  setConfig(cfg);
28599
- setStage("form");
28600
28970
  startDebugRun({
28601
28971
  flow: "settings/contentful-configuration",
28602
28972
  step: "01-configuration",
28603
- menuOption: "Configuration",
28973
+ menuOption: "Configuration > Project",
28604
28974
  inputs: debugFields(cfg)
28605
28975
  });
28606
28976
  });
28607
28977
  }, []);
28608
- function fieldValue(field) {
28609
- if (!config) return "";
28610
- return config[field] || "";
28611
- }
28612
- function setFieldValue(field, value) {
28613
- if (!config) return;
28614
- setConfig({ ...config, [field]: value });
28615
- setNotice(null);
28978
+ if (!config) {
28979
+ return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28980
+ /* @__PURE__ */ jsx57(Text48, { bold: true, children: "Project" }),
28981
+ /* @__PURE__ */ jsx57(Text48, { children: " " }),
28982
+ /* @__PURE__ */ jsx57(Text48, { color: PALETTE.accent, children: "Loading..." })
28983
+ ] });
28616
28984
  }
28617
- function handleSave() {
28618
- if (!config) return;
28619
- setStage("saving");
28985
+ const save = () => {
28986
+ setSaving(true);
28620
28987
  setNotice(null);
28621
28988
  writeCredentials(config).then(() => {
28622
28989
  setLastSaved(config);
28623
28990
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
28624
- setNotice({ kind: "success", text: "Configuration saved" });
28625
- setStage("form");
28991
+ setNotice({ kind: "success", text: "Project settings saved" });
28626
28992
  }).catch((err) => {
28627
28993
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
28628
- setStage("form");
28629
- });
28630
- }
28631
- function quit() {
28994
+ }).finally(() => setSaving(false));
28995
+ };
28996
+ const quit = () => {
28632
28997
  void finishDebugRun(
28633
28998
  lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
28634
28999
  );
28635
29000
  onDone();
28636
- }
28637
- useInput11((input, key) => {
28638
- if (stage === "loading" || stage === "saving") return;
28639
- if (editing) {
28640
- if (key.escape) {
28641
- setFieldValue(activeField, valueBeforeEdit);
28642
- setEditing(false);
28643
- }
28644
- return;
28645
- }
28646
- if (key.escape || input === "q") {
28647
- quit();
28648
- return;
28649
- }
28650
- if (input === "s") {
28651
- handleSave();
28652
- return;
28653
- }
28654
- if (input === "c") {
28655
- setFieldValue(activeField, "");
28656
- return;
29001
+ };
29002
+ return /* @__PURE__ */ jsx57(
29003
+ FieldForm,
29004
+ {
29005
+ title: "Project",
29006
+ subtitle: "The Contentful space and where the CLI keeps its files.",
29007
+ fields: FIELDS2,
29008
+ values: valuesOf(config),
29009
+ onChange: (key, value) => {
29010
+ setConfig({ ...config, [key]: value });
29011
+ setNotice(null);
29012
+ },
29013
+ onSave: save,
29014
+ onQuit: quit,
29015
+ notice,
29016
+ busy: saving
28657
29017
  }
28658
- if (key.tab || key.downArrow) {
28659
- const idx = FIELD_ORDER.indexOf(activeField);
28660
- setActiveField(FIELD_ORDER[(idx + 1) % FIELD_ORDER.length]);
29018
+ );
29019
+ }
29020
+
29021
+ // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
29022
+ import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
29023
+ var SECTIONS = [
29024
+ {
29025
+ id: "project",
29026
+ label: "Project",
29027
+ description: "Contentful space, credentials, defaults and where .contentful goes"
29028
+ },
29029
+ { id: "agents", label: "Agents", description: "Which coding agent the CLI uses, and each agent\u2019s settings" }
29030
+ ];
29031
+ function ConfigurationScreen({ onDone }) {
29032
+ const [focus, setFocus] = useState32(0);
29033
+ const [open, setOpen] = useState32(null);
29034
+ const close = () => setOpen(null);
29035
+ useInput13((input, key) => {
29036
+ if (open) return;
29037
+ if (key.upArrow) {
29038
+ setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
28661
29039
  return;
28662
29040
  }
28663
- if (key.upArrow) {
28664
- const idx = FIELD_ORDER.indexOf(activeField);
28665
- setActiveField(FIELD_ORDER[(idx - 1 + FIELD_ORDER.length) % FIELD_ORDER.length]);
29041
+ if (key.downArrow || key.tab) {
29042
+ setFocus((i) => (i + 1) % SECTIONS.length);
28666
29043
  return;
28667
29044
  }
28668
29045
  if (key.return) {
28669
- setValueBeforeEdit(fieldValue(activeField));
28670
- setEditing(true);
29046
+ setOpen(SECTIONS[focus].id);
29047
+ return;
28671
29048
  }
29049
+ if (key.escape || input === "q") onDone();
28672
29050
  });
28673
- if (stage === "loading") {
28674
- return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28675
- /* @__PURE__ */ jsx55(Text46, { bold: true, children: "Configuration" }),
28676
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
28677
- /* @__PURE__ */ jsx55(Text46, { color: PALETTE.accent, children: "Loading..." })
28678
- ] });
28679
- }
28680
- return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28681
- /* @__PURE__ */ jsx55(Text46, { bold: true, children: "Configuration" }),
28682
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
28683
- /* @__PURE__ */ jsx55(Box44, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
28684
- const isActive = activeField === field;
28685
- const value = fieldValue(field);
28686
- const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
28687
- return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
28688
- /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
28689
- /* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
28690
- isActive && editing ? /* @__PURE__ */ jsx55(
28691
- TextInput4,
28692
- {
28693
- value,
28694
- onChange: (next) => setFieldValue(field, next),
28695
- onSubmit: () => setEditing(false),
28696
- mask: field === "cmaToken" ? "\u2022" : void 0
28697
- }
28698
- ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
28699
- FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
28700
- ] }, field);
28701
- }) }),
28702
- notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
28703
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
28704
- /* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
28705
- notice.kind === "success" ? "\u2713" : "\u2717",
28706
- " ",
28707
- notice.text
28708
- ] })
28709
- ] }),
28710
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
28711
- /* @__PURE__ */ jsx55(
29051
+ if (open === "project") return /* @__PURE__ */ jsx58(ProjectConfigScreen, { onDone: close });
29052
+ if (open === "agents") return /* @__PURE__ */ jsx58(AgentsScreen, { onDone: close });
29053
+ return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29054
+ /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Configuration" }),
29055
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
29056
+ SECTIONS.map((section, index) => /* @__PURE__ */ jsxs48(Box47, { gap: 1, children: [
29057
+ /* @__PURE__ */ jsx58(Text49, { color: index === focus ? PALETTE.accent : void 0, children: index === focus ? "\u276F" : " " }),
29058
+ /* @__PURE__ */ jsx58(Box47, { width: 9, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { bold: index === focus, color: index === focus ? PALETTE.accent : void 0, children: section.label }) }),
29059
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: section.description })
29060
+ ] }, section.id)),
29061
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
29062
+ /* @__PURE__ */ jsx58(
28712
29063
  ControlHints,
28713
29064
  {
28714
- hints: editing ? [
28715
- { keys: "type", label: "edit" },
28716
- { keys: "\u2190/\u2192", label: "move cursor" },
28717
- { keys: "\u23CE", label: "done" },
28718
- { keys: "Esc", label: "cancel edit" }
28719
- ] : [
29065
+ hints: [
28720
29066
  { keys: "\u2191/\u2193", label: "move" },
28721
- { keys: "\u23CE", label: "edit" },
28722
- { keys: "c", label: "clear" },
28723
- { keys: "s", label: "save" },
28724
- { keys: "Esc/q", label: "quit without saving" }
29067
+ { keys: "\u23CE", label: "open" },
29068
+ { keys: "Esc/q", label: "back" }
28725
29069
  ]
28726
29070
  }
28727
29071
  )
@@ -28729,8 +29073,8 @@ function ConfigurationScreen({ onDone }) {
28729
29073
  }
28730
29074
 
28731
29075
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
28732
- import { useEffect as useEffect23, useState as useState30 } from "react";
28733
- import { Box as Box45, Text as Text47, useInput as useInput12 } from "ink";
29076
+ import { useEffect as useEffect24, useState as useState33 } from "react";
29077
+ import { Box as Box48, Text as Text50, useInput as useInput14 } from "ink";
28734
29078
 
28735
29079
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
28736
29080
  async function readAnalyticsSetting() {
@@ -28749,11 +29093,11 @@ async function writeAnalyticsSetting(setting) {
28749
29093
 
28750
29094
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
28751
29095
  init_debug_store();
28752
- import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
29096
+ import { Fragment as Fragment19, jsx as jsx59, jsxs as jsxs49 } from "react/jsx-runtime";
28753
29097
  function OptInAnalyticsScreen({ onDone }) {
28754
- const [loading, setLoading] = useState30(true);
28755
- const [enabled, setEnabled] = useState30(true);
28756
- useEffect23(() => {
29098
+ const [loading, setLoading] = useState33(true);
29099
+ const [enabled, setEnabled] = useState33(true);
29100
+ useEffect24(() => {
28757
29101
  readAnalyticsSetting().then((setting) => {
28758
29102
  setEnabled(setting.enabled);
28759
29103
  setLoading(false);
@@ -28765,7 +29109,7 @@ function OptInAnalyticsScreen({ onDone }) {
28765
29109
  });
28766
29110
  });
28767
29111
  }, []);
28768
- useInput12((input, key) => {
29112
+ useInput14((input, key) => {
28769
29113
  if (loading) return;
28770
29114
  if (key.return || input === " ") {
28771
29115
  setEnabled((current) => {
@@ -28780,21 +29124,21 @@ function OptInAnalyticsScreen({ onDone }) {
28780
29124
  onDone();
28781
29125
  }
28782
29126
  });
28783
- return /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28784
- /* @__PURE__ */ jsx56(Text47, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
28785
- /* @__PURE__ */ jsx56(Text47, { children: " " }),
28786
- loading ? /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs46(Fragment18, { children: [
28787
- /* @__PURE__ */ jsxs46(Text47, { children: [
29127
+ return /* @__PURE__ */ jsxs49(Box48, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29128
+ /* @__PURE__ */ jsx59(Text50, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
29129
+ /* @__PURE__ */ jsx59(Text50, { children: " " }),
29130
+ loading ? /* @__PURE__ */ jsx59(Text50, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs49(Fragment19, { children: [
29131
+ /* @__PURE__ */ jsxs49(Text50, { children: [
28788
29132
  "Share anonymous usage data:",
28789
29133
  " ",
28790
- /* @__PURE__ */ jsx56(Text47, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
29134
+ /* @__PURE__ */ jsx59(Text50, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
28791
29135
  ] }),
28792
- /* @__PURE__ */ jsx56(Text47, { children: " " }),
28793
- /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
28794
- /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
29136
+ /* @__PURE__ */ jsx59(Text50, { children: " " }),
29137
+ /* @__PURE__ */ jsx59(Text50, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
29138
+ /* @__PURE__ */ jsx59(Text50, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
28795
29139
  ] }),
28796
- /* @__PURE__ */ jsx56(Text47, { children: " " }),
28797
- /* @__PURE__ */ jsx56(
29140
+ /* @__PURE__ */ jsx59(Text50, { children: " " }),
29141
+ /* @__PURE__ */ jsx59(
28798
29142
  ControlHints,
28799
29143
  {
28800
29144
  hints: [
@@ -28807,15 +29151,15 @@ function OptInAnalyticsScreen({ onDone }) {
28807
29151
  }
28808
29152
 
28809
29153
  // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
28810
- import { useEffect as useEffect24, useState as useState31 } from "react";
28811
- import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
29154
+ import { useEffect as useEffect25, useState as useState34 } from "react";
29155
+ import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
28812
29156
  init_version();
28813
29157
  init_debug_store();
28814
- import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
29158
+ import { jsx as jsx60, jsxs as jsxs50 } from "react/jsx-runtime";
28815
29159
  var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
28816
29160
  function UpgradeScreen({ onDone }) {
28817
- const [upgradeCheck, setUpgradeCheck] = useState31();
28818
- useEffect24(() => {
29161
+ const [upgradeCheck, setUpgradeCheck] = useState34();
29162
+ useEffect25(() => {
28819
29163
  startDebugRun({
28820
29164
  flow: "upgrade",
28821
29165
  step: "01-upgrade",
@@ -28824,7 +29168,7 @@ function UpgradeScreen({ onDone }) {
28824
29168
  });
28825
29169
  checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
28826
29170
  }, []);
28827
- useInput13((_input, key) => {
29171
+ useInput15((_input, key) => {
28828
29172
  if (key.return) {
28829
29173
  void finishDebugRun({
28830
29174
  outputs: upgradeCheck ?? {},
@@ -28835,12 +29179,12 @@ function UpgradeScreen({ onDone }) {
28835
29179
  return;
28836
29180
  }
28837
29181
  });
28838
- return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28839
- /* @__PURE__ */ jsx57(Text48, { bold: true, children: "Upgrade" }),
28840
- /* @__PURE__ */ jsx57(Text48, { children: " " }),
29182
+ return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29183
+ /* @__PURE__ */ jsx60(Text51, { bold: true, children: "Upgrade" }),
29184
+ /* @__PURE__ */ jsx60(Text51, { children: " " }),
28841
29185
  renderBody(upgradeCheck),
28842
- /* @__PURE__ */ jsx57(Text48, { children: " " }),
28843
- /* @__PURE__ */ jsxs47(Text48, { bold: true, color: PALETTE.accent, children: [
29186
+ /* @__PURE__ */ jsx60(Text51, { children: " " }),
29187
+ /* @__PURE__ */ jsxs50(Text51, { bold: true, color: PALETTE.accent, children: [
28844
29188
  FOCUS_MARKER,
28845
29189
  " Go Back"
28846
29190
  ] })
@@ -28848,47 +29192,47 @@ function UpgradeScreen({ onDone }) {
28848
29192
  }
28849
29193
  function renderBody(upgradeCheck) {
28850
29194
  if (!upgradeCheck) {
28851
- return /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "Checking for updates\u2026" });
29195
+ return /* @__PURE__ */ jsx60(Text51, { color: PALETTE.muted, children: "Checking for updates\u2026" });
28852
29196
  }
28853
29197
  if (upgradeCheck.status === "error") {
28854
- return /* @__PURE__ */ jsx57(Text48, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
29198
+ return /* @__PURE__ */ jsx60(Text51, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
28855
29199
  }
28856
29200
  if (upgradeCheck.status === "up-to-date") {
28857
- return /* @__PURE__ */ jsxs47(Text48, { color: PALETTE.success, children: [
29201
+ return /* @__PURE__ */ jsxs50(Text51, { color: PALETTE.success, children: [
28858
29202
  "You're already on the latest version (v",
28859
29203
  upgradeCheck.current,
28860
29204
  ")."
28861
29205
  ] });
28862
29206
  }
28863
- return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", children: [
28864
- /* @__PURE__ */ jsxs47(Text48, { color: PALETTE.muted, children: [
28865
- /* @__PURE__ */ jsxs47(Text48, { bold: true, color: PALETTE.success, children: [
29207
+ return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", children: [
29208
+ /* @__PURE__ */ jsxs50(Text51, { color: PALETTE.muted, children: [
29209
+ /* @__PURE__ */ jsxs50(Text51, { bold: true, color: PALETTE.success, children: [
28866
29210
  "v",
28867
29211
  upgradeCheck.latest
28868
29212
  ] }),
28869
29213
  " ",
28870
29214
  "is available (you're on ",
28871
- /* @__PURE__ */ jsxs47(Text48, { bold: true, children: [
29215
+ /* @__PURE__ */ jsxs50(Text51, { bold: true, children: [
28872
29216
  "v",
28873
29217
  upgradeCheck.current
28874
29218
  ] }),
28875
29219
  "). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
28876
29220
  ] }),
28877
- /* @__PURE__ */ jsx57(Text48, { children: " " }),
28878
- /* @__PURE__ */ jsx57(Box46, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx57(Text48, { bold: true, children: cmd }, cmd)) })
29221
+ /* @__PURE__ */ jsx60(Text51, { children: " " }),
29222
+ /* @__PURE__ */ jsx60(Box49, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx60(Text51, { bold: true, children: cmd }, cmd)) })
28879
29223
  ] });
28880
29224
  }
28881
29225
 
28882
29226
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
28883
- import { useEffect as useEffect25, useState as useState32 } from "react";
28884
- import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
29227
+ import { useEffect as useEffect26, useState as useState35 } from "react";
29228
+ import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
28885
29229
  init_debug_mode_store();
28886
29230
  init_debug_store();
28887
- import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
29231
+ import { jsx as jsx61, jsxs as jsxs51 } from "react/jsx-runtime";
28888
29232
  function DebugModeScreen({ onDone }) {
28889
- const [loading, setLoading] = useState32(true);
28890
- const [enabled, setEnabled] = useState32(true);
28891
- useEffect25(() => {
29233
+ const [loading, setLoading] = useState35(true);
29234
+ const [enabled, setEnabled] = useState35(true);
29235
+ useEffect26(() => {
28892
29236
  readDebugModeSetting().then((setting) => {
28893
29237
  setEnabled(setting.enabled);
28894
29238
  setLoading(false);
@@ -28900,7 +29244,7 @@ function DebugModeScreen({ onDone }) {
28900
29244
  });
28901
29245
  });
28902
29246
  }, []);
28903
- useInput14((input, key) => {
29247
+ useInput16((input, key) => {
28904
29248
  if (loading) return;
28905
29249
  if (key.return || input === " ") {
28906
29250
  setEnabled((current) => {
@@ -28915,16 +29259,16 @@ function DebugModeScreen({ onDone }) {
28915
29259
  onDone();
28916
29260
  }
28917
29261
  });
28918
- return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28919
- /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Settings \u203A Debug Mode" }),
28920
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
28921
- loading ? /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs48(Text49, { children: [
29262
+ return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29263
+ /* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Debug Mode" }),
29264
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
29265
+ loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs51(Text52, { children: [
28922
29266
  "Debug logging:",
28923
29267
  " ",
28924
- /* @__PURE__ */ jsx58(Text49, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
29268
+ /* @__PURE__ */ jsx61(Text52, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
28925
29269
  ] }),
28926
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
28927
- /* @__PURE__ */ jsx58(
29270
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
29271
+ /* @__PURE__ */ jsx61(
28928
29272
  ControlHints,
28929
29273
  {
28930
29274
  hints: [
@@ -28937,18 +29281,18 @@ function DebugModeScreen({ onDone }) {
28937
29281
  }
28938
29282
 
28939
29283
  // packages/experience-design-system-cli/app.tsx
28940
- import { Fragment as Fragment19, jsx as jsx59 } from "react/jsx-runtime";
29284
+ import { Fragment as Fragment20, jsx as jsx62 } from "react/jsx-runtime";
28941
29285
  function App({ importOptions, inkClear }) {
28942
- const [screen, setScreen] = useState33("start");
28943
- const [importExitCode, setImportExitCode] = useState33();
29286
+ const [screen, setScreen] = useState36("start");
29287
+ const [importExitCode, setImportExitCode] = useState36();
28944
29288
  const showImportResult = importExitCode !== void 0;
28945
- const [projectPath, setProjectPath] = useState33();
28946
- const [tokensPath, setTokensPath] = useState33();
28947
- const [scannedFiles, setScannedFiles] = useState33();
28948
- const [pendingLaunch, setPendingLaunch] = useState33();
28949
- const [extractionRun, setExtractionRun] = useState33();
29289
+ const [projectPath, setProjectPath] = useState36();
29290
+ const [tokensPath, setTokensPath] = useState36();
29291
+ const [scannedFiles, setScannedFiles] = useState36();
29292
+ const [pendingLaunch, setPendingLaunch] = useState36();
29293
+ const [extractionRun, setExtractionRun] = useState36();
28950
29294
  const extraction = useExtraction(extractionRun?.input);
28951
- const [scopeRun, setScopeRun] = useState33();
29295
+ const [scopeRun, setScopeRun] = useState36();
28952
29296
  const scopeFlow = useScopeGateFlow(
28953
29297
  scopeRun && {
28954
29298
  sessionId: scopeRun.extraction.sessionId,
@@ -28963,12 +29307,12 @@ function App({ importOptions, inkClear }) {
28963
29307
  }
28964
29308
  }
28965
29309
  );
28966
- const [generationInput, setGenerationInput] = useState33();
29310
+ const [generationInput, setGenerationInput] = useState36();
28967
29311
  const generation = useGeneration(generationInput);
28968
- const [flowStart, setFlowStart] = useState33();
29312
+ const [flowStart, setFlowStart] = useState36();
28969
29313
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
28970
- const [importDefaults, setImportDefaults] = useState33();
28971
- useEffect26(() => {
29314
+ const [importDefaults, setImportDefaults] = useState36();
29315
+ useEffect27(() => {
28972
29316
  if (screen !== "import") {
28973
29317
  setImportDefaults(void 0);
28974
29318
  return;
@@ -28986,7 +29330,7 @@ function App({ importOptions, inkClear }) {
28986
29330
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
28987
29331
  const state2 = await inspectTokens({
28988
29332
  rawTokensPath: tokens,
28989
- contentfulDir: join25(resolveUserPath(projectPath2), ".contentful"),
29333
+ contentfulDir: join26(resolveUserPath(projectPath2), ".contentful"),
28990
29334
  cache: importOptions.cache
28991
29335
  });
28992
29336
  if (state2.kind === "cached") {
@@ -29028,12 +29372,12 @@ function App({ importOptions, inkClear }) {
29028
29372
  }
29029
29373
  });
29030
29374
  };
29031
- useEffect26(() => {
29375
+ useEffect27(() => {
29032
29376
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
29033
29377
  setExtractionRun(void 0);
29034
29378
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
29035
29379
  }, [extraction, extractionRun]);
29036
- useEffect26(() => {
29380
+ useEffect27(() => {
29037
29381
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
29038
29382
  const { extraction: produced, input, generatePromptPath } = scopeRun;
29039
29383
  setGenerationInput({
@@ -29051,7 +29395,7 @@ function App({ importOptions, inkClear }) {
29051
29395
  ...generatePromptPath ? { generatePromptPath } : {}
29052
29396
  });
29053
29397
  }, [scopeFlow, scopeRun, generationInput]);
29054
- useEffect26(() => {
29398
+ useEffect27(() => {
29055
29399
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
29056
29400
  const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
29057
29401
  inkClear();
@@ -29094,9 +29438,9 @@ function App({ importOptions, inkClear }) {
29094
29438
  };
29095
29439
  switch (screen) {
29096
29440
  case "import":
29097
- if (showImportResult) return /* @__PURE__ */ jsx59(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
29441
+ if (showImportResult) return /* @__PURE__ */ jsx62(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
29098
29442
  if (flow && flowStart) {
29099
- return /* @__PURE__ */ jsx59(
29443
+ return /* @__PURE__ */ jsx62(
29100
29444
  FlowScreen,
29101
29445
  {
29102
29446
  state: flow.state,
@@ -29106,12 +29450,12 @@ function App({ importOptions, inkClear }) {
29106
29450
  }
29107
29451
  );
29108
29452
  }
29109
- if (importDefaults === void 0) return /* @__PURE__ */ jsx59(Fragment19, {});
29453
+ if (importDefaults === void 0) return /* @__PURE__ */ jsx62(Fragment20, {});
29110
29454
  if (projectPath === void 0) {
29111
- return /* @__PURE__ */ jsx59(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
29455
+ return /* @__PURE__ */ jsx62(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
29112
29456
  }
29113
29457
  if (tokensPath === void 0) {
29114
- return /* @__PURE__ */ jsx59(
29458
+ return /* @__PURE__ */ jsx62(
29115
29459
  TokenInputScreen,
29116
29460
  {
29117
29461
  initialPath: importDefaults.tokenFile,
@@ -29121,7 +29465,7 @@ function App({ importOptions, inkClear }) {
29121
29465
  );
29122
29466
  }
29123
29467
  if (scannedFiles === void 0) {
29124
- return /* @__PURE__ */ jsx59(
29468
+ return /* @__PURE__ */ jsx62(
29125
29469
  PathValidationScreen,
29126
29470
  {
29127
29471
  projectPath,
@@ -29133,10 +29477,10 @@ function App({ importOptions, inkClear }) {
29133
29477
  }
29134
29478
  if (extractionRun) {
29135
29479
  if (extraction?.status === "done" && !extraction.result.ok) {
29136
- return /* @__PURE__ */ jsx59(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
29480
+ return /* @__PURE__ */ jsx62(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
29137
29481
  }
29138
29482
  if (extraction?.status === "running") {
29139
- return /* @__PURE__ */ jsx59(
29483
+ return /* @__PURE__ */ jsx62(
29140
29484
  ExtractionScreen,
29141
29485
  {
29142
29486
  progress: extraction.progress,
@@ -29145,14 +29489,14 @@ function App({ importOptions, inkClear }) {
29145
29489
  }
29146
29490
  );
29147
29491
  }
29148
- return /* @__PURE__ */ jsx59(Fragment19, {});
29492
+ return /* @__PURE__ */ jsx62(Fragment20, {});
29149
29493
  }
29150
29494
  if (scopeRun && scopeFlow) {
29151
29495
  if (scopeFlow.status === "failed") {
29152
- return /* @__PURE__ */ jsx59(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
29496
+ return /* @__PURE__ */ jsx62(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
29153
29497
  }
29154
29498
  if (scopeFlow.status === "deciding") {
29155
- return /* @__PURE__ */ jsx59(
29499
+ return /* @__PURE__ */ jsx62(
29156
29500
  ScopeGateScreen,
29157
29501
  {
29158
29502
  components: scopeFlow.load.components,
@@ -29162,7 +29506,7 @@ function App({ importOptions, inkClear }) {
29162
29506
  );
29163
29507
  }
29164
29508
  if (generation?.status === "done" && !generation.result.ok) {
29165
- return /* @__PURE__ */ jsx59(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
29509
+ return /* @__PURE__ */ jsx62(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
29166
29510
  }
29167
29511
  if (generation?.status === "running") {
29168
29512
  const hasRawTokens = scopeRun.input.rawTokensPath !== "";
@@ -29170,7 +29514,7 @@ function App({ importOptions, inkClear }) {
29170
29514
  hasRawTokens,
29171
29515
  mapTokensEligible: generation.progress.mapTokensEligible
29172
29516
  });
29173
- return /* @__PURE__ */ jsx59(
29517
+ return /* @__PURE__ */ jsx62(
29174
29518
  GenerationScreen,
29175
29519
  {
29176
29520
  progress: generation.progress,
@@ -29182,10 +29526,10 @@ function App({ importOptions, inkClear }) {
29182
29526
  }
29183
29527
  );
29184
29528
  }
29185
- return /* @__PURE__ */ jsx59(Fragment19, {});
29529
+ return /* @__PURE__ */ jsx62(Fragment20, {});
29186
29530
  }
29187
29531
  if (pendingLaunch?.cached) {
29188
- return /* @__PURE__ */ jsx59(
29532
+ return /* @__PURE__ */ jsx62(
29189
29533
  TokenReuseScreen,
29190
29534
  {
29191
29535
  tokensPath: pendingLaunch.cached.tokensPath,
@@ -29196,7 +29540,7 @@ function App({ importOptions, inkClear }) {
29196
29540
  }
29197
29541
  );
29198
29542
  }
29199
- return /* @__PURE__ */ jsx59(
29543
+ return /* @__PURE__ */ jsx62(
29200
29544
  CredentialsScreen,
29201
29545
  {
29202
29546
  initial: importDefaults.credentials,
@@ -29205,19 +29549,19 @@ function App({ importOptions, inkClear }) {
29205
29549
  }
29206
29550
  );
29207
29551
  case "help":
29208
- return /* @__PURE__ */ jsx59(HelpScreen, { onDone: goToStart });
29552
+ return /* @__PURE__ */ jsx62(HelpScreen, { onDone: goToStart });
29209
29553
  case "upgrade":
29210
- return /* @__PURE__ */ jsx59(UpgradeScreen, { onDone: goToStart });
29554
+ return /* @__PURE__ */ jsx62(UpgradeScreen, { onDone: goToStart });
29211
29555
  case "settings":
29212
- return /* @__PURE__ */ jsx59(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
29556
+ return /* @__PURE__ */ jsx62(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
29213
29557
  case "settings-configuration":
29214
- return /* @__PURE__ */ jsx59(ConfigurationScreen, { onDone: goToSettings });
29558
+ return /* @__PURE__ */ jsx62(ConfigurationScreen, { onDone: goToSettings });
29215
29559
  case "settings-opt-in-analytics":
29216
- return /* @__PURE__ */ jsx59(OptInAnalyticsScreen, { onDone: goToSettings });
29560
+ return /* @__PURE__ */ jsx62(OptInAnalyticsScreen, { onDone: goToSettings });
29217
29561
  case "settings-debug-mode":
29218
- return /* @__PURE__ */ jsx59(DebugModeScreen, { onDone: goToSettings });
29562
+ return /* @__PURE__ */ jsx62(DebugModeScreen, { onDone: goToSettings });
29219
29563
  case "start":
29220
- return /* @__PURE__ */ jsx59(HomeScreen, { onNavigate: setScreen });
29564
+ return /* @__PURE__ */ jsx62(HomeScreen, { onNavigate: setScreen });
29221
29565
  }
29222
29566
  }
29223
29567
  async function runApp(renderApp, importOptions) {
@@ -29225,7 +29569,7 @@ async function runApp(renderApp, importOptions) {
29225
29569
  instance.clear?.();
29226
29570
  process.stdout.write("\x1B[H\x1B[0J");
29227
29571
  };
29228
- const instance = renderApp(/* @__PURE__ */ jsx59(App, { importOptions, inkClear }));
29572
+ const instance = renderApp(/* @__PURE__ */ jsx62(App, { importOptions, inkClear }));
29229
29573
  await instance.waitUntilExit();
29230
29574
  }
29231
29575
  export {