@contentful/experience-design-system-cli 2.37.1-dev-build-9d1e87d0.0 → 2.37.1-dev-build-a67bc4a4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -32,7 +32,7 @@ var init_package_root = __esm({
32
32
  }
33
33
  });
34
34
 
35
- // packages/experience-design-system-cli/src/tui/upgrade/version.ts
35
+ // packages/experience-design-system-cli/src/tui/home/version.ts
36
36
  import { readFileSync as readFileSync2 } from "node:fs";
37
37
  import { join as join2 } from "node:path";
38
38
  import semver from "semver";
@@ -65,7 +65,7 @@ async function checkForUpgrade() {
65
65
  }
66
66
  var PACKAGE_NAME, TAGS_URL;
67
67
  var init_version = __esm({
68
- "packages/experience-design-system-cli/src/tui/upgrade/version.ts"() {
68
+ "packages/experience-design-system-cli/src/tui/home/version.ts"() {
69
69
  "use strict";
70
70
  init_package_root();
71
71
  PACKAGE_NAME = "@contentful/experience-design-system-cli";
@@ -837,7 +837,7 @@ async function runAgent(options) {
837
837
  promptLen: prompt.length,
838
838
  promptHead: prompt.slice(0, 500)
839
839
  });
840
- return new Promise((resolve28) => {
840
+ return new Promise((resolve27) => {
841
841
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
842
842
  const child = spawn(binary, args, {
843
843
  stdio: ["pipe", "pipe", "pipe"],
@@ -886,7 +886,7 @@ async function runAgent(options) {
886
886
  stderrLen: stderr.length,
887
887
  stderrTail: stderr.slice(-1e3)
888
888
  });
889
- resolve28(result);
889
+ resolve27(result);
890
890
  });
891
891
  });
892
892
  }
@@ -908,7 +908,7 @@ async function checkAgentAuth(agent) {
908
908
  return "not-found";
909
909
  if (agent !== "claude")
910
910
  return "ok";
911
- return new Promise((resolve28) => {
911
+ return new Promise((resolve27) => {
912
912
  const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
913
913
  let stdout = "";
914
914
  let done = false;
@@ -917,7 +917,7 @@ async function checkAgentAuth(agent) {
917
917
  return;
918
918
  done = true;
919
919
  child.kill("SIGTERM");
920
- resolve28("unauthenticated");
920
+ resolve27("unauthenticated");
921
921
  }, 5e3);
922
922
  child.stdout?.on("data", (chunk) => {
923
923
  stdout += chunk.toString();
@@ -928,14 +928,14 @@ async function checkAgentAuth(agent) {
928
928
  done = true;
929
929
  clearTimeout(timer);
930
930
  if (code !== 0) {
931
- resolve28("unauthenticated");
931
+ resolve27("unauthenticated");
932
932
  return;
933
933
  }
934
934
  try {
935
935
  const status = JSON.parse(stdout);
936
- resolve28(status.loggedIn ? "ok" : "unauthenticated");
936
+ resolve27(status.loggedIn ? "ok" : "unauthenticated");
937
937
  } catch {
938
- resolve28("unauthenticated");
938
+ resolve27("unauthenticated");
939
939
  }
940
940
  });
941
941
  });
@@ -945,9 +945,9 @@ async function binaryIsOnPath(binary) {
945
945
  const fs = await import("node:fs/promises");
946
946
  return fs.access(binary).then(() => true, () => false);
947
947
  }
948
- return new Promise((resolve28) => {
948
+ return new Promise((resolve27) => {
949
949
  const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
950
- child.on("close", (code) => resolve28(code === 0));
950
+ child.on("close", (code) => resolve27(code === 0));
951
951
  });
952
952
  }
953
953
  var init_check_agent_auth = __esm({
@@ -2329,8 +2329,8 @@ var init_debug_store = __esm({
2329
2329
  });
2330
2330
 
2331
2331
  // packages/experience-design-system-cli/app.tsx
2332
- import { join as join26 } from "node:path";
2333
- import { useEffect as useEffect28, useState as useState37 } from "react";
2332
+ import { join as join25 } from "node:path";
2333
+ import { useEffect as useEffect25, useState as useState32 } from "react";
2334
2334
 
2335
2335
  // packages/experience-design-system-cli/src/tui/home/home.tsx
2336
2336
  import { useEffect as useEffect2, useState as useState2 } from "react";
@@ -2431,18 +2431,14 @@ var SUBTITLE = "Let's import your design system into Contentful";
2431
2431
  var MIN_TERMINAL_WIDTH = 164;
2432
2432
  var START_ITEMS = [
2433
2433
  { label: "Import", screen: "import" },
2434
- { label: "Upgrade Version", screen: "upgrade" },
2435
2434
  { label: "Settings", screen: "settings" },
2436
2435
  { label: "Help", screen: "help" }
2437
2436
  ];
2438
- function upgradeItemDisplay(upgradeCheck) {
2437
+ function versionStatus(upgradeCheck) {
2439
2438
  if (upgradeCheck?.status === "update-available") {
2440
- return { label: `Upgrade Version (v${upgradeCheck.latest} available)`, color: PALETTE.warning };
2439
+ return { text: ` (upgrade available v${upgradeCheck.latest})`, color: PALETTE.success };
2441
2440
  }
2442
- if (upgradeCheck?.status === "up-to-date") {
2443
- return { label: "Upgrade Version (up to date)", color: PALETTE.muted };
2444
- }
2445
- return { label: "Upgrade Version" };
2441
+ return void 0;
2446
2442
  }
2447
2443
  function HomeScreen({ onNavigate }) {
2448
2444
  const [focusIdx, setFocusIdx] = useState2(0);
@@ -2450,7 +2446,7 @@ function HomeScreen({ onNavigate }) {
2450
2446
  const { exit } = useApp();
2451
2447
  const terminalWidth = useTerminalWidth();
2452
2448
  const tooNarrow = terminalWidth < MIN_TERMINAL_WIDTH;
2453
- const upgradeDisabled = upgradeCheck?.status === "up-to-date";
2449
+ const status = versionStatus(upgradeCheck);
2454
2450
  useEffect2(() => {
2455
2451
  checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
2456
2452
  }, []);
@@ -2470,7 +2466,6 @@ function HomeScreen({ onNavigate }) {
2470
2466
  }
2471
2467
  if (key.return) {
2472
2468
  const item = START_ITEMS[focusIdx];
2473
- if (item.screen === "upgrade" && upgradeDisabled) return;
2474
2469
  onNavigate(item.screen);
2475
2470
  return;
2476
2471
  }
@@ -2488,26 +2483,16 @@ function HomeScreen({ onNavigate }) {
2488
2483
  /* @__PURE__ */ jsx2(Text2, { color: PALETTE.muted, children: SUBTITLE }),
2489
2484
  /* @__PURE__ */ jsxs(Text2, { color: PALETTE.muted, children: [
2490
2485
  "v",
2491
- VERSION
2486
+ VERSION,
2487
+ status && /* @__PURE__ */ jsx2(Text2, { color: status.color, children: status.text })
2492
2488
  ] })
2493
2489
  ] }),
2494
2490
  /* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(Box, { flexDirection: "column", children: START_ITEMS.map((item, i) => {
2495
2491
  const focused = i === focusIdx;
2496
- const isUpgradeItem = item.screen === "upgrade";
2497
- const display = isUpgradeItem ? upgradeItemDisplay(upgradeCheck) : { label: item.label };
2498
- const dimmed = isUpgradeItem && upgradeDisabled;
2499
- return /* @__PURE__ */ jsxs(
2500
- Text2,
2501
- {
2502
- bold: focused && !dimmed,
2503
- color: dimmed ? PALETTE.muted : focused ? PALETTE.accent : display.color,
2504
- children: [
2505
- focused ? `${FOCUS_MARKER} ` : " ",
2506
- display.label
2507
- ]
2508
- },
2492
+ return /* @__PURE__ */ jsxs(Text2, { bold: focused, color: focused ? PALETTE.accent : void 0, children: [
2493
+ focused ? `${FOCUS_MARKER} ` : " ",
2509
2494
  item.label
2510
- );
2495
+ ] }, item.label);
2511
2496
  }) }) }),
2512
2497
  /* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(
2513
2498
  ControlHints,
@@ -8453,10 +8438,10 @@ function extractVueSlotsFromSetup(options) {
8453
8438
  if (!body)
8454
8439
  return [];
8455
8440
  const slotsByName = /* @__PURE__ */ new Map();
8456
- for (const access7 of body.getDescendantsOfKind(SyntaxKind5.PropertyAccessExpression)) {
8457
- if (access7.getExpression().getText() !== slotsName)
8441
+ for (const access6 of body.getDescendantsOfKind(SyntaxKind5.PropertyAccessExpression)) {
8442
+ if (access6.getExpression().getText() !== slotsName)
8458
8443
  continue;
8459
- const slotName = access7.getName();
8444
+ const slotName = access6.getName();
8460
8445
  if (!slotsByName.has(slotName)) {
8461
8446
  slotsByName.set(slotName, {
8462
8447
  name: slotName,
@@ -13846,7 +13831,7 @@ function errorMessage(error) {
13846
13831
  return error instanceof Error && error.message ? error.message : String(error);
13847
13832
  }
13848
13833
  function defaultSleep(delayMs) {
13849
- return new Promise((resolve28) => setTimeout(resolve28, delayMs));
13834
+ return new Promise((resolve27) => setTimeout(resolve27, delayMs));
13850
13835
  }
13851
13836
 
13852
13837
  // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
@@ -14087,7 +14072,7 @@ var ApiClient = class {
14087
14072
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
14088
14073
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
14089
14074
  const jitter = Math.random() * baseDelay * 0.15;
14090
- await new Promise((resolve28) => setTimeout(resolve28, baseDelay + jitter));
14075
+ await new Promise((resolve27) => setTimeout(resolve27, baseDelay + jitter));
14091
14076
  }
14092
14077
  }
14093
14078
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -14572,7 +14557,6 @@ function readTokensFromPath2(request) {
14572
14557
  init_agents();
14573
14558
  init_agent_name();
14574
14559
  init_models();
14575
- init_binaries();
14576
14560
  init_is_agent_name();
14577
14561
  init_agent_supports_bedrock();
14578
14562
  init_check_agent_auth();
@@ -15131,11 +15115,11 @@ function setCommandContext(context) {
15131
15115
  mergeContext(state.pending.context, context);
15132
15116
  mergeContext(state.pending.completion, context);
15133
15117
  }
15134
- function enrichCommandResult(fields2) {
15118
+ function enrichCommandResult(fields) {
15135
15119
  if (!state.pending)
15136
15120
  return;
15137
- Object.assign(state.pending.completion, fields2);
15138
- mergeContext(state.pending.context, fields2);
15121
+ Object.assign(state.pending.completion, fields);
15122
+ mergeContext(state.pending.context, fields);
15139
15123
  }
15140
15124
 
15141
15125
  // packages/experience-design-system-backend-pipeline/dist/src/analytics/os.js
@@ -16397,7 +16381,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
16397
16381
  const message = error instanceof Error ? error.message : String(error);
16398
16382
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
16399
16383
  throw error;
16400
- await new Promise((resolve28) => setTimeout(resolve28, Math.min(250 * attempt, 2e3)));
16384
+ await new Promise((resolve27) => setTimeout(resolve27, Math.min(250 * attempt, 2e3)));
16401
16385
  }
16402
16386
  }
16403
16387
  }
@@ -22344,16 +22328,16 @@ function SlotRow({
22344
22328
  ] });
22345
22329
  }
22346
22330
  function propFields(prop) {
22347
- const fields2 = ["description", "required", "type"];
22331
+ const fields = ["description", "required", "type"];
22348
22332
  if (prop.type === "token") {
22349
- fields2.push("tokenKind");
22333
+ fields.push("tokenKind");
22350
22334
  }
22351
- if (prop.type === "enum") fields2.push("values");
22335
+ if (prop.type === "enum") fields.push("values");
22352
22336
  if (prop.type !== "richtext" && prop.type !== "media" && prop.type !== "link") {
22353
- fields2.push("default");
22337
+ fields.push("default");
22354
22338
  }
22355
- if (prop.type === "token" && prop.category === "design") fields2.push("allowed");
22356
- return fields2;
22339
+ if (prop.type === "token" && prop.category === "design") fields.push("allowed");
22340
+ return fields;
22357
22341
  }
22358
22342
  var SLOT_FIELDS = ["description", "required", "allowedComponents"];
22359
22343
  function simulateGraphWithCandidate(projectSlotGraph, selfName, currentSlots, targetSlotName, candidate) {
@@ -22892,8 +22876,8 @@ function FieldEditor({
22892
22876
  return;
22893
22877
  }
22894
22878
  if (focusLevel === "field") {
22895
- const fields2 = inSlots ? SLOT_FIELDS : currentProp ? propFields(currentProp) : [];
22896
- const currentFieldIdx = fields2.indexOf(activeField);
22879
+ const fields = inSlots ? SLOT_FIELDS : currentProp ? propFields(currentProp) : [];
22880
+ const currentFieldIdx = fields.indexOf(activeField);
22897
22881
  const isValuesNav = activeField === "values" || activeField === "allowedComponents";
22898
22882
  const arrowUp = key.upArrow;
22899
22883
  const arrowDown = key.downArrow;
@@ -22907,10 +22891,10 @@ function FieldEditor({
22907
22891
  const navPrevious = arrowUp || arrowLeft;
22908
22892
  const navNext = arrowDown || arrowRight || input === "j";
22909
22893
  const navBack = navPrevious || input === "k";
22910
- if ((navBack || navNext) && fields2.length > 0) {
22911
- const lastIdx = fields2.length - 1;
22894
+ if ((navBack || navNext) && fields.length > 0) {
22895
+ const lastIdx = fields.length - 1;
22912
22896
  const targetIdx = navNext ? currentFieldIdx >= lastIdx ? 0 : currentFieldIdx + 1 : currentFieldIdx <= 0 ? lastIdx : currentFieldIdx - 1;
22913
- const next = fields2[targetIdx];
22897
+ const next = fields[targetIdx];
22914
22898
  setActiveField(next);
22915
22899
  if (next === "description") {
22916
22900
  const desc = inSlots ? currentSlot?.description ?? "" : currentProp?.description ?? "";
@@ -28031,7 +28015,7 @@ var realSaveDeps = () => ({
28031
28015
  writeFile: (path5, contents) => writeFile7(path5, contents),
28032
28016
  appendRun,
28033
28017
  buildSourceFingerprint,
28034
- sleep: (ms) => new Promise((resolve28) => setTimeout(resolve28, ms)),
28018
+ sleep: (ms) => new Promise((resolve27) => setTimeout(resolve27, ms)),
28035
28019
  warn: (message) => process.stderr.write(message)
28036
28020
  });
28037
28021
  async function runPrintFiles(input, deps, onPatch) {
@@ -28421,44 +28405,12 @@ init_config();
28421
28405
  init_debug_store();
28422
28406
  init_debug_mode_store();
28423
28407
  init_version();
28424
-
28425
- // packages/experience-design-system-cli/src/tui/help/file-locations.ts
28426
- import { join as join25, resolve as resolve27 } from "node:path";
28427
- function describeFileLocations({
28428
- contentfulBaseDir,
28429
- debugModeEnabled,
28430
- currentSessionDir: currentSessionDir2
28431
- }) {
28432
- if (!debugModeEnabled) {
28433
- return {
28434
- debugLogs: "none while Debug Mode is off",
28435
- importFiles: `${join25("<project>", ".contentful")}/ (tokens.json, components.json)`
28436
- };
28437
- }
28438
- const base = contentfulBaseDir ? resolve27(contentfulBaseDir) : "<project>";
28439
- const session = currentSessionDir2 ?? join25(base, ".contentful", "<date>-session-<n>");
28440
- return {
28441
- debugLogs: join25(session, "debug"),
28442
- importFiles: `${join25(session, "dsi-import-<n>")}/ (tokens.json, components.json)`
28443
- };
28444
- }
28445
-
28446
- // packages/experience-design-system-cli/src/tui/help/help-info.ts
28447
28408
  async function readHelpInfo() {
28448
- const [debugMode, settings] = await Promise.all([readDebugModeSetting(), readSettings2()]);
28449
- const base = settings["contentfulBaseDir"];
28450
- const locations = describeFileLocations({
28451
- contentfulBaseDir: typeof base === "string" ? base : "",
28452
- debugModeEnabled: debugMode.enabled,
28453
- currentSessionDir: currentSessionDir()
28454
- });
28409
+ const debugMode = await readDebugModeSetting();
28455
28410
  return {
28456
28411
  storage: [
28457
28412
  { label: "Config folder", value: configRoot2() },
28458
- { label: "Settings file", value: configFilePath2() },
28459
- { label: "Agent settings", value: `${configFilePath2()} (keys: agent, agentModel, agents)` },
28460
- { label: "Debug logs", value: locations.debugLogs },
28461
- { label: "Import files", value: locations.importFiles }
28413
+ { label: "Settings file", value: configFilePath2() }
28462
28414
  ],
28463
28415
  troubleshooting: [
28464
28416
  { label: "CLI version", value: readPackageVersion() },
@@ -28479,7 +28431,7 @@ function Section({ title, rows }) {
28479
28431
  return /* @__PURE__ */ jsxs43(Box42, { flexDirection: "column", children: [
28480
28432
  /* @__PURE__ */ jsx53(Text44, { bold: true, color: PALETTE.accent, children: title }),
28481
28433
  rows.map((row) => /* @__PURE__ */ jsxs43(Box42, { gap: 1, children: [
28482
- /* @__PURE__ */ jsx53(Box42, { width: 16, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
28434
+ /* @__PURE__ */ jsx53(Box42, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx53(Text44, { color: PALETTE.muted, children: row.label }) }),
28483
28435
  /* @__PURE__ */ jsx53(Text44, { children: row.value })
28484
28436
  ] }, row.label))
28485
28437
  ] });
@@ -28579,694 +28531,15 @@ function SettingsScreen({
28579
28531
  }
28580
28532
 
28581
28533
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28582
- import { useState as useState33 } from "react";
28583
- import { Box as Box48, Text as Text51, useInput as useInput13 } from "ink";
28584
-
28585
- // packages/experience-design-system-cli/src/tui/settings/agents/AgentsScreen.tsx
28586
- import { useEffect as useEffect23, useState as useState31 } from "react";
28587
- import { Box as Box46, Text as Text49, useInput as useInput12 } from "ink";
28588
- init_debug_store();
28534
+ import { useEffect as useEffect22, useState as useState29 } from "react";
28535
+ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
28536
+ import TextInput4 from "ink-text-input";
28589
28537
 
28590
28538
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
28591
28539
  init_config();
28592
28540
  var readV1Store = readSettings2;
28593
28541
  var writeV1Store = writeSettings2;
28594
28542
 
28595
- // packages/experience-design-system-cli/src/tui/settings/agents/agent-store.ts
28596
- var DEFAULT_AGENT3 = "claude";
28597
- var AGENT_LABELS = {
28598
- claude: "Claude Code",
28599
- codex: "OpenAI Codex",
28600
- opencode: "OpenCode",
28601
- cursor: "Cursor",
28602
- copilot: "GitHub Copilot"
28603
- };
28604
- var asString = (value) => typeof value === "string" ? value : "";
28605
- function emptyAgents() {
28606
- return Object.fromEntries(AGENT_NAMES.map((name) => [name, { model: "", binary: "" }]));
28607
- }
28608
- async function readAgentConfig() {
28609
- const store = await readV1Store();
28610
- const stored = asString(store["agent"]);
28611
- const defaultAgent = isAgentName(stored) ? stored : DEFAULT_AGENT3;
28612
- const agents = emptyAgents();
28613
- const saved = store["agents"];
28614
- if (saved && typeof saved === "object") {
28615
- for (const name of AGENT_NAMES) {
28616
- const entry = saved[name];
28617
- if (entry && typeof entry === "object") {
28618
- const fields2 = entry;
28619
- agents[name] = { model: asString(fields2["model"]), binary: asString(fields2["binary"]) };
28620
- }
28621
- }
28622
- }
28623
- const legacyModel = asString(store["agentModel"]);
28624
- if (legacyModel && !agents[defaultAgent].model)
28625
- agents[defaultAgent] = { ...agents[defaultAgent], model: legacyModel };
28626
- return { defaultAgent, agents };
28627
- }
28628
- async function writeAgentConfig(config) {
28629
- const existing = await readV1Store();
28630
- const merged = { ...existing };
28631
- const agents = {};
28632
- for (const name of AGENT_NAMES) {
28633
- const model = config.agents[name].model.trim();
28634
- const binary = config.agents[name].binary.trim();
28635
- if (model || binary) agents[name] = { ...model ? { model } : {}, ...binary ? { binary } : {} };
28636
- }
28637
- merged["agent"] = config.defaultAgent;
28638
- const defaultModel = agents[config.defaultAgent]?.model;
28639
- if (defaultModel) merged["agentModel"] = defaultModel;
28640
- else delete merged["agentModel"];
28641
- if (Object.keys(agents).length > 0) merged["agents"] = agents;
28642
- else delete merged["agents"];
28643
- await writeV1Store(merged);
28644
- }
28645
-
28646
- // packages/experience-design-system-cli/src/tui/settings/agents/agent-status.ts
28647
- import { execFile as execFile2 } from "node:child_process";
28648
- import { access as access6, constants } from "node:fs/promises";
28649
- var VERSION_TIMEOUT_MS = 5e3;
28650
- var PROMPT_TIMEOUT_MS = 6e4;
28651
- var TEST_PROMPT = "Reply with the single word: ok";
28652
- var INSTALL_HINTS = {
28653
- claude: "npm install -g @anthropic-ai/claude-code",
28654
- codex: "npm install -g @openai/codex",
28655
- opencode: "npm install -g opencode-ai",
28656
- cursor: "install Cursor\u2019s `cursor-agent` command",
28657
- copilot: "npm install -g @github/copilot"
28658
- };
28659
- var LOGIN_HINTS = {
28660
- claude: "run `claude login`",
28661
- codex: "set OPENAI_API_KEY, or sign in with a ChatGPT account",
28662
- opencode: "run `opencode auth`",
28663
- cursor: "sign in from Cursor",
28664
- copilot: "run `copilot` and sign in"
28665
- };
28666
- function effectiveBinary(name, savedBinary) {
28667
- return savedBinary.trim() || AGENT_BINARIES[name];
28668
- }
28669
- function defaultModelLabel(name) {
28670
- const model = DEFAULT_MODELS[name];
28671
- return model && model !== "Auto" ? model : "chosen by the agent";
28672
- }
28673
- var fail3 = (step, detail) => ({ step, ok: false, detail });
28674
- var pass = (step, detail) => ({ step, ok: true, detail });
28675
- function resolveOnPath(binary) {
28676
- if (binary.includes("/")) {
28677
- return access6(binary, constants.X_OK).then(
28678
- () => binary,
28679
- () => null
28680
- );
28681
- }
28682
- return new Promise((resolve28) => {
28683
- execFile2(
28684
- process.platform === "win32" ? "where" : "which",
28685
- [binary],
28686
- (error, stdout) => resolve28(error ? null : stdout.split("\n")[0]?.trim() ?? null)
28687
- );
28688
- });
28689
- }
28690
- function readVersion(binary) {
28691
- return new Promise((resolve28) => {
28692
- execFile2(binary, ["--version"], { timeout: VERSION_TIMEOUT_MS }, (error, stdout) => {
28693
- const line = stdout.split("\n")[0]?.trim() ?? "";
28694
- if (!error && line) resolve28(pass("version", line));
28695
- else resolve28(fail3("version", "runs, but did not report a version"));
28696
- });
28697
- });
28698
- }
28699
- async function inspect(name, binary) {
28700
- const target = effectiveBinary(name, binary);
28701
- const found = await resolveOnPath(target);
28702
- if (!found) return { checks: [fail3("path", `\`${target}\` was not found or is not executable`)], found: null };
28703
- const checks = [pass("path", found)];
28704
- checks.push(await readVersion(found));
28705
- if (name === "claude") {
28706
- const auth = await withBinaryEnv(name, found, () => checkAgentAuth(name));
28707
- checks.push(
28708
- auth === "ok" ? pass("login", "logged in") : fail3("login", auth === "not-found" ? "binary not found" : `not logged in: ${LOGIN_HINTS.claude}`)
28709
- );
28710
- }
28711
- return { checks, found };
28712
- }
28713
- async function inspectAgent(name, binary) {
28714
- return (await inspect(name, binary)).checks;
28715
- }
28716
- async function testAgent(name, binary, model) {
28717
- const { checks, found } = await inspect(name, binary);
28718
- if (!found || !checks.every((check) => check.step === "version" || check.ok)) return checks;
28719
- const started = Date.now();
28720
- const result = await withBinaryEnv(
28721
- name,
28722
- found,
28723
- () => createLocalCliAgentInvoker().invoke({
28724
- agent: name,
28725
- ...model.trim() ? { model: model.trim() } : {},
28726
- prompt: TEST_PROMPT,
28727
- timeoutMs: PROMPT_TIMEOUT_MS
28728
- })
28729
- );
28730
- const seconds = ((Date.now() - started) / 1e3).toFixed(1);
28731
- if (result.timedOut) {
28732
- return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
28733
- }
28734
- if (result.exitCode !== 0) {
28735
- const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
28736
- return [...checks, fail3("prompt", reason)];
28737
- }
28738
- return [...checks, pass("prompt", `answered in ${seconds}s`)];
28739
- }
28740
- function statusFromChecks(name, checks, savedBinary) {
28741
- if (checks.length === 0) return "checking";
28742
- if (checks.some((check) => check.step === "path" && !check.ok)) {
28743
- return savedBinary.trim() ? "not-found" : "not-configured";
28744
- }
28745
- const prompt = checks.find((check) => check.step === "prompt");
28746
- if (prompt) {
28747
- if (prompt.ok) return "ready";
28748
- return prompt.timedOut ? "timed-out" : "test-failed";
28749
- }
28750
- const login = checks.find((check) => check.step === "login");
28751
- if (login) return login.ok ? "ready" : "not-logged-in";
28752
- return name === "claude" ? "ready" : "unknown";
28753
- }
28754
- function setupHint(name, status) {
28755
- if (status === "not-configured") return `${INSTALL_HINTS[name]}, or set its command path in settings`;
28756
- if (status === "not-found") return `${INSTALL_HINTS[name]}, or correct the command path in settings`;
28757
- if (status === "not-logged-in") return LOGIN_HINTS[name];
28758
- if (status === "test-failed") return `read the test message; if it is a login problem, ${LOGIN_HINTS[name]}`;
28759
- if (status === "timed-out") return "it may be slow or waiting for input; run the test again, or try it in a terminal";
28760
- if (status === "unknown") return "run a full test to confirm it is logged in";
28761
- return "";
28762
- }
28763
- function testOutcome(checks) {
28764
- const prompt = checks?.find((check) => check.step === "prompt");
28765
- if (!prompt) return void 0;
28766
- if (prompt.ok) return { ok: true, text: `Test passed: ${prompt.detail}` };
28767
- if (prompt.timedOut) return { ok: false, text: `Test timed out: ${prompt.detail}` };
28768
- return { ok: false, text: `Test failed: ${prompt.detail}` };
28769
- }
28770
- var LIST_STATUS = {
28771
- checking: { symbol: "\u2026", text: "checking", tone: "muted" },
28772
- ready: { symbol: "\u25CF", text: "ready", tone: "ok" },
28773
- "not-configured": { symbol: "\u25CB", text: "not installed", tone: "muted" },
28774
- "not-found": { symbol: "\u25CB", text: "not installed", tone: "bad" },
28775
- "not-logged-in": { symbol: "\u25D0", text: "not logged in", tone: "bad" },
28776
- "test-failed": { symbol: "\u2717", text: "test failed", tone: "bad" },
28777
- "timed-out": { symbol: "\u2717", text: "test timed out", tone: "bad" },
28778
- unknown: { symbol: "\u25D0", text: "installed, login unknown", tone: "muted" }
28779
- };
28780
- function modelLine(name, savedModel) {
28781
- const model = savedModel.trim();
28782
- return model ? model : `${defaultModelLabel(name)} (built-in default)`;
28783
- }
28784
- function baseRows(name, checks, savedBinary) {
28785
- const path5 = checks.find((check) => check.step === "path");
28786
- const version = checks.find((check) => check.step === "version");
28787
- const hint = setupHint(name, statusFromChecks(name, checks, savedBinary));
28788
- const setup = hint ? { label: "Setup", value: hint, tone: "muted" } : void 0;
28789
- if (!path5?.ok) {
28790
- const saved = savedBinary.trim() !== "";
28791
- const command = {
28792
- label: "Command",
28793
- value: saved ? path5?.detail ?? "not found" : "not configured (not on the PATH)",
28794
- tone: saved ? "bad" : "muted"
28795
- };
28796
- return { command, version: void 0, setup, found: false };
28797
- }
28798
- return {
28799
- command: { label: "Command", value: path5.detail, tone: "ok" },
28800
- version: {
28801
- label: "Version",
28802
- value: version?.ok ? version.detail : "could not be read",
28803
- tone: version?.ok ? "ok" : "muted"
28804
- },
28805
- setup,
28806
- found: true
28807
- };
28808
- }
28809
- var checking = [{ label: "Command", value: "checking...", tone: "muted" }];
28810
- function panelRows(name, checks, settings) {
28811
- if (!checks) return checking;
28812
- const { command, version, setup, found } = baseRows(name, checks, settings.binary);
28813
- const model = { label: "Model", value: modelLine(name, settings.model), tone: "muted" };
28814
- return [command, ...found ? [...version?.tone === "ok" ? [version] : [], model] : [], ...setup ? [setup] : []];
28815
- }
28816
- function statusRows(name, checks, savedBinary) {
28817
- if (!checks) return checking;
28818
- const { command, version, setup, found } = baseRows(name, checks, savedBinary);
28819
- if (!found) return [command];
28820
- const login = checks.find((check) => check.step === "login");
28821
- const prompt = checks.find((check) => check.step === "prompt");
28822
- let loginRow;
28823
- if (login) {
28824
- loginRow = { label: "Login", value: login.detail, tone: login.ok ? "ok" : "bad" };
28825
- } else if (prompt) {
28826
- loginRow = {
28827
- label: "Login",
28828
- value: prompt.ok ? "confirmed by the test" : prompt.timedOut ? "unknown (the test timed out)" : "see the test result",
28829
- tone: prompt.ok ? "ok" : prompt.timedOut ? "muted" : "bad"
28830
- };
28831
- } else {
28832
- loginRow = { label: "Login", value: "not checked (use Run test)", tone: "muted" };
28833
- }
28834
- const testRow = prompt ? [{ label: "Test", value: prompt.detail, tone: prompt.ok ? "ok" : "bad" }] : [];
28835
- return [command, ...version ? [version] : [], loginRow, ...testRow, ...setup ? [setup] : []];
28836
- }
28837
- async function withBinaryEnv(name, binary, run) {
28838
- const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
28839
- const previous = process.env[key];
28840
- process.env[key] = binary;
28841
- try {
28842
- return await run();
28843
- } finally {
28844
- if (previous === void 0) delete process.env[key];
28845
- else process.env[key] = previous;
28846
- }
28847
- }
28848
-
28849
- // packages/experience-design-system-cli/src/tui/settings/agents/AgentDetail.tsx
28850
- import { useEffect as useEffect22, useState as useState30 } from "react";
28851
- import { Box as Box45, Text as Text48 } from "ink";
28852
-
28853
- // packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx
28854
- import { useState as useState29 } from "react";
28855
- import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
28856
- import TextInput4 from "ink-text-input";
28857
- import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
28858
- function FieldForm({
28859
- title,
28860
- subtitle,
28861
- fields: fields2,
28862
- values,
28863
- onChange,
28864
- onSave,
28865
- onQuit,
28866
- actions = [],
28867
- notice,
28868
- busy = false,
28869
- children
28870
- }) {
28871
- const [active, setActive] = useState29(0);
28872
- const [editing, setEditing] = useState29(false);
28873
- const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
28874
- const rowCount = fields2.length + actions.length;
28875
- const labelWidth = Math.max(
28876
- ...fields2.map((field) => field.label.length),
28877
- ...actions.map((action) => action.label.length)
28878
- );
28879
- const currentField = active < fields2.length ? fields2[active] : void 0;
28880
- const currentAction = currentField ? void 0 : actions[active - fields2.length];
28881
- useInput11((input, key) => {
28882
- if (busy) return;
28883
- if (editing) {
28884
- if (key.escape && currentField) {
28885
- onChange(currentField.key, valueBeforeEdit);
28886
- setEditing(false);
28887
- }
28888
- return;
28889
- }
28890
- if (key.escape || input === "q") {
28891
- onQuit();
28892
- return;
28893
- }
28894
- if (input === "s") {
28895
- onSave();
28896
- return;
28897
- }
28898
- if (input === "c" && currentField) {
28899
- onChange(currentField.key, "");
28900
- return;
28901
- }
28902
- if (key.tab || key.downArrow) {
28903
- setActive((i) => (i + 1) % rowCount);
28904
- return;
28905
- }
28906
- if (key.upArrow) {
28907
- setActive((i) => (i - 1 + rowCount) % rowCount);
28908
- return;
28909
- }
28910
- if (key.return) {
28911
- if (currentField) {
28912
- setValueBeforeEdit(values[currentField.key]);
28913
- setEditing(true);
28914
- } else {
28915
- currentAction?.onRun();
28916
- }
28917
- }
28918
- });
28919
- const pointer = (isActive) => /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " });
28920
- return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28921
- /* @__PURE__ */ jsx55(Text46, { bold: true, children: title }),
28922
- subtitle && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: subtitle }),
28923
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
28924
- /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", children: [
28925
- fields2.map((field, index) => {
28926
- const isActive = index === active;
28927
- const value = values[field.key];
28928
- const display = field.masked ? "\u2022".repeat(value.length) : value;
28929
- return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
28930
- pointer(isActive),
28931
- /* @__PURE__ */ jsx55(Box44, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: field.label }) }),
28932
- isActive && editing ? /* @__PURE__ */ jsx55(
28933
- TextInput4,
28934
- {
28935
- value,
28936
- onChange: (next) => onChange(field.key, next),
28937
- onSubmit: () => setEditing(false),
28938
- mask: field.masked ? "\u2022" : void 0
28939
- }
28940
- ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (field.hint ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
28941
- field.hint && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: field.hint })
28942
- ] }, field.key);
28943
- }),
28944
- actions.map((action, index) => {
28945
- const isActive = fields2.length + index === active;
28946
- return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
28947
- pointer(isActive),
28948
- /* @__PURE__ */ jsx55(Box44, { width: labelWidth, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: action.label }) }),
28949
- /* @__PURE__ */ jsx55(Text46, { color: action.running ? PALETTE.accent : PALETTE.muted, children: action.running ? action.runningText ?? "running..." : action.description })
28950
- ] }, action.label);
28951
- })
28952
- ] }),
28953
- notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
28954
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
28955
- /* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
28956
- notice.kind === "success" ? "\u2713" : "\u2717",
28957
- " ",
28958
- notice.text
28959
- ] })
28960
- ] }),
28961
- children,
28962
- /* @__PURE__ */ jsx55(Text46, { children: " " }),
28963
- /* @__PURE__ */ jsx55(
28964
- ControlHints,
28965
- {
28966
- hints: editing ? [
28967
- { keys: "type", label: "edit" },
28968
- { keys: "\u2190/\u2192", label: "move cursor" },
28969
- { keys: "\u23CE", label: "done" },
28970
- { keys: "Esc", label: "cancel edit" }
28971
- ] : [
28972
- { keys: "\u2191/\u2193", label: "move" },
28973
- { keys: "\u23CE", label: currentAction ? currentAction.hint : "edit" },
28974
- ...currentField ? [{ keys: "c", label: "clear" }] : [],
28975
- { keys: "s", label: "save" },
28976
- { keys: "Esc/q", label: "back without saving" }
28977
- ]
28978
- }
28979
- )
28980
- ] });
28981
- }
28982
-
28983
- // packages/experience-design-system-cli/src/tui/settings/agents/AgentStatusBadge.tsx
28984
- import { Text as Text47 } from "ink";
28985
- import { jsx as jsx56 } from "react/jsx-runtime";
28986
- var TONE_COLOR = {
28987
- ok: PALETTE.success,
28988
- bad: PALETTE.error,
28989
- muted: PALETTE.muted
28990
- };
28991
- function AgentStatusBadge({
28992
- name,
28993
- checks,
28994
- binary
28995
- }) {
28996
- const { symbol, text, tone } = LIST_STATUS[checks ? statusFromChecks(name, checks, binary) : "checking"];
28997
- return /* @__PURE__ */ jsx56(Text47, { color: TONE_COLOR[tone], children: `${symbol} ${text}` });
28998
- }
28999
-
29000
- // packages/experience-design-system-cli/src/tui/settings/agents/apply-binary-overrides.ts
29001
- var shellValues = /* @__PURE__ */ new Map();
29002
- function applyBinaryOverrides(config) {
29003
- for (const name of AGENT_NAMES) {
29004
- const key = `EDS_AGENT_BINARY_${name.toUpperCase()}`;
29005
- const binary = config.agents[name].binary.trim();
29006
- if (binary) {
29007
- if (!shellValues.has(key)) shellValues.set(key, process.env[key]);
29008
- process.env[key] = binary;
29009
- } else if (shellValues.has(key)) {
29010
- const shellValue = shellValues.get(key);
29011
- if (shellValue === void 0) delete process.env[key];
29012
- else process.env[key] = shellValue;
29013
- shellValues.delete(key);
29014
- }
29015
- }
29016
- }
29017
-
29018
- // packages/experience-design-system-cli/src/tui/settings/agents/AgentDetail.tsx
29019
- import { jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
29020
- var fields = (name) => [
29021
- { key: "binary", label: "Command path", hint: `(empty: \`${AGENT_BINARIES[name]}\` from the PATH)` },
29022
- { key: "model", label: "Model", hint: `(empty: ${defaultModelLabel(name)})` }
29023
- ];
29024
- var LABEL_WIDTH = "Command path".length;
29025
- var LABEL_GAP = 2;
29026
- var POINTER_WIDTH = 2;
29027
- function Row2({ label, children }) {
29028
- return /* @__PURE__ */ jsxs46(Box45, { children: [
29029
- /* @__PURE__ */ jsx57(Box45, { width: POINTER_WIDTH + LABEL_WIDTH + LABEL_GAP, flexShrink: 0, children: /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: label }) }),
29030
- children
29031
- ] });
29032
- }
29033
- function StatusHeading() {
29034
- return /* @__PURE__ */ jsxs46(Box45, { gap: 1, children: [
29035
- /* @__PURE__ */ jsx57(Text48, { bold: true, color: PALETTE.muted, children: "STATUS" }),
29036
- /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "\xB7 read only" })
29037
- ] });
29038
- }
29039
- function AgentDetail({
29040
- name,
29041
- config,
29042
- setConfig,
29043
- onBack
29044
- }) {
29045
- const settings = config.agents[name];
29046
- const [saving, setSaving] = useState30(false);
29047
- const [testing, setTesting] = useState30(false);
29048
- const [notice, setNotice] = useState30(null);
29049
- const [checks, setChecks] = useState30(void 0);
29050
- useEffect22(() => {
29051
- let active = true;
29052
- setChecks(void 0);
29053
- void inspectAgent(name, settings.binary).then((result) => active && setChecks(result));
29054
- return () => {
29055
- active = false;
29056
- };
29057
- }, [name, settings.binary]);
29058
- const save = () => {
29059
- setSaving(true);
29060
- setNotice(null);
29061
- writeAgentConfig(config).then(() => {
29062
- applyBinaryOverrides(config);
29063
- setNotice({ kind: "success", text: `Saved: ${AGENT_LABELS[name]} settings are written to config.json` });
29064
- }).catch(
29065
- (err) => setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` })
29066
- ).finally(() => setSaving(false));
29067
- };
29068
- const runTest = () => {
29069
- setTesting(true);
29070
- setNotice(null);
29071
- testAgent(name, settings.binary, settings.model).then((result) => {
29072
- setChecks(result);
29073
- const outcome = testOutcome(result);
29074
- setNotice(
29075
- outcome ? { kind: outcome.ok ? "success" : "error", text: outcome.text } : { kind: "error", text: "Test not run: the agent could not be started (see Status)" }
29076
- );
29077
- }).catch(
29078
- (err) => setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` })
29079
- ).finally(() => setTesting(false));
29080
- };
29081
- const action = {
29082
- label: "Run test",
29083
- description: "sends one small prompt (uses a few tokens)",
29084
- running: testing,
29085
- hint: "run test",
29086
- onRun: runTest
29087
- };
29088
- return /* @__PURE__ */ jsx57(
29089
- FieldForm,
29090
- {
29091
- title: AGENT_LABELS[name],
29092
- subtitle: config.defaultAgent === name ? "This is the default agent." : `Runs the \`${AGENT_BINARIES[name]}\` command.`,
29093
- fields: fields(name),
29094
- values: { binary: settings.binary, model: settings.model },
29095
- onChange: (key, value) => {
29096
- setConfig({ ...config, agents: { ...config.agents, [name]: { ...settings, [key]: value } } });
29097
- setNotice(null);
29098
- },
29099
- onSave: save,
29100
- onQuit: onBack,
29101
- actions: [action],
29102
- notice: testing ? null : notice,
29103
- busy: saving || testing,
29104
- children: /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", marginTop: 1, children: [
29105
- /* @__PURE__ */ jsx57(StatusHeading, {}),
29106
- 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))
29107
- ] })
29108
- }
29109
- );
29110
- }
29111
-
29112
- // packages/experience-design-system-cli/src/tui/settings/agents/AgentsScreen.tsx
29113
- import { Fragment as Fragment18, jsx as jsx58, jsxs as jsxs47 } from "react/jsx-runtime";
29114
- var NAME_WIDTH = 16;
29115
- var PANEL_LABEL_WIDTH = "Command".length;
29116
- function AgentsScreen({ onDone }) {
29117
- const [config, setConfig] = useState31(null);
29118
- const [focus, setFocus] = useState31(0);
29119
- const [open, setOpen] = useState31(null);
29120
- const [notice, setNotice] = useState31(null);
29121
- const [saving, setSaving] = useState31(false);
29122
- const [checks, setChecks] = useState31({});
29123
- const inspectAll = (loaded) => {
29124
- for (const name of AGENT_NAMES) {
29125
- void inspectAgent(name, loaded.agents[name].binary).then(
29126
- (result) => setChecks((previous) => ({ ...previous, [name]: result }))
29127
- );
29128
- }
29129
- };
29130
- useEffect23(() => {
29131
- void readAgentConfig().then((loaded) => {
29132
- setConfig(loaded);
29133
- inspectAll(loaded);
29134
- startDebugRun({
29135
- flow: "settings/agents",
29136
- step: "01-agents",
29137
- menuOption: "Configuration > Agents",
29138
- inputs: { default_agent: loaded.defaultAgent }
29139
- });
29140
- });
29141
- }, []);
29142
- const makeDefault = (name) => {
29143
- if (!config || saving) return;
29144
- if (name === config.defaultAgent) {
29145
- setNotice({ kind: "success", text: `${AGENT_LABELS[name]} is already the default agent` });
29146
- return;
29147
- }
29148
- setSaving(true);
29149
- setNotice(null);
29150
- writeAgentConfig({ ...config, defaultAgent: name }).then(() => {
29151
- setConfig((current) => current ? { ...current, defaultAgent: name } : current);
29152
- setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[name]}` });
29153
- }).catch(
29154
- (err) => setNotice({
29155
- kind: "error",
29156
- text: `Default agent not changed: ${err instanceof Error ? err.message : String(err)}`
29157
- })
29158
- ).finally(() => setSaving(false));
29159
- };
29160
- useInput12((input, key) => {
29161
- if (!config || open || saving) return;
29162
- const focused = AGENT_NAMES[focus];
29163
- if (key.upArrow || key.downArrow || key.tab) setNotice(null);
29164
- if (key.upArrow) {
29165
- setFocus((i) => (i - 1 + AGENT_NAMES.length) % AGENT_NAMES.length);
29166
- return;
29167
- }
29168
- if (key.downArrow || key.tab) {
29169
- setFocus((i) => (i + 1) % AGENT_NAMES.length);
29170
- return;
29171
- }
29172
- if (key.return) {
29173
- makeDefault(focused);
29174
- return;
29175
- }
29176
- if (key.rightArrow) {
29177
- setNotice(null);
29178
- setOpen(focused);
29179
- return;
29180
- }
29181
- if (key.escape || input === "q") {
29182
- void finishDebugRun({ outputs: { default_agent: config.defaultAgent }, status: "success", exitMethod: "saved" });
29183
- onDone();
29184
- }
29185
- });
29186
- if (!config) {
29187
- return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29188
- /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Agents" }),
29189
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
29190
- /* @__PURE__ */ jsx58(Text49, { color: PALETTE.accent, children: "Loading..." })
29191
- ] });
29192
- }
29193
- if (open) {
29194
- return /* @__PURE__ */ jsx58(
29195
- AgentDetail,
29196
- {
29197
- name: open,
29198
- config,
29199
- setConfig,
29200
- onBack: () => {
29201
- setOpen(null);
29202
- void readAgentConfig().then((saved) => {
29203
- setConfig(saved);
29204
- inspectAll(saved);
29205
- });
29206
- }
29207
- }
29208
- );
29209
- }
29210
- const focusedAgent = AGENT_NAMES[focus];
29211
- return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29212
- /* @__PURE__ */ jsx58(Text49, { bold: true, children: "Agents" }),
29213
- /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "The coding agent the CLI runs, and what was found for each one." }),
29214
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
29215
- /* @__PURE__ */ jsxs47(Box46, { gap: 1, children: [
29216
- /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "Default agent" }),
29217
- /* @__PURE__ */ jsx58(Text49, { bold: true, children: AGENT_LABELS[config.defaultAgent] }),
29218
- saving && /* @__PURE__ */ jsx58(Text49, { color: PALETTE.accent, children: "\u2026 saving" })
29219
- ] }),
29220
- /* @__PURE__ */ jsxs47(Box46, { marginTop: 1, gap: 1, children: [
29221
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
29222
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
29223
- /* @__PURE__ */ jsx58(Box46, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "AGENT" }) }),
29224
- /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: "STATUS" })
29225
- ] }),
29226
- AGENT_NAMES.map((name) => {
29227
- const isFocused = focusedAgent === name;
29228
- return /* @__PURE__ */ jsxs47(Box46, { gap: 1, children: [
29229
- /* @__PURE__ */ jsx58(Text49, { color: isFocused ? PALETTE.accent : void 0, children: isFocused ? "\u276F" : " " }),
29230
- /* @__PURE__ */ jsx58(Text49, { color: PALETTE.success, children: name === config.defaultAgent ? "\u2605" : " " }),
29231
- /* @__PURE__ */ jsx58(Box46, { width: NAME_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { bold: isFocused, color: isFocused ? PALETTE.accent : void 0, children: AGENT_LABELS[name] }) }),
29232
- /* @__PURE__ */ jsx58(AgentStatusBadge, { name, checks: checks[name], binary: config.agents[name].binary })
29233
- ] }, name);
29234
- }),
29235
- /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", marginTop: 1, children: [
29236
- /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: `\u2500 ${AGENT_LABELS[focusedAgent]} ${"\u2500".repeat(30)}` }),
29237
- panelRows(focusedAgent, checks[focusedAgent], config.agents[focusedAgent]).map((row) => /* @__PURE__ */ jsxs47(Box46, { gap: 1, paddingLeft: 1, children: [
29238
- /* @__PURE__ */ jsx58(Box46, { width: PANEL_LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx58(Text49, { color: PALETTE.muted, children: row.label }) }),
29239
- /* @__PURE__ */ jsx58(Text49, { color: TONE_COLOR[row.tone], children: row.value })
29240
- ] }, row.label))
29241
- ] }),
29242
- notice && /* @__PURE__ */ jsxs47(Fragment18, { children: [
29243
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
29244
- /* @__PURE__ */ jsxs47(Text49, { bold: true, color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
29245
- notice.kind === "success" ? "\u2713" : "\u2717",
29246
- " ",
29247
- notice.text
29248
- ] })
29249
- ] }),
29250
- /* @__PURE__ */ jsx58(Text49, { children: " " }),
29251
- /* @__PURE__ */ jsx58(
29252
- ControlHints,
29253
- {
29254
- hints: [
29255
- { keys: "\u2191/\u2193", label: "move" },
29256
- { keys: "\u23CE", label: "make default" },
29257
- { keys: "\u2192", label: "settings and test" },
29258
- { keys: "Esc/q", label: "back" }
29259
- ]
29260
- }
29261
- )
29262
- ] });
29263
- }
29264
-
29265
- // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ProjectConfigScreen.tsx
29266
- import { useEffect as useEffect24, useState as useState32 } from "react";
29267
- import { Box as Box47, Text as Text50 } from "ink";
29268
- init_debug_store();
29269
-
29270
28543
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
29271
28544
  async function readCredentials() {
29272
28545
  const store = await readV1Store();
@@ -29292,16 +28565,17 @@ async function writeCredentials(config) {
29292
28565
  await writeV1Store(merged);
29293
28566
  }
29294
28567
 
29295
- // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ProjectConfigScreen.tsx
29296
- import { jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
29297
- var FIELDS2 = [
29298
- { key: "spaceId", label: "Space ID" },
29299
- { key: "environmentId", label: "Environment ID" },
29300
- { key: "cmaToken", label: "CMA Token", masked: true },
29301
- { key: "host", label: "API Host" },
29302
- { key: "defaultComponentDir", label: "Default component directory" },
29303
- { key: "defaultTokenFile", label: "Default token file" },
29304
- { key: "contentfulBaseDir", label: "Root Project Directory", hint: "(where .contentful goes)" }
28568
+ // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28569
+ init_debug_store();
28570
+ import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
28571
+ var FIELD_ORDER = [
28572
+ "spaceId",
28573
+ "environmentId",
28574
+ "cmaToken",
28575
+ "host",
28576
+ "defaultComponentDir",
28577
+ "defaultTokenFile",
28578
+ "contentfulBaseDir"
29305
28579
  ];
29306
28580
  function debugFields(config) {
29307
28581
  return {
@@ -29314,114 +28588,156 @@ function debugFields(config) {
29314
28588
  contentful_base_dir: config?.contentfulBaseDir ?? ""
29315
28589
  };
29316
28590
  }
29317
- var valuesOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
29318
- function ProjectConfigScreen({ onDone }) {
29319
- const [config, setConfig] = useState32(null);
29320
- const [saving, setSaving] = useState32(false);
29321
- const [notice, setNotice] = useState32(null);
29322
- const [lastSaved, setLastSaved] = useState32(null);
29323
- useEffect24(() => {
29324
- void readCredentials().then((cfg) => {
28591
+ var FIELD_LABELS = {
28592
+ spaceId: "Space ID",
28593
+ environmentId: "Environment ID",
28594
+ cmaToken: "CMA Token",
28595
+ host: "API Host",
28596
+ defaultComponentDir: "Default component directory",
28597
+ defaultTokenFile: "Default token file",
28598
+ contentfulBaseDir: "Root Project Directory"
28599
+ };
28600
+ var FIELD_HINTS = {
28601
+ contentfulBaseDir: "(where .contentful goes)"
28602
+ };
28603
+ var LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
28604
+ function ConfigurationScreen({ onDone }) {
28605
+ const [stage, setStage] = useState29("loading");
28606
+ const [config, setConfig] = useState29(null);
28607
+ const [activeField, setActiveField] = useState29("spaceId");
28608
+ const [notice, setNotice] = useState29(null);
28609
+ const [lastSaved, setLastSaved] = useState29(null);
28610
+ const [editing, setEditing] = useState29(false);
28611
+ const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
28612
+ useEffect22(() => {
28613
+ readCredentials().then((cfg) => {
29325
28614
  setConfig(cfg);
28615
+ setStage("form");
29326
28616
  startDebugRun({
29327
28617
  flow: "settings/contentful-configuration",
29328
28618
  step: "01-configuration",
29329
- menuOption: "Configuration > Project",
28619
+ menuOption: "Configuration",
29330
28620
  inputs: debugFields(cfg)
29331
28621
  });
29332
28622
  });
29333
28623
  }, []);
29334
- if (!config) {
29335
- return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29336
- /* @__PURE__ */ jsx59(Text50, { bold: true, children: "Project" }),
29337
- /* @__PURE__ */ jsx59(Text50, { children: " " }),
29338
- /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
29339
- ] });
28624
+ function fieldValue(field) {
28625
+ if (!config) return "";
28626
+ return config[field] || "";
28627
+ }
28628
+ function setFieldValue(field, value) {
28629
+ if (!config) return;
28630
+ setConfig({ ...config, [field]: value });
28631
+ setNotice(null);
29340
28632
  }
29341
- const save = () => {
29342
- setSaving(true);
28633
+ function handleSave() {
28634
+ if (!config) return;
28635
+ setStage("saving");
29343
28636
  setNotice(null);
29344
28637
  writeCredentials(config).then(() => {
29345
28638
  setLastSaved(config);
29346
28639
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
29347
- setNotice({ kind: "success", text: "Project settings saved" });
28640
+ setNotice({ kind: "success", text: "Configuration saved" });
28641
+ setStage("form");
29348
28642
  }).catch((err) => {
29349
28643
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
29350
- }).finally(() => setSaving(false));
29351
- };
29352
- const quit = () => {
28644
+ setStage("form");
28645
+ });
28646
+ }
28647
+ function quit() {
29353
28648
  void finishDebugRun(
29354
28649
  lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
29355
28650
  );
29356
28651
  onDone();
29357
- };
29358
- return /* @__PURE__ */ jsx59(
29359
- FieldForm,
29360
- {
29361
- title: "Project",
29362
- subtitle: "The Contentful space and where the CLI keeps its files.",
29363
- fields: FIELDS2,
29364
- values: valuesOf(config),
29365
- onChange: (key, value) => {
29366
- setConfig({ ...config, [key]: value });
29367
- setNotice(null);
29368
- },
29369
- onSave: save,
29370
- onQuit: quit,
29371
- notice,
29372
- busy: saving
28652
+ }
28653
+ useInput11((input, key) => {
28654
+ if (stage === "loading" || stage === "saving") return;
28655
+ if (editing) {
28656
+ if (key.escape) {
28657
+ setFieldValue(activeField, valueBeforeEdit);
28658
+ setEditing(false);
28659
+ }
28660
+ return;
29373
28661
  }
29374
- );
29375
- }
29376
-
29377
- // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
29378
- import { jsx as jsx60, jsxs as jsxs49 } from "react/jsx-runtime";
29379
- var SECTIONS = [
29380
- {
29381
- id: "project",
29382
- label: "Project",
29383
- description: "Contentful space, credentials, defaults and where .contentful goes"
29384
- },
29385
- { id: "agents", label: "Agents", description: "Which coding agent the CLI uses, and each agent\u2019s settings" }
29386
- ];
29387
- function ConfigurationScreen({ onDone }) {
29388
- const [focus, setFocus] = useState33(0);
29389
- const [open, setOpen] = useState33(null);
29390
- const close = () => setOpen(null);
29391
- useInput13((input, key) => {
29392
- if (open) return;
29393
- if (key.upArrow) {
29394
- setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
28662
+ if (key.escape || input === "q") {
28663
+ quit();
29395
28664
  return;
29396
28665
  }
29397
- if (key.downArrow || key.tab) {
29398
- setFocus((i) => (i + 1) % SECTIONS.length);
28666
+ if (input === "s") {
28667
+ handleSave();
29399
28668
  return;
29400
28669
  }
29401
- if (key.return) {
29402
- setOpen(SECTIONS[focus].id);
28670
+ if (input === "c") {
28671
+ setFieldValue(activeField, "");
28672
+ return;
28673
+ }
28674
+ if (key.tab || key.downArrow) {
28675
+ const idx = FIELD_ORDER.indexOf(activeField);
28676
+ setActiveField(FIELD_ORDER[(idx + 1) % FIELD_ORDER.length]);
29403
28677
  return;
29404
28678
  }
29405
- if (key.escape || input === "q") onDone();
28679
+ if (key.upArrow) {
28680
+ const idx = FIELD_ORDER.indexOf(activeField);
28681
+ setActiveField(FIELD_ORDER[(idx - 1 + FIELD_ORDER.length) % FIELD_ORDER.length]);
28682
+ return;
28683
+ }
28684
+ if (key.return) {
28685
+ setValueBeforeEdit(fieldValue(activeField));
28686
+ setEditing(true);
28687
+ }
29406
28688
  });
29407
- if (open === "project") return /* @__PURE__ */ jsx60(ProjectConfigScreen, { onDone: close });
29408
- if (open === "agents") return /* @__PURE__ */ jsx60(AgentsScreen, { onDone: close });
29409
- return /* @__PURE__ */ jsxs49(Box48, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29410
- /* @__PURE__ */ jsx60(Text51, { bold: true, children: "Configuration" }),
29411
- /* @__PURE__ */ jsx60(Text51, { children: " " }),
29412
- SECTIONS.map((section, index) => /* @__PURE__ */ jsxs49(Box48, { gap: 1, children: [
29413
- /* @__PURE__ */ jsx60(Text51, { color: index === focus ? PALETTE.accent : void 0, children: index === focus ? "\u276F" : " " }),
29414
- /* @__PURE__ */ jsx60(Box48, { width: 9, flexShrink: 0, children: /* @__PURE__ */ jsx60(Text51, { bold: index === focus, color: index === focus ? PALETTE.accent : void 0, children: section.label }) }),
29415
- /* @__PURE__ */ jsx60(Text51, { color: PALETTE.muted, children: section.description })
29416
- ] }, section.id)),
29417
- /* @__PURE__ */ jsx60(Text51, { children: " " }),
29418
- /* @__PURE__ */ jsx60(
28689
+ if (stage === "loading") {
28690
+ return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28691
+ /* @__PURE__ */ jsx55(Text46, { bold: true, children: "Configuration" }),
28692
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
28693
+ /* @__PURE__ */ jsx55(Text46, { color: PALETTE.accent, children: "Loading..." })
28694
+ ] });
28695
+ }
28696
+ return /* @__PURE__ */ jsxs45(Box44, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28697
+ /* @__PURE__ */ jsx55(Text46, { bold: true, children: "Configuration" }),
28698
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
28699
+ /* @__PURE__ */ jsx55(Box44, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
28700
+ const isActive = activeField === field;
28701
+ const value = fieldValue(field);
28702
+ const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
28703
+ return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
28704
+ /* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
28705
+ /* @__PURE__ */ jsx55(Box44, { width: LABEL_WIDTH, flexShrink: 0, children: /* @__PURE__ */ jsx55(Text46, { bold: isActive, color: isActive ? PALETTE.accent : PALETTE.muted, children: FIELD_LABELS[field] }) }),
28706
+ isActive && editing ? /* @__PURE__ */ jsx55(
28707
+ TextInput4,
28708
+ {
28709
+ value,
28710
+ onChange: (next) => setFieldValue(field, next),
28711
+ onSubmit: () => setEditing(false),
28712
+ mask: field === "cmaToken" ? "\u2022" : void 0
28713
+ }
28714
+ ) : /* @__PURE__ */ jsx55(Text46, { bold: !!display, children: display || (FIELD_HINTS[field] ? "" : /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" })) }),
28715
+ FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
28716
+ ] }, field);
28717
+ }) }),
28718
+ notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
28719
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
28720
+ /* @__PURE__ */ jsxs45(Text46, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
28721
+ notice.kind === "success" ? "\u2713" : "\u2717",
28722
+ " ",
28723
+ notice.text
28724
+ ] })
28725
+ ] }),
28726
+ /* @__PURE__ */ jsx55(Text46, { children: " " }),
28727
+ /* @__PURE__ */ jsx55(
29419
28728
  ControlHints,
29420
28729
  {
29421
- hints: [
28730
+ hints: editing ? [
28731
+ { keys: "type", label: "edit" },
28732
+ { keys: "\u2190/\u2192", label: "move cursor" },
28733
+ { keys: "\u23CE", label: "done" },
28734
+ { keys: "Esc", label: "cancel edit" }
28735
+ ] : [
29422
28736
  { keys: "\u2191/\u2193", label: "move" },
29423
- { keys: "\u23CE", label: "open" },
29424
- { keys: "Esc/q", label: "back" }
28737
+ { keys: "\u23CE", label: "edit" },
28738
+ { keys: "c", label: "clear" },
28739
+ { keys: "s", label: "save" },
28740
+ { keys: "Esc/q", label: "quit without saving" }
29425
28741
  ]
29426
28742
  }
29427
28743
  )
@@ -29429,8 +28745,8 @@ function ConfigurationScreen({ onDone }) {
29429
28745
  }
29430
28746
 
29431
28747
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
29432
- import { useEffect as useEffect25, useState as useState34 } from "react";
29433
- import { Box as Box49, Text as Text52, useInput as useInput14 } from "ink";
28748
+ import { useEffect as useEffect23, useState as useState30 } from "react";
28749
+ import { Box as Box45, Text as Text47, useInput as useInput12 } from "ink";
29434
28750
 
29435
28751
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
29436
28752
  async function readAnalyticsSetting() {
@@ -29449,11 +28765,11 @@ async function writeAnalyticsSetting(setting) {
29449
28765
 
29450
28766
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
29451
28767
  init_debug_store();
29452
- import { Fragment as Fragment19, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
28768
+ import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
29453
28769
  function OptInAnalyticsScreen({ onDone }) {
29454
- const [loading, setLoading] = useState34(true);
29455
- const [enabled, setEnabled] = useState34(true);
29456
- useEffect25(() => {
28770
+ const [loading, setLoading] = useState30(true);
28771
+ const [enabled, setEnabled] = useState30(true);
28772
+ useEffect23(() => {
29457
28773
  readAnalyticsSetting().then((setting) => {
29458
28774
  setEnabled(setting.enabled);
29459
28775
  setLoading(false);
@@ -29465,7 +28781,7 @@ function OptInAnalyticsScreen({ onDone }) {
29465
28781
  });
29466
28782
  });
29467
28783
  }, []);
29468
- useInput14((input, key) => {
28784
+ useInput12((input, key) => {
29469
28785
  if (loading) return;
29470
28786
  if (key.return || input === " ") {
29471
28787
  setEnabled((current) => {
@@ -29480,21 +28796,21 @@ function OptInAnalyticsScreen({ onDone }) {
29480
28796
  onDone();
29481
28797
  }
29482
28798
  });
29483
- return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29484
- /* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
29485
- /* @__PURE__ */ jsx61(Text52, { children: " " }),
29486
- loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment19, { children: [
29487
- /* @__PURE__ */ jsxs50(Text52, { children: [
28799
+ return /* @__PURE__ */ jsxs46(Box45, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28800
+ /* @__PURE__ */ jsx56(Text47, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
28801
+ /* @__PURE__ */ jsx56(Text47, { children: " " }),
28802
+ loading ? /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs46(Fragment18, { children: [
28803
+ /* @__PURE__ */ jsxs46(Text47, { children: [
29488
28804
  "Share anonymous usage data:",
29489
28805
  " ",
29490
- /* @__PURE__ */ jsx61(Text52, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
28806
+ /* @__PURE__ */ jsx56(Text47, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
29491
28807
  ] }),
29492
- /* @__PURE__ */ jsx61(Text52, { children: " " }),
29493
- /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
29494
- /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
28808
+ /* @__PURE__ */ jsx56(Text47, { children: " " }),
28809
+ /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
28810
+ /* @__PURE__ */ jsx56(Text47, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
29495
28811
  ] }),
29496
- /* @__PURE__ */ jsx61(Text52, { children: " " }),
29497
- /* @__PURE__ */ jsx61(
28812
+ /* @__PURE__ */ jsx56(Text47, { children: " " }),
28813
+ /* @__PURE__ */ jsx56(
29498
28814
  ControlHints,
29499
28815
  {
29500
28816
  hints: [
@@ -29506,89 +28822,16 @@ function OptInAnalyticsScreen({ onDone }) {
29506
28822
  ] });
29507
28823
  }
29508
28824
 
29509
- // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
29510
- import { useEffect as useEffect26, useState as useState35 } from "react";
29511
- import { Box as Box50, Text as Text53, useInput as useInput15 } from "ink";
29512
- init_version();
29513
- init_debug_store();
29514
- import { jsx as jsx62, jsxs as jsxs51 } from "react/jsx-runtime";
29515
- var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
29516
- function UpgradeScreen({ onDone }) {
29517
- const [upgradeCheck, setUpgradeCheck] = useState35();
29518
- useEffect26(() => {
29519
- startDebugRun({
29520
- flow: "upgrade",
29521
- step: "01-upgrade",
29522
- menuOption: "Upgrade",
29523
- inputs: { currentVersion: readPackageVersion() }
29524
- });
29525
- checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
29526
- }, []);
29527
- useInput15((_input, key) => {
29528
- if (key.return) {
29529
- void finishDebugRun({
29530
- outputs: upgradeCheck ?? {},
29531
- status: upgradeCheck?.status === "error" ? "error" : "success",
29532
- exitMethod: "saved"
29533
- });
29534
- onDone();
29535
- return;
29536
- }
29537
- });
29538
- return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29539
- /* @__PURE__ */ jsx62(Text53, { bold: true, children: "Upgrade" }),
29540
- /* @__PURE__ */ jsx62(Text53, { children: " " }),
29541
- renderBody(upgradeCheck),
29542
- /* @__PURE__ */ jsx62(Text53, { children: " " }),
29543
- /* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.accent, children: [
29544
- FOCUS_MARKER,
29545
- " Go Back"
29546
- ] })
29547
- ] });
29548
- }
29549
- function renderBody(upgradeCheck) {
29550
- if (!upgradeCheck) {
29551
- return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.muted, children: "Checking for updates\u2026" });
29552
- }
29553
- if (upgradeCheck.status === "error") {
29554
- return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
29555
- }
29556
- if (upgradeCheck.status === "up-to-date") {
29557
- return /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.success, children: [
29558
- "You're already on the latest version (v",
29559
- upgradeCheck.current,
29560
- ")."
29561
- ] });
29562
- }
29563
- return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", children: [
29564
- /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.muted, children: [
29565
- /* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.success, children: [
29566
- "v",
29567
- upgradeCheck.latest
29568
- ] }),
29569
- " ",
29570
- "is available (you're on ",
29571
- /* @__PURE__ */ jsxs51(Text53, { bold: true, children: [
29572
- "v",
29573
- upgradeCheck.current
29574
- ] }),
29575
- "). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
29576
- ] }),
29577
- /* @__PURE__ */ jsx62(Text53, { children: " " }),
29578
- /* @__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)) })
29579
- ] });
29580
- }
29581
-
29582
28825
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
29583
- import { useEffect as useEffect27, useState as useState36 } from "react";
29584
- import { Box as Box51, Text as Text54, useInput as useInput16 } from "ink";
28826
+ import { useEffect as useEffect24, useState as useState31 } from "react";
28827
+ import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
29585
28828
  init_debug_mode_store();
29586
28829
  init_debug_store();
29587
- import { jsx as jsx63, jsxs as jsxs52 } from "react/jsx-runtime";
28830
+ import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
29588
28831
  function DebugModeScreen({ onDone }) {
29589
- const [loading, setLoading] = useState36(true);
29590
- const [enabled, setEnabled] = useState36(true);
29591
- useEffect27(() => {
28832
+ const [loading, setLoading] = useState31(true);
28833
+ const [enabled, setEnabled] = useState31(true);
28834
+ useEffect24(() => {
29592
28835
  readDebugModeSetting().then((setting) => {
29593
28836
  setEnabled(setting.enabled);
29594
28837
  setLoading(false);
@@ -29600,7 +28843,7 @@ function DebugModeScreen({ onDone }) {
29600
28843
  });
29601
28844
  });
29602
28845
  }, []);
29603
- useInput16((input, key) => {
28846
+ useInput13((input, key) => {
29604
28847
  if (loading) return;
29605
28848
  if (key.return || input === " ") {
29606
28849
  setEnabled((current) => {
@@ -29615,16 +28858,16 @@ function DebugModeScreen({ onDone }) {
29615
28858
  onDone();
29616
28859
  }
29617
28860
  });
29618
- return /* @__PURE__ */ jsxs52(Box51, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29619
- /* @__PURE__ */ jsx63(Text54, { bold: true, children: "Settings \u203A Debug Mode" }),
29620
- /* @__PURE__ */ jsx63(Text54, { children: " " }),
29621
- loading ? /* @__PURE__ */ jsx63(Text54, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs52(Text54, { children: [
28861
+ return /* @__PURE__ */ jsxs47(Box46, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
28862
+ /* @__PURE__ */ jsx57(Text48, { bold: true, children: "Settings \u203A Debug Mode" }),
28863
+ /* @__PURE__ */ jsx57(Text48, { children: " " }),
28864
+ loading ? /* @__PURE__ */ jsx57(Text48, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs47(Text48, { children: [
29622
28865
  "Debug logging:",
29623
28866
  " ",
29624
- /* @__PURE__ */ jsx63(Text54, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
28867
+ /* @__PURE__ */ jsx57(Text48, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
29625
28868
  ] }),
29626
- /* @__PURE__ */ jsx63(Text54, { children: " " }),
29627
- /* @__PURE__ */ jsx63(
28869
+ /* @__PURE__ */ jsx57(Text48, { children: " " }),
28870
+ /* @__PURE__ */ jsx57(
29628
28871
  ControlHints,
29629
28872
  {
29630
28873
  hints: [
@@ -29637,18 +28880,18 @@ function DebugModeScreen({ onDone }) {
29637
28880
  }
29638
28881
 
29639
28882
  // packages/experience-design-system-cli/app.tsx
29640
- import { Fragment as Fragment20, jsx as jsx64 } from "react/jsx-runtime";
28883
+ import { Fragment as Fragment19, jsx as jsx58 } from "react/jsx-runtime";
29641
28884
  function App({ importOptions, inkClear }) {
29642
- const [screen, setScreen] = useState37("start");
29643
- const [importExitCode, setImportExitCode] = useState37();
28885
+ const [screen, setScreen] = useState32("start");
28886
+ const [importExitCode, setImportExitCode] = useState32();
29644
28887
  const showImportResult = importExitCode !== void 0;
29645
- const [projectPath, setProjectPath] = useState37();
29646
- const [tokensPath, setTokensPath] = useState37();
29647
- const [scannedFiles, setScannedFiles] = useState37();
29648
- const [pendingLaunch, setPendingLaunch] = useState37();
29649
- const [extractionRun, setExtractionRun] = useState37();
28888
+ const [projectPath, setProjectPath] = useState32();
28889
+ const [tokensPath, setTokensPath] = useState32();
28890
+ const [scannedFiles, setScannedFiles] = useState32();
28891
+ const [pendingLaunch, setPendingLaunch] = useState32();
28892
+ const [extractionRun, setExtractionRun] = useState32();
29650
28893
  const extraction = useExtraction(extractionRun?.input);
29651
- const [scopeRun, setScopeRun] = useState37();
28894
+ const [scopeRun, setScopeRun] = useState32();
29652
28895
  const scopeFlow = useScopeGateFlow(
29653
28896
  scopeRun && {
29654
28897
  sessionId: scopeRun.extraction.sessionId,
@@ -29663,12 +28906,12 @@ function App({ importOptions, inkClear }) {
29663
28906
  }
29664
28907
  }
29665
28908
  );
29666
- const [generationInput, setGenerationInput] = useState37();
28909
+ const [generationInput, setGenerationInput] = useState32();
29667
28910
  const generation = useGeneration(generationInput);
29668
- const [flowStart, setFlowStart] = useState37();
28911
+ const [flowStart, setFlowStart] = useState32();
29669
28912
  const flow = useFlow(flowStart, { beforeStepChange: inkClear });
29670
- const [importDefaults, setImportDefaults] = useState37();
29671
- useEffect28(() => {
28913
+ const [importDefaults, setImportDefaults] = useState32();
28914
+ useEffect25(() => {
29672
28915
  if (screen !== "import") {
29673
28916
  setImportDefaults(void 0);
29674
28917
  return;
@@ -29686,7 +28929,7 @@ function App({ importOptions, inkClear }) {
29686
28929
  const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
29687
28930
  const state2 = await inspectTokens({
29688
28931
  rawTokensPath: tokens,
29689
- contentfulDir: join26(resolveUserPath(projectPath2), ".contentful"),
28932
+ contentfulDir: join25(resolveUserPath(projectPath2), ".contentful"),
29690
28933
  cache: importOptions.cache
29691
28934
  });
29692
28935
  if (state2.kind === "cached") {
@@ -29728,12 +28971,12 @@ function App({ importOptions, inkClear }) {
29728
28971
  }
29729
28972
  });
29730
28973
  };
29731
- useEffect28(() => {
28974
+ useEffect25(() => {
29732
28975
  if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
29733
28976
  setExtractionRun(void 0);
29734
28977
  setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
29735
28978
  }, [extraction, extractionRun]);
29736
- useEffect28(() => {
28979
+ useEffect25(() => {
29737
28980
  if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
29738
28981
  const { extraction: produced, input, generatePromptPath } = scopeRun;
29739
28982
  setGenerationInput({
@@ -29751,7 +28994,7 @@ function App({ importOptions, inkClear }) {
29751
28994
  ...generatePromptPath ? { generatePromptPath } : {}
29752
28995
  });
29753
28996
  }, [scopeFlow, scopeRun, generationInput]);
29754
- useEffect28(() => {
28997
+ useEffect25(() => {
29755
28998
  if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
29756
28999
  const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
29757
29000
  inkClear();
@@ -29794,9 +29037,9 @@ function App({ importOptions, inkClear }) {
29794
29037
  };
29795
29038
  switch (screen) {
29796
29039
  case "import":
29797
- if (showImportResult) return /* @__PURE__ */ jsx64(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
29040
+ if (showImportResult) return /* @__PURE__ */ jsx58(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
29798
29041
  if (flow && flowStart) {
29799
- return /* @__PURE__ */ jsx64(
29042
+ return /* @__PURE__ */ jsx58(
29800
29043
  FlowScreen,
29801
29044
  {
29802
29045
  state: flow.state,
@@ -29806,12 +29049,12 @@ function App({ importOptions, inkClear }) {
29806
29049
  }
29807
29050
  );
29808
29051
  }
29809
- if (importDefaults === void 0) return /* @__PURE__ */ jsx64(Fragment20, {});
29052
+ if (importDefaults === void 0) return /* @__PURE__ */ jsx58(Fragment19, {});
29810
29053
  if (projectPath === void 0) {
29811
- return /* @__PURE__ */ jsx64(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
29054
+ return /* @__PURE__ */ jsx58(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
29812
29055
  }
29813
29056
  if (tokensPath === void 0) {
29814
- return /* @__PURE__ */ jsx64(
29057
+ return /* @__PURE__ */ jsx58(
29815
29058
  TokenInputScreen,
29816
29059
  {
29817
29060
  initialPath: importDefaults.tokenFile,
@@ -29821,7 +29064,7 @@ function App({ importOptions, inkClear }) {
29821
29064
  );
29822
29065
  }
29823
29066
  if (scannedFiles === void 0) {
29824
- return /* @__PURE__ */ jsx64(
29067
+ return /* @__PURE__ */ jsx58(
29825
29068
  PathValidationScreen,
29826
29069
  {
29827
29070
  projectPath,
@@ -29833,10 +29076,10 @@ function App({ importOptions, inkClear }) {
29833
29076
  }
29834
29077
  if (extractionRun) {
29835
29078
  if (extraction?.status === "done" && !extraction.result.ok) {
29836
- return /* @__PURE__ */ jsx64(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
29079
+ return /* @__PURE__ */ jsx58(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
29837
29080
  }
29838
29081
  if (extraction?.status === "running") {
29839
- return /* @__PURE__ */ jsx64(
29082
+ return /* @__PURE__ */ jsx58(
29840
29083
  ExtractionScreen,
29841
29084
  {
29842
29085
  progress: extraction.progress,
@@ -29845,14 +29088,14 @@ function App({ importOptions, inkClear }) {
29845
29088
  }
29846
29089
  );
29847
29090
  }
29848
- return /* @__PURE__ */ jsx64(Fragment20, {});
29091
+ return /* @__PURE__ */ jsx58(Fragment19, {});
29849
29092
  }
29850
29093
  if (scopeRun && scopeFlow) {
29851
29094
  if (scopeFlow.status === "failed") {
29852
- return /* @__PURE__ */ jsx64(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
29095
+ return /* @__PURE__ */ jsx58(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
29853
29096
  }
29854
29097
  if (scopeFlow.status === "deciding") {
29855
- return /* @__PURE__ */ jsx64(
29098
+ return /* @__PURE__ */ jsx58(
29856
29099
  ScopeGateScreen,
29857
29100
  {
29858
29101
  components: scopeFlow.load.components,
@@ -29862,7 +29105,7 @@ function App({ importOptions, inkClear }) {
29862
29105
  );
29863
29106
  }
29864
29107
  if (generation?.status === "done" && !generation.result.ok) {
29865
- return /* @__PURE__ */ jsx64(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
29108
+ return /* @__PURE__ */ jsx58(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
29866
29109
  }
29867
29110
  if (generation?.status === "running") {
29868
29111
  const hasRawTokens = scopeRun.input.rawTokensPath !== "";
@@ -29870,7 +29113,7 @@ function App({ importOptions, inkClear }) {
29870
29113
  hasRawTokens,
29871
29114
  mapTokensEligible: generation.progress.mapTokensEligible
29872
29115
  });
29873
- return /* @__PURE__ */ jsx64(
29116
+ return /* @__PURE__ */ jsx58(
29874
29117
  GenerationScreen,
29875
29118
  {
29876
29119
  progress: generation.progress,
@@ -29882,10 +29125,10 @@ function App({ importOptions, inkClear }) {
29882
29125
  }
29883
29126
  );
29884
29127
  }
29885
- return /* @__PURE__ */ jsx64(Fragment20, {});
29128
+ return /* @__PURE__ */ jsx58(Fragment19, {});
29886
29129
  }
29887
29130
  if (pendingLaunch?.cached) {
29888
- return /* @__PURE__ */ jsx64(
29131
+ return /* @__PURE__ */ jsx58(
29889
29132
  TokenReuseScreen,
29890
29133
  {
29891
29134
  tokensPath: pendingLaunch.cached.tokensPath,
@@ -29896,7 +29139,7 @@ function App({ importOptions, inkClear }) {
29896
29139
  }
29897
29140
  );
29898
29141
  }
29899
- return /* @__PURE__ */ jsx64(
29142
+ return /* @__PURE__ */ jsx58(
29900
29143
  CredentialsScreen,
29901
29144
  {
29902
29145
  initial: importDefaults.credentials,
@@ -29905,19 +29148,17 @@ function App({ importOptions, inkClear }) {
29905
29148
  }
29906
29149
  );
29907
29150
  case "help":
29908
- return /* @__PURE__ */ jsx64(HelpScreen, { onDone: goToStart });
29909
- case "upgrade":
29910
- return /* @__PURE__ */ jsx64(UpgradeScreen, { onDone: goToStart });
29151
+ return /* @__PURE__ */ jsx58(HelpScreen, { onDone: goToStart });
29911
29152
  case "settings":
29912
- return /* @__PURE__ */ jsx64(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
29153
+ return /* @__PURE__ */ jsx58(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
29913
29154
  case "settings-configuration":
29914
- return /* @__PURE__ */ jsx64(ConfigurationScreen, { onDone: goToSettings });
29155
+ return /* @__PURE__ */ jsx58(ConfigurationScreen, { onDone: goToSettings });
29915
29156
  case "settings-opt-in-analytics":
29916
- return /* @__PURE__ */ jsx64(OptInAnalyticsScreen, { onDone: goToSettings });
29157
+ return /* @__PURE__ */ jsx58(OptInAnalyticsScreen, { onDone: goToSettings });
29917
29158
  case "settings-debug-mode":
29918
- return /* @__PURE__ */ jsx64(DebugModeScreen, { onDone: goToSettings });
29159
+ return /* @__PURE__ */ jsx58(DebugModeScreen, { onDone: goToSettings });
29919
29160
  case "start":
29920
- return /* @__PURE__ */ jsx64(HomeScreen, { onNavigate: setScreen });
29161
+ return /* @__PURE__ */ jsx58(HomeScreen, { onNavigate: setScreen });
29921
29162
  }
29922
29163
  }
29923
29164
  async function runApp(renderApp, importOptions) {
@@ -29925,7 +29166,7 @@ async function runApp(renderApp, importOptions) {
29925
29166
  instance.clear?.();
29926
29167
  process.stdout.write("\x1B[H\x1B[0J");
29927
29168
  };
29928
- const instance = renderApp(/* @__PURE__ */ jsx64(App, { importOptions, inkClear }));
29169
+ const instance = renderApp(/* @__PURE__ */ jsx58(App, { importOptions, inkClear }));
29929
29170
  await instance.waitUntilExit();
29930
29171
  }
29931
29172
  export {