@contentful/experience-design-system-cli 2.37.1-dev-build-a67bc4a4.0 → 2.37.1-dev-build-75039ab7.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,91 @@ 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 defaultChosen = isAgentName(stored);
19577
+ const defaultAgent = defaultChosen ? stored : DEFAULT_AGENT_NAME;
19578
+ const agents = emptyAgents();
19579
+ const saved = store["agents"];
19580
+ if (saved && typeof saved === "object") {
19581
+ for (const name of AGENT_NAMES) {
19582
+ const entry = saved[name];
19583
+ if (entry && typeof entry === "object") {
19584
+ const fields2 = entry;
19585
+ agents[name] = { model: asString(fields2["model"]), binary: asString(fields2["binary"]) };
19586
+ }
19587
+ }
19588
+ }
19589
+ const legacyModel = asString(store["agentModel"]);
19590
+ if (legacyModel && !agents[defaultAgent].model)
19591
+ agents[defaultAgent] = { ...agents[defaultAgent], model: legacyModel };
19592
+ return { defaultAgent, defaultChosen, agents };
19593
+ }
19594
+ async function writeAgentConfig(config) {
19595
+ const existing = await readV1Store();
19596
+ const merged = { ...existing };
19597
+ const agents = {};
19598
+ for (const name of AGENT_NAMES) {
19599
+ const model = config.agents[name].model.trim();
19600
+ const binary = config.agents[name].binary.trim();
19601
+ if (model || binary) agents[name] = { ...model ? { model } : {}, ...binary ? { binary } : {} };
19602
+ }
19603
+ const defaultModel = config.defaultChosen ? agents[config.defaultAgent]?.model : void 0;
19604
+ if (config.defaultChosen) merged["agent"] = config.defaultAgent;
19605
+ else delete merged["agent"];
19606
+ if (defaultModel) merged["agentModel"] = defaultModel;
19607
+ else delete merged["agentModel"];
19608
+ if (Object.keys(agents).length > 0) merged["agents"] = agents;
19609
+ else delete merged["agents"];
19610
+ await writeV1Store(merged);
19611
+ }
19612
+ var AGENT_LABELS, asString;
19613
+ var init_agent_store = __esm({
19614
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-store.ts"() {
19615
+ "use strict";
19616
+ init_src4();
19617
+ init_v1_store();
19618
+ AGENT_LABELS = {
19619
+ claude: "Claude Code",
19620
+ codex: "OpenAI Codex",
19621
+ opencode: "OpenCode",
19622
+ cursor: "Cursor",
19623
+ copilot: "GitHub Copilot"
19624
+ };
19625
+ asString = (value) => typeof value === "string" ? value : "";
19626
+ }
19627
+ });
19628
+
19629
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/apply-binary-overrides.ts
19630
+ function applyBinaryOverrides(config) {
19631
+ for (const name of AGENT_NAMES) {
19632
+ const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
19633
+ const binary = config.agents[name].binary.trim();
19634
+ if (binary) {
19635
+ if (!shellValues.has(key)) shellValues.set(key, process.env[key]);
19636
+ process.env[key] = binary;
19637
+ } else if (shellValues.has(key)) {
19638
+ const shellValue = shellValues.get(key);
19639
+ if (shellValue === void 0) delete process.env[key];
19640
+ else process.env[key] = shellValue;
19641
+ shellValues.delete(key);
19642
+ }
19643
+ }
19644
+ }
19645
+ var shellValues;
19646
+ var init_apply_binary_overrides = __esm({
19647
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/apply-binary-overrides.ts"() {
19648
+ "use strict";
19649
+ init_src4();
19650
+ shellValues = /* @__PURE__ */ new Map();
19651
+ }
19652
+ });
19653
+
19568
19654
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
19569
19655
  async function readAnalyticsSetting() {
19570
19656
  const store = await readV1Store();
@@ -19652,7 +19738,7 @@ var init_home_theme = __esm({
19652
19738
  }
19653
19739
  });
19654
19740
 
19655
- // packages/experience-design-system-cli/src/tui/home/version.ts
19741
+ // packages/experience-design-system-cli/src/tui/upgrade/version.ts
19656
19742
  import { readFileSync as readFileSync8 } from "node:fs";
19657
19743
  import { join as join17 } from "node:path";
19658
19744
  import semver from "semver";
@@ -19685,7 +19771,7 @@ async function checkForUpgrade() {
19685
19771
  }
19686
19772
  var PACKAGE_NAME2, TAGS_URL;
19687
19773
  var init_version = __esm({
19688
- "packages/experience-design-system-cli/src/tui/home/version.ts"() {
19774
+ "packages/experience-design-system-cli/src/tui/upgrade/version.ts"() {
19689
19775
  "use strict";
19690
19776
  init_package_root();
19691
19777
  PACKAGE_NAME2 = "@contentful/experience-design-system-cli";
@@ -19739,11 +19825,14 @@ var init_control_hints = __esm({
19739
19825
  import { useEffect as useEffect2, useState as useState2 } from "react";
19740
19826
  import { Box, Text as Text2, useApp, useInput } from "ink";
19741
19827
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
19742
- function versionStatus(upgradeCheck) {
19828
+ function upgradeItemDisplay(upgradeCheck) {
19743
19829
  if (upgradeCheck?.status === "update-available") {
19744
- return { text: ` (upgrade available v${upgradeCheck.latest})`, color: PALETTE.success };
19830
+ return { label: `Upgrade Version (v${upgradeCheck.latest} available)`, color: PALETTE.warning };
19745
19831
  }
19746
- return void 0;
19832
+ if (upgradeCheck?.status === "up-to-date") {
19833
+ return { label: "Upgrade Version (up to date)", color: PALETTE.muted };
19834
+ }
19835
+ return { label: "Upgrade Version" };
19747
19836
  }
19748
19837
  function HomeScreen({ onNavigate }) {
19749
19838
  const [focusIdx, setFocusIdx] = useState2(0);
@@ -19751,7 +19840,7 @@ function HomeScreen({ onNavigate }) {
19751
19840
  const { exit } = useApp();
19752
19841
  const terminalWidth = useTerminalWidth();
19753
19842
  const tooNarrow = terminalWidth < MIN_TERMINAL_WIDTH;
19754
- const status = versionStatus(upgradeCheck);
19843
+ const upgradeDisabled = upgradeCheck?.status === "up-to-date";
19755
19844
  useEffect2(() => {
19756
19845
  checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
19757
19846
  }, []);
@@ -19771,6 +19860,7 @@ function HomeScreen({ onNavigate }) {
19771
19860
  }
19772
19861
  if (key.return) {
19773
19862
  const item = START_ITEMS[focusIdx];
19863
+ if (item.screen === "upgrade" && upgradeDisabled) return;
19774
19864
  onNavigate(item.screen);
19775
19865
  return;
19776
19866
  }
@@ -19788,16 +19878,26 @@ function HomeScreen({ onNavigate }) {
19788
19878
  /* @__PURE__ */ jsx2(Text2, { color: PALETTE.muted, children: SUBTITLE }),
19789
19879
  /* @__PURE__ */ jsxs(Text2, { color: PALETTE.muted, children: [
19790
19880
  "v",
19791
- VERSION,
19792
- status && /* @__PURE__ */ jsx2(Text2, { color: status.color, children: status.text })
19881
+ VERSION
19793
19882
  ] })
19794
19883
  ] }),
19795
19884
  /* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(Box, { flexDirection: "column", children: START_ITEMS.map((item, i) => {
19796
19885
  const focused = i === focusIdx;
19797
- return /* @__PURE__ */ jsxs(Text2, { bold: focused, color: focused ? PALETTE.accent : void 0, children: [
19798
- focused ? `${FOCUS_MARKER} ` : " ",
19886
+ const isUpgradeItem = item.screen === "upgrade";
19887
+ const display = isUpgradeItem ? upgradeItemDisplay(upgradeCheck) : { label: item.label };
19888
+ const dimmed = isUpgradeItem && upgradeDisabled;
19889
+ return /* @__PURE__ */ jsxs(
19890
+ Text2,
19891
+ {
19892
+ bold: focused && !dimmed,
19893
+ color: dimmed ? PALETTE.muted : focused ? PALETTE.accent : display.color,
19894
+ children: [
19895
+ focused ? `${FOCUS_MARKER} ` : " ",
19896
+ display.label
19897
+ ]
19898
+ },
19799
19899
  item.label
19800
- ] }, item.label);
19900
+ );
19801
19901
  }) }) }),
19802
19902
  /* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(
19803
19903
  ControlHints,
@@ -19826,6 +19926,7 @@ var init_home = __esm({
19826
19926
  MIN_TERMINAL_WIDTH = 164;
19827
19927
  START_ITEMS = [
19828
19928
  { label: "Import", screen: "import" },
19929
+ { label: "Upgrade Version", screen: "upgrade" },
19829
19930
  { label: "Settings", screen: "settings" },
19830
19931
  { label: "Help", screen: "help" }
19831
19932
  ];
@@ -26116,16 +26217,16 @@ function SlotRow({
26116
26217
  ] });
26117
26218
  }
26118
26219
  function propFields(prop) {
26119
- const fields = ["description", "required", "type"];
26220
+ const fields2 = ["description", "required", "type"];
26120
26221
  if (prop.type === "token") {
26121
- fields.push("tokenKind");
26222
+ fields2.push("tokenKind");
26122
26223
  }
26123
- if (prop.type === "enum") fields.push("values");
26224
+ if (prop.type === "enum") fields2.push("values");
26124
26225
  if (prop.type !== "richtext" && prop.type !== "media" && prop.type !== "link") {
26125
- fields.push("default");
26226
+ fields2.push("default");
26126
26227
  }
26127
- if (prop.type === "token" && prop.category === "design") fields.push("allowed");
26128
- return fields;
26228
+ if (prop.type === "token" && prop.category === "design") fields2.push("allowed");
26229
+ return fields2;
26129
26230
  }
26130
26231
  function simulateGraphWithCandidate(projectSlotGraph, selfName, currentSlots, targetSlotName, candidate) {
26131
26232
  const selfEntry = {
@@ -26663,8 +26764,8 @@ function FieldEditor({
26663
26764
  return;
26664
26765
  }
26665
26766
  if (focusLevel === "field") {
26666
- const fields = inSlots ? SLOT_FIELDS : currentProp ? propFields(currentProp) : [];
26667
- const currentFieldIdx = fields.indexOf(activeField);
26767
+ const fields2 = inSlots ? SLOT_FIELDS : currentProp ? propFields(currentProp) : [];
26768
+ const currentFieldIdx = fields2.indexOf(activeField);
26668
26769
  const isValuesNav = activeField === "values" || activeField === "allowedComponents";
26669
26770
  const arrowUp = key.upArrow;
26670
26771
  const arrowDown = key.downArrow;
@@ -26678,10 +26779,10 @@ function FieldEditor({
26678
26779
  const navPrevious = arrowUp || arrowLeft;
26679
26780
  const navNext = arrowDown || arrowRight || input === "j";
26680
26781
  const navBack = navPrevious || input === "k";
26681
- if ((navBack || navNext) && fields.length > 0) {
26682
- const lastIdx = fields.length - 1;
26782
+ if ((navBack || navNext) && fields2.length > 0) {
26783
+ const lastIdx = fields2.length - 1;
26683
26784
  const targetIdx = navNext ? currentFieldIdx >= lastIdx ? 0 : currentFieldIdx + 1 : currentFieldIdx <= 0 ? lastIdx : currentFieldIdx - 1;
26684
- const next = fields[targetIdx];
26785
+ const next = fields2[targetIdx];
26685
26786
  setActiveField(next);
26686
26787
  if (next === "description") {
26687
26788
  const desc = inSlots ? currentSlot?.description ?? "" : currentProp?.description ?? "";
@@ -32258,7 +32359,7 @@ var init_save = __esm({
32258
32359
  writeFile: (path5, contents) => writeFile7(path5, contents),
32259
32360
  appendRun,
32260
32361
  buildSourceFingerprint,
32261
- sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
32362
+ sleep: (ms) => new Promise((resolve28) => setTimeout(resolve28, ms)),
32262
32363
  warn: (message) => process.stderr.write(message)
32263
32364
  });
32264
32365
  }
@@ -32809,13 +32910,48 @@ var init_debug_store = __esm({
32809
32910
  }
32810
32911
  });
32811
32912
 
32913
+ // packages/experience-design-system-cli/src/tui/help/file-locations.ts
32914
+ import { join as join26, resolve as resolve27 } from "node:path";
32915
+ function describeFileLocations({
32916
+ contentfulBaseDir,
32917
+ debugModeEnabled,
32918
+ currentSessionDir: currentSessionDir2
32919
+ }) {
32920
+ if (!debugModeEnabled) {
32921
+ return {
32922
+ debugLogs: "none while Debug Mode is off",
32923
+ importFiles: `${join26("<project>", ".contentful")}/ (tokens.json, components.json)`
32924
+ };
32925
+ }
32926
+ const base = contentfulBaseDir ? resolve27(contentfulBaseDir) : "<project>";
32927
+ const session = currentSessionDir2 ?? join26(base, ".contentful", "<date>-session-<n>");
32928
+ return {
32929
+ debugLogs: join26(session, "debug"),
32930
+ importFiles: `${join26(session, "dsi-import-<n>")}/ (tokens.json, components.json)`
32931
+ };
32932
+ }
32933
+ var init_file_locations = __esm({
32934
+ "packages/experience-design-system-cli/src/tui/help/file-locations.ts"() {
32935
+ "use strict";
32936
+ }
32937
+ });
32938
+
32812
32939
  // packages/experience-design-system-cli/src/tui/help/help-info.ts
32813
32940
  async function readHelpInfo() {
32814
- const debugMode = await readDebugModeSetting();
32941
+ const [debugMode, settings] = await Promise.all([readDebugModeSetting(), readSettings2()]);
32942
+ const base = settings["contentfulBaseDir"];
32943
+ const locations = describeFileLocations({
32944
+ contentfulBaseDir: typeof base === "string" ? base : "",
32945
+ debugModeEnabled: debugMode.enabled,
32946
+ currentSessionDir: currentSessionDir()
32947
+ });
32815
32948
  return {
32816
32949
  storage: [
32817
32950
  { label: "Config folder", value: configRoot2() },
32818
- { label: "Settings file", value: configFilePath2() }
32951
+ { label: "Settings file", value: configFilePath2() },
32952
+ { label: "Agent settings", value: `${configFilePath2()} (keys: agent, agentModel, agents)` },
32953
+ { label: "Debug logs", value: locations.debugLogs },
32954
+ { label: "Import files", value: locations.importFiles }
32819
32955
  ],
32820
32956
  troubleshooting: [
32821
32957
  { label: "CLI version", value: readPackageVersion() },
@@ -32836,6 +32972,7 @@ var init_help_info = __esm({
32836
32972
  init_debug_store();
32837
32973
  init_debug_mode_store();
32838
32974
  init_version();
32975
+ init_file_locations();
32839
32976
  }
32840
32977
  });
32841
32978
 
@@ -32847,7 +32984,7 @@ function Section({ title, rows }) {
32847
32984
  return /* @__PURE__ */ jsxs43(Box42, { flexDirection: "column", children: [
32848
32985
  /* @__PURE__ */ jsx53(Text44, { bold: true, color: PALETTE.accent, children: title }),
32849
32986
  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 }) }),
32987
+ /* @__PURE__ */ jsx53(Box42, { width: 16, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
32851
32988
  /* @__PURE__ */ jsx53(Text44, { children: row.value })
32852
32989
  ] }, row.label))
32853
32990
  ] });
@@ -32962,7 +33099,673 @@ var init_PageContainer3 = __esm({
32962
33099
  }
32963
33100
  });
32964
33101
 
32965
- // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
33102
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
33103
+ import { execFile as execFile2 } from "node:child_process";
33104
+ import { access as access6, constants } from "node:fs/promises";
33105
+ function effectiveBinary(name, savedBinary) {
33106
+ return savedBinary.trim() || AGENT_BINARIES[name];
33107
+ }
33108
+ function defaultModelLabel(name) {
33109
+ const model = DEFAULT_MODELS[name];
33110
+ return model && model !== "Auto" ? model : "chosen by the agent";
33111
+ }
33112
+ function resolveOnPath(binary) {
33113
+ if (binary.includes("/")) {
33114
+ return access6(binary, constants.X_OK).then(
33115
+ () => binary,
33116
+ () => null
33117
+ );
33118
+ }
33119
+ return new Promise((resolve28) => {
33120
+ execFile2(
33121
+ process.platform === "win32" ? "where" : "which",
33122
+ [binary],
33123
+ (error, stdout) => resolve28(error ? null : stdout.split("\n")[0]?.trim() ?? null)
33124
+ );
33125
+ });
33126
+ }
33127
+ function readVersion(binary) {
33128
+ return new Promise((resolve28) => {
33129
+ execFile2(binary, ["--version"], { timeout: VERSION_TIMEOUT_MS }, (error, stdout) => {
33130
+ const line = stdout.split("\n")[0]?.trim() ?? "";
33131
+ if (!error && line) resolve28(pass("version", line));
33132
+ else resolve28(fail3("version", "runs, but did not report a version"));
33133
+ });
33134
+ });
33135
+ }
33136
+ async function inspect(name, binary) {
33137
+ const target = effectiveBinary(name, binary);
33138
+ const found = await resolveOnPath(target);
33139
+ if (!found) return { checks: [fail3("path", `\`${target}\` was not found or is not executable`)], found: null };
33140
+ const checks = [pass("path", found)];
33141
+ checks.push(await readVersion(found));
33142
+ if (name === "claude") {
33143
+ const auth = await withBinaryEnv(name, found, () => checkAgentAuth(name));
33144
+ checks.push(
33145
+ auth === "ok" ? pass("login", "logged in") : fail3("login", auth === "not-found" ? "binary not found" : `not logged in: ${LOGIN_HINTS.claude}`)
33146
+ );
33147
+ }
33148
+ return { checks, found };
33149
+ }
33150
+ async function inspectAgent(name, binary) {
33151
+ return (await inspect(name, binary)).checks;
33152
+ }
33153
+ async function testAgent(name, binary, model) {
33154
+ const { checks, found } = await inspect(name, binary);
33155
+ if (!found || !checks.every((check) => check.step === "version" || check.ok)) return checks;
33156
+ const started = Date.now();
33157
+ const result = await withBinaryEnv(
33158
+ name,
33159
+ found,
33160
+ () => createLocalCliAgentInvoker().invoke({
33161
+ agent: name,
33162
+ ...model.trim() ? { model: model.trim() } : {},
33163
+ prompt: TEST_PROMPT,
33164
+ timeoutMs: PROMPT_TIMEOUT_MS
33165
+ })
33166
+ );
33167
+ const seconds = ((Date.now() - started) / 1e3).toFixed(1);
33168
+ if (result.timedOut) {
33169
+ return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
33170
+ }
33171
+ if (result.exitCode !== 0) {
33172
+ const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
33173
+ return [...checks, fail3("prompt", reason)];
33174
+ }
33175
+ return [...checks, pass("prompt", `answered in ${seconds}s`)];
33176
+ }
33177
+ function statusFromChecks(name, checks, savedBinary) {
33178
+ if (checks.length === 0) return "checking";
33179
+ if (checks.some((check) => check.step === "path" && !check.ok)) {
33180
+ return savedBinary.trim() ? "not-found" : "not-configured";
33181
+ }
33182
+ const prompt = checks.find((check) => check.step === "prompt");
33183
+ if (prompt) {
33184
+ if (prompt.ok) return "ready";
33185
+ return prompt.timedOut ? "timed-out" : "test-failed";
33186
+ }
33187
+ const login = checks.find((check) => check.step === "login");
33188
+ if (login) return login.ok ? "ready" : "not-logged-in";
33189
+ return name === "claude" ? "ready" : "unknown";
33190
+ }
33191
+ function setupHint(name, status) {
33192
+ if (status === "not-configured") return `${INSTALL_HINTS[name]}, or set its command path in settings`;
33193
+ if (status === "not-found") return `${INSTALL_HINTS[name]}, or correct the command path in settings`;
33194
+ if (status === "not-logged-in") return LOGIN_HINTS[name];
33195
+ if (status === "test-failed") return `read the test message; if it is a login problem, ${LOGIN_HINTS[name]}`;
33196
+ if (status === "timed-out") return "it may be slow or waiting for input; run the test again, or try it in a terminal";
33197
+ if (status === "unknown") return "run a full test to confirm it is logged in";
33198
+ return "";
33199
+ }
33200
+ function testOutcome(checks) {
33201
+ const prompt = checks?.find((check) => check.step === "prompt");
33202
+ if (!prompt) return void 0;
33203
+ if (prompt.ok) return { ok: true, text: `Test passed: ${prompt.detail}` };
33204
+ if (prompt.timedOut) return { ok: false, text: `Test timed out: ${prompt.detail}` };
33205
+ return { ok: false, text: `Test failed: ${prompt.detail}` };
33206
+ }
33207
+ function modelLine(name, savedModel) {
33208
+ const model = savedModel.trim();
33209
+ return model ? model : `${defaultModelLabel(name)} (built-in default)`;
33210
+ }
33211
+ function baseRows(name, checks, savedBinary) {
33212
+ const path5 = checks.find((check) => check.step === "path");
33213
+ const version = checks.find((check) => check.step === "version");
33214
+ const hint = setupHint(name, statusFromChecks(name, checks, savedBinary));
33215
+ const setup = hint ? { label: "Setup", value: hint, tone: "muted" } : void 0;
33216
+ if (!path5?.ok) {
33217
+ const saved = savedBinary.trim() !== "";
33218
+ const command = {
33219
+ label: "Command",
33220
+ value: saved ? path5?.detail ?? "not found" : "not configured (not on the PATH)",
33221
+ tone: saved ? "bad" : "muted"
33222
+ };
33223
+ return { command, version: void 0, setup, found: false };
33224
+ }
33225
+ return {
33226
+ command: { label: "Command", value: path5.detail, tone: "ok" },
33227
+ version: {
33228
+ label: "Version",
33229
+ value: version?.ok ? version.detail : "could not be read",
33230
+ tone: version?.ok ? "ok" : "muted"
33231
+ },
33232
+ setup,
33233
+ found: true
33234
+ };
33235
+ }
33236
+ function panelRows(name, checks, settings) {
33237
+ if (!checks) return checking;
33238
+ const { command, version, setup, found } = baseRows(name, checks, settings.binary);
33239
+ const model = { label: "Model", value: modelLine(name, settings.model), tone: "muted" };
33240
+ return [command, ...found ? [...version?.tone === "ok" ? [version] : [], model] : [], ...setup ? [setup] : []];
33241
+ }
33242
+ function statusRows(name, checks, savedBinary) {
33243
+ if (!checks) return checking;
33244
+ const { command, version, setup, found } = baseRows(name, checks, savedBinary);
33245
+ if (!found) return [command];
33246
+ const login = checks.find((check) => check.step === "login");
33247
+ const prompt = checks.find((check) => check.step === "prompt");
33248
+ let loginRow;
33249
+ if (login) {
33250
+ loginRow = { label: "Login", value: login.detail, tone: login.ok ? "ok" : "bad" };
33251
+ } else if (prompt) {
33252
+ loginRow = {
33253
+ label: "Login",
33254
+ value: prompt.ok ? "confirmed by the test" : prompt.timedOut ? "unknown (the test timed out)" : "see the test result",
33255
+ tone: prompt.ok ? "ok" : prompt.timedOut ? "muted" : "bad"
33256
+ };
33257
+ } else {
33258
+ loginRow = { label: "Login", value: "not checked (use Run test)", tone: "muted" };
33259
+ }
33260
+ const testRow = prompt ? [{ label: "Test", value: prompt.detail, tone: prompt.ok ? "ok" : "bad" }] : [];
33261
+ return [command, ...version ? [version] : [], loginRow, ...testRow, ...setup ? [setup] : []];
33262
+ }
33263
+ async function withBinaryEnv(name, binary, run) {
33264
+ const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
33265
+ const previous = process.env[key];
33266
+ process.env[key] = binary;
33267
+ try {
33268
+ return await run();
33269
+ } finally {
33270
+ if (previous === void 0) delete process.env[key];
33271
+ else process.env[key] = previous;
33272
+ }
33273
+ }
33274
+ var VERSION_TIMEOUT_MS, PROMPT_TIMEOUT_MS, TEST_PROMPT, INSTALL_HINTS, LOGIN_HINTS, fail3, pass, LIST_STATUS, checking;
33275
+ var init_agent_status = __esm({
33276
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts"() {
33277
+ "use strict";
33278
+ init_src4();
33279
+ VERSION_TIMEOUT_MS = 5e3;
33280
+ PROMPT_TIMEOUT_MS = 6e4;
33281
+ TEST_PROMPT = "Reply with the single word: ok";
33282
+ INSTALL_HINTS = {
33283
+ claude: "npm install -g @anthropic-ai/claude-code",
33284
+ codex: "npm install -g @openai/codex",
33285
+ opencode: "npm install -g opencode-ai",
33286
+ cursor: "install Cursor\u2019s `cursor-agent` command",
33287
+ copilot: "npm install -g @github/copilot"
33288
+ };
33289
+ LOGIN_HINTS = {
33290
+ claude: "run `claude login`",
33291
+ codex: "set OPENAI_API_KEY, or sign in with a ChatGPT account",
33292
+ opencode: "run `opencode auth`",
33293
+ cursor: "sign in from Cursor",
33294
+ copilot: "run `copilot` and sign in"
33295
+ };
33296
+ fail3 = (step, detail) => ({ step, ok: false, detail });
33297
+ pass = (step, detail) => ({ step, ok: true, detail });
33298
+ LIST_STATUS = {
33299
+ checking: { symbol: "\u2026", text: "checking", tone: "muted" },
33300
+ ready: { symbol: "\u25CF", text: "ready", tone: "ok" },
33301
+ "not-configured": { symbol: "\u25CB", text: "not installed", tone: "muted" },
33302
+ "not-found": { symbol: "\u25CB", text: "not installed", tone: "bad" },
33303
+ "not-logged-in": { symbol: "\u25D0", text: "not logged in", tone: "bad" },
33304
+ "test-failed": { symbol: "\u2717", text: "test failed", tone: "bad" },
33305
+ "timed-out": { symbol: "\u2717", text: "test timed out", tone: "bad" },
33306
+ unknown: { symbol: "\u25D0", text: "installed, login unknown", tone: "muted" }
33307
+ };
33308
+ checking = [{ label: "Command", value: "checking...", tone: "muted" }];
33309
+ }
33310
+ });
33311
+
33312
+ // packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx
33313
+ import { useState as useState29 } from "react";
33314
+ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
33315
+ import TextInput4 from "ink-text-input";
33316
+ import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
33317
+ function FieldForm({
33318
+ title,
33319
+ subtitle,
33320
+ fields: fields2,
33321
+ values,
33322
+ onChange,
33323
+ onSave,
33324
+ onQuit,
33325
+ actions = [],
33326
+ notice,
33327
+ busy = false,
33328
+ children
33329
+ }) {
33330
+ const [active, setActive] = useState29(0);
33331
+ const [editing, setEditing] = useState29(false);
33332
+ const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
33333
+ const rowCount = fields2.length + actions.length;
33334
+ const labelWidth = Math.max(
33335
+ ...fields2.map((field) => field.label.length),
33336
+ ...actions.map((action) => action.label.length)
33337
+ );
33338
+ const currentField = active < fields2.length ? fields2[active] : void 0;
33339
+ const currentAction = currentField ? void 0 : actions[active - fields2.length];
33340
+ useInput11((input, key) => {
33341
+ if (busy) return;
33342
+ if (editing) {
33343
+ if (key.escape && currentField) {
33344
+ onChange(currentField.key, valueBeforeEdit);
33345
+ setEditing(false);
33346
+ }
33347
+ return;
33348
+ }
33349
+ if (key.escape || input === "q") {
33350
+ onQuit();
33351
+ return;
33352
+ }
33353
+ if (input === "s") {
33354
+ onSave();
33355
+ return;
33356
+ }
33357
+ if (input === "c" && currentField) {
33358
+ onChange(currentField.key, "");
33359
+ return;
33360
+ }
33361
+ if (key.tab || key.downArrow) {
33362
+ setActive((i) => (i + 1) % rowCount);
33363
+ return;
33364
+ }
33365
+ if (key.upArrow) {
33366
+ setActive((i) => (i - 1 + rowCount) % rowCount);
33367
+ return;
33368
+ }
33369
+ if (key.return) {
33370
+ if (currentField) {
33371
+ setValueBeforeEdit(values[currentField.key]);
33372
+ setEditing(true);
33373
+ } else {
33374
+ currentAction?.onRun();
33375
+ }
33376
+ }
33377
+ });
33378
+ const pointer = (isActive) => /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " });
33379
+ return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33380
+ /* @__PURE__ */ jsx55(Text46, { bold: true, children: title }),
33381
+ subtitle && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: subtitle }),
33382
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
33383
+ /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", children: [
33384
+ fields2.map((field, index) => {
33385
+ const isActive = index === active;
33386
+ const value = values[field.key];
33387
+ const display = field.masked ? "\u2022".repeat(value.length) : value;
33388
+ return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
33389
+ pointer(isActive),
33390
+ /* @__PURE__ */ jsx55(Box44, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: field.label }) }),
33391
+ isActive && editing ? /* @__PURE__ */ jsx55(
33392
+ TextInput4,
33393
+ {
33394
+ value,
33395
+ onChange: (next) => onChange(field.key, next),
33396
+ onSubmit: () => setEditing(false),
33397
+ mask: field.masked ? "\u2022" : void 0
33398
+ }
33399
+ ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (field.hint ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
33400
+ field.hint && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: field.hint })
33401
+ ] }, field.key);
33402
+ }),
33403
+ actions.map((action, index) => {
33404
+ const isActive = fields2.length + index === active;
33405
+ return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
33406
+ pointer(isActive),
33407
+ /* @__PURE__ */ jsx55(Box44, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: action.label }) }),
33408
+ /* @__PURE__ */ jsx55(Text46, { color: action.running ? PALETTE.accent : PALETTE.muted, children: action.running ? action.runningText ?? "running..." : action.description })
33409
+ ] }, action.label);
33410
+ })
33411
+ ] }),
33412
+ notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
33413
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
33414
+ /* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
33415
+ notice.kind === "success" ? "\u2713" : "\u2717",
33416
+ " ",
33417
+ notice.text
33418
+ ] })
33419
+ ] }),
33420
+ children,
33421
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
33422
+ /* @__PURE__ */ jsx55(
33423
+ ControlHints,
33424
+ {
33425
+ hints: editing ? [
33426
+ { keys: "type", label: "edit" },
33427
+ { keys: "\u2190/\u2192", label: "move cursor" },
33428
+ { keys: "\u23CE", label: "done" },
33429
+ { keys: "Esc", label: "cancel edit" }
33430
+ ] : [
33431
+ { keys: "\u2191/\u2193", label: "move" },
33432
+ { keys: "\u23CE", label: currentAction ? currentAction.hint : "edit" },
33433
+ ...currentField ? [{ keys: "c", label: "clear" }] : [],
33434
+ { keys: "s", label: "save" },
33435
+ { keys: "Esc/q", label: "back without saving" }
33436
+ ]
33437
+ }
33438
+ )
33439
+ ] });
33440
+ }
33441
+ var init_FieldForm = __esm({
33442
+ "packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx"() {
33443
+ "use strict";
33444
+ init_theme();
33445
+ init_control_hints();
33446
+ }
33447
+ });
33448
+
33449
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx
33450
+ import { Text as Text47 } from "ink";
33451
+ import { jsx as jsx56 } from "react/jsx-runtime";
33452
+ function AgentStatusBadge({
33453
+ name,
33454
+ checks,
33455
+ binary
33456
+ }) {
33457
+ const { symbol, text, tone } = LIST_STATUS[checks ? statusFromChecks(name, checks, binary) : "checking"];
33458
+ return /* @__PURE__ */ jsx56(Text47, { color: TONE_COLOR[tone], children: `${symbol} ${text}` });
33459
+ }
33460
+ var TONE_COLOR;
33461
+ var init_AgentStatusBadge = __esm({
33462
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx"() {
33463
+ "use strict";
33464
+ init_theme();
33465
+ init_agent_status();
33466
+ TONE_COLOR = {
33467
+ ok: PALETTE.success,
33468
+ bad: PALETTE.error,
33469
+ muted: PALETTE.muted
33470
+ };
33471
+ }
33472
+ });
33473
+
33474
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
33475
+ import { useEffect as useEffect22, useState as useState30 } from "react";
33476
+ import { Box as Box45, Text as Text48 } from "ink";
33477
+ import { jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
33478
+ function Row2({ label, children }) {
33479
+ return /* @__PURE__ */ jsxs46(Box45, { children: [
33480
+ /* @__PURE__ */ jsx57(Box45, { width: POINTER_WIDTH + LABEL_WIDTH + LABEL_GAP, flexShrink: 0, children: /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: label }) }),
33481
+ children
33482
+ ] });
33483
+ }
33484
+ function StatusHeading() {
33485
+ return /* @__PURE__ */ jsxs46(Box45, { gap: 1, children: [
33486
+ /* @__PURE__ */ jsx57(Text48, { bold: true, color: PALETTE.muted, children: "STATUS" }),
33487
+ /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "\xB7 read only" })
33488
+ ] });
33489
+ }
33490
+ function AgentDetail({
33491
+ name,
33492
+ config,
33493
+ setConfig,
33494
+ onBack
33495
+ }) {
33496
+ const settings = config.agents[name];
33497
+ const [saving, setSaving] = useState30(false);
33498
+ const [testing, setTesting] = useState30(false);
33499
+ const [notice, setNotice] = useState30(null);
33500
+ const [checks, setChecks] = useState30(void 0);
33501
+ useEffect22(() => {
33502
+ let active = true;
33503
+ setChecks(void 0);
33504
+ const timer = setTimeout(() => {
33505
+ void inspectAgent(name, settings.binary).then((result) => active && setChecks(result));
33506
+ }, INSPECT_DELAY_MS);
33507
+ return () => {
33508
+ active = false;
33509
+ clearTimeout(timer);
33510
+ };
33511
+ }, [name, settings.binary]);
33512
+ const save = () => {
33513
+ setSaving(true);
33514
+ setNotice(null);
33515
+ writeAgentConfig(config).then(() => {
33516
+ applyBinaryOverrides(config);
33517
+ setNotice({ kind: "success", text: `Saved: ${AGENT_LABELS[name]} settings are written to config.json` });
33518
+ }).catch(
33519
+ (err) => setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` })
33520
+ ).finally(() => setSaving(false));
33521
+ };
33522
+ const runTest = () => {
33523
+ setTesting(true);
33524
+ setNotice(null);
33525
+ testAgent(name, settings.binary, settings.model).then((result) => {
33526
+ setChecks(result);
33527
+ const outcome = testOutcome(result);
33528
+ setNotice(
33529
+ outcome ? { kind: outcome.ok ? "success" : "error", text: outcome.text } : { kind: "error", text: "Test not run: the agent could not be started (see Status)" }
33530
+ );
33531
+ }).catch(
33532
+ (err) => setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` })
33533
+ ).finally(() => setTesting(false));
33534
+ };
33535
+ const action = {
33536
+ label: "Run test",
33537
+ description: "sends one small prompt (uses a few tokens)",
33538
+ running: testing,
33539
+ hint: "run test",
33540
+ onRun: runTest
33541
+ };
33542
+ return /* @__PURE__ */ jsx57(
33543
+ FieldForm,
33544
+ {
33545
+ title: AGENT_LABELS[name],
33546
+ subtitle: config.defaultAgent === name ? "This is the default agent." : `Runs the \`${AGENT_BINARIES[name]}\` command.`,
33547
+ fields: fields(name),
33548
+ values: { binary: settings.binary, model: settings.model },
33549
+ onChange: (key, value) => {
33550
+ setConfig({ ...config, agents: { ...config.agents, [name]: { ...settings, [key]: value } } });
33551
+ setNotice(null);
33552
+ },
33553
+ onSave: save,
33554
+ onQuit: onBack,
33555
+ actions: [action],
33556
+ notice: testing ? null : notice,
33557
+ busy: saving || testing,
33558
+ children: /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", marginTop: 1, children: [
33559
+ /* @__PURE__ */ jsx57(StatusHeading, {}),
33560
+ 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))
33561
+ ] })
33562
+ }
33563
+ );
33564
+ }
33565
+ var fields, INSPECT_DELAY_MS, LABEL_WIDTH, LABEL_GAP, POINTER_WIDTH;
33566
+ var init_AgentDetail = __esm({
33567
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx"() {
33568
+ "use strict";
33569
+ init_src4();
33570
+ init_theme();
33571
+ init_FieldForm();
33572
+ init_agent_store();
33573
+ init_agent_status();
33574
+ init_AgentStatusBadge();
33575
+ init_apply_binary_overrides();
33576
+ fields = (name) => [
33577
+ { key: "binary", label: "Command path", hint: `(empty: \`${AGENT_BINARIES[name]}\` from the PATH)` },
33578
+ { key: "model", label: "Model", hint: `(empty: ${defaultModelLabel(name)})` }
33579
+ ];
33580
+ INSPECT_DELAY_MS = 400;
33581
+ LABEL_WIDTH = "Command path".length;
33582
+ LABEL_GAP = 2;
33583
+ POINTER_WIDTH = 2;
33584
+ }
33585
+ });
33586
+
33587
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
33588
+ import { useEffect as useEffect23, useState as useState31 } from "react";
33589
+ import { Box as Box46, Text as Text49, useInput as useInput12 } from "ink";
33590
+ import { Fragment as Fragment18, jsx as jsx58, jsxs as jsxs47 } from "react/jsx-runtime";
33591
+ function AgentsScreen({ onDone }) {
33592
+ const [config, setConfig] = useState31(null);
33593
+ const [focus, setFocus] = useState31(0);
33594
+ const [open, setOpen] = useState31(null);
33595
+ const [notice, setNotice] = useState31(null);
33596
+ const [saving, setSaving] = useState31(false);
33597
+ const [loadError, setLoadError] = useState31(null);
33598
+ const [checks, setChecks] = useState31({});
33599
+ const inspectAll = (loaded) => {
33600
+ for (const name of AGENT_NAMES) {
33601
+ void inspectAgent(name, loaded.agents[name].binary).then(
33602
+ (result) => setChecks((previous) => ({ ...previous, [name]: result }))
33603
+ );
33604
+ }
33605
+ };
33606
+ useEffect23(() => {
33607
+ readAgentConfig().then((loaded) => {
33608
+ setConfig(loaded);
33609
+ inspectAll(loaded);
33610
+ startDebugRun({
33611
+ flow: "settings/agents",
33612
+ step: "01-agents",
33613
+ menuOption: "Configuration > Agents",
33614
+ inputs: { default_agent: loaded.defaultAgent }
33615
+ });
33616
+ }).catch((err) => setLoadError(err instanceof Error ? err.message : String(err)));
33617
+ }, []);
33618
+ const makeDefault = (name) => {
33619
+ if (!config || saving) return;
33620
+ if (name === config.defaultAgent) {
33621
+ setNotice({ kind: "success", text: `${AGENT_LABELS[name]} is already the default agent` });
33622
+ return;
33623
+ }
33624
+ setSaving(true);
33625
+ setNotice(null);
33626
+ writeAgentConfig({ ...config, defaultAgent: name, defaultChosen: true }).then(() => {
33627
+ setConfig((current) => current ? { ...current, defaultAgent: name, defaultChosen: true } : current);
33628
+ setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[name]}` });
33629
+ }).catch(
33630
+ (err) => setNotice({
33631
+ kind: "error",
33632
+ text: `Default agent not changed: ${err instanceof Error ? err.message : String(err)}`
33633
+ })
33634
+ ).finally(() => setSaving(false));
33635
+ };
33636
+ useInput12((input, key) => {
33637
+ if (loadError && (key.escape || input === "q")) {
33638
+ onDone();
33639
+ return;
33640
+ }
33641
+ if (!config || open || saving) return;
33642
+ const focused = AGENT_NAMES[focus];
33643
+ if (key.upArrow || key.downArrow || key.tab) setNotice(null);
33644
+ if (key.upArrow) {
33645
+ setFocus((i) => (i - 1 + AGENT_NAMES.length) % AGENT_NAMES.length);
33646
+ return;
33647
+ }
33648
+ if (key.downArrow || key.tab) {
33649
+ setFocus((i) => (i + 1) % AGENT_NAMES.length);
33650
+ return;
33651
+ }
33652
+ if (key.return) {
33653
+ makeDefault(focused);
33654
+ return;
33655
+ }
33656
+ if (key.rightArrow) {
33657
+ setNotice(null);
33658
+ setOpen(focused);
33659
+ return;
33660
+ }
33661
+ if (key.escape || input === "q") {
33662
+ void finishDebugRun({ outputs: { default_agent: config.defaultAgent }, status: "success", exitMethod: "saved" });
33663
+ onDone();
33664
+ }
33665
+ });
33666
+ if (!config) {
33667
+ return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33668
+ /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Agents" }),
33669
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33670
+ loadError ? /* @__PURE__ */ jsxs47(Fragment18, { children: [
33671
+ /* @__PURE__ */ jsxs47(Text49, { color: PALETTE.error, children: [
33672
+ "\u2717 Could not read the settings: ",
33673
+ loadError
33674
+ ] }),
33675
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33676
+ /* @__PURE__ */ jsx58(ControlHints, { hints: [{ keys: "Esc/q", label: "back" }] })
33677
+ ] }) : /* @__PURE__ */ jsx58(Text49, { color: PALETTE.accent, children: "Loading..." })
33678
+ ] });
33679
+ }
33680
+ if (open) {
33681
+ return /* @__PURE__ */ jsx58(
33682
+ AgentDetail,
33683
+ {
33684
+ name: open,
33685
+ config,
33686
+ setConfig,
33687
+ onBack: () => {
33688
+ setOpen(null);
33689
+ void readAgentConfig().then((saved) => {
33690
+ setConfig(saved);
33691
+ inspectAll(saved);
33692
+ });
33693
+ }
33694
+ }
33695
+ );
33696
+ }
33697
+ const focusedAgent = AGENT_NAMES[focus];
33698
+ return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33699
+ /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Agents" }),
33700
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "The coding agent the CLI runs, and what was found for each one." }),
33701
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33702
+ /* @__PURE__ */ jsxs47(Box46, { gap: 1, children: [
33703
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "Default agent" }),
33704
+ /* @__PURE__ */ jsx58(Text49, { bold: true, children: AGENT_LABELS[config.defaultAgent] }),
33705
+ saving && /* @__PURE__ */ jsx58(Text49, { color: PALETTE.accent, children: "\u2026 saving" })
33706
+ ] }),
33707
+ /* @__PURE__ */ jsxs47(Box46, { marginTop: 1, gap: 1, children: [
33708
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33709
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33710
+ /* @__PURE__ */ jsx58(Box46, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "AGENT" }) }),
33711
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "STATUS" })
33712
+ ] }),
33713
+ AGENT_NAMES.map((name) => {
33714
+ const isFocused = focusedAgent === name;
33715
+ return /* @__PURE__ */ jsxs47(Box46, { gap: 1, children: [
33716
+ /* @__PURE__ */ jsx58(Text49, { color: isFocused ? PALETTE.accent : void 0, children: isFocused ? "\u276F" : " " }),
33717
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.success, children: name === config.defaultAgent ? "\u2605" : " " }),
33718
+ /* @__PURE__ */ jsx58(Box46, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { bold: isFocused, color: isFocused ? PALETTE.accent : void 0, children: AGENT_LABELS[name] }) }),
33719
+ /* @__PURE__ */ jsx58(AgentStatusBadge, { name, checks: checks[name], binary: config.agents[name].binary })
33720
+ ] }, name);
33721
+ }),
33722
+ /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", marginTop: 1, children: [
33723
+ /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: `\u2500 ${AGENT_LABELS[focusedAgent]} ${"\u2500".repeat(30)}` }),
33724
+ panelRows(focusedAgent, checks[focusedAgent], config.agents[focusedAgent]).map((row) => /* @__PURE__ */ jsxs47(Box46, { gap: 1, paddingLeft: 1, children: [
33725
+ /* @__PURE__ */ jsx58(Box46, { width: PANEL_LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: row.label }) }),
33726
+ /* @__PURE__ */ jsx58(Text49, { color: TONE_COLOR[row.tone], children: row.value })
33727
+ ] }, row.label))
33728
+ ] }),
33729
+ notice && /* @__PURE__ */ jsxs47(Fragment18, { children: [
33730
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33731
+ /* @__PURE__ */ jsxs47(Text49, { bold: true, color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
33732
+ notice.kind === "success" ? "\u2713" : "\u2717",
33733
+ " ",
33734
+ notice.text
33735
+ ] })
33736
+ ] }),
33737
+ /* @__PURE__ */ jsx58(Text49, { children: " " }),
33738
+ /* @__PURE__ */ jsx58(
33739
+ ControlHints,
33740
+ {
33741
+ hints: [
33742
+ { keys: "\u2191/\u2193", label: "move" },
33743
+ { keys: "\u23CE", label: "make default" },
33744
+ { keys: "\u2192", label: "settings and test" },
33745
+ { keys: "Esc/q", label: "back" }
33746
+ ]
33747
+ }
33748
+ )
33749
+ ] });
33750
+ }
33751
+ var NAME_WIDTH, PANEL_LABEL_WIDTH;
33752
+ var init_AgentsScreen = __esm({
33753
+ "packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx"() {
33754
+ "use strict";
33755
+ init_src4();
33756
+ init_theme();
33757
+ init_control_hints();
33758
+ init_debug_store();
33759
+ init_agent_store();
33760
+ init_agent_status();
33761
+ init_AgentDetail();
33762
+ init_AgentStatusBadge();
33763
+ NAME_WIDTH = 16;
33764
+ PANEL_LABEL_WIDTH = "Command".length;
33765
+ }
33766
+ });
33767
+
33768
+ // packages/experience-design-system-cli/src/tui/settings/configuration/project/project-store.ts
32966
33769
  async function readCredentials() {
32967
33770
  const store = await readV1Store();
32968
33771
  return {
@@ -32986,18 +33789,17 @@ async function writeCredentials(config) {
32986
33789
  });
32987
33790
  await writeV1Store(merged);
32988
33791
  }
32989
- var init_config_store = __esm({
32990
- "packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts"() {
33792
+ var init_project_store = __esm({
33793
+ "packages/experience-design-system-cli/src/tui/settings/configuration/project/project-store.ts"() {
32991
33794
  "use strict";
32992
33795
  init_v1_store();
32993
33796
  }
32994
33797
  });
32995
33798
 
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";
33799
+ // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
33800
+ import { useEffect as useEffect24, useState as useState32 } from "react";
33801
+ import { Box as Box47, Text as Text50 } from "ink";
33802
+ import { jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
33001
33803
  function debugFields(config) {
33002
33804
  return {
33003
33805
  space_id: config?.spaceId ?? "",
@@ -33009,189 +33811,159 @@ function debugFields(config) {
33009
33811
  contentful_base_dir: config?.contentfulBaseDir ?? ""
33010
33812
  };
33011
33813
  }
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) => {
33814
+ function ProjectScreen({ onDone }) {
33815
+ const [config, setConfig] = useState32(null);
33816
+ const [saving, setSaving] = useState32(false);
33817
+ const [notice, setNotice] = useState32(null);
33818
+ const [lastSaved, setLastSaved] = useState32(null);
33819
+ useEffect24(() => {
33820
+ void readCredentials().then((cfg) => {
33022
33821
  setConfig(cfg);
33023
- setStage("form");
33024
33822
  startDebugRun({
33025
33823
  flow: "settings/contentful-configuration",
33026
33824
  step: "01-configuration",
33027
- menuOption: "Configuration",
33825
+ menuOption: "Configuration > Project",
33028
33826
  inputs: debugFields(cfg)
33029
33827
  });
33030
33828
  });
33031
33829
  }, []);
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);
33830
+ if (!config) {
33831
+ return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33832
+ /* @__PURE__ */ jsx59(Text50, { bold: true, children: "Project" }),
33833
+ /* @__PURE__ */ jsx59(Text50, { children: " " }),
33834
+ /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
33835
+ ] });
33040
33836
  }
33041
- function handleSave() {
33042
- if (!config) return;
33043
- setStage("saving");
33837
+ const save = () => {
33838
+ setSaving(true);
33044
33839
  setNotice(null);
33045
33840
  writeCredentials(config).then(() => {
33046
33841
  setLastSaved(config);
33047
33842
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
33048
- setNotice({ kind: "success", text: "Configuration saved" });
33049
- setStage("form");
33843
+ setNotice({ kind: "success", text: "Project settings saved" });
33050
33844
  }).catch((err) => {
33051
33845
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
33052
- setStage("form");
33053
- });
33054
- }
33055
- function quit() {
33846
+ }).finally(() => setSaving(false));
33847
+ };
33848
+ const quit = () => {
33056
33849
  void finishDebugRun(
33057
33850
  lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
33058
33851
  );
33059
33852
  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;
33853
+ };
33854
+ return /* @__PURE__ */ jsx59(
33855
+ FieldForm,
33856
+ {
33857
+ title: "Project",
33858
+ subtitle: "The Contentful space and where the CLI keeps its files.",
33859
+ fields: FIELDS2,
33860
+ values: valuesOf(config),
33861
+ onChange: (key, value) => {
33862
+ setConfig({ ...config, [key]: value });
33863
+ setNotice(null);
33864
+ },
33865
+ onSave: save,
33866
+ onQuit: quit,
33867
+ notice,
33868
+ busy: saving
33081
33869
  }
33082
- if (key.tab || key.downArrow) {
33083
- const idx = FIELD_ORDER.indexOf(activeField);
33084
- setActiveField(FIELD_ORDER[(idx + 1) % FIELD_ORDER.length]);
33870
+ );
33871
+ }
33872
+ var FIELDS2, valuesOf;
33873
+ var init_ProjectScreen = __esm({
33874
+ "packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx"() {
33875
+ "use strict";
33876
+ init_theme();
33877
+ init_debug_store();
33878
+ init_FieldForm();
33879
+ init_project_store();
33880
+ FIELDS2 = [
33881
+ { key: "spaceId", label: "Space ID" },
33882
+ { key: "environmentId", label: "Environment ID" },
33883
+ { key: "cmaToken", label: "CMA Token", masked: true },
33884
+ { key: "host", label: "API Host" },
33885
+ { key: "defaultComponentDir", label: "Default component directory" },
33886
+ { key: "defaultTokenFile", label: "Default token file" },
33887
+ { key: "contentfulBaseDir", label: "Root Project Directory", hint: "(where .contentful goes)" }
33888
+ ];
33889
+ valuesOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
33890
+ }
33891
+ });
33892
+
33893
+ // packages/experience-design-system-cli/src/tui/settings/configuration/ConfigurationScreen.tsx
33894
+ import { useState as useState33 } from "react";
33895
+ import { Box as Box48, Text as Text51, useInput as useInput13 } from "ink";
33896
+ import { jsx as jsx60, jsxs as jsxs49 } from "react/jsx-runtime";
33897
+ function ConfigurationScreen({ onDone }) {
33898
+ const [focus, setFocus] = useState33(0);
33899
+ const [open, setOpen] = useState33(null);
33900
+ const close = () => setOpen(null);
33901
+ useInput13((input, key) => {
33902
+ if (open) return;
33903
+ if (key.upArrow) {
33904
+ setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
33085
33905
  return;
33086
33906
  }
33087
- if (key.upArrow) {
33088
- const idx = FIELD_ORDER.indexOf(activeField);
33089
- setActiveField(FIELD_ORDER[(idx - 1 + FIELD_ORDER.length) % FIELD_ORDER.length]);
33907
+ if (key.downArrow || key.tab) {
33908
+ setFocus((i) => (i + 1) % SECTIONS.length);
33090
33909
  return;
33091
33910
  }
33092
33911
  if (key.return) {
33093
- setValueBeforeEdit(fieldValue(activeField));
33094
- setEditing(true);
33912
+ setOpen(SECTIONS[focus].id);
33913
+ return;
33095
33914
  }
33915
+ if (key.escape || input === "q") onDone();
33096
33916
  });
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(
33917
+ if (open === "project") return /* @__PURE__ */ jsx60(ProjectScreen, { onDone: close });
33918
+ if (open === "agents") return /* @__PURE__ */ jsx60(AgentsScreen, { onDone: close });
33919
+ return /* @__PURE__ */ jsxs49(Box48, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33920
+ /* @__PURE__ */ jsx60(Text51, { bold: true, children: "Configuration" }),
33921
+ /* @__PURE__ */ jsx60(Text51, { children: " " }),
33922
+ SECTIONS.map((section, index) => /* @__PURE__ */ jsxs49(Box48, { gap: 1, children: [
33923
+ /* @__PURE__ */ jsx60(Text51, { color: index === focus ? PALETTE.accent : void 0, children: index === focus ? "\u276F" : " " }),
33924
+ /* @__PURE__ */ jsx60(Box48, { width: 9, flexShrink: 0, children: /* @__PURE__ */ jsx60(Text51, { bold: index === focus, color: index === focus ? PALETTE.accent : void 0, children: section.label }) }),
33925
+ /* @__PURE__ */ jsx60(Text51, { color: PALETTE.muted, children: section.description })
33926
+ ] }, section.id)),
33927
+ /* @__PURE__ */ jsx60(Text51, { children: " " }),
33928
+ /* @__PURE__ */ jsx60(
33136
33929
  ControlHints,
33137
33930
  {
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
- ] : [
33931
+ hints: [
33144
33932
  { 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" }
33933
+ { keys: "\u23CE", label: "open" },
33934
+ { keys: "Esc/q", label: "back" }
33149
33935
  ]
33150
33936
  }
33151
33937
  )
33152
33938
  ] });
33153
33939
  }
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"() {
33940
+ var SECTIONS;
33941
+ var init_ConfigurationScreen = __esm({
33942
+ "packages/experience-design-system-cli/src/tui/settings/configuration/ConfigurationScreen.tsx"() {
33157
33943
  "use strict";
33158
33944
  init_theme();
33159
- init_config_store();
33160
- init_debug_store();
33161
33945
  init_control_hints();
33162
- FIELD_ORDER = [
33163
- "spaceId",
33164
- "environmentId",
33165
- "cmaToken",
33166
- "host",
33167
- "defaultComponentDir",
33168
- "defaultTokenFile",
33169
- "contentfulBaseDir"
33946
+ init_AgentsScreen();
33947
+ init_ProjectScreen();
33948
+ SECTIONS = [
33949
+ {
33950
+ id: "project",
33951
+ label: "Project",
33952
+ description: "Contentful space, credentials, defaults and where .contentful goes"
33953
+ },
33954
+ { id: "agents", label: "Agents", description: "Which coding agent the CLI uses, and each agent\u2019s settings" }
33170
33955
  ];
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
33956
  }
33185
33957
  });
33186
33958
 
33187
33959
  // 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";
33960
+ import { useEffect as useEffect25, useState as useState34 } from "react";
33961
+ import { Box as Box49, Text as Text52, useInput as useInput14 } from "ink";
33962
+ import { Fragment as Fragment19, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
33191
33963
  function OptInAnalyticsScreen({ onDone }) {
33192
- const [loading, setLoading] = useState30(true);
33193
- const [enabled, setEnabled] = useState30(true);
33194
- useEffect23(() => {
33964
+ const [loading, setLoading] = useState34(true);
33965
+ const [enabled, setEnabled] = useState34(true);
33966
+ useEffect25(() => {
33195
33967
  readAnalyticsSetting().then((setting) => {
33196
33968
  setEnabled(setting.enabled);
33197
33969
  setLoading(false);
@@ -33203,7 +33975,7 @@ function OptInAnalyticsScreen({ onDone }) {
33203
33975
  });
33204
33976
  });
33205
33977
  }, []);
33206
- useInput12((input, key) => {
33978
+ useInput14((input, key) => {
33207
33979
  if (loading) return;
33208
33980
  if (key.return || input === " ") {
33209
33981
  setEnabled((current) => {
@@ -33218,21 +33990,21 @@ function OptInAnalyticsScreen({ onDone }) {
33218
33990
  onDone();
33219
33991
  }
33220
33992
  });
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: [
33993
+ return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33994
+ /* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
33995
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
33996
+ loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment19, { children: [
33997
+ /* @__PURE__ */ jsxs50(Text52, { children: [
33226
33998
  "Share anonymous usage data:",
33227
33999
  " ",
33228
- /* @__PURE__ */ jsx56(Text47, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
34000
+ /* @__PURE__ */ jsx61(Text52, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
33229
34001
  ] }),
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." })
34002
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
34003
+ /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
34004
+ /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
33233
34005
  ] }),
33234
- /* @__PURE__ */ jsx56(Text47, { children: " " }),
33235
- /* @__PURE__ */ jsx56(
34006
+ /* @__PURE__ */ jsx61(Text52, { children: " " }),
34007
+ /* @__PURE__ */ jsx61(
33236
34008
  ControlHints,
33237
34009
  {
33238
34010
  hints: [
@@ -33253,14 +34025,95 @@ var init_screen11 = __esm({
33253
34025
  }
33254
34026
  });
33255
34027
 
34028
+ // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
34029
+ import { useEffect as useEffect26, useState as useState35 } from "react";
34030
+ import { Box as Box50, Text as Text53, useInput as useInput15 } from "ink";
34031
+ import { jsx as jsx62, jsxs as jsxs51 } from "react/jsx-runtime";
34032
+ function UpgradeScreen({ onDone }) {
34033
+ const [upgradeCheck, setUpgradeCheck] = useState35();
34034
+ useEffect26(() => {
34035
+ startDebugRun({
34036
+ flow: "upgrade",
34037
+ step: "01-upgrade",
34038
+ menuOption: "Upgrade",
34039
+ inputs: { currentVersion: readPackageVersion() }
34040
+ });
34041
+ checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
34042
+ }, []);
34043
+ useInput15((_input, key) => {
34044
+ if (key.return) {
34045
+ void finishDebugRun({
34046
+ outputs: upgradeCheck ?? {},
34047
+ status: upgradeCheck?.status === "error" ? "error" : "success",
34048
+ exitMethod: "saved"
34049
+ });
34050
+ onDone();
34051
+ return;
34052
+ }
34053
+ });
34054
+ return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
34055
+ /* @__PURE__ */ jsx62(Text53, { bold: true, children: "Upgrade" }),
34056
+ /* @__PURE__ */ jsx62(Text53, { children: " " }),
34057
+ renderBody(upgradeCheck),
34058
+ /* @__PURE__ */ jsx62(Text53, { children: " " }),
34059
+ /* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.accent, children: [
34060
+ FOCUS_MARKER,
34061
+ " Go Back"
34062
+ ] })
34063
+ ] });
34064
+ }
34065
+ function renderBody(upgradeCheck) {
34066
+ if (!upgradeCheck) {
34067
+ return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.muted, children: "Checking for updates\u2026" });
34068
+ }
34069
+ if (upgradeCheck.status === "error") {
34070
+ return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
34071
+ }
34072
+ if (upgradeCheck.status === "up-to-date") {
34073
+ return /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.success, children: [
34074
+ "You're already on the latest version (v",
34075
+ upgradeCheck.current,
34076
+ ")."
34077
+ ] });
34078
+ }
34079
+ return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", children: [
34080
+ /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.muted, children: [
34081
+ /* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.success, children: [
34082
+ "v",
34083
+ upgradeCheck.latest
34084
+ ] }),
34085
+ " ",
34086
+ "is available (you're on ",
34087
+ /* @__PURE__ */ jsxs51(Text53, { bold: true, children: [
34088
+ "v",
34089
+ upgradeCheck.current
34090
+ ] }),
34091
+ "). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
34092
+ ] }),
34093
+ /* @__PURE__ */ jsx62(Text53, { children: " " }),
34094
+ /* @__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)) })
34095
+ ] });
34096
+ }
34097
+ var UPGRADE_COMMANDS;
34098
+ var init_PageContainer4 = __esm({
34099
+ "packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx"() {
34100
+ "use strict";
34101
+ init_theme();
34102
+ init_home_theme();
34103
+ init_version();
34104
+ init_debug_store();
34105
+ UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
34106
+ }
34107
+ });
34108
+
33256
34109
  // 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";
34110
+ import { useEffect as useEffect27, useState as useState36 } from "react";
34111
+ import { Box as Box51, Text as Text54, useInput as useInput16 } from "ink";
34112
+ import { jsx as jsx63, jsxs as jsxs52 } from "react/jsx-runtime";
33260
34113
  function DebugModeScreen({ onDone }) {
33261
- const [loading, setLoading] = useState31(true);
33262
- const [enabled, setEnabled] = useState31(true);
33263
- useEffect24(() => {
34114
+ const [loading, setLoading] = useState36(true);
34115
+ const [enabled, setEnabled] = useState36(true);
34116
+ useEffect27(() => {
33264
34117
  readDebugModeSetting().then((setting) => {
33265
34118
  setEnabled(setting.enabled);
33266
34119
  setLoading(false);
@@ -33272,7 +34125,7 @@ function DebugModeScreen({ onDone }) {
33272
34125
  });
33273
34126
  });
33274
34127
  }, []);
33275
- useInput13((input, key) => {
34128
+ useInput16((input, key) => {
33276
34129
  if (loading) return;
33277
34130
  if (key.return || input === " ") {
33278
34131
  setEnabled((current) => {
@@ -33287,16 +34140,16 @@ function DebugModeScreen({ onDone }) {
33287
34140
  onDone();
33288
34141
  }
33289
34142
  });
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: [
34143
+ return /* @__PURE__ */ jsxs52(Box51, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
34144
+ /* @__PURE__ */ jsx63(Text54, { bold: true, children: "Settings \u203A Debug Mode" }),
34145
+ /* @__PURE__ */ jsx63(Text54, { children: " " }),
34146
+ loading ? /* @__PURE__ */ jsx63(Text54, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs52(Text54, { children: [
33294
34147
  "Debug logging:",
33295
34148
  " ",
33296
- /* @__PURE__ */ jsx57(Text48, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
34149
+ /* @__PURE__ */ jsx63(Text54, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
33297
34150
  ] }),
33298
- /* @__PURE__ */ jsx57(Text48, { children: " " }),
33299
- /* @__PURE__ */ jsx57(
34151
+ /* @__PURE__ */ jsx63(Text54, { children: " " }),
34152
+ /* @__PURE__ */ jsx63(
33300
34153
  ControlHints,
33301
34154
  {
33302
34155
  hints: [
@@ -33322,20 +34175,20 @@ var app_exports = {};
33322
34175
  __export(app_exports, {
33323
34176
  runApp: () => runApp
33324
34177
  });
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";
34178
+ import { join as join27 } from "node:path";
34179
+ import { useEffect as useEffect28, useState as useState37 } from "react";
34180
+ import { Fragment as Fragment20, jsx as jsx64 } from "react/jsx-runtime";
33328
34181
  function App({ importOptions, inkClear }) {
33329
- const [screen, setScreen] = useState32("start");
33330
- const [importExitCode, setImportExitCode] = useState32();
34182
+ const [screen, setScreen] = useState37("start");
34183
+ const [importExitCode, setImportExitCode] = useState37();
33331
34184
  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();
34185
+ const [projectPath, setProjectPath] = useState37();
34186
+ const [tokensPath, setTokensPath] = useState37();
34187
+ const [scannedFiles, setScannedFiles] = useState37();
34188
+ const [pendingLaunch, setPendingLaunch] = useState37();
34189
+ const [extractionRun, setExtractionRun] = useState37();
33337
34190
  const extraction = useExtraction(extractionRun?.input);
33338
- const [scopeRun, setScopeRun] = useState32();
34191
+ const [scopeRun, setScopeRun] = useState37();
33339
34192
  const scopeFlow = useScopeGateFlow(
33340
34193
  scopeRun && {
33341
34194
  sessionId: scopeRun.extraction.sessionId,
@@ -33350,12 +34203,12 @@ function App({ importOptions, inkClear }) {
33350
34203
  }
33351
34204
  }
33352
34205
  );
33353
- const [generationInput, setGenerationInput] = useState32();
34206
+ const [generationInput, setGenerationInput] = useState37();
33354
34207
  const generation = useGeneration(generationInput);
33355
- const [flowStart, setFlowStart] = useState32();
34208
+ const [flowStart, setFlowStart] = useState37();
33356
34209
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
33357
- const [importDefaults, setImportDefaults] = useState32();
33358
- useEffect25(() => {
34210
+ const [importDefaults, setImportDefaults] = useState37();
34211
+ useEffect28(() => {
33359
34212
  if (screen !== "import") {
33360
34213
  setImportDefaults(void 0);
33361
34214
  return;
@@ -33373,7 +34226,7 @@ function App({ importOptions, inkClear }) {
33373
34226
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
33374
34227
  const state2 = await inspectTokens({
33375
34228
  rawTokensPath: tokens,
33376
- contentfulDir: join26(resolveUserPath(projectPath2), ".contentful"),
34229
+ contentfulDir: join27(resolveUserPath(projectPath2), ".contentful"),
33377
34230
  cache: importOptions.cache
33378
34231
  });
33379
34232
  if (state2.kind === "cached") {
@@ -33415,12 +34268,12 @@ function App({ importOptions, inkClear }) {
33415
34268
  }
33416
34269
  });
33417
34270
  };
33418
- useEffect25(() => {
34271
+ useEffect28(() => {
33419
34272
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
33420
34273
  setExtractionRun(void 0);
33421
34274
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
33422
34275
  }, [extraction, extractionRun]);
33423
- useEffect25(() => {
34276
+ useEffect28(() => {
33424
34277
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
33425
34278
  const { extraction: produced, input, generatePromptPath } = scopeRun;
33426
34279
  setGenerationInput({
@@ -33438,7 +34291,7 @@ function App({ importOptions, inkClear }) {
33438
34291
  ...generatePromptPath ? { generatePromptPath } : {}
33439
34292
  });
33440
34293
  }, [scopeFlow, scopeRun, generationInput]);
33441
- useEffect25(() => {
34294
+ useEffect28(() => {
33442
34295
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
33443
34296
  const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
33444
34297
  inkClear();
@@ -33481,9 +34334,9 @@ function App({ importOptions, inkClear }) {
33481
34334
  };
33482
34335
  switch (screen) {
33483
34336
  case "import":
33484
- if (showImportResult) return /* @__PURE__ */ jsx58(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
34337
+ if (showImportResult) return /* @__PURE__ */ jsx64(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
33485
34338
  if (flow && flowStart) {
33486
- return /* @__PURE__ */ jsx58(
34339
+ return /* @__PURE__ */ jsx64(
33487
34340
  FlowScreen,
33488
34341
  {
33489
34342
  state: flow.state,
@@ -33493,12 +34346,12 @@ function App({ importOptions, inkClear }) {
33493
34346
  }
33494
34347
  );
33495
34348
  }
33496
- if (importDefaults === void 0) return /* @__PURE__ */ jsx58(Fragment19, {});
34349
+ if (importDefaults === void 0) return /* @__PURE__ */ jsx64(Fragment20, {});
33497
34350
  if (projectPath === void 0) {
33498
- return /* @__PURE__ */ jsx58(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
34351
+ return /* @__PURE__ */ jsx64(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
33499
34352
  }
33500
34353
  if (tokensPath === void 0) {
33501
- return /* @__PURE__ */ jsx58(
34354
+ return /* @__PURE__ */ jsx64(
33502
34355
  TokenInputScreen,
33503
34356
  {
33504
34357
  initialPath: importDefaults.tokenFile,
@@ -33508,7 +34361,7 @@ function App({ importOptions, inkClear }) {
33508
34361
  );
33509
34362
  }
33510
34363
  if (scannedFiles === void 0) {
33511
- return /* @__PURE__ */ jsx58(
34364
+ return /* @__PURE__ */ jsx64(
33512
34365
  PathValidationScreen,
33513
34366
  {
33514
34367
  projectPath,
@@ -33520,10 +34373,10 @@ function App({ importOptions, inkClear }) {
33520
34373
  }
33521
34374
  if (extractionRun) {
33522
34375
  if (extraction?.status === "done" && !extraction.result.ok) {
33523
- return /* @__PURE__ */ jsx58(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
34376
+ return /* @__PURE__ */ jsx64(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
33524
34377
  }
33525
34378
  if (extraction?.status === "running") {
33526
- return /* @__PURE__ */ jsx58(
34379
+ return /* @__PURE__ */ jsx64(
33527
34380
  ExtractionScreen,
33528
34381
  {
33529
34382
  progress: extraction.progress,
@@ -33532,14 +34385,14 @@ function App({ importOptions, inkClear }) {
33532
34385
  }
33533
34386
  );
33534
34387
  }
33535
- return /* @__PURE__ */ jsx58(Fragment19, {});
34388
+ return /* @__PURE__ */ jsx64(Fragment20, {});
33536
34389
  }
33537
34390
  if (scopeRun && scopeFlow) {
33538
34391
  if (scopeFlow.status === "failed") {
33539
- return /* @__PURE__ */ jsx58(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
34392
+ return /* @__PURE__ */ jsx64(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
33540
34393
  }
33541
34394
  if (scopeFlow.status === "deciding") {
33542
- return /* @__PURE__ */ jsx58(
34395
+ return /* @__PURE__ */ jsx64(
33543
34396
  ScopeGateScreen,
33544
34397
  {
33545
34398
  components: scopeFlow.load.components,
@@ -33549,7 +34402,7 @@ function App({ importOptions, inkClear }) {
33549
34402
  );
33550
34403
  }
33551
34404
  if (generation?.status === "done" && !generation.result.ok) {
33552
- return /* @__PURE__ */ jsx58(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
34405
+ return /* @__PURE__ */ jsx64(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
33553
34406
  }
33554
34407
  if (generation?.status === "running") {
33555
34408
  const hasRawTokens = scopeRun.input.rawTokensPath !== "";
@@ -33557,7 +34410,7 @@ function App({ importOptions, inkClear }) {
33557
34410
  hasRawTokens,
33558
34411
  mapTokensEligible: generation.progress.mapTokensEligible
33559
34412
  });
33560
- return /* @__PURE__ */ jsx58(
34413
+ return /* @__PURE__ */ jsx64(
33561
34414
  GenerationScreen,
33562
34415
  {
33563
34416
  progress: generation.progress,
@@ -33569,10 +34422,10 @@ function App({ importOptions, inkClear }) {
33569
34422
  }
33570
34423
  );
33571
34424
  }
33572
- return /* @__PURE__ */ jsx58(Fragment19, {});
34425
+ return /* @__PURE__ */ jsx64(Fragment20, {});
33573
34426
  }
33574
34427
  if (pendingLaunch?.cached) {
33575
- return /* @__PURE__ */ jsx58(
34428
+ return /* @__PURE__ */ jsx64(
33576
34429
  TokenReuseScreen,
33577
34430
  {
33578
34431
  tokensPath: pendingLaunch.cached.tokensPath,
@@ -33583,7 +34436,7 @@ function App({ importOptions, inkClear }) {
33583
34436
  }
33584
34437
  );
33585
34438
  }
33586
- return /* @__PURE__ */ jsx58(
34439
+ return /* @__PURE__ */ jsx64(
33587
34440
  CredentialsScreen,
33588
34441
  {
33589
34442
  initial: importDefaults.credentials,
@@ -33592,17 +34445,19 @@ function App({ importOptions, inkClear }) {
33592
34445
  }
33593
34446
  );
33594
34447
  case "help":
33595
- return /* @__PURE__ */ jsx58(HelpScreen, { onDone: goToStart });
34448
+ return /* @__PURE__ */ jsx64(HelpScreen, { onDone: goToStart });
34449
+ case "upgrade":
34450
+ return /* @__PURE__ */ jsx64(UpgradeScreen, { onDone: goToStart });
33596
34451
  case "settings":
33597
- return /* @__PURE__ */ jsx58(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
34452
+ return /* @__PURE__ */ jsx64(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
33598
34453
  case "settings-configuration":
33599
- return /* @__PURE__ */ jsx58(ConfigurationScreen, { onDone: goToSettings });
34454
+ return /* @__PURE__ */ jsx64(ConfigurationScreen, { onDone: goToSettings });
33600
34455
  case "settings-opt-in-analytics":
33601
- return /* @__PURE__ */ jsx58(OptInAnalyticsScreen, { onDone: goToSettings });
34456
+ return /* @__PURE__ */ jsx64(OptInAnalyticsScreen, { onDone: goToSettings });
33602
34457
  case "settings-debug-mode":
33603
- return /* @__PURE__ */ jsx58(DebugModeScreen, { onDone: goToSettings });
34458
+ return /* @__PURE__ */ jsx64(DebugModeScreen, { onDone: goToSettings });
33604
34459
  case "start":
33605
- return /* @__PURE__ */ jsx58(HomeScreen, { onNavigate: setScreen });
34460
+ return /* @__PURE__ */ jsx64(HomeScreen, { onNavigate: setScreen });
33606
34461
  }
33607
34462
  }
33608
34463
  async function runApp(renderApp, importOptions) {
@@ -33610,7 +34465,7 @@ async function runApp(renderApp, importOptions) {
33610
34465
  instance.clear?.();
33611
34466
  process.stdout.write("\x1B[H\x1B[0J");
33612
34467
  };
33613
- const instance = renderApp(/* @__PURE__ */ jsx58(App, { importOptions, inkClear }));
34468
+ const instance = renderApp(/* @__PURE__ */ jsx64(App, { importOptions, inkClear }));
33614
34469
  await instance.waitUntilExit();
33615
34470
  }
33616
34471
  var init_app = __esm({
@@ -33634,17 +34489,18 @@ var init_app = __esm({
33634
34489
  init_use_flow();
33635
34490
  init_PageContainer2();
33636
34491
  init_PageContainer3();
33637
- init_ContentfulConfigScreen();
34492
+ init_ConfigurationScreen();
33638
34493
  init_screen11();
34494
+ init_PageContainer4();
33639
34495
  init_screen12();
33640
- init_config_store();
34496
+ init_project_store();
33641
34497
  }
33642
34498
  });
33643
34499
 
33644
34500
  // packages/experience-design-system-cli/program.ts
33645
34501
  init_src4();
33646
34502
  import { readFileSync as readFileSync9 } from "node:fs";
33647
- import { join as join27 } from "node:path";
34503
+ import { join as join28 } from "node:path";
33648
34504
  import { Command } from "commander";
33649
34505
 
33650
34506
  // packages/experience-design-system-cli/src/commands/import-options.ts
@@ -33672,14 +34528,14 @@ function runDevWatch(args) {
33672
34528
  process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
33673
34529
  return Promise.resolve(1);
33674
34530
  }
33675
- return new Promise((resolve27) => {
34531
+ return new Promise((resolve28) => {
33676
34532
  const child = spawn3(process.execPath, [script, ...args], { stdio: "inherit" });
33677
34533
  process.on("SIGINT", () => void 0);
33678
- child.on("exit", (code) => resolve27(code ?? 0));
34534
+ child.on("exit", (code) => resolve28(code ?? 0));
33679
34535
  child.on("error", (err) => {
33680
34536
  process.stderr.write(`${err.message}
33681
34537
  `);
33682
- resolve27(1);
34538
+ resolve28(1);
33683
34539
  });
33684
34540
  });
33685
34541
  }
@@ -33704,11 +34560,13 @@ function registerImportCommand(program, openTui) {
33704
34560
  }
33705
34561
 
33706
34562
  // packages/experience-design-system-cli/program.ts
34563
+ init_agent_store();
34564
+ init_apply_binary_overrides();
33707
34565
  init_analytics_store();
33708
34566
  init_package_root();
33709
34567
  var pkg = JSON.parse(
33710
34568
  readFileSync9(
33711
- join27(findPackageRoot(import.meta.url, "@contentful/experience-design-system-cli"), "package.json"),
34569
+ join28(findPackageRoot(import.meta.url, "@contentful/experience-design-system-cli"), "package.json"),
33712
34570
  "utf8"
33713
34571
  )
33714
34572
  );
@@ -33725,6 +34583,7 @@ function createProgram() {
33725
34583
  const commandChain = chain.join(" ") || actionCommand.name();
33726
34584
  const { enabled } = await readAnalyticsSetting();
33727
34585
  setPersistedAnalyticsDisabled(!enabled);
34586
+ await readAgentConfig().then(applyBinaryOverrides, () => void 0);
33728
34587
  setCliVersion(pkg.version);
33729
34588
  noteCommandStart(commandChain);
33730
34589
  });
@@ -33748,7 +34607,7 @@ init_config();
33748
34607
  init_package_root();
33749
34608
  import { existsSync as existsSync11 } from "node:fs";
33750
34609
  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";
34610
+ import { dirname as dirname16, join as join29 } from "node:path";
33752
34611
  var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
33753
34612
  async function readJson(path5) {
33754
34613
  try {
@@ -33759,9 +34618,9 @@ async function readJson(path5) {
33759
34618
  }
33760
34619
  async function migrateOldConfig() {
33761
34620
  try {
33762
- const oldCredentials = join28(oldConfigDir2(), "credentials.json");
33763
- const oldRuns = join28(oldConfigDir2(), "runs.json");
33764
- const oldDebugMode = join28(
34621
+ const oldCredentials = join29(oldConfigDir2(), "credentials.json");
34622
+ const oldRuns = join29(oldConfigDir2(), "runs.json");
34623
+ const oldDebugMode = join29(
33765
34624
  findPackageRoot(import.meta.url, PACKAGE_NAME3),
33766
34625
  ".contentful",
33767
34626
  "config",