@contentful/experience-design-system-cli 2.37.1-dev-build-a67bc4a4.0 → 2.37.1-dev-build-5efcf6e5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1500,7 +1500,7 @@ async function runAgent(options) {
1500
1500
  promptLen: prompt.length,
1501
1501
  promptHead: prompt.slice(0, 500)
1502
1502
  });
1503
- return new Promise((resolve27) => {
1503
+ return new Promise((resolve28) => {
1504
1504
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
1505
1505
  const child = spawn(binary, args, {
1506
1506
  stdio: ["pipe", "pipe", "pipe"],
@@ -1549,7 +1549,7 @@ async function runAgent(options) {
1549
1549
  stderrLen: stderr.length,
1550
1550
  stderrTail: stderr.slice(-1e3)
1551
1551
  });
1552
- resolve27(result);
1552
+ resolve28(result);
1553
1553
  });
1554
1554
  });
1555
1555
  }
@@ -1571,7 +1571,7 @@ async function checkAgentAuth(agent) {
1571
1571
  return "not-found";
1572
1572
  if (agent !== "claude")
1573
1573
  return "ok";
1574
- return new Promise((resolve27) => {
1574
+ return new Promise((resolve28) => {
1575
1575
  const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
1576
1576
  let stdout = "";
1577
1577
  let done = false;
@@ -1580,7 +1580,7 @@ async function checkAgentAuth(agent) {
1580
1580
  return;
1581
1581
  done = true;
1582
1582
  child.kill("SIGTERM");
1583
- resolve27("unauthenticated");
1583
+ resolve28("unauthenticated");
1584
1584
  }, 5e3);
1585
1585
  child.stdout?.on("data", (chunk) => {
1586
1586
  stdout += chunk.toString();
@@ -1591,14 +1591,14 @@ async function checkAgentAuth(agent) {
1591
1591
  done = true;
1592
1592
  clearTimeout(timer);
1593
1593
  if (code !== 0) {
1594
- resolve27("unauthenticated");
1594
+ resolve28("unauthenticated");
1595
1595
  return;
1596
1596
  }
1597
1597
  try {
1598
1598
  const status = JSON.parse(stdout);
1599
- resolve27(status.loggedIn ? "ok" : "unauthenticated");
1599
+ resolve28(status.loggedIn ? "ok" : "unauthenticated");
1600
1600
  } catch {
1601
- resolve27("unauthenticated");
1601
+ resolve28("unauthenticated");
1602
1602
  }
1603
1603
  });
1604
1604
  });
@@ -1608,9 +1608,9 @@ async function binaryIsOnPath(binary) {
1608
1608
  const fs = await import("node:fs/promises");
1609
1609
  return fs.access(binary).then(() => true, () => false);
1610
1610
  }
1611
- return new Promise((resolve27) => {
1611
+ return new Promise((resolve28) => {
1612
1612
  const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
1613
- child.on("close", (code) => resolve27(code === 0));
1613
+ child.on("close", (code) => resolve28(code === 0));
1614
1614
  });
1615
1615
  }
1616
1616
  var init_check_agent_auth = __esm({
@@ -7916,10 +7916,10 @@ function extractVueSlotsFromSetup(options) {
7916
7916
  if (!body)
7917
7917
  return [];
7918
7918
  const slotsByName = /* @__PURE__ */ new Map();
7919
- for (const access6 of body.getDescendantsOfKind(SyntaxKind5.PropertyAccessExpression)) {
7920
- if (access6.getExpression().getText() !== slotsName)
7919
+ for (const access7 of body.getDescendantsOfKind(SyntaxKind5.PropertyAccessExpression)) {
7920
+ if (access7.getExpression().getText() !== slotsName)
7921
7921
  continue;
7922
- const slotName = access6.getName();
7922
+ const slotName = access7.getName();
7923
7923
  if (!slotsByName.has(slotName)) {
7924
7924
  slotsByName.set(slotName, {
7925
7925
  name: slotName,
@@ -14333,7 +14333,7 @@ function errorMessage(error) {
14333
14333
  return error instanceof Error && error.message ? error.message : String(error);
14334
14334
  }
14335
14335
  function defaultSleep(delayMs) {
14336
- return new Promise((resolve27) => setTimeout(resolve27, delayMs));
14336
+ return new Promise((resolve28) => setTimeout(resolve28, delayMs));
14337
14337
  }
14338
14338
  var MAX_RETRY_AFTER_MS;
14339
14339
  var init_http_utils = __esm({
@@ -14609,7 +14609,7 @@ var init_api_client = __esm({
14609
14609
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
14610
14610
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
14611
14611
  const jitter = Math.random() * baseDelay * 0.15;
14612
- await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
14612
+ await new Promise((resolve28) => setTimeout(resolve28, baseDelay + jitter));
14613
14613
  }
14614
14614
  }
14615
14615
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -16147,11 +16147,11 @@ function setCommandContext(context) {
16147
16147
  mergeContext(state.pending.context, context);
16148
16148
  mergeContext(state.pending.completion, context);
16149
16149
  }
16150
- function enrichCommandResult(fields) {
16150
+ function enrichCommandResult(fields2) {
16151
16151
  if (!state.pending)
16152
16152
  return;
16153
- Object.assign(state.pending.completion, fields);
16154
- mergeContext(state.pending.context, fields);
16153
+ Object.assign(state.pending.completion, fields2);
16154
+ mergeContext(state.pending.context, fields2);
16155
16155
  }
16156
16156
  var state;
16157
16157
  var init_pending_command = __esm({
@@ -16235,16 +16235,16 @@ async function completeActiveCommand() {
16235
16235
  duration_ms: durationMs
16236
16236
  }, state.sessionId, { flush: true });
16237
16237
  }
16238
- async function failActiveCommand(fields = {}) {
16238
+ async function failActiveCommand(fields2 = {}) {
16239
16239
  if (!state.pending || state.pending.terminalEmitted || !state.sessionId || !state.pending.invoked)
16240
16240
  return;
16241
16241
  state.pending.terminalEmitted = true;
16242
16242
  const durationMs = Date.now() - state.pending.startedAt;
16243
- const outcome = fields.exit_code === 130 ? "interrupted" : "error";
16243
+ const outcome = fields2.exit_code === 130 ? "interrupted" : "error";
16244
16244
  await trackEvent("dsi_cli_command_failed", {
16245
16245
  ...buildBaseProps(state.pending.command),
16246
16246
  ...state.pending.context,
16247
- ...fields,
16247
+ ...fields2,
16248
16248
  outcome,
16249
16249
  duration_ms: durationMs
16250
16250
  }, state.sessionId, { flush: true });
@@ -18527,7 +18527,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
18527
18527
  const message = error instanceof Error ? error.message : String(error);
18528
18528
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
18529
18529
  throw error;
18530
- await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
18530
+ await new Promise((resolve28) => setTimeout(resolve28, Math.min(250 * attempt, 2e3)));
18531
18531
  }
18532
18532
  }
18533
18533
  }
@@ -19446,6 +19446,7 @@ var init_src4 = __esm({
19446
19446
  init_agents();
19447
19447
  init_agent_name();
19448
19448
  init_models();
19449
+ init_binaries();
19449
19450
  init_is_agent_name();
19450
19451
  init_agent_supports_bedrock();
19451
19452
  init_check_agent_auth();
@@ -19554,10 +19555,10 @@ var init_config = __esm({
19554
19555
  }
19555
19556
  });
19556
19557
 
19557
- // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
19558
+ // packages/experience-design-system-cli/src/tui/settings/shared/v1-store.ts
19558
19559
  var readV1Store, writeV1Store;
19559
19560
  var init_v1_store = __esm({
19560
- "packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts"() {
19561
+ "packages/experience-design-system-cli/src/tui/settings/shared/v1-store.ts"() {
19561
19562
  "use strict";
19562
19563
  init_config();
19563
19564
  readV1Store = readSettings2;
@@ -19565,6 +19566,89 @@ var init_v1_store = __esm({
19565
19566
  }
19566
19567
  });
19567
19568
 
19569
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-store.ts
19570
+ function emptyAgents() {
19571
+ return Object.fromEntries(AGENT_NAMES.map((name) => [name, { model: "", binary: "" }]));
19572
+ }
19573
+ async function readAgentConfig() {
19574
+ const store = await readV1Store();
19575
+ const stored = asString(store["agent"]);
19576
+ const defaultAgent = isAgentName(stored) ? stored : DEFAULT_AGENT_NAME;
19577
+ const agents = emptyAgents();
19578
+ const saved = store["agents"];
19579
+ if (saved && typeof saved === "object") {
19580
+ for (const name of AGENT_NAMES) {
19581
+ const entry = saved[name];
19582
+ if (entry && typeof entry === "object") {
19583
+ const fields2 = entry;
19584
+ agents[name] = { model: asString(fields2["model"]), binary: asString(fields2["binary"]) };
19585
+ }
19586
+ }
19587
+ }
19588
+ const legacyModel = asString(store["agentModel"]);
19589
+ if (legacyModel && !agents[defaultAgent].model)
19590
+ agents[defaultAgent] = { ...agents[defaultAgent], model: legacyModel };
19591
+ return { defaultAgent, agents };
19592
+ }
19593
+ async function writeAgentConfig(config) {
19594
+ const existing = await readV1Store();
19595
+ const merged = { ...existing };
19596
+ const agents = {};
19597
+ for (const name of AGENT_NAMES) {
19598
+ const model = config.agents[name].model.trim();
19599
+ const binary = config.agents[name].binary.trim();
19600
+ if (model || binary) agents[name] = { ...model ? { model } : {}, ...binary ? { binary } : {} };
19601
+ }
19602
+ merged["agent"] = config.defaultAgent;
19603
+ const defaultModel = agents[config.defaultAgent]?.model;
19604
+ if (defaultModel) merged["agentModel"] = defaultModel;
19605
+ else delete merged["agentModel"];
19606
+ if (Object.keys(agents).length > 0) merged["agents"] = agents;
19607
+ else delete merged["agents"];
19608
+ await writeV1Store(merged);
19609
+ }
19610
+ var AGENT_LABELS, asString;
19611
+ var init_agent_store = __esm({
19612
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-store.ts"() {
19613
+ "use strict";
19614
+ init_src4();
19615
+ init_v1_store();
19616
+ AGENT_LABELS = {
19617
+ claude: "Claude Code",
19618
+ codex: "OpenAI Codex",
19619
+ opencode: "OpenCode",
19620
+ cursor: "Cursor",
19621
+ copilot: "GitHub Copilot"
19622
+ };
19623
+ asString = (value) => typeof value === "string" ? value : "";
19624
+ }
19625
+ });
19626
+
19627
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/apply-binary-overrides.ts
19628
+ function applyBinaryOverrides(config) {
19629
+ for (const name of AGENT_NAMES) {
19630
+ const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
19631
+ const binary = config.agents[name].binary.trim();
19632
+ if (binary) {
19633
+ if (!shellValues.has(key)) shellValues.set(key, process.env[key]);
19634
+ process.env[key] = binary;
19635
+ } else if (shellValues.has(key)) {
19636
+ const shellValue = shellValues.get(key);
19637
+ if (shellValue === void 0) delete process.env[key];
19638
+ else process.env[key] = shellValue;
19639
+ shellValues.delete(key);
19640
+ }
19641
+ }
19642
+ }
19643
+ var shellValues;
19644
+ var init_apply_binary_overrides = __esm({
19645
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/apply-binary-overrides.ts"() {
19646
+ "use strict";
19647
+ init_src4();
19648
+ shellValues = /* @__PURE__ */ new Map();
19649
+ }
19650
+ });
19651
+
19568
19652
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
19569
19653
  async function readAnalyticsSetting() {
19570
19654
  const store = await readV1Store();
@@ -19652,7 +19736,7 @@ var init_home_theme = __esm({
19652
19736
  }
19653
19737
  });
19654
19738
 
19655
- // packages/experience-design-system-cli/src/tui/home/version.ts
19739
+ // packages/experience-design-system-cli/src/tui/upgrade/version.ts
19656
19740
  import { readFileSync as readFileSync8 } from "node:fs";
19657
19741
  import { join as join17 } from "node:path";
19658
19742
  import semver from "semver";
@@ -19685,7 +19769,7 @@ async function checkForUpgrade() {
19685
19769
  }
19686
19770
  var PACKAGE_NAME2, TAGS_URL;
19687
19771
  var init_version = __esm({
19688
- "packages/experience-design-system-cli/src/tui/home/version.ts"() {
19772
+ "packages/experience-design-system-cli/src/tui/upgrade/version.ts"() {
19689
19773
  "use strict";
19690
19774
  init_package_root();
19691
19775
  PACKAGE_NAME2 = "@contentful/experience-design-system-cli";
@@ -19739,11 +19823,14 @@ var init_control_hints = __esm({
19739
19823
  import { useEffect as useEffect2, useState as useState2 } from "react";
19740
19824
  import { Box, Text as Text2, useApp, useInput } from "ink";
19741
19825
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
19742
- function versionStatus(upgradeCheck) {
19826
+ function upgradeItemDisplay(upgradeCheck) {
19743
19827
  if (upgradeCheck?.status === "update-available") {
19744
- return { text: ` (upgrade available v${upgradeCheck.latest})`, color: PALETTE.success };
19828
+ return { label: `Upgrade Version (v${upgradeCheck.latest} available)`, color: PALETTE.warning };
19745
19829
  }
19746
- return void 0;
19830
+ if (upgradeCheck?.status === "up-to-date") {
19831
+ return { label: "Upgrade Version (up to date)", color: PALETTE.muted };
19832
+ }
19833
+ return { label: "Upgrade Version" };
19747
19834
  }
19748
19835
  function HomeScreen({ onNavigate }) {
19749
19836
  const [focusIdx, setFocusIdx] = useState2(0);
@@ -19751,7 +19838,7 @@ function HomeScreen({ onNavigate }) {
19751
19838
  const { exit } = useApp();
19752
19839
  const terminalWidth = useTerminalWidth();
19753
19840
  const tooNarrow = terminalWidth < MIN_TERMINAL_WIDTH;
19754
- const status = versionStatus(upgradeCheck);
19841
+ const upgradeDisabled = upgradeCheck?.status === "up-to-date";
19755
19842
  useEffect2(() => {
19756
19843
  checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
19757
19844
  }, []);
@@ -19771,6 +19858,7 @@ function HomeScreen({ onNavigate }) {
19771
19858
  }
19772
19859
  if (key.return) {
19773
19860
  const item = START_ITEMS[focusIdx];
19861
+ if (item.screen === "upgrade" && upgradeDisabled) return;
19774
19862
  onNavigate(item.screen);
19775
19863
  return;
19776
19864
  }
@@ -19788,16 +19876,26 @@ function HomeScreen({ onNavigate }) {
19788
19876
  /* @__PURE__ */ jsx2(Text2, { color: PALETTE.muted, children: SUBTITLE }),
19789
19877
  /* @__PURE__ */ jsxs(Text2, { color: PALETTE.muted, children: [
19790
19878
  "v",
19791
- VERSION,
19792
- status && /* @__PURE__ */ jsx2(Text2, { color: status.color, children: status.text })
19879
+ VERSION
19793
19880
  ] })
19794
19881
  ] }),
19795
19882
  /* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(Box, { flexDirection: "column", children: START_ITEMS.map((item, i) => {
19796
19883
  const focused = i === focusIdx;
19797
- return /* @__PURE__ */ jsxs(Text2, { bold: focused, color: focused ? PALETTE.accent : void 0, children: [
19798
- focused ? `${FOCUS_MARKER} ` : " ",
19884
+ const isUpgradeItem = item.screen === "upgrade";
19885
+ const display = isUpgradeItem ? upgradeItemDisplay(upgradeCheck) : { label: item.label };
19886
+ const dimmed = isUpgradeItem && upgradeDisabled;
19887
+ return /* @__PURE__ */ jsxs(
19888
+ Text2,
19889
+ {
19890
+ bold: focused && !dimmed,
19891
+ color: dimmed ? PALETTE.muted : focused ? PALETTE.accent : display.color,
19892
+ children: [
19893
+ focused ? `${FOCUS_MARKER} ` : " ",
19894
+ display.label
19895
+ ]
19896
+ },
19799
19897
  item.label
19800
- ] }, item.label);
19898
+ );
19801
19899
  }) }) }),
19802
19900
  /* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(
19803
19901
  ControlHints,
@@ -19826,6 +19924,7 @@ var init_home = __esm({
19826
19924
  MIN_TERMINAL_WIDTH = 164;
19827
19925
  START_ITEMS = [
19828
19926
  { label: "Import", screen: "import" },
19927
+ { label: "Upgrade Version", screen: "upgrade" },
19829
19928
  { label: "Settings", screen: "settings" },
19830
19929
  { label: "Help", screen: "help" }
19831
19930
  ];
@@ -26116,16 +26215,16 @@ function SlotRow({
26116
26215
  ] });
26117
26216
  }
26118
26217
  function propFields(prop) {
26119
- const fields = ["description", "required", "type"];
26218
+ const fields2 = ["description", "required", "type"];
26120
26219
  if (prop.type === "token") {
26121
- fields.push("tokenKind");
26220
+ fields2.push("tokenKind");
26122
26221
  }
26123
- if (prop.type === "enum") fields.push("values");
26222
+ if (prop.type === "enum") fields2.push("values");
26124
26223
  if (prop.type !== "richtext" && prop.type !== "media" && prop.type !== "link") {
26125
- fields.push("default");
26224
+ fields2.push("default");
26126
26225
  }
26127
- if (prop.type === "token" && prop.category === "design") fields.push("allowed");
26128
- return fields;
26226
+ if (prop.type === "token" && prop.category === "design") fields2.push("allowed");
26227
+ return fields2;
26129
26228
  }
26130
26229
  function simulateGraphWithCandidate(projectSlotGraph, selfName, currentSlots, targetSlotName, candidate) {
26131
26230
  const selfEntry = {
@@ -26663,8 +26762,8 @@ function FieldEditor({
26663
26762
  return;
26664
26763
  }
26665
26764
  if (focusLevel === "field") {
26666
- const fields = inSlots ? SLOT_FIELDS : currentProp ? propFields(currentProp) : [];
26667
- const currentFieldIdx = fields.indexOf(activeField);
26765
+ const fields2 = inSlots ? SLOT_FIELDS : currentProp ? propFields(currentProp) : [];
26766
+ const currentFieldIdx = fields2.indexOf(activeField);
26668
26767
  const isValuesNav = activeField === "values" || activeField === "allowedComponents";
26669
26768
  const arrowUp = key.upArrow;
26670
26769
  const arrowDown = key.downArrow;
@@ -26678,10 +26777,10 @@ function FieldEditor({
26678
26777
  const navPrevious = arrowUp || arrowLeft;
26679
26778
  const navNext = arrowDown || arrowRight || input === "j";
26680
26779
  const navBack = navPrevious || input === "k";
26681
- if ((navBack || navNext) && fields.length > 0) {
26682
- const lastIdx = fields.length - 1;
26780
+ if ((navBack || navNext) && fields2.length > 0) {
26781
+ const lastIdx = fields2.length - 1;
26683
26782
  const targetIdx = navNext ? currentFieldIdx >= lastIdx ? 0 : currentFieldIdx + 1 : currentFieldIdx <= 0 ? lastIdx : currentFieldIdx - 1;
26684
- const next = fields[targetIdx];
26783
+ const next = fields2[targetIdx];
26685
26784
  setActiveField(next);
26686
26785
  if (next === "description") {
26687
26786
  const desc = inSlots ? currentSlot?.description ?? "" : currentProp?.description ?? "";
@@ -32258,7 +32357,7 @@ var init_save = __esm({
32258
32357
  writeFile: (path5, contents) => writeFile7(path5, contents),
32259
32358
  appendRun,
32260
32359
  buildSourceFingerprint,
32261
- sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
32360
+ sleep: (ms) => new Promise((resolve28) => setTimeout(resolve28, ms)),
32262
32361
  warn: (message) => process.stderr.write(message)
32263
32362
  });
32264
32363
  }
@@ -32809,13 +32908,48 @@ var init_debug_store = __esm({
32809
32908
  }
32810
32909
  });
32811
32910
 
32911
+ // packages/experience-design-system-cli/src/tui/help/file-locations.ts
32912
+ import { join as join26, resolve as resolve27 } from "node:path";
32913
+ function describeFileLocations({
32914
+ contentfulBaseDir,
32915
+ debugModeEnabled,
32916
+ currentSessionDir: currentSessionDir2
32917
+ }) {
32918
+ if (!debugModeEnabled) {
32919
+ return {
32920
+ debugLogs: "none while Debug Mode is off",
32921
+ importFiles: `${join26("<project>", ".contentful")}/ (tokens.json, components.json)`
32922
+ };
32923
+ }
32924
+ const base = contentfulBaseDir ? resolve27(contentfulBaseDir) : "<project>";
32925
+ const session = currentSessionDir2 ?? join26(base, ".contentful", "<date>-session-<n>");
32926
+ return {
32927
+ debugLogs: join26(session, "debug"),
32928
+ importFiles: `${join26(session, "dsi-import-<n>")}/ (tokens.json, components.json)`
32929
+ };
32930
+ }
32931
+ var init_file_locations = __esm({
32932
+ "packages/experience-design-system-cli/src/tui/help/file-locations.ts"() {
32933
+ "use strict";
32934
+ }
32935
+ });
32936
+
32812
32937
  // packages/experience-design-system-cli/src/tui/help/help-info.ts
32813
32938
  async function readHelpInfo() {
32814
- const debugMode = await readDebugModeSetting();
32939
+ const [debugMode, settings] = await Promise.all([readDebugModeSetting(), readSettings2()]);
32940
+ const base = settings["contentfulBaseDir"];
32941
+ const locations = describeFileLocations({
32942
+ contentfulBaseDir: typeof base === "string" ? base : "",
32943
+ debugModeEnabled: debugMode.enabled,
32944
+ currentSessionDir: currentSessionDir()
32945
+ });
32815
32946
  return {
32816
32947
  storage: [
32817
32948
  { label: "Config folder", value: configRoot2() },
32818
- { label: "Settings file", value: configFilePath2() }
32949
+ { label: "Settings file", value: configFilePath2() },
32950
+ { label: "Agent settings", value: `${configFilePath2()} (keys: agent, agentModel, agents)` },
32951
+ { label: "Debug logs", value: locations.debugLogs },
32952
+ { label: "Import files", value: locations.importFiles }
32819
32953
  ],
32820
32954
  troubleshooting: [
32821
32955
  { label: "CLI version", value: readPackageVersion() },
@@ -32836,6 +32970,7 @@ var init_help_info = __esm({
32836
32970
  init_debug_store();
32837
32971
  init_debug_mode_store();
32838
32972
  init_version();
32973
+ init_file_locations();
32839
32974
  }
32840
32975
  });
32841
32976
 
@@ -32847,7 +32982,7 @@ function Section({ title, rows }) {
32847
32982
  return /* @__PURE__ */ jsxs43(Box42, { flexDirection: "column", children: [
32848
32983
  /* @__PURE__ */ jsx53(Text44, { bold: true, color: PALETTE.accent, children: title }),
32849
32984
  rows.map((row) => /* @__PURE__ */ jsxs43(Box42, { gap: 1, children: [
32850
- /* @__PURE__ */ jsx53(Box42, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
32985
+ /* @__PURE__ */ jsx53(Box42, { width: 16, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
32851
32986
  /* @__PURE__ */ jsx53(Text44, { children: row.value })
32852
32987
  ] }, row.label))
32853
32988
  ] });
@@ -32962,7 +33097,657 @@ var init_PageContainer3 = __esm({
32962
33097
  }
32963
33098
  });
32964
33099
 
32965
- // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
33100
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
33101
+ import { execFile as execFile2 } from "node:child_process";
33102
+ import { access as access6, constants } from "node:fs/promises";
33103
+ function effectiveBinary(name, savedBinary) {
33104
+ return savedBinary.trim() || AGENT_BINARIES[name];
33105
+ }
33106
+ function defaultModelLabel(name) {
33107
+ const model = DEFAULT_MODELS[name];
33108
+ return model && model !== "Auto" ? model : "chosen by the agent";
33109
+ }
33110
+ function resolveOnPath(binary) {
33111
+ if (binary.includes("/")) {
33112
+ return access6(binary, constants.X_OK).then(
33113
+ () => binary,
33114
+ () => null
33115
+ );
33116
+ }
33117
+ return new Promise((resolve28) => {
33118
+ execFile2(
33119
+ process.platform === "win32" ? "where" : "which",
33120
+ [binary],
33121
+ (error, stdout) => resolve28(error ? null : stdout.split("\n")[0]?.trim() ?? null)
33122
+ );
33123
+ });
33124
+ }
33125
+ function readVersion(binary) {
33126
+ return new Promise((resolve28) => {
33127
+ execFile2(binary, ["--version"], { timeout: VERSION_TIMEOUT_MS }, (error, stdout) => {
33128
+ const line = stdout.split("\n")[0]?.trim() ?? "";
33129
+ if (!error && line) resolve28(pass("version", line));
33130
+ else resolve28(fail3("version", "runs, but did not report a version"));
33131
+ });
33132
+ });
33133
+ }
33134
+ async function inspect(name, binary) {
33135
+ const target = effectiveBinary(name, binary);
33136
+ const found = await resolveOnPath(target);
33137
+ if (!found) return { checks: [fail3("path", `\`${target}\` was not found or is not executable`)], found: null };
33138
+ const checks = [pass("path", found)];
33139
+ checks.push(await readVersion(found));
33140
+ if (name === "claude") {
33141
+ const auth = await withBinaryEnv(name, found, () => checkAgentAuth(name));
33142
+ checks.push(
33143
+ auth === "ok" ? pass("login", "logged in") : fail3("login", auth === "not-found" ? "binary not found" : `not logged in: ${LOGIN_HINTS.claude}`)
33144
+ );
33145
+ }
33146
+ return { checks, found };
33147
+ }
33148
+ async function inspectAgent(name, binary) {
33149
+ return (await inspect(name, binary)).checks;
33150
+ }
33151
+ async function testAgent(name, binary, model) {
33152
+ const { checks, found } = await inspect(name, binary);
33153
+ if (!found || !checks.every((check) => check.step === "version" || check.ok)) return checks;
33154
+ const started = Date.now();
33155
+ const result = await withBinaryEnv(
33156
+ name,
33157
+ found,
33158
+ () => createLocalCliAgentInvoker().invoke({
33159
+ agent: name,
33160
+ ...model.trim() ? { model: model.trim() } : {},
33161
+ prompt: TEST_PROMPT,
33162
+ timeoutMs: PROMPT_TIMEOUT_MS
33163
+ })
33164
+ );
33165
+ const seconds = ((Date.now() - started) / 1e3).toFixed(1);
33166
+ if (result.timedOut) {
33167
+ return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
33168
+ }
33169
+ if (result.exitCode !== 0) {
33170
+ const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
33171
+ return [...checks, fail3("prompt", reason)];
33172
+ }
33173
+ return [...checks, pass("prompt", `answered in ${seconds}s`)];
33174
+ }
33175
+ function statusFromChecks(name, checks, savedBinary) {
33176
+ if (checks.length === 0) return "checking";
33177
+ if (checks.some((check) => check.step === "path" && !check.ok)) {
33178
+ return savedBinary.trim() ? "not-found" : "not-configured";
33179
+ }
33180
+ const prompt = checks.find((check) => check.step === "prompt");
33181
+ if (prompt) {
33182
+ if (prompt.ok) return "ready";
33183
+ return prompt.timedOut ? "timed-out" : "test-failed";
33184
+ }
33185
+ const login = checks.find((check) => check.step === "login");
33186
+ if (login) return login.ok ? "ready" : "not-logged-in";
33187
+ return name === "claude" ? "ready" : "unknown";
33188
+ }
33189
+ function setupHint(name, status) {
33190
+ if (status === "not-configured") return `${INSTALL_HINTS[name]}, or set its command path in settings`;
33191
+ if (status === "not-found") return `${INSTALL_HINTS[name]}, or correct the command path in settings`;
33192
+ if (status === "not-logged-in") return LOGIN_HINTS[name];
33193
+ if (status === "test-failed") return `read the test message; if it is a login problem, ${LOGIN_HINTS[name]}`;
33194
+ if (status === "timed-out") return "it may be slow or waiting for input; run the test again, or try it in a terminal";
33195
+ if (status === "unknown") return "run a full test to confirm it is logged in";
33196
+ return "";
33197
+ }
33198
+ function testOutcome(checks) {
33199
+ const prompt = checks?.find((check) => check.step === "prompt");
33200
+ if (!prompt) return void 0;
33201
+ if (prompt.ok) return { ok: true, text: `Test passed: ${prompt.detail}` };
33202
+ if (prompt.timedOut) return { ok: false, text: `Test timed out: ${prompt.detail}` };
33203
+ return { ok: false, text: `Test failed: ${prompt.detail}` };
33204
+ }
33205
+ function modelLine(name, savedModel) {
33206
+ const model = savedModel.trim();
33207
+ return model ? model : `${defaultModelLabel(name)} (built-in default)`;
33208
+ }
33209
+ function baseRows(name, checks, savedBinary) {
33210
+ const path5 = checks.find((check) => check.step === "path");
33211
+ const version = checks.find((check) => check.step === "version");
33212
+ const hint = setupHint(name, statusFromChecks(name, checks, savedBinary));
33213
+ const setup = hint ? { label: "Setup", value: hint, tone: "muted" } : void 0;
33214
+ if (!path5?.ok) {
33215
+ const saved = savedBinary.trim() !== "";
33216
+ const command = {
33217
+ label: "Command",
33218
+ value: saved ? path5?.detail ?? "not found" : "not configured (not on the PATH)",
33219
+ tone: saved ? "bad" : "muted"
33220
+ };
33221
+ return { command, version: void 0, setup, found: false };
33222
+ }
33223
+ return {
33224
+ command: { label: "Command", value: path5.detail, tone: "ok" },
33225
+ version: {
33226
+ label: "Version",
33227
+ value: version?.ok ? version.detail : "could not be read",
33228
+ tone: version?.ok ? "ok" : "muted"
33229
+ },
33230
+ setup,
33231
+ found: true
33232
+ };
33233
+ }
33234
+ function panelRows(name, checks, settings) {
33235
+ if (!checks) return checking;
33236
+ const { command, version, setup, found } = baseRows(name, checks, settings.binary);
33237
+ const model = { label: "Model", value: modelLine(name, settings.model), tone: "muted" };
33238
+ return [command, ...found ? [...version?.tone === "ok" ? [version] : [], model] : [], ...setup ? [setup] : []];
33239
+ }
33240
+ function statusRows(name, checks, savedBinary) {
33241
+ if (!checks) return checking;
33242
+ const { command, version, setup, found } = baseRows(name, checks, savedBinary);
33243
+ if (!found) return [command];
33244
+ const login = checks.find((check) => check.step === "login");
33245
+ const prompt = checks.find((check) => check.step === "prompt");
33246
+ let loginRow;
33247
+ if (login) {
33248
+ loginRow = { label: "Login", value: login.detail, tone: login.ok ? "ok" : "bad" };
33249
+ } else if (prompt) {
33250
+ loginRow = {
33251
+ label: "Login",
33252
+ value: prompt.ok ? "confirmed by the test" : prompt.timedOut ? "unknown (the test timed out)" : "see the test result",
33253
+ tone: prompt.ok ? "ok" : prompt.timedOut ? "muted" : "bad"
33254
+ };
33255
+ } else {
33256
+ loginRow = { label: "Login", value: "not checked (use Run test)", tone: "muted" };
33257
+ }
33258
+ const testRow = prompt ? [{ label: "Test", value: prompt.detail, tone: prompt.ok ? "ok" : "bad" }] : [];
33259
+ return [command, ...version ? [version] : [], loginRow, ...testRow, ...setup ? [setup] : []];
33260
+ }
33261
+ async function withBinaryEnv(name, binary, run) {
33262
+ const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
33263
+ const previous = process.env[key];
33264
+ process.env[key] = binary;
33265
+ try {
33266
+ return await run();
33267
+ } finally {
33268
+ if (previous === void 0) delete process.env[key];
33269
+ else process.env[key] = previous;
33270
+ }
33271
+ }
33272
+ var VERSION_TIMEOUT_MS, PROMPT_TIMEOUT_MS, TEST_PROMPT, INSTALL_HINTS, LOGIN_HINTS, fail3, pass, LIST_STATUS, checking;
33273
+ var init_agent_status = __esm({
33274
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts"() {
33275
+ "use strict";
33276
+ init_src4();
33277
+ VERSION_TIMEOUT_MS = 5e3;
33278
+ PROMPT_TIMEOUT_MS = 6e4;
33279
+ TEST_PROMPT = "Reply with the single word: ok";
33280
+ INSTALL_HINTS = {
33281
+ claude: "npm install -g @anthropic-ai/claude-code",
33282
+ codex: "npm install -g @openai/codex",
33283
+ opencode: "npm install -g opencode-ai",
33284
+ cursor: "install Cursor\u2019s `cursor-agent` command",
33285
+ copilot: "npm install -g @github/copilot"
33286
+ };
33287
+ LOGIN_HINTS = {
33288
+ claude: "run `claude login`",
33289
+ codex: "set OPENAI_API_KEY, or sign in with a ChatGPT account",
33290
+ opencode: "run `opencode auth`",
33291
+ cursor: "sign in from Cursor",
33292
+ copilot: "run `copilot` and sign in"
33293
+ };
33294
+ fail3 = (step, detail) => ({ step, ok: false, detail });
33295
+ pass = (step, detail) => ({ step, ok: true, detail });
33296
+ LIST_STATUS = {
33297
+ checking: { symbol: "\u2026", text: "checking", tone: "muted" },
33298
+ ready: { symbol: "\u25CF", text: "ready", tone: "ok" },
33299
+ "not-configured": { symbol: "\u25CB", text: "not installed", tone: "muted" },
33300
+ "not-found": { symbol: "\u25CB", text: "not installed", tone: "bad" },
33301
+ "not-logged-in": { symbol: "\u25D0", text: "not logged in", tone: "bad" },
33302
+ "test-failed": { symbol: "\u2717", text: "test failed", tone: "bad" },
33303
+ "timed-out": { symbol: "\u2717", text: "test timed out", tone: "bad" },
33304
+ unknown: { symbol: "\u25D0", text: "installed, login unknown", tone: "muted" }
33305
+ };
33306
+ checking = [{ label: "Command", value: "checking...", tone: "muted" }];
33307
+ }
33308
+ });
33309
+
33310
+ // packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx
33311
+ import { useState as useState29 } from "react";
33312
+ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
33313
+ import TextInput4 from "ink-text-input";
33314
+ import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
33315
+ function FieldForm({
33316
+ title,
33317
+ subtitle,
33318
+ fields: fields2,
33319
+ values,
33320
+ onChange,
33321
+ onSave,
33322
+ onQuit,
33323
+ actions = [],
33324
+ notice,
33325
+ busy = false,
33326
+ children
33327
+ }) {
33328
+ const [active, setActive] = useState29(0);
33329
+ const [editing, setEditing] = useState29(false);
33330
+ const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
33331
+ const rowCount = fields2.length + actions.length;
33332
+ const labelWidth = Math.max(
33333
+ ...fields2.map((field) => field.label.length),
33334
+ ...actions.map((action) => action.label.length)
33335
+ );
33336
+ const currentField = active < fields2.length ? fields2[active] : void 0;
33337
+ const currentAction = currentField ? void 0 : actions[active - fields2.length];
33338
+ useInput11((input, key) => {
33339
+ if (busy) return;
33340
+ if (editing) {
33341
+ if (key.escape && currentField) {
33342
+ onChange(currentField.key, valueBeforeEdit);
33343
+ setEditing(false);
33344
+ }
33345
+ return;
33346
+ }
33347
+ if (key.escape || input === "q") {
33348
+ onQuit();
33349
+ return;
33350
+ }
33351
+ if (input === "s") {
33352
+ onSave();
33353
+ return;
33354
+ }
33355
+ if (input === "c" && currentField) {
33356
+ onChange(currentField.key, "");
33357
+ return;
33358
+ }
33359
+ if (key.tab || key.downArrow) {
33360
+ setActive((i) => (i + 1) % rowCount);
33361
+ return;
33362
+ }
33363
+ if (key.upArrow) {
33364
+ setActive((i) => (i - 1 + rowCount) % rowCount);
33365
+ return;
33366
+ }
33367
+ if (key.return) {
33368
+ if (currentField) {
33369
+ setValueBeforeEdit(values[currentField.key]);
33370
+ setEditing(true);
33371
+ } else {
33372
+ currentAction?.onRun();
33373
+ }
33374
+ }
33375
+ });
33376
+ const pointer = (isActive) => /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " });
33377
+ return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33378
+ /* @__PURE__ */ jsx55(Text46, { bold: true, children: title }),
33379
+ subtitle && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: subtitle }),
33380
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
33381
+ /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", children: [
33382
+ fields2.map((field, index) => {
33383
+ const isActive = index === active;
33384
+ const value = values[field.key];
33385
+ const display = field.masked ? "\u2022".repeat(value.length) : value;
33386
+ return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
33387
+ pointer(isActive),
33388
+ /* @__PURE__ */ jsx55(Box44, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: field.label }) }),
33389
+ isActive && editing ? /* @__PURE__ */ jsx55(
33390
+ TextInput4,
33391
+ {
33392
+ value,
33393
+ onChange: (next) => onChange(field.key, next),
33394
+ onSubmit: () => setEditing(false),
33395
+ mask: field.masked ? "\u2022" : void 0
33396
+ }
33397
+ ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (field.hint ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
33398
+ field.hint && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: field.hint })
33399
+ ] }, field.key);
33400
+ }),
33401
+ actions.map((action, index) => {
33402
+ const isActive = fields2.length + index === active;
33403
+ return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
33404
+ pointer(isActive),
33405
+ /* @__PURE__ */ jsx55(Box44, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: action.label }) }),
33406
+ /* @__PURE__ */ jsx55(Text46, { color: action.running ? PALETTE.accent : PALETTE.muted, children: action.running ? action.runningText ?? "running..." : action.description })
33407
+ ] }, action.label);
33408
+ })
33409
+ ] }),
33410
+ notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
33411
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
33412
+ /* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
33413
+ notice.kind === "success" ? "\u2713" : "\u2717",
33414
+ " ",
33415
+ notice.text
33416
+ ] })
33417
+ ] }),
33418
+ children,
33419
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
33420
+ /* @__PURE__ */ jsx55(
33421
+ ControlHints,
33422
+ {
33423
+ hints: editing ? [
33424
+ { keys: "type", label: "edit" },
33425
+ { keys: "\u2190/\u2192", label: "move cursor" },
33426
+ { keys: "\u23CE", label: "done" },
33427
+ { keys: "Esc", label: "cancel edit" }
33428
+ ] : [
33429
+ { keys: "\u2191/\u2193", label: "move" },
33430
+ { keys: "\u23CE", label: currentAction ? currentAction.hint : "edit" },
33431
+ ...currentField ? [{ keys: "c", label: "clear" }] : [],
33432
+ { keys: "s", label: "save" },
33433
+ { keys: "Esc/q", label: "back without saving" }
33434
+ ]
33435
+ }
33436
+ )
33437
+ ] });
33438
+ }
33439
+ var init_FieldForm = __esm({
33440
+ "packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx"() {
33441
+ "use strict";
33442
+ init_theme();
33443
+ init_control_hints();
33444
+ }
33445
+ });
33446
+
33447
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx
33448
+ import { Text as Text47 } from "ink";
33449
+ import { jsx as jsx56 } from "react/jsx-runtime";
33450
+ function AgentStatusBadge({
33451
+ name,
33452
+ checks,
33453
+ binary
33454
+ }) {
33455
+ const { symbol, text, tone } = LIST_STATUS[checks ? statusFromChecks(name, checks, binary) : "checking"];
33456
+ return /* @__PURE__ */ jsx56(Text47, { color: TONE_COLOR[tone], children: `${symbol} ${text}` });
33457
+ }
33458
+ var TONE_COLOR;
33459
+ var init_AgentStatusBadge = __esm({
33460
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx"() {
33461
+ "use strict";
33462
+ init_theme();
33463
+ init_agent_status();
33464
+ TONE_COLOR = {
33465
+ ok: PALETTE.success,
33466
+ bad: PALETTE.error,
33467
+ muted: PALETTE.muted
33468
+ };
33469
+ }
33470
+ });
33471
+
33472
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
33473
+ import { useEffect as useEffect22, useState as useState30 } from "react";
33474
+ import { Box as Box45, Text as Text48 } from "ink";
33475
+ import { jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
33476
+ function Row2({ label, children }) {
33477
+ return /* @__PURE__ */ jsxs46(Box45, { children: [
33478
+ /* @__PURE__ */ jsx57(Box45, { width: POINTER_WIDTH + LABEL_WIDTH + LABEL_GAP, flexShrink: 0, children: /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: label }) }),
33479
+ children
33480
+ ] });
33481
+ }
33482
+ function StatusHeading() {
33483
+ return /* @__PURE__ */ jsxs46(Box45, { gap: 1, children: [
33484
+ /* @__PURE__ */ jsx57(Text48, { bold: true, color: PALETTE.muted, children: "STATUS" }),
33485
+ /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "\xB7 read only" })
33486
+ ] });
33487
+ }
33488
+ function AgentDetail({
33489
+ name,
33490
+ config,
33491
+ setConfig,
33492
+ onBack
33493
+ }) {
33494
+ const settings = config.agents[name];
33495
+ const [saving, setSaving] = useState30(false);
33496
+ const [testing, setTesting] = useState30(false);
33497
+ const [notice, setNotice] = useState30(null);
33498
+ const [checks, setChecks] = useState30(void 0);
33499
+ useEffect22(() => {
33500
+ let active = true;
33501
+ setChecks(void 0);
33502
+ void inspectAgent(name, settings.binary).then((result) => active && setChecks(result));
33503
+ return () => {
33504
+ active = false;
33505
+ };
33506
+ }, [name, settings.binary]);
33507
+ const save = () => {
33508
+ setSaving(true);
33509
+ setNotice(null);
33510
+ writeAgentConfig(config).then(() => {
33511
+ applyBinaryOverrides(config);
33512
+ setNotice({ kind: "success", text: `Saved: ${AGENT_LABELS[name]} settings are written to config.json` });
33513
+ }).catch(
33514
+ (err) => setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` })
33515
+ ).finally(() => setSaving(false));
33516
+ };
33517
+ const runTest = () => {
33518
+ setTesting(true);
33519
+ setNotice(null);
33520
+ testAgent(name, settings.binary, settings.model).then((result) => {
33521
+ setChecks(result);
33522
+ const outcome = testOutcome(result);
33523
+ setNotice(
33524
+ outcome ? { kind: outcome.ok ? "success" : "error", text: outcome.text } : { kind: "error", text: "Test not run: the agent could not be started (see Status)" }
33525
+ );
33526
+ }).catch(
33527
+ (err) => setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` })
33528
+ ).finally(() => setTesting(false));
33529
+ };
33530
+ const action = {
33531
+ label: "Run test",
33532
+ description: "sends one small prompt (uses a few tokens)",
33533
+ running: testing,
33534
+ hint: "run test",
33535
+ onRun: runTest
33536
+ };
33537
+ return /* @__PURE__ */ jsx57(
33538
+ FieldForm,
33539
+ {
33540
+ title: AGENT_LABELS[name],
33541
+ subtitle: config.defaultAgent === name ? "This is the default agent." : `Runs the \`${AGENT_BINARIES[name]}\` command.`,
33542
+ fields: fields(name),
33543
+ values: { binary: settings.binary, model: settings.model },
33544
+ onChange: (key, value) => {
33545
+ setConfig({ ...config, agents: { ...config.agents, [name]: { ...settings, [key]: value } } });
33546
+ setNotice(null);
33547
+ },
33548
+ onSave: save,
33549
+ onQuit: onBack,
33550
+ actions: [action],
33551
+ notice: testing ? null : notice,
33552
+ busy: saving || testing,
33553
+ children: /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", marginTop: 1, children: [
33554
+ /* @__PURE__ */ jsx57(StatusHeading, {}),
33555
+ statusRows(name, checks, settings.binary).map((row) => /* @__PURE__ */ jsx57(Row2, { label: row.label, children: /* @__PURE__ */ jsx57(Text48, { color: TONE_COLOR[row.tone], children: row.value }) }, row.label))
33556
+ ] })
33557
+ }
33558
+ );
33559
+ }
33560
+ var fields, LABEL_WIDTH, LABEL_GAP, POINTER_WIDTH;
33561
+ var init_AgentDetail = __esm({
33562
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx"() {
33563
+ "use strict";
33564
+ init_src4();
33565
+ init_theme();
33566
+ init_FieldForm();
33567
+ init_agent_store();
33568
+ init_agent_status();
33569
+ init_AgentStatusBadge();
33570
+ init_apply_binary_overrides();
33571
+ fields = (name) => [
33572
+ { key: "binary", label: "Command path", hint: `(empty: \`${AGENT_BINARIES[name]}\` from the PATH)` },
33573
+ { key: "model", label: "Model", hint: `(empty: ${defaultModelLabel(name)})` }
33574
+ ];
33575
+ LABEL_WIDTH = "Command path".length;
33576
+ LABEL_GAP = 2;
33577
+ POINTER_WIDTH = 2;
33578
+ }
33579
+ });
33580
+
33581
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
33582
+ import { useEffect as useEffect23, useState as useState31 } from "react";
33583
+ import { Box as Box46, Text as Text49, useInput as useInput12 } from "ink";
33584
+ import { Fragment as Fragment18, jsx as jsx58, jsxs as jsxs47 } from "react/jsx-runtime";
33585
+ function AgentsScreen({ onDone }) {
33586
+ const [config, setConfig] = useState31(null);
33587
+ const [focus, setFocus] = useState31(0);
33588
+ const [open, setOpen] = useState31(null);
33589
+ const [notice, setNotice] = useState31(null);
33590
+ const [saving, setSaving] = useState31(false);
33591
+ const [checks, setChecks] = useState31({});
33592
+ const inspectAll = (loaded) => {
33593
+ for (const name of AGENT_NAMES) {
33594
+ void inspectAgent(name, loaded.agents[name].binary).then(
33595
+ (result) => setChecks((previous) => ({ ...previous, [name]: result }))
33596
+ );
33597
+ }
33598
+ };
33599
+ useEffect23(() => {
33600
+ void readAgentConfig().then((loaded) => {
33601
+ setConfig(loaded);
33602
+ inspectAll(loaded);
33603
+ startDebugRun({
33604
+ flow: "settings/agents",
33605
+ step: "01-agents",
33606
+ menuOption: "Configuration > Agents",
33607
+ inputs: { default_agent: loaded.defaultAgent }
33608
+ });
33609
+ });
33610
+ }, []);
33611
+ const makeDefault = (name) => {
33612
+ if (!config || saving) return;
33613
+ if (name === config.defaultAgent) {
33614
+ setNotice({ kind: "success", text: `${AGENT_LABELS[name]} is already the default agent` });
33615
+ return;
33616
+ }
33617
+ setSaving(true);
33618
+ setNotice(null);
33619
+ writeAgentConfig({ ...config, defaultAgent: name }).then(() => {
33620
+ setConfig((current) => current ? { ...current, defaultAgent: name } : current);
33621
+ setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[name]}` });
33622
+ }).catch(
33623
+ (err) => setNotice({
33624
+ kind: "error",
33625
+ text: `Default agent not changed: ${err instanceof Error ? err.message : String(err)}`
33626
+ })
33627
+ ).finally(() => setSaving(false));
33628
+ };
33629
+ useInput12((input, key) => {
33630
+ if (!config || open || saving) return;
33631
+ const focused = AGENT_NAMES[focus];
33632
+ if (key.upArrow || key.downArrow || key.tab) setNotice(null);
33633
+ if (key.upArrow) {
33634
+ setFocus((i) => (i - 1 + AGENT_NAMES.length) % AGENT_NAMES.length);
33635
+ return;
33636
+ }
33637
+ if (key.downArrow || key.tab) {
33638
+ setFocus((i) => (i + 1) % AGENT_NAMES.length);
33639
+ return;
33640
+ }
33641
+ if (key.return) {
33642
+ makeDefault(focused);
33643
+ return;
33644
+ }
33645
+ if (key.rightArrow) {
33646
+ setNotice(null);
33647
+ setOpen(focused);
33648
+ return;
33649
+ }
33650
+ if (key.escape || input === "q") {
33651
+ void finishDebugRun({ outputs: { default_agent: config.defaultAgent }, status: "success", exitMethod: "saved" });
33652
+ onDone();
33653
+ }
33654
+ });
33655
+ if (!config) {
33656
+ return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33657
+ /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Agents" }),
33658
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33659
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.accent, children: "Loading..." })
33660
+ ] });
33661
+ }
33662
+ if (open) {
33663
+ return /* @__PURE__ */ jsx58(
33664
+ AgentDetail,
33665
+ {
33666
+ name: open,
33667
+ config,
33668
+ setConfig,
33669
+ onBack: () => {
33670
+ setOpen(null);
33671
+ void readAgentConfig().then((saved) => {
33672
+ setConfig(saved);
33673
+ inspectAll(saved);
33674
+ });
33675
+ }
33676
+ }
33677
+ );
33678
+ }
33679
+ const focusedAgent = AGENT_NAMES[focus];
33680
+ return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33681
+ /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Agents" }),
33682
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "The coding agent the CLI runs, and what was found for each one." }),
33683
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33684
+ /* @__PURE__ */ jsxs47(Box46, { gap: 1, children: [
33685
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "Default agent" }),
33686
+ /* @__PURE__ */ jsx58(Text49, { bold: true, children: AGENT_LABELS[config.defaultAgent] }),
33687
+ saving && /* @__PURE__ */ jsx58(Text49, { color: PALETTE.accent, children: "\u2026 saving" })
33688
+ ] }),
33689
+ /* @__PURE__ */ jsxs47(Box46, { marginTop: 1, gap: 1, children: [
33690
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33691
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33692
+ /* @__PURE__ */ jsx58(Box46, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "AGENT" }) }),
33693
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "STATUS" })
33694
+ ] }),
33695
+ AGENT_NAMES.map((name) => {
33696
+ const isFocused = focusedAgent === name;
33697
+ return /* @__PURE__ */ jsxs47(Box46, { gap: 1, children: [
33698
+ /* @__PURE__ */ jsx58(Text49, { color: isFocused ? PALETTE.accent : void 0, children: isFocused ? "\u276F" : " " }),
33699
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.success, children: name === config.defaultAgent ? "\u2605" : " " }),
33700
+ /* @__PURE__ */ jsx58(Box46, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { bold: isFocused, color: isFocused ? PALETTE.accent : void 0, children: AGENT_LABELS[name] }) }),
33701
+ /* @__PURE__ */ jsx58(AgentStatusBadge, { name, checks: checks[name], binary: config.agents[name].binary })
33702
+ ] }, name);
33703
+ }),
33704
+ /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", marginTop: 1, children: [
33705
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: `\u2500 ${AGENT_LABELS[focusedAgent]} ${"\u2500".repeat(30)}` }),
33706
+ panelRows(focusedAgent, checks[focusedAgent], config.agents[focusedAgent]).map((row) => /* @__PURE__ */ jsxs47(Box46, { gap: 1, paddingLeft: 1, children: [
33707
+ /* @__PURE__ */ jsx58(Box46, { width: PANEL_LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: row.label }) }),
33708
+ /* @__PURE__ */ jsx58(Text49, { color: TONE_COLOR[row.tone], children: row.value })
33709
+ ] }, row.label))
33710
+ ] }),
33711
+ notice && /* @__PURE__ */ jsxs47(Fragment18, { children: [
33712
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33713
+ /* @__PURE__ */ jsxs47(Text49, { bold: true, color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
33714
+ notice.kind === "success" ? "\u2713" : "\u2717",
33715
+ " ",
33716
+ notice.text
33717
+ ] })
33718
+ ] }),
33719
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33720
+ /* @__PURE__ */ jsx58(
33721
+ ControlHints,
33722
+ {
33723
+ hints: [
33724
+ { keys: "\u2191/\u2193", label: "move" },
33725
+ { keys: "\u23CE", label: "make default" },
33726
+ { keys: "\u2192", label: "settings and test" },
33727
+ { keys: "Esc/q", label: "back" }
33728
+ ]
33729
+ }
33730
+ )
33731
+ ] });
33732
+ }
33733
+ var NAME_WIDTH, PANEL_LABEL_WIDTH;
33734
+ var init_AgentsScreen = __esm({
33735
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx"() {
33736
+ "use strict";
33737
+ init_src4();
33738
+ init_theme();
33739
+ init_control_hints();
33740
+ init_debug_store();
33741
+ init_agent_store();
33742
+ init_agent_status();
33743
+ init_AgentDetail();
33744
+ init_AgentStatusBadge();
33745
+ NAME_WIDTH = 16;
33746
+ PANEL_LABEL_WIDTH = "Command".length;
33747
+ }
33748
+ });
33749
+
33750
+ // packages/experience-design-system-cli/src/tui/settings/configuration/project/project-store.ts
32966
33751
  async function readCredentials() {
32967
33752
  const store = await readV1Store();
32968
33753
  return {
@@ -32986,18 +33771,17 @@ async function writeCredentials(config) {
32986
33771
  });
32987
33772
  await writeV1Store(merged);
32988
33773
  }
32989
- var init_config_store = __esm({
32990
- "packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts"() {
33774
+ var init_project_store = __esm({
33775
+ "packages/experience-design-system-cli/src/tui/settings/configuration/project/project-store.ts"() {
32991
33776
  "use strict";
32992
33777
  init_v1_store();
32993
33778
  }
32994
33779
  });
32995
33780
 
32996
- // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
32997
- import { useEffect as useEffect22, useState as useState29 } from "react";
32998
- import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
32999
- import TextInput4 from "ink-text-input";
33000
- import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
33781
+ // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
33782
+ import { useEffect as useEffect24, useState as useState32 } from "react";
33783
+ import { Box as Box47, Text as Text50 } from "ink";
33784
+ import { jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
33001
33785
  function debugFields(config) {
33002
33786
  return {
33003
33787
  space_id: config?.spaceId ?? "",
@@ -33009,189 +33793,159 @@ function debugFields(config) {
33009
33793
  contentful_base_dir: config?.contentfulBaseDir ?? ""
33010
33794
  };
33011
33795
  }
33012
- function ConfigurationScreen({ onDone }) {
33013
- const [stage, setStage] = useState29("loading");
33014
- const [config, setConfig] = useState29(null);
33015
- const [activeField, setActiveField] = useState29("spaceId");
33016
- const [notice, setNotice] = useState29(null);
33017
- const [lastSaved, setLastSaved] = useState29(null);
33018
- const [editing, setEditing] = useState29(false);
33019
- const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
33020
- useEffect22(() => {
33021
- readCredentials().then((cfg) => {
33796
+ function ProjectScreen({ onDone }) {
33797
+ const [config, setConfig] = useState32(null);
33798
+ const [saving, setSaving] = useState32(false);
33799
+ const [notice, setNotice] = useState32(null);
33800
+ const [lastSaved, setLastSaved] = useState32(null);
33801
+ useEffect24(() => {
33802
+ void readCredentials().then((cfg) => {
33022
33803
  setConfig(cfg);
33023
- setStage("form");
33024
33804
  startDebugRun({
33025
33805
  flow: "settings/contentful-configuration",
33026
33806
  step: "01-configuration",
33027
- menuOption: "Configuration",
33807
+ menuOption: "Configuration > Project",
33028
33808
  inputs: debugFields(cfg)
33029
33809
  });
33030
33810
  });
33031
33811
  }, []);
33032
- function fieldValue(field) {
33033
- if (!config) return "";
33034
- return config[field] || "";
33035
- }
33036
- function setFieldValue(field, value) {
33037
- if (!config) return;
33038
- setConfig({ ...config, [field]: value });
33039
- setNotice(null);
33812
+ if (!config) {
33813
+ return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33814
+ /* @__PURE__ */ jsx59(Text50, { bold: true, children: "Project" }),
33815
+ /* @__PURE__ */ jsx59(Text50, { children: " " }),
33816
+ /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
33817
+ ] });
33040
33818
  }
33041
- function handleSave() {
33042
- if (!config) return;
33043
- setStage("saving");
33819
+ const save = () => {
33820
+ setSaving(true);
33044
33821
  setNotice(null);
33045
33822
  writeCredentials(config).then(() => {
33046
33823
  setLastSaved(config);
33047
33824
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
33048
- setNotice({ kind: "success", text: "Configuration saved" });
33049
- setStage("form");
33825
+ setNotice({ kind: "success", text: "Project settings saved" });
33050
33826
  }).catch((err) => {
33051
33827
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
33052
- setStage("form");
33053
- });
33054
- }
33055
- function quit() {
33828
+ }).finally(() => setSaving(false));
33829
+ };
33830
+ const quit = () => {
33056
33831
  void finishDebugRun(
33057
33832
  lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
33058
33833
  );
33059
33834
  onDone();
33060
- }
33061
- useInput11((input, key) => {
33062
- if (stage === "loading" || stage === "saving") return;
33063
- if (editing) {
33064
- if (key.escape) {
33065
- setFieldValue(activeField, valueBeforeEdit);
33066
- setEditing(false);
33067
- }
33068
- return;
33069
- }
33070
- if (key.escape || input === "q") {
33071
- quit();
33072
- return;
33073
- }
33074
- if (input === "s") {
33075
- handleSave();
33076
- return;
33077
- }
33078
- if (input === "c") {
33079
- setFieldValue(activeField, "");
33080
- return;
33835
+ };
33836
+ return /* @__PURE__ */ jsx59(
33837
+ FieldForm,
33838
+ {
33839
+ title: "Project",
33840
+ subtitle: "The Contentful space and where the CLI keeps its files.",
33841
+ fields: FIELDS2,
33842
+ values: valuesOf(config),
33843
+ onChange: (key, value) => {
33844
+ setConfig({ ...config, [key]: value });
33845
+ setNotice(null);
33846
+ },
33847
+ onSave: save,
33848
+ onQuit: quit,
33849
+ notice,
33850
+ busy: saving
33081
33851
  }
33082
- if (key.tab || key.downArrow) {
33083
- const idx = FIELD_ORDER.indexOf(activeField);
33084
- setActiveField(FIELD_ORDER[(idx + 1) % FIELD_ORDER.length]);
33852
+ );
33853
+ }
33854
+ var FIELDS2, valuesOf;
33855
+ var init_ProjectScreen = __esm({
33856
+ "packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx"() {
33857
+ "use strict";
33858
+ init_theme();
33859
+ init_debug_store();
33860
+ init_FieldForm();
33861
+ init_project_store();
33862
+ FIELDS2 = [
33863
+ { key: "spaceId", label: "Space ID" },
33864
+ { key: "environmentId", label: "Environment ID" },
33865
+ { key: "cmaToken", label: "CMA Token", masked: true },
33866
+ { key: "host", label: "API Host" },
33867
+ { key: "defaultComponentDir", label: "Default component directory" },
33868
+ { key: "defaultTokenFile", label: "Default token file" },
33869
+ { key: "contentfulBaseDir", label: "Root Project Directory", hint: "(where .contentful goes)" }
33870
+ ];
33871
+ valuesOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
33872
+ }
33873
+ });
33874
+
33875
+ // packages/experience-design-system-cli/src/tui/settings/configuration/ConfigurationScreen.tsx
33876
+ import { useState as useState33 } from "react";
33877
+ import { Box as Box48, Text as Text51, useInput as useInput13 } from "ink";
33878
+ import { jsx as jsx60, jsxs as jsxs49 } from "react/jsx-runtime";
33879
+ function ConfigurationScreen({ onDone }) {
33880
+ const [focus, setFocus] = useState33(0);
33881
+ const [open, setOpen] = useState33(null);
33882
+ const close = () => setOpen(null);
33883
+ useInput13((input, key) => {
33884
+ if (open) return;
33885
+ if (key.upArrow) {
33886
+ setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
33085
33887
  return;
33086
33888
  }
33087
- if (key.upArrow) {
33088
- const idx = FIELD_ORDER.indexOf(activeField);
33089
- setActiveField(FIELD_ORDER[(idx - 1 + FIELD_ORDER.length) % FIELD_ORDER.length]);
33889
+ if (key.downArrow || key.tab) {
33890
+ setFocus((i) => (i + 1) % SECTIONS.length);
33090
33891
  return;
33091
33892
  }
33092
33893
  if (key.return) {
33093
- setValueBeforeEdit(fieldValue(activeField));
33094
- setEditing(true);
33894
+ setOpen(SECTIONS[focus].id);
33895
+ return;
33095
33896
  }
33897
+ if (key.escape || input === "q") onDone();
33096
33898
  });
33097
- if (stage === "loading") {
33098
- return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33099
- /* @__PURE__ */ jsx55(Text46, { bold: true, children: "Configuration" }),
33100
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
33101
- /* @__PURE__ */ jsx55(Text46, { color: PALETTE.accent, children: "Loading..." })
33102
- ] });
33103
- }
33104
- return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33105
- /* @__PURE__ */ jsx55(Text46, { bold: true, children: "Configuration" }),
33106
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
33107
- /* @__PURE__ */ jsx55(Box44, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
33108
- const isActive = activeField === field;
33109
- const value = fieldValue(field);
33110
- const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
33111
- return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
33112
- /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
33113
- /* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
33114
- isActive && editing ? /* @__PURE__ */ jsx55(
33115
- TextInput4,
33116
- {
33117
- value,
33118
- onChange: (next) => setFieldValue(field, next),
33119
- onSubmit: () => setEditing(false),
33120
- mask: field === "cmaToken" ? "\u2022" : void 0
33121
- }
33122
- ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
33123
- FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
33124
- ] }, field);
33125
- }) }),
33126
- notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
33127
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
33128
- /* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
33129
- notice.kind === "success" ? "\u2713" : "\u2717",
33130
- " ",
33131
- notice.text
33132
- ] })
33133
- ] }),
33134
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
33135
- /* @__PURE__ */ jsx55(
33899
+ if (open === "project") return /* @__PURE__ */ jsx60(ProjectScreen, { onDone: close });
33900
+ if (open === "agents") return /* @__PURE__ */ jsx60(AgentsScreen, { onDone: close });
33901
+ return /* @__PURE__ */ jsxs49(Box48, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33902
+ /* @__PURE__ */ jsx60(Text51, { bold: true, children: "Configuration" }),
33903
+ /* @__PURE__ */ jsx60(Text51, { children: " " }),
33904
+ SECTIONS.map((section, index) => /* @__PURE__ */ jsxs49(Box48, { gap: 1, children: [
33905
+ /* @__PURE__ */ jsx60(Text51, { color: index === focus ? PALETTE.accent : void 0, children: index === focus ? "\u276F" : " " }),
33906
+ /* @__PURE__ */ jsx60(Box48, { width: 9, flexShrink: 0, children: /* @__PURE__ */ jsx60(Text51, { bold: index === focus, color: index === focus ? PALETTE.accent : void 0, children: section.label }) }),
33907
+ /* @__PURE__ */ jsx60(Text51, { color: PALETTE.muted, children: section.description })
33908
+ ] }, section.id)),
33909
+ /* @__PURE__ */ jsx60(Text51, { children: " " }),
33910
+ /* @__PURE__ */ jsx60(
33136
33911
  ControlHints,
33137
33912
  {
33138
- hints: editing ? [
33139
- { keys: "type", label: "edit" },
33140
- { keys: "\u2190/\u2192", label: "move cursor" },
33141
- { keys: "\u23CE", label: "done" },
33142
- { keys: "Esc", label: "cancel edit" }
33143
- ] : [
33913
+ hints: [
33144
33914
  { keys: "\u2191/\u2193", label: "move" },
33145
- { keys: "\u23CE", label: "edit" },
33146
- { keys: "c", label: "clear" },
33147
- { keys: "s", label: "save" },
33148
- { keys: "Esc/q", label: "quit without saving" }
33915
+ { keys: "\u23CE", label: "open" },
33916
+ { keys: "Esc/q", label: "back" }
33149
33917
  ]
33150
33918
  }
33151
33919
  )
33152
33920
  ] });
33153
33921
  }
33154
- var FIELD_ORDER, FIELD_LABELS, FIELD_HINTS, LABEL_WIDTH;
33155
- var init_ContentfulConfigScreen = __esm({
33156
- "packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx"() {
33922
+ var SECTIONS;
33923
+ var init_ConfigurationScreen = __esm({
33924
+ "packages/experience-design-system-cli/src/tui/settings/configuration/ConfigurationScreen.tsx"() {
33157
33925
  "use strict";
33158
33926
  init_theme();
33159
- init_config_store();
33160
- init_debug_store();
33161
33927
  init_control_hints();
33162
- FIELD_ORDER = [
33163
- "spaceId",
33164
- "environmentId",
33165
- "cmaToken",
33166
- "host",
33167
- "defaultComponentDir",
33168
- "defaultTokenFile",
33169
- "contentfulBaseDir"
33928
+ init_AgentsScreen();
33929
+ init_ProjectScreen();
33930
+ SECTIONS = [
33931
+ {
33932
+ id: "project",
33933
+ label: "Project",
33934
+ description: "Contentful space, credentials, defaults and where .contentful goes"
33935
+ },
33936
+ { id: "agents", label: "Agents", description: "Which coding agent the CLI uses, and each agent\u2019s settings" }
33170
33937
  ];
33171
- FIELD_LABELS = {
33172
- spaceId: "Space ID",
33173
- environmentId: "Environment ID",
33174
- cmaToken: "CMA Token",
33175
- host: "API Host",
33176
- defaultComponentDir: "Default component directory",
33177
- defaultTokenFile: "Default token file",
33178
- contentfulBaseDir: "Root Project Directory"
33179
- };
33180
- FIELD_HINTS = {
33181
- contentfulBaseDir: "(where .contentful goes)"
33182
- };
33183
- LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
33184
33938
  }
33185
33939
  });
33186
33940
 
33187
33941
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
33188
- import { useEffect as useEffect23, useState as useState30 } from "react";
33189
- import { Box as Box45, Text as Text47, useInput as useInput12 } from "ink";
33190
- import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
33942
+ import { useEffect as useEffect25, useState as useState34 } from "react";
33943
+ import { Box as Box49, Text as Text52, useInput as useInput14 } from "ink";
33944
+ import { Fragment as Fragment19, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
33191
33945
  function OptInAnalyticsScreen({ onDone }) {
33192
- const [loading, setLoading] = useState30(true);
33193
- const [enabled, setEnabled] = useState30(true);
33194
- useEffect23(() => {
33946
+ const [loading, setLoading] = useState34(true);
33947
+ const [enabled, setEnabled] = useState34(true);
33948
+ useEffect25(() => {
33195
33949
  readAnalyticsSetting().then((setting) => {
33196
33950
  setEnabled(setting.enabled);
33197
33951
  setLoading(false);
@@ -33203,7 +33957,7 @@ function OptInAnalyticsScreen({ onDone }) {
33203
33957
  });
33204
33958
  });
33205
33959
  }, []);
33206
- useInput12((input, key) => {
33960
+ useInput14((input, key) => {
33207
33961
  if (loading) return;
33208
33962
  if (key.return || input === " ") {
33209
33963
  setEnabled((current) => {
@@ -33218,21 +33972,21 @@ function OptInAnalyticsScreen({ onDone }) {
33218
33972
  onDone();
33219
33973
  }
33220
33974
  });
33221
- return /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33222
- /* @__PURE__ */ jsx56(Text47, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
33223
- /* @__PURE__ */ jsx56(Text47, { children: " " }),
33224
- loading ? /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs46(Fragment18, { children: [
33225
- /* @__PURE__ */ jsxs46(Text47, { children: [
33975
+ return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33976
+ /* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
33977
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
33978
+ loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment19, { children: [
33979
+ /* @__PURE__ */ jsxs50(Text52, { children: [
33226
33980
  "Share anonymous usage data:",
33227
33981
  " ",
33228
- /* @__PURE__ */ jsx56(Text47, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
33982
+ /* @__PURE__ */ jsx61(Text52, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
33229
33983
  ] }),
33230
- /* @__PURE__ */ jsx56(Text47, { children: " " }),
33231
- /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
33232
- /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
33984
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
33985
+ /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
33986
+ /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
33233
33987
  ] }),
33234
- /* @__PURE__ */ jsx56(Text47, { children: " " }),
33235
- /* @__PURE__ */ jsx56(
33988
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
33989
+ /* @__PURE__ */ jsx61(
33236
33990
  ControlHints,
33237
33991
  {
33238
33992
  hints: [
@@ -33253,14 +34007,95 @@ var init_screen11 = __esm({
33253
34007
  }
33254
34008
  });
33255
34009
 
34010
+ // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
34011
+ import { useEffect as useEffect26, useState as useState35 } from "react";
34012
+ import { Box as Box50, Text as Text53, useInput as useInput15 } from "ink";
34013
+ import { jsx as jsx62, jsxs as jsxs51 } from "react/jsx-runtime";
34014
+ function UpgradeScreen({ onDone }) {
34015
+ const [upgradeCheck, setUpgradeCheck] = useState35();
34016
+ useEffect26(() => {
34017
+ startDebugRun({
34018
+ flow: "upgrade",
34019
+ step: "01-upgrade",
34020
+ menuOption: "Upgrade",
34021
+ inputs: { currentVersion: readPackageVersion() }
34022
+ });
34023
+ checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
34024
+ }, []);
34025
+ useInput15((_input, key) => {
34026
+ if (key.return) {
34027
+ void finishDebugRun({
34028
+ outputs: upgradeCheck ?? {},
34029
+ status: upgradeCheck?.status === "error" ? "error" : "success",
34030
+ exitMethod: "saved"
34031
+ });
34032
+ onDone();
34033
+ return;
34034
+ }
34035
+ });
34036
+ return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
34037
+ /* @__PURE__ */ jsx62(Text53, { bold: true, children: "Upgrade" }),
34038
+ /* @__PURE__ */ jsx62(Text53, { children: " " }),
34039
+ renderBody(upgradeCheck),
34040
+ /* @__PURE__ */ jsx62(Text53, { children: " " }),
34041
+ /* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.accent, children: [
34042
+ FOCUS_MARKER,
34043
+ " Go Back"
34044
+ ] })
34045
+ ] });
34046
+ }
34047
+ function renderBody(upgradeCheck) {
34048
+ if (!upgradeCheck) {
34049
+ return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.muted, children: "Checking for updates\u2026" });
34050
+ }
34051
+ if (upgradeCheck.status === "error") {
34052
+ return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
34053
+ }
34054
+ if (upgradeCheck.status === "up-to-date") {
34055
+ return /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.success, children: [
34056
+ "You're already on the latest version (v",
34057
+ upgradeCheck.current,
34058
+ ")."
34059
+ ] });
34060
+ }
34061
+ return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", children: [
34062
+ /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.muted, children: [
34063
+ /* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.success, children: [
34064
+ "v",
34065
+ upgradeCheck.latest
34066
+ ] }),
34067
+ " ",
34068
+ "is available (you're on ",
34069
+ /* @__PURE__ */ jsxs51(Text53, { bold: true, children: [
34070
+ "v",
34071
+ upgradeCheck.current
34072
+ ] }),
34073
+ "). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
34074
+ ] }),
34075
+ /* @__PURE__ */ jsx62(Text53, { children: " " }),
34076
+ /* @__PURE__ */ jsx62(Box50, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx62(Text53, { bold: true, children: cmd }, cmd)) })
34077
+ ] });
34078
+ }
34079
+ var UPGRADE_COMMANDS;
34080
+ var init_PageContainer4 = __esm({
34081
+ "packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx"() {
34082
+ "use strict";
34083
+ init_theme();
34084
+ init_home_theme();
34085
+ init_version();
34086
+ init_debug_store();
34087
+ UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
34088
+ }
34089
+ });
34090
+
33256
34091
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
33257
- import { useEffect as useEffect24, useState as useState31 } from "react";
33258
- import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
33259
- import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
34092
+ import { useEffect as useEffect27, useState as useState36 } from "react";
34093
+ import { Box as Box51, Text as Text54, useInput as useInput16 } from "ink";
34094
+ import { jsx as jsx63, jsxs as jsxs52 } from "react/jsx-runtime";
33260
34095
  function DebugModeScreen({ onDone }) {
33261
- const [loading, setLoading] = useState31(true);
33262
- const [enabled, setEnabled] = useState31(true);
33263
- useEffect24(() => {
34096
+ const [loading, setLoading] = useState36(true);
34097
+ const [enabled, setEnabled] = useState36(true);
34098
+ useEffect27(() => {
33264
34099
  readDebugModeSetting().then((setting) => {
33265
34100
  setEnabled(setting.enabled);
33266
34101
  setLoading(false);
@@ -33272,7 +34107,7 @@ function DebugModeScreen({ onDone }) {
33272
34107
  });
33273
34108
  });
33274
34109
  }, []);
33275
- useInput13((input, key) => {
34110
+ useInput16((input, key) => {
33276
34111
  if (loading) return;
33277
34112
  if (key.return || input === " ") {
33278
34113
  setEnabled((current) => {
@@ -33287,16 +34122,16 @@ function DebugModeScreen({ onDone }) {
33287
34122
  onDone();
33288
34123
  }
33289
34124
  });
33290
- return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33291
- /* @__PURE__ */ jsx57(Text48, { bold: true, children: "Settings \u203A Debug Mode" }),
33292
- /* @__PURE__ */ jsx57(Text48, { children: " " }),
33293
- loading ? /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs47(Text48, { children: [
34125
+ return /* @__PURE__ */ jsxs52(Box51, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
34126
+ /* @__PURE__ */ jsx63(Text54, { bold: true, children: "Settings \u203A Debug Mode" }),
34127
+ /* @__PURE__ */ jsx63(Text54, { children: " " }),
34128
+ loading ? /* @__PURE__ */ jsx63(Text54, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs52(Text54, { children: [
33294
34129
  "Debug logging:",
33295
34130
  " ",
33296
- /* @__PURE__ */ jsx57(Text48, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
34131
+ /* @__PURE__ */ jsx63(Text54, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
33297
34132
  ] }),
33298
- /* @__PURE__ */ jsx57(Text48, { children: " " }),
33299
- /* @__PURE__ */ jsx57(
34133
+ /* @__PURE__ */ jsx63(Text54, { children: " " }),
34134
+ /* @__PURE__ */ jsx63(
33300
34135
  ControlHints,
33301
34136
  {
33302
34137
  hints: [
@@ -33322,20 +34157,20 @@ var app_exports = {};
33322
34157
  __export(app_exports, {
33323
34158
  runApp: () => runApp
33324
34159
  });
33325
- import { join as join26 } from "node:path";
33326
- import { useEffect as useEffect25, useState as useState32 } from "react";
33327
- import { Fragment as Fragment19, jsx as jsx58 } from "react/jsx-runtime";
34160
+ import { join as join27 } from "node:path";
34161
+ import { useEffect as useEffect28, useState as useState37 } from "react";
34162
+ import { Fragment as Fragment20, jsx as jsx64 } from "react/jsx-runtime";
33328
34163
  function App({ importOptions, inkClear }) {
33329
- const [screen, setScreen] = useState32("start");
33330
- const [importExitCode, setImportExitCode] = useState32();
34164
+ const [screen, setScreen] = useState37("start");
34165
+ const [importExitCode, setImportExitCode] = useState37();
33331
34166
  const showImportResult = importExitCode !== void 0;
33332
- const [projectPath, setProjectPath] = useState32();
33333
- const [tokensPath, setTokensPath] = useState32();
33334
- const [scannedFiles, setScannedFiles] = useState32();
33335
- const [pendingLaunch, setPendingLaunch] = useState32();
33336
- const [extractionRun, setExtractionRun] = useState32();
34167
+ const [projectPath, setProjectPath] = useState37();
34168
+ const [tokensPath, setTokensPath] = useState37();
34169
+ const [scannedFiles, setScannedFiles] = useState37();
34170
+ const [pendingLaunch, setPendingLaunch] = useState37();
34171
+ const [extractionRun, setExtractionRun] = useState37();
33337
34172
  const extraction = useExtraction(extractionRun?.input);
33338
- const [scopeRun, setScopeRun] = useState32();
34173
+ const [scopeRun, setScopeRun] = useState37();
33339
34174
  const scopeFlow = useScopeGateFlow(
33340
34175
  scopeRun && {
33341
34176
  sessionId: scopeRun.extraction.sessionId,
@@ -33350,12 +34185,12 @@ function App({ importOptions, inkClear }) {
33350
34185
  }
33351
34186
  }
33352
34187
  );
33353
- const [generationInput, setGenerationInput] = useState32();
34188
+ const [generationInput, setGenerationInput] = useState37();
33354
34189
  const generation = useGeneration(generationInput);
33355
- const [flowStart, setFlowStart] = useState32();
34190
+ const [flowStart, setFlowStart] = useState37();
33356
34191
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
33357
- const [importDefaults, setImportDefaults] = useState32();
33358
- useEffect25(() => {
34192
+ const [importDefaults, setImportDefaults] = useState37();
34193
+ useEffect28(() => {
33359
34194
  if (screen !== "import") {
33360
34195
  setImportDefaults(void 0);
33361
34196
  return;
@@ -33373,7 +34208,7 @@ function App({ importOptions, inkClear }) {
33373
34208
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
33374
34209
  const state2 = await inspectTokens({
33375
34210
  rawTokensPath: tokens,
33376
- contentfulDir: join26(resolveUserPath(projectPath2), ".contentful"),
34211
+ contentfulDir: join27(resolveUserPath(projectPath2), ".contentful"),
33377
34212
  cache: importOptions.cache
33378
34213
  });
33379
34214
  if (state2.kind === "cached") {
@@ -33415,12 +34250,12 @@ function App({ importOptions, inkClear }) {
33415
34250
  }
33416
34251
  });
33417
34252
  };
33418
- useEffect25(() => {
34253
+ useEffect28(() => {
33419
34254
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
33420
34255
  setExtractionRun(void 0);
33421
34256
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
33422
34257
  }, [extraction, extractionRun]);
33423
- useEffect25(() => {
34258
+ useEffect28(() => {
33424
34259
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
33425
34260
  const { extraction: produced, input, generatePromptPath } = scopeRun;
33426
34261
  setGenerationInput({
@@ -33438,7 +34273,7 @@ function App({ importOptions, inkClear }) {
33438
34273
  ...generatePromptPath ? { generatePromptPath } : {}
33439
34274
  });
33440
34275
  }, [scopeFlow, scopeRun, generationInput]);
33441
- useEffect25(() => {
34276
+ useEffect28(() => {
33442
34277
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
33443
34278
  const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
33444
34279
  inkClear();
@@ -33481,9 +34316,9 @@ function App({ importOptions, inkClear }) {
33481
34316
  };
33482
34317
  switch (screen) {
33483
34318
  case "import":
33484
- if (showImportResult) return /* @__PURE__ */ jsx58(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
34319
+ if (showImportResult) return /* @__PURE__ */ jsx64(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
33485
34320
  if (flow && flowStart) {
33486
- return /* @__PURE__ */ jsx58(
34321
+ return /* @__PURE__ */ jsx64(
33487
34322
  FlowScreen,
33488
34323
  {
33489
34324
  state: flow.state,
@@ -33493,12 +34328,12 @@ function App({ importOptions, inkClear }) {
33493
34328
  }
33494
34329
  );
33495
34330
  }
33496
- if (importDefaults === void 0) return /* @__PURE__ */ jsx58(Fragment19, {});
34331
+ if (importDefaults === void 0) return /* @__PURE__ */ jsx64(Fragment20, {});
33497
34332
  if (projectPath === void 0) {
33498
- return /* @__PURE__ */ jsx58(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
34333
+ return /* @__PURE__ */ jsx64(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
33499
34334
  }
33500
34335
  if (tokensPath === void 0) {
33501
- return /* @__PURE__ */ jsx58(
34336
+ return /* @__PURE__ */ jsx64(
33502
34337
  TokenInputScreen,
33503
34338
  {
33504
34339
  initialPath: importDefaults.tokenFile,
@@ -33508,7 +34343,7 @@ function App({ importOptions, inkClear }) {
33508
34343
  );
33509
34344
  }
33510
34345
  if (scannedFiles === void 0) {
33511
- return /* @__PURE__ */ jsx58(
34346
+ return /* @__PURE__ */ jsx64(
33512
34347
  PathValidationScreen,
33513
34348
  {
33514
34349
  projectPath,
@@ -33520,10 +34355,10 @@ function App({ importOptions, inkClear }) {
33520
34355
  }
33521
34356
  if (extractionRun) {
33522
34357
  if (extraction?.status === "done" && !extraction.result.ok) {
33523
- return /* @__PURE__ */ jsx58(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
34358
+ return /* @__PURE__ */ jsx64(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
33524
34359
  }
33525
34360
  if (extraction?.status === "running") {
33526
- return /* @__PURE__ */ jsx58(
34361
+ return /* @__PURE__ */ jsx64(
33527
34362
  ExtractionScreen,
33528
34363
  {
33529
34364
  progress: extraction.progress,
@@ -33532,14 +34367,14 @@ function App({ importOptions, inkClear }) {
33532
34367
  }
33533
34368
  );
33534
34369
  }
33535
- return /* @__PURE__ */ jsx58(Fragment19, {});
34370
+ return /* @__PURE__ */ jsx64(Fragment20, {});
33536
34371
  }
33537
34372
  if (scopeRun && scopeFlow) {
33538
34373
  if (scopeFlow.status === "failed") {
33539
- return /* @__PURE__ */ jsx58(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
34374
+ return /* @__PURE__ */ jsx64(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
33540
34375
  }
33541
34376
  if (scopeFlow.status === "deciding") {
33542
- return /* @__PURE__ */ jsx58(
34377
+ return /* @__PURE__ */ jsx64(
33543
34378
  ScopeGateScreen,
33544
34379
  {
33545
34380
  components: scopeFlow.load.components,
@@ -33549,7 +34384,7 @@ function App({ importOptions, inkClear }) {
33549
34384
  );
33550
34385
  }
33551
34386
  if (generation?.status === "done" && !generation.result.ok) {
33552
- return /* @__PURE__ */ jsx58(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
34387
+ return /* @__PURE__ */ jsx64(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
33553
34388
  }
33554
34389
  if (generation?.status === "running") {
33555
34390
  const hasRawTokens = scopeRun.input.rawTokensPath !== "";
@@ -33557,7 +34392,7 @@ function App({ importOptions, inkClear }) {
33557
34392
  hasRawTokens,
33558
34393
  mapTokensEligible: generation.progress.mapTokensEligible
33559
34394
  });
33560
- return /* @__PURE__ */ jsx58(
34395
+ return /* @__PURE__ */ jsx64(
33561
34396
  GenerationScreen,
33562
34397
  {
33563
34398
  progress: generation.progress,
@@ -33569,10 +34404,10 @@ function App({ importOptions, inkClear }) {
33569
34404
  }
33570
34405
  );
33571
34406
  }
33572
- return /* @__PURE__ */ jsx58(Fragment19, {});
34407
+ return /* @__PURE__ */ jsx64(Fragment20, {});
33573
34408
  }
33574
34409
  if (pendingLaunch?.cached) {
33575
- return /* @__PURE__ */ jsx58(
34410
+ return /* @__PURE__ */ jsx64(
33576
34411
  TokenReuseScreen,
33577
34412
  {
33578
34413
  tokensPath: pendingLaunch.cached.tokensPath,
@@ -33583,7 +34418,7 @@ function App({ importOptions, inkClear }) {
33583
34418
  }
33584
34419
  );
33585
34420
  }
33586
- return /* @__PURE__ */ jsx58(
34421
+ return /* @__PURE__ */ jsx64(
33587
34422
  CredentialsScreen,
33588
34423
  {
33589
34424
  initial: importDefaults.credentials,
@@ -33592,17 +34427,19 @@ function App({ importOptions, inkClear }) {
33592
34427
  }
33593
34428
  );
33594
34429
  case "help":
33595
- return /* @__PURE__ */ jsx58(HelpScreen, { onDone: goToStart });
34430
+ return /* @__PURE__ */ jsx64(HelpScreen, { onDone: goToStart });
34431
+ case "upgrade":
34432
+ return /* @__PURE__ */ jsx64(UpgradeScreen, { onDone: goToStart });
33596
34433
  case "settings":
33597
- return /* @__PURE__ */ jsx58(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
34434
+ return /* @__PURE__ */ jsx64(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
33598
34435
  case "settings-configuration":
33599
- return /* @__PURE__ */ jsx58(ConfigurationScreen, { onDone: goToSettings });
34436
+ return /* @__PURE__ */ jsx64(ConfigurationScreen, { onDone: goToSettings });
33600
34437
  case "settings-opt-in-analytics":
33601
- return /* @__PURE__ */ jsx58(OptInAnalyticsScreen, { onDone: goToSettings });
34438
+ return /* @__PURE__ */ jsx64(OptInAnalyticsScreen, { onDone: goToSettings });
33602
34439
  case "settings-debug-mode":
33603
- return /* @__PURE__ */ jsx58(DebugModeScreen, { onDone: goToSettings });
34440
+ return /* @__PURE__ */ jsx64(DebugModeScreen, { onDone: goToSettings });
33604
34441
  case "start":
33605
- return /* @__PURE__ */ jsx58(HomeScreen, { onNavigate: setScreen });
34442
+ return /* @__PURE__ */ jsx64(HomeScreen, { onNavigate: setScreen });
33606
34443
  }
33607
34444
  }
33608
34445
  async function runApp(renderApp, importOptions) {
@@ -33610,7 +34447,7 @@ async function runApp(renderApp, importOptions) {
33610
34447
  instance.clear?.();
33611
34448
  process.stdout.write("\x1B[H\x1B[0J");
33612
34449
  };
33613
- const instance = renderApp(/* @__PURE__ */ jsx58(App, { importOptions, inkClear }));
34450
+ const instance = renderApp(/* @__PURE__ */ jsx64(App, { importOptions, inkClear }));
33614
34451
  await instance.waitUntilExit();
33615
34452
  }
33616
34453
  var init_app = __esm({
@@ -33634,17 +34471,18 @@ var init_app = __esm({
33634
34471
  init_use_flow();
33635
34472
  init_PageContainer2();
33636
34473
  init_PageContainer3();
33637
- init_ContentfulConfigScreen();
34474
+ init_ConfigurationScreen();
33638
34475
  init_screen11();
34476
+ init_PageContainer4();
33639
34477
  init_screen12();
33640
- init_config_store();
34478
+ init_project_store();
33641
34479
  }
33642
34480
  });
33643
34481
 
33644
34482
  // packages/experience-design-system-cli/program.ts
33645
34483
  init_src4();
33646
34484
  import { readFileSync as readFileSync9 } from "node:fs";
33647
- import { join as join27 } from "node:path";
34485
+ import { join as join28 } from "node:path";
33648
34486
  import { Command } from "commander";
33649
34487
 
33650
34488
  // packages/experience-design-system-cli/src/commands/import-options.ts
@@ -33672,14 +34510,14 @@ function runDevWatch(args) {
33672
34510
  process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
33673
34511
  return Promise.resolve(1);
33674
34512
  }
33675
- return new Promise((resolve27) => {
34513
+ return new Promise((resolve28) => {
33676
34514
  const child = spawn3(process.execPath, [script, ...args], { stdio: "inherit" });
33677
34515
  process.on("SIGINT", () => void 0);
33678
- child.on("exit", (code) => resolve27(code ?? 0));
34516
+ child.on("exit", (code) => resolve28(code ?? 0));
33679
34517
  child.on("error", (err) => {
33680
34518
  process.stderr.write(`${err.message}
33681
34519
  `);
33682
- resolve27(1);
34520
+ resolve28(1);
33683
34521
  });
33684
34522
  });
33685
34523
  }
@@ -33704,11 +34542,13 @@ function registerImportCommand(program, openTui) {
33704
34542
  }
33705
34543
 
33706
34544
  // packages/experience-design-system-cli/program.ts
34545
+ init_agent_store();
34546
+ init_apply_binary_overrides();
33707
34547
  init_analytics_store();
33708
34548
  init_package_root();
33709
34549
  var pkg = JSON.parse(
33710
34550
  readFileSync9(
33711
- join27(findPackageRoot(import.meta.url, "@contentful/experience-design-system-cli"), "package.json"),
34551
+ join28(findPackageRoot(import.meta.url, "@contentful/experience-design-system-cli"), "package.json"),
33712
34552
  "utf8"
33713
34553
  )
33714
34554
  );
@@ -33725,6 +34565,7 @@ function createProgram() {
33725
34565
  const commandChain = chain.join(" ") || actionCommand.name();
33726
34566
  const { enabled } = await readAnalyticsSetting();
33727
34567
  setPersistedAnalyticsDisabled(!enabled);
34568
+ await readAgentConfig().then(applyBinaryOverrides, () => void 0);
33728
34569
  setCliVersion(pkg.version);
33729
34570
  noteCommandStart(commandChain);
33730
34571
  });
@@ -33748,7 +34589,7 @@ init_config();
33748
34589
  init_package_root();
33749
34590
  import { existsSync as existsSync11 } from "node:fs";
33750
34591
  import { mkdir as mkdir10, readFile as readFile19, rename as rename3, rmdir, unlink } from "node:fs/promises";
33751
- import { dirname as dirname16, join as join28 } from "node:path";
34592
+ import { dirname as dirname16, join as join29 } from "node:path";
33752
34593
  var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
33753
34594
  async function readJson(path5) {
33754
34595
  try {
@@ -33759,9 +34600,9 @@ async function readJson(path5) {
33759
34600
  }
33760
34601
  async function migrateOldConfig() {
33761
34602
  try {
33762
- const oldCredentials = join28(oldConfigDir2(), "credentials.json");
33763
- const oldRuns = join28(oldConfigDir2(), "runs.json");
33764
- const oldDebugMode = join28(
34603
+ const oldCredentials = join29(oldConfigDir2(), "credentials.json");
34604
+ const oldRuns = join29(oldConfigDir2(), "runs.json");
34605
+ const oldDebugMode = join29(
33765
34606
  findPackageRoot(import.meta.url, PACKAGE_NAME3),
33766
34607
  ".contentful",
33767
34608
  "config",