@contentful/experience-design-system-cli 2.37.1-dev-build-f22bf3b7.0 → 2.37.1-dev-build-2582b468.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
@@ -28565,44 +28565,68 @@ function SettingsScreen({
28565
28565
 
28566
28566
  // packages/experience-design-system-cli/src/tui/settings/configuration/ConfigurationScreen.tsx
28567
28567
  import { useState as useState33 } from "react";
28568
- import { Box as Box48, Text as Text51, useInput as useInput14 } from "ink";
28568
+ import { Box as Box48, Text as Text51, useInput as useInput13 } from "ink";
28569
28569
 
28570
28570
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
28571
- import { useEffect as useEffect23, useRef as useRef13, useState as useState31 } from "react";
28571
+ import { useEffect as useEffect23, useState as useState31 } from "react";
28572
28572
  import { Box as Box46, Text as Text49, useInput as useInput12 } from "ink";
28573
28573
  init_debug_store();
28574
28574
 
28575
- // packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
28575
+ // packages/experience-design-system-cli/src/tui/settings/shared/v1-store.ts
28576
28576
  init_config();
28577
- import { existsSync as existsSync10 } from "node:fs";
28578
- function diffSnapshots(before, after) {
28579
- const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
28580
- const changed_fields = names.filter((name) => before[name] !== after[name]);
28581
- return { changed: changed_fields.length > 0, changed_fields };
28582
- }
28583
- var DEFAULT_TRAIL_LIMIT = 30;
28584
- function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
28585
- const actions = [];
28586
- return {
28587
- record(action) {
28588
- actions.push(action);
28589
- if (actions.length > limit) actions.shift();
28590
- },
28591
- entries: () => [...actions]
28592
- };
28577
+ var readV1Store = readSettings2;
28578
+ var writeV1Store = writeSettings2;
28579
+
28580
+ // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-store.ts
28581
+ var AGENT_LABELS = {
28582
+ claude: "Claude Code",
28583
+ codex: "OpenAI Codex",
28584
+ opencode: "OpenCode",
28585
+ cursor: "Cursor",
28586
+ copilot: "GitHub Copilot"
28587
+ };
28588
+ var asString = (value) => typeof value === "string" ? value : "";
28589
+ function emptyAgents() {
28590
+ return Object.fromEntries(AGENT_NAMES.map((name) => [name, { model: "", binary: "" }]));
28593
28591
  }
28594
- var MIN_SECRET_LENGTH = 6;
28595
- function scrubError(error, secrets) {
28596
- let message = error instanceof Error ? error.message : String(error);
28597
- for (const secret of secrets) {
28598
- if (secret.length < MIN_SECRET_LENGTH) continue;
28599
- for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
28592
+ async function readAgentConfig() {
28593
+ const store = await readV1Store();
28594
+ const stored = asString(store["agent"]);
28595
+ const defaultChosen = isAgentName(stored);
28596
+ const defaultAgent = defaultChosen ? stored : DEFAULT_AGENT_NAME;
28597
+ const agents = emptyAgents();
28598
+ const saved = store["agents"];
28599
+ if (saved && typeof saved === "object") {
28600
+ for (const name of AGENT_NAMES) {
28601
+ const entry = saved[name];
28602
+ if (entry && typeof entry === "object") {
28603
+ const fields2 = entry;
28604
+ agents[name] = { model: asString(fields2["model"]), binary: asString(fields2["binary"]) };
28605
+ }
28606
+ }
28600
28607
  }
28601
- return message;
28608
+ const legacyModel = asString(store["agentModel"]);
28609
+ if (legacyModel && !agents[defaultAgent].model)
28610
+ agents[defaultAgent] = { ...agents[defaultAgent], model: legacyModel };
28611
+ return { defaultAgent, defaultChosen, agents };
28602
28612
  }
28603
- function describeSettingsFile() {
28604
- const path5 = configFilePath2();
28605
- return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
28613
+ async function writeAgentConfig(config) {
28614
+ const existing = await readV1Store();
28615
+ const merged = { ...existing };
28616
+ const agents = {};
28617
+ for (const name of AGENT_NAMES) {
28618
+ const model = config.agents[name].model.trim();
28619
+ const binary = config.agents[name].binary.trim();
28620
+ if (model || binary) agents[name] = { ...model ? { model } : {}, ...binary ? { binary } : {} };
28621
+ }
28622
+ const defaultModel = config.defaultChosen ? agents[config.defaultAgent]?.model : void 0;
28623
+ if (config.defaultChosen) merged["agent"] = config.defaultAgent;
28624
+ else delete merged["agent"];
28625
+ if (defaultModel) merged["agentModel"] = defaultModel;
28626
+ else delete merged["agentModel"];
28627
+ if (Object.keys(agents).length > 0) merged["agents"] = agents;
28628
+ else delete merged["agents"];
28629
+ await writeV1Store(merged);
28606
28630
  }
28607
28631
 
28608
28632
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
@@ -28808,94 +28832,6 @@ async function withBinaryEnv(name, binary, run) {
28808
28832
  }
28809
28833
  }
28810
28834
 
28811
- // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-debug.ts
28812
- function agentSnapshot(config) {
28813
- const snapshot = { default_agent: config.defaultAgent };
28814
- for (const name of AGENT_NAMES) {
28815
- snapshot[`${name}.model`] = config.agents[name].model;
28816
- snapshot[`${name}.binary`] = config.agents[name].binary;
28817
- }
28818
- return snapshot;
28819
- }
28820
- function environmentFrom(checks, savedBinary, envValue) {
28821
- const path5 = checks.find((check) => check.step === "path");
28822
- const version = checks.find((check) => check.step === "version");
28823
- const overridden = envValue !== void 0 && envValue !== "" && envValue !== savedBinary.trim();
28824
- return {
28825
- found: path5?.ok === true,
28826
- resolved_path: path5?.ok ? path5.detail : "",
28827
- version: version?.ok ? version.detail : "",
28828
- env_override: overridden ? envValue : ""
28829
- };
28830
- }
28831
- async function describeAgents(config) {
28832
- const entries = await Promise.all(
28833
- AGENT_NAMES.map(async (name) => {
28834
- const saved = config.agents[name].binary;
28835
- const checks = await inspectAgent(name, saved);
28836
- return [name, environmentFrom(checks, saved, process.env[`EDS_AGENT_BINARY_${name.toUpperCase()}`])];
28837
- })
28838
- );
28839
- return Object.fromEntries(entries);
28840
- }
28841
-
28842
- // packages/experience-design-system-cli/src/tui/settings/shared/v1-store.ts
28843
- init_config();
28844
- var readV1Store = readSettings2;
28845
- var writeV1Store = writeSettings2;
28846
-
28847
- // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-store.ts
28848
- var AGENT_LABELS = {
28849
- claude: "Claude Code",
28850
- codex: "OpenAI Codex",
28851
- opencode: "OpenCode",
28852
- cursor: "Cursor",
28853
- copilot: "GitHub Copilot"
28854
- };
28855
- var asString = (value) => typeof value === "string" ? value : "";
28856
- function emptyAgents() {
28857
- return Object.fromEntries(AGENT_NAMES.map((name) => [name, { model: "", binary: "" }]));
28858
- }
28859
- async function readAgentConfig() {
28860
- const store = await readV1Store();
28861
- const stored = asString(store["agent"]);
28862
- const defaultChosen = isAgentName(stored);
28863
- const defaultAgent = defaultChosen ? stored : DEFAULT_AGENT_NAME;
28864
- const agents = emptyAgents();
28865
- const saved = store["agents"];
28866
- if (saved && typeof saved === "object") {
28867
- for (const name of AGENT_NAMES) {
28868
- const entry = saved[name];
28869
- if (entry && typeof entry === "object") {
28870
- const fields2 = entry;
28871
- agents[name] = { model: asString(fields2["model"]), binary: asString(fields2["binary"]) };
28872
- }
28873
- }
28874
- }
28875
- const legacyModel = asString(store["agentModel"]);
28876
- if (legacyModel && !agents[defaultAgent].model)
28877
- agents[defaultAgent] = { ...agents[defaultAgent], model: legacyModel };
28878
- return { defaultAgent, defaultChosen, agents };
28879
- }
28880
- async function writeAgentConfig(config) {
28881
- const existing = await readV1Store();
28882
- const merged = { ...existing };
28883
- const agents = {};
28884
- for (const name of AGENT_NAMES) {
28885
- const model = config.agents[name].model.trim();
28886
- const binary = config.agents[name].binary.trim();
28887
- if (model || binary) agents[name] = { ...model ? { model } : {}, ...binary ? { binary } : {} };
28888
- }
28889
- const defaultModel = config.defaultChosen ? agents[config.defaultAgent]?.model : void 0;
28890
- if (config.defaultChosen) merged["agent"] = config.defaultAgent;
28891
- else delete merged["agent"];
28892
- if (defaultModel) merged["agentModel"] = defaultModel;
28893
- else delete merged["agentModel"];
28894
- if (Object.keys(agents).length > 0) merged["agents"] = agents;
28895
- else delete merged["agents"];
28896
- await writeV1Store(merged);
28897
- }
28898
-
28899
28835
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
28900
28836
  import { useEffect as useEffect22, useState as useState30 } from "react";
28901
28837
  import { Box as Box45, Text as Text48 } from "ink";
@@ -29097,8 +29033,7 @@ function AgentDetail({
29097
29033
  name,
29098
29034
  config,
29099
29035
  setConfig,
29100
- onBack,
29101
- record: record3
29036
+ onBack
29102
29037
  }) {
29103
29038
  const settings = config.agents[name];
29104
29039
  const [saving, setSaving] = useState30(false);
@@ -29121,12 +29056,10 @@ function AgentDetail({
29121
29056
  setNotice(null);
29122
29057
  writeAgentConfig(config).then(() => {
29123
29058
  applyBinaryOverrides(config);
29124
- record3(`saved ${name}`);
29125
29059
  setNotice({ kind: "success", text: `Saved: ${AGENT_LABELS[name]} settings are written to config.json` });
29126
- }).catch((err) => {
29127
- record3(`saving ${name} failed`, err);
29128
- setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` });
29129
- }).finally(() => setSaving(false));
29060
+ }).catch(
29061
+ (err) => setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` })
29062
+ ).finally(() => setSaving(false));
29130
29063
  };
29131
29064
  const runTest = () => {
29132
29065
  setTesting(true);
@@ -29134,15 +29067,12 @@ function AgentDetail({
29134
29067
  testAgent(name, settings.binary, settings.model).then((result) => {
29135
29068
  setChecks(result);
29136
29069
  const outcome = testOutcome(result);
29137
- if (!outcome || !outcome.ok)
29138
- record3(`test of ${name} failed: ${outcome?.text ?? "the agent could not be started"}`);
29139
29070
  setNotice(
29140
29071
  outcome ? { kind: outcome.ok ? "success" : "error", text: outcome.text } : { kind: "error", text: "Test not run: the agent could not be started (see Status)" }
29141
29072
  );
29142
- }).catch((err) => {
29143
- record3(`test of ${name} could not run`, err);
29144
- setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` });
29145
- }).finally(() => setTesting(false));
29073
+ }).catch(
29074
+ (err) => setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` })
29075
+ ).finally(() => setTesting(false));
29146
29076
  };
29147
29077
  const action = {
29148
29078
  label: "Run test",
@@ -29163,7 +29093,6 @@ function AgentDetail({
29163
29093
  onChange: (key, value) => {
29164
29094
  setConfig({ ...config, agents: { ...config.agents, [name]: { ...settings, [key]: value } } });
29165
29095
  setNotice(null);
29166
- record3(`edited ${name}.${key}`);
29167
29096
  },
29168
29097
  onSave: save,
29169
29098
  onQuit: onBack,
@@ -29190,12 +29119,6 @@ function AgentsScreen({ onDone }) {
29190
29119
  const [saving, setSaving] = useState31(false);
29191
29120
  const [loadError, setLoadError] = useState31(null);
29192
29121
  const [checks, setChecks] = useState31({});
29193
- const visit = useRef13({
29194
- trail: createTrail(),
29195
- before: void 0,
29196
- environment: void 0,
29197
- error: ""
29198
- }).current;
29199
29122
  const inspectAll = (loaded) => {
29200
29123
  for (const name of AGENT_NAMES) {
29201
29124
  void inspectAgent(name, loaded.agents[name].binary).then(
@@ -29207,38 +29130,14 @@ function AgentsScreen({ onDone }) {
29207
29130
  readAgentConfig().then((loaded) => {
29208
29131
  setConfig(loaded);
29209
29132
  inspectAll(loaded);
29210
- visit.before = agentSnapshot(loaded);
29211
29133
  startDebugRun({
29212
29134
  flow: "settings/agents",
29213
29135
  step: "01-agents",
29214
29136
  menuOption: "Configuration > Agents",
29215
- inputs: { ...visit.before, default_chosen: loaded.defaultChosen ?? false }
29137
+ inputs: { default_agent: loaded.defaultAgent }
29216
29138
  });
29217
- void describeAgents(loaded).then((found) => {
29218
- visit.environment = found;
29219
- });
29220
- }).catch((err) => {
29221
- visit.error = scrubError(err, []);
29222
- startDebugRun({ flow: "settings/agents", step: "01-agents", menuOption: "Configuration > Agents", inputs: {} });
29223
- setLoadError(visit.error);
29224
- });
29139
+ }).catch((err) => setLoadError(err instanceof Error ? err.message : String(err)));
29225
29140
  }, []);
29226
- const endVisit = (current) => {
29227
- const after = current ? agentSnapshot(current) : void 0;
29228
- const change = visit.before && after ? diffSnapshots(visit.before, after) : { changed: false, changed_fields: [] };
29229
- void finishDebugRun({
29230
- outputs: {
29231
- ...after ?? {},
29232
- ...change,
29233
- actions: visit.trail.entries(),
29234
- // Missing only when the user left before the probes finished.
29235
- ...visit.environment ? { agents: visit.environment } : {},
29236
- ...visit.error ? { error: visit.error } : {}
29237
- },
29238
- status: visit.error ? "error" : "success",
29239
- exitMethod: change.changed ? "saved" : "discarded"
29240
- });
29241
- };
29242
29141
  const makeDefault = (name) => {
29243
29142
  if (!config || saving) return;
29244
29143
  if (name === config.defaultAgent) {
@@ -29250,16 +29149,15 @@ function AgentsScreen({ onDone }) {
29250
29149
  writeAgentConfig({ ...config, defaultAgent: name, defaultChosen: true }).then(() => {
29251
29150
  setConfig((current) => current ? { ...current, defaultAgent: name, defaultChosen: true } : current);
29252
29151
  setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[name]}` });
29253
- visit.trail.record(`made ${name} the default`);
29254
- }).catch((err) => {
29255
- visit.error = scrubError(err, []);
29256
- visit.trail.record(`making ${name} the default failed`);
29257
- setNotice({ kind: "error", text: `Default agent not changed: ${visit.error}` });
29258
- }).finally(() => setSaving(false));
29152
+ }).catch(
29153
+ (err) => setNotice({
29154
+ kind: "error",
29155
+ text: `Default agent not changed: ${err instanceof Error ? err.message : String(err)}`
29156
+ })
29157
+ ).finally(() => setSaving(false));
29259
29158
  };
29260
29159
  useInput12((input, key) => {
29261
29160
  if (loadError && (key.escape || input === "q")) {
29262
- endVisit(null);
29263
29161
  onDone();
29264
29162
  return;
29265
29163
  }
@@ -29284,7 +29182,7 @@ function AgentsScreen({ onDone }) {
29284
29182
  return;
29285
29183
  }
29286
29184
  if (key.escape || input === "q") {
29287
- endVisit(config);
29185
+ void finishDebugRun({ outputs: { default_agent: config.defaultAgent }, status: "success", exitMethod: "saved" });
29288
29186
  onDone();
29289
29187
  }
29290
29188
  });
@@ -29309,10 +29207,6 @@ function AgentsScreen({ onDone }) {
29309
29207
  name: open,
29310
29208
  config,
29311
29209
  setConfig,
29312
- record: (action, error) => {
29313
- visit.trail.record(action);
29314
- if (error !== void 0) visit.error = scrubError(error, []);
29315
- },
29316
29210
  onBack: () => {
29317
29211
  setOpen(null);
29318
29212
  void readAgentConfig().then((saved) => {
@@ -29379,8 +29273,8 @@ function AgentsScreen({ onDone }) {
29379
29273
  }
29380
29274
 
29381
29275
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
29382
- import { useEffect as useEffect24, useRef as useRef14, useState as useState32 } from "react";
29383
- import { Box as Box47, Text as Text50, useInput as useInput13 } from "ink";
29276
+ import { useEffect as useEffect24, useState as useState32 } from "react";
29277
+ import { Box as Box47, Text as Text50 } from "ink";
29384
29278
  init_debug_store();
29385
29279
 
29386
29280
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/project-store.ts
@@ -29409,7 +29303,7 @@ async function writeCredentials(config) {
29409
29303
  }
29410
29304
 
29411
29305
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
29412
- import { Fragment as Fragment19, jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
29306
+ import { jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
29413
29307
  var FIELDS2 = [
29414
29308
  { key: "spaceId", label: "Space ID" },
29415
29309
  { key: "environmentId", label: "Environment ID" },
@@ -29430,94 +29324,45 @@ function debugFields(config) {
29430
29324
  contentful_base_dir: config?.contentfulBaseDir ?? ""
29431
29325
  };
29432
29326
  }
29433
- var snapshotOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
29434
29327
  var valuesOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
29435
29328
  function ProjectScreen({ onDone }) {
29436
29329
  const [config, setConfig] = useState32(null);
29437
29330
  const [saving, setSaving] = useState32(false);
29438
29331
  const [notice, setNotice] = useState32(null);
29439
- const [loadError, setLoadError] = useState32(null);
29440
- const visit = useRef14({
29441
- trail: createTrail(),
29442
- before: void 0,
29443
- persisted: void 0,
29444
- error: ""
29445
- }).current;
29446
- const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
29332
+ const [lastSaved, setLastSaved] = useState32(null);
29447
29333
  useEffect24(() => {
29448
- readCredentials().then((cfg) => {
29334
+ void readCredentials().then((cfg) => {
29449
29335
  setConfig(cfg);
29450
- visit.before = snapshotOf(cfg);
29451
- visit.persisted = visit.before;
29452
- startDebugRun({
29453
- flow: "settings/contentful-configuration",
29454
- step: "01-configuration",
29455
- menuOption: "Configuration > Project",
29456
- inputs: { ...debugFields(cfg), settings_file: describeSettingsFile() }
29457
- });
29458
- }).catch((err) => {
29459
- visit.error = scrubError(err, []);
29460
29336
  startDebugRun({
29461
29337
  flow: "settings/contentful-configuration",
29462
29338
  step: "01-configuration",
29463
29339
  menuOption: "Configuration > Project",
29464
- inputs: { settings_file: describeSettingsFile() }
29340
+ inputs: debugFields(cfg)
29465
29341
  });
29466
- setLoadError(visit.error);
29467
29342
  });
29468
29343
  }, []);
29469
- const endVisit = (current) => {
29470
- const onScreen = current ? snapshotOf(current) : void 0;
29471
- const change = visit.before && visit.persisted ? diffSnapshots(visit.before, visit.persisted) : { changed: false, changed_fields: [] };
29472
- const unsaved = visit.persisted && onScreen ? diffSnapshots(visit.persisted, onScreen) : { changed: false, changed_fields: [] };
29473
- void finishDebugRun({
29474
- outputs: {
29475
- ...debugFields(current),
29476
- ...change,
29477
- unsaved_edits: unsaved.changed_fields,
29478
- actions: visit.trail.entries(),
29479
- ...visit.error ? { error: visit.error } : {}
29480
- },
29481
- status: visit.error ? "error" : "success",
29482
- exitMethod: change.changed ? "saved" : "discarded"
29483
- });
29484
- };
29485
- useInput13((input, key) => {
29486
- if (!config && loadError && (key.escape || input === "q")) {
29487
- endVisit(null);
29488
- onDone();
29489
- }
29490
- });
29491
29344
  if (!config) {
29492
29345
  return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29493
29346
  /* @__PURE__ */ jsx59(Text50, { bold: true, children: "Project" }),
29494
29347
  /* @__PURE__ */ jsx59(Text50, { children: " " }),
29495
- loadError ? /* @__PURE__ */ jsxs48(Fragment19, { children: [
29496
- /* @__PURE__ */ jsxs48(Text50, { color: PALETTE.error, children: [
29497
- "\u2717 Could not read the settings: ",
29498
- loadError
29499
- ] }),
29500
- /* @__PURE__ */ jsx59(Text50, { children: " " }),
29501
- /* @__PURE__ */ jsx59(ControlHints, { hints: [{ keys: "Esc/q", label: "back" }] })
29502
- ] }) : /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
29348
+ /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
29503
29349
  ] });
29504
29350
  }
29505
29351
  const save = () => {
29506
29352
  setSaving(true);
29507
29353
  setNotice(null);
29508
29354
  writeCredentials(config).then(() => {
29509
- visit.persisted = snapshotOf(config);
29510
- visit.trail.record("saved");
29355
+ setLastSaved(config);
29511
29356
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
29512
29357
  setNotice({ kind: "success", text: "Project settings saved" });
29513
29358
  }).catch((err) => {
29514
- visit.error = scrub(err);
29515
- visit.trail.record("save failed");
29516
29359
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
29517
29360
  }).finally(() => setSaving(false));
29518
29361
  };
29519
29362
  const quit = () => {
29520
- endVisit(config);
29363
+ void finishDebugRun(
29364
+ lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
29365
+ );
29521
29366
  onDone();
29522
29367
  };
29523
29368
  return /* @__PURE__ */ jsx59(
@@ -29530,7 +29375,6 @@ function ProjectScreen({ onDone }) {
29530
29375
  onChange: (key, value) => {
29531
29376
  setConfig({ ...config, [key]: value });
29532
29377
  setNotice(null);
29533
- visit.trail.record(`edited ${key}`);
29534
29378
  },
29535
29379
  onSave: save,
29536
29380
  onQuit: quit,
@@ -29554,7 +29398,7 @@ function ConfigurationScreen({ onDone }) {
29554
29398
  const [focus, setFocus] = useState33(0);
29555
29399
  const [open, setOpen] = useState33(null);
29556
29400
  const close = () => setOpen(null);
29557
- useInput14((input, key) => {
29401
+ useInput13((input, key) => {
29558
29402
  if (open) return;
29559
29403
  if (key.upArrow) {
29560
29404
  setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
@@ -29596,7 +29440,7 @@ function ConfigurationScreen({ onDone }) {
29596
29440
 
29597
29441
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
29598
29442
  import { useEffect as useEffect25, useState as useState34 } from "react";
29599
- import { Box as Box49, Text as Text52, useInput as useInput15 } from "ink";
29443
+ import { Box as Box49, Text as Text52, useInput as useInput14 } from "ink";
29600
29444
 
29601
29445
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
29602
29446
  async function readAnalyticsSetting() {
@@ -29615,7 +29459,7 @@ async function writeAnalyticsSetting(setting) {
29615
29459
 
29616
29460
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
29617
29461
  init_debug_store();
29618
- import { Fragment as Fragment20, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
29462
+ import { Fragment as Fragment19, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
29619
29463
  function OptInAnalyticsScreen({ onDone }) {
29620
29464
  const [loading, setLoading] = useState34(true);
29621
29465
  const [enabled, setEnabled] = useState34(true);
@@ -29631,7 +29475,7 @@ function OptInAnalyticsScreen({ onDone }) {
29631
29475
  });
29632
29476
  });
29633
29477
  }, []);
29634
- useInput15((input, key) => {
29478
+ useInput14((input, key) => {
29635
29479
  if (loading) return;
29636
29480
  if (key.return || input === " ") {
29637
29481
  setEnabled((current) => {
@@ -29649,7 +29493,7 @@ function OptInAnalyticsScreen({ onDone }) {
29649
29493
  return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
29650
29494
  /* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
29651
29495
  /* @__PURE__ */ jsx61(Text52, { children: " " }),
29652
- loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment20, { children: [
29496
+ loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment19, { children: [
29653
29497
  /* @__PURE__ */ jsxs50(Text52, { children: [
29654
29498
  "Share anonymous usage data:",
29655
29499
  " ",
@@ -29674,7 +29518,7 @@ function OptInAnalyticsScreen({ onDone }) {
29674
29518
 
29675
29519
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
29676
29520
  import { useEffect as useEffect26, useState as useState35 } from "react";
29677
- import { Box as Box50, Text as Text53, useInput as useInput16 } from "ink";
29521
+ import { Box as Box50, Text as Text53, useInput as useInput15 } from "ink";
29678
29522
  init_debug_mode_store();
29679
29523
  init_debug_store();
29680
29524
  import { jsx as jsx62, jsxs as jsxs51 } from "react/jsx-runtime";
@@ -29693,7 +29537,7 @@ function DebugModeScreen({ onDone }) {
29693
29537
  });
29694
29538
  });
29695
29539
  }, []);
29696
- useInput16((input, key) => {
29540
+ useInput15((input, key) => {
29697
29541
  if (loading) return;
29698
29542
  if (key.return || input === " ") {
29699
29543
  setEnabled((current) => {
@@ -29730,7 +29574,7 @@ function DebugModeScreen({ onDone }) {
29730
29574
  }
29731
29575
 
29732
29576
  // packages/experience-design-system-cli/app.tsx
29733
- import { Fragment as Fragment21, jsx as jsx63 } from "react/jsx-runtime";
29577
+ import { Fragment as Fragment20, jsx as jsx63 } from "react/jsx-runtime";
29734
29578
  function App({ importOptions, inkClear }) {
29735
29579
  const [screen, setScreen] = useState36("start");
29736
29580
  const [importExitCode, setImportExitCode] = useState36();
@@ -29899,7 +29743,7 @@ function App({ importOptions, inkClear }) {
29899
29743
  }
29900
29744
  );
29901
29745
  }
29902
- if (importDefaults === void 0) return /* @__PURE__ */ jsx63(Fragment21, {});
29746
+ if (importDefaults === void 0) return /* @__PURE__ */ jsx63(Fragment20, {});
29903
29747
  if (projectPath === void 0) {
29904
29748
  return /* @__PURE__ */ jsx63(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
29905
29749
  }
@@ -29938,7 +29782,7 @@ function App({ importOptions, inkClear }) {
29938
29782
  }
29939
29783
  );
29940
29784
  }
29941
- return /* @__PURE__ */ jsx63(Fragment21, {});
29785
+ return /* @__PURE__ */ jsx63(Fragment20, {});
29942
29786
  }
29943
29787
  if (scopeRun && scopeFlow) {
29944
29788
  if (scopeFlow.status === "failed") {
@@ -29975,7 +29819,7 @@ function App({ importOptions, inkClear }) {
29975
29819
  }
29976
29820
  );
29977
29821
  }
29978
- return /* @__PURE__ */ jsx63(Fragment21, {});
29822
+ return /* @__PURE__ */ jsx63(Fragment20, {});
29979
29823
  }
29980
29824
  if (pendingLaunch?.cached) {
29981
29825
  return /* @__PURE__ */ jsx63(
package/dist/index.js CHANGED
@@ -33084,45 +33084,6 @@ var init_PageContainer3 = __esm({
33084
33084
  }
33085
33085
  });
33086
33086
 
33087
- // packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
33088
- import { existsSync as existsSync11 } from "node:fs";
33089
- function diffSnapshots(before, after) {
33090
- const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
33091
- const changed_fields = names.filter((name) => before[name] !== after[name]);
33092
- return { changed: changed_fields.length > 0, changed_fields };
33093
- }
33094
- function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
33095
- const actions = [];
33096
- return {
33097
- record(action) {
33098
- actions.push(action);
33099
- if (actions.length > limit) actions.shift();
33100
- },
33101
- entries: () => [...actions]
33102
- };
33103
- }
33104
- function scrubError(error, secrets) {
33105
- let message = error instanceof Error ? error.message : String(error);
33106
- for (const secret of secrets) {
33107
- if (secret.length < MIN_SECRET_LENGTH) continue;
33108
- for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
33109
- }
33110
- return message;
33111
- }
33112
- function describeSettingsFile() {
33113
- const path5 = configFilePath2();
33114
- return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync11(path5) };
33115
- }
33116
- var DEFAULT_TRAIL_LIMIT, MIN_SECRET_LENGTH;
33117
- var init_debug_trail = __esm({
33118
- "packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts"() {
33119
- "use strict";
33120
- init_config();
33121
- DEFAULT_TRAIL_LIMIT = 30;
33122
- MIN_SECRET_LENGTH = 6;
33123
- }
33124
- });
33125
-
33126
33087
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
33127
33088
  import { execFile as execFile2 } from "node:child_process";
33128
33089
  import { access as access6, constants } from "node:fs/promises";
@@ -33333,44 +33294,6 @@ var init_agent_status = __esm({
33333
33294
  }
33334
33295
  });
33335
33296
 
33336
- // packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-debug.ts
33337
- function agentSnapshot(config) {
33338
- const snapshot = { default_agent: config.defaultAgent };
33339
- for (const name of AGENT_NAMES) {
33340
- snapshot[`${name}.model`] = config.agents[name].model;
33341
- snapshot[`${name}.binary`] = config.agents[name].binary;
33342
- }
33343
- return snapshot;
33344
- }
33345
- function environmentFrom(checks, savedBinary, envValue) {
33346
- const path5 = checks.find((check) => check.step === "path");
33347
- const version = checks.find((check) => check.step === "version");
33348
- const overridden = envValue !== void 0 && envValue !== "" && envValue !== savedBinary.trim();
33349
- return {
33350
- found: path5?.ok === true,
33351
- resolved_path: path5?.ok ? path5.detail : "",
33352
- version: version?.ok ? version.detail : "",
33353
- env_override: overridden ? envValue : ""
33354
- };
33355
- }
33356
- async function describeAgents(config) {
33357
- const entries = await Promise.all(
33358
- AGENT_NAMES.map(async (name) => {
33359
- const saved = config.agents[name].binary;
33360
- const checks = await inspectAgent(name, saved);
33361
- return [name, environmentFrom(checks, saved, process.env[`EDS_AGENT_BINARY_${name.toUpperCase()}`])];
33362
- })
33363
- );
33364
- return Object.fromEntries(entries);
33365
- }
33366
- var init_agent_debug = __esm({
33367
- "packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-debug.ts"() {
33368
- "use strict";
33369
- init_src4();
33370
- init_agent_status();
33371
- }
33372
- });
33373
-
33374
33297
  // packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx
33375
33298
  import { useState as useState29 } from "react";
33376
33299
  import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
@@ -33562,8 +33485,7 @@ function AgentDetail({
33562
33485
  name,
33563
33486
  config,
33564
33487
  setConfig,
33565
- onBack,
33566
- record: record3
33488
+ onBack
33567
33489
  }) {
33568
33490
  const settings = config.agents[name];
33569
33491
  const [saving, setSaving] = useState30(false);
@@ -33586,12 +33508,10 @@ function AgentDetail({
33586
33508
  setNotice(null);
33587
33509
  writeAgentConfig(config).then(() => {
33588
33510
  applyBinaryOverrides(config);
33589
- record3(`saved ${name}`);
33590
33511
  setNotice({ kind: "success", text: `Saved: ${AGENT_LABELS[name]} settings are written to config.json` });
33591
- }).catch((err) => {
33592
- record3(`saving ${name} failed`, err);
33593
- setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` });
33594
- }).finally(() => setSaving(false));
33512
+ }).catch(
33513
+ (err) => setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` })
33514
+ ).finally(() => setSaving(false));
33595
33515
  };
33596
33516
  const runTest = () => {
33597
33517
  setTesting(true);
@@ -33599,15 +33519,12 @@ function AgentDetail({
33599
33519
  testAgent(name, settings.binary, settings.model).then((result) => {
33600
33520
  setChecks(result);
33601
33521
  const outcome = testOutcome(result);
33602
- if (!outcome || !outcome.ok)
33603
- record3(`test of ${name} failed: ${outcome?.text ?? "the agent could not be started"}`);
33604
33522
  setNotice(
33605
33523
  outcome ? { kind: outcome.ok ? "success" : "error", text: outcome.text } : { kind: "error", text: "Test not run: the agent could not be started (see Status)" }
33606
33524
  );
33607
- }).catch((err) => {
33608
- record3(`test of ${name} could not run`, err);
33609
- setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` });
33610
- }).finally(() => setTesting(false));
33525
+ }).catch(
33526
+ (err) => setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` })
33527
+ ).finally(() => setTesting(false));
33611
33528
  };
33612
33529
  const action = {
33613
33530
  label: "Run test",
@@ -33628,7 +33545,6 @@ function AgentDetail({
33628
33545
  onChange: (key, value) => {
33629
33546
  setConfig({ ...config, agents: { ...config.agents, [name]: { ...settings, [key]: value } } });
33630
33547
  setNotice(null);
33631
- record3(`edited ${name}.${key}`);
33632
33548
  },
33633
33549
  onSave: save,
33634
33550
  onQuit: onBack,
@@ -33662,7 +33578,7 @@ var init_AgentDetail = __esm({
33662
33578
  });
33663
33579
 
33664
33580
  // packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
33665
- import { useEffect as useEffect23, useRef as useRef13, useState as useState31 } from "react";
33581
+ import { useEffect as useEffect23, useState as useState31 } from "react";
33666
33582
  import { Box as Box46, Text as Text49, useInput as useInput12 } from "ink";
33667
33583
  import { Fragment as Fragment18, jsx as jsx58, jsxs as jsxs47 } from "react/jsx-runtime";
33668
33584
  function AgentsScreen({ onDone }) {
@@ -33673,12 +33589,6 @@ function AgentsScreen({ onDone }) {
33673
33589
  const [saving, setSaving] = useState31(false);
33674
33590
  const [loadError, setLoadError] = useState31(null);
33675
33591
  const [checks, setChecks] = useState31({});
33676
- const visit = useRef13({
33677
- trail: createTrail(),
33678
- before: void 0,
33679
- environment: void 0,
33680
- error: ""
33681
- }).current;
33682
33592
  const inspectAll = (loaded) => {
33683
33593
  for (const name of AGENT_NAMES) {
33684
33594
  void inspectAgent(name, loaded.agents[name].binary).then(
@@ -33690,38 +33600,14 @@ function AgentsScreen({ onDone }) {
33690
33600
  readAgentConfig().then((loaded) => {
33691
33601
  setConfig(loaded);
33692
33602
  inspectAll(loaded);
33693
- visit.before = agentSnapshot(loaded);
33694
33603
  startDebugRun({
33695
33604
  flow: "settings/agents",
33696
33605
  step: "01-agents",
33697
33606
  menuOption: "Configuration > Agents",
33698
- inputs: { ...visit.before, default_chosen: loaded.defaultChosen ?? false }
33699
- });
33700
- void describeAgents(loaded).then((found) => {
33701
- visit.environment = found;
33607
+ inputs: { default_agent: loaded.defaultAgent }
33702
33608
  });
33703
- }).catch((err) => {
33704
- visit.error = scrubError(err, []);
33705
- startDebugRun({ flow: "settings/agents", step: "01-agents", menuOption: "Configuration > Agents", inputs: {} });
33706
- setLoadError(visit.error);
33707
- });
33609
+ }).catch((err) => setLoadError(err instanceof Error ? err.message : String(err)));
33708
33610
  }, []);
33709
- const endVisit = (current) => {
33710
- const after = current ? agentSnapshot(current) : void 0;
33711
- const change = visit.before && after ? diffSnapshots(visit.before, after) : { changed: false, changed_fields: [] };
33712
- void finishDebugRun({
33713
- outputs: {
33714
- ...after ?? {},
33715
- ...change,
33716
- actions: visit.trail.entries(),
33717
- // Missing only when the user left before the probes finished.
33718
- ...visit.environment ? { agents: visit.environment } : {},
33719
- ...visit.error ? { error: visit.error } : {}
33720
- },
33721
- status: visit.error ? "error" : "success",
33722
- exitMethod: change.changed ? "saved" : "discarded"
33723
- });
33724
- };
33725
33611
  const makeDefault = (name) => {
33726
33612
  if (!config || saving) return;
33727
33613
  if (name === config.defaultAgent) {
@@ -33733,16 +33619,15 @@ function AgentsScreen({ onDone }) {
33733
33619
  writeAgentConfig({ ...config, defaultAgent: name, defaultChosen: true }).then(() => {
33734
33620
  setConfig((current) => current ? { ...current, defaultAgent: name, defaultChosen: true } : current);
33735
33621
  setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[name]}` });
33736
- visit.trail.record(`made ${name} the default`);
33737
- }).catch((err) => {
33738
- visit.error = scrubError(err, []);
33739
- visit.trail.record(`making ${name} the default failed`);
33740
- setNotice({ kind: "error", text: `Default agent not changed: ${visit.error}` });
33741
- }).finally(() => setSaving(false));
33622
+ }).catch(
33623
+ (err) => setNotice({
33624
+ kind: "error",
33625
+ text: `Default agent not changed: ${err instanceof Error ? err.message : String(err)}`
33626
+ })
33627
+ ).finally(() => setSaving(false));
33742
33628
  };
33743
33629
  useInput12((input, key) => {
33744
33630
  if (loadError && (key.escape || input === "q")) {
33745
- endVisit(null);
33746
33631
  onDone();
33747
33632
  return;
33748
33633
  }
@@ -33767,7 +33652,7 @@ function AgentsScreen({ onDone }) {
33767
33652
  return;
33768
33653
  }
33769
33654
  if (key.escape || input === "q") {
33770
- endVisit(config);
33655
+ void finishDebugRun({ outputs: { default_agent: config.defaultAgent }, status: "success", exitMethod: "saved" });
33771
33656
  onDone();
33772
33657
  }
33773
33658
  });
@@ -33792,10 +33677,6 @@ function AgentsScreen({ onDone }) {
33792
33677
  name: open,
33793
33678
  config,
33794
33679
  setConfig,
33795
- record: (action, error) => {
33796
- visit.trail.record(action);
33797
- if (error !== void 0) visit.error = scrubError(error, []);
33798
- },
33799
33680
  onBack: () => {
33800
33681
  setOpen(null);
33801
33682
  void readAgentConfig().then((saved) => {
@@ -33868,8 +33749,6 @@ var init_AgentsScreen = __esm({
33868
33749
  init_theme();
33869
33750
  init_control_hints();
33870
33751
  init_debug_store();
33871
- init_debug_trail();
33872
- init_agent_debug();
33873
33752
  init_agent_store();
33874
33753
  init_agent_status();
33875
33754
  init_AgentDetail();
@@ -33911,9 +33790,9 @@ var init_project_store = __esm({
33911
33790
  });
33912
33791
 
33913
33792
  // packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
33914
- import { useEffect as useEffect24, useRef as useRef14, useState as useState32 } from "react";
33915
- import { Box as Box47, Text as Text50, useInput as useInput13 } from "ink";
33916
- import { Fragment as Fragment19, jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
33793
+ import { useEffect as useEffect24, useState as useState32 } from "react";
33794
+ import { Box as Box47, Text as Text50 } from "ink";
33795
+ import { jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
33917
33796
  function debugFields(config) {
33918
33797
  return {
33919
33798
  space_id: config?.spaceId ?? "",
@@ -33929,88 +33808,40 @@ function ProjectScreen({ onDone }) {
33929
33808
  const [config, setConfig] = useState32(null);
33930
33809
  const [saving, setSaving] = useState32(false);
33931
33810
  const [notice, setNotice] = useState32(null);
33932
- const [loadError, setLoadError] = useState32(null);
33933
- const visit = useRef14({
33934
- trail: createTrail(),
33935
- before: void 0,
33936
- persisted: void 0,
33937
- error: ""
33938
- }).current;
33939
- const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
33811
+ const [lastSaved, setLastSaved] = useState32(null);
33940
33812
  useEffect24(() => {
33941
- readCredentials().then((cfg) => {
33813
+ void readCredentials().then((cfg) => {
33942
33814
  setConfig(cfg);
33943
- visit.before = snapshotOf(cfg);
33944
- visit.persisted = visit.before;
33945
33815
  startDebugRun({
33946
33816
  flow: "settings/contentful-configuration",
33947
33817
  step: "01-configuration",
33948
33818
  menuOption: "Configuration > Project",
33949
- inputs: { ...debugFields(cfg), settings_file: describeSettingsFile() }
33819
+ inputs: debugFields(cfg)
33950
33820
  });
33951
- }).catch((err) => {
33952
- visit.error = scrubError(err, []);
33953
- startDebugRun({
33954
- flow: "settings/contentful-configuration",
33955
- step: "01-configuration",
33956
- menuOption: "Configuration > Project",
33957
- inputs: { settings_file: describeSettingsFile() }
33958
- });
33959
- setLoadError(visit.error);
33960
33821
  });
33961
33822
  }, []);
33962
- const endVisit = (current) => {
33963
- const onScreen = current ? snapshotOf(current) : void 0;
33964
- const change = visit.before && visit.persisted ? diffSnapshots(visit.before, visit.persisted) : { changed: false, changed_fields: [] };
33965
- const unsaved = visit.persisted && onScreen ? diffSnapshots(visit.persisted, onScreen) : { changed: false, changed_fields: [] };
33966
- void finishDebugRun({
33967
- outputs: {
33968
- ...debugFields(current),
33969
- ...change,
33970
- unsaved_edits: unsaved.changed_fields,
33971
- actions: visit.trail.entries(),
33972
- ...visit.error ? { error: visit.error } : {}
33973
- },
33974
- status: visit.error ? "error" : "success",
33975
- exitMethod: change.changed ? "saved" : "discarded"
33976
- });
33977
- };
33978
- useInput13((input, key) => {
33979
- if (!config && loadError && (key.escape || input === "q")) {
33980
- endVisit(null);
33981
- onDone();
33982
- }
33983
- });
33984
33823
  if (!config) {
33985
33824
  return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
33986
33825
  /* @__PURE__ */ jsx59(Text50, { bold: true, children: "Project" }),
33987
33826
  /* @__PURE__ */ jsx59(Text50, { children: " " }),
33988
- loadError ? /* @__PURE__ */ jsxs48(Fragment19, { children: [
33989
- /* @__PURE__ */ jsxs48(Text50, { color: PALETTE.error, children: [
33990
- "\u2717 Could not read the settings: ",
33991
- loadError
33992
- ] }),
33993
- /* @__PURE__ */ jsx59(Text50, { children: " " }),
33994
- /* @__PURE__ */ jsx59(ControlHints, { hints: [{ keys: "Esc/q", label: "back" }] })
33995
- ] }) : /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
33827
+ /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
33996
33828
  ] });
33997
33829
  }
33998
33830
  const save = () => {
33999
33831
  setSaving(true);
34000
33832
  setNotice(null);
34001
33833
  writeCredentials(config).then(() => {
34002
- visit.persisted = snapshotOf(config);
34003
- visit.trail.record("saved");
33834
+ setLastSaved(config);
34004
33835
  if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
34005
33836
  setNotice({ kind: "success", text: "Project settings saved" });
34006
33837
  }).catch((err) => {
34007
- visit.error = scrub(err);
34008
- visit.trail.record("save failed");
34009
33838
  setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
34010
33839
  }).finally(() => setSaving(false));
34011
33840
  };
34012
33841
  const quit = () => {
34013
- endVisit(config);
33842
+ void finishDebugRun(
33843
+ lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
33844
+ );
34014
33845
  onDone();
34015
33846
  };
34016
33847
  return /* @__PURE__ */ jsx59(
@@ -34023,7 +33854,6 @@ function ProjectScreen({ onDone }) {
34023
33854
  onChange: (key, value) => {
34024
33855
  setConfig({ ...config, [key]: value });
34025
33856
  setNotice(null);
34026
- visit.trail.record(`edited ${key}`);
34027
33857
  },
34028
33858
  onSave: save,
34029
33859
  onQuit: quit,
@@ -34032,14 +33862,12 @@ function ProjectScreen({ onDone }) {
34032
33862
  }
34033
33863
  );
34034
33864
  }
34035
- var FIELDS2, snapshotOf, valuesOf;
33865
+ var FIELDS2, valuesOf;
34036
33866
  var init_ProjectScreen = __esm({
34037
33867
  "packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx"() {
34038
33868
  "use strict";
34039
33869
  init_theme();
34040
- init_control_hints();
34041
33870
  init_debug_store();
34042
- init_debug_trail();
34043
33871
  init_FieldForm();
34044
33872
  init_project_store();
34045
33873
  FIELDS2 = [
@@ -34051,20 +33879,19 @@ var init_ProjectScreen = __esm({
34051
33879
  { key: "defaultTokenFile", label: "Default token file" },
34052
33880
  { key: "contentfulBaseDir", label: "Root Project Directory", hint: "(where .contentful goes)" }
34053
33881
  ];
34054
- snapshotOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
34055
33882
  valuesOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
34056
33883
  }
34057
33884
  });
34058
33885
 
34059
33886
  // packages/experience-design-system-cli/src/tui/settings/configuration/ConfigurationScreen.tsx
34060
33887
  import { useState as useState33 } from "react";
34061
- import { Box as Box48, Text as Text51, useInput as useInput14 } from "ink";
33888
+ import { Box as Box48, Text as Text51, useInput as useInput13 } from "ink";
34062
33889
  import { jsx as jsx60, jsxs as jsxs49 } from "react/jsx-runtime";
34063
33890
  function ConfigurationScreen({ onDone }) {
34064
33891
  const [focus, setFocus] = useState33(0);
34065
33892
  const [open, setOpen] = useState33(null);
34066
33893
  const close = () => setOpen(null);
34067
- useInput14((input, key) => {
33894
+ useInput13((input, key) => {
34068
33895
  if (open) return;
34069
33896
  if (key.upArrow) {
34070
33897
  setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
@@ -34124,8 +33951,8 @@ var init_ConfigurationScreen = __esm({
34124
33951
 
34125
33952
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
34126
33953
  import { useEffect as useEffect25, useState as useState34 } from "react";
34127
- import { Box as Box49, Text as Text52, useInput as useInput15 } from "ink";
34128
- import { Fragment as Fragment20, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
33954
+ import { Box as Box49, Text as Text52, useInput as useInput14 } from "ink";
33955
+ import { Fragment as Fragment19, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
34129
33956
  function OptInAnalyticsScreen({ onDone }) {
34130
33957
  const [loading, setLoading] = useState34(true);
34131
33958
  const [enabled, setEnabled] = useState34(true);
@@ -34141,7 +33968,7 @@ function OptInAnalyticsScreen({ onDone }) {
34141
33968
  });
34142
33969
  });
34143
33970
  }, []);
34144
- useInput15((input, key) => {
33971
+ useInput14((input, key) => {
34145
33972
  if (loading) return;
34146
33973
  if (key.return || input === " ") {
34147
33974
  setEnabled((current) => {
@@ -34159,7 +33986,7 @@ function OptInAnalyticsScreen({ onDone }) {
34159
33986
  return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
34160
33987
  /* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
34161
33988
  /* @__PURE__ */ jsx61(Text52, { children: " " }),
34162
- loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment20, { children: [
33989
+ loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment19, { children: [
34163
33990
  /* @__PURE__ */ jsxs50(Text52, { children: [
34164
33991
  "Share anonymous usage data:",
34165
33992
  " ",
@@ -34193,7 +34020,7 @@ var init_screen11 = __esm({
34193
34020
 
34194
34021
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
34195
34022
  import { useEffect as useEffect26, useState as useState35 } from "react";
34196
- import { Box as Box50, Text as Text53, useInput as useInput16 } from "ink";
34023
+ import { Box as Box50, Text as Text53, useInput as useInput15 } from "ink";
34197
34024
  import { jsx as jsx62, jsxs as jsxs51 } from "react/jsx-runtime";
34198
34025
  function DebugModeScreen({ onDone }) {
34199
34026
  const [loading, setLoading] = useState35(true);
@@ -34210,7 +34037,7 @@ function DebugModeScreen({ onDone }) {
34210
34037
  });
34211
34038
  });
34212
34039
  }, []);
34213
- useInput16((input, key) => {
34040
+ useInput15((input, key) => {
34214
34041
  if (loading) return;
34215
34042
  if (key.return || input === " ") {
34216
34043
  setEnabled((current) => {
@@ -34262,7 +34089,7 @@ __export(app_exports, {
34262
34089
  });
34263
34090
  import { join as join27 } from "node:path";
34264
34091
  import { useEffect as useEffect27, useState as useState36 } from "react";
34265
- import { Fragment as Fragment21, jsx as jsx63 } from "react/jsx-runtime";
34092
+ import { Fragment as Fragment20, jsx as jsx63 } from "react/jsx-runtime";
34266
34093
  function App({ importOptions, inkClear }) {
34267
34094
  const [screen, setScreen] = useState36("start");
34268
34095
  const [importExitCode, setImportExitCode] = useState36();
@@ -34431,7 +34258,7 @@ function App({ importOptions, inkClear }) {
34431
34258
  }
34432
34259
  );
34433
34260
  }
34434
- if (importDefaults === void 0) return /* @__PURE__ */ jsx63(Fragment21, {});
34261
+ if (importDefaults === void 0) return /* @__PURE__ */ jsx63(Fragment20, {});
34435
34262
  if (projectPath === void 0) {
34436
34263
  return /* @__PURE__ */ jsx63(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
34437
34264
  }
@@ -34470,7 +34297,7 @@ function App({ importOptions, inkClear }) {
34470
34297
  }
34471
34298
  );
34472
34299
  }
34473
- return /* @__PURE__ */ jsx63(Fragment21, {});
34300
+ return /* @__PURE__ */ jsx63(Fragment20, {});
34474
34301
  }
34475
34302
  if (scopeRun && scopeFlow) {
34476
34303
  if (scopeFlow.status === "failed") {
@@ -34507,7 +34334,7 @@ function App({ importOptions, inkClear }) {
34507
34334
  }
34508
34335
  );
34509
34336
  }
34510
- return /* @__PURE__ */ jsx63(Fragment21, {});
34337
+ return /* @__PURE__ */ jsx63(Fragment20, {});
34511
34338
  }
34512
34339
  if (pendingLaunch?.cached) {
34513
34340
  return /* @__PURE__ */ jsx63(
@@ -34687,7 +34514,7 @@ function createProgram() {
34687
34514
  // packages/experience-design-system-cli/src/config/migrate.ts
34688
34515
  init_config();
34689
34516
  init_package_root();
34690
- import { existsSync as existsSync12 } from "node:fs";
34517
+ import { existsSync as existsSync11 } from "node:fs";
34691
34518
  import { mkdir as mkdir10, readFile as readFile19, rename as rename3, rmdir, unlink } from "node:fs/promises";
34692
34519
  import { dirname as dirname16, join as join29 } from "node:path";
34693
34520
  var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
@@ -34713,8 +34540,8 @@ async function migrateOldConfig() {
34713
34540
  if (debugMode) migrated["debugMode"] = debugMode;
34714
34541
  Object.assign(migrated, await readJson(oldCredentials));
34715
34542
  if (Object.keys(migrated).length > 0) await updateSettings2({ ...migrated, ...await readSettings2() });
34716
- if (existsSync12(oldRuns)) {
34717
- if (!existsSync12(runsFilePath2())) {
34543
+ if (existsSync11(oldRuns)) {
34544
+ if (!existsSync11(runsFilePath2())) {
34718
34545
  await mkdir10(dirname16(runsFilePath2()), { recursive: true });
34719
34546
  await rename3(oldRuns, runsFilePath2());
34720
34547
  } else {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.37.1-dev-build-f22bf3b7.0",
3
+ "version": "2.37.1-dev-build-2582b468.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -5,11 +5,9 @@ import { type AgentConfig } from './agent-store.js';
5
5
  * One agent's screen: what was found for it, its two settings, and the test. Saving writes the whole agent config, so the
6
6
  * default agent and the other agents are kept. The test uses the values on screen, saved or not.
7
7
  */
8
- export declare function AgentDetail({ name, config, setConfig, onBack, record, }: {
8
+ export declare function AgentDetail({ name, config, setConfig, onBack, }: {
9
9
  name: AgentName;
10
10
  config: AgentConfig;
11
11
  setConfig: (config: AgentConfig) => void;
12
12
  onBack: () => void;
13
- /** Adds a line to the debug log of this visit. The Agents list owns the log, since it is the screen that is open. */
14
- record: (action: string, error?: unknown) => void;
15
13
  }): React.ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.37.1-dev-build-f22bf3b7.0",
3
+ "version": "2.37.1-dev-build-2582b468.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,8 +45,8 @@
45
45
  "ts-morph": "^27.0.2",
46
46
  "typescript": "^5.9.3",
47
47
  "zod": "^4.6.5",
48
- "@contentful/experience-design-system-types": "2.37.1-dev-build-f22bf3b7.0",
49
- "@contentful/experience-design-system-backend-pipeline": "2.37.1-dev-build-f22bf3b7.0"
48
+ "@contentful/experience-design-system-backend-pipeline": "2.37.1-dev-build-2582b468.0",
49
+ "@contentful/experience-design-system-types": "2.37.1-dev-build-2582b468.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@tsconfig/node24": "^24.0.4",
@@ -1,25 +0,0 @@
1
- import { type AgentName } from '@contentful/experience-design-system-backend-pipeline';
2
- import type { Snapshot } from '../../shared/debug-trail.js';
3
- import type { AgentConfig } from './agent-store.js';
4
- /**
5
- * The agent settings as flat text, for `diffSnapshots`: `default_agent`, then `<agent>.model` and `<agent>.binary` for
6
- * every agent. Taken on entry and on exit, so the log shows what a visit changed.
7
- */
8
- export declare function agentSnapshot(config: AgentConfig): Snapshot;
9
- export type AgentEnvironment = {
10
- /** Whether the command was found, and the path it resolved to. */
11
- found: boolean;
12
- resolved_path: string;
13
- version: string;
14
- /**
15
- * The `EDS_AGENT_BINARY_<AGENT>` variable when it points somewhere other than the saved path. Settings copies a saved
16
- * path into that variable at startup, so a value equal to the saved path is not an override and is left out.
17
- */
18
- env_override: string;
19
- };
20
- /**
21
- * What is true about each agent on this machine, so "my agent does not work" can be read from the log: found or not,
22
- * where, its version, and whether a shell variable is overriding the saved path. Uses the quick checks only, so it never
23
- * spends a prompt.
24
- */
25
- export declare function describeAgents(config: AgentConfig): Promise<Record<AgentName, AgentEnvironment>>;
@@ -1,35 +0,0 @@
1
- /** One screen's values, as flat text, taken when the screen opens and again when it closes. */
2
- export type Snapshot = Record<string, string>;
3
- export type Change = {
4
- changed: boolean;
5
- /** Field names that differ between the two snapshots, in the order the fields appear. Never the values. */
6
- changed_fields: string[];
7
- };
8
- /**
9
- * Compares the snapshot taken on entry with the one taken on exit. A field that exists in only one of them counts as
10
- * changed. Only names are returned, so the result can be logged without repeating a secret.
11
- */
12
- export declare function diffSnapshots(before: Snapshot, after: Snapshot): Change;
13
- export type Trail = {
14
- /** Adds one action, such as `edited spaceId`, `saved`, or `made Codex the default`. Field names, never values. */
15
- record(action: string): void;
16
- /** The recorded actions in order, oldest first. Once the limit is passed the oldest are dropped. */
17
- entries(): string[];
18
- };
19
- /** Keeps the last `limit` actions of a visit, so a long visit cannot make the log grow without bound. */
20
- export declare function createTrail(limit?: number): Trail;
21
- /**
22
- * The message of a failed load or save, safe to log: any of `secrets` that appears in it is replaced. The CMA token is
23
- * only redacted by key elsewhere, so an error that quotes it would otherwise get through. A secret is matched as it is
24
- * and as it looks URL-encoded, which is how it appears in a request error.
25
- */
26
- export declare function scrubError(error: unknown, secrets: readonly string[]): string;
27
- /**
28
- * Where Project's settings live and what could be moving them: the settings file path, whether `EDS_HOME` relocated it,
29
- * and whether the file exists. Facts for the log, with no values read from the file.
30
- */
31
- export declare function describeSettingsFile(): {
32
- path: string;
33
- eds_home_set: boolean;
34
- exists: boolean;
35
- };