@contentful/experience-design-system-cli 2.37.1-dev-build-444a2d6a.0 → 2.37.1-dev-build-04545499.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.
Files changed (27) hide show
  1. package/dist/app.js +973 -290
  2. package/dist/index.js +1014 -306
  3. package/dist/package.json +1 -1
  4. package/dist/src/tui/import/steps/07-scope-gate/sidebar/components/GroupedSidebar.d.ts +0 -5
  5. package/dist/src/tui/import/steps/07-scope-gate/state.d.ts +2 -3
  6. package/dist/src/tui/import/steps/07-scope-gate/types.d.ts +0 -7
  7. package/dist/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.d.ts +2 -6
  8. package/dist/src/tui/import/steps/07-scope-gate/use-scope-gate.d.ts +1 -2
  9. package/dist/src/tui/import/steps/08-generation/logic.d.ts +44 -0
  10. package/dist/src/tui/import/steps/08-generation/map-tokens.d.ts +14 -0
  11. package/dist/src/tui/import/steps/08-generation/processes.d.ts +42 -0
  12. package/dist/src/tui/import/steps/08-generation/run.d.ts +26 -0
  13. package/dist/src/tui/import/steps/08-generation/save-decisions.d.ts +8 -0
  14. package/dist/src/tui/import/steps/08-generation/screen.d.ts +12 -0
  15. package/dist/src/tui/import/steps/08-generation/types.d.ts +47 -0
  16. package/dist/src/tui/import/steps/08-generation/use-generation.d.ts +14 -0
  17. package/legacy/dist/src/analyze/select/tui/components/GroupedSidebar.d.ts +0 -2
  18. package/legacy/dist/src/import/tui/WizardApp.d.ts +1 -36
  19. package/legacy/dist/src/import/tui/handoff.d.ts +10 -13
  20. package/legacy/dist/src/import/tui/runLivePreview.d.ts +2 -3
  21. package/legacy/dist/src/index.js +55 -908
  22. package/legacy/dist/src/session/db.d.ts +0 -11
  23. package/legacy/package.json +1 -1
  24. package/package.json +4 -4
  25. package/legacy/dist/src/import/tui/runScopeGate.d.ts +0 -14
  26. package/legacy/dist/src/import/tui/spawn-generate.d.ts +0 -33
  27. package/legacy/dist/src/import/tui/wizard-generate-progress.d.ts +0 -21
@@ -2237,24 +2237,6 @@ var init_hash_token_content = __esm({
2237
2237
  });
2238
2238
 
2239
2239
  // packages/experience-design-system-cli-legacy/src/session/repositories/tokens/write.ts
2240
- function deleteRawTokensForSession(db, sessionId2) {
2241
- db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId2);
2242
- db.prepare("DELETE FROM raw_tokens WHERE session_id = ?").run(sessionId2);
2243
- }
2244
- function createRawTokenGroups(db, sessionId2, groups) {
2245
- const insertGroup = db.prepare(`INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)`);
2246
- for (const group of groups) {
2247
- insertGroup.run(sessionId2, group.path, group.$description ?? null);
2248
- }
2249
- }
2250
- function createRawTokens(db, sessionId2, tokens) {
2251
- const insertToken = db.prepare(
2252
- `INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)`
2253
- );
2254
- for (const token of tokens) {
2255
- insertToken.run(sessionId2, token.path, token.$type, JSON.stringify(token.$value), token.$description ?? null);
2256
- }
2257
- }
2258
2240
  function upsertRawToken(db, sessionId2, call) {
2259
2241
  db.prepare(
2260
2242
  `INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)
@@ -2320,15 +2302,6 @@ var init_with_transaction = __esm({
2320
2302
  });
2321
2303
 
2322
2304
  // packages/experience-design-system-cli-legacy/src/session/services/tokens/store-dtcg-tokens.ts
2323
- function storeDtcgTokens(db, sessionId2, groups, tokens) {
2324
- const now = (/* @__PURE__ */ new Date()).toISOString();
2325
- withTransaction(db, () => {
2326
- deleteRawTokensForSession(db, sessionId2);
2327
- createRawTokenGroups(db, sessionId2, groups);
2328
- createRawTokens(db, sessionId2, tokens);
2329
- updateSessionTimestamp(db, sessionId2, now);
2330
- });
2331
- }
2332
2305
  var init_store_dtcg_tokens = __esm({
2333
2306
  "packages/experience-design-system-cli-legacy/src/session/services/tokens/store-dtcg-tokens.ts"() {
2334
2307
  "use strict";
@@ -3614,50 +3587,6 @@ function loadCDFComponents(db, sessionId2) {
3614
3587
  return { key: name, entry };
3615
3588
  });
3616
3589
  }
3617
- function applyScopeDecisions(db, sessionId2, decisions) {
3618
- const now = (/* @__PURE__ */ new Date()).toISOString();
3619
- const acceptedSet = new Set(decisions.accepted);
3620
- const accepted = [...acceptedSet];
3621
- const rejected = [...new Set(decisions.rejected)].filter((n) => !acceptedSet.has(n));
3622
- if (rejected.length > 0) {
3623
- const placeholders = rejected.map(() => "?").join(",");
3624
- db.prepare(`UPDATE raw_components SET status = 'rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(
3625
- sessionId2,
3626
- ...rejected
3627
- );
3628
- }
3629
- if (accepted.length > 0) {
3630
- const placeholders = accepted.map(() => "?").join(",");
3631
- db.prepare(`UPDATE raw_components SET status = 'generated' WHERE session_id = ? AND name IN (${placeholders})`).run(
3632
- sessionId2,
3633
- ...accepted
3634
- );
3635
- }
3636
- removeSlotAllowedComponents(db, sessionId2, decisions.excludedSlotEdges ?? [], rejected);
3637
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
3638
- }
3639
- function removeSlotAllowedComponents(db, sessionId2, edges, rejectedNames) {
3640
- if (edges.length === 0 && rejectedNames.length === 0) return;
3641
- const componentId = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?");
3642
- const removeEdge = db.prepare(
3643
- "DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ? AND allowed_component = ?"
3644
- );
3645
- const removeEverywhere = db.prepare(
3646
- "DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND allowed_component = ?"
3647
- );
3648
- db.exec("BEGIN");
3649
- try {
3650
- for (const edge of edges) {
3651
- const row = componentId.get(sessionId2, edge.parent);
3652
- if (row) removeEdge.run(sessionId2, row.component_id, edge.child);
3653
- }
3654
- for (const name of rejectedNames) removeEverywhere.run(sessionId2, name);
3655
- db.exec("COMMIT");
3656
- } catch (e) {
3657
- db.exec("ROLLBACK");
3658
- throw e;
3659
- }
3660
- }
3661
3590
  function findLatestSessionForCommand(db, command) {
3662
3591
  return getLatestCompletedSessionForCommand(db, command);
3663
3592
  }
@@ -4533,35 +4462,6 @@ async function ensureRefineSession(sessionId2, artifactsRoot, initialSnapshot) {
4533
4462
  return initialSnapshot;
4534
4463
  }
4535
4464
  }
4536
- async function writeScopeDecisionsSnapshot(db, sessionId2, decisions) {
4537
- const acceptedSet = new Set(decisions.accepted);
4538
- const rawComponents = loadRawComponents(db, sessionId2);
4539
- const records = rawComponents.map((c2) => {
4540
- const status = acceptedSet.has(c2.name) ? "accepted" : "rejected";
4541
- const proposal = {
4542
- name: c2.name,
4543
- source: c2.source,
4544
- framework: c2.framework,
4545
- props: c2.props,
4546
- slots: c2.slots,
4547
- ...c2.extractionConfidence !== void 0 ? { extractionConfidence: c2.extractionConfidence } : {},
4548
- ...c2.reviewReasons !== void 0 ? { reviewReasons: c2.reviewReasons } : {},
4549
- ...c2.needsReview !== void 0 ? { needsReview: c2.needsReview } : {}
4550
- };
4551
- return {
4552
- id: c2.component_id,
4553
- name: c2.name,
4554
- resolvedSourcePath: "",
4555
- sourceCode: null,
4556
- originalProposal: proposal,
4557
- editedProposal: proposal,
4558
- status
4559
- };
4560
- });
4561
- const paths = await getRefineSessionPaths(sessionId2, getRefineArtifactsRoot());
4562
- await mkdir(paths.sessionDir, { recursive: true });
4563
- await saveReviewState(paths.statePath, { components: records });
4564
- }
4565
4465
  var init_persistence = __esm({
4566
4466
  "packages/experience-design-system-cli-legacy/src/analyze/select/persistence.ts"() {
4567
4467
  "use strict";
@@ -9883,16 +9783,11 @@ var init_GateStep = __esm({
9883
9783
 
9884
9784
  // packages/experience-design-system-cli-legacy/src/import/tui/handoff.ts
9885
9785
  import { HANDOFF_ENV, parseHandoff } from "@contentful/experience-design-system-types/handoff";
9886
- function scopeFromHandoff(handoff) {
9887
- const { scope } = handoff;
9888
- if (!scope) return null;
9889
- return {
9890
- decisions: { accepted: scope.accepted, rejected: scope.rejected, excludedSlotEdges: scope.excludedSlotEdges },
9891
- cachedNames: scope.cachedNames
9892
- };
9786
+ function routeFromHandoff(handoff) {
9787
+ return handoff.generation?.route ?? null;
9893
9788
  }
9894
9789
  function stateFromHandoff(handoff) {
9895
- const { extraction } = handoff;
9790
+ const { extraction, generation } = handoff;
9896
9791
  return {
9897
9792
  credentialsSkipped: handoff.credentialsSkipped,
9898
9793
  ...extraction ? {
@@ -9906,7 +9801,15 @@ function stateFromHandoff(handoff) {
9906
9801
  selectionAgentStatus: "complete",
9907
9802
  existingEntitiesStatus: extraction.existingEntitiesStatus,
9908
9803
  existingEntitiesPath: extraction.existingEntitiesPath
9909
- } : {}
9804
+ } : {},
9805
+ ...generation?.route === "review" ? {
9806
+ acceptedCount: generation.acceptedCount,
9807
+ autoRejectedCount: 0,
9808
+ generateSessionId: generation.sessionId,
9809
+ generatedCount: generation.generatedCount,
9810
+ mapTokensEligible: generation.mapTokensEligible,
9811
+ mapTokensStatus: "complete"
9812
+ } : generation?.route === "push" ? { acceptedCount: 0, autoRejectedCount: 0 } : {}
9910
9813
  };
9911
9814
  }
9912
9815
  function readHandoff(env = process.env) {
@@ -9916,7 +9819,7 @@ function readHandoff(env = process.env) {
9916
9819
  ok: true,
9917
9820
  handoff: parsed.handoff,
9918
9821
  state: stateFromHandoff(parsed.handoff),
9919
- scope: scopeFromHandoff(parsed.handoff)
9822
+ route: routeFromHandoff(parsed.handoff)
9920
9823
  };
9921
9824
  }
9922
9825
  var init_handoff = __esm({
@@ -19144,81 +19047,6 @@ var init_wizard_422_helpers = __esm({
19144
19047
  }
19145
19048
  });
19146
19049
 
19147
- // packages/experience-design-system-cli-legacy/src/import/tui/wizard-generate-progress.ts
19148
- function parseGenerateStderrChunk(chunk, prev) {
19149
- let state = prev;
19150
- for (const line of chunk.split("\n")) {
19151
- const progressMatch = PROGRESS_LINE.exec(line);
19152
- if (progressMatch) {
19153
- state = {
19154
- done: Number(progressMatch[1]),
19155
- total: Number(progressMatch[2]),
19156
- current: progressMatch[3].trim()
19157
- };
19158
- continue;
19159
- }
19160
- const legacyMatch = LEGACY_LINE.exec(line);
19161
- if (legacyMatch) {
19162
- state = {
19163
- done: state?.done ?? 0,
19164
- total: Number(legacyMatch[2]),
19165
- current: legacyMatch[3].trim()
19166
- };
19167
- }
19168
- }
19169
- return state;
19170
- }
19171
- var PROGRESS_LINE, LEGACY_LINE;
19172
- var init_wizard_generate_progress = __esm({
19173
- "packages/experience-design-system-cli-legacy/src/import/tui/wizard-generate-progress.ts"() {
19174
- "use strict";
19175
- PROGRESS_LINE = /^progress=generate:(\d+)\/(\d+):(.+)$/;
19176
- LEGACY_LINE = /\[(\d+)\/(\d+)\]\s+(.+)/;
19177
- }
19178
- });
19179
-
19180
- // packages/experience-design-system-cli-legacy/src/import/tui/spawn-generate.ts
19181
- import { spawn as spawn4 } from "node:child_process";
19182
- function spawnGenerateChild(opts) {
19183
- const child = spawn4(opts.command, opts.args);
19184
- let stdout = "";
19185
- let stderr = "";
19186
- child.stdout?.on("data", (d) => {
19187
- const chunk = String(d);
19188
- stdout += chunk;
19189
- opts.onStdout?.(chunk);
19190
- });
19191
- child.stderr?.on("data", (d) => {
19192
- const chunk = String(d);
19193
- stderr += chunk;
19194
- opts.onStderr?.(chunk);
19195
- });
19196
- const donePromise = new Promise((resolve22) => {
19197
- child.on("close", (code, signal) => {
19198
- resolve22({
19199
- exitCode: code ?? 0,
19200
- signal: signal ?? null,
19201
- stdout,
19202
- stderr
19203
- });
19204
- });
19205
- child.on("error", (err) => {
19206
- resolve22({
19207
- exitCode: 1,
19208
- signal: null,
19209
- stdout,
19210
- stderr: stderr + (err.message ?? String(err))
19211
- });
19212
- });
19213
- });
19214
- return { child, donePromise };
19215
- }
19216
- var init_spawn_generate = __esm({
19217
- "packages/experience-design-system-cli-legacy/src/import/tui/spawn-generate.ts"() {
19218
- "use strict";
19219
- }
19220
- });
19221
-
19222
19050
  // packages/experience-design-system-cli-legacy/src/import/tui/steps/review-json-panel.ts
19223
19051
  function getReviewJsonPanelValue(selected, showHiddenProps) {
19224
19052
  if (!selected) return "";
@@ -19527,7 +19355,7 @@ function buildVisibleRows(props) {
19527
19355
  if (visited.has(target)) continue;
19528
19356
  visited.add(target);
19529
19357
  const isCycleMember = cycleParticipants.has(target);
19530
- out.push({ name: target, depth: cur.depth + 1, isCycleMember, parent: cur.name });
19358
+ out.push({ name: target, depth: cur.depth + 1, isCycleMember });
19531
19359
  queue.push({ name: target, depth: cur.depth + 1 });
19532
19360
  }
19533
19361
  }
@@ -19574,8 +19402,7 @@ function buildVisibleRows(props) {
19574
19402
  sharedSuffix,
19575
19403
  cycleChild: child.isCycleMember || void 0,
19576
19404
  itemIdx: childRec?.idx ?? -1,
19577
- rootName: key,
19578
- parentName: child.parent
19405
+ rootName: key
19579
19406
  });
19580
19407
  });
19581
19408
  }
@@ -19658,19 +19485,13 @@ function buildVisibleRows(props) {
19658
19485
  injectedChildren.push({
19659
19486
  name: target,
19660
19487
  depth: parentDepth + 1,
19661
- isCycleChild: true,
19662
- parent: parentName
19488
+ isCycleChild: true
19663
19489
  });
19664
19490
  }
19665
19491
  };
19666
19492
  emitCycleChildrenOf(root, 0);
19667
19493
  for (const c2 of closureChildren) {
19668
- injectedChildren.push({
19669
- name: c2.name,
19670
- depth: c2.depth,
19671
- isCycleChild: false,
19672
- parent: c2.path[c2.path.length - 2] ?? root
19673
- });
19494
+ injectedChildren.push({ name: c2.name, depth: c2.depth, isCycleChild: false });
19674
19495
  emitCycleChildrenOf(c2.name, c2.depth);
19675
19496
  }
19676
19497
  const isLastAtDepth = (idx) => {
@@ -19704,8 +19525,7 @@ function buildVisibleRows(props) {
19704
19525
  sharedSuffix,
19705
19526
  cycleChild: child.isCycleChild || void 0,
19706
19527
  itemIdx: childRec?.idx ?? -1,
19707
- rootName: root,
19708
- parentName: child.parent
19528
+ rootName: root
19709
19529
  });
19710
19530
  });
19711
19531
  }
@@ -19858,7 +19678,7 @@ function GroupedSidebar(props) {
19858
19678
  const rs = itemName ? renderStatusByKey?.get(itemName) : void 0;
19859
19679
  const badge = itemName ? previewBadge(previewAnnotationByKey?.get(itemName)) : null;
19860
19680
  const showInheritance = rs !== void 0 && row.kind !== "cycle" && row.kind !== "empty" && row.kind !== "group-root";
19861
- const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "empty" || row.kind === "cycle");
19681
+ const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "cycle");
19862
19682
  const selState = supportsSelectionGlyph ? selectionStateByKey.get(itemName) ?? "undecided" : void 0;
19863
19683
  const isCycleRow = row.kind === "cycle";
19864
19684
  const selStyle = selectionGlyphStyleFor(selState, isCycleRow);
@@ -19888,7 +19708,7 @@ function GroupedSidebar(props) {
19888
19708
  color: isSelected ? PALETTE.info : labelStyle.dim ? PALETTE.muted : labelStyle.color,
19889
19709
  bold: isSelected || labelStyle.bold,
19890
19710
  inverse: false,
19891
- underline: isSelected && focused,
19711
+ underline: isSelected && !focused,
19892
19712
  wrap: wrapLabels ? "wrap" : "truncate",
19893
19713
  children: [
19894
19714
  " ",
@@ -22292,8 +22112,8 @@ function FieldEditor({
22292
22112
  return /* @__PURE__ */ jsxs24(Box23, { flexDirection: "column", width, borderStyle: "single", borderColor: PALETTE.warning, children: [
22293
22113
  /* @__PURE__ */ jsx28(Text24, { bold: true, color: PALETTE.warning, children: "FIELD EDITOR \u2014 no fields" }),
22294
22114
  /* @__PURE__ */ jsx28(Text24, { color: PALETTE.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify." }),
22295
- /* @__PURE__ */ jsx28(Text24, { color: PALETTE.muted, children: "There is nothing to edit here." }),
22296
- /* @__PURE__ */ jsx28(Text24, { color: PALETTE.muted, children: active ? "[Esc] go back to the list" : "In the list: [r] reject this component \xB7 [a] accept it" })
22115
+ /* @__PURE__ */ jsx28(Text24, { color: PALETTE.muted, children: "You can add fields manually below or reject this component." }),
22116
+ /* @__PURE__ */ jsx28(Text24, { color: PALETTE.muted, children: "Enter to save \xB7 Esc to discard" })
22297
22117
  ] });
22298
22118
  }
22299
22119
  const hasEmptyProperties = props.length === 0 && slots.length === 0;
@@ -22508,7 +22328,7 @@ function FieldEditor({
22508
22328
  children: [
22509
22329
  hasEmptyProperties && /* @__PURE__ */ jsx28(Text24, { color: PALETTE.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify. Reject this component or add fields manually." }),
22510
22330
  header,
22511
- /* @__PURE__ */ jsx28(Box23, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && !inSlots && currentProp ? /* @__PURE__ */ jsx28(
22331
+ /* @__PURE__ */ jsx28(Box23, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && currentProp ? /* @__PURE__ */ jsx28(
22512
22332
  PropRow,
22513
22333
  {
22514
22334
  prop: currentProp,
@@ -23932,7 +23752,6 @@ function finalizeReviewSession(extractSessionId, components) {
23932
23752
  db.exec("ROLLBACK");
23933
23753
  throw error;
23934
23754
  }
23935
- removeSlotAllowedComponents(db, extractSessionId, [], toReject);
23936
23755
  } finally {
23937
23756
  db.close();
23938
23757
  }
@@ -25274,50 +25093,33 @@ function GenerateReviewStepView({
25274
25093
  const cycle = cycleRows[cyclesCursor];
25275
25094
  return cycle ? enumerateCycleBreaks(cycle, components) : [];
25276
25095
  }, [cycleRows, cyclesCursor, components]);
25277
- const saveSlotChange = (parentKey, nextEntry, historyLabel) => {
25096
+ const handleBreakEdge = (edge) => {
25097
+ const target = components.find((component) => component.key === edge.fromComponent);
25098
+ const slot = target?.entry.$slots?.[edge.slotName];
25099
+ if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
25100
+ const nextEntry = {
25101
+ ...target.entry,
25102
+ $slots: {
25103
+ ...target.entry.$slots,
25104
+ [edge.slotName]: {
25105
+ ...slot,
25106
+ $allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
25107
+ }
25108
+ }
25109
+ };
25278
25110
  const next = components.map(
25279
- (component) => component.key === parentKey ? { ...component, entry: nextEntry } : component
25111
+ (component) => component.key === target.key ? { ...component, entry: nextEntry } : component
25280
25112
  );
25281
25113
  setComponents(next);
25282
25114
  const db = openPipelineDb();
25283
25115
  try {
25284
- storeCDFComponents(db, extractSessionId, [{ key: parentKey, entry: nextEntry }]);
25116
+ storeCDFComponents(db, extractSessionId, [{ key: target.key, entry: nextEntry }]);
25285
25117
  } finally {
25286
25118
  db.close();
25287
25119
  }
25288
25120
  recomputeCycles(next);
25289
25121
  livePreviewHook.trigger();
25290
- pushHistorySnapshot(next, historyLabel);
25291
- };
25292
- const handleBreakEdge = (edge) => {
25293
- const target = components.find((component) => component.key === edge.fromComponent);
25294
- const slot = target?.entry.$slots?.[edge.slotName];
25295
- if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
25296
- saveSlotChange(
25297
- target.key,
25298
- {
25299
- ...target.entry,
25300
- $slots: {
25301
- ...target.entry.$slots,
25302
- [edge.slotName]: {
25303
- ...slot,
25304
- $allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
25305
- }
25306
- }
25307
- },
25308
- "break-cycle-edge"
25309
- );
25310
- };
25311
- const handleRemoveSlotChild = (parentKey, childKey) => {
25312
- const parent = components.find((component) => component.key === parentKey);
25313
- if (!parent?.entry.$slots) return;
25314
- const slots = Object.fromEntries(
25315
- Object.entries(parent.entry.$slots).map(([slotName, slot]) => [
25316
- slotName,
25317
- Array.isArray(slot.$allowedComponents) ? { ...slot, $allowedComponents: slot.$allowedComponents.filter((value) => value !== childKey) } : slot
25318
- ])
25319
- );
25320
- saveSlotChange(parentKey, { ...parent.entry, $slots: slots }, "remove-slot-child");
25122
+ pushHistorySnapshot(next, "break-cycle-edge");
25321
25123
  };
25322
25124
  const handleRejectComponent = (key) => {
25323
25125
  const rejectCascade = computeRejectCascade(key, componentGraph);
@@ -25647,11 +25449,6 @@ function GenerateReviewStepView({
25647
25449
  if (input === "r") {
25648
25450
  const current = components[selectedIdx];
25649
25451
  if (!current) return;
25650
- const row = visibleRowsMemo[cursorRowIdx];
25651
- if (row?.kind === "group-child" && row.parentName) {
25652
- handleRemoveSlotChild(row.parentName, current.key);
25653
- return;
25654
- }
25655
25452
  handleRejectComponent(current.key);
25656
25453
  return;
25657
25454
  }
@@ -26081,64 +25878,7 @@ var init_GenerateReviewStep = __esm({
26081
25878
  }
26082
25879
  });
26083
25880
 
26084
- // packages/experience-design-system-cli-legacy/src/import/tui/runScopeGate.ts
26085
- async function runScopeGate(opts) {
26086
- const startedAt = Date.now();
26087
- getDebugLogger().event("wizard", "scope-decision-persistence.start", {
26088
- sessionId: opts.sessionId,
26089
- acceptedCount: opts.decisions.accepted.length,
26090
- rejectedCount: opts.decisions.rejected.length
26091
- });
26092
- const db = openPipelineDb();
26093
- try {
26094
- applyScopeDecisions(db, opts.sessionId, opts.decisions);
26095
- await writeScopeDecisionsSnapshot(db, opts.sessionId, opts.decisions);
26096
- getDebugLogger().event("wizard", "scope-decision-persistence.complete", {
26097
- sessionId: opts.sessionId,
26098
- acceptedCount: opts.decisions.accepted.length,
26099
- rejectedCount: opts.decisions.rejected.length,
26100
- durationMs: Date.now() - startedAt
26101
- });
26102
- } catch (error) {
26103
- getDebugLogger().event("wizard", "scope-decision-persistence.error", {
26104
- sessionId: opts.sessionId,
26105
- acceptedCount: opts.decisions.accepted.length,
26106
- rejectedCount: opts.decisions.rejected.length,
26107
- durationMs: Date.now() - startedAt,
26108
- error: error instanceof Error ? error.message : String(error)
26109
- });
26110
- throw error;
26111
- } finally {
26112
- db.close();
26113
- }
26114
- if (opts.decisions.accepted.length > 0) {
26115
- await opts.onAdvanceToGenerate({ sessionId: opts.sessionId, acceptedCount: opts.decisions.accepted.length });
26116
- } else {
26117
- await opts.onAdvanceToPushFlow(0);
26118
- }
26119
- }
26120
- var init_runScopeGate = __esm({
26121
- "packages/experience-design-system-cli-legacy/src/import/tui/runScopeGate.ts"() {
26122
- "use strict";
26123
- init_persistence();
26124
- init_debug_logger();
26125
- init_db();
26126
- }
26127
- });
26128
-
26129
25881
  // packages/experience-design-system-cli-legacy/src/import/tui/wizard-state-transitions.ts
26130
- function shouldGenerateAfterScopeGate(opts) {
26131
- return opts.acceptedCount > 0;
26132
- }
26133
- function shouldGenerateAfterCredentialsValidated(opts) {
26134
- return opts.acceptedCount > 0;
26135
- }
26136
- function shouldSkipFinalReviewAfterCredentials(state) {
26137
- return state.finalReviewPassed && state.generateSessionId != null;
26138
- }
26139
- function resolveNoCacheForGenerate(opts) {
26140
- return opts.cliNoCache;
26141
- }
26142
25882
  function shouldBypassPreview(state) {
26143
25883
  return state.credentialsSkipped === true;
26144
25884
  }
@@ -26165,12 +25905,8 @@ var init_wizard_state_transitions = __esm({
26165
25905
  var WizardApp_exports = {};
26166
25906
  __export(WizardApp_exports, {
26167
25907
  WizardApp: () => WizardApp,
26168
- buildGenerateComponentsArgs: () => buildGenerateComponentsArgs,
26169
- buildMapTokensArgs: () => buildMapTokensArgs,
26170
25908
  buildSavedCDF: () => buildSavedCDF,
26171
- formatAcceptanceSummary: () => formatAcceptanceSummary,
26172
- parsePrintTokensCount: () => parsePrintTokensCount,
26173
- shouldRunMapTokens: () => shouldRunMapTokens
25909
+ parsePrintTokensCount: () => parsePrintTokensCount
26174
25910
  });
26175
25911
  import { useEffect as useEffect13, useRef as useRef8, useState as useState18 } from "react";
26176
25912
  import { Box as Box36 } from "ink";
@@ -26178,37 +25914,9 @@ import { join as join19, resolve as resolve18 } from "node:path";
26178
25914
  import { appendFileSync as appendFileSync2, writeFileSync } from "node:fs";
26179
25915
  import { writeFile as writeFile4 } from "node:fs/promises";
26180
25916
  import { tmpdir } from "node:os";
26181
- import { execFile as execFile2 } from "node:child_process";
26182
25917
  import { mkdir as mkdir4 } from "node:fs/promises";
26183
25918
  import { buildCDF as buildCDF3, validateCDF as validateCDF3, validateSlotReferences as validateSlotReferences2 } from "@contentful/experience-design-system-types";
26184
25919
  import { jsx as jsx45, jsxs as jsxs37 } from "react/jsx-runtime";
26185
- function buildGenerateComponentsArgs(opts) {
26186
- const args = ["__generate", "components", "--agent", opts.agent, "--session", opts.sessionId];
26187
- if (opts.tokensPath) args.push("--tokens", opts.tokensPath);
26188
- if (opts.model) args.push("--model", opts.model);
26189
- if (opts.bedrock) args.push("--bedrock");
26190
- if (opts.noCache) args.push("--no-cache");
26191
- if (opts.generatePromptPath) args.push("--generate-prompt-path", opts.generatePromptPath);
26192
- for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
26193
- if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
26194
- if (opts.restoreCache) args.push("--restore-cache");
26195
- if (opts.cachedComponents && opts.cachedComponents.length > 0) {
26196
- args.push("--cached-components", JSON.stringify(opts.cachedComponents));
26197
- }
26198
- return args;
26199
- }
26200
- function buildMapTokensArgs(opts) {
26201
- const args = ["map", "tokens", "--session", opts.sessionId, "--agent", opts.agent];
26202
- if (opts.model) args.push("--model", opts.model);
26203
- if (opts.noCache) args.push("--no-cache");
26204
- if (opts.skipAgent) args.push("--skip-agent");
26205
- for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
26206
- if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
26207
- return args;
26208
- }
26209
- function shouldRunMapTokens(opts) {
26210
- return opts.mappablePropCount > 0 && opts.rawTokenCount > 0;
26211
- }
26212
25920
  function buildSavedCDF(components, tokens, opts = {}) {
26213
25921
  const cdf = buildCDF3(components, toCDFTokens(tokens), opts);
26214
25922
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
@@ -26218,31 +25926,6 @@ function buildSavedCDF(components, tokens, opts = {}) {
26218
25926
  }
26219
25927
  return cdf;
26220
25928
  }
26221
- function formatAcceptanceSummary(opts) {
26222
- const acceptedClause = `${opts.accepted} component${opts.accepted === 1 ? "" : "s"} accepted`;
26223
- if (opts.autoRejected === 0) return `${acceptedClause}.`;
26224
- return `${acceptedClause}, ${opts.autoRejected} excluded due to validation errors.`;
26225
- }
26226
- function runCli(args) {
26227
- return new Promise((res) => {
26228
- execFile2("node", [findCliPath(), ...args], (error, stdout, stderr) => {
26229
- res({ exitCode: error?.code ? Number(error.code) : 0, stdout, stderr });
26230
- });
26231
- });
26232
- }
26233
- function buildGenerateProcessArgs(opts) {
26234
- return [findCliPath(), ...buildGenerateComponentsArgs(opts)];
26235
- }
26236
- function parseGenerateResult(result, fallbackCount) {
26237
- const sessionMatch = /^session=(.+)$/m.exec(result.stdout);
26238
- const countMatch = /(\d+) components?/.exec(result.stderr);
26239
- const renamedMatch = /^renamed-slots:\s*(\d+)$/m.exec(result.stdout);
26240
- return {
26241
- generateSessionId: sessionMatch ? sessionMatch[1].trim() : null,
26242
- generatedCount: countMatch ? Number(countMatch[1]) : fallbackCount,
26243
- renamedSlotsCount: renamedMatch ? Number(renamedMatch[1]) : 0
26244
- };
26245
- }
26246
25929
  function parsePrintTokensCount(stdout) {
26247
25930
  const m = /\((\d+)\s+token/.exec(stdout);
26248
25931
  return m ? Number(m[1]) : 0;
@@ -26252,17 +25935,6 @@ function logStep(entry) {
26252
25935
  appendFileSync2(WIZARD_LOG, line);
26253
25936
  getDebugLogger().event("wizard", "step", entry);
26254
25937
  }
26255
- function startWizardTimer(name, payload = {}) {
26256
- const startedAt = Date.now();
26257
- getDebugLogger().event("wizard", `${name}.start`, payload);
26258
- return startedAt;
26259
- }
26260
- function finishWizardTimer(name, startedAt, payload = {}) {
26261
- getDebugLogger().event("wizard", `${name}.complete`, {
26262
- ...payload,
26263
- durationMs: Date.now() - startedAt
26264
- });
26265
- }
26266
25938
  function WizardApp({
26267
25939
  initialSpaceId = "",
26268
25940
  initialEnvironmentId = "master",
@@ -26273,20 +25945,15 @@ function WizardApp({
26273
25945
  bedrock = false,
26274
25946
  initialProjectPath,
26275
25947
  host,
26276
- promptOverrides,
26277
- noCache = false,
26278
25948
  livePreview = true,
26279
25949
  generatePromptPath,
26280
- skipMapTokens = false,
26281
- initialRawTokensPath,
26282
- initialAgentAuth
25950
+ initialRawTokensPath
26283
25951
  } = {}) {
26284
25952
  const defaultConfiguredHost = toConfiguredHost(host || process.env["EDS_HOST"]) ?? DEFAULT_CONFIGURED_HOST;
26285
25953
  const resolveWizardHost = (hostValue) => hostValue || defaultConfiguredHost;
26286
25954
  const { columns: terminalWidth } = useTerminalSize();
26287
25955
  const clearScreenOnTransition = useScreenTransitionClear();
26288
25956
  const logInit = useRef8(false);
26289
- const initialAgentAuthRef = useRef8(initialAgentAuth ?? null);
26290
25957
  if (!logInit.current) {
26291
25958
  writeFileSync(WIZARD_LOG, `--- experiences import session ${(/* @__PURE__ */ new Date()).toISOString()} ---
26292
25959
  `);
@@ -26297,13 +25964,9 @@ function WizardApp({
26297
25964
  tokensPath: ""
26298
25965
  });
26299
25966
  const allowEmptyDeleteAllRef = useRef8(false);
26300
- const selectionToReviewStartedAtRef = useRef8(null);
26301
25967
  const credentialsReadyRef = useRef8(false);
26302
- const agentAuthVerifiedRef = useRef8(false);
26303
25968
  const scopeGateCompletedRef = useRef8(false);
26304
- const generatePromiseRef = useRef8(null);
26305
25969
  const rawTokensEntryReady = !!initialRawTokensPath;
26306
- const effectiveNoCache = resolveNoCacheForGenerate({ cliNoCache: noCache });
26307
25970
  const [startedFrom] = useState18(() => readHandoff());
26308
25971
  const initialStepResolved = startedFrom.ok ? "credentials" : "error";
26309
25972
  const initialOutDir = initialProjectPath ? join19(resolve18(initialProjectPath), ".contentful") : "";
@@ -26419,342 +26082,6 @@ function WizardApp({
26419
26082
  logStep({ update: sanitized });
26420
26083
  setState((prev) => ({ ...prev, ...partial }));
26421
26084
  };
26422
- const finishSelectionToReviewTimer = (mode) => {
26423
- const startedAt = selectionToReviewStartedAtRef.current;
26424
- if (startedAt === null) return;
26425
- selectionToReviewStartedAtRef.current = null;
26426
- finishWizardTimer("selection-to-review", startedAt, { mode });
26427
- };
26428
- const runAgentAuthCheck = async (nextStep, deferStep = false) => {
26429
- const timer = startWizardTimer("agent-auth-validation", {
26430
- agent: state.agent,
26431
- deferred: deferStep,
26432
- nextStep
26433
- });
26434
- if (agentAuthVerifiedRef.current) {
26435
- finishWizardTimer("agent-auth-validation", timer, {
26436
- status: "already-verified"
26437
- });
26438
- if (!deferStep) update({ step: nextStep });
26439
- return true;
26440
- }
26441
- const authCheckStepNumber = state.tokensPath ? 4 : 3;
26442
- const prefetchedAuth = initialAgentAuthRef.current;
26443
- initialAgentAuthRef.current = null;
26444
- if (!prefetchedAuth && !deferStep) update({ step: "checking-claude-auth", authCheckStepNumber });
26445
- let status;
26446
- try {
26447
- status = await (prefetchedAuth ?? checkAgentAuth(state.agent));
26448
- } catch (error) {
26449
- finishWizardTimer("agent-auth-validation", timer, {
26450
- status: "error",
26451
- error: error instanceof Error ? error.message : String(error)
26452
- });
26453
- throw error;
26454
- }
26455
- finishWizardTimer("agent-auth-validation", timer, {
26456
- status,
26457
- prefetched: Boolean(prefetchedAuth)
26458
- });
26459
- if (status === "not-found") {
26460
- update({
26461
- step: "error",
26462
- errorStep: `${state.agent} auth check`,
26463
- errorMessage: `The \`${state.agent}\` CLI was not found on your PATH.
26464
-
26465
- Install it, then re-run \`experiences import\`.`
26466
- });
26467
- return false;
26468
- }
26469
- if (status === "unauthenticated") {
26470
- update({
26471
- step: "error",
26472
- errorStep: `${state.agent} auth check`,
26473
- errorMessage: `${state.agent} is not authenticated.
26474
-
26475
- Run \`${state.agent}\` in your terminal to log in, then re-run \`experiences import\`.
26476
-
26477
- If you are using AWS Bedrock, run:
26478
- aws sso login --profile <your-profile>`
26479
- });
26480
- return false;
26481
- }
26482
- agentAuthVerifiedRef.current = true;
26483
- if (!deferStep) update({ step: nextStep });
26484
- return true;
26485
- };
26486
- const runMapTokens2 = async (sessionId2, silent = false) => {
26487
- const timer = startWizardTimer("token-mapping", {
26488
- sessionId: sessionId2,
26489
- silent,
26490
- noCache: effectiveNoCache,
26491
- skipAgent: skipMapTokens
26492
- });
26493
- let mappablePropCount = 0;
26494
- let rawTokenCount = 0;
26495
- try {
26496
- const db = openPipelineDb();
26497
- try {
26498
- if (state.tokenSessionId && state.tokenSessionId !== sessionId2) {
26499
- copyTokensFromCache(db, state.tokenSessionId, sessionId2);
26500
- } else if (!state.tokenSessionId && state.tokensPath) {
26501
- const tokens = await readTokensFromPath("tokens", state.tokensPath);
26502
- storeDtcgTokens(db, sessionId2, [], tokens);
26503
- }
26504
- const cdfEntries = loadCDFComponents(db, sessionId2);
26505
- mappablePropCount = cdfEntries.reduce(
26506
- (count, { entry }) => count + Object.values(entry.$properties).filter((prop) => prop.$type === "token" && prop.$category === "design").length,
26507
- 0
26508
- );
26509
- rawTokenCount = getDtcgTokensForSession(db, sessionId2).tokens.length;
26510
- } finally {
26511
- db.close();
26512
- }
26513
- } catch (error) {
26514
- update({
26515
- step: "error",
26516
- errorStep: "map tokens",
26517
- errorMessage: error instanceof Error ? error.message : String(error)
26518
- });
26519
- finishWizardTimer("token-mapping", timer, {
26520
- status: "error",
26521
- error: error instanceof Error ? error.message : String(error)
26522
- });
26523
- return false;
26524
- }
26525
- if (!shouldRunMapTokens({ mappablePropCount, rawTokenCount })) {
26526
- if (!silent) update({ mapTokensEligible: false, mapTokensStatus: "complete" });
26527
- finishWizardTimer("token-mapping", timer, {
26528
- status: "skipped",
26529
- mappablePropCount,
26530
- rawTokenCount
26531
- });
26532
- return true;
26533
- }
26534
- if (!silent)
26535
- update({
26536
- mapTokensEligible: true,
26537
- mapTokensStatus: "running",
26538
- step: "generating"
26539
- });
26540
- const args = buildMapTokensArgs({
26541
- sessionId: sessionId2,
26542
- agent: state.agent,
26543
- ...state.agentModel ? { model: state.agentModel } : {},
26544
- noCache: effectiveNoCache,
26545
- skipAgent: skipMapTokens,
26546
- promptOverrides,
26547
- ...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {}
26548
- });
26549
- const result = await runCli(args);
26550
- if (result.exitCode !== 0) {
26551
- update({
26552
- step: "error",
26553
- mapTokensStatus: "failed",
26554
- errorStep: "map tokens",
26555
- errorMessage: result.stderr.trim() || "Unknown error"
26556
- });
26557
- finishWizardTimer("token-mapping", timer, {
26558
- status: "error",
26559
- exitCode: result.exitCode,
26560
- mappablePropCount,
26561
- rawTokenCount
26562
- });
26563
- return false;
26564
- }
26565
- if (!silent) update({ mapTokensStatus: "complete" });
26566
- finishWizardTimer("token-mapping", timer, {
26567
- status: "complete",
26568
- exitCode: result.exitCode,
26569
- mappablePropCount,
26570
- rawTokenCount
26571
- });
26572
- return true;
26573
- };
26574
- const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => ({
26575
- sessionId: extractSessionId,
26576
- tokensPath,
26577
- agent: state.agent,
26578
- ...state.agentModel ? { model: state.agentModel } : {},
26579
- ...state.bedrock ? { bedrock: true } : {},
26580
- noCache: effectiveNoCache,
26581
- ...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {},
26582
- ...generatePromptPath2 ? { generatePromptPath: generatePromptPath2 } : {},
26583
- promptOverrides,
26584
- ...cachedComponents && cachedComponents.length > 0 ? { cachedComponents } : {}
26585
- });
26586
- const buildGenerateArgs = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => buildGenerateProcessArgs(buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2, cachedComponents));
26587
- const buildGenerateCliArgs = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => buildGenerateComponentsArgs(
26588
- buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2, cachedComponents)
26589
- );
26590
- const checkGenerateCache = async (extractSessionId, tokensPath) => {
26591
- const timer = startWizardTimer("generation-cache-status", {
26592
- sessionId: extractSessionId,
26593
- noCache: effectiveNoCache
26594
- });
26595
- if (effectiveNoCache) {
26596
- finishWizardTimer("generation-cache-status", timer, {
26597
- status: "skipped"
26598
- });
26599
- return false;
26600
- }
26601
- const result = await runCli([...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"]);
26602
- const hit = result.exitCode === 0 && /^cache-status=hit$/m.test(result.stdout);
26603
- finishWizardTimer("generation-cache-status", timer, {
26604
- status: hit ? "hit" : "miss",
26605
- exitCode: result.exitCode,
26606
- ...result.exitCode !== 0 ? { stderrTail: result.stderr.trim().slice(-500) } : {}
26607
- });
26608
- return hit;
26609
- };
26610
- const checkGenerateCacheComponents = async (extractSessionId, tokensPath, restoreCache = false) => {
26611
- const timer = startWizardTimer("generation-cache-components", {
26612
- sessionId: extractSessionId,
26613
- restoreCache,
26614
- noCache: effectiveNoCache
26615
- });
26616
- if (effectiveNoCache) {
26617
- finishWizardTimer("generation-cache-components", timer, {
26618
- status: "skipped"
26619
- });
26620
- return /* @__PURE__ */ new Set();
26621
- }
26622
- const args = [...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"];
26623
- if (restoreCache) args.push("--restore-cache");
26624
- const result = await runCli(args);
26625
- if (result.exitCode !== 0) {
26626
- finishWizardTimer("generation-cache-components", timer, {
26627
- status: "error",
26628
- exitCode: result.exitCode,
26629
- stderrTail: result.stderr.trim().slice(-500)
26630
- });
26631
- return /* @__PURE__ */ new Set();
26632
- }
26633
- const line = /^cache-components=(.+)$/m.exec(result.stdout)?.[1];
26634
- if (!line) {
26635
- finishWizardTimer("generation-cache-components", timer, {
26636
- status: "missing-output",
26637
- exitCode: result.exitCode,
26638
- cachedCount: 0
26639
- });
26640
- return /* @__PURE__ */ new Set();
26641
- }
26642
- try {
26643
- const names = JSON.parse(line);
26644
- const cachedNames = new Set(
26645
- Array.isArray(names) ? names.filter((name) => typeof name === "string") : []
26646
- );
26647
- finishWizardTimer("generation-cache-components", timer, {
26648
- status: "complete",
26649
- exitCode: result.exitCode,
26650
- cachedCount: cachedNames.size
26651
- });
26652
- return cachedNames;
26653
- } catch {
26654
- finishWizardTimer("generation-cache-components", timer, {
26655
- status: "invalid-output",
26656
- exitCode: result.exitCode,
26657
- cachedCount: 0
26658
- });
26659
- return /* @__PURE__ */ new Set();
26660
- }
26661
- };
26662
- const runGenerate = async (extractSessionId, tokensPath, acceptedCount, suppressScreen = false, cachedComponents = []) => {
26663
- const timer = startWizardTimer("component-generation", {
26664
- sessionId: extractSessionId,
26665
- acceptedCount,
26666
- suppressScreen,
26667
- noCache: effectiveNoCache
26668
- });
26669
- const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath, cachedComponents);
26670
- let progressCursor = state.generateProgress;
26671
- const { donePromise } = spawnGenerateChild({
26672
- command: "node",
26673
- args,
26674
- onStderr: (chunk) => {
26675
- const nextProgress = parseGenerateStderrChunk(chunk, progressCursor);
26676
- if (nextProgress !== progressCursor) {
26677
- progressCursor = nextProgress;
26678
- if (!suppressScreen) update({ generateProgress: nextProgress });
26679
- }
26680
- }
26681
- });
26682
- const result = await donePromise;
26683
- if (result.exitCode !== 0) {
26684
- finishWizardTimer("component-generation", timer, {
26685
- status: "error",
26686
- exitCode: result.exitCode
26687
- });
26688
- finishSelectionToReviewTimer("error");
26689
- update({
26690
- step: "error",
26691
- errorStep: "generate components",
26692
- errorMessage: result.stderr.trim() || "Unknown error"
26693
- });
26694
- return;
26695
- }
26696
- const { generateSessionId: generateSessionId2, generatedCount, renamedSlotsCount } = parseGenerateResult(result, acceptedCount);
26697
- const mappedSessionId = generateSessionId2 ?? extractSessionId;
26698
- finishWizardTimer("component-generation", timer, {
26699
- status: "complete",
26700
- exitCode: result.exitCode,
26701
- generatedCount,
26702
- renamedSlotsCount
26703
- });
26704
- if (!suppressScreen) {
26705
- update({
26706
- acceptedCount,
26707
- autoRejectedCount: 0,
26708
- generateSessionId: mappedSessionId,
26709
- generatedCount,
26710
- generateProgress: null
26711
- });
26712
- if (await runMapTokens2(mappedSessionId)) {
26713
- finishSelectionToReviewTimer("generated");
26714
- update({ step: "final-review" });
26715
- } else {
26716
- finishSelectionToReviewTimer("error");
26717
- }
26718
- return;
26719
- }
26720
- const mapped = await runMapTokens2(mappedSessionId, true);
26721
- if (mapped) {
26722
- finishSelectionToReviewTimer("generated");
26723
- update(
26724
- {
26725
- acceptedCount,
26726
- autoRejectedCount: 0,
26727
- generateSessionId: mappedSessionId,
26728
- generatedCount,
26729
- generateProgress: null,
26730
- mapTokensStatus: "complete",
26731
- step: "final-review"
26732
- },
26733
- { clearScreen: false }
26734
- );
26735
- } else {
26736
- finishSelectionToReviewTimer("error");
26737
- }
26738
- };
26739
- const finishCachedGeneration = async (sessionId2, acceptedCount) => {
26740
- if (await runMapTokens2(sessionId2, true)) {
26741
- finishSelectionToReviewTimer("cached");
26742
- update(
26743
- {
26744
- acceptedCount,
26745
- autoRejectedCount: 0,
26746
- generateSessionId: sessionId2,
26747
- generatedCount: acceptedCount,
26748
- generateProgress: null,
26749
- mapTokensStatus: "complete",
26750
- step: "final-review"
26751
- },
26752
- { clearScreen: false }
26753
- );
26754
- } else {
26755
- finishSelectionToReviewTimer("error");
26756
- }
26757
- };
26758
26085
  const advanceToPushFlow = (generatedAcceptedCount) => {
26759
26086
  update({ generatedAcceptedCount });
26760
26087
  void runSaveAndPush();
@@ -26767,140 +26094,22 @@ If you are using AWS Bedrock, run:
26767
26094
  const { extractSessionId: sid, tokensPath: tp } = sessionRef.current;
26768
26095
  void runPreview(sid, tp, state.spaceId, state.environmentId, state.cmaToken, state.host);
26769
26096
  };
26770
- const confirmScope = async (decisions, handedOffCachedNames) => {
26771
- const sessionId2 = sessionRef.current.extractSessionId;
26772
- if (!sessionId2) {
26773
- update({
26774
- step: "error",
26775
- errorStep: "start import",
26776
- errorMessage: "Internal error: the CLI did not hand over an extract session."
26777
- });
26778
- return;
26779
- }
26780
- selectionToReviewStartedAtRef.current = decisions.accepted.length > 0 ? startWizardTimer("selection-to-review", {
26781
- sessionId: sessionId2,
26782
- acceptedCount: decisions.accepted.length,
26783
- rejectedCount: decisions.rejected.length
26784
- }) : null;
26785
- const cachePromise = Promise.resolve(new Set(handedOffCachedNames));
26786
- await runScopeGate({
26787
- sessionId: sessionId2,
26788
- decisions,
26789
- onAdvanceToGenerate: async ({ sessionId: sid, acceptedCount }) => {
26790
- scopeGateCompletedRef.current = true;
26791
- if (shouldGenerateAfterScopeGate({ acceptedCount })) {
26792
- const authPromise = runAgentAuthCheck("generating", true);
26793
- if (await authPromise) {
26794
- const comparisonStartedAt = startWizardTimer("generation-cache-set-comparison", {
26795
- sessionId: sid,
26796
- acceptedCount: decisions.accepted.length
26797
- });
26798
- let cachedNames = await cachePromise;
26799
- const acceptedNames = decisions.accepted;
26800
- let cacheHit = !effectiveNoCache && acceptedNames.length > 0 && acceptedNames.every((name) => cachedNames.has(name));
26801
- if (!cacheHit && !effectiveNoCache && acceptedNames.length > 0) {
26802
- cachedNames = await checkGenerateCacheComponents(sid, state.tokensPath, true);
26803
- cacheHit = acceptedNames.every((name) => cachedNames.has(name));
26804
- }
26805
- finishWizardTimer("generation-cache-set-comparison", comparisonStartedAt, {
26806
- status: "complete",
26807
- cacheHit,
26808
- cachedCount: cachedNames.size,
26809
- acceptedCount: acceptedNames.length
26810
- });
26811
- if (cacheHit) {
26812
- void finishCachedGeneration(sid, acceptedCount);
26813
- } else {
26814
- const acceptedNameSet = new Set(acceptedNames);
26815
- const restoredCachedNames = [...cachedNames].filter((name) => acceptedNameSet.has(name));
26816
- update({
26817
- step: "generating",
26818
- generateProgress: null,
26819
- acceptedCount
26820
- });
26821
- void runGenerate(sid, state.tokensPath, acceptedCount, false, restoredCachedNames);
26822
- }
26823
- } else {
26824
- finishSelectionToReviewTimer("error");
26825
- }
26826
- return;
26827
- }
26828
- void runSaveAndPush();
26829
- },
26830
- onAdvanceToPushFlow: (count) => {
26831
- scopeGateCompletedRef.current = true;
26832
- update({ acceptedCount: count, autoRejectedCount: 0 });
26833
- advanceToPushFlow(count);
26834
- }
26835
- });
26836
- };
26837
26097
  const advanceAfterCredentialsValidated = async () => {
26838
26098
  credentialsReadyRef.current = true;
26839
- if (!sessionRef.current.extractSessionId) {
26099
+ if (!startedFrom.ok || !startedFrom.route || !sessionRef.current.extractSessionId) {
26840
26100
  update({
26841
26101
  step: "error",
26842
26102
  errorStep: "start import",
26843
- errorMessage: "Internal error: the CLI did not hand over an extract session."
26103
+ errorMessage: "Internal error: the CLI did not hand over the generated definitions."
26844
26104
  });
26845
26105
  return;
26846
26106
  }
26847
- if (!scopeGateCompletedRef.current) {
26848
- if (!startedFrom.ok || !startedFrom.scope) {
26849
- update({
26850
- step: "error",
26851
- errorStep: "start import",
26852
- errorMessage: "Internal error: the CLI did not hand over the scope decisions."
26853
- });
26854
- return;
26855
- }
26856
- await confirmScope(startedFrom.scope.decisions, startedFrom.scope.cachedNames);
26857
- return;
26858
- }
26859
- if (shouldSkipFinalReviewAfterCredentials({
26860
- generateSessionId: state.generateSessionId,
26861
- finalReviewPassed: state.finalReviewPassed
26862
- })) {
26863
- void runSaveAndPush();
26107
+ scopeGateCompletedRef.current = true;
26108
+ if (startedFrom.route === "push") {
26109
+ advanceToPushFlow(0);
26864
26110
  return;
26865
26111
  }
26866
- if (shouldGenerateAfterCredentialsValidated({
26867
- acceptedCount: state.acceptedCount
26868
- })) {
26869
- const sid = sessionRef.current.extractSessionId;
26870
- if (!sid) {
26871
- update({
26872
- step: "error",
26873
- errorStep: "post-credentials",
26874
- errorMessage: "Internal error: extract session ID missing after credential validation."
26875
- });
26876
- return;
26877
- }
26878
- const inflight = generatePromiseRef.current;
26879
- if (inflight) {
26880
- update({ step: "generating" });
26881
- const result = await inflight;
26882
- generatePromiseRef.current = null;
26883
- if (result.exitCode === 0 && result.signal !== "SIGTERM") {
26884
- const sessionMatch = /^session=(.+)$/m.exec(result.stdout);
26885
- const generatedSessionId = sessionMatch ? sessionMatch[1].trim() : sid;
26886
- update({ generateSessionId: generatedSessionId });
26887
- if (await runMapTokens2(generatedSessionId)) update({ step: "final-review" });
26888
- return;
26889
- }
26890
- }
26891
- if (await runAgentAuthCheck("generating", true)) {
26892
- const cacheHit = await checkGenerateCache(sid, state.tokensPath);
26893
- if (cacheHit) {
26894
- update({ step: "generating" });
26895
- void finishCachedGeneration(sid, state.acceptedCount);
26896
- } else {
26897
- update({ step: "generating" });
26898
- void runGenerate(sid, state.tokensPath, state.acceptedCount);
26899
- }
26900
- }
26901
- return;
26902
- }
26903
- void runSaveAndPush();
26112
+ update({ step: "final-review" });
26904
26113
  };
26905
26114
  const runPreview = async (extractSessionId, tokensPath, spaceId, environmentId, cmaToken, host2) => {
26906
26115
  if (shouldBypassPreview(state)) {
@@ -27359,65 +26568,13 @@ If using a custom host configuration, make sure the space exists on that host.`
27359
26568
  credentialsHandedOff.current = true;
27360
26569
  void advanceAfterCredentialsValidated();
27361
26570
  }, [state.step]);
27362
- const noQuitSteps = [
27363
- "checking-claude-auth",
27364
- "validating-credentials",
27365
- "generating",
27366
- "mapping-tokens",
27367
- "printing",
27368
- "previewing",
27369
- "pushing"
27370
- ];
26571
+ const noQuitSteps = ["validating-credentials", "printing", "previewing", "pushing"];
27371
26572
  const hints = noQuitSteps.includes(state.step) ? [] : [{ key: "q", label: "quit" }];
27372
26573
  const hasTokens = !!state.tokensPath;
27373
26574
  const hasTokenStage = hasTokens || !!state.rawTokensPath;
27374
26575
  const totalSteps = 3 + (hasTokenStage ? 1 : 0) + 2 + (state.mapTokensEligible === true ? 1 : 0);
27375
26576
  const stepContent = (() => {
27376
26577
  switch (state.step) {
27377
- case "checking-claude-auth":
27378
- return /* @__PURE__ */ jsx45(
27379
- RunningStep,
27380
- {
27381
- stepNumber: state.authCheckStepNumber,
27382
- totalSteps,
27383
- title: `Checking ${state.agent}`,
27384
- description: `Verifying ${state.agent} is installed and authenticated...`
27385
- }
27386
- );
27387
- case "generating": {
27388
- const p = state.generateProgress;
27389
- const stepNum = hasTokenStage ? 4 : 3;
27390
- const displayAgent = state.agent.charAt(0).toUpperCase() + state.agent.slice(1);
27391
- const progressDetail = p ? `${p.current}` : `Starting up ${displayAgent}...`;
27392
- const mapTokensDetail = state.mapTokensStatus === "running" ? skipMapTokens ? "Resolving token defaults..." : `Mapping token restrictions via ${displayAgent}...` : state.mapTokensStatus === "complete" ? skipMapTokens ? "Token defaults ready" : "Token restrictions ready" : void 0;
27393
- return /* @__PURE__ */ jsx45(
27394
- RunningStep,
27395
- {
27396
- stepNumber: stepNum,
27397
- totalSteps,
27398
- title: "Generating definitions",
27399
- description: `${formatAcceptanceSummary({ accepted: state.acceptedCount, autoRejected: state.autoRejectedCount })}
27400
- ${displayAgent} is mapping your selected components to Contentful's Component Definition Format (CDF).${hasTokens ? " Using your design tokens for prop resolution." : ""}`,
27401
- detail: progressDetail,
27402
- detailProgress: p ? { done: p.done, total: p.total } : void 0,
27403
- secondaryDetail: mapTokensDetail,
27404
- secondaryComplete: state.mapTokensStatus === "complete"
27405
- }
27406
- );
27407
- }
27408
- case "mapping-tokens": {
27409
- const stepNum = hasTokenStage ? 5 : 4;
27410
- return /* @__PURE__ */ jsx45(
27411
- RunningStep,
27412
- {
27413
- stepNumber: stepNum,
27414
- totalSteps,
27415
- title: "Mapping design tokens",
27416
- description: "Finding the design tokens that are valid for each generated token property.",
27417
- detail: skipMapTokens ? "Resolving token defaults..." : `Running ${state.agent}...`
27418
- }
27419
- );
27420
- }
27421
26578
  case "final-review": {
27422
26579
  return /* @__PURE__ */ jsx45(
27423
26580
  GenerateReviewStep,
@@ -27657,17 +26814,12 @@ var init_WizardApp = __esm({
27657
26814
  init_slot_graph();
27658
26815
  init_error_parser();
27659
26816
  init_wizard_422_helpers();
27660
- init_wizard_generate_progress();
27661
- init_spawn_generate();
27662
26817
  init_tokens();
27663
26818
  init_preview_utils();
27664
26819
  init_db();
27665
26820
  init_GenerateReviewStep();
27666
- init_runScopeGate();
27667
- init_src();
27668
26821
  init_host_utils();
27669
26822
  init_wizard_state_transitions();
27670
- init_cli_path();
27671
26823
  init_use_terminal_size();
27672
26824
  init_render_with_goodbye();
27673
26825
  SAVE_CONFIRMATION_DELAY_MS = 1e3;
@@ -27718,7 +26870,6 @@ function registerImportCommand(program) {
27718
26870
  const parsedAgentModel = parseAgentModel(opts.agent);
27719
26871
  const resolvedAgent = resolveAgent(parsedAgentModel.agent, creds.agent);
27720
26872
  const resolvedModel = resolveModel(parsedAgentModel.model, creds.agentModel);
27721
- const initialAgentAuth = checkAgentAuth(resolvedAgent);
27722
26873
  const { waitUntilExit } = renderWithGoodbye2(
27723
26874
  createElement6(WizardApp2, {
27724
26875
  initialSpaceId: creds.spaceId,
@@ -27729,12 +26880,9 @@ function registerImportCommand(program) {
27729
26880
  ...resolvedModel ? { initialModel: resolvedModel } : {},
27730
26881
  initialProjectPath: opts.project !== "." ? normalizePath(opts.project) : void 0,
27731
26882
  ...buildCompositionForwardingOptions(opts),
27732
- noCache: opts.cache === false,
27733
- skipMapTokens: false,
27734
26883
  livePreview: true,
27735
26884
  generatePromptPath: creds.generatePromptPath,
27736
- ...opts.tokens ? { initialRawTokensPath: normalizePath(opts.tokens) } : {},
27737
- initialAgentAuth
26885
+ ...opts.tokens ? { initialRawTokensPath: normalizePath(opts.tokens) } : {}
27738
26886
  })
27739
26887
  );
27740
26888
  await waitUntilExit();
@@ -27752,7 +26900,6 @@ var init_command6 = __esm({
27752
26900
  init_host_utils();
27753
26901
  init_composition_options();
27754
26902
  init_terminal_capabilities();
27755
- init_src();
27756
26903
  }
27757
26904
  });
27758
26905
 
@@ -27802,7 +26949,7 @@ var init_agent_definitions = __esm({
27802
26949
  });
27803
26950
 
27804
26951
  // packages/experience-design-system-cli-legacy/src/setup/lib/shell.ts
27805
- import { execFile as execFile3, spawn as spawn5 } from "node:child_process";
26952
+ import { execFile as execFile2, spawn as spawn4 } from "node:child_process";
27806
26953
  import { access as access7 } from "node:fs/promises";
27807
26954
  import { promisify as promisify2 } from "node:util";
27808
26955
  async function binaryExists(name) {
@@ -27818,7 +26965,7 @@ async function pathExists3(path) {
27818
26965
  }
27819
26966
  function runSpawn(cmd, args, opts = {}) {
27820
26967
  return new Promise((resolve22) => {
27821
- const child = spawn5(cmd, args, {
26968
+ const child = spawn4(cmd, args, {
27822
26969
  cwd: opts.cwd,
27823
26970
  env: opts.env ?? process.env,
27824
26971
  stdio: ["ignore", "pipe", "pipe"]
@@ -27845,7 +26992,7 @@ var execFileAsync2, REQUIRED_NODE_MAJOR;
27845
26992
  var init_shell = __esm({
27846
26993
  "packages/experience-design-system-cli-legacy/src/setup/lib/shell.ts"() {
27847
26994
  "use strict";
27848
- execFileAsync2 = promisify2(execFile3);
26995
+ execFileAsync2 = promisify2(execFile2);
27849
26996
  REQUIRED_NODE_MAJOR = 24;
27850
26997
  }
27851
26998
  });
@@ -30207,7 +29354,7 @@ __export(program_exports, {
30207
29354
  resolveBedrockFromAncestors: () => resolveBedrockFromAncestors,
30208
29355
  runBuild: () => runBuild
30209
29356
  });
30210
- import { spawn as spawn6 } from "node:child_process";
29357
+ import { spawn as spawn5 } from "node:child_process";
30211
29358
  import { fileURLToPath as fileURLToPath4 } from "node:url";
30212
29359
  import { dirname as dirname20, join as join25, resolve as resolve21 } from "node:path";
30213
29360
  import { readFileSync as readFileSync11 } from "node:fs";
@@ -30242,7 +29389,7 @@ function registerBuildCommand(program) {
30242
29389
  const pkgRoot = resolve21(dirname20(fileURLToPath4(import.meta.url)), "..", "..");
30243
29390
  process.stderr.write("\u2699 Building from source...\n");
30244
29391
  const { exitCode } = await runBuild({
30245
- spawnFn: () => spawn6("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),
29392
+ spawnFn: () => spawn5("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),
30246
29393
  stderrWrite: (s) => process.stderr.write(s)
30247
29394
  });
30248
29395
  process.exit(exitCode);